From 13a7a8fa6944726a94dca5e3e9ab075e2d739dde Mon Sep 17 00:00:00 2001 From: Pavel Smirnov Date: Wed, 17 Jan 2018 13:11:52 +0300 Subject: [PATCH] 0.7.11 --- CHANGELOG.md | 9 +- dist/Miew.js | 942 +++++++++++++++++++-------------------- dist/Miew.min.js | 22 +- dist/Miew.module.js | 942 +++++++++++++++++++-------------------- package.json | 2 +- sonar-project.properties | 2 +- 6 files changed, 962 insertions(+), 957 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d92883..4c81cb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.7.11] - 2018-01-17 +### Fixed +- Fixed a loading error in IE11 when a relative URL is used. +- Fixed an FBX export. +- Renamed files and classes to match and fixed other code smells found by SonarCloud. + ## [0.7.10] - 2017-12-25 ### Added - Add more unit tests for loaders. @@ -193,7 +199,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.10...HEAD +[Unreleased]: https://github.com/epam/miew/compare/v0.7.11...HEAD +[0.7.11]: https://github.com/epam/miew/compare/v0.7.10...v0.7.11 [0.7.10]: https://github.com/epam/miew/compare/v0.7.9...v0.7.10 [0.7.9]: https://github.com/epam/miew/compare/v0.7.8...v0.7.9 [0.7.8]: https://github.com/epam/miew/compare/v0.7.7...v0.7.8 diff --git a/dist/Miew.js b/dist/Miew.js index af2c47df..02c4be08 100644 --- a/dist/Miew.js +++ b/dist/Miew.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.10 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.11 Copyright (c) 2015-2018 EPAM Systems, Inc. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -62053,12 +62053,17 @@ function getUrlParametersAsDict(url) { function resolveURL(str) { if (typeof URL !== 'undefined') { - if (typeof window !== 'undefined') { - return new URL(str, window.location).href; - } else { - return new URL(str).href; + try { + if (typeof window !== 'undefined') { + return new URL(str, window.location).href; + } else { + return new URL(str).href; + } + } catch (error) { + // IE 11 has a URL object with no constructor available so just try a different approach instead } - } else if (typeof document !== 'undefined') { + } + if (typeof document !== 'undefined') { var anchor = document.createElement('a'); anchor.href = str; return anchor.href; @@ -62087,7 +62092,7 @@ function generateRegExp(symbolStr) { //////////////////////////////////////////////////////////////////////////// // Create HTML element -function createElement$2(tag, attrs, content) { +function createElement(tag, attrs, content) { var element = document.createElement(tag); var i, n; if (attrs) { @@ -62441,7 +62446,7 @@ var utils = { getUrlParametersAsDict: getUrlParametersAsDict, resolveURL: resolveURL, generateRegExp: generateRegExp, - createElement: createElement$2, + createElement: createElement, deriveClass: deriveClass, deriveDeep: deriveDeep, hexColor: hexColor, @@ -64188,7 +64193,7 @@ Element.getByName = function (element) { * @exports Atom * @constructor */ -function Atom$1(residue, name, type, position, role, het, serial, location, occupancy, temperature, charge) { +function Atom(residue, name, type, position, role, het, serial, location, occupancy, temperature, charge) { this._index = -1; this._residue = residue; if (name instanceof AtomName) { @@ -64218,9 +64223,9 @@ function Atom$1(residue, name, type, position, role, het, serial, location, occu this.flags = 0x0000; if (type.name === 'H') { - this.flags |= Atom$1.Flags.HYDROGEN; + this.flags |= Atom.Flags.HYDROGEN; } else if (type.name === 'C') { - this.flags |= Atom$1.Flags.CARBON; + this.flags |= Atom.Flags.CARBON; } } @@ -64230,7 +64235,7 @@ function Atom$1(residue, name, type, position, role, het, serial, location, occu * @enum {number} * @readonly */ -Atom$1.Flags = { +Atom.Flags = { CARBON: 0x0001, // OXYGEN: 0x0002, // NITROGEN: 0x0004, @@ -64243,39 +64248,39 @@ Atom$1.Flags = { * Get atom full name. * @returns {AtomName} Atom full name. */ -Atom$1.prototype.getName = function () { +Atom.prototype.getName = function () { return this._name; }; -Atom$1.prototype.getPosition = function () { +Atom.prototype.getPosition = function () { return this._position; }; -Atom$1.prototype.getResidue = function () { +Atom.prototype.getResidue = function () { return this._residue; }; -Atom$1.prototype.getSerial = function () { +Atom.prototype.getSerial = function () { return this._serial; }; -Atom$1.prototype.getBonds = function () { +Atom.prototype.getBonds = function () { return this._bonds; }; -Atom$1.prototype.isHet = function () { +Atom.prototype.isHet = function () { return this._het; }; -Atom$1.prototype.isHydrogen = function () { +Atom.prototype.isHydrogen = function () { return this.element.number === 1; }; -Atom$1.prototype.getValence = function () { +Atom.prototype.getValence = function () { return this._valence === -1 ? 0 : this._valence; }; -Atom$1.prototype.getVisualName = function () { +Atom.prototype.getVisualName = function () { var name = this.getName(); if (name.getString().length > 0) { return name.getString(); @@ -64284,7 +64289,7 @@ Atom$1.prototype.getVisualName = function () { } }; -Atom$1.prototype.forEachBond = function (process) { +Atom.prototype.forEachBond = function (process) { var bonds = this._bonds; for (var i = 0, n = bonds.length; i < n; ++i) { process(bonds[i]); @@ -64292,7 +64297,7 @@ Atom$1.prototype.forEachBond = function (process) { }; /** @deprecated Old-fashioned atom labels, to be removed in the next major version. */ -Atom$1.prototype.isLabelVisible = function () { +Atom.prototype.isLabelVisible = function () { if (this.getName().getNode() !== null) { return true; } @@ -64312,7 +64317,7 @@ Atom$1.prototype.isLabelVisible = function () { return true; }; -Atom$1.prototype.getHydrogenCountBoron = function () { +Atom.prototype.getHydrogenCountBoron = function () { //examples //BH3*BH4(1-)*BH2(1+)*BH3(2-)*BH(2+) var valence = 3; //hardcoded as 3 @@ -64320,7 +64325,7 @@ Atom$1.prototype.getHydrogenCountBoron = function () { return Math.max(0, hc); }; -Atom$1.prototype.getHydrogenCountTin = function () { +Atom.prototype.getHydrogenCountTin = function () { var valence = this._valence; if (valence === -1) { valence = this.getAtomBondsCount() - Math.abs(this.getCharge()) + this._radicalCount; @@ -64334,11 +64339,11 @@ Atom$1.prototype.getHydrogenCountTin = function () { return Math.max(0, defVal - valence); }; -Atom$1.prototype.getHydrogenCountMetal = function () { +Atom.prototype.getHydrogenCountMetal = function () { return 0; }; -Atom$1.prototype.getHydrogenCountGroup14 = function () { +Atom.prototype.getHydrogenCountGroup14 = function () { var valence = this._valence; if (valence === -1) { valence = this.getAtomBondsCount() - Math.abs(this.getCharge()) + this._radicalCount; @@ -64349,7 +64354,7 @@ Atom$1.prototype.getHydrogenCountGroup14 = function () { return Math.max(0, defVal - valence); }; -Atom$1.prototype.getHydrogenCountNonMetal = function () { +Atom.prototype.getHydrogenCountNonMetal = function () { // apply from Reaxys Drawing Guidelines (Version 2.04 // January 2012) Standard Valence – (Valence + Charge + Number of Radical(s)) var valence = this._valence; @@ -64362,7 +64367,7 @@ Atom$1.prototype.getHydrogenCountNonMetal = function () { return Math.max(0, defVal - valence); }; -Atom$1.prototype.getHydrogenCountHydrogen = function () { +Atom.prototype.getHydrogenCountHydrogen = function () { if (this.getAtomBondsCount() === 0 && this.getCharge() === 0 && this.getValence() === 0 && this._radicalCount === 0) { return 1; } @@ -64370,7 +64375,7 @@ Atom$1.prototype.getHydrogenCountHydrogen = function () { return 0; }; -Atom$1.prototype.getHydrogenCount = function () { +Atom.prototype.getHydrogenCount = function () { if (this._hydrogenCount >= 0) { return this._hydrogenCount; } @@ -64437,7 +64442,7 @@ function getCylinderCount(bondOrder) { return bondOrder < 2 ? 1 : bondOrder; } -Atom$1.prototype.getAtomBondsCount = function () { +Atom.prototype.getAtomBondsCount = function () { var explicitBonds = this.getBonds(); var ebCount = 0; for (var i = 0; i < explicitBonds.length; i++) { @@ -64446,7 +64451,7 @@ Atom$1.prototype.getAtomBondsCount = function () { return ebCount; }; -Atom$1.prototype.findSuitableValence = function (valence) { +Atom.prototype.findSuitableValence = function (valence) { var val = this.element.hydrogenValency; var defVal = val[val.length - 1]; for (var i = 0; i < val.length; i++) { @@ -64458,15 +64463,15 @@ Atom$1.prototype.findSuitableValence = function (valence) { return defVal; }; -Atom$1.prototype.getCharge = function () { +Atom.prototype.getCharge = function () { return this._charge; }; -Atom$1.prototype.getLocation = function () { +Atom.prototype.getLocation = function () { return this._location; }; -Atom$1.prototype.getFullName = function () { +Atom.prototype.getFullName = function () { var name = ''; if (this._residue !== null) { if (this._residue._chain !== null) { @@ -64871,7 +64876,7 @@ var cCylinderTarget = [{ * @exports Residue * @constructor */ -function Residue$1(chain, type, sequence, icode) { +function Residue(chain, type, sequence, icode) { this._chain = chain; this._component = null; this._type = type; @@ -64896,34 +64901,34 @@ function Residue$1(chain, type, sequence, icode) { } // Getters and setters -Residue$1.prototype.getChain = function () { +Residue.prototype.getChain = function () { return this._chain; }; -Residue$1.prototype.getMolecule = function () { +Residue.prototype.getMolecule = function () { return this._molecule; }; -Residue$1.prototype.getType = function () { +Residue.prototype.getType = function () { return this._type; }; -Residue$1.prototype.getSequence = function () { +Residue.prototype.getSequence = function () { return this._sequence; }; -Residue$1.prototype.getSecondary = function () { +Residue.prototype.getSecondary = function () { return this._secondary; }; -Residue$1.prototype.getICode = function () { +Residue.prototype.getICode = function () { return this._icode; }; // Other methods -Residue$1.prototype.addAtom = function (name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge) { - var atom = new Atom$1(this, name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge); +Residue.prototype.addAtom = function (name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge) { + var atom = new Atom(this, name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge); var complex = this._chain.getComplex(); complex.addAtom(atom); this._atoms.push(atom); // TODO: change to range @@ -64931,11 +64936,11 @@ Residue$1.prototype.addAtom = function (name, type, xyz, role, het, serial, altL return atom; }; -Residue$1.prototype.getAtomCount = function () { +Residue.prototype.getAtomCount = function () { return this._atoms.length; }; -Residue$1.prototype.forEachAtom = function (process) { +Residue.prototype.forEachAtom = function (process) { var atoms = this._atoms; for (var i = 0, n = atoms.length; i < n; ++i) { if (process(atoms[i])) { @@ -64944,7 +64949,7 @@ Residue$1.prototype.forEachAtom = function (process) { } }; -Residue$1.prototype._findAtomByName = function (name) { +Residue.prototype._findAtomByName = function (name) { var res = null; this.forEachAtom(function (atom) { if (atom._name._name === name) { @@ -64956,7 +64961,7 @@ Residue$1.prototype._findAtomByName = function (name) { return res; }; -Residue$1.prototype._findFirstAtomInList = function (names) { +Residue.prototype._findFirstAtomInList = function (names) { var res = null; for (var i = 0; i < names.length; ++i) { res = this._findAtomByName(names[i]); @@ -64967,7 +64972,7 @@ Residue$1.prototype._findFirstAtomInList = function (names) { return res; }; -Residue$1.prototype.collectMask = function () { +Residue.prototype.collectMask = function () { var mask = 0xffffffff; var atoms = this._atoms; for (var i = 0, n = atoms.length; i < n; ++i) { @@ -64976,7 +64981,7 @@ Residue$1.prototype.collectMask = function () { this._mask = mask; }; -Residue$1.prototype.getCylinderTargetList = function () { +Residue.prototype.getCylinderTargetList = function () { var type = this._type._name; for (var i = 0, n = cCylinderTarget.length; i < n; ++i) { for (var j = 0, m = cCylinderTarget[i].types.length; j < m; ++j) { @@ -64988,7 +64993,7 @@ Residue$1.prototype.getCylinderTargetList = function () { return null; }; -Residue$1.prototype._detectLeadWing = function (dst, next, getAtomPosition) { +Residue.prototype._detectLeadWing = function (dst, next, getAtomPosition) { var leadAtom = this._findFirstAtomInList(cNucleicControlNames); var wingStart = this._findFirstAtomInList(cNucleicWing1Names); var wingEnd = this._findFirstAtomInList(cNucleicWing2Names); @@ -65019,7 +65024,7 @@ Residue$1.prototype._detectLeadWing = function (dst, next, getAtomPosition) { dst._cylinders = [getAtomPosition(cylSource), getAtomPosition(cylTarget)]; }; -Residue$1.prototype.calcWing = function (prevLeadPos, currLeadPos, prevWingPos, prevWing) { +Residue.prototype.calcWing = function (prevLeadPos, currLeadPos, prevWingPos, prevWing) { var vectorA = currLeadPos.clone().sub(prevLeadPos); var vectorB = prevLeadPos.clone().sub(prevWingPos); vectorB.crossVectors(vectorA, vectorB); @@ -65030,7 +65035,7 @@ Residue$1.prototype.calcWing = function (prevLeadPos, currLeadPos, prevWingPos, return vectorB; }; -Residue$1.prototype._innerFinalize = function (prevRes, prev, nextRes, dst, getAtomPosition) { +Residue.prototype._innerFinalize = function (prevRes, prev, nextRes, dst, getAtomPosition) { var bFirstInChain = prev === null; var lp = getAtomPosition(this._leadAtom); @@ -65050,14 +65055,14 @@ Residue$1.prototype._innerFinalize = function (prevRes, prev, nextRes, dst, getA dst._controlPoint = currLeadPos; }; -Residue$1.prototype._finalize2 = function (prev, next) { +Residue.prototype._finalize2 = function (prev, next) { //Should be called AFTER first finalize this._innerFinalize(prev, prev, next, this, function (atom) { return atom._position; }); }; -Residue$1.prototype.isConnected = function (anotherResidue) { +Residue.prototype.isConnected = function (anotherResidue) { if (this._chain !== anotherResidue._chain) { return false; } @@ -65079,7 +65084,7 @@ Residue$1.prototype.isConnected = function (anotherResidue) { return res; }; -Residue$1.prototype._finalize = function () { +Residue.prototype._finalize = function () { var self = this; this._firstAtom = this._atoms[0]; this._lastAtom = this._atoms[this._atoms.length - 1]; @@ -65126,7 +65131,7 @@ Residue$1.prototype._finalize = function () { * @exports Chain * @constructor */ -function Chain$1(complex, name) { +function Chain(complex, name) { this._complex = complex; this._name = name; this._mask = 1 | 0; @@ -65138,15 +65143,15 @@ function Chain$1(complex, name) { this.maxSequence = Number.NEGATIVE_INFINITY; } -Chain$1.prototype.getComplex = function () { +Chain.prototype.getComplex = function () { return this._complex; }; -Chain$1.prototype.getName = function () { +Chain.prototype.getName = function () { return this._name; }; -Chain$1.prototype.getResidues = function () { +Chain.prototype.getResidues = function () { return this._residues; }; @@ -65156,7 +65161,7 @@ Chain$1.prototype.getResidues = function () { * @param {string} iCode insertion code * @returns {*} Residue or null if not found */ -Chain$1.prototype.findResidue = function (seqNum, iCode) { +Chain.prototype.findResidue = function (seqNum, iCode) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -65169,7 +65174,7 @@ Chain$1.prototype.findResidue = function (seqNum, iCode) { return null; }; -Chain$1.prototype._finalize = function () { +Chain.prototype._finalize = function () { var residues = this._residues; var prev = null; @@ -65193,7 +65198,7 @@ Chain$1.prototype._finalize = function () { } }; -Chain$1.prototype.updateToFrame = function (frameData) { +Chain.prototype.updateToFrame = function (frameData) { var residues = this._residues; var prev = null; var prevData = null; @@ -65222,12 +65227,12 @@ Chain$1.prototype.updateToFrame = function (frameData) { * @param {string} iCode - Insertion code. * @returns {Residue} - Newly created residue instance. */ -Chain$1.prototype.addResidue = function (name, sequence, iCode) { +Chain.prototype.addResidue = function (name, sequence, iCode) { var type = this._complex.getResidueType(name); if (type === null) { type = this._complex.addResidueType(name); } - var residue = new Residue$1(this, type, sequence, iCode); + var residue = new Residue(this, type, sequence, iCode); this._complex.addResidue(residue); this._residues.push(residue); // TODO: change to range @@ -65243,18 +65248,18 @@ Chain$1.prototype.addResidue = function (name, sequence, iCode) { return residue; }; -Chain$1.prototype.getResidueCount = function () { +Chain.prototype.getResidueCount = function () { return this._residues.length; }; -Chain$1.prototype.forEachResidue = function (process) { +Chain.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Chain$1.prototype.collectMask = function () { +Chain.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -65299,7 +65304,7 @@ Helix.prototype.getName = function () { }; Helix.prototype._finalize = function (residueHash, complex) { - if (this._start instanceof Residue$1 && this._end instanceof Residue$1) { + if (this._start instanceof Residue && this._end instanceof Residue) { // no need to convert unified serial numbers to actual references return; } @@ -65366,7 +65371,7 @@ Strand.prototype.getStart = function () { }; Strand.prototype._finalize = function (serialAtomMap, residueHash, complex) { - if (this._start instanceof Residue$1 && this._end instanceof Residue$1) { + if (this._start instanceof Residue && this._end instanceof Residue) { // no need to convert unified serial numbers to actual references return; } @@ -66961,7 +66966,7 @@ defineSelector('PolarH', function (_Selector3) { createClass(PolarHSelector, [{ key: 'includesAtom', value: function includesAtom(atom) { - return (atom.flags & Atom$1.Flags.NONPOLARH) === Atom$1.Flags.HYDROGEN; + return (atom.flags & Atom.Flags.NONPOLARH) === Atom.Flags.HYDROGEN; } }]); return PolarHSelector; @@ -66978,7 +66983,7 @@ defineSelector('NonPolarH', function (_Selector4) { createClass(NonPolarHSelector, [{ key: 'includesAtom', value: function includesAtom(atom) { - return (atom.flags & Atom$1.Flags.NONPOLARH) === Atom$1.Flags.NONPOLARH; + return (atom.flags & Atom.Flags.NONPOLARH) === Atom.Flags.NONPOLARH; } }]); return NonPolarHSelector; @@ -67175,38 +67180,38 @@ defineOperator('Or', 3, function (_InfixOperator2) { ////////////////////////////////////////////////////////////////////////////// -var selectors$1 = Object.create(keywords); +var selectors = Object.create(keywords); // TODO: Provide consistent module exports -selectors$1.Selector = Selector; -selectors$1.RangeListSelector = RangeListSelector; -selectors$1.ValueListSelector = ValueListSelector; -selectors$1.Range = Range; -selectors$1.RangeList = RangeList; -selectors$1.ValueList = ValueList; -selectors$1.PrefixOperator = PrefixOperator; -selectors$1.InfixOperator = InfixOperator; -selectors$1.Context = Object.create({}); - -selectors$1.GetSelector = function (key) { - if (!selectors$1.Context.hasOwnProperty(key)) { +selectors.Selector = Selector; +selectors.RangeListSelector = RangeListSelector; +selectors.ValueListSelector = ValueListSelector; +selectors.Range = Range; +selectors.RangeList = RangeList; +selectors.ValueList = ValueList; +selectors.PrefixOperator = PrefixOperator; +selectors.InfixOperator = InfixOperator; +selectors.Context = Object.create({}); + +selectors.GetSelector = function (key) { + if (!selectors.Context.hasOwnProperty(key)) { var exc = { message: 'selector ' + key + ' is not registered' }; throw exc; } - return selectors$1.Context[key] || NULL_SELECTOR; + return selectors.Context[key] || NULL_SELECTOR; }; -selectors$1.ClearContext = function () { - Object.keys(selectors$1.Context).forEach(function (k) { - delete selectors$1.Context[k]; +selectors.ClearContext = function () { + Object.keys(selectors.Context).forEach(function (k) { + delete selectors.Context[k]; }); }; -selectors$1.keyword = function (key) { +selectors.keyword = function (key) { return keywords[key.toLowerCase()] || keywords.none; }; -selectors$1.parse = function (str) { +selectors.parse = function (str) { var res = {}; try { res.selector = SelectionParser_1.parse(str); @@ -67217,7 +67222,7 @@ selectors$1.parse = function (str) { return res; }; -SelectionParser_1.yy = selectors$1; +SelectionParser_1.yy = selectors; SelectionParser_1.yy.parseError = SelectionParser_1.parseError; // FIXME: workaround for incorrect JISON parser generator for AMD module ////////////////////////////////////////////////////////////////////////////// @@ -67231,7 +67236,7 @@ SelectionParser_1.yy.parseError = SelectionParser_1.parseError; // FIXME: workar */ function BioStructure(complex) { this._complex = complex; - this._selector = selectors$1.keyword('All')(); + this._selector = selectors.keyword('All')(); this._boundaries = { boundingBox: new Box3(), boundingSphere: new Sphere() @@ -67354,9 +67359,9 @@ Assembly.prototype.getTransforms = function () { Assembly.prototype.finalize = function () { if (this.chains.length > 0) { - this._selector = selectors$1.keyword('Chain')(this.chains); + this._selector = selectors.keyword('Chain')(this.chains); } else { - this._selector = selectors$1.keyword('None')(); + this._selector = selectors.keyword('None')(); } }; @@ -67551,7 +67556,7 @@ var cInvalidVal = -1; // 89237 is a large simple number, can be used for pseudo random hash code create var cBigPrime = 89237; -function PairCollection(maxPairsEstimate) { +function AtomPairs(maxPairsEstimate) { var i = 0; this.numPairs = 0; @@ -67569,7 +67574,7 @@ function PairCollection(maxPairsEstimate) { /** * Destroy all pairs memory */ -PairCollection.prototype.destroy = function () { +AtomPairs.prototype.destroy = function () { this.intBuffer = null; this.hashBuffer = null; }; @@ -67579,7 +67584,7 @@ PairCollection.prototype.destroy = function () { * @param {number} indexA - Index of the 1st vertex. * @param {number} indexB - Index of the 2nd vertex. */ -PairCollection.prototype.addPair = function (indexA, indexB) { +AtomPairs.prototype.addPair = function (indexA, indexB) { var ia = indexA < indexB ? indexA : indexB; var ib = indexA > indexB ? indexA : indexB; var codeToAdd = ia + (ib << cMaxNeighbours); @@ -67866,7 +67871,7 @@ AutoBond.prototype._buildInner = function () { this._calcBoundingBox(); var volMap = this._buildGridMap(); - this._pairCollection = new PairCollection(atoms.length * cEstBondsMultiplier); + this._pairCollection = new AtomPairs(atoms.length * cEstBondsMultiplier); this._addExistingPairs(); this._findPairs(volMap); this._addPairs(); @@ -68331,7 +68336,7 @@ Complex.prototype.getAtomByFullname = function (fullName) { * @returns {Chain} - Newly created chain. */ Complex.prototype.addChain = function (name) { - var result = new Chain$1(this, name); + var result = new Chain(this, name); this._chains.push(result); // TODO: keep chains in dictionary with an (ordered?) array of keys return result; }; @@ -68710,7 +68715,7 @@ Complex.prototype.buildChemicalFormula = function () { //now join the same parts var i = formulaParts.length - 1; var j = formulaParts.length - 2; - for (; i >= 0 && j >= 0;) { + while (i >= 0 && j >= 0) { var pi = formulaParts[i]; var pj = formulaParts[j]; if (!(pi.owner instanceof Complex || pi.owner instanceof Component)) { @@ -69011,11 +69016,11 @@ Complex.prototype.finalize = function (opts) { // mark non-polar hydrogens for (i = 0, n = atoms.length; i < n; ++i) { var atom = atoms[i]; - if (atom.flags & Atom$1.Flags.HYDROGEN && atom._bonds.length === 1) { + if (atom.flags & Atom.Flags.HYDROGEN && atom._bonds.length === 1) { var _bond = atom._bonds[0]; var other = _bond._left !== atom && _bond._left || _bond._right; - if (other.flags & Atom$1.Flags.CARBON) { - atom.flags |= Atom$1.Flags.NONPOLARH; + if (other.flags & Atom.Flags.CARBON) { + atom.flags |= Atom.Flags.NONPOLARH; } } } @@ -69088,7 +69093,7 @@ Complex.prototype.markAtoms = function (selector, mask) { var setMask = mask; var clearMask = ~setMask; var count = 0; - var totalSelector = selectors$1.keyword('And')(selector, this.getSelector()); + var totalSelector = selectors.keyword('And')(selector, this.getSelector()); this.forEachAtom(function (atom) { if (totalSelector.includesAtom(atom)) { @@ -69933,7 +69938,7 @@ VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, di * @exports Molecule * @constructor */ -function Molecule$1(complex, name, index) { +function Molecule(complex, name, index) { this._complex = complex; this._name = name || ''; this._residues = []; @@ -69941,30 +69946,30 @@ function Molecule$1(complex, name, index) { this._index = index || -1; // start with 1 } -Molecule$1.prototype.getComplex = function () { +Molecule.prototype.getComplex = function () { return this._complex; }; -Molecule$1.prototype.getName = function () { +Molecule.prototype.getName = function () { return this._name; }; -Molecule$1.prototype.getResidues = function () { +Molecule.prototype.getResidues = function () { return this._residues; }; -Molecule$1.prototype.getIndex = function () { +Molecule.prototype.getIndex = function () { return this._index; }; -Molecule$1.prototype.forEachResidue = function (process) { +Molecule.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Molecule$1.prototype.collectMask = function () { +Molecule.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -69974,13 +69979,13 @@ Molecule$1.prototype.collectMask = function () { }; var chem = { - Atom: Atom$1, + Atom: Atom, Element: Element, AtomName: AtomName, Bond: Bond, - Residue: Residue$1, + Residue: Residue, ResidueType: ResidueType, - Chain: Chain$1, + Chain: Chain, Helix: Helix, Strand: Strand, Sheet: Sheet, @@ -69989,8 +69994,8 @@ var chem = { Complex: Complex, Volume: Volume, VoxelWorld: VoxelWorld, - selectors: selectors$1, - Molecule: Molecule$1 + selectors: selectors, + Molecule: Molecule }; /** @@ -70843,19 +70848,19 @@ CollisionSphere.prototype.raycast = function () { ////////////////////////////////////////////////////////////////////////////// -function CollisionSpheresGeo(count) { +function SphereCollisionGeo(count) { this._objects = new Array(count); this.boundingSphere = null; this.boundingBox = null; } -CollisionSpheresGeo.constructor = CollisionSpheresGeo; +SphereCollisionGeo.constructor = SphereCollisionGeo; -CollisionSpheresGeo.prototype.setSphere = function (idx, position, radius) { +SphereCollisionGeo.prototype.setSphere = function (idx, position, radius) { this._objects[idx] = new CollisionSphere(position, radius); }; -CollisionSpheresGeo.prototype.raycast = function (raycaster, intersects) { +SphereCollisionGeo.prototype.raycast = function (raycaster, intersects) { // TODO raycast with bounding sphere? How to deal with updates? for (var i = 0, n = this._objects.length; i < n; ++i) { var inters = this._objects[i].raycast(raycaster); @@ -70866,7 +70871,7 @@ CollisionSpheresGeo.prototype.raycast = function (raycaster, intersects) { } }; -CollisionSpheresGeo.prototype.computeBoundingBox = function () { +SphereCollisionGeo.prototype.computeBoundingBox = function () { var objects = this._objects; var boundingBox = this.boundingBox; if (boundingBox === null) { @@ -70878,7 +70883,7 @@ CollisionSpheresGeo.prototype.computeBoundingBox = function () { } }; -CollisionSpheresGeo.prototype.computeBoundingSphere = function () { +SphereCollisionGeo.prototype.computeBoundingSphere = function () { this.computeBoundingBox(); var objects = this._objects; var boundingBox = this.boundingBox; @@ -70919,13 +70924,13 @@ function setArrayXYZW(arr, idx, x, y, z, w) { function InstancedSpheresGeometry(spheresCount, sphereComplexity, useZSprites) { InstancedBufferGeometry.call(this); - CollisionSpheresGeo.call(this, spheresCount); + SphereCollisionGeo.call(this, spheresCount); this._sphGeometry = useZSprites ? new PlaneBufferGeometry(2, 2, 1, 1) : new SphereBufferGeometry(1, sphereComplexity * 2, sphereComplexity, 0, Math.PI * 2, 0, Math.PI); this._init(spheresCount, this._sphGeometry); } InstancedSpheresGeometry.prototype = Object.create(InstancedBufferGeometry.prototype); -lodash.mixin(InstancedSpheresGeometry.prototype, CollisionSpheresGeo.prototype); +lodash.mixin(InstancedSpheresGeometry.prototype, SphereCollisionGeo.prototype); InstancedSpheresGeometry.prototype.constructor = InstancedSpheresGeometry; InstancedSpheresGeometry.prototype.setItem = function (itemIdx, itemPos, itemRad) { @@ -70991,14 +70996,14 @@ InstancedSpheresGeometry.prototype._init = function (spheresCount, sphereGeo) { * THREE.BufferGeometry. * @constructor */ -function RaycastableObjectsGeometry() { +function RaycastableBufferGeometry() { BufferGeometry.call(this); } -RaycastableObjectsGeometry.prototype = Object.create(BufferGeometry.prototype); -RaycastableObjectsGeometry.prototype.constructor = RaycastableObjectsGeometry; +RaycastableBufferGeometry.prototype = Object.create(BufferGeometry.prototype); +RaycastableBufferGeometry.prototype.constructor = RaycastableBufferGeometry; -RaycastableObjectsGeometry.prototype.raycast = function () { +RaycastableBufferGeometry.prototype.raycast = function () { // This method was copied from three.js var vA = new Vector3(); var vB = new Vector3(); @@ -71098,7 +71103,7 @@ RaycastableObjectsGeometry.prototype.raycast = function () { }(); var MAX_IDC_16BIT = 65535; -var VEC_SIZE$1 = 3; +var VEC_SIZE = 3; var tmpColor$1 = new Color(); /** @@ -71108,7 +71113,7 @@ var tmpColor$1 = new Color(); * @constructor */ function ChunkedObjectsGeometry(chunkGeo, chunksCount) { - RaycastableObjectsGeometry.call(this); + RaycastableBufferGeometry.call(this); if (this.constructor === ChunkedObjectsGeometry) { throw new Error('Can not instantiate abstract class!'); @@ -71119,7 +71124,7 @@ function ChunkedObjectsGeometry(chunkGeo, chunksCount) { this._init(chunkGeo, chunksCount); } -ChunkedObjectsGeometry.prototype = Object.create(RaycastableObjectsGeometry.prototype); +ChunkedObjectsGeometry.prototype = Object.create(RaycastableBufferGeometry.prototype); ChunkedObjectsGeometry.prototype.constructor = ChunkedObjectsGeometry; ChunkedObjectsGeometry.prototype.startUpdate = function () { @@ -71137,7 +71142,7 @@ ChunkedObjectsGeometry.prototype.setColor = function (chunkIdx, colorVal) { var colors = this._colors; var chunkSize = this._chunkSize; for (var i = chunkIdx * chunkSize, end = i + chunkSize; i < end; ++i) { - var idx = i * VEC_SIZE$1; + var idx = i * VEC_SIZE; colors[idx] = tmpColor$1.r; colors[idx + 1] = tmpColor$1.g; colors[idx + 2] = tmpColor$1.b; @@ -71162,7 +71167,7 @@ ChunkedObjectsGeometry.prototype.setOpacity = function (chunkIndices, value) { ChunkedObjectsGeometry.prototype.raycast = function (raycaster, intersects) { var inters = []; - RaycastableObjectsGeometry.prototype.raycast.call(this, raycaster, inters); + RaycastableBufferGeometry.prototype.raycast.call(this, raycaster, inters); // TODO faceIdx to chunkIdx var facesPerChunk = this._chunkGeo.index.count / 3; for (var i = 0, n = inters.length; i < n; ++i) { @@ -71187,7 +71192,7 @@ ChunkedObjectsGeometry.prototype.getSubset = function (chunkIndices) { var dstNorm = geom._normals; var dstColor = geom._colors; - var chunkSize = this._chunkSize * VEC_SIZE$1; + var chunkSize = this._chunkSize * VEC_SIZE; for (var i = 0, n = chunkIndices.length; i < n; ++i) { var dstPtOffset = i * chunkSize; @@ -71211,9 +71216,9 @@ ChunkedObjectsGeometry.prototype._init = function (chunkGeo, chunksCount) { var use32bitIndex = pointsCount > MAX_IDC_16BIT; var indexSize = chunkIndexSize * chunksCount; var index = this._index = utils.allocateTyped(use32bitIndex ? Uint32Array : Uint16Array, indexSize); - this._positions = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE$1); - this._normals = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE$1); - this._colors = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE$1); + this._positions = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE); + this._normals = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE); + this._colors = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE); var alpha = this._alpha = utils.allocateTyped(Float32Array, pointsCount); lodash.fill(alpha, 1.0); @@ -71227,31 +71232,31 @@ ChunkedObjectsGeometry.prototype._init = function (chunkGeo, chunksCount) { } this.setIndex(new BufferAttribute(this._index, 1)); - this.addAttribute('position', new BufferAttribute(this._positions, VEC_SIZE$1)); - this.addAttribute('normal', new BufferAttribute(this._normals, VEC_SIZE$1)); - this.addAttribute('color', new BufferAttribute(this._colors, VEC_SIZE$1)); + this.addAttribute('position', new BufferAttribute(this._positions, VEC_SIZE)); + this.addAttribute('normal', new BufferAttribute(this._normals, VEC_SIZE)); + this.addAttribute('color', new BufferAttribute(this._colors, VEC_SIZE)); this.addAttribute('alphaColor', new BufferAttribute(alpha, 1)); }; -var VEC_SIZE = 3; +var VEC_SIZE$1 = 3; function SimpleSpheresGeometry(spheresCount, sphereComplexity) { var sphGeometry = new SphereBufferGeometry(1, sphereComplexity * 2, sphereComplexity, 0, Math.PI * 2, 0, Math.PI); ChunkedObjectsGeometry.call(this, sphGeometry, spheresCount); - CollisionSpheresGeo.call(this, spheresCount); + SphereCollisionGeo.call(this, spheresCount); var normals = this._normals; var geoNormals = sphGeometry.attributes.normal.array; var chunkSize = this._chunkSize; this._chunkPos = this._chunkGeo.attributes.position.array; - this._tmpPositions = utils.allocateTyped(Float32Array, chunkSize * VEC_SIZE); + this._tmpPositions = utils.allocateTyped(Float32Array, chunkSize * VEC_SIZE$1); for (var i = 0; i < spheresCount; ++i) { - normals.set(geoNormals, chunkSize * VEC_SIZE * i); + normals.set(geoNormals, chunkSize * VEC_SIZE$1 * i); } } SimpleSpheresGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); -lodash.mixin(SimpleSpheresGeometry.prototype, CollisionSpheresGeo.prototype); +lodash.mixin(SimpleSpheresGeometry.prototype, SphereCollisionGeo.prototype); SimpleSpheresGeometry.prototype.constructor = SimpleSpheresGeometry; SimpleSpheresGeometry.prototype.setItem = function (itemIdx, itemPos, itemRad) { @@ -71266,7 +71271,7 @@ SimpleSpheresGeometry.prototype.setItem = function (itemIdx, itemPos, itemRad) { tmpPos[idx + 2] = itemPos.z + geoPos[idx + 2] * itemRad; } - this._positions.set(tmpPos, chunkSize * itemIdx * VEC_SIZE); + this._positions.set(tmpPos, chunkSize * itemIdx * VEC_SIZE$1); this.setSphere(itemIdx, itemPos, itemRad); }; @@ -71276,7 +71281,7 @@ var centerPos = new Vector3(); var tmpVector = new Vector3(); var normMtx = new Matrix3(); -function Simple2CCylinderGeometry(instanceCount, polyComplexity) { +function Simple2CCylindersGeometry(instanceCount, polyComplexity) { var cylGeometry = new CylinderBufferGeometry(1, 1, 1.0, Math.max(3, polyComplexity), 2, true); ChunkedObjectsGeometry.call(this, cylGeometry, 2 * instanceCount); @@ -71286,10 +71291,10 @@ function Simple2CCylinderGeometry(instanceCount, polyComplexity) { this._tmpVector = utils.allocateTyped(Float32Array, chunkSize * VEC_SIZE$2); } -Simple2CCylinderGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); -Simple2CCylinderGeometry.prototype.constructor = Simple2CCylinderGeometry; +Simple2CCylindersGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); +Simple2CCylindersGeometry.prototype.constructor = Simple2CCylindersGeometry; -Simple2CCylinderGeometry.prototype.setItem = function (itemIdx, botPos, topPos, itemRad) { +Simple2CCylindersGeometry.prototype.setItem = function (itemIdx, botPos, topPos, itemRad) { var chunkSize = this._chunkSize; var firstOffset = chunkSize * 2 * itemIdx * VEC_SIZE$2; var secondOffset = firstOffset + chunkSize * VEC_SIZE$2; @@ -71332,7 +71337,7 @@ Simple2CCylinderGeometry.prototype.setItem = function (itemIdx, botPos, topPos, this._normals.set(tmpArray, secondOffset); }; -Simple2CCylinderGeometry.prototype.setColor = function (itemIdx, colorVal1, colorVal2) { +Simple2CCylindersGeometry.prototype.setColor = function (itemIdx, colorVal1, colorVal2) { var first = 2 * itemIdx; parentSetColor.call(this, first, colorVal1); @@ -71546,7 +71551,7 @@ function Instanced2CCylindersGeometry(instanceCount, polyComplexity, useZSprites this._cylGeometry = useZSprites ? new PlaneBufferGeometry(2, 2, 1, 1) : new CylinderBufferGeometry$1(1, 1, 1.0, Math.max(3, polyComplexity), 2, openEnded); this._init(instanceCount, this._cylGeometry, this._useZSprites); - this._collisionGeo = new Simple2CCylinderGeometry(instanceCount, 3); + this._collisionGeo = new Simple2CCylindersGeometry(instanceCount, 3); } Instanced2CCylindersGeometry.prototype = Object.create(InstancedBufferGeometry.prototype); @@ -71724,7 +71729,7 @@ function _createExtrudedChunkGeometry(shape, ringsCount) { return geo; } -function ExtrudedObjectsGroup(shape, ringsCount, chunksCount) { +function ExtrudedObjectsGeometry(shape, ringsCount, chunksCount) { var chunkGeo = _createExtrudedChunkGeometry(shape, ringsCount); ChunkedObjectsGeometry.call(this, chunkGeo, chunksCount); this._ringsCount = ringsCount; @@ -71735,10 +71740,10 @@ function ExtrudedObjectsGroup(shape, ringsCount, chunksCount) { } } -ExtrudedObjectsGroup.prototype = Object.create(ChunkedObjectsGeometry.prototype); -ExtrudedObjectsGroup.prototype.constructor = ExtrudedObjectsGroup; +ExtrudedObjectsGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); +ExtrudedObjectsGeometry.prototype.constructor = ExtrudedObjectsGeometry; -ExtrudedObjectsGroup.prototype.setItem = function (itemIdx, matrices) { +ExtrudedObjectsGeometry.prototype.setItem = function (itemIdx, matrices) { var shape = this._chunkGeo._positions; var ptsCount = shape.length; var innerPtIdx = 0; @@ -72165,7 +72170,7 @@ var tmpVector$2 = new Vector3(); function TwoColorLinesGeometry(segmentsCount) { LinesGeometry.call(this, segmentsCount * 2); this._init(segmentsCount); - this._collisionGeo = new Simple2CCylinderGeometry(segmentsCount, 3); + this._collisionGeo = new Simple2CCylindersGeometry(segmentsCount, 3); } TwoColorLinesGeometry.prototype = Object.create(LinesGeometry.prototype); @@ -72225,7 +72230,7 @@ var tempPos2 = new Vector3(); function CrossGeometry(chunksCount) { ChunkedLinesGeometry.call(this, chunksCount, vecCount / 2 | 0, false); - this._collisionGeo = new CollisionSpheresGeo(chunksCount); + this._collisionGeo = new SphereCollisionGeo(chunksCount); } CrossGeometry.prototype = Object.create(ChunkedLinesGeometry.prototype); @@ -72275,7 +72280,7 @@ var tmpColor$4 = new Color(); * @constructor */ function IsoSurfaceGeometry(spheresCount, opts) { - RaycastableObjectsGeometry.call(this); + RaycastableBufferGeometry.call(this); this._opts = opts; this.zClip = this._opts.zClip; @@ -72283,7 +72288,7 @@ function IsoSurfaceGeometry(spheresCount, opts) { this._colors = utils.allocateTyped(Float32Array, spheresCount * COLOR_SIZE$2); } -IsoSurfaceGeometry.prototype = Object.create(RaycastableObjectsGeometry.prototype); +IsoSurfaceGeometry.prototype = Object.create(RaycastableBufferGeometry.prototype); IsoSurfaceGeometry.prototype.constructor = IsoSurfaceGeometry; IsoSurfaceGeometry.prototype.setItem = function (chunkIdx, pos, radius) { @@ -75443,9 +75448,9 @@ LabelsGeometry.prototype.getSubset = function () { var geometries = { InstancedSpheresGeometry: InstancedSpheresGeometry, SimpleSpheresGeometry: SimpleSpheresGeometry, - Simple2CCylindersGeometry: Simple2CCylinderGeometry, - Instanced2CCylinderGeometry: Instanced2CCylindersGeometry, - ExtrudedObjectsGeometry: ExtrudedObjectsGroup, + Simple2CCylindersGeometry: Simple2CCylindersGeometry, + Instanced2CCylindersGeometry: Instanced2CCylindersGeometry, + ExtrudedObjectsGeometry: ExtrudedObjectsGeometry, ChunkedLinesGeometry: ChunkedLinesGeometry, TwoColorLinesGeometry: TwoColorLinesGeometry, CrossGeometry: CrossGeometry, @@ -75597,14 +75602,14 @@ TextMesh.prototype.update = function () { var Mesh$3 = UberObject(Mesh); -function ThickLineSegments(geometry, material) { +function ThickLineMesh(geometry, material) { Mesh$3.call(this, geometry, material); } -ThickLineSegments.prototype = Object.create(Mesh$3.prototype); -ThickLineSegments.prototype.constructor = ThickLineSegments; +ThickLineMesh.prototype = Object.create(Mesh$3.prototype); +ThickLineMesh.prototype.constructor = ThickLineMesh; -ThickLineSegments.prototype._onBeforeRender = function (renderer, scene, camera) { +ThickLineMesh.prototype._onBeforeRender = function (renderer, scene, camera) { var material = this.material; if (!material.uberOptions) { return; @@ -75622,7 +75627,7 @@ var meshes = { Line: UberObject(Line), LineSegments: UberObject(LineSegments), Mesh: UberObject(Mesh), - ThickLineMesh: ThickLineSegments + ThickLineMesh: ThickLineMesh }; function setMatParams(params, uniforms) { @@ -75635,7 +75640,7 @@ function setMatParams(params, uniforms) { function _createInstancedCylinders(useZSprites, openEnded) { return { Geometry: function Geometry(a, b) { - return new geometries.Instanced2CCylinderGeometry(a, b, useZSprites, openEnded); + return new geometries.Instanced2CCylindersGeometry(a, b, useZSprites, openEnded); }, Object: meshes.ZSprite, initMaterial: setMatParams({ @@ -76002,14 +76007,14 @@ AtomsSurfaceGroup.prototype._makeGeoArgs = function (selection, mode, _colorer, /* This is a stub class keep it until SAS/SES is refactored */ -function AtomsSurfaceGroup$2(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { +function AtomsSASSESGroupStub(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { AtomsSphereGroup.call(this, geoParams, selection, colorer, mode, transforms, polyComplexity, material); } -AtomsSurfaceGroup$2.prototype = Object.create(AtomsSphereGroup.prototype); -AtomsSurfaceGroup$2.prototype.constructor = AtomsSurfaceGroup$2; +AtomsSASSESGroupStub.prototype = Object.create(AtomsSphereGroup.prototype); +AtomsSASSESGroupStub.prototype.constructor = AtomsSASSESGroupStub; -AtomsSurfaceGroup$2.prototype._makeGeoArgs = function (selection, mode, colorer, _polyComplexity) { +AtomsSASSESGroupStub.prototype._makeGeoArgs = function (selection, mode, colorer, _polyComplexity) { var selectedAtoms = []; var atoms = selection.atoms; var chunks = selection.chunks; @@ -76438,32 +76443,32 @@ NucleicItemGroup.prototype.updateToFrame = function (frameData) { geo.finishUpdate(); }; -function NucleicCylindersItemGroup(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { +function NucleicCylindersGroup(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { this._stickRad = mode.calcStickRadius(); this._geoArgs = [selection.chunks.length, polyComplexity]; NucleicItemGroup.call(this, geoParams, selection, colorer, mode, transforms, polyComplexity, material); } -NucleicCylindersItemGroup.prototype = Object.create(NucleicItemGroup.prototype); -NucleicCylindersItemGroup.prototype.constructor = NucleicCylindersItemGroup; +NucleicCylindersGroup.prototype = Object.create(NucleicItemGroup.prototype); +NucleicCylindersGroup.prototype.constructor = NucleicCylindersGroup; -NucleicCylindersItemGroup.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { +NucleicCylindersGroup.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { var geo = this._geo; geo.setItem(chunkIdx, cyl1, cyl2, this._stickRad); geo.setColor(chunkIdx, color, color); }; -function NucleicCylindersItemGroup$1(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { +function NucleicSpheresGroup(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { this._stickRad = mode.calcStickRadius(); this._geoArgs = [selection.chunks.length * 2, polyComplexity]; NucleicItemGroup.call(this, geoParams, selection, colorer, mode, transforms, polyComplexity, material); } -NucleicCylindersItemGroup$1.prototype = Object.create(NucleicItemGroup.prototype); -NucleicCylindersItemGroup$1.prototype.constructor = NucleicCylindersItemGroup$1; +NucleicSpheresGroup.prototype = Object.create(NucleicItemGroup.prototype); +NucleicSpheresGroup.prototype.constructor = NucleicSpheresGroup; -NucleicCylindersItemGroup$1.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { +NucleicSpheresGroup.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { var geo = this._geo; var stickRad = this._stickRad; var idx = chunkIdx * 2; @@ -77037,7 +77042,7 @@ function _calcPoints(residues, firstIdx, lastIdx, boundaries) { return { centerPoints: centerPoints, topPoints: topPoints }; } -function MatrixHelper(residues, startIdx, endIdx, segmentsCount, tension, boundaries) { +function CartoonHelper(residues, startIdx, endIdx, segmentsCount, tension, boundaries) { var pointsArrays = _calcPoints(residues, startIdx, endIdx, boundaries); this._topInterp = _buildStructureInterpolator(pointsArrays.topPoints, tension); this._centerInterp = _buildStructureInterpolator(pointsArrays.centerPoints, tension); @@ -77047,7 +77052,7 @@ function MatrixHelper(residues, startIdx, endIdx, segmentsCount, tension, bounda this._segmentsCount = segmentsCount; } -MatrixHelper.prototype.prepareMatrices = function (idx, firstRad, secondRad) { +CartoonHelper.prototype.prepareMatrices = function (idx, firstRad, secondRad) { var mtcCount = this._segmentsCount; var outMtc = new Array(mtcCount); var currRad = new Vector2(0, 0); @@ -77090,7 +77095,7 @@ function _loopThrough(subDiv, residues, segmentsHeight, tension, mode, callback) var boundaries = subDiv[subDivI].boundaries; for (var i = 0, n = subs.length; i < n; ++i) { var idc = [subs[i].start, subs[i].end]; - var matrixHelper = new MatrixHelper(residues, idc[0], idc[1], segmentsHeight, tension, boundaries); + var matrixHelper = new CartoonHelper(residues, idc[0], idc[1], segmentsHeight, tension, boundaries); var prevLast = null; var startIdx = subs[i].start * 2; var endIdx = subs[i].end * 2 + 1; @@ -77566,19 +77571,19 @@ BondsLinesGroup.prototype.updateToFrame = function (frameData) { var groups = { AtomsSphereGroup: AtomsSphereGroup, AtomsSurfaceGroup: AtomsSurfaceGroup, - AtomsSASSESGroup_stub: AtomsSurfaceGroup$2, + AtomsSASSESGroupStub: AtomsSASSESGroupStub, AtomsTextGroup: AtomsTextGroup, AromaticTorusGroup: AromaticTorusGroup, AromaticLinesGroup: AromaticLinesGroup, - NucleicCylindersGroup: NucleicCylindersItemGroup, - NucleicSpheresGroup: NucleicCylindersItemGroup$1, + NucleicCylindersGroup: NucleicCylindersGroup, + NucleicSpheresGroup: NucleicSpheresGroup, ResiduesSubseqGroup: ResiduesSubseqGroup, ResiduesTraceGroup: ResiduesTraceGroup, BondsCylinderGroup: BondsCylinderGroup, BondsLinesGroup: BondsLinesGroup }; -function ComponentsAtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function AtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77607,14 +77612,14 @@ function ComponentsAtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, }); } -ComponentsAtomsProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsAtomsProcessor.prototype.constructor = ComponentsAtomsProcessor; +AtomsProcessor.prototype = Object.create(RCGroup.prototype); +AtomsProcessor.prototype.constructor = AtomsProcessor; -ComponentsAtomsProcessor.prototype._checkAtom = function (atom, mask) { +AtomsProcessor.prototype._checkAtom = function (atom, mask) { return atom._mask & mask; }; -ComponentsAtomsProcessor.prototype.getSubset = function (mask, innerOnly) { +AtomsProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77633,10 +77638,10 @@ ComponentsAtomsProcessor.prototype.getSubset = function (mask, innerOnly) { function OrphanAtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { this._mode = mode; - ComponentsAtomsProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); + AtomsProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); } -OrphanAtomsProcessor.prototype = Object.create(ComponentsAtomsProcessor.prototype); +OrphanAtomsProcessor.prototype = Object.create(AtomsProcessor.prototype); OrphanAtomsProcessor.prototype.constructor = OrphanAtomsProcessor; OrphanAtomsProcessor.prototype._checkAtom = function (atom, mask) { @@ -77657,7 +77662,7 @@ OrphanAtomsProcessor.prototype._checkAtom = function (atom, mask) { return true; }; -function ComponentsResiduesProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function ResiduesProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77686,14 +77691,14 @@ function ComponentsResiduesProcessor(ResidueGroup, geoParams, complex, colorer, }); } -ComponentsResiduesProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsResiduesProcessor.prototype.constructor = ComponentsResiduesProcessor; +ResiduesProcessor.prototype = Object.create(RCGroup.prototype); +ResiduesProcessor.prototype.constructor = ResiduesProcessor; -ComponentsResiduesProcessor.prototype._checkResidue = function (residue, mask) { +ResiduesProcessor.prototype._checkResidue = function (residue, mask) { return residue._mask & mask; }; -ComponentsResiduesProcessor.prototype.getSubset = function (mask, innerOnly) { +ResiduesProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77710,18 +77715,18 @@ ComponentsResiduesProcessor.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -function ComponentNucleicProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { - ComponentsResiduesProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); +function NucleicProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { + ResiduesProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); } -ComponentNucleicProcessor.prototype = Object.create(ComponentsResiduesProcessor.prototype); -ComponentNucleicProcessor.prototype.constructor = ComponentNucleicProcessor; +NucleicProcessor.prototype = Object.create(ResiduesProcessor.prototype); +NucleicProcessor.prototype.constructor = NucleicProcessor; -ComponentNucleicProcessor.prototype._checkResidue = function (residue, mask) { +NucleicProcessor.prototype._checkResidue = function (residue, mask) { return mask & residue._mask && residue._cylinders !== null; }; -function ComponentsSubseqsProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function SubseqsProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77756,10 +77761,10 @@ function ComponentsSubseqsProcessor(ResidueGroup, geoParams, complex, colorer, m }); } -ComponentsSubseqsProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsSubseqsProcessor.prototype.constructor = ComponentsSubseqsProcessor; +SubseqsProcessor.prototype = Object.create(RCGroup.prototype); +SubseqsProcessor.prototype.constructor = SubseqsProcessor; -ComponentsSubseqsProcessor.prototype.getSubset = function (mask, innerOnly) { +SubseqsProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77776,7 +77781,7 @@ ComponentsSubseqsProcessor.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -function ComponentsAtomsProcessor$1(BondsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function BondsProcessor(BondsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77807,10 +77812,10 @@ function ComponentsAtomsProcessor$1(BondsGroup, geoParams, complex, colorer, mod }); } -ComponentsAtomsProcessor$1.prototype = Object.create(RCGroup.prototype); -ComponentsAtomsProcessor$1.prototype.constructor = ComponentsAtomsProcessor$1; +BondsProcessor.prototype = Object.create(RCGroup.prototype); +BondsProcessor.prototype.constructor = BondsProcessor; -ComponentsAtomsProcessor$1.prototype.getSubset = function (mask, innerOnly) { +BondsProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77827,7 +77832,7 @@ ComponentsAtomsProcessor$1.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -function ComponentsAromaticProcessor(AromaticGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function AromaticProcessor(AromaticGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); @@ -77868,10 +77873,10 @@ function ComponentsAromaticProcessor(AromaticGroup, geoParams, complex, colorer, }); } -ComponentsAromaticProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsAromaticProcessor.prototype.constructor = ComponentsAromaticProcessor; +AromaticProcessor.prototype = Object.create(RCGroup.prototype); +AromaticProcessor.prototype.constructor = AromaticProcessor; -ComponentsAromaticProcessor.prototype.getSubset = function (mask, innerOnly) { +AromaticProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77949,13 +77954,13 @@ function SGroupProcessor(AtomsGroup, geoParams, complex, _colorer, _mode, _polyC SGroupProcessor.prototype = Object.create(RCGroup.prototype); var processors = { - Atoms: ComponentsAtomsProcessor, + Atoms: AtomsProcessor, OrphanAtoms: OrphanAtomsProcessor, - Residues: ComponentsResiduesProcessor, - Nucleic: ComponentNucleicProcessor, - Subseqs: ComponentsSubseqsProcessor, - Bonds: ComponentsAtomsProcessor$1, - Aromatic: ComponentsAromaticProcessor, + Residues: ResiduesProcessor, + Nucleic: NucleicProcessor, + Subseqs: SubseqsProcessor, + Bonds: BondsProcessor, + Aromatic: AromaticProcessor, SGroups: SGroupProcessor }; @@ -78039,7 +78044,7 @@ GroupsFactory.ContactSurfaceGeo = function (caps, settings, renderParams) { GroupsFactory.SASSESSurfaceGeo = function (caps, settings, renderParams) { var gfxTriplet = MeshCreator.createSASSES(caps, settings, renderParams); - return _bakeGroup(gfxTriplet, processors.Atoms, groups.AtomsSASSESGroup_stub); + return _bakeGroup(gfxTriplet, processors.Atoms, groups.AtomsSASSESGroupStub); }; GroupsFactory.TextLabelsGeo = function (caps, settings) { @@ -78456,7 +78461,7 @@ CartoonMode.prototype.buildGeometry = function (complex, colorer, mask, material return Mode.prototype.buildGeometry.call(this, complex, colorer, mask, material); }; -var selectors$4 = chem.selectors; +var selectors$2 = chem.selectors; function getRenderParams$1() { return { @@ -78487,7 +78492,7 @@ SurfaceMode.prototype.calcAtomRadius = function (atom) { SurfaceMode.prototype.getVisibilitySelector = function () { var visibilitySelector = null; if (this.opts.subset !== '') { - var res = selectors$4.parse(this.opts.subset); + var res = selectors$2.parse(this.opts.subset); if (!res.error) { visibilitySelector = res.selector; } @@ -78495,18 +78500,18 @@ SurfaceMode.prototype.getVisibilitySelector = function () { return visibilitySelector; }; -function QuickSurfMode(opts) { +function QuickSurfaceMode(opts) { SurfaceMode.call(this, opts); } -utils.deriveClass(QuickSurfMode, SurfaceMode, { +utils.deriveClass(QuickSurfaceMode, SurfaceMode, { id: 'QS', name: 'Quick Surface', shortName: 'Quick Surf', surfaceNames: ['QuickSurfGeo'] }); -QuickSurfMode.prototype.getSurfaceOpts = function () { +QuickSurfaceMode.prototype.getSurfaceOpts = function () { return { useBeads: false, isoValue: this.opts.isoValue, @@ -78574,11 +78579,11 @@ utils.deriveClass(IsoSurfaceSESMode, IsoSurfaceMode, { shortName: 'SES' }); -function ContactSurfMode(opts) { +function ContactSurfaceMode(opts) { SurfaceMode.call(this, opts); } -utils.deriveClass(ContactSurfMode, SurfaceMode, { +utils.deriveClass(ContactSurfaceMode, SurfaceMode, { id: 'CS', name: 'Contact Surface', shortName: 'Contact Surf', @@ -78586,7 +78591,7 @@ utils.deriveClass(ContactSurfMode, SurfaceMode, { surfaceNames: ['ContactSurfaceGeo'] }); -ContactSurfMode.prototype.getSurfaceOpts = function () { +ContactSurfaceMode.prototype.getSurfaceOpts = function () { return { probeRadius: this.opts.probeRadius, radScale: this.opts.polyComplexity[this.settings.now.resolution], @@ -78633,7 +78638,7 @@ TextMode.prototype.getLabelOpts = function () { var modeList = []; var modeDict = {}; -var ag = [LinesMode, LicoriceMode, BallsAndSticksMode, VanDerWaalsMode, TraceMode, TubeMode, CartoonMode, QuickSurfMode, IsoSurfaceSASMode, IsoSurfaceSESMode, ContactSurfMode, TextMode]; +var ag = [LinesMode, LicoriceMode, BallsAndSticksMode, VanDerWaalsMode, TraceMode, TubeMode, CartoonMode, QuickSurfaceMode, IsoSurfaceSASMode, IsoSurfaceSESMode, ContactSurfaceMode, TextMode]; (function (plugins) { for (var i = 0, n = plugins.length; i < n; ++i) { @@ -78833,14 +78838,14 @@ Palette.prototype = { var namedColorsArray = Palette.prototype.namedColorsArray; var namedColors = Palette.prototype.namedColors; -for (var i$1 = 0, length = namedColorsArray.length; i$1 < length; ++i$1) { - var namedColor = namedColorsArray[i$1]; +for (var i = 0, length = namedColorsArray.length; i < length; ++i) { + var namedColor = namedColorsArray[i]; namedColors[namedColor[0]] = namedColor[1]; } -var palette$1 = new Palette('Jmol', 'JM'); +var palette = new Palette('Jmol', 'JM'); -palette$1.colors = [ +palette.colors = [ /* eslint-disable no-magic-numbers */ 0x0000FF, // blue 0x0055FF, // @@ -78862,7 +78867,7 @@ palette$1.colors = [ 0x5500FF]; // DO NOT EDIT MANUALLY! Autogenerated from atom_types.csv by atom_types.py. -palette$1.elementColors = { +palette.elementColors = { /* eslint-disable no-magic-numbers */ H: 0xFFFFFF, D: 0xFFFFC0, @@ -78978,10 +78983,10 @@ palette$1.elementColors = { /* eslint-enable no-magic-numbers */ }; -palette$1.defaultResidueColor = 0xBEA06E; +palette.defaultResidueColor = 0xBEA06E; // DO NOT EDIT MANUALLY! Autogenerated from residue_types.csv by residue_types.py. -palette$1.residueColors = { +palette.residueColors = { /* eslint-disable no-magic-numbers */ 'ALA': 0xC8C8C8, 'ARG': 0x145AFF, @@ -79024,7 +79029,7 @@ palette$1.residueColors = { /* eslint-enable no-magic-numbers */ }; -palette$1.chainColors = [ +palette.chainColors = [ // ' '->0 'A'->1, 'B'->2 0xFFffffff, // ' ' & '0' white // @@ -79057,7 +79062,7 @@ palette$1.chainColors = [ 0xFFB8860B, // darkgoldenrod 0xFFB22222]; -palette$1.secondaryColors = { +palette.secondaryColors = { 'helix': { 1: 0xFF0080, // RH alpha 3: 0x600080, // RH pi @@ -79069,9 +79074,9 @@ palette$1.secondaryColors = { 'rna': 0xFD0162 }; -var palette$2 = new Palette('VMD', 'VM'); +var palette$1 = new Palette('VMD', 'VM'); -palette$2.colors = [ +palette$1.colors = [ /* eslint-disable no-magic-numbers */ 0x0000FF, // blue 0xFF0000, // red @@ -79092,10 +79097,10 @@ palette$2.colors = [ /* eslint-enable no-magic-numbers */ ]; -palette$2.defaultElementColor = 0x804D00; +palette$1.defaultElementColor = 0x804D00; // DO NOT EDIT MANUALLY! Autogenerated from atom_types.csv by atom_types.py. -palette$2.elementColors = { +palette$1.elementColors = { /* eslint-disable no-magic-numbers */ H: 0xFFFFFF, C: 0x40BFBF, @@ -79106,10 +79111,10 @@ palette$2.elementColors = { /* eslint-enable no-magic-numbers */ }; -palette$2.defaultResidueColor = 0x40C0C0; +palette$1.defaultResidueColor = 0x40C0C0; // DO NOT EDIT MANUALLY! Autogenerated from residue_types.csv by residue_types.py. -palette$2.residueColors = { +palette$1.residueColors = { /* eslint-disable no-magic-numbers */ 'ALA': 0x0000FF, 'ARG': 0xFFFFFF, @@ -79152,22 +79157,22 @@ palette$2.residueColors = { /* eslint-enable no-magic-numbers */ }; -palette$2.chainColors = [0xFFFFFF].concat(palette$2.colors); +palette$1.chainColors = [0xFFFFFF].concat(palette$1.colors); -palette$2.secondaryColors = { +palette$1.secondaryColors = { 'helix': { 1: 0xA600A6, 5: 0x0000FF }, 'strand': 0xFFFF00 }; var paletteList = []; var paletteDict = {}; -var ag$2 = [palette$1, palette$2]; +var ag$1 = [palette, palette$1]; -for (var i = 0, n = ag$2.length; i < n; ++i) { - var palette = ag$2[i]; - paletteList.push(palette); - if (palette.id) { - paletteDict[palette.id] = palette; +for (var i$1 = 0, n = ag$1.length; i$1 < n; ++i$1) { + var palette$2 = ag$1[i$1]; + paletteList.push(palette$2); + if (palette$2.id) { + paletteDict[palette$2.id] = palette$2; } } @@ -79392,8 +79397,8 @@ UniformColorer.prototype.getResidueColor = function (_residue, _complex) { */ function ConditionalColorer(opts) { Colorer.call(this, opts); - var parsed = selectors$1.parse(this.opts.subset); - this._subsetCached = parsed.error ? selectors$1.none() : parsed.selector; + var parsed = selectors.parse(this.opts.subset); + this._subsetCached = parsed.error ? selectors.none() : parsed.selector; } utils.deriveClass(ConditionalColorer, Colorer, { @@ -79601,7 +79606,7 @@ MoleculeColorer.prototype.getResidueColor = function (residue, _complex) { */ var colorerList = []; var colorerDict = {}; -var ag$1 = [ElementColorer, ResidueTypeColorer, SequenceColorer, ChainColorer, SecondaryStructureColorer, UniformColorer, ConditionalColorer, ConformationColorer, TemperatureColorer, OccupancyColorer, HydrophobicityColorer, MoleculeColorer]; +var ag$2 = [ElementColorer, ResidueTypeColorer, SequenceColorer, ChainColorer, SecondaryStructureColorer, UniformColorer, ConditionalColorer, ConformationColorer, TemperatureColorer, OccupancyColorer, HydrophobicityColorer, MoleculeColorer]; (function (plugins) { for (var i = 0, n = plugins.length; i < n; ++i) { @@ -79617,7 +79622,7 @@ var ag$1 = [ElementColorer, ResidueTypeColorer, SequenceColorer, ChainColorer, S } } } -})(ag$1); +})(ag$2); // NOTE: workaround for https://github.com/gfranko/amdclean/issues/115 var exports$2 = /** @alias module:gfx/colorers */{ @@ -82522,7 +82527,7 @@ var Helix$2 = chem.Helix; var Sheet$2 = chem.Sheet; var Strand$2 = chem.Strand; var Bond$2 = chem.Bond; -var Molecule$3 = chem.Molecule; +var Molecule$2 = chem.Molecule; var TAG_LENGTH = 6; @@ -82638,7 +82643,7 @@ PDBParser.prototype._finalizeMolecules = function () { var chain = chainDict[name]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$3(this._complex, m._name, i + 1); + var molecule = new Molecule$2(this._complex, m._name, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -83674,8 +83679,8 @@ var mmtf = createCommonjsModule(function (module, exports) { }); var Complex$4 = chem.Complex; -var Chain$3 = chem.Chain; -var Atom$3 = chem.Atom; +var Chain$2 = chem.Chain; +var Atom$2 = chem.Atom; var AtomName$3 = chem.AtomName; var Element$5 = chem.Element; var Helix$3 = chem.Helix; @@ -83683,7 +83688,7 @@ var Sheet$3 = chem.Sheet; var Strand$3 = chem.Strand; var Bond$4 = chem.Bond; var Assembly$3 = chem.Assembly; -var Molecule$4 = chem.Molecule; +var Molecule$3 = chem.Molecule; function ArrayComparator(original) { this._original = Array.from(original); @@ -83767,7 +83772,7 @@ MMTFParser.prototype._onChain = function (chainData) { return; } - var chain = new Chain$3(this._complex, chainData.chainName); + var chain = new Chain$2(this._complex, chainData.chainName); this._complex._chains[chainData.chainIndex] = chain; chain._index = chainData.chainIndex; }; @@ -83798,7 +83803,7 @@ MMTFParser.prototype._onAtom = function (atomData) { } var altLoc = !atomData.altLoc.charCodeAt(0) ? '' : atomData.altLoc; - var atom = new Atom$3(atomData.groupIndex, // we store residue index here to replace it later with actual reference + var atom = new Atom$2(atomData.groupIndex, // we store residue index here to replace it later with actual reference new AtomName$3(atomData.atomName), Element$5.getByName(atomData.element.toUpperCase()), new Vector3(atomData.xCoord, atomData.yCoord, atomData.zCoord), Element$5.Role[atomData.atomName], false, // hetero atoms will be marked later atomData.atomId, altLoc, atomData.occupancy, atomData.bFactor, atomData.formalCharge); @@ -83886,7 +83891,7 @@ MMTFParser.prototype._updateMolecules = function (mmtfData) { var chain = this._complex._chains[chainIndex]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$4(this._complex, entity.description, i + 1); + var molecule = new Molecule$3(this._complex, entity.description, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -84123,7 +84128,7 @@ var Helix$4 = chem.Helix; var Sheet$4 = chem.Sheet; var Strand$4 = chem.Strand; var Assembly$4 = chem.Assembly; -var Molecule$5 = chem.Molecule; +var Molecule$4 = chem.Molecule; var cRequiredAtomFields = ['auth_seq_id', 'Cartn_x', 'Cartn_y', 'Cartn_z', 'label_atom_id']; @@ -84257,7 +84262,7 @@ CIFParser.prototype._extractMolecules = function (complex, complexData) { var molecules = complex.getMolecules(); for (i = 0; i < count; i++) { var molecule = this.molecules[i]; - molecules[i] = new Molecule$5(complex, molecule.name, i + 1); + molecules[i] = new Molecule$4(complex, molecule.name, i + 1); molecules[i]._residues = molecule.residues; } }; @@ -84474,14 +84479,12 @@ CIFParser.prototype._extractConfs = function (complex, helicesData) { var helClass = helClasses[i] || ' '; var struct; // TODO Add turns and strands(!)? - switch (type) { - case 'helix': - var idx = complex._helices.length; - struct = new Helix$4(idx, name, start[0], end[0], helClass, comment, length); - complex.addHelix(struct); - break; - default: - struct = null; + if (type === 'helix') { + var idx = complex._helices.length; + struct = new Helix$4(idx, name, start[0], end[0], helClass, comment, length); + complex.addHelix(struct); + } else { + struct = null; } if (!struct) { continue; @@ -84884,7 +84887,7 @@ CIFParser._parseToObject = function (source) { state = 0; } else { // .................................................................................................. - if (!Number.isNaN(code) && _storeValue(_parseValue()) !== null) { + if (_storeValue(_parseValue()) !== null) { continue; } state = 666; @@ -85046,12 +85049,10 @@ Ccp4Model.prototype.load = function (buffer) { yaxis.multiplyScalar(header.extent[yIndex] - 1); zaxis.multiplyScalar(header.extent[zIndex] - 1); - switch (header.type) { - case 2: - this._data = new Float32Array(buffer, 1024 + header.nsymbt, header.extent[0] * header.extent[1] * header.extent[2]); - break; - default: - throw new Error('CCP4: Unsupported format ' + header.type); + if (header.type === 2) { + this._data = new Float32Array(buffer, 1024 + header.nsymbt, header.extent[0] * header.extent[1] * header.extent[2]); + } else { + throw new Error('CCP4: Unsupported format ' + header.type); } this._bboxSize = new Vector3(xaxis.length(), yaxis.length(), zaxis.length()); @@ -86958,7 +86959,7 @@ function overrideUniforms$1(params) { return uniforms; } -function createOutlineMaterial(params) { +function OutlineMaterial(params) { var settings = { uniforms: overrideUniforms$1(params), vertexShader: vertexShader$1, @@ -86989,7 +86990,7 @@ function overrideUniforms$2(params) { return uniforms; } -function createFXAAMaterial(params) { +function FXAAMaterial(params) { var settings = { uniforms: overrideUniforms$2(params), vertexShader: vertexShader$1, @@ -87109,7 +87110,7 @@ function overrideUniforms$4(params) { return uniforms; } -function createAnaglyphMaterial(params) { +function AnaglyphMaterial(params) { var settings = { uniforms: overrideUniforms$4(params), vertexShader: vertexShader$1, @@ -87430,7 +87431,7 @@ function exportBonds(queue, complex, bondsFileName) { queue.add(bondsFileName, 'TED', false, true); } -function exportAll(complex, reprList, fullReport) { +function fbxExport(complex, reprList, fullReport) { prec = settings.now.fbxprec; window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; function onInitFS(fs) { @@ -87663,21 +87664,21 @@ var WEBVR = function () { return WEBVR; }(); -/* global "0.7.10":false */ +/* global "0.7.11":false */ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -var selectors = chem.selectors; -var Atom = chem.Atom; -var Residue = chem.Residue; -var Chain = chem.Chain; -var Molecule = chem.Molecule; +var selectors$4 = chem.selectors; +var Atom$3 = chem.Atom; +var Residue$2 = chem.Residue; +var Chain$3 = chem.Chain; +var Molecule$5 = chem.Molecule; var EDIT_MODE = { COMPLEX: 0, COMPONENT: 1, FRAGMENT: 2 }; -var createElement = utils.createElement; +var createElement$2 = utils.createElement; function updateFogRange(fog, center, radius) { fog.near = center - radius * settings.now.fogNearFactor; @@ -87727,7 +87728,7 @@ function reportProgress(log, action, percent) { * @exports Miew * @constructor */ -function Miew$1(opts) { +function Miew(opts) { EventDispatcher$1.call(this); this._opts = lodash.merge({ settingsCookie: 'settings', @@ -87801,15 +87802,15 @@ function Miew$1(opts) { } var self = this; - Miew$1.registeredPlugins.forEach(function (plugin) { + Miew.registeredPlugins.forEach(function (plugin) { plugin.call(self); }); } -Miew$1.prototype = Object.create(EventDispatcher$1.prototype); -Miew$1.prototype.constructor = Miew$1; +Miew.prototype = Object.create(EventDispatcher$1.prototype); +Miew.prototype.constructor = Miew; -Miew$1.prototype.getMaxRepresentationCount = function () { +Miew.prototype.getMaxRepresentationCount = function () { return ComplexVisual.NUM_REPRESENTATION_BITS; }; @@ -87819,15 +87820,15 @@ Miew$1.prototype.getMaxRepresentationCount = function () { * @throws Forwards exception raised during initialization. * @see Miew#term */ -Miew$1.prototype.init = function () { +Miew.prototype.init = function () { var container = this._container; var elem = utils.createElement('div', { 'class': 'miew-canvas' }); _setContainerContents(container, elem); this._container = elem; var frag = document.createDocumentFragment(); - frag.appendChild(this._msgMode = createElement('div', { 'class': 'mode-message overlay' }, createElement('p', {}, 'COMPONENT EDIT MODE'))); - frag.appendChild(this._msgAtomInfo = createElement('div', { 'class': 'atom-info overlay' }, createElement('p', {}, ''))); + frag.appendChild(this._msgMode = createElement$2('div', { 'class': 'mode-message overlay' }, createElement$2('p', {}, 'COMPONENT EDIT MODE'))); + frag.appendChild(this._msgAtomInfo = createElement$2('div', { 'class': 'atom-info overlay' }, createElement$2('p', {}, ''))); container.appendChild(frag); if (this._gfx !== null) { @@ -87912,7 +87913,7 @@ Miew$1.prototype.init = function () { * Terminate the viewer completely. * @see Miew#init */ -Miew$1.prototype.term = function () { +Miew.prototype.term = function () { this._showMessage('Viewer has been terminated.'); this._loading.forEach(function (job) { job.cancel(); @@ -87941,7 +87942,7 @@ function _setContainerContents(container, element) { * @param {string} msg - Message to show. * @private */ -Miew$1.prototype._showMessage = function (msg) { +Miew.prototype._showMessage = function (msg) { var element = document.createElement('div'); element.setAttribute('class', 'miew-message'); element.appendChild(document.createElement('p')).appendChild(document.createTextNode(msg)); @@ -87952,7 +87953,7 @@ Miew$1.prototype._showMessage = function (msg) { * Display WebGL canvas inside the viewer container, hiding any message shown. * @private */ -Miew$1.prototype._showCanvas = function () { +Miew.prototype._showCanvas = function () { _setContainerContents(this._container, this._gfx.renderer.domElement); }; @@ -87960,7 +87961,7 @@ Miew$1.prototype._showCanvas = function () { * Initialize WebGL and set 3D scene up. * @private */ -Miew$1.prototype._initGfx = function () { +Miew.prototype._initGfx = function () { var gfx = { width: this._container.clientWidth, height: this._container.clientHeight @@ -88111,7 +88112,7 @@ Miew$1.prototype._initGfx = function () { * Setup event listeners. * @private */ -Miew$1.prototype._initListeners = function () { +Miew.prototype._initListeners = function () { var self = this; window.addEventListener('resize', function _onResize() { self._onResize(); @@ -88122,7 +88123,7 @@ Miew$1.prototype._initListeners = function () { * Try to add numbers to the base name to make it unique among visuals * @private */ -Miew$1.prototype._makeUniqueVisualName = function (baseName) { +Miew.prototype._makeUniqueVisualName = function (baseName) { if (!baseName) { return Math.random().toString(); } @@ -88141,7 +88142,7 @@ Miew$1.prototype._makeUniqueVisualName = function (baseName) { * Add visual to the viewer * @private */ -Miew$1.prototype._addVisual = function (visual) { +Miew.prototype._addVisual = function (visual) { if (!visual) { return null; } @@ -88163,7 +88164,7 @@ Miew$1.prototype._addVisual = function (visual) { * Remove visual from the viewer * @private */ -Miew$1.prototype._removeVisual = function (visual) { +Miew.prototype._removeVisual = function (visual) { var name = ''; var obj = null; if (visual instanceof Visual) { @@ -88192,7 +88193,7 @@ Miew$1.prototype._removeVisual = function (visual) { * Call specified function for each Visual * @private */ -Miew$1.prototype._forEachVisual = function (callback) { +Miew.prototype._forEachVisual = function (callback) { for (var name in this._visuals) { if (this._visuals.hasOwnProperty(name)) { callback(this._visuals[name]); @@ -88204,7 +88205,7 @@ Miew$1.prototype._forEachVisual = function (callback) { * Release (destroy) all visuals in the scene * @private */ -Miew$1.prototype._releaseAllVisuals = function () { +Miew.prototype._releaseAllVisuals = function () { if (!this._gfx || !this._gfx.pivot) { return; } @@ -88222,7 +88223,7 @@ Miew$1.prototype._releaseAllVisuals = function () { * Call specified function for each ComplexVisual * @private */ -Miew$1.prototype._forEachComplexVisual = function (callback) { +Miew.prototype._forEachComplexVisual = function (callback) { if (!this._gfx || !this._gfx.pivot) { return; } @@ -88238,7 +88239,7 @@ Miew$1.prototype._forEachComplexVisual = function (callback) { * Returns ComplexVisual with specified name, or current (if not found), or any, or null * @private */ -Miew$1.prototype._getComplexVisual = function (name) { +Miew.prototype._getComplexVisual = function (name) { name = name || this._curVisualName; var any = null; var named = null; @@ -88255,7 +88256,7 @@ Miew$1.prototype._getComplexVisual = function (name) { * Returns first found VolumeVisual (no more than one should be present actually) * @private */ -Miew$1.prototype._getVolumeVisual = function () { +Miew.prototype._getVolumeVisual = function () { var any = null; this._forEachVisual(function (visual) { if (visual instanceof VolumeVisual) { @@ -88269,7 +88270,7 @@ Miew$1.prototype._getVolumeVisual = function () { * Returns ComplexVisual corresponding to specified complex * @private */ -Miew$1.prototype._getVisualForComplex = function (complex) { +Miew.prototype._getVisualForComplex = function (complex) { if (!complex) { return null; } @@ -88286,14 +88287,14 @@ Miew$1.prototype._getVisualForComplex = function (complex) { /* * Get a list of names of visuals currently shown by the viewer */ -Miew$1.prototype.getVisuals = function () { +Miew.prototype.getVisuals = function () { return Object.keys(this._visuals); }; /* * Get current visual */ -Miew$1.prototype.getCurrentVisual = function () { +Miew.prototype.getCurrentVisual = function () { return this._curVisualName; }; @@ -88301,7 +88302,7 @@ Miew$1.prototype.getCurrentVisual = function () { * Set current visual. * All further operations will be performed on this visual (complex) if not stated otherwise. */ -Miew$1.prototype.setCurrentVisual = function (name) { +Miew.prototype.setCurrentVisual = function (name) { if (!this._visuals[name]) { return; } @@ -88314,7 +88315,7 @@ Miew$1.prototype.setCurrentVisual = function (name) { * Has no effect if already running. * @see Miew#halt */ -Miew$1.prototype.run = function () { +Miew.prototype.run = function () { var _this = this; if (!this._running) { @@ -88338,7 +88339,7 @@ Miew$1.prototype.run = function () { * Will be processed during the next frame. * @see Miew#run */ -Miew$1.prototype.halt = function () { +Miew.prototype.halt = function () { if (this._running) { this._discardComponentEdit(); this._discardFragmentEdit(); @@ -88352,7 +88353,7 @@ Miew$1.prototype.halt = function () { * on hot keys. * @param enabled - start (true) or stop (false) response on hot keys. */ -Miew$1.prototype.enableHotKeys = function (enabled) { +Miew.prototype.enableHotKeys = function (enabled) { this._hotKeysEnabled = enabled; this._objectControls.enableHotkeys(enabled); }; @@ -88361,7 +88362,7 @@ Miew$1.prototype.enableHotKeys = function (enabled) { * Callback which processes window resize. * @private */ -Miew$1.prototype._onResize = function () { +Miew.prototype._onResize = function () { this._needRender = true; var gfx = this._gfx; @@ -88378,7 +88379,7 @@ Miew$1.prototype._onResize = function () { this.dispatchEvent({ type: 'resize' }); }; -Miew$1.prototype._resizeOffscreenBuffers = function (width, height, stereo) { +Miew.prototype._resizeOffscreenBuffers = function (width, height, stereo) { var gfx = this._gfx; stereo = stereo || 'NONE'; var isAnaglyph = stereo === 'NONE' || stereo === 'ANAGLYPH'; @@ -88405,7 +88406,7 @@ Miew$1.prototype._resizeOffscreenBuffers = function (width, height, stereo) { * Callback which processes update/render frames. * @private */ -Miew$1.prototype._onTick = function () { +Miew.prototype._onTick = function () { var _this2 = this; if (this._halting) { @@ -88432,7 +88433,7 @@ Miew$1.prototype._onTick = function () { * 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 () { +Miew.prototype._toggleWebVR = function () { var _mainCamera = new PerspectiveCamera(); var _cameraWasStored = false; @@ -88475,12 +88476,12 @@ Miew$1.prototype._toggleWebVR = function () { }; }(); -Miew$1.prototype._getWebVRDevice = function () { +Miew.prototype._getWebVRDevice = function () { var vr = this._gfx.renderer.vr; return vr && vr.enabled ? vr.getDevice() : null; }; -Miew$1.prototype._getBSphereRadius = function () { +Miew.prototype._getBSphereRadius = function () { // calculate radius that would include all visuals var radius = 0; this._forEachVisual(function (visual) { @@ -88489,7 +88490,7 @@ Miew$1.prototype._getBSphereRadius = function () { return radius * this._objectControls.getScale(); }; -Miew$1.prototype._updateFog = function () { +Miew.prototype._updateFog = function () { var gfx = this._gfx; if (settings.now.fog) { @@ -88504,7 +88505,7 @@ Miew$1.prototype._updateFog = function () { } }; -Miew$1.prototype._onUpdate = function () { +Miew.prototype._onUpdate = function () { if (this.isScriptingCommandAvailable !== undefined && this.isScriptingCommandAvailable() && !this._building) { this.callNextCmd(); @@ -88527,7 +88528,7 @@ Miew$1.prototype._onUpdate = function () { this._updateFog(); }; -Miew$1.prototype._onRender = function () { +Miew.prototype._onRender = function () { var gfx = this._gfx; // update all matrices @@ -88542,9 +88543,9 @@ Miew$1.prototype._onRender = function () { this._renderFrame(settings.now.stereo); }; -Miew$1.prototype._renderFrame = function () { +Miew.prototype._renderFrame = function () { - var _anaglyphMat = new createAnaglyphMaterial(); + var _anaglyphMat = new AnaglyphMaterial(); return function (stereo) { var gfx = this._gfx; @@ -88601,7 +88602,7 @@ Miew$1.prototype._renderFrame = function () { }; }(); -Miew$1.prototype._onThemeChanged = function () { +Miew.prototype._onThemeChanged = function () { var themeRE = /\s*theme-\w+\b/g; return function () { var theme = settings.now.theme; @@ -88619,7 +88620,7 @@ Miew$1.prototype._onThemeChanged = function () { }; }(); -Miew$1.prototype._setUberMaterialValues = function (values) { +Miew.prototype._setUberMaterialValues = function (values) { this._gfx.root.traverse(function (obj) { if ((obj instanceof Mesh || obj instanceof LineSegments || obj instanceof Line) && obj.material instanceof UberMaterial) { obj.material.setValues(values); @@ -88628,7 +88629,7 @@ Miew$1.prototype._setUberMaterialValues = function (values) { }); }; -Miew$1.prototype._renderScene = function () { +Miew.prototype._renderScene = function () { return function (camera, distortion, target) { distortion = distortion || false; target = target || null; @@ -88699,7 +88700,7 @@ Miew$1.prototype._renderScene = function () { }; }(); -Miew$1.prototype._performDistortion = function () { +Miew.prototype._performDistortion = function () { var _scene = new Scene(); var _camera = new OrthographicCamera(-1.0, 1.0, 1.0, -1.0, -500, 1000); @@ -88733,9 +88734,9 @@ Miew$1.prototype._performDistortion = function () { }; }(); -Miew$1.prototype._renderSelection = function () { +Miew.prototype._renderSelection = function () { - var _outlineMaterial = new createOutlineMaterial(); + var _outlineMaterial = new OutlineMaterial(); return function (camera, srcBuffer, targetBuffer) { @@ -88766,7 +88767,7 @@ Miew$1.prototype._renderSelection = function () { }; }(); -Miew$1.prototype._checkVolumeRenderingSupport = function (renderTarget) { +Miew.prototype._checkVolumeRenderingSupport = function (renderTarget) { if (!renderTarget) { return false; } @@ -88786,7 +88787,7 @@ Miew$1.prototype._checkVolumeRenderingSupport = function (renderTarget) { } }; -Miew$1.prototype._renderVolume = function () { +Miew.prototype._renderVolume = function () { var volumeBFMat = new VolumeMaterial$1.BackFacePosMaterial(); var volumeFFMat = new VolumeMaterial$1.FrontFacePosMaterial(); @@ -88859,7 +88860,7 @@ Miew$1.prototype._renderVolume = function () { * 2. Realization doesn't use camera layers because scene traversing is used for material changes and * we can use it to select needed meshes and don't complicate meshes builders with layers */ -Miew$1.prototype._renderWithPrepassTransparency = function () { +Miew.prototype._renderWithPrepassTransparency = function () { return function (camera, targetBuffer) { var gfx = this._gfx; @@ -88883,9 +88884,9 @@ Miew$1.prototype._renderWithPrepassTransparency = function () { }; }(); -Miew$1.prototype._performFXAA = function () { +Miew.prototype._performFXAA = function () { - var _fxaaMaterial = new createFXAAMaterial(); + var _fxaaMaterial = new FXAAMaterial(); return function (srcBuffer, targetBuffer) { @@ -88908,7 +88909,7 @@ Miew$1.prototype._performFXAA = function () { }; }(); -Miew$1.prototype._performAO = function () { +Miew.prototype._performAO = function () { var _aoMaterial = new ao.AOMaterial(); var _horBlurMaterial = new ao.HorBilateralBlurMaterial(); @@ -88989,7 +88990,7 @@ Miew$1.prototype._performAO = function () { * Reset the viewer, unload molecules. * @param {boolean=} keepReps - Keep representations while resetting viewer state. */ -Miew$1.prototype.reset = function () /* keepReps */{ +Miew.prototype.reset = function () /* keepReps */{ if (this._picker) { this._picker.reset(); } @@ -89009,7 +89010,7 @@ Miew$1.prototype.reset = function () /* keepReps */{ this.setNeedRender(); }; -Miew$1.prototype._resetScene = function () { +Miew.prototype._resetScene = function () { this._objectControls.reset(); this._objectControls.allowTranslation(true); this._objectControls.allowAltObjFreeRotation(true); @@ -89018,7 +89019,7 @@ Miew$1.prototype._resetScene = function () { this.rebuildAll(); }; -Miew$1.prototype.resetView = function () { +Miew.prototype.resetView = function () { // reset controls if (this._picker) { this._picker.reset(); @@ -89043,7 +89044,7 @@ Miew$1.prototype.resetView = function () { * @param {boolean=} opts.keepRepsInfo - prevent reset of object and reps information. * @returns {Promise} name of the visual that was added to the viewer */ -Miew$1.prototype.load = function (source, opts) { +Miew.prototype.load = function (source, opts) { var _this3 = this; opts = lodash.merge({}, opts, { @@ -89106,12 +89107,12 @@ Miew$1.prototype.load = function (source, opts) { * Unload molecule (delete corresponding visual). * @param {string=} name - name of the visual */ -Miew$1.prototype.unload = function (name) { +Miew.prototype.unload = function (name) { this._removeVisual(name || this.getCurrentVisual()); this.resetPivot(); }; -Miew$1.prototype._startAnimation = function (fileData) { +Miew.prototype._startAnimation = function (fileData) { this._stopAnimation(); var self = this; var visual = this._getComplexVisual(); @@ -89142,7 +89143,7 @@ Miew$1.prototype._startAnimation = function (fileData) { this._continueAnimation(); }; -Miew$1.prototype._startMdAnimation = function (mdFile, pdbFile) { +Miew.prototype._startMdAnimation = function (mdFile, pdbFile) { this._stopAnimation(); var self = this; var visual = this._getComplexVisual(); @@ -89173,7 +89174,7 @@ Miew$1.prototype._startMdAnimation = function (mdFile, pdbFile) { this._continueAnimation(); }; -Miew$1.prototype._pauseAnimation = function () { +Miew.prototype._pauseAnimation = function () { if (this._animInterval === null) { return; } @@ -89191,7 +89192,7 @@ Miew$1.prototype._pauseAnimation = function () { } }; -Miew$1.prototype._continueAnimation = function () { +Miew.prototype._continueAnimation = function () { this._isAnimating = true; var minFrameTime = 1000 / settings.now.maxfps; minFrameTime = Number.isNaN(minFrameTime) ? 0 : minFrameTime; @@ -89228,7 +89229,7 @@ Miew$1.prototype._continueAnimation = function () { }, minFrameTime); }; -Miew$1.prototype._stopAnimation = function () { +Miew.prototype._stopAnimation = function () { if (this._animInterval === null) { return; } @@ -89249,7 +89250,7 @@ Miew$1.prototype._stopAnimation = function () { * @param {object} opts - TODO: Options. * @private */ -Miew$1.prototype._onLoad = function (dataSource, opts) { +Miew.prototype._onLoad = function (dataSource, opts) { var gfx = this._gfx; var visualName = null; @@ -89352,7 +89353,7 @@ Miew$1.prototype._onLoad = function (dataSource, opts) { return visualName; }; -Miew$1.prototype.resetEd = function () { +Miew.prototype.resetEd = function () { if (this._edLoader) { this._edLoader.abort(); this._edLoader = null; @@ -89364,7 +89365,7 @@ Miew$1.prototype.resetEd = function () { this._needRender = true; }; -Miew$1.prototype.loadEd = function (source) { +Miew.prototype.loadEd = function (source) { var _this4 = this; this.resetEd(); @@ -89393,7 +89394,7 @@ Miew$1.prototype.loadEd = function (source) { }); }; -Miew$1.prototype._onLoadEd = function (dataSource) { +Miew.prototype._onLoadEd = function (dataSource) { dataSource.normalize(); var volumeVisual = new VolumeVisual('volume', dataSource); @@ -89404,7 +89405,7 @@ Miew$1.prototype._onLoadEd = function (dataSource) { return visualName; }; -Miew$1.prototype._needRebuild = function () { +Miew.prototype._needRebuild = function () { var needsRebuild = false; this._forEachComplexVisual(function (visual) { needsRebuild = needsRebuild || visual.needsRebuild(); @@ -89412,7 +89413,7 @@ Miew$1.prototype._needRebuild = function () { return needsRebuild; }; -Miew$1.prototype._rebuildObjects = function () { +Miew.prototype._rebuildObjects = function () { var self = this; var gfx = this._gfx; var i, n; @@ -89443,7 +89444,7 @@ Miew$1.prototype._rebuildObjects = function () { }, 10); }; -Miew$1.prototype.changeUnit = function (unitIdx, name) { +Miew.prototype.changeUnit = function (unitIdx, name) { var visual = this._getComplexVisual(name); if (unitIdx === undefined) { var unit = visual ? visual.getComplex().getCurrentStructure() : 0; @@ -89463,7 +89464,7 @@ Miew$1.prototype.changeUnit = function (unitIdx, name) { /** * Start to rebuild geometry asynchronously. */ -Miew$1.prototype.rebuild = function () { +Miew.prototype.rebuild = function () { if (this._building) { this.logger.warn('Miew.rebuild(): already building!'); return; @@ -89503,14 +89504,14 @@ Miew$1.prototype.rebuild = function () { }; /** Mark all representations for rebuilding */ -Miew$1.prototype.rebuildAll = function () { +Miew.prototype.rebuildAll = function () { this._forEachComplexVisual(function (visual) { visual.setNeedsRebuild(); }); // this.rebuild(); // TODO: isn't implicit rebuild enough? }; -Miew$1.prototype._refreshTitle = function (appendix) { +Miew.prototype._refreshTitle = function (appendix) { var title; appendix = appendix === undefined ? '' : appendix; var visual = this._getComplexVisual(); @@ -89526,11 +89527,11 @@ Miew$1.prototype._refreshTitle = function (appendix) { this.dispatchEvent({ type: 'titleChanged', data: title }); }; -Miew$1.prototype.setNeedRender = function () { +Miew.prototype.setNeedRender = function () { this._needRender = true; }; -Miew$1.prototype._extractRepresentation = function () { +Miew.prototype._extractRepresentation = function () { var _this5 = this; var changed = []; @@ -89569,7 +89570,7 @@ Miew$1.prototype._extractRepresentation = function () { * Change current representation list. * @param {array} reps - Representation list. */ -Miew$1.prototype._setReps = function (reps) { +Miew.prototype._setReps = function (reps) { reps = reps || this._opts && this._opts.reps || []; this._forEachComplexVisual(function (visual) { return visual.resetReps(reps); @@ -89580,7 +89581,7 @@ Miew$1.prototype._setReps = function (reps) { * Apply existing preset to current scene. * @param preset */ -Miew$1.prototype.applyPreset = function (preset) { +Miew.prototype.applyPreset = function (preset) { var presets = settings.now.presets; var presList = [preset || settings.defaults.preset, settings.defaults.preset, Object.keys(presets)[0]]; var reps = null; @@ -89598,7 +89599,7 @@ Miew$1.prototype.applyPreset = function (preset) { * Reset current representation list to initial values. * @param {string} [preset] - The source preset in case of uninitialized representation list. */ -Miew$1.prototype.resetReps = function (preset) { +Miew.prototype.resetReps = function (preset) { var reps = this._opts && this._opts.reps; if (reps) { this._setReps(reps); @@ -89611,7 +89612,7 @@ Miew$1.prototype.resetReps = function (preset) { * Get number of representations created so far. * @returns {number} Number of reps. */ -Miew$1.prototype.repCount = function (name) { +Miew.prototype.repCount = function (name) { var visual = this._getComplexVisual(name); return visual ? visual.repCount() : 0; }; @@ -89622,7 +89623,7 @@ Miew$1.prototype.repCount = function (name) { * @param {string=} [name] - Complex name. Defaults to the current one. * @returns {number} The current index. */ -Miew$1.prototype.repCurrent = function (index, name) { +Miew.prototype.repCurrent = function (index, name) { var visual = this._getComplexVisual(name); var newIdx = visual ? visual.repCurrent(index) : -1; if (index && newIdx !== index) { @@ -89641,7 +89642,7 @@ Miew$1.prototype.repCurrent = function (index, name) { * @param {string=} rep.material - Material id. * @returns {?object} Representation description. */ -Miew$1.prototype.rep = function (index, rep) { +Miew.prototype.rep = function (index, rep) { // FIXME support targeting visual by name var visual = this._getComplexVisual(''); return visual ? visual.rep(index, rep) : null; @@ -89652,7 +89653,7 @@ Miew$1.prototype.rep = function (index, rep) { * @param {number=} index - Zero-based index, up to {@link Miew#repCount}(). Defaults to the current one. * @returns {?object} Representation. */ -Miew$1.prototype.repGet = function (index, name) { +Miew.prototype.repGet = function (index, name) { var visual = this._getComplexVisual(name); return visual ? visual.repGet(index) : null; }; @@ -89662,7 +89663,7 @@ Miew$1.prototype.repGet = function (index, name) { * @param {object=} rep - Representation description. * @returns {number} Index of the new representation. */ -Miew$1.prototype.repAdd = function (rep, name) { +Miew.prototype.repAdd = function (rep, name) { var visual = this._getComplexVisual(name); return visual ? visual.repAdd(rep) : -1; }; @@ -89671,7 +89672,7 @@ Miew$1.prototype.repAdd = function (rep, name) { * Remove representation. * @param {number=} index - Zero-based representation index. */ -Miew$1.prototype.repRemove = function (index, name) { +Miew.prototype.repRemove = function (index, name) { var visual = this._getComplexVisual(name); return visual ? visual.repRemove(index) : null; }; @@ -89681,13 +89682,13 @@ Miew$1.prototype.repRemove = function (index, name) { * @param {number} index - Zero-based representation index. * @param {boolean=} hide - Specify false to make rep visible, true to hide (by default). */ -Miew$1.prototype.repHide = function (index, hide, name) { +Miew.prototype.repHide = function (index, hide, name) { this._needRender = true; var visual = this._getComplexVisual(name); return visual ? visual.repHide(index, hide) : null; }; -Miew$1.prototype._setEditMode = function (mode) { +Miew.prototype._setEditMode = function (mode) { this._editMode = mode; @@ -89704,7 +89705,7 @@ Miew$1.prototype._setEditMode = function (mode) { this.dispatchEvent({ type: 'editModeChanged', data: mode === EDIT_MODE.COMPLEX }); }; -Miew$1.prototype._enterComponentEditMode = function () { +Miew.prototype._enterComponentEditMode = function () { if (this._editMode !== EDIT_MODE.COMPLEX) { return; @@ -89729,7 +89730,7 @@ Miew$1.prototype._enterComponentEditMode = function () { this._objectControls.keysTranslateObj(true); }; -Miew$1.prototype._applyComponentEdit = function () { +Miew.prototype._applyComponentEdit = function () { if (this._editMode !== EDIT_MODE.COMPONENT) { return; } @@ -89748,7 +89749,7 @@ Miew$1.prototype._applyComponentEdit = function () { this.rebuildAll(); }; -Miew$1.prototype._discardComponentEdit = function () { +Miew.prototype._discardComponentEdit = function () { if (this._editMode !== EDIT_MODE.COMPONENT) { return; } @@ -89767,7 +89768,7 @@ Miew$1.prototype._discardComponentEdit = function () { this._needRender = true; }; -Miew$1.prototype._enterFragmentEditMode = function () { +Miew.prototype._enterFragmentEditMode = function () { if (this._editMode !== EDIT_MODE.COMPLEX) { return; @@ -89800,7 +89801,7 @@ Miew$1.prototype._enterFragmentEditMode = function () { this._needRender = true; }; -Miew$1.prototype._applyFragmentEdit = function () { +Miew.prototype._applyFragmentEdit = function () { if (this._editMode !== EDIT_MODE.FRAGMENT) { return; } @@ -89820,7 +89821,7 @@ Miew$1.prototype._applyFragmentEdit = function () { this.rebuildAll(); }; -Miew$1.prototype._discardFragmentEdit = function () { +Miew.prototype._discardFragmentEdit = function () { if (this._editMode !== EDIT_MODE.FRAGMENT) { return; } @@ -89841,13 +89842,13 @@ Miew$1.prototype._discardFragmentEdit = function () { }; /** @deprecated Move object instead of panning the camera */ -Miew$1.prototype.resetPan = function () { +Miew.prototype.resetPan = function () { this._gfx.camera.position.x = 0.0; this._gfx.camera.position.y = 0.0; this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype._onPick = function (event) { +Miew.prototype._onPick = function (event) { if (!settings.now.picking) { // picking is disabled return; @@ -89906,7 +89907,7 @@ Miew$1.prototype._onPick = function (event) { this._updateInfoPanel(); }; -Miew$1.prototype._onDblClick = function (event) { +Miew.prototype._onDblClick = function (event) { if ('atom' in event.obj) { this.setPivotAtom(event.obj.atom); } else if ('residue' in event.obj) { @@ -89919,7 +89920,7 @@ Miew$1.prototype._onDblClick = function (event) { this._needRender = true; }; -Miew$1.prototype._onKeyDown = function (event) { +Miew.prototype._onKeyDown = function (event) { if (!this._running || !this._hotKeysEnabled) { return; } @@ -89985,20 +89986,17 @@ Miew$1.prototype._onKeyDown = function (event) { } }; -Miew$1.prototype._onKeyUp = function (event) { +Miew.prototype._onKeyUp = function (event) { if (!this._running || !this._hotKeysEnabled) { return; } - switch (event.keyCode) { - case 'X'.charCodeAt(0): - this._extractRepresentation(); - break; - default: + if (event.keyCode === 'X'.charCodeAt(0)) { + this._extractRepresentation(); } }; -Miew$1.prototype._updateInfoPanel = function () { +Miew.prototype._updateInfoPanel = function () { var info = this._msgAtomInfo.getElementsByTagName('p')[0]; var atom, residue; @@ -90024,7 +90022,7 @@ Miew$1.prototype._updateInfoPanel = function () { var aName = ''; var coordLine = ''; - if (this._lastPick instanceof Atom) { + if (this._lastPick instanceof Atom$3) { atom = this._lastPick; residue = atom._residue; @@ -90042,13 +90040,13 @@ Miew$1.prototype._updateInfoPanel = function () { } coordLine = 'Coord: (' + atom._position.x.toFixed(2).toString() + ', ' + atom._position.y.toFixed(2).toString() + ', ' + atom._position.z.toFixed(2).toString() + ')'; - } else if (this._lastPick instanceof Residue) { + } else if (this._lastPick instanceof Residue$2) { residue = this._lastPick; secondLine = residue._type._fullName + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim(); - } else if (this._lastPick instanceof Chain) { + } else if (this._lastPick instanceof Chain$3) { secondLine = 'chain ' + this._lastPick._name; - } else if (this._lastPick instanceof Molecule) { + } else if (this._lastPick instanceof Molecule$5) { secondLine = 'molecule ' + this._lastPick._name; } @@ -90074,7 +90072,7 @@ Miew$1.prototype._updateInfoPanel = function () { this._msgAtomInfo.style.opacity = 1.0; }; -Miew$1.prototype._getAltObj = function () { +Miew.prototype._getAltObj = function () { if (this._editors) { var altObj = null; for (var i = 0; i < this._editors.length; ++i) { @@ -90099,7 +90097,7 @@ Miew$1.prototype._getAltObj = function () { }; }; -Miew$1.prototype.resetPivot = function () { +Miew.prototype.resetPivot = function () { var boundingBox = new Box3(); this._forEachVisual(function (visual) { boundingBox.union(visual.getBoundaries().boundingBox); @@ -90110,7 +90108,7 @@ Miew$1.prototype.resetPivot = function () { this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype.setPivotResidue = function (residue) { +Miew.prototype.setPivotResidue = function (residue) { var visual = this._getVisualForComplex(residue.getChain().getComplex()); if (!visual) { return; @@ -90137,7 +90135,7 @@ Miew$1.prototype.setPivotResidue = function (residue) { this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype.setPivotAtom = function (atom) { +Miew.prototype.setPivotAtom = function (atom) { var visual = this._getVisualForComplex(atom.getResidue().getChain().getComplex()); if (!visual) { return; @@ -90150,7 +90148,7 @@ Miew$1.prototype.setPivotAtom = function (atom) { this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype.benchmarkGfx = function (force) { +Miew.prototype.benchmarkGfx = function (force) { var self = this; var prof = new GfxProfiler(this._gfx.renderer); @@ -90186,7 +90184,7 @@ Miew$1.prototype.benchmarkGfx = function (force) { * if width is omitted too. * @returns {string} Data URL representing the image contents. */ -Miew$1.prototype.screenshot = function (width, height) { +Miew.prototype.screenshot = function (width, height) { var gfx = this._gfx; function Fov2Tan(fov) { @@ -90248,12 +90246,12 @@ Miew$1.prototype.screenshot = function (width, height) { * @param {number} [height] - Height of an image. Defaults to the width (square) or canvas height, * if width is omitted too. */ -Miew$1.prototype.screenshotSave = function (filename, width, height) { +Miew.prototype.screenshotSave = function (filename, width, height) { var uri = this.screenshot(width, height); utils.shotDownload(uri, filename); }; -Miew$1.prototype._tweakResolution = function () { +Miew.prototype._tweakResolution = function () { var maxPerf = [['poor', 100], ['low', 500], ['medium', 1000], ['high', 5000], ['ultra', Number.MAX_VALUE]]; var atomCount = 0; @@ -90273,7 +90271,7 @@ Miew$1.prototype._tweakResolution = function () { } }; -Miew$1.prototype._autoChangeResolution = function (resolution) { +Miew.prototype._autoChangeResolution = function (resolution) { if (resolution !== settings.now.resolution) { this.logger.report('Your rendering resolution was changed to "' + resolution + '" for best performance.'); } @@ -90283,11 +90281,11 @@ Miew$1.prototype._autoChangeResolution = function (resolution) { /** * Save current settings to cookies. */ -Miew$1.prototype.saveSettings = function () { +Miew.prototype.saveSettings = function () { this._cookies.setCookie(this._opts.settingsCookie, JSON.stringify(this.settings.getDiffs(true))); }; -Miew$1.prototype._loadSettings = function () { +Miew.prototype._loadSettings = function () { try { var cookie = this._cookies.getCookie(this._opts.settingsCookie); var diffs = cookie ? JSON.parse(cookie) : {}; @@ -90300,7 +90298,7 @@ Miew$1.prototype._loadSettings = function () { /** * Load settings from cookies. */ -Miew$1.prototype.restoreSettings = function () { +Miew.prototype.restoreSettings = function () { var oldSettings = lodash.cloneDeep(this.settings.now); this._loadSettings(); var changes = utils.objectsDiff(this.settings.now, oldSettings); @@ -90310,7 +90308,7 @@ Miew$1.prototype.restoreSettings = function () { /** * Reset current settings to the defaults. */ -Miew$1.prototype.resetSettings = function () { +Miew.prototype.resetSettings = function () { var oldSettings = lodash.cloneDeep(this.settings.now); this.settings.reset(); var changes = utils.objectsDiff(this.settings.now, oldSettings); @@ -90322,9 +90320,9 @@ Miew$1.prototype.resetSettings = function () { * @param {string|object} opts - See {@link Miew} constructor. * @see {@link Miew#set}, {@link Miew#repAdd}, {@link Miew#rep}. */ -Miew$1.prototype.setOptions = function (opts) { +Miew.prototype.setOptions = function (opts) { if (typeof opts === 'string') { - opts = Miew$1.options.fromAttr(opts); + opts = Miew.options.fromAttr(opts); } if (opts.reps) { this._opts.reps = null; @@ -90366,7 +90364,7 @@ Miew$1.prototype.setOptions = function (opts) { } }; -Miew$1.prototype.info = function (name) { +Miew.prototype.info = function (name) { var visual = this._getComplexVisual(name); if (!visual) { return {}; @@ -90387,7 +90385,7 @@ Miew$1.prototype.info = function (name) { * OBJECTS SEGMENT */ -Miew$1.prototype.addObject = function (objData, bThrow) { +Miew.prototype.addObject = function (objData, bThrow) { var Ctor = null; // TODO change this to factory when better times come. @@ -90412,7 +90410,7 @@ Miew$1.prototype.addObject = function (objData, bThrow) { this._needRender = true; }; -Miew$1.prototype._addSceneObject = function (sceneObject) { +Miew.prototype._addSceneObject = function (sceneObject) { var visual = this._getComplexVisual(); if (sceneObject.build && visual) { sceneObject.build(visual.getComplex()); @@ -90422,7 +90420,7 @@ Miew$1.prototype._addSceneObject = function (sceneObject) { objects[objects.length] = sceneObject; }; -Miew$1.prototype._updateObjsToFrame = function (frameData) { +Miew.prototype._updateObjsToFrame = function (frameData) { var objs = this._objects; for (var i = 0, n = objs.length; i < n; ++i) { if (objs[i].updateToFrame) { @@ -90431,7 +90429,7 @@ Miew$1.prototype._updateObjsToFrame = function (frameData) { } }; -Miew$1.prototype._resetObjects = function () { +Miew.prototype._resetObjects = function () { var objs = this._opts._objects; this._objects = []; @@ -90442,7 +90440,7 @@ Miew$1.prototype._resetObjects = function () { } }; -Miew$1.prototype.removeObject = function (index) { +Miew.prototype.removeObject = function (index) { var obj = this._objects[index]; if (!obj) { throw new Error('Scene object with index ' + index + ' does not exist'); @@ -90461,7 +90459,7 @@ Miew$1.prototype.removeObject = function (index) { * @param {boolean} [opts.view=false] - when this flag is true, a view information is included * @returns {string} URL */ -Miew$1.prototype.getURL = function (opts) { +Miew.prototype.getURL = function (opts) { return options.toURL(this.getState(lodash.defaults(opts, { compact: true, settings: false, @@ -90478,7 +90476,7 @@ Miew$1.prototype.getURL = function (opts) { * @param {boolean} [opts.view=true] - when this flag is true, a view information is included * @returns {string} script */ -Miew$1.prototype.getScript = function (opts) { +Miew.prototype.getScript = function (opts) { return options.toScript(this.getState(lodash.defaults(opts, { compact: true, settings: true, @@ -90491,7 +90489,7 @@ Miew$1.prototype.getScript = function (opts) { * @param {boolean} compareWithDefaults - when this flag is true, reps list is compared (if possible) * to preset's defaults and only diffs are generated */ -Miew$1.prototype._compareReps = function (complexVisual, compareWithDefaults) { +Miew.prototype._compareReps = function (complexVisual, compareWithDefaults) { var ans = {}; var repCount = 0; @@ -90530,7 +90528,7 @@ Miew$1.prototype._compareReps = function (complexVisual, compareWithDefaults) { * @param {boolean} [opts.view=false] - when this flag is true, a view information is included * @returns {Object} State object. */ -Miew$1.prototype.getState = function (opts) { +Miew.prototype.getState = function (opts) { var state = {}; opts = lodash.defaults(opts, { @@ -90596,11 +90594,11 @@ Miew$1.prototype.getState = function (opts) { * @param {*=} value - Default value. * @returns {*} Parameter value. */ -Miew$1.prototype.get = function (param, value) { +Miew.prototype.get = function (param, value) { return settings.get(param, value); }; -Miew$1.prototype._clipPlaneUpdateValue = function (radius) { +Miew.prototype._clipPlaneUpdateValue = function (radius) { var clipPlaneValue = Math.max(this._gfx.camera.position.z - radius * settings.now.draft.clipPlaneFactor, settings.now.camNear); var opts = { clipPlaneValue: clipPlaneValue }; @@ -90618,7 +90616,7 @@ Miew$1.prototype._clipPlaneUpdateValue = function (radius) { } }; -Miew$1.prototype._fogFarUpdateValue = function () { +Miew.prototype._fogFarUpdateValue = function () { if (this._picker !== null) { if (this._gfx.scene.fog) { this._picker.fogFarValue = this._gfx.scene.fog.far; @@ -90633,7 +90631,7 @@ Miew$1.prototype._fogFarUpdateValue = function () { * @param changes - differences with previous settings * @private */ -Miew$1.prototype._onSettingsChanged = function (changes) { +Miew.prototype._onSettingsChanged = function (changes) { if (!(changes instanceof Object)) { return; } @@ -90685,7 +90683,7 @@ Miew$1.prototype._onSettingsChanged = function (changes) { * @param {string|object} params - Parameter name or path (e.g. 'modes.BS.atom') or even settings object. * @param {*=} value - Value. */ -Miew$1.prototype.set = function (params, value) { +Miew.prototype.set = function (params, value) { if (typeof params === 'string' && value !== undefined) { // slow but avoids code duplication var key = params; @@ -90704,7 +90702,7 @@ Miew$1.prototype.set = function (params, value) { * @param {string} expression - string expression of selection * @param {boolean=} append - true to append selection atoms to current selection, false to rewrite selection */ -Miew$1.prototype.select = function (expression, append) { +Miew.prototype.select = function (expression, append) { var visual = this._getComplexVisual(); if (!visual) { return; @@ -90712,7 +90710,7 @@ Miew$1.prototype.select = function (expression, append) { var sel = expression; if (lodash.isString(expression)) { - sel = selectors.parse(expression).selector; + sel = selectors$4.parse(expression).selector; } visual.select(sel, append); @@ -90729,7 +90727,7 @@ var VIEW_VERSION = '1'; * * @param {string=} expression - Optional string encoded the view */ -Miew$1.prototype.view = function (expression) { +Miew.prototype.view = function (expression) { var self = this; var pivot = this._gfx.pivot; var transform = []; @@ -90797,7 +90795,7 @@ Miew$1.prototype.view = function (expression) { /* * Update current view due to viewinterpolator state */ -Miew$1.prototype._updateView = function () { +Miew.prototype._updateView = function () { var self = this; var pivot = this._gfx.pivot; @@ -90827,7 +90825,7 @@ Miew$1.prototype._updateView = function () { * @param {number} y - translation value (Ang) along model's Y axis * @param {number} z - translation value (Ang) along model's Z axis */ -Miew$1.prototype.translate = function (x, y, z) { +Miew.prototype.translate = function (x, y, z) { this._objectControls.translatePivot(x, y, z); this.dispatchEvent({ type: 'transform' }); this._needRender = true; @@ -90839,7 +90837,7 @@ Miew$1.prototype.translate = function (x, y, z) { * @param {number} y - rotation angle around Y axis in radians * @param {number} z - rotation angle around Z axis in radians */ -Miew$1.prototype.rotate = function (x, y, z) { +Miew.prototype.rotate = function (x, y, z) { this._objectControls.rotate(new Quaternion().setFromEuler(new Euler(x, y, z, 'XYZ'))); this.dispatchEvent({ type: 'transform' }); this._needRender = true; @@ -90849,7 +90847,7 @@ Miew$1.prototype.rotate = function (x, y, z) { * Scale object by factor * @param {number} factor - scale multiplier */ -Miew$1.prototype.scale = function (factor) { +Miew.prototype.scale = function (factor) { if (factor <= 0) { throw new RangeError('Scale should be greater than zero'); } @@ -90864,7 +90862,7 @@ Miew$1.prototype.scale = function (factor) { * @param {number} y - vertical panning * @deprecated Move object instead of panning the camera */ -Miew$1.prototype.pan = function (x, y) { +Miew.prototype.pan = function (x, y) { this._gfx.camera.translateX(x); this._gfx.camera.translateY(y); this._needRender = true; @@ -90876,14 +90874,14 @@ Miew$1.prototype.pan = function (x, y) { * @param {number} radius - distance * @returns {Selector} selector describing result group of atoms */ -Miew$1.prototype.within = function (selector, radius) { +Miew.prototype.within = function (selector, radius) { var visual = this._getComplexVisual(); if (!visual) { - return selectors.None(); + return selectors$4.None(); } if (selector instanceof String) { - selector = selectors.parse(selector); + selector = selectors$4.parse(selector); } var res = visual.within(selector, radius); @@ -90899,7 +90897,7 @@ Miew$1.prototype.within = function (selector, radius) { * @param {string} fullAtomName - full atom name, like A.38.CG * @returns {Object} {x, y} or false if atom not found */ -Miew$1.prototype.projected = function (fullAtomName, complexName) { +Miew.prototype.projected = function (fullAtomName, complexName) { var visual = this._getComplexVisual(complexName); if (!visual) { return false; @@ -91125,7 +91123,7 @@ function _convertData(data, opts, job) { var bytes = new Uint8Array(byteNumbers); var blob = new File([bytes], opts.fileName); console.time('convert'); - Miew$1.prototype.srvTopologyConvert(blob, opts.mdFile, function (success, newData, message) { + Miew.prototype.srvTopologyConvert(blob, opts.mdFile, function (success, newData, message) { console.timeEnd('convert'); if (success) { opts.converted = true; @@ -91188,11 +91186,11 @@ function _parseData(data, opts, job) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.10" !== 'undefined' && "0.7.10" || '0.0.0-dev'; +Miew.prototype.VERSION = typeof "0.7.11" !== 'undefined' && "0.7.11" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); -lodash.assign(Miew$1, /** @lends Miew */{ - VERSION: Miew$1.prototype.VERSION, +lodash.assign(Miew, /** @lends Miew */{ + VERSION: Miew.prototype.VERSION, registeredPlugins: [], @@ -91207,7 +91205,7 @@ lodash.assign(Miew$1, /** @lends Miew */{ utils: utils, gfx: { Representation: Representation, - fbxExport: exportAll + fbxExport: fbxExport }, /** @@ -92562,9 +92560,9 @@ var help = { function parseRange(node) { if (node instanceof Array) { - return new selectors$1.Range(node[0], node[1]); + return new selectors.Range(node[0], node[1]); } else { - return new selectors$1.Range(node, node); + return new selectors.Range(node, node); } } @@ -92573,7 +92571,7 @@ function parseRangeList(node) { for (var i = 0; i < node.length; ++i) { args.push(parseRange(node[i])); } - return new selectors$1.RangeList(args); + return new selectors.RangeList(args); } function parseValueList(node) { @@ -92581,26 +92579,26 @@ function parseValueList(node) { for (var i = 0; i < node.length; ++i) { args.push(node[i]); } - return new selectors$1.ValueList(args); + return new selectors.ValueList(args); } function _createSelectorFromNode(node) { - var factory = selectors$1.keyword(node[0]); + var factory = selectors.keyword(node[0]); if (!factory || !factory.SelectorClass) { return null; } var selector = null; var proto = factory.SelectorClass.prototype; - if (proto instanceof selectors$1.PrefixOperator && node.length === 2) { + if (proto instanceof selectors.PrefixOperator && node.length === 2) { selector = factory(_createSelectorFromNode(node[1])); - } else if (proto instanceof selectors$1.InfixOperator && node.length === 3) { + } else if (proto instanceof selectors.InfixOperator && node.length === 3) { selector = factory(_createSelectorFromNode(node[1]), _createSelectorFromNode(node[2])); - } else if (proto instanceof selectors$1.RangeListSelector && node.length === 2) { + } else if (proto instanceof selectors.RangeListSelector && node.length === 2) { selector = factory(parseRangeList(node[1])); - } else if (proto instanceof selectors$1.ValueListSelector && node.length === 2) { + } else if (proto instanceof selectors.ValueListSelector && node.length === 2) { selector = factory(parseValueList(node[1])); - } else if (proto instanceof selectors$1.Selector && node.length === 1) { + } else if (proto instanceof selectors.Selector && node.length === 1) { selector = factory(); } @@ -92621,13 +92619,13 @@ var JSONtoSelectorConverter = function () { return JSONtoSelectorConverter; }(); -var selectors$5 = Miew$1.chem.selectors; -var modes$1 = Miew$1.modes; -var colorers$1 = Miew$1.colorers; -var materials$1 = Miew$1.materials; -var palettes$1 = Miew$1.palettes; -var options$1 = Miew$1.options; -var settings$1 = Miew$1.settings; +var selectors$5 = Miew.chem.selectors; +var modes$1 = Miew.modes; +var colorers$1 = Miew.colorers; +var materials$1 = Miew.materials; +var palettes$1 = Miew.palettes; +var options$1 = Miew.options; +var settings$1 = Miew.settings; function None() {} @@ -93545,7 +93543,7 @@ cliutils.notimplemented = function () { return this.NULL; }; -Miew$1.prototype.script = function (script, _printCallback, _errorCallback) { +Miew.prototype.script = function (script, _printCallback, _errorCallback) { MiewCLIParser_1.yy.miew = this; MiewCLIParser_1.yy.echo = _printCallback; MiewCLIParser_1.yy.error = _errorCallback; @@ -93560,19 +93558,19 @@ Miew$1.prototype.script = function (script, _printCallback, _errorCallback) { this.cmdQueue = this.cmdQueue.concat(script.split('\n')); }; -Miew$1.prototype.awaitWhileCMDisInProcess = function () { +Miew.prototype.awaitWhileCMDisInProcess = function () { this.commandInAction = true; }; -Miew$1.prototype.finishAwaitingCMDInProcess = function () { +Miew.prototype.finishAwaitingCMDInProcess = function () { this.commandInAction = false; }; -Miew$1.prototype.isScriptingCommandAvailable = function () { +Miew.prototype.isScriptingCommandAvailable = function () { return this.commandInAction !== undefined && !this.commandInAction && this.cmdQueue !== undefined && this.cmdQueue.length > 0; }; -Miew$1.prototype.callNextCmd = function () { +Miew.prototype.callNextCmd = function () { if (this.isScriptingCommandAvailable()) { var cmd = this.cmdQueue.shift(); @@ -93591,13 +93589,13 @@ Miew$1.prototype.callNextCmd = function () { return ''; }; -Miew$1.JSONConverter = JSONtoSelectorConverter; +Miew.JSONConverter = JSONtoSelectorConverter; MiewCLIParser_1.yy = cliutils; // FIXME: workaround for incorrect JISON parser generator for AMD module MiewCLIParser_1.yy.parseError = MiewCLIParser_1.parseError; -return Miew$1; +return Miew; }))); //# sourceMappingURL=Miew.js.map diff --git a/dist/Miew.min.js b/dist/Miew.min.js index d2730bd6..576d7d37 100644 --- a/dist/Miew.min.js +++ b/dist/Miew.min.js @@ -1,9 +1,6 @@ -/** Miew - 3D Molecular Viewer v0.7.10 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:Ch++}),this.uuid=Eh.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:Pu,this.wrapT=void 0!==o?o:Pu,this.magFilter=void 0!==a?a:Ou,this.minFilter=void 0!==s?s:Fu,this.anisotropy=void 0!==u?u:1,this.format=void 0!==c?c:Ku,this.type=void 0!==l?l:zu,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:vh,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=Eh.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=Ou),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:Ru,this.minFilter=void 0!==u?u:Ru,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:bu,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=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 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 +8,8 @@ function so(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,r,n){for(var i=-1,o=null==t?0:t.length;++i-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>>1,k=[["ary",w],["bind",m],["bindKey",g],["curry",y],["curryRight",_],["flip",M],["partial",x],["partialRight",b],["rearg",S]],U="[object Arguments]",B="[object Array]",V="[object AsyncFunction]",j="[object Boolean]",G="[object Date]",W="[object DOMException]",H="[object Error]",X="[object Function]",Y="[object GeneratorFunction]",q="[object Map]",Z="[object Number]",$="[object Null]",K="[object Object]",Q="[object Promise]",J="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",at="[object WeakSet]",st="[object ArrayBuffer]",lt="[object DataView]",ct="[object Float32Array]",ut="[object Float64Array]",ht="[object Int8Array]",pt="[object Int16Array]",ft="[object Int32Array]",dt="[object Uint8Array]",mt="[object Uint8ClampedArray]",gt="[object Uint16Array]",vt="[object Uint32Array]",yt=/\b__p \+= '';/g,_t=/\b(__p \+=) '' \+/g,xt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bt=/&(?:amp|lt|gt|quot|#39);/g,wt=/[&<>"']/g,St=RegExp(bt.source),Mt=RegExp(wt.source),At=/<%-([\s\S]+?)%>/g,Et=/<%([\s\S]+?)%>/g,Ct=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pt=/^\w*$/,Lt=/^\./,Rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nt=/[\\^$.*+?()[\]{}|]/g,It=RegExp(Nt.source),Ot=/^\s+|\s+$/g,Dt=/^\s+/,Ft=/\s+$/,zt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,kt=/\{\n\/\* \[wrapped with (.+)\] \*/,Ut=/,? & /,Bt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Vt=/\\(\\)?/g,jt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Gt=/\w*$/,Wt=/^[-+]0x[0-9a-f]+$/i,Ht=/^0b[01]+$/i,Xt=/^\[object .+?Constructor\]$/,Yt=/^0o[0-7]+$/i,qt=/^(?:0|[1-9]\d*)$/,Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$t=/($^)/,Kt=/['\n\r\u2028\u2029\\]/g,Qt="\\ud800-\\udfff",Jt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",te="\\u2700-\\u27bf",ee="a-z\\xdf-\\xf6\\xf8-\\xff",re="A-Z\\xc0-\\xd6\\xd8-\\xde",ne="\\ufe0e\\ufe0f",ie="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",oe="['’]",ae="["+Qt+"]",se="["+ie+"]",le="["+Jt+"]",ce="\\d+",ue="["+te+"]",he="["+ee+"]",pe="[^"+Qt+ie+ce+te+ee+re+"]",fe="\\ud83c[\\udffb-\\udfff]",de="[^"+Qt+"]",me="(?:\\ud83c[\\udde6-\\uddff]){2}",ge="[\\ud800-\\udbff][\\udc00-\\udfff]",ve="["+re+"]",ye="\\u200d",_e="(?:"+he+"|"+pe+")",xe="(?:"+ve+"|"+pe+")",be="(?:['’](?:d|ll|m|re|s|t|ve))?",we="(?:['’](?:D|LL|M|RE|S|T|VE))?",Se="(?:"+le+"|"+fe+")"+"?",Me="["+ne+"]?",Ae=Me+Se+("(?:"+ye+"(?:"+[de,me,ge].join("|")+")"+Me+Se+")*"),Ee="(?:"+[ue,me,ge].join("|")+")"+Ae,Ce="(?:"+[de+le+"?",le,me,ge,ae].join("|")+")",Te=RegExp(oe,"g"),Pe=RegExp(le,"g"),Le=RegExp(fe+"(?="+fe+")|"+Ce+Ae,"g"),Re=RegExp([ve+"?"+he+"+"+be+"(?="+[se,ve,"$"].join("|")+")",xe+"+"+we+"(?="+[se,ve+_e,"$"].join("|")+")",ve+"?"+_e+"+"+be,ve+"+"+we,"\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",ce,Ee].join("|"),"g"),Ne=RegExp("["+ye+Qt+Jt+ne+"]"),Ie=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Oe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],De=-1,Fe={};Fe[ct]=Fe[ut]=Fe[ht]=Fe[pt]=Fe[ft]=Fe[dt]=Fe[mt]=Fe[gt]=Fe[vt]=!0,Fe[U]=Fe[B]=Fe[st]=Fe[j]=Fe[lt]=Fe[G]=Fe[H]=Fe[X]=Fe[q]=Fe[Z]=Fe[K]=Fe[tt]=Fe[et]=Fe[rt]=Fe[ot]=!1;var ze={};ze[U]=ze[B]=ze[st]=ze[lt]=ze[j]=ze[G]=ze[ct]=ze[ut]=ze[ht]=ze[pt]=ze[ft]=ze[q]=ze[Z]=ze[K]=ze[tt]=ze[et]=ze[rt]=ze[nt]=ze[dt]=ze[mt]=ze[gt]=ze[vt]=!0,ze[H]=ze[X]=ze[ot]=!1;var ke={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ue=parseFloat,Be=parseInt,Ve="object"==typeof t&&t&&t.Object===Object&&t,je="object"==typeof self&&self&&self.Object===Object&&self,Ge=Ve||je||Function("return this")(),We=r&&!r.nodeType&&r,He=We&&e&&!e.nodeType&&e,Xe=He&&He.exports===We,Ye=Xe&&Ve.process,qe=function(){try{return Ye&&Ye.binding&&Ye.binding("util")}catch(t){}}(),Ze=qe&&qe.isArrayBuffer,$e=qe&&qe.isDate,Ke=qe&&qe.isMap,Qe=qe&&qe.isRegExp,Je=qe&&qe.isSet,tr=qe&&qe.isTypedArray;function er(t,e){return t.set(e[0],e[1]),t}function rr(t,e){return t.add(e),t}function nr(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function ir(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function ur(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function Nr(t,e){for(var r=t.length;r--&&_r(e,t[r],0)>-1;);return r}var Ir=Mr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Or=Mr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Dr(t){return"\\"+ke[t]}function Fr(t){return Ne.test(t)}function zr(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function kr(t,e){return function(r){return t(e(r))}}function Ur(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Wr=function t(e){var r,Qt=(e=null==e?Ge:Wr.defaults(Ge.Object(),e,Wr.pick(Ge,Oe))).Array,Jt=e.Date,te=e.Error,ee=e.Function,re=e.Math,ne=e.Object,ie=e.RegExp,oe=e.String,ae=e.TypeError,se=Qt.prototype,le=ee.prototype,ce=ne.prototype,ue=e["__core-js_shared__"],he=le.toString,pe=ce.hasOwnProperty,fe=0,de=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",me=ce.toString,ge=he.call(ne),ve=Ge._,ye=ie("^"+he.call(pe).replace(Nt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_e=Xe?e.Buffer:n,xe=e.Symbol,be=e.Uint8Array,we=_e?_e.allocUnsafe:n,Se=kr(ne.getPrototypeOf,ne),Me=ne.create,Ae=ce.propertyIsEnumerable,Ee=se.splice,Ce=xe?xe.isConcatSpreadable:n,Le=xe?xe.iterator:n,Ne=xe?xe.toStringTag:n,ke=function(){try{var t=jo(ne,"defineProperty");return t({},"",{}),t}catch(t){}}(),Ve=e.clearTimeout!==Ge.clearTimeout&&e.clearTimeout,je=Jt&&Jt.now!==Ge.Date.now&&Jt.now,We=e.setTimeout!==Ge.setTimeout&&e.setTimeout,He=re.ceil,Ye=re.floor,qe=ne.getOwnPropertySymbols,gr=_e?_e.isBuffer:n,Mr=e.isFinite,Hr=se.join,Xr=kr(ne.keys,ne),Yr=re.max,qr=re.min,Zr=Jt.now,$r=e.parseInt,Kr=re.random,Qr=se.reverse,Jr=jo(e,"DataView"),tn=jo(e,"Map"),en=jo(e,"Promise"),rn=jo(e,"Set"),nn=jo(e,"WeakMap"),on=jo(ne,"create"),an=nn&&new nn,sn={},ln=ma(Jr),cn=ma(tn),un=ma(en),hn=ma(rn),pn=ma(nn),fn=xe?xe.prototype:n,dn=fn?fn.valueOf:n,mn=fn?fn.toString:n;function gn(t){if(Ns(t)&&!bs(t)&&!(t instanceof xn)){if(t instanceof _n)return t;if(pe.call(t,"__wrapped__"))return ga(t)}return new _n(t)}var vn=function(){function t(){}return function(e){if(!Rs(e))return{};if(Me)return Me(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function _n(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function xn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=D,this.__views__=[]}function bn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function kn(t,e,r,i,o,a){var s,l=e&u,c=e&h,f=e&p;if(r&&(s=o?r(t,i,o,a):r(t)),s!==n)return s;if(!Rs(t))return t;var d,m,g,v,y,_,x,b,w,S=bs(t);if(S){if(x=t,b=x.length,w=x.constructor(b),b&&"string"==typeof x[0]&&pe.call(x,"index")&&(w.index=x.index,w.input=x.input),s=w,!l)return oo(t,s)}else{var M=Ho(t),A=M==X||M==Y;if(As(t))return Ji(t,l);if(M==K||M==U||A&&!o){if(s=c||A?{}:Yo(t),!l)return c?(g=t,_=t,v=(y=s)&&ao(_,cl(_),y),ao(g,Wo(g),v)):(d=t,m=On(s,t),ao(d,Go(d),m))}else{if(!ze[M])return o?t:{};s=function(t,e,r,n){var i,o,a,s,l,c,h,p=t.constructor;switch(e){case st:return to(t);case j:case G:return new p(+t);case lt:return c=t,h=n?to(c.buffer):c.buffer,new c.constructor(h,c.byteOffset,c.byteLength);case ct:case ut:case ht:case pt:case ft:case dt:case mt:case gt:case vt:return eo(t,n);case q:return l=t,fr(n?r(zr(l),u):zr(l),er,new l.constructor);case Z:case rt:return new p(t);case tt:return(s=new(a=t).constructor(a.source,Gt.exec(a))).lastIndex=a.lastIndex,s;case et:return o=t,fr(n?r(Br(o),u):Br(o),rr,new o.constructor);case nt:return i=t,dn?ne(dn.call(i)):{}}}(t,M,kn,l)}}a||(a=new An);var E=a.get(t);if(E)return E;a.set(t,s);var C=S?n:(f?c?Do:Oo:c?cl:ll)(t);return or(C||t,function(n,i){C&&(n=t[i=n]),Rn(s,i,kn(n,e,r,i,t,a))}),s}function Un(t,e,r){var i=r.length;if(null==t)return!i;for(t=ne(t);i--;){var o=r[i],a=e[o],s=t[o];if(s===n&&!(o in t)||!a(s))return!1}return!0}function Bn(t,e,r){if("function"!=typeof t)throw new ae(a);return aa(function(){t.apply(n,r)},e)}function Vn(t,e,r,n){var o=-1,a=cr,s=!0,l=t.length,c=[],u=e.length;if(!l)return c;r&&(e=hr(e,Tr(r))),n?(a=ur,s=!1):e.length>=i&&(a=Lr,s=!1,e=new Mn(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Nn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Sn.prototype.clear=function(){this.size=0,this.__data__={hash:new bn,map:new(tn||wn),string:new bn}},Sn.prototype.delete=function(t){var e=Bo(this,t).delete(t);return this.size-=e?1:0,e},Sn.prototype.get=function(t){return Bo(this,t).get(t)},Sn.prototype.has=function(t){return Bo(this,t).has(t)},Sn.prototype.set=function(t,e){var r=Bo(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Mn.prototype.add=Mn.prototype.push=function(t){return this.__data__.set(t,s),this},Mn.prototype.has=function(t){return this.__data__.has(t)},An.prototype.clear=function(){this.__data__=new wn,this.size=0},An.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},An.prototype.get=function(t){return this.__data__.get(t)},An.prototype.has=function(t){return this.__data__.has(t)},An.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!tn||n.length0&&r(s)?e>1?Yn(s,e-1,r,n,i):pr(i,s):n||(i[i.length]=s)}return i}var qn=uo(),Zn=uo(!0);function $n(t,e){return t&&qn(t,e,ll)}function Kn(t,e){return t&&Zn(t,e,ll)}function Qn(t,e){return lr(e,function(e){return Ts(t[e])})}function Jn(t,e){for(var r=0,i=(e=Zi(e,t)).length;null!=t&&re}function ni(t,e){return null!=t&&pe.call(t,e)}function ii(t,e){return null!=t&&e in ne(t)}function oi(t,e,r){for(var i=r?ur:cr,o=t[0].length,a=t.length,s=a,l=Qt(a),c=1/0,u=[];s--;){var h=t[s];s&&e&&(h=hr(h,Tr(e))),c=qr(h.length,c),l[s]=!r&&(e||o>=120&&h.length>=120)?new Mn(s&&h):n}h=t[0];var p=-1,f=l[0];t:for(;++p=s)return l;var c=r[n];return l*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function bi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)s!==t&&Ee.call(s,l,1),Ee.call(t,l,1);return t}function Si(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Zo(i)?Ee.call(t,i,1):Vi(t,i)}}return t}function Mi(t,e){return t+Ye(Kr()*(e-t+1))}function Ai(t,e){var r="";if(!t||e<1||e>N)return r;do{e%2&&(r+=t),(e=Ye(e/2))&&(t+=t)}while(e);return r}function Ei(t,e){return sa(na(t,e,Ol),t+"")}function Ci(t){return Cn(vl(t))}function Ti(t,e){var r=vl(t);return ua(r,zn(e,0,r.length))}function Pi(t,e,r,i){if(!Rs(t))return t;for(var o=-1,a=(e=Zi(e,t)).length,s=a-1,l=t;null!=l&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Qt(i);++n>>1,a=t[o];null!==a&&!Us(a)&&(r?a<=e:a=i){var u=e?null:Eo(t);if(u)return Br(u);s=!1,o=Lr,c=new Mn}else c=e?[]:l;t:for(;++n=i?t:Ii(t,e,r)}var Qi=Ve||function(t){return Ge.clearTimeout(t)};function Ji(t,e){if(e)return t.slice();var r=t.length,n=we?we(r):new t.constructor(r);return t.copy(n),n}function to(t){var e=new t.constructor(t.byteLength);return new be(e).set(new be(t)),e}function eo(t,e){var r=e?to(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function ro(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,a=Us(t),s=e!==n,l=null===e,c=e==e,u=Us(e);if(!l&&!u&&!a&&t>e||a&&s&&c&&!l&&!u||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!u&&t1?r[o-1]:n,s=o>2?r[2]:n;for(a=t.length>3&&"function"==typeof a?(o--,a):n,s&&$o(r[0],r[1],s)&&(a=o<3?n:a,o=1),e=ne(e);++i-1?o[a?e[s]:s]:n}}function go(t){return Io(function(e){var r=e.length,i=r,o=_n.prototype.thru;for(t&&e.reverse();i--;){var s=e[i];if("function"!=typeof s)throw new ae(a);if(o&&!l&&"wrapper"==zo(s))var l=new _n([],!0)}for(i=l?i:r;++i1&&y.reverse(),h&&cl))return!1;var u=a.get(t);if(u&&a.get(e))return u==e;var h=-1,p=!0,m=r&d?new Mn:n;for(a.set(t,e),a.set(e,t);++h-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(zt,"{\n/* [wrapped with "+e+"] */\n")}(a,(o=a.match(kt),n=o?o[1].split(Ut):[],i=r,or(k,function(t){var e="_."+t[0];i&t[1]&&!cr(n,e)&&n.push(e)}),n.sort())))}function ca(t){var e=0,r=0;return function(){var i=Zr(),o=T-(i-r);if(r=i,o>0){if(++e>=C)return arguments[0]}else e=0;return t.apply(n,arguments)}}function ua(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Fa(t,r="function"==typeof r?(t.pop(),r):n)});function Ga(t){var e=gn(t);return e.__chain__=!0,e}function Wa(t,e){return e(t)}var Ha=Io(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return Fn(e,t)};return!(e>1||this.__actions__.length)&&i instanceof xn&&Zo(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Wa,args:[o],thisArg:n}),new _n(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var Xa=so(function(t,e,r){pe.call(t,r)?++t[r]:Dn(t,r,1)});var Ya=mo(xa),qa=mo(ba);function Za(t,e){return(bs(t)?or:jn)(t,Uo(e,3))}function $a(t,e){return(bs(t)?ar:Gn)(t,Uo(e,3))}var Ka=so(function(t,e,r){pe.call(t,r)?t[r].push(e):Dn(t,r,[e])});var Qa=Ei(function(t,e,r){var n=-1,i="function"==typeof e,o=Ss(t)?Qt(t.length):[];return jn(t,function(t){o[++n]=i?nr(e,t,r):ai(t,e,r)}),o}),Ja=so(function(t,e,r){Dn(t,r,e)});function ts(t,e){return(bs(t)?hr:mi)(t,Uo(e,3))}var es=so(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var rs=Ei(function(t,e){if(null==t)return[];var r=e.length;return r>1&&$o(t,e[0],e[1])?e=[]:r>2&&$o(e[0],e[1],e[2])&&(e=[e[0]]),xi(t,Yn(e,1),[])}),ns=je||function(){return Ge.Date.now()};function is(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,To(t,w,n,n,n,n,e)}function os(t,e){var r;if("function"!=typeof e)throw new ae(a);return t=Hs(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var as=Ei(function(t,e,r){var n=m;if(r.length){var i=Ur(r,ko(as));n|=x}return To(t,n,e,r,i)}),ss=Ei(function(t,e,r){var n=m|g;if(r.length){var i=Ur(r,ko(ss));n|=x}return To(e,n,t,r,i)});function ls(t,e,r){var i,o,s,l,c,u,h=0,p=!1,f=!1,d=!0;if("function"!=typeof t)throw new ae(a);function m(e){var r=i,a=o;return i=o=n,h=e,l=t.apply(a,r)}function g(t){var r=t-u;return u===n||r>=e||r<0||f&&t-h>=s}function v(){var t,r,n=ns();if(g(n))return y(n);c=aa(v,(r=e-((t=n)-u),f?qr(r,s-(t-h)):r))}function y(t){return c=n,d&&i?m(t):(i=o=n,l)}function _(){var t,r=ns(),a=g(r);if(i=arguments,o=this,u=r,a){if(c===n)return h=t=u,c=aa(v,e),p?m(t):l;if(f)return c=aa(v,e),m(u)}return c===n&&(c=aa(v,e)),l}return e=Ys(e)||0,Rs(r)&&(p=!!r.leading,s=(f="maxWait"in r)?Yr(Ys(r.maxWait)||0,e):s,d="trailing"in r?!!r.trailing:d),_.cancel=function(){c!==n&&Qi(c),h=0,i=u=o=c=n},_.flush=function(){return c===n?l:y(ns())},_}var cs=Ei(function(t,e){return Bn(t,1,e)}),us=Ei(function(t,e,r){return Bn(t,Ys(e)||0,r)});function hs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ae(a);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(hs.Cache||Sn),r}function ps(t){if("function"!=typeof t)throw new ae(a);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}hs.Cache=Sn;var fs=$i(function(t,e){var r=(e=1==e.length&&bs(e[0])?hr(e[0],Tr(Uo())):hr(Yn(e,1),Tr(Uo()))).length;return Ei(function(n){for(var i=-1,o=qr(n.length,r);++i=e}),xs=si(function(){return arguments}())?si:function(t){return Ns(t)&&pe.call(t,"callee")&&!Ae.call(t,"callee")},bs=Qt.isArray,ws=Ze?Tr(Ze):function(t){return Ns(t)&&ei(t)==st};function Ss(t){return null!=t&&Ls(t.length)&&!Ts(t)}function Ms(t){return Ns(t)&&Ss(t)}var As=gr||Yl,Es=$e?Tr($e):function(t){return Ns(t)&&ei(t)==G};function Cs(t){if(!Ns(t))return!1;var e=ei(t);return e==H||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ds(t)}function Ts(t){if(!Rs(t))return!1;var e=ei(t);return e==X||e==Y||e==V||e==J}function Ps(t){return"number"==typeof t&&t==Hs(t)}function Ls(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=N}function Rs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ns(t){return null!=t&&"object"==typeof t}var Is=Ke?Tr(Ke):function(t){return Ns(t)&&Ho(t)==q};function Os(t){return"number"==typeof t||Ns(t)&&ei(t)==Z}function Ds(t){if(!Ns(t)||ei(t)!=K)return!1;var e=Se(t);if(null===e)return!0;var r=pe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&he.call(r)==ge}var Fs=Qe?Tr(Qe):function(t){return Ns(t)&&ei(t)==tt};var zs=Je?Tr(Je):function(t){return Ns(t)&&Ho(t)==et};function ks(t){return"string"==typeof t||!bs(t)&&Ns(t)&&ei(t)==rt}function Us(t){return"symbol"==typeof t||Ns(t)&&ei(t)==nt}var Bs=tr?Tr(tr):function(t){return Ns(t)&&Ls(t.length)&&!!Fe[ei(t)]};var Vs=So(di),js=So(function(t,e){return t<=e});function Gs(t){if(!t)return[];if(Ss(t))return ks(t)?jr(t):oo(t);if(Le&&t[Le])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Le]());var e=Ho(t);return(e==q?zr:e==et?Br:vl)(t)}function Ws(t){return t?(t=Ys(t))===R||t===-R?(t<0?-1:1)*I:t==t?t:0:0===t?t:0}function Hs(t){var e=Ws(t),r=e%1;return e==e?r?e-r:e:0}function Xs(t){return t?zn(Hs(t),0,D):0}function Ys(t){if("number"==typeof t)return t;if(Us(t))return O;if(Rs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Rs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Ot,"");var r=Ht.test(t);return r||Yt.test(t)?Be(t.slice(2),r?2:8):Wt.test(t)?O:+t}function qs(t){return ao(t,cl(t))}function Zs(t){return null==t?"":Ui(t)}var $s=lo(function(t,e){if(ta(e)||Ss(e))ao(e,ll(e),t);else for(var r in e)pe.call(e,r)&&Rn(t,r,e[r])}),Ks=lo(function(t,e){ao(e,cl(e),t)}),Qs=lo(function(t,e,r,n){ao(e,cl(e),t,n)}),Js=lo(function(t,e,r,n){ao(e,ll(e),t,n)}),tl=Io(Fn);var el=Ei(function(t){return t.push(n,Po),nr(Qs,n,t)}),rl=Ei(function(t){return t.push(n,Lo),nr(hl,n,t)});function nl(t,e,r){var i=null==t?n:Jn(t,e);return i===n?r:i}function il(t,e){return null!=t&&Xo(t,e,ii)}var ol=yo(function(t,e,r){t[e]=r},Rl(Ol)),al=yo(function(t,e,r){pe.call(t,e)?t[e].push(r):t[e]=[r]},Uo),sl=Ei(ai);function ll(t){return Ss(t)?En(t):pi(t)}function cl(t){return Ss(t)?En(t,!0):fi(t)}var ul=lo(function(t,e,r){yi(t,e,r)}),hl=lo(function(t,e,r,n){yi(t,e,r,n)}),pl=Io(function(t,e){var r={};if(null==t)return r;var n=!1;e=hr(e,function(e){return e=Zi(e,t),n||(n=e.length>1),e}),ao(t,Do(t),r),n&&(r=kn(r,u|h|p,Ro));for(var i=e.length;i--;)Vi(r,e[i]);return r});var fl=Io(function(t,e){return null==t?{}:bi(r=t,e,function(t,e){return il(r,e)});var r});function dl(t,e){if(null==t)return{};var r=hr(Do(t),function(t){return[t]});return e=Uo(e),bi(t,r,function(t,r){return e(t,r[0])})}var ml=Co(ll),gl=Co(cl);function vl(t){return null==t?[]:Pr(t,ll(t))}var yl=po(function(t,e,r){return e=e.toLowerCase(),t+(r?_l(e):e)});function _l(t){return Cl(Zs(t).toLowerCase())}function xl(t){return(t=Zs(t))&&t.replace(Zt,Ir).replace(Pe,"")}var bl=po(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),wl=po(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),Sl=ho("toLowerCase");var Ml=po(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Al=po(function(t,e,r){return t+(r?" ":"")+Cl(e)});var El=po(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Cl=ho("toUpperCase");function Tl(t,e,r){return t=Zs(t),(e=r?n:e)===n?(i=t,Ie.test(i)?t.match(Re)||[]:t.match(Bt)||[]):t.match(e)||[];var i}var Pl=Ei(function(t,e){try{return nr(t,n,e)}catch(t){return Cs(t)?t:new te(t)}}),Ll=Io(function(t,e){return or(e,function(e){e=da(e),Dn(t,e,as(t[e],t))}),t});function Rl(t){return function(){return t}}var Nl=go(),Il=go(!0);function Ol(t){return t}function Dl(t){return hi("function"==typeof t?t:kn(t,u))}var Fl=Ei(function(t,e){return function(r){return ai(r,t,e)}}),zl=Ei(function(t,e){return function(r){return ai(t,r,e)}});function kl(t,e,r){var n=ll(e),i=Qn(e,n);null!=r||Rs(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Qn(e,ll(e)));var o=!(Rs(r)&&"chain"in r&&!r.chain),a=Ts(t);return or(i,function(r){var n=e[r];t[r]=n,a&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=oo(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,pr([this.value()],arguments))})}),t}function Ul(){}var Bl=xo(hr),Vl=xo(sr),jl=xo(mr);function Gl(t){return Ko(t)?Sr(da(t)):(e=t,function(t){return Jn(t,e)});var e}var Wl=wo(),Hl=wo(!0);function Xl(){return[]}function Yl(){return!1}var ql=_o(function(t,e){return t+e},0),Zl=Ao("ceil"),$l=_o(function(t,e){return t/e},1),Kl=Ao("floor");var Ql,Jl=_o(function(t,e){return t*e},1),tc=Ao("round"),ec=_o(function(t,e){return t-e},0);return gn.after=function(t,e){if("function"!=typeof e)throw new ae(a);return t=Hs(t),function(){if(--t<1)return e.apply(this,arguments)}},gn.ary=is,gn.assign=$s,gn.assignIn=Ks,gn.assignInWith=Qs,gn.assignWith=Js,gn.at=tl,gn.before=os,gn.bind=as,gn.bindAll=Ll,gn.bindKey=ss,gn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return bs(t)?t:[t]},gn.chain=Ga,gn.chunk=function(t,e,r){e=(r?$o(t,e,r):e===n)?1:Yr(Hs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,a=0,s=Qt(He(i/e));oo?0:o+r),(i=i===n||i>o?o:Hs(i))<0&&(i+=o),i=r>i?0:Xs(i);r>>0)?(t=Zs(t))&&("string"==typeof e||null!=e&&!Fs(e))&&!(e=Ui(e))&&Fr(t)?Ki(jr(t),0,r):t.split(e,r):[]},gn.spread=function(t,e){if("function"!=typeof t)throw new ae(a);return e=null==e?0:Yr(Hs(e),0),Ei(function(r){var n=r[e],i=Ki(r,0,e);return n&&pr(i,n),nr(t,this,i)})},gn.tail=function(t){var e=null==t?0:t.length;return e?Ii(t,1,e):[]},gn.take=function(t,e,r){return t&&t.length?Ii(t,0,(e=r||e===n?1:Hs(e))<0?0:e):[]},gn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Ii(t,(e=i-(e=r||e===n?1:Hs(e)))<0?0:e,i):[]},gn.takeRightWhile=function(t,e){return t&&t.length?Gi(t,Uo(e,3),!1,!0):[]},gn.takeWhile=function(t,e){return t&&t.length?Gi(t,Uo(e,3)):[]},gn.tap=function(t,e){return e(t),t},gn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ae(a);return Rs(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),ls(t,e,{leading:n,maxWait:e,trailing:i})},gn.thru=Wa,gn.toArray=Gs,gn.toPairs=ml,gn.toPairsIn=gl,gn.toPath=function(t){return bs(t)?hr(t,da):Us(t)?[t]:oo(fa(Zs(t)))},gn.toPlainObject=qs,gn.transform=function(t,e,r){var n=bs(t),i=n||As(t)||Bs(t);if(e=Uo(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Rs(t)&&Ts(o)?vn(Se(t)):{}}return(i?or:$n)(t,function(t,n,i){return e(r,t,n,i)}),r},gn.unary=function(t){return is(t,1)},gn.union=Na,gn.unionBy=Ia,gn.unionWith=Oa,gn.uniq=function(t){return t&&t.length?Bi(t):[]},gn.uniqBy=function(t,e){return t&&t.length?Bi(t,Uo(e,2)):[]},gn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Bi(t,n,e):[]},gn.unset=function(t,e){return null==t||Vi(t,e)},gn.unzip=Da,gn.unzipWith=Fa,gn.update=function(t,e,r){return null==t?t:ji(t,e,qi(r))},gn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:ji(t,e,qi(r),i)},gn.values=vl,gn.valuesIn=function(t){return null==t?[]:Pr(t,cl(t))},gn.without=za,gn.words=Tl,gn.wrap=function(t,e){return ds(qi(e),t)},gn.xor=ka,gn.xorBy=Ua,gn.xorWith=Ba,gn.zip=Va,gn.zipObject=function(t,e){return Xi(t||[],e||[],Rn)},gn.zipObjectDeep=function(t,e){return Xi(t||[],e||[],Pi)},gn.zipWith=ja,gn.entries=ml,gn.entriesIn=gl,gn.extend=Ks,gn.extendWith=Qs,kl(gn,gn),gn.add=ql,gn.attempt=Pl,gn.camelCase=yl,gn.capitalize=_l,gn.ceil=Zl,gn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Ys(r))==r?r:0),e!==n&&(e=(e=Ys(e))==e?e:0),zn(Ys(t),e,r)},gn.clone=function(t){return kn(t,p)},gn.cloneDeep=function(t){return kn(t,u|p)},gn.cloneDeepWith=function(t,e){return kn(t,u|p,e="function"==typeof e?e:n)},gn.cloneWith=function(t,e){return kn(t,p,e="function"==typeof e?e:n)},gn.conformsTo=function(t,e){return null==e||Un(t,e,ll(e))},gn.deburr=xl,gn.defaultTo=function(t,e){return null==t||t!=t?e:t},gn.divide=$l,gn.endsWith=function(t,e,r){t=Zs(t),e=Ui(e);var i=t.length,o=r=r===n?i:zn(Hs(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},gn.eq=vs,gn.escape=function(t){return(t=Zs(t))&&Mt.test(t)?t.replace(wt,Or):t},gn.escapeRegExp=function(t){return(t=Zs(t))&&It.test(t)?t.replace(Nt,"\\$&"):t},gn.every=function(t,e,r){var i=bs(t)?sr:Wn;return r&&$o(t,e,r)&&(e=n),i(t,Uo(e,3))},gn.find=Ya,gn.findIndex=xa,gn.findKey=function(t,e){return vr(t,Uo(e,3),$n)},gn.findLast=qa,gn.findLastIndex=ba,gn.findLastKey=function(t,e){return vr(t,Uo(e,3),Kn)},gn.floor=Kl,gn.forEach=Za,gn.forEachRight=$a,gn.forIn=function(t,e){return null==t?t:qn(t,Uo(e,3),cl)},gn.forInRight=function(t,e){return null==t?t:Zn(t,Uo(e,3),cl)},gn.forOwn=function(t,e){return t&&$n(t,Uo(e,3))},gn.forOwnRight=function(t,e){return t&&Kn(t,Uo(e,3))},gn.get=nl,gn.gt=ys,gn.gte=_s,gn.has=function(t,e){return null!=t&&Xo(t,e,ni)},gn.hasIn=il,gn.head=Sa,gn.identity=Ol,gn.includes=function(t,e,r,n){t=Ss(t)?t:vl(t),r=r&&!n?Hs(r):0;var i=t.length;return r<0&&(r=Yr(i+r,0)),ks(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&_r(t,e,r)>-1},gn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:Hs(r);return i<0&&(i=Yr(n+i,0)),_r(t,e,i)},gn.inRange=function(t,e,r){return e=Ws(e),r===n?(r=e,e=0):r=Ws(r),t=Ys(t),(i=t)>=qr(o=e,a=r)&&i=-N&&t<=N},gn.isSet=zs,gn.isString=ks,gn.isSymbol=Us,gn.isTypedArray=Bs,gn.isUndefined=function(t){return t===n},gn.isWeakMap=function(t){return Ns(t)&&Ho(t)==ot},gn.isWeakSet=function(t){return Ns(t)&&ei(t)==at},gn.join=function(t,e){return null==t?"":Hr.call(t,e)},gn.kebabCase=bl,gn.last=Ca,gn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=Hs(r))<0?Yr(i+o,0):qr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):yr(t,br,o,!0)},gn.lowerCase=wl,gn.lowerFirst=Sl,gn.lt=Vs,gn.lte=js,gn.max=function(t){return t&&t.length?Hn(t,Ol,ri):n},gn.maxBy=function(t,e){return t&&t.length?Hn(t,Uo(e,2),ri):n},gn.mean=function(t){return wr(t,Ol)},gn.meanBy=function(t,e){return wr(t,Uo(e,2))},gn.min=function(t){return t&&t.length?Hn(t,Ol,di):n},gn.minBy=function(t,e){return t&&t.length?Hn(t,Uo(e,2),di):n},gn.stubArray=Xl,gn.stubFalse=Yl,gn.stubObject=function(){return{}},gn.stubString=function(){return""},gn.stubTrue=function(){return!0},gn.multiply=Jl,gn.nth=function(t,e){return t&&t.length?_i(t,Hs(e)):n},gn.noConflict=function(){return Ge._===this&&(Ge._=ve),this},gn.noop=Ul,gn.now=ns,gn.pad=function(t,e,r){t=Zs(t);var n=(e=Hs(e))?Vr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return bo(Ye(i),r)+t+bo(He(i),r)},gn.padEnd=function(t,e,r){t=Zs(t);var n=(e=Hs(e))?Vr(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Kr();return qr(t+o*(e-t+Ue("1e-"+((o+"").length-1))),e)}return Mi(t,e)},gn.reduce=function(t,e,r){var n=bs(t)?fr:Ar,i=arguments.length<3;return n(t,Uo(e,4),r,i,jn)},gn.reduceRight=function(t,e,r){var n=bs(t)?dr:Ar,i=arguments.length<3;return n(t,Uo(e,4),r,i,Gn)},gn.repeat=function(t,e,r){return e=(r?$o(t,e,r):e===n)?1:Hs(e),Ai(Zs(t),e)},gn.replace=function(){var t=arguments,e=Zs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},gn.result=function(t,e,r){var i=-1,o=(e=Zi(e,t)).length;for(o||(o=1,t=n);++iN)return[];var r=D,n=qr(t,D);e=Uo(e),t-=D;for(var i=Cr(n,e);++r=a)return t;var l=r-Vr(i);if(l<1)return i;var c=s?Ki(s,0,l).join(""):t.slice(0,l);if(o===n)return c+i;if(s&&(l+=c.length-l),Fs(o)){if(t.slice(l).search(o)){var u,h=c;for(o.global||(o=ie(o.source,Zs(Gt.exec(o))+"g")),o.lastIndex=0;u=o.exec(h);)var p=u.index;c=c.slice(0,p===n?l:p)}}else if(t.indexOf(Ui(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+i},gn.unescape=function(t){return(t=Zs(t))&&St.test(t)?t.replace(bt,Gr):t},gn.uniqueId=function(t){var e=++fe;return Zs(t)+e},gn.upperCase=El,gn.upperFirst=Cl,gn.each=Za,gn.eachRight=$a,gn.first=Sa,kl(gn,(Ql={},$n(gn,function(t,e){pe.call(gn.prototype,e)||(Ql[e]=t)}),Ql),{chain:!1}),gn.VERSION="4.17.4",or(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){gn[t].placeholder=gn}),or(["drop","take"],function(t,e){xn.prototype[t]=function(r){r=r===n?1:Yr(Hs(r),0);var i=this.__filtered__&&!e?new xn(this):this.clone();return i.__filtered__?i.__takeCount__=qr(r,i.__takeCount__):i.__views__.push({size:qr(r,D),type:t+(i.__dir__<0?"Right":"")}),i},xn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),or(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==P||3==r;xn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Uo(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),or(["head","last"],function(t,e){var r="take"+(e?"Right":"");xn.prototype[t]=function(){return this[r](1).value()[0]}}),or(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");xn.prototype[t]=function(){return this.__filtered__?new xn(this):this[r](1)}}),xn.prototype.compact=function(){return this.filter(Ol)},xn.prototype.find=function(t){return this.filter(t).head()},xn.prototype.findLast=function(t){return this.reverse().find(t)},xn.prototype.invokeMap=Ei(function(t,e){return"function"==typeof t?new xn(this):this.map(function(r){return ai(r,t,e)})}),xn.prototype.reject=function(t){return this.filter(ps(Uo(t)))},xn.prototype.slice=function(t,e){t=Hs(t);var r=this;return r.__filtered__&&(t>0||e<0)?new xn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=Hs(e))<0?r.dropRight(-e):r.take(e-t)),r)},xn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},xn.prototype.toArray=function(){return this.take(D)},$n(xn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=gn[i?"take"+("last"==e?"Right":""):e],a=i||/^find/.test(e);o&&(gn.prototype[e]=function(){var e=this.__wrapped__,s=i?[1]:arguments,l=e instanceof xn,c=s[0],u=l||bs(e),h=function(t){var e=o.apply(gn,pr([t],s));return i&&p?e[0]:e};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var p=this.__chain__,f=!!this.__actions__.length,d=a&&!p,m=l&&!f;if(!a&&u){e=m?e:new xn(this);var g=t.apply(e,s);return g.__actions__.push({func:Wa,args:[h],thisArg:n}),new _n(g,p)}return d&&m?t.apply(this,s):(g=this.thru(h),d?i?g.value()[0]:g.value():g)})}),or(["pop","push","shift","sort","splice","unshift"],function(t){var e=se[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);gn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(bs(i)?i:[],t)}return this[r](function(r){return e.apply(bs(r)?r:[],t)})}}),$n(xn.prototype,function(t,e){var r=gn[e];if(r){var n=r.name+"";(sn[n]||(sn[n]=[])).push({name:e,func:r})}}),sn[vo(n,g).name]=[{name:"wrapper",func:n}],xn.prototype.clone=function(){var t=new xn(this.__wrapped__);return t.__actions__=oo(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=oo(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=oo(this.__views__),t},xn.prototype.reverse=function(){if(this.__filtered__){var t=new xn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},xn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=bs(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},gn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ga(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},gn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof xn){var e=t;return this.__actions__.length&&(e=new xn(this)),(e=e.reverse()).__actions__.push({func:Wa,args:[Ra],thisArg:n}),new _n(e,this.__chain__)}return this.thru(Ra)},gn.prototype.toJSON=gn.prototype.valueOf=gn.prototype.value=function(){return Wi(this.__wrapped__,this.__actions__)},gn.prototype.first=gn.prototype.head,Le&&(gn.prototype[Le]=function(){return this}),gn}();"function"==typeof n&&"object"==typeof n.amd&&n.amd?(Ge._=Wr,n(function(){return Wr})):He?((He.exports=Wr)._=Wr,We._=Wr):Ge._=Wr}).call(t)});function i(){}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>=4,s[t]=a[19===t?3&o|8:o]);return s.join("")}),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*ye.DEG2RAD},radToDeg:function(t){return t*ye.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};function _e(t,e){this.x=t||0,this.y=e||0}Object.defineProperties(_e.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(_e.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:(c=new _e,u=new _e,function(t,e){return c.set(t,t),u.set(e,e),this.clamp(c,u)}),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}});var xe,be,we,Se,Me,Ae,Ee,Ce,Te,Pe,Le,Re,Ne,Ie,Oe,De,Fe,ze,ke,Ue=0;function Be(t,e,r,n,i,o,a,s,l,c){Object.defineProperty(this,"id",{value:Ue++}),this.uuid=ye.generateUUID(),this.name="",this.image=void 0!==t?t:Be.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Be.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:vt,this.wrapT=void 0!==n?n:vt,this.magFilter=void 0!==i?i:wt,this.minFilter=void 0!==o?o:Mt,this.anisotropy=void 0!==l?l:1,this.format=void 0!==a?a:Ut,this.type=void 0!==s?s:At,this.offset=new _e(0,0),this.repeat=new _e(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==c?c:ce,this.version=0,this.onUpdate=null}function Ve(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function je(t,e,r){this.uuid=ye.generateUUID(),this.width=t,this.height=e,this.scissor=new Ve(0,0,t,e),this.scissorTest=!1,this.viewport=new Ve(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=wt),this.texture=new Be(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function Ge(t,e,r){je.call(this,t,e,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function We(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function He(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function Xe(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length}function Ye(t,e,r,n,i,o,a,s,l,c,u,h){Be.call(this,null,o,a,s,l,c,n,i,u,h),this.image={data:t,width:e,height:r},this.magFilter=void 0!==l?l:_t,this.minFilter=void 0!==c?c:_t,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function qe(t,e,r,n,i,o,a,s,l,c){t=void 0!==t?t:[],e=void 0!==e?e:ct,Be.call(this,t,e,r,n,i,o,a,s,l,c),this.flipY=!1}Be.DEFAULT_IMAGE=void 0,Be.DEFAULT_MAPPING=300,Object.defineProperty(Be.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Be.prototype,i.prototype,{constructor:Be,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=ye.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.uuid,url:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height;var r=e.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case vt:t.x=t.x<0?0:1;break;case yt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case gt:t.y=t.y-Math.floor(t.y);break;case vt:t.y=t.y<0?0:1;break;case yt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.assign(Ve.prototype,{isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,o=t.elements,a=o[0],s=o[4],l=o[8],c=o[1],u=o[5],h=o[9],p=o[2],f=o[6],d=o[10];if(Math.abs(s-c)<.01&&Math.abs(l-p)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+c)<.1&&Math.abs(l+p)<.1&&Math.abs(h+f)<.1&&Math.abs(a+u+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(u+1)/2,v=(d+1)/2,y=(s+c)/4,_=(l+p)/4,x=(h+f)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(n=y/(r=Math.sqrt(m)),i=_/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(r=y/(n=Math.sqrt(g)),i=x/n):v<.01?(r=.707106781,n=.707106781,i=0):(r=_/(i=Math.sqrt(v)),n=x/i),this.set(r,n,i,e),this}var b=Math.sqrt((f-h)*(f-h)+(l-p)*(l-p)+(c-s)*(c-s));return Math.abs(b)<.001&&(b=1),this.x=(f-h)/b,this.y=(l-p)/b,this.z=(c-s)/b,this.w=Math.acos((a+u+d-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return void 0===xe&&(xe=new Ve,be=new Ve),xe.set(t,t,t,t),be.set(e,e,e,e),this.clamp(xe,be)},clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(je.prototype,i.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Ge.prototype=Object.create(je.prototype),Ge.prototype.constructor=Ge,Ge.prototype.isWebGLRenderTargetCube=!0,Object.assign(We,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,o,a){var s=r[n+0],l=r[n+1],c=r[n+2],u=r[n+3],h=i[o+0],p=i[o+1],f=i[o+2],d=i[o+3];if(u!==d||s!==h||l!==p||c!==f){var m=1-a,g=s*h+l*p+c*f+u*d,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var _=Math.sqrt(y),x=Math.atan2(_,g*v);m=Math.sin(m*x)/_,a=Math.sin(a*x)/_}var b=a*v;if(s=s*m+h*b,l=l*m+p*b,c=c*m+f*b,u=u*m+d*b,m===1-a){var w=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=w,l*=w,c*=w,u*=w}}t[e]=s,t[e+1]=l,t[e+2]=c,t[e+3]=u}}),Object.defineProperties(We.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(We.prototype,{set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,n=t._y,i=t._z,o=t.order,a=Math.cos,s=Math.sin,l=a(r/2),c=a(n/2),u=a(i/2),h=s(r/2),p=s(n/2),f=s(i/2);return"XYZ"===o?(this._x=h*c*u+l*p*f,this._y=l*p*u-h*c*f,this._z=l*c*f+h*p*u,this._w=l*c*u-h*p*f):"YXZ"===o?(this._x=h*c*u+l*p*f,this._y=l*p*u-h*c*f,this._z=l*c*f-h*p*u,this._w=l*c*u+h*p*f):"ZXY"===o?(this._x=h*c*u-l*p*f,this._y=l*p*u+h*c*f,this._z=l*c*f+h*p*u,this._w=l*c*u-h*p*f):"ZYX"===o?(this._x=h*c*u-l*p*f,this._y=l*p*u+h*c*f,this._z=l*c*f-h*p*u,this._w=l*c*u+h*p*f):"YZX"===o?(this._x=h*c*u+l*p*f,this._y=l*p*u+h*c*f,this._z=l*c*f-h*p*u,this._w=l*c*u-h*p*f):"XZY"===o&&(this._x=h*c*u-l*p*f,this._y=l*p*u-h*c*f,this._z=l*c*f+h*p*u,this._w=l*c*u+h*p*f),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],l=r[9],c=r[2],u=r[6],h=r[10],p=n+s+h;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(u-l)*e,this._y=(o-c)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-l)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+c)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-c)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(l+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+c)/e,this._y=(l+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:(Se=new He,function(t,e){return void 0===Se&&(Se=new He),(we=t.dot(e)+1)<1e-6?(we=0,Math.abs(t.x)>Math.abs(t.z)?Se.set(-t.y,t.x,0):Se.set(0,-t.z,t.y)):Se.crossVectors(t,e),this._x=Se.x,this._y=Se.y,this._z=Se.z,this._w=we,this.normalize()}),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?this.multiplyQuaternions(t,e):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,n=t._y,i=t._z,o=t._w,a=e._x,s=e._y,l=e._z,c=e._w;return this._x=r*c+o*a+n*l-i*s,this._y=n*c+o*s+i*a-r*l,this._z=i*c+o*l+r*s-n*a,this._w=o*c-r*a-n*s-i*l,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var l=Math.atan2(s,a),c=Math.sin((1-e)*l)/s,u=Math.sin(e*l)/s;return this._w=o*c+this._w*u,this._x=r*c+this._x*u,this._y=n*c+this._y*u,this._z=i*c+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(He.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:(Re=new We,function(t){return!t||t.isEuler,this.applyQuaternion(Re.setFromEuler(t))}),applyAxisAngle:(Le=new We,function(t,e){return this.applyQuaternion(Le.setFromAxisAngle(t,e))}),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements,o=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*o,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*o,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,a=t.z,s=t.w,l=s*e+o*n-a*r,c=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=l*s+h*-i+c*-a-u*-o,this.y=c*s+h*-o+u*-i-l*-a,this.z=u*s+h*-a+l*-o-c*-i,this},project:(Pe=new Xe,function(t){return Pe.multiplyMatrices(t.projectionMatrix,Pe.getInverse(t.matrixWorld)),this.applyMatrix4(Pe)}),unproject:(Te=new Xe,function(t){return Te.multiplyMatrices(t.matrixWorld,Te.getInverse(t.projectionMatrix)),this.applyMatrix4(Te)}),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:(Ee=new He,Ce=new He,function(t,e){return Ee.set(t,t,t),Ce.set(e,e,e),this.clamp(Ee,Ce)}),clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:(Ae=new He,function(t){return Ae.copy(this).projectOnVector(t),this.sub(Ae)}),reflect:(Me=new He,function(t){return this.sub(Me.copy(t).multiplyScalar(2*this.dot(t)))}),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(ye.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(Xe.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,l,c,u,h,p,f,d,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new Xe).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:(ke=new He,function(t){var e=this.elements,r=t.elements,n=1/ke.setFromMatrixColumn(t,0).length(),i=1/ke.setFromMatrixColumn(t,1).length(),o=1/ke.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,this}),makeRotationFromEuler:function(t){!t||t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),l=Math.sin(n),c=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*c,p=o*u,f=a*c,d=a*u;e[0]=s*c,e[4]=-s*u,e[8]=l,e[1]=p+f*l,e[5]=h-d*l,e[9]=-a*s,e[2]=d-h*l,e[6]=f+p*l,e[10]=o*s}else if("YXZ"===t.order){var m=s*c,g=s*u,v=l*c,y=l*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*l,e[1]=o*u,e[5]=o*c,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*c,g=s*u,v=l*c,y=l*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*c,e[9]=y-m*a,e[2]=-o*l,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){h=o*c,p=o*u,f=a*c,d=a*u;e[0]=s*c,e[4]=f*l-p,e[8]=h*l+d,e[1]=s*u,e[5]=d*l+h,e[9]=p*l-f,e[2]=-l,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*l,b=a*s,w=a*l;e[0]=s*c,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*c,e[9]=-a*c,e[2]=-l*c,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){_=o*s,x=o*l,b=a*s,w=a*l;e[0]=s*c,e[4]=-u,e[8]=l*c,e[1]=_*u+w,e[5]=o*c,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*c,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,n=t._y,i=t._z,o=t._w,a=r+r,s=n+n,l=i+i,c=r*a,u=r*s,h=r*l,p=n*s,f=n*l,d=i*l,m=o*a,g=o*s,v=o*l;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(c+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(c+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:(De=new He,Fe=new He,ze=new He,function(t,e,r){var n=this.elements;return ze.subVectors(t,e),0===ze.lengthSq()&&(ze.z=1),ze.normalize(),De.crossVectors(r,ze),0===De.lengthSq()&&(1===Math.abs(r.z)?ze.x+=1e-4:ze.z+=1e-4,ze.normalize(),De.crossVectors(r,ze)),De.normalize(),Fe.crossVectors(ze,De),n[0]=De.x,n[4]=Fe.x,n[8]=ze.x,n[1]=De.y,n[5]=Fe.y,n[9]=ze.y,n[2]=De.z,n[6]=Fe.z,n[10]=ze.z,this}),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],l=r[12],c=r[1],u=r[5],h=r[9],p=r[13],f=r[2],d=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],F=n[15];return i[0]=o*b+a*A+s*P+l*I,i[4]=o*w+a*E+s*L+l*O,i[8]=o*S+a*C+s*R+l*D,i[12]=o*M+a*T+s*N+l*F,i[1]=c*b+u*A+h*P+p*I,i[5]=c*w+u*E+h*L+p*O,i[9]=c*S+u*C+h*R+p*D,i[13]=c*M+u*T+h*N+p*F,i[2]=f*b+d*A+m*P+g*I,i[6]=f*w+d*E+m*L+g*O,i[10]=f*S+d*C+m*R+g*D,i[14]=f*M+d*T+m*N+g*F,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*F,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:(Oe=new He,function(t){for(var e=0,r=t.count;e0)return t;var i=e*r,o=Qe[i];if(void 0===o&&(o=new Float32Array(i),Qe[i]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function nr(t,e){var r=Je[e];void 0===r&&(r=new Int32Array(e),Je[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function ir(t,e){t.uniform1f(this.addr,e)}function or(t,e){t.uniform1i(this.addr,e)}function ar(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function sr(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function lr(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function cr(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function ur(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(er.set(e.elements),t.uniformMatrix3fv(this.addr,!1,er))}function hr(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(tr.set(e.elements),t.uniformMatrix4fv(this.addr,!1,tr))}function pr(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Ze,n)}function fr(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||$e,n)}function dr(t,e){t.uniform2iv(this.addr,e)}function mr(t,e){t.uniform3iv(this.addr,e)}function gr(t,e){t.uniform4iv(this.addr,e)}function vr(t,e){t.uniform1fv(this.addr,e)}function yr(t,e){t.uniform1iv(this.addr,e)}function _r(t,e){t.uniform2fv(this.addr,rr(e,this.size,2))}function xr(t,e){t.uniform3fv(this.addr,rr(e,this.size,3))}function br(t,e){t.uniform4fv(this.addr,rr(e,this.size,4))}function wr(t,e){t.uniformMatrix2fv(this.addr,!1,rr(e,this.size,4))}function Sr(t,e){t.uniformMatrix3fv(this.addr,!1,rr(e,this.size,9))}function Mr(t,e){t.uniformMatrix4fv(this.addr,!1,rr(e,this.size,16))}function Ar(t,e,r){var n=e.length,i=nr(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||Ze,i[o])}function Er(t,e,r){var n=e.length,i=nr(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||$e,i[o])}function Cr(t,e,r){this.id=t,this.addr=r,this.setValue=function(t){switch(t){case 5126:return ir;case 35664:return ar;case 35665:return sr;case 35666:return lr;case 35674:return cr;case 35675:return ur;case 35676:return hr;case 35678:case 36198:return pr;case 35680:return fr;case 5124:case 35670:return or;case 35667:case 35671:return dr;case 35668:case 35672:return mr;case 35669:case 35673:return gr}}(e.type)}function Tr(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return vr;case 35664:return _r;case 35665:return xr;case 35666:return br;case 35674:return wr;case 35675:return Sr;case 35676:return Mr;case 35678:return Ar;case 35680:return Er;case 5124:case 35670:return yr;case 35667:case 35671:return dr;case 35668:case 35672:return mr;case 35669:case 35673:return gr}}(e.type)}function Pr(t){this.id=t,Ke.call(this)}Pr.prototype.setValue=function(t,e){for(var r=this.seq,n=0,i=r.length;n!==i;++n){var o=r[n];o.setValue(t,e[o.id])}};var Lr=/([\w\d_]+)(\])?(\[|\.)?/g;function Rr(t,e){t.seq.push(e),t.map[e.id]=e}function Nr(t,e,r){var n=t.name,i=n.length;for(Lr.lastIndex=0;;){var o=Lr.exec(n),a=Lr.lastIndex,s=o[1],l="]"===o[2],c=o[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===i){Rr(r,void 0===c?new Cr(s,t,e):new Tr(s,t,e));break}var u=r.map[s];void 0===u&&Rr(r,u=new Pr(s)),r=u}}function Ir(t,e,r){Ke.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=ye.euclideanModulo(e,1),r=ye.clamp(r,0,1),n=ye.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,l=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,l)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var c,u=(c=r[1]).length;if(3===u)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}t&&t.length>0&&(void 0!==(c=Or[t])&&this.setHex(c));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),l=Math.min(i,o,a),c=(l+s)/2;if(l===s)e=0,r=0;else{var u=s-l;switch(r=c<=.5?u/(s+l):u/(2-s-l),s){case i:e=(o-a)/u+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},Vr={basic:{uniforms:Ur.merge([kr.common,kr.specularmap,kr.envmap,kr.aomap,kr.lightmap,kr.fog]),vertexShader:Br.meshbasic_vert,fragmentShader:Br.meshbasic_frag},lambert:{uniforms:Ur.merge([kr.common,kr.specularmap,kr.envmap,kr.aomap,kr.lightmap,kr.emissivemap,kr.fog,kr.lights,{emissive:{value:new Dr(0)}}]),vertexShader:Br.meshlambert_vert,fragmentShader:Br.meshlambert_frag},phong:{uniforms:Ur.merge([kr.common,kr.specularmap,kr.envmap,kr.aomap,kr.lightmap,kr.emissivemap,kr.bumpmap,kr.normalmap,kr.displacementmap,kr.gradientmap,kr.fog,kr.lights,{emissive:{value:new Dr(0)},specular:{value:new Dr(1118481)},shininess:{value:30}}]),vertexShader:Br.meshphong_vert,fragmentShader:Br.meshphong_frag},standard:{uniforms:Ur.merge([kr.common,kr.envmap,kr.aomap,kr.lightmap,kr.emissivemap,kr.bumpmap,kr.normalmap,kr.displacementmap,kr.roughnessmap,kr.metalnessmap,kr.fog,kr.lights,{emissive:{value:new Dr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Br.meshphysical_vert,fragmentShader:Br.meshphysical_frag},points:{uniforms:Ur.merge([kr.points,kr.fog]),vertexShader:Br.points_vert,fragmentShader:Br.points_frag},dashed:{uniforms:Ur.merge([kr.common,kr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Br.linedashed_vert,fragmentShader:Br.linedashed_frag},depth:{uniforms:Ur.merge([kr.common,kr.displacementmap]),vertexShader:Br.depth_vert,fragmentShader:Br.depth_frag},normal:{uniforms:Ur.merge([kr.common,kr.bumpmap,kr.normalmap,kr.displacementmap,{opacity:{value:1}}]),vertexShader:Br.normal_vert,fragmentShader:Br.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Br.cube_vert,fragmentShader:Br.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Br.equirect_vert,fragmentShader:Br.equirect_frag},distanceRGBA:{uniforms:Ur.merge([kr.common,kr.displacementmap,{referencePosition:{value:new He},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Br.distanceRGBA_vert,fragmentShader:Br.distanceRGBA_frag},shadow:{uniforms:Ur.merge([kr.lights,{color:{value:new Dr(0)},opacity:{value:1}}]),vertexShader:Br.shadow_vert,fragmentShader:Br.shadow_frag}};function jr(t,e){this.min=void 0!==t?t:new _e(1/0,1/0),this.max=void 0!==e?e:new _e(-1/0,-1/0)}function Gr(t,e,r,n,i){var o,a,s,l,c,u,h,p;function f(){var t,n,f,d,m,g=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),v=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,g,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,v,e.STATIC_DRAW),h=e.createTexture(),p=e.createTexture(),r.bindTexture(e.TEXTURE_2D,h),e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),r.bindTexture(e.TEXTURE_2D,p),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),s={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},t=s,n=e.createProgram(),f=e.createShader(e.FRAGMENT_SHADER),d=e.createShader(e.VERTEX_SHADER),m="precision "+i.precision+" float;\n",e.shaderSource(f,m+t.fragmentShader),e.shaderSource(d,m+t.vertexShader),e.compileShader(f),e.compileShader(d),e.attachShader(n,f),e.attachShader(n,d),e.linkProgram(n),l=n,c={vertex:e.getAttribLocation(l,"position"),uv:e.getAttribLocation(l,"uv")},u={renderType:e.getUniformLocation(l,"renderType"),map:e.getUniformLocation(l,"map"),occlusionMap:e.getUniformLocation(l,"occlusionMap"),opacity:e.getUniformLocation(l,"opacity"),color:e.getUniformLocation(l,"color"),scale:e.getUniformLocation(l,"scale"),rotation:e.getUniformLocation(l,"rotation"),screenPosition:e.getUniformLocation(l,"screenPosition")}}this.render=function(t,i,s,d){if(0!==t.length){var m=new He,g=d.w/d.z,v=.5*d.z,y=.5*d.w,_=16/d.w,x=new _e(_*g,_),b=new He(1,1,0),w=new _e(1,1),S=new jr;S.min.set(d.x,d.y),S.max.set(d.x+(d.z-16),d.y+(d.w-16)),void 0===l&&f(),r.useProgram(l),r.initAttributes(),r.enableAttribute(c.vertex),r.enableAttribute(c.uv),r.disableUnusedAttributes(),e.uniform1i(u.occlusionMap,0),e.uniform1i(u.map,1),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(c.vertex,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(c.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),r.disable(e.CULL_FACE),r.buffers.depth.setMask(!1);for(var M=0,A=t.length;M.001&&P.scale>.001&&(b.x=P.x,b.y=P.y,b.z=P.z,_=P.size*P.scale/d.w,x.x=_*g,x.y=_,e.uniform3f(u.screenPosition,b.x,b.y,b.z),e.uniform2f(u.scale,x.x,x.y),e.uniform1f(u.rotation,P.rotation),e.uniform1f(u.opacity,P.opacity),e.uniform3f(u.color,P.color.r,P.color.g,P.color.b),r.setBlending(P.blending,P.blendEquation,P.blendSrc,P.blendDst),n.setTexture2D(P.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}r.enable(e.CULL_FACE),r.enable(e.DEPTH_TEST),r.buffers.depth.setMask(!0),r.reset()}}}function Wr(t,e,r,n,i,o,a,s,l){Be.call(this,t,e,r,n,i,o,a,s,l),this.needsUpdate=!0}function Hr(t,e,r,n,i){var o,a,s,l,c,u,h=new He,p=new We,f=new He;function d(){var t,r,n,h=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),p=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,h,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,p,e.STATIC_DRAW),t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),n=e.createShader(e.FRAGMENT_SHADER),e.shaderSource(r,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(n,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(r),e.compileShader(n),e.attachShader(t,r),e.attachShader(t,n),e.linkProgram(t),s=t,l={position:e.getAttribLocation(s,"position"),uv:e.getAttribLocation(s,"uv")},c={uvOffset:e.getUniformLocation(s,"uvOffset"),uvScale:e.getUniformLocation(s,"uvScale"),rotation:e.getUniformLocation(s,"rotation"),scale:e.getUniformLocation(s,"scale"),color:e.getUniformLocation(s,"color"),map:e.getUniformLocation(s,"map"),opacity:e.getUniformLocation(s,"opacity"),modelViewMatrix:e.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(s,"projectionMatrix"),fogType:e.getUniformLocation(s,"fogType"),fogDensity:e.getUniformLocation(s,"fogDensity"),fogNear:e.getUniformLocation(s,"fogNear"),fogFar:e.getUniformLocation(s,"fogFar"),fogColor:e.getUniformLocation(s,"fogColor"),alphaTest:e.getUniformLocation(s,"alphaTest")};var f=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");f.width=8,f.height=8;var d=f.getContext("2d");d.fillStyle="white",d.fillRect(0,0,8,8),u=new Wr(f)}function m(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(i,g,v){if(0!==i.length){void 0===s&&d(),r.useProgram(s),r.initAttributes(),r.enableAttribute(l.position),r.enableAttribute(l.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(l.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.uniformMatrix4fv(c.projectionMatrix,!1,v.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(c.map,0);var y=0,_=0,x=g.fog;x?(e.uniform3f(c.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(c.fogNear,x.near),e.uniform1f(c.fogFar,x.far),e.uniform1i(c.fogType,1),y=1,_=1):x.isFogExp2&&(e.uniform1f(c.fogDensity,x.density),e.uniform1i(c.fogType,2),y=2,_=2)):(e.uniform1i(c.fogType,0),y=0,_=0);for(var b=0,w=i.length;bthis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new _e).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new _e).copy(t).clamp(this.min,this.max)},distanceToPoint:(Fr=new _e,function(t){return Fr.copy(t).clamp(this.min,this.max).sub(t).length()}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Wr.prototype=Object.create(Be.prototype),Wr.prototype.constructor=Wr;var Xr,Yr,qr,Zr,$r,Kr,Qr,Jr,tn,en,rn,nn,on,an,sn,ln,cn,un,hn,pn=0;function fn(){Object.defineProperty(this,"id",{value:pn++}),this.uuid=ye.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=E,this.side=y,this.flatShading=!1,this.vertexColors=w,this.opacity=1,this.transparent=!1,this.blendSrc=B,this.blendDst=V,this.blendEquation=R,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=$,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function dn(t){fn.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(t.attributes,this.setValues(t))}function mn(t){fn.call(this),this.type="MeshDepthMaterial",this.depthPacking=ge,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function gn(t){fn.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new He,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function vn(t,e){this.min=void 0!==t?t:new He(1/0,1/0,1/0),this.max=void 0!==e?e:new He(-1/0,-1/0,-1/0)}function yn(t,e){this.center=void 0!==t?t:new He,this.radius=void 0!==e?e:0}function _n(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length}function xn(t,e){this.normal=void 0!==t?t:new He(1,0,0),this.constant=void 0!==e?e:0}function bn(t,e,r,n,i,o){this.planes=[void 0!==t?t:new xn,void 0!==e?e:new xn,void 0!==r?r:new xn,void 0!==n?n:new xn,void 0!==i?i:new xn,void 0!==o?o:new xn]}function wn(t,e,r){for(var n=new bn,i=new Xe,o=new _e,a=new _e(r,r),s=new He,l=new He,c=1,u=2,h=1+(c|u),p=new Array(h),f=new Array(h),d={},m=[new He(1,0,0),new He(-1,0,0),new He(0,0,1),new He(0,0,-1),new He(0,1,0),new He(0,-1,0)],v=[new He(0,1,0),new He(0,1,0),new He(0,1,0),new He(0,1,0),new He(0,0,1),new He(0,0,-1)],_=[new Ve,new Ve,new Ve,new Ve,new Ve,new Ve],w=0;w!==h;++w){var S=0!=(w&c),M=0!=(w&u),A=new mn({depthPacking:ve,morphTargets:S,skinning:M});p[w]=A;var E=new gn({morphTargets:S,skinning:M});f[w]=E}var C=this;function T(e,r,n,i,o,a){var s=e.geometry,l=null,h=p,m=e.customDepthMaterial;if(n&&(h=f,m=e.customDistanceMaterial),m)l=m;else{var g=!1;r.morphTargets&&(s&&s.isBufferGeometry?g=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(g=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&r.skinning;var v=e.isSkinnedMesh&&r.skinning,_=0;g&&(_|=c),v&&(_|=u),l=h[_]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var w=l.uuid,S=r.uuid,M=d[w];void 0===M&&(M={},d[w]=M);var A=M[S];void 0===A&&(A=l.clone(),M[S]=A),l=A}l.visible=r.visible,l.wireframe=r.wireframe;var E=r.side;return C.renderSingleSided&&E==b&&(E=y),C.renderReverseSided&&(E===y?E=x:E===x&&(E=y)),l.side=E,l.clipShadows=r.clipShadows,l.clippingPlanes=r.clippingPlanes,l.clipIntersection=r.clipIntersection,l.wireframeLinewidth=r.wireframeLinewidth,l.linewidth=r.linewidth,n&&l.isMeshDistanceMaterial&&(l.referencePosition.copy(i),l.nearDistance=o,l.farDistance=a),l}function P(r,i,o,a){if(!1!==r.visible){if(r.layers.test(i.layers)&&(r.isMesh||r.isLine||r.isPoints)&&r.castShadow&&(!r.frustumCulled||n.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,r.matrixWorld);var s=e.update(r),c=r.material;if(Array.isArray(c))for(var u=s.groups,h=0,p=u.length;h0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(r.morphTargets=!0),!0===this.skinning&&(r.skinning=!0),!1===this.visible&&(r.visible=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),e){var i=n(t.textures),o=n(t.images);i.length>0&&(r.textures=i),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),dn.prototype=Object.create(fn.prototype),dn.prototype.constructor=dn,dn.prototype.isShaderMaterial=!0,dn.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ur.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},dn.prototype.toJSON=function(t){var e=fn.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},mn.prototype=Object.create(fn.prototype),mn.prototype.constructor=mn,mn.prototype.isMeshDepthMaterial=!0,mn.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},gn.prototype=Object.create(fn.prototype),gn.prototype.constructor=gn,gn.prototype.isMeshDistanceMaterial=!0,gn.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},Object.assign(vn.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=t.length;si&&(i=c),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=t.count;si&&(i=c),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new He).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:(Zr=new He,function(t){return this.clampPoint(t.center,Zr),Zr.distanceToSquared(t.center)<=t.radius*t.radius}),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new He).copy(t).clamp(this.min,this.max)},distanceToPoint:(qr=new He,function(t){return qr.copy(t).clamp(this.min,this.max).sub(t).length()}),getBoundingSphere:(Yr=new He,function(t){var e=t||new yn;return this.getCenter(e.center),e.radius=.5*this.getSize(Yr).length(),e}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:(Xr=[new He,new He,new He,new He,new He,new He,new He,new He],function(t){return this.isEmpty()?this:(Xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Xr),this)}),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(yn.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(Qr=new vn,function(t,e){var r=this.center;void 0!==e?r.copy(e):Qr.setFromPoints(t).getCenter(r);for(var n=0,i=0,o=t.length;ithis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new vn;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(_n.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,l){var c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=i,c[5]=s,c[6]=r,c[7]=o,c[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:(Jr=new He,function(t){for(var e=0,r=t.count;e1?void 0:r.copy(n).multiplyScalar(o).add(t.start)}),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new He).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:(tn=new He,en=new _n,function(t,e){var r=e||en.getNormalMatrix(t),n=this.coplanarPoint(tn).applyMatrix4(t),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this}),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(bn.prototype,{set:function(t,e,r,n,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],l=r[5],c=r[6],u=r[7],h=r[8],p=r[9],f=r[10],d=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-n,u-s,d-h,y-m).normalize(),e[1].setComponents(a+n,u+s,d+h,y+m).normalize(),e[2].setComponents(a+i,u+l,d+p,y+g).normalize(),e[3].setComponents(a-i,u-l,d-p,y-g).normalize(),e[4].setComponents(a-o,u-c,d-f,y-v).normalize(),e[5].setComponents(a+o,u+c,d+f,y+v).normalize(),this},intersectsObject:(cn=new yn,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),cn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(cn)}),intersectsSprite:(ln=new yn,function(t){return ln.center.set(0,0,0),ln.radius=.7071067811865476,ln.applyMatrix4(t.matrixWorld),this.intersectsSphere(ln)}),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(r)0?t.min.x:t.max.x,sn.x=n.normal.x>0?t.max.x:t.min.x,an.y=n.normal.y>0?t.min.y:t.max.y,sn.y=n.normal.y>0?t.max.y:t.min.y,an.z=n.normal.z>0?t.min.z:t.max.z,sn.z=n.normal.z>0?t.max.z:t.min.z;var i=n.distanceToPoint(an),o=n.distanceToPoint(sn);if(i<0&&o<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}}),Mn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Mn.DefaultOrder="XYZ",Object.defineProperties(Mn.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(Mn.prototype,{isEuler:!0,set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=ye.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],l=i[1],c=i[5],u=i[9],h=i[2],p=i[6],f=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,c),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,o))):"ZYX"===e?(this._y=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,c))):"YZX"===e?(this._z=Math.asin(n(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===e&&(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,c),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:(hn=new Xe,function(t,e,r){return hn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(hn,e,r)}),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:(un=new We,function(t){return un.setFromEuler(this),this.setFromQuaternion(un,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new He(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(An.prototype,{set:function(t){this.mask=1<1){for(var e=0;e1){for(var e=0;e0){n.children=[];for(a=0;a0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),h.length>0&&(r.images=h)}return r.object=n,r;function p(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;re&&(e=t[r]);return e}function Zi(){Object.defineProperty(this,"id",{value:Di()}),this.uuid=ye.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function $i(t,e,r,n,i,o){Fi.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Ki(t,e,r,n,i,o)),this.mergeVertices()}function Ki(t,e,r,n,i,o){Zi.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o};var a=this;n=Math.floor(n)||1,i=Math.floor(i)||1;var s=[],l=[],c=[],u=[],h=0,p=0;function f(t,e,r,n,i,o,f,d,m,g,v){var y,_,x=o/m,b=f/g,w=o/2,S=f/2,M=d/2,A=m+1,E=g+1,C=0,T=0,P=new He;for(_=0;_0?1:-1,c.push(P.x,P.y,P.z),u.push(y/m),u.push(1-_/g),C+=1}}for(_=0;_1&&r.sort(oo),n.length>1&&n.sort(ao)}}},t[n]=i),i},dispose:function(){t={}}}}function lo(t,e){return Math.abs(e[1])-Math.abs(t[1])}function co(){var t=new function(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var r;switch(e.type){case"DirectionalLight":r={direction:new He,color:new Dr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new _e};break;case"SpotLight":r={position:new He,direction:new He,color:new Dr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new _e};break;case"PointLight":r={position:new He,color:new Dr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new _e,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":r={direction:new He,skyColor:new Dr,groundColor:new Dr};break;case"RectAreaLight":r={color:new Dr,position:new He,halfWidth:new He,halfHeight:new He}}return t[e.id]=r,r}}},e={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},r=new He,n=new Xe,i=new Xe;return{setup:function(o,a,s){for(var l=0,c=0,u=0,h=0,p=0,f=0,d=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new vn),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new yn),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(t&&t.isGeometry){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,l=t.faces,c=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new _n).getNormalMatrix(e));for(var f=0,d=a.length;f=0;r--){var d=p[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a0,g=f.vertexNormals.length>0,v=1!==f.color.r||1!==f.color.g||1!==f.color.b,y=f.vertexColors.length>0,_=0;if(_=S(_=S(_=S(_=S(_=S(_=S(_=S(_=S(_,0,0),1,!0),2,!1),3,d),4,m),5,g),6,v),7,y),a.push(_),a.push(f.a,f.b,f.c),a.push(f.materialIndex),d){var x=this.faceVertexUvs[0][i];a.push(E(x[0]),E(x[1]),E(x[2]))}if(m&&a.push(M(f.normal)),g){var b=f.vertexNormals;a.push(M(b[0]),M(b[1]),M(b[2]))}if(v&&a.push(A(f.color)),y){var w=f.vertexColors;a.push(A(w[0]),A(w[1]),A(w[2]))}}function S(t,e,r){return r?t|1<0&&(t.data.colors=c),h.length>0&&(t.data.uvs=[h]),t.data.faces=a,t},clone:function(){return(new Fi).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e0,a=i[1]&&i[1].length>0,s=t.morphTargets,l=s.length;if(l>0){e=[];for(var c=0;c0){u=[];for(c=0;c65535?Wi:ji)(t,1):this.index=t},addAttribute:function(t,e){if(e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute){if("index"!==t)return this.attributes[t]=e,this;this.setIndex(e)}else this.addAttribute(t,new zi(arguments[1],arguments[2]))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;void 0!==r&&((new _n).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:(ci=new Xe,function(t){return ci.makeRotationX(t),this.applyMatrix(ci),this}),rotateY:(li=new Xe,function(t){return li.makeRotationY(t),this.applyMatrix(li),this}),rotateZ:(si=new Xe,function(t){return si.makeRotationZ(t),this.applyMatrix(si),this}),translate:(ai=new Xe,function(t,e,r){return ai.makeTranslation(t,e,r),this.applyMatrix(ai),this}),scale:(oi=new Xe,function(t,e,r){return oi.makeScale(t,e,r),this.applyMatrix(oi),this}),lookAt:(ii=new Wn,function(t){ii.lookAt(t),ii.updateMatrix(),this.applyMatrix(ii.matrix)}),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new Hi(3*e.vertices.length,3),n=new Hi(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new Hi(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e,r=t.geometry;if(t.isMesh){var n=r.__directGeometry;if(!0===r.elementsNeedUpdate&&(n=void 0,r.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(r);n.verticesNeedUpdate=r.verticesNeedUpdate,n.normalsNeedUpdate=r.normalsNeedUpdate,n.colorsNeedUpdate=r.colorsNeedUpdate,n.uvsNeedUpdate=r.uvsNeedUpdate,n.groupsNeedUpdate=r.groupsNeedUpdate,r.verticesNeedUpdate=!1,r.normalsNeedUpdate=!1,r.colorsNeedUpdate=!1,r.uvsNeedUpdate=!1,r.groupsNeedUpdate=!1,r=n}return!0===r.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(r.vertices),e.needsUpdate=!0),r.verticesNeedUpdate=!1),!0===r.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(r.normals),e.needsUpdate=!0),r.normalsNeedUpdate=!1),!0===r.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(r.colors),e.needsUpdate=!0),r.colorsNeedUpdate=!1),r.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(r.uvs),e.needsUpdate=!0),r.uvsNeedUpdate=!1),r.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(r.lineDistances),e.needsUpdate=!0),r.lineDistancesNeedUpdate=!1),r.groupsNeedUpdate&&(r.computeGroups(t.geometry),this.groups=r.groups,r.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Yi).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new zi(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new zi(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new zi(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new zi(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new zi(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(qi(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new zi(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var l=[],c=t.morphTargets[s],u=0,h=c.length;u0){var d=new Hi(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new Hi(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new vn);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:(ri=new vn,ni=new He,function(){null===this.boundingSphere&&(this.boundingSphere=new yn);var t=this.attributes.position;if(t){var e=this.boundingSphere.center;ri.setFromBufferAttribute(t),ri.getCenter(e);for(var r=0,n=0,i=t.count;n0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(t.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),t},clone:function(){return(new Zi).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var l=[],c=s[e];for(r=0,n=c.length;r0)if(o=c*u-h,s=l*f,(i=c*h-u)>=0)if(o>=-s)if(o<=s){var d=1/f;a=(i*=d)*(i+c*(o*=d)+2*u)+o*(c*i+o+2*h)+p}else o=l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;else o=-l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;else o<=-s?a=-(i=Math.max(0,-(-c*l+u)))*i+(o=i>0?-l:Math.min(Math.max(-l,-h),l))*(o+2*h)+p:o<=s?(i=0,a=(o=Math.min(Math.max(-l,-h),l))*(o+2*h)+p):a=-(i=Math.max(0,-(c*l+u)))*i+(o=i>0?l:Math.min(Math.max(-l,-h),l))*(o+2*h)+p;else o=c>0?-l:l,a=-(i=Math.max(0,-(c*o+u)))*i+o*(o+2*h)+p;return r&&r.copy(this.direction).multiplyScalar(i).add(this.origin),n&&n.copy(vi).multiplyScalar(o).add(gi),a}),intersectSphere:(mi=new He,function(t,e){mi.subVectors(t.center,this.origin);var r=mi.dot(this.direction),n=mi.dot(mi)-r*r,i=t.radius*t.radius;if(n>i)return null;var o=Math.sqrt(i-n),a=r-o,s=r+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(r=(t.min.x-h.x)*l,n=(t.max.x-h.x)*l):(r=(t.max.x-h.x)*l,n=(t.min.x-h.x)*l),c>=0?(i=(t.min.y-h.y)*c,o=(t.max.y-h.y)*c):(i=(t.max.y-h.y)*c,o=(t.min.y-h.y)*c),r>o||i>n?null:((i>r||r!=r)&&(r=i),(o=0?(a=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),r>s||a>n?null:((a>r||r!=r)&&(r=a),(s=0?r:n,e)))},intersectsBox:(di=new He,function(t){return null!==this.intersectBox(t,di)}),intersectTriangle:(ui=new He,hi=new He,pi=new He,fi=new He,function(t,e,r,n,i){hi.subVectors(e,t),pi.subVectors(r,t),fi.crossVectors(hi,pi);var o,a=this.direction.dot(fi);if(a>0){if(n)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}ui.subVectors(this.origin,t);var s=o*this.direction.dot(pi.crossVectors(ui,pi));if(s<0)return null;var l=o*this.direction.dot(hi.cross(ui));if(l<0)return null;if(s+l>a)return null;var c=-o*ui.dot(fi);return c<0?null:this.at(c/a,i)}),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(ro.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new He).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new He).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new He;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(bi=new He,wi=new He,function(t,e){bi.subVectors(t,this.start),wi.subVectors(this.end,this.start);var r=wi.dot(wi),n=wi.dot(bi)/r;return e&&(n=ye.clamp(n,0,1)),n}),closestPointToPoint:function(t,e,r){var n=this.closestPointToPointParameter(t,e),i=r||new He;return this.delta(i).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(no,{normal:(Ci=new He,function(t,e,r,n){var i=n||new He;i.subVectors(r,e),Ci.subVectors(t,e),i.cross(Ci);var o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}),barycoordFromPoint:(Mi=new He,Ai=new He,Ei=new He,function(t,e,r,n,i){Mi.subVectors(n,e),Ai.subVectors(r,e),Ei.subVectors(t,e);var o=Mi.dot(Mi),a=Mi.dot(Ai),s=Mi.dot(Ei),l=Ai.dot(Ai),c=Ai.dot(Ei),u=o*l-a*a,h=i||new He;if(0===u)return h.set(-2,-1,-1);var p=1/u,f=(l*s-a*c)*p,d=(o*c-a*s)*p;return h.set(1-f-d,d,f)}),containsPoint:(Si=new He,function(t,e,r,n){var i=no.barycoordFromPoint(t,e,r,n,Si);return i.x>=0&&i.y>=0&&i.x+i.y<=1})}),Object.assign(no.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:(Ni=new He,Ii=new He,function(){return Ni.subVectors(this.c,this.b),Ii.subVectors(this.a,this.b),.5*Ni.cross(Ii).length()}),midpoint:function(t){return(t||new He).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return no.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new xn).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return no.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return no.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:(Ti=new xn,Pi=[new ro,new ro,new ro],Li=new He,Ri=new He,function(t,e){var r=e||new He,n=1/0;if(Ti.setFromCoplanarPoints(this.a,this.b,this.c),Ti.projectPoint(t,Li),!0===this.containsPoint(Li))r.copy(Li);else{Pi[0].set(this.a,this.b),Pi[1].set(this.b,this.c),Pi[2].set(this.c,this.a);for(var i=0;i0){var a=i[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;tr.far?null:{distance:l,point:d.clone(),object:t}}function v(t,e,r,a,s,l,p,d){n.fromBufferAttribute(a,l),i.fromBufferAttribute(a,p),o.fromBufferAttribute(a,d);var v=g(t,t.material,e,r,n,i,o,f);return v&&(s&&(c.fromBufferAttribute(s,l),u.fromBufferAttribute(s,p),h.fromBufferAttribute(s,d),v.uv=m(f,n,i,o,c,u,h)),v.face=new qn(l,p,d,no.normal(n,i,o)),v.faceIndex=l),v}return function(p,d){var y,_=this.geometry,x=this.material,b=this.matrixWorld;if(void 0!==x&&(null===_.boundingSphere&&_.computeBoundingSphere(),r.copy(_.boundingSphere),r.applyMatrix4(b),!1!==p.ray.intersectsSphere(r)&&(t.getInverse(b),e.copy(p.ray).applyMatrix4(t),null===_.boundingBox||!1!==e.intersectsBox(_.boundingBox))))if(_.isBufferGeometry){var w,S,M,A,E,C=_.index,T=_.attributes.position,P=_.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=z);for(var k=0,U=F.length;k/gm,function(t,e){var r=Br[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return Ro(r)})}function No(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,A=(d=n.extensions,m=o,y=e,[(d=d||{}).derivatives||m.envMapCubeUV||m.bumpMap||m.normalMap||m.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(d.fragDepth||m.logarithmicDepthBuffer)&&y.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",d.drawBuffers&&y.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(d.shaderTextureLOD||m.envMap)&&y.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Po).join("\n")),E=function(t){var e=[];for(var r in t){var n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(s),C=a.createProgram();n.isRawShaderMaterial?(_=[E,"\n"].filter(Po).join("\n"),x=[A,E,"\n"].filter(Po).join("\n")):(_=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,E,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+M,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Po).join("\n"),x=[A,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,E,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+M,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+p:"",o.envMap?"#define "+f:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==it?"#define TONE_MAPPING":"",o.toneMapping!==it?Br.tonemapping_pars_fragment:"",o.toneMapping!==it?function(t,e){var r;switch(e){case ot:r="Linear";break;case at:r="Reinhard";break;case st:r="Uncharted2";break;case lt:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Br.encodings_pars_fragment:"",o.mapEncoding?To("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?To("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?To("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(b="linearToOutputTexel",w=o.outputEncoding,S=Co(w),"vec4 "+b+"( vec4 value ) { return LinearTo"+S[0]+S[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Po).join("\n")),l=Lo(l=Ro(l),o),c=Lo(c=Ro(c),o),n.isShaderMaterial||(l=No(l),c=No(c));var T=_+l,P=x+c,L=uo(a,a.VERTEX_SHADER,T),R=uo(a,a.FRAGMENT_SHADER,P);a.attachShader(C,L),a.attachShader(C,R),void 0!==n.index0AttributeName?a.bindAttribLocation(C,0,n.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(C,0,"position"),a.linkProgram(C);var N,I,O=a.getProgramInfoLog(C),D=a.getShaderInfoLog(L),F=a.getShaderInfoLog(R),z=!0,k=!0;return!1===a.getProgramParameter(C,a.LINK_STATUS)?z=!1:""!==O||""!==D&&""!==F||(k=!1),k&&(this.diagnostics={runnable:z,material:n,programLog:O,vertexShader:{log:D,prefix:_},fragmentShader:{log:F,prefix:x}}),a.deleteShader(L),a.deleteShader(R),this.getUniforms=function(){return void 0===N&&(N=new Ir(a,C,t)),N},this.getAttributes=function(){return void 0===I&&(I=function(t,e,r){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o0,maxBones:p,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:n.directional.length,numPointLights:n.point.length,numSpotLights:n.spot.length,numRectAreaLights:n.rectArea.length,numHemiLights:n.hemi.length,numClippingPlanes:l,numClipIntersection:c,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&o.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===b,flipSided:e.side===x,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,r){var n=[];if(r.shaderID?n.push(r.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)n.push(i),n.push(e.defines[i]);for(var a=0;ae||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return ye.isPowerOfTwo(t.width)&&ye.isPowerOfTwo(t.height)}function u(t,e){return t.generateMipmaps&&e&&t.minFilter!==_t&&t.minFilter!==wt}function h(e){return e===_t||e===xt||e===bt?t.NEAREST:t.LINEAR}function p(e){var r=e.target;r.removeEventListener("dispose",p),function(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.remove(e)}(r),a.textures--}function f(e){var r=e.target;r.removeEventListener("dispose",f),function(e){var r=n.get(e),i=n.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.remove(e.texture),n.remove(e)}(r),a.textures--}function d(e,h){var f=n.get(e);if(e.version>0&&f.__version!==e.version){var d=e.image;if(void 0===d);else if(!1!==d.complete)return void function(e,n,h){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),a.textures++);r.activeTexture(t.TEXTURE0+h),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var f=l(n.image,i.maxTextureSize);d=n,(d.wrapS!==vt||d.wrapT!==vt||d.minFilter!==_t&&d.minFilter!==wt)&&!1===c(f)&&(f=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=ye.nearestPowerOfTwo(t.width),e.height=ye.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}(f));var d;var g=c(f),v=o.convert(n.format),y=o.convert(n.type);m(t.TEXTURE_2D,n,g);var _,x=n.mipmaps;if(n.isDepthTexture){var b=t.DEPTH_COMPONENT;if(n.type===Rt){if(!s)throw new Error("Float Depth Texture only supported in WebGL2.0");b=t.DEPTH_COMPONENT32F}else s&&(b=t.DEPTH_COMPONENT16);n.format===Gt&&b===t.DEPTH_COMPONENT&&n.type!==Tt&&n.type!==Lt&&(n.type=Tt,y=o.convert(n.type)),n.format===Wt&&(b=t.DEPTH_STENCIL,n.type!==Ft&&(n.type=Ft,y=o.convert(n.type))),r.texImage2D(t.TEXTURE_2D,0,b,f.width,f.height,0,v,y,null)}else if(n.isDataTexture)if(x.length>0&&g){for(var w=0,S=x.length;w-1&&r.compressedTexImage2D(t.TEXTURE_2D,w,v,_.width,_.height,0,_.data):r.texImage2D(t.TEXTURE_2D,w,v,_.width,_.height,0,v,y,_.data);else if(x.length>0&&g){for(var w=0,S=x.length;w1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function g(e,i,a,s){var l=o.convert(i.texture.format),c=o.convert(i.texture.type);r.texImage2D(s,0,l,i.width,i.height,0,l,c,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,n.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function v(e,r){t.bindRenderbuffer(t.RENDERBUFFER,e),r.depthBuffer&&!r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):r.depthBuffer&&r.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,r.width,r.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,r.width,r.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function y(e){var r=n.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),d(r.depthTexture,0);var i=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===Gt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==Wt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(r.__webglFramebuffer,e)}else if(i){r.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[o]),r.__webglDepthbuffer[o]=t.createRenderbuffer(),v(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),v(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=d,this.setTextureCube=function(e,s){var h=n.get(e);if(6===e.image.length)if(e.version>0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",p),h.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+s),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var f=e&&e.isCompressedTexture,d=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=f||d?d?e.image[v].image:e.image[v]:l(e.image[v],i.maxCubemapSize);var y=c(g[0]),_=o.convert(e.format),x=o.convert(e.type);for(m(t.TEXTURE_CUBE_MAP,e,y),v=0;v<6;v++)if(f)for(var b,w=g[v].mipmaps,S=0,M=w.length;S-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,b.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,_,x,b.data);else d?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,g[v].width,g[v].height,0,_,x,g[v].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,_,x,g[v]);u(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+s),r.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",f),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,l=c(e);if(s){i.__webglFramebuffer=[];for(var h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(s){for(r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,l),h=0;h<6;h++)g(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);u(e.texture,l)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),m(t.TEXTURE_2D,e.texture,l),g(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),u(e.texture,l)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&y(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(u(i,c(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function Fo(t){Yn.call(this),this.cameras=t||[]}function zo(t,e){return{convert:function(r){var n;if(r===gt)return t.REPEAT;if(r===vt)return t.CLAMP_TO_EDGE;if(r===yt)return t.MIRRORED_REPEAT;if(r===_t)return t.NEAREST;if(r===xt)return t.NEAREST_MIPMAP_NEAREST;if(r===bt)return t.NEAREST_MIPMAP_LINEAR;if(r===wt)return t.LINEAR;if(r===St)return t.LINEAR_MIPMAP_NEAREST;if(r===Mt)return t.LINEAR_MIPMAP_LINEAR;if(r===At)return t.UNSIGNED_BYTE;if(r===It)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Ot)return t.UNSIGNED_SHORT_5_5_5_1;if(r===Dt)return t.UNSIGNED_SHORT_5_6_5;if(r===Et)return t.BYTE;if(r===Ct)return t.SHORT;if(r===Tt)return t.UNSIGNED_SHORT;if(r===Pt)return t.INT;if(r===Lt)return t.UNSIGNED_INT;if(r===Rt)return t.FLOAT;if(r===Nt&&null!==(n=e.get("OES_texture_half_float")))return n.HALF_FLOAT_OES;if(r===zt)return t.ALPHA;if(r===kt)return t.RGB;if(r===Ut)return t.RGBA;if(r===Bt)return t.LUMINANCE;if(r===Vt)return t.LUMINANCE_ALPHA;if(r===Gt)return t.DEPTH_COMPONENT;if(r===Wt)return t.DEPTH_STENCIL;if(r===R)return t.FUNC_ADD;if(r===N)return t.FUNC_SUBTRACT;if(r===I)return t.FUNC_REVERSE_SUBTRACT;if(r===F)return t.ZERO;if(r===z)return t.ONE;if(r===k)return t.SRC_COLOR;if(r===U)return t.ONE_MINUS_SRC_COLOR;if(r===B)return t.SRC_ALPHA;if(r===V)return t.ONE_MINUS_SRC_ALPHA;if(r===j)return t.DST_ALPHA;if(r===G)return t.ONE_MINUS_DST_ALPHA;if(r===W)return t.DST_COLOR;if(r===H)return t.ONE_MINUS_DST_COLOR;if(r===X)return t.SRC_ALPHA_SATURATE;if((r===Ht||r===Xt||r===Yt||r===qt)&&null!==(n=e.get("WEBGL_compressed_texture_s3tc"))){if(r===Ht)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Xt)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Yt)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===qt)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((r===Zt||r===$t||r===Kt||r===Qt)&&null!==(n=e.get("WEBGL_compressed_texture_pvrtc"))){if(r===Zt)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===$t)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Kt)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Qt)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===Jt&&null!==(n=e.get("WEBGL_compressed_texture_etc1")))return n.COMPRESSED_RGB_ETC1_WEBGL;if((r===O||r===D)&&null!==(n=e.get("EXT_blend_minmax"))){if(r===O)return n.MIN_EXT;if(r===D)return n.MAX_EXT}return r===Ft&&null!==(n=e.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:0}}}function ko(t){var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),r=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=[],u=[],h=null,g=[],v=[];this.domElement=e,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=ot,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var y,_,S,M,R,N,I,O,D,F,z,k,U,B,V,j,G,W,H,X=this,et=!1,rt=null,nt=null,it=-1,at="",st=null,lt=null,ct=new Ve,ut=new Ve,ht=null,pt=0,ft=e.width,dt=e.height,mt=1,gt=new Ve(0,0,ft,dt),vt=new Ve(0,0,ft,dt),yt=!1,_t=new bn,xt=new function(){var t=this,e=null,r=0,n=!1,i=!1,o=new xn,a=new _n,s={value:null,needsUpdate:!1};function l(){s.value!==e&&(s.value=e,s.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function c(e,r,n,i){var l=null!==e?e.length:0,c=null;if(0!==l){if(c=s.value,!0!==i||null===c){var u=n+4*l,h=r.matrixWorldInverse;a.getNormalMatrix(h),(null===c||c.length0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==r.precision?r.precision:"highp",a=i(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),l=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),c=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),d=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=c>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==n)return n;var r=e.get("EXT_texture_filter_anisotropic");return n=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:l,maxVertexTextures:c,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(y,_,t),(M=new function(t,e,r){var n=new function(){var e=!1,r=new Ve,n=null,i=new Ve(0,0,0,0);return{setMask:function(r){n===r||e||(t.colorMask(r,r,r,r),n=r)},setLocked:function(t){e=t},setClear:function(e,n,o,a,s){!0===s&&(e*=a,n*=a,o*=a),r.set(e,n,o,a),!1===i.equals(r)&&(t.clearColor(e,n,o,a),i.copy(r))},reset:function(){e=!1,n=null,i.set(-1,0,0,0)}}},i=new function(){var e=!1,r=null,n=null,i=null;return{setTest:function(e){e?X(t.DEPTH_TEST):et(t.DEPTH_TEST)},setMask:function(n){r===n||e||(t.depthMask(n),r=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case Y:t.depthFunc(t.NEVER);break;case q:t.depthFunc(t.ALWAYS);break;case Z:t.depthFunc(t.LESS);break;case $:t.depthFunc(t.LEQUAL);break;case K:t.depthFunc(t.EQUAL);break;case Q:t.depthFunc(t.GEQUAL);break;case J:t.depthFunc(t.GREATER);break;case tt:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);n=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,r=null,n=null,i=null}}},o=new function(){var e=!1,r=null,n=null,i=null,o=null,a=null,s=null,l=null,c=null;return{setTest:function(e){e?X(t.STENCIL_TEST):et(t.STENCIL_TEST)},setMask:function(n){r===n||e||(t.stencilMask(n),r=n)},setFunc:function(e,r,a){n===e&&i===r&&o===a||(t.stencilFunc(e,r,a),n=e,i=r,o=a)},setOp:function(e,r,n){a===e&&s===r&&l===n||(t.stencilOp(e,r,n),a=e,s=r,l=n)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,r=null,n=null,i=null,o=null,a=null,s=null,l=null,c=null}}},a=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),l=new Uint8Array(a),c=new Uint8Array(a),u={},h=null,m=null,g=null,v=null,y=null,_=null,w=null,S=null,M=null,R=!1,N=null,I=null,O=null,D=null,F=null,z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),k=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),U=parseFloat(k)>=1,B=null,V={},j=new Ve,G=new Ve;function W(e,r,n){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a65535?Wi:ji)(a,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),i[r.id]=n,n}}}(y,I,Et),D=new function(t,e){var r={};return{update:function(n){var i=e.frame,o=n.geometry,a=t.get(n,o);return r[a.id]!==i&&(o.isGeometry&&a.updateFromObject(n),t.update(a),r[a.id]=i),a},clear:function(){r={}}}}(O,Ct),B=new function(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,l=s.length,c=e[i.id];if(void 0===c){c=[];for(var u=0;u=0){var c=i[s];if(void 0!==c){var u=c.normalized,h=c.itemSize,p=I.get(c);if(void 0===p)continue;var f=p.buffer,d=p.type,m=p.bytesPerElement;if(c.isInterleavedBufferAttribute){var g=c.data,v=g.stride,x=c.offset;g&&g.isInstancedInterleavedBuffer?(M.enableAttributeAndDivisor(l,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):M.enableAttribute(l),y.bindBuffer(y.ARRAY_BUFFER,f),y.vertexAttribPointer(l,h,d,u,v*m,(n*v+x)*m)}else c.isInstancedBufferAttribute?(M.enableAttributeAndDivisor(l,c.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=c.meshPerAttribute*c.count)):M.enableAttribute(l),y.bindBuffer(y.ARRAY_BUFFER,f),y.vertexAttribPointer(l,h,d,u,0,n*h*m)}else if(void 0!==a){var b=a[s];if(void 0!==b)switch(b.length){case 2:y.vertexAttrib2fv(l,b);break;case 3:y.vertexAttrib3fv(l,b);break;case 4:y.vertexAttrib4fv(l,b);break;default:y.vertexAttrib1fv(l,b)}}}}M.disableUnusedAttributes()}(n,a,r),null!==u&&y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,c.buffer));var d=0;null!==u?d=u.count:void 0!==h&&(d=h.count);var m=r.drawRange.start*p,g=r.drawRange.count*p,v=null!==o?o.start*p:0,x=null!==o?o.count*p:1/0,b=Math.max(m,v),w=Math.min(d,m+g,v+x)-1,S=Math.max(0,w-b+1);if(0!==S){if(i.isMesh)if(!0===n.wireframe)M.setLineWidth(n.wireframeLinewidth*Tt()),f.setMode(y.LINES);else switch(i.drawMode){case ae:f.setMode(y.TRIANGLES);break;case se:f.setMode(y.TRIANGLE_STRIP);break;case le:f.setMode(y.TRIANGLE_FAN)}else if(i.isLine){var A=n.linewidth;void 0===A&&(A=1),M.setLineWidth(A*Tt()),i.isLineSegments?f.setMode(y.LINES):i.isLineLoop?f.setMode(y.LINE_LOOP):f.setMode(y.LINE_STRIP)}else i.isPoints&&f.setMode(y.POINTS);r&&r.isInstancedBufferGeometry?r.maxInstancedCount>0&&f.renderInstances(r,b,S):f.render(b,S)}},this.compile=function(t,e){c.length=0,u.length=0,t.traverse(function(t){t.isLight&&(c.push(t),t.castShadow&&u.push(t))}),F.setup(c,u,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(h=0;h=0&&t.numSupportedMorphNormals++}var p=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=xt.numPlanes,n.numIntersection=xt.numIntersection,p.clippingPlanes=xt.uniform),n.fog=e,n.lightsHash=F.state.hash,t.lights&&(p.ambientLightColor.value=F.state.ambient,p.directionalLights.value=F.state.directional,p.spotLights.value=F.state.spot,p.rectAreaLights.value=F.state.rectArea,p.pointLights.value=F.state.point,p.hemisphereLights.value=F.state.hemi,p.directionalShadowMap.value=F.state.directionalShadowMap,p.directionalShadowMatrix.value=F.state.directionalShadowMatrix,p.spotShadowMap.value=F.state.spotShadowMap,p.spotShadowMatrix.value=F.state.spotShadowMatrix,p.pointShadowMap.value=F.state.pointShadowMap,p.pointShadowMatrix.value=F.state.pointShadowMatrix);var f=n.program.getUniforms(),d=Ir.seqWithValue(f.seq,p);n.uniformsList=d}function Zt(t,e,r,n){pt=0;var i=R.get(r);if(bt&&(wt||t!==st)){var o=t===st&&r.id===it;xt.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,o)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsHash!==F.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===xt.numPlanes&&i.numIntersection===xt.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(qt(r,e,n),r.needsUpdate=!1);var a,s,l,c,u,h,p,f,d,m,g,v,_,x,b,w,A=!1,E=!1,C=!1,T=i.program,P=T.getUniforms(),L=i.shader.uniforms;if(M.useProgram(T.program)&&(A=!0,E=!0,C=!0),r.id!==it&&(it=r.id,E=!0),A||t!==st){if(P.setValue(y,"projectionMatrix",t.projectionMatrix),S.logarithmicDepthBuffer&&P.setValue(y,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),st!==(lt||t)&&(st=lt||t,E=!0,C=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var N=P.map.cameraPosition;void 0!==N&&N.setValue(y,Mt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&P.setValue(y,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){P.setOptional(y,n,"bindMatrix"),P.setOptional(y,n,"bindMatrixInverse");var I=n.skeleton;if(I){var O=I.bones;if(S.floatVertexTextures){if(void 0===I.boneTexture){var D=Math.sqrt(4*O.length);D=ye.nextPowerOfTwo(Math.ceil(D)),D=Math.max(D,4);var z=new Float32Array(D*D*4);z.set(I.boneMatrices);var k=new Ye(z,D,D,Ut,Rt);I.boneMatrices=z,I.boneTexture=k,I.boneTextureSize=D}P.setValue(y,"boneTexture",I.boneTexture),P.setValue(y,"boneTextureSize",I.boneTextureSize)}else P.setOptional(y,I,"boneMatrices")}}return(E||r.forceUniformsUpdate)&&(P.setValue(y,"toneMappingExposure",X.toneMappingExposure),P.setValue(y,"toneMappingWhitePoint",X.toneMappingWhitePoint),r.lights&&(w=C,(b=L).ambientLightColor.needsUpdate=w,b.directionalLights.needsUpdate=w,b.pointLights.needsUpdate=w,b.spotLights.needsUpdate=w,b.rectAreaLights.needsUpdate=w,b.hemisphereLights.needsUpdate=w),e&&r.fog&&(x=e,(_=L).fogColor.value=x.color,x.isFog?(_.fogNear.value=x.near,_.fogFar.value=x.far):x.isFogExp2&&(_.fogDensity.value=x.density)),r.isMeshBasicMaterial?$t(L,r):r.isMeshLambertMaterial?($t(L,r),g=L,(v=r).emissiveMap&&(g.emissiveMap.value=v.emissiveMap)):r.isMeshPhongMaterial?($t(L,r),r.isMeshToonMaterial?(Kt(d=L,m=r),m.gradientMap&&(d.gradientMap.value=m.gradientMap)):Kt(L,r)):r.isMeshStandardMaterial?($t(L,r),r.isMeshPhysicalMaterial?(f=r,(p=L).clearCoat.value=f.clearCoat,p.clearCoatRoughness.value=f.clearCoatRoughness,Qt(p,f)):Qt(L,r)):r.isMeshDepthMaterial?($t(L,r),u=L,(h=r).displacementMap&&(u.displacementMap.value=h.displacementMap,u.displacementScale.value=h.displacementScale,u.displacementBias.value=h.displacementBias)):r.isMeshDistanceMaterial?($t(L,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(L,r)):r.isMeshNormalMaterial?($t(L,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(L,r)):r.isLineBasicMaterial?(c=r,(l=L).diffuse.value=c.color,l.opacity.value=c.opacity,r.isLineDashedMaterial&&(s=r,(a=L).dashSize.value=s.dashSize,a.totalSize.value=s.dashSize+s.gapSize,a.scale.value=s.scale)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*mt,t.scale.value=.5*dt,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}(L,r):r.isShadowMaterial&&(L.color.value=r.color,L.opacity.value=r.opacity),void 0!==L.ltcMat&&(L.ltcMat.value=kr.LTC_MAT_TEXTURE),void 0!==L.ltcMag&&(L.ltcMag.value=kr.LTC_MAG_TEXTURE),Ir.upload(y,i.uniformsList,L,X)),P.setValue(y,"modelViewMatrix",n.modelViewMatrix),P.setValue(y,"normalMatrix",n.normalMatrix),P.setValue(y,"modelMatrix",n.matrixWorld),T}function $t(t,e){var r;if(t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}}function Kt(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function Qt(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}this.animate=function(t){Wt=t,Gt||((It.getDevice()||window).requestAnimationFrame(Ht),Gt=!0)},this.render=function(t,e,r,n){if(e&&e.isCamera&&!et){at="",it=-1,st=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),It.enabled&&(e=It.getCamera(e)),St.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),_t.setFromMatrix(St),c.length=0,u.length=0,g.length=0,v.length=0,wt=this.localClippingEnabled,bt=xt.init(this.clippingPlanes,wt,e),(h=k.get(t,e)).init(),function t(e,r,n){if(!e.visible)return;var i=e.layers.test(r.layers);if(i)if(e.isLight)c.push(e),e.castShadow&&u.push(e);else if(e.isSprite)e.frustumCulled&&!_t.intersectsSprite(e)||g.push(e);else if(e.isLensFlare)v.push(e);else if(e.isImmediateRenderObject)n&&Mt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(St),h.push(e,null,e.material,Mt.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||_t.intersectsObject(e))){n&&Mt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(St);var o=D.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,l=0,p=s.length;l=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&y.readPixels(e,r,n,i,H.convert(c),H.convert(u),o)}finally{s&&y.bindFramebuffer(y.FRAMEBUFFER,nt)}}}}}function Uo(t,e){this.name="",this.color=new Dr(t),this.density=void 0!==e?e:25e-5}function Bo(t,e,r){this.name="",this.color=new Dr(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function Vo(){Wn.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function jo(t,e,r,n,i){Wn.call(this),this.lensFlares=[],this.positionScreen=new He,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function Go(t){fn.call(this),this.type="SpriteMaterial",this.color=new Dr(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Wo(t){Wn.call(this),this.type="Sprite",this.material=void 0!==t?t:new Go}function Ho(){Wn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Xo(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{this.boneInverses=[];for(var r=0,n=this.bones.length;r=t.HAVE_CURRENT_DATA&&(c.needsUpdate=!0)}()}function na(t,e,r,n,i,o,a,s,l,c,u,h){Be.call(this,null,o,a,s,l,c,n,i,u,h),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function ia(t,e,r,n,i,o,a,s,l,c){if((c=void 0!==c?c:Gt)!==Gt&&c!==Wt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&c===Gt&&(r=Tt),void 0===r&&c===Wt&&(r=Ft),Be.call(this,null,n,i,o,a,s,c,r,l),this.image={width:t,height:e},this.magFilter=void 0!==a?a:_t,this.minFilter=void 0!==s?s:_t,this.flipY=!1,this.generateMipmaps=!1}function oa(t){Zi.call(this),this.type="WireframeGeometry";var e,r,n,i,o,a,s,l,c,u,h=[],p=[0,0],f={},d=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,n=m.length;e=0?(h=t(g-1e-5,m,h),p.subVectors(u,h)):(h=t(g+1e-5,m,h),p.subVectors(h,u)),m-1e-5>=0?(h=t(g,m-1e-5,h),f.subVectors(u,h)):(h=t(g,m+1e-5,h),f.subVectors(h,u)),c.crossVectors(p,f).normalize(),s.push(c.x,c.y,c.z),l.push(g,m)}}for(n=0;n.9&&a<.1&&(e<.2&&(o[t+0]+=1),r<.2&&(o[t+2]+=1),n<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new Hi(i,3)),this.addAttribute("normal",new Hi(i.slice(),3)),this.addAttribute("uv",new Hi(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function ua(t,e){Fi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ha(t,e)),this.mergeVertices()}function ha(t,e){ca.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function pa(t,e){Fi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new fa(t,e)),this.mergeVertices()}function fa(t,e){ca.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function da(t,e){Fi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new ma(t,e)),this.mergeVertices()}function ma(t,e){var r=(1+Math.sqrt(5))/2,n=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1];ca.call(this,n,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ga(t,e){Fi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new va(t,e)),this.mergeVertices()}function va(t,e){var r=(1+Math.sqrt(5))/2,n=1/r,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-r,0,-n,r,0,n,-r,0,n,r,-n,-r,0,-n,r,0,n,-r,0,n,r,0,-r,0,-n,r,0,-n,-r,0,n,r,0,n];ca.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ya(t,e,r,n,i,o){Fi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i};var a=new _a(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function _a(t,e,r,n,i){Zi.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:r,radialSegments:n,closed:i},e=e||64,r=r||1,n=n||8,i=i||!1;var o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,l=new He,c=new He,u=new _e,h=[],p=[],f=[],d=[];function m(i){var a=t.getPointAt(i/e),u=o.normals[i],f=o.binormals[i];for(s=0;s<=n;s++){var d=s/n*Math.PI*2,m=Math.sin(d),g=-Math.cos(d);c.x=g*u.x+m*f.x,c.y=g*u.y+m*f.y,c.z=g*u.z+m*f.z,c.normalize(),p.push(c.x,c.y,c.z),l.x=a.x+r*c.x,l.y=a.y+r*c.y,l.z=a.z+r*c.z,h.push(l.x,l.y,l.z)}}!function(){for(a=0;ar)){var n=t.ray.origin.distanceTo(ho);nt.far||e.push({distance:n,point:ho.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)}}),Ho.prototype=Object.assign(Object.create(Wn.prototype),{constructor:Ho,copy:function(t){Wn.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){mo.setFromMatrixPosition(t.matrixWorld),go.setFromMatrixPosition(this.matrixWorld);var r=mo.distanceTo(go);e[0].object.visible=!0;for(var n=1,i=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(;nn||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}else for(d=0,m=p.length/3-1;dn||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}else if(i.isGeometry){var y=i.vertices,_=y.length;for(d=0;d<_-1;d+=u){var x;bo.distanceSqToSegment(y[d],y[d+1],c,l)>n||(c.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(c))t.far||e.push({distance:x,point:l.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Ko.prototype=Object.assign(Object.create($o.prototype),{constructor:Ko,isLineSegments:!0}),Qo.prototype=Object.assign(Object.create($o.prototype),{constructor:Qo,isLineLoop:!0}),Jo.prototype=Object.create(fn.prototype),Jo.prototype.constructor=Jo,Jo.prototype.isPointsMaterial=!0,Jo.prototype.copy=function(t){return fn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},ta.prototype=Object.assign(Object.create(Wn.prototype),{constructor:ta,isPoints:!0,raycast:(So=new Xe,Mo=new eo,Ao=new yn,function(t,e){var r=this,n=this.geometry,i=this.matrixWorld,o=t.params.Points.threshold;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ao.copy(n.boundingSphere),Ao.applyMatrix4(i),Ao.radius+=o,!1!==t.ray.intersectsSphere(Ao)){So.getInverse(i),Mo.copy(t.ray).applyMatrix4(So);var a=o/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new He;if(n.isBufferGeometry){var c=n.index,u=n.attributes.position.array;if(null!==c)for(var h=c.array,p=0,f=h.length;pt.far)return;e.push({distance:c,distanceToRay:Math.sqrt(a),point:l.clone(),index:o,face:null,object:r})}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ea.prototype=Object.assign(Object.create(Wn.prototype),{constructor:ea}),ra.prototype=Object.create(Be.prototype),ra.prototype.constructor=ra,na.prototype=Object.create(Be.prototype),na.prototype.constructor=na,na.prototype.isCompressedTexture=!0,ia.prototype=Object.create(Be.prototype),ia.prototype.constructor=ia,ia.prototype.isDepthTexture=!0,oa.prototype=Object.create(Zi.prototype),oa.prototype.constructor=oa,aa.prototype=Object.create(Fi.prototype),aa.prototype.constructor=aa,sa.prototype=Object.create(Zi.prototype),sa.prototype.constructor=sa,la.prototype=Object.create(Fi.prototype),la.prototype.constructor=la,ca.prototype=Object.create(Zi.prototype),ca.prototype.constructor=ca,ua.prototype=Object.create(Fi.prototype),ua.prototype.constructor=ua,ha.prototype=Object.create(ca.prototype),ha.prototype.constructor=ha,pa.prototype=Object.create(Fi.prototype),pa.prototype.constructor=pa,fa.prototype=Object.create(ca.prototype),fa.prototype.constructor=fa,da.prototype=Object.create(Fi.prototype),da.prototype.constructor=da,ma.prototype=Object.create(ca.prototype),ma.prototype.constructor=ma,ga.prototype=Object.create(Fi.prototype),ga.prototype.constructor=ga,va.prototype=Object.create(ca.prototype),va.prototype.constructor=va,ya.prototype=Object.create(Fi.prototype),ya.prototype.constructor=ya,_a.prototype=Object.create(Zi.prototype),_a.prototype.constructor=_a,xa.prototype=Object.create(Fi.prototype),xa.prototype.constructor=xa,ba.prototype=Object.create(Zi.prototype),ba.prototype.constructor=ba,wa.prototype=Object.create(Fi.prototype),wa.prototype.constructor=wa,Sa.prototype=Object.create(Zi.prototype),Sa.prototype.constructor=Sa;var Ma={area:function(t){for(var e=t.length,r=0,n=e-1,i=0;i=-Number.EPSILON&&w>=-Number.EPSILON&&b>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],l=[],c=[];if(Ma.area(e)>0)for(o=0;o2;){if(h--<=0)return r?c:s;if(u<=(i=o)&&(i=0),u<=(o=i+1)&&(o=0),u<=(a=o+1)&&(a=0),t(e,i,o,a,u,l)){var p,f,d,m,g;for(p=l[i],f=l[o],d=l[a],s.push([e[p],e[f],e[d]]),c.push([l[i],l[o],l[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var d;if(p>0){if(f<0||f>p)return[];if((d=c*u-l*h)<0||d>p)return[]}else{if(f>0||f0||dS?[]:y===S?o?[]:[g]:_<=S?[g,v]:[g,b])}function o(t,e,r,n){var i=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,l=n.x-t.x,c=n.y-t.y,u=i*s-o*a,h=i*c-o*l;if(Math.abs(u)>Number.EPSILON){var p=l*s-c*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,l,c,u,h,p={},f=t.concat(),d=0,m=e.length;di&&(s=0);var l=o(n[t],n[a],n[s],r[e]);if(!l)return!1;var c=r.length-1,u=e-1;u<0&&(u=c);var h=e+1;return h>c&&(h=0),!!(l=o(r[e],r[u],r[h],n[t]))}function s(t,e){var r,o;for(r=0;r0)return!0;return!1}var l=[];function c(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}for(var u,h,p,f,d,m,g,v,y,_,x=[],b=0,w=e.length;b0&&!(--M<0);)for(h=S;h=0)break;x[m]=!0}if(u>=0)break}return n}(t,e),v=Ma.triangulate(g,!1);for(a=0,s=v.length;a0)&&d.push(b,w,M),(l!==r-1||c0&&v(!0),e>0&&v(!1)),this.setIndex(c),this.addAttribute("position",new Hi(u,3)),this.addAttribute("normal",new Hi(h,3)),this.addAttribute("uv",new Hi(p,2))}function Ba(t,e,r,n,i,o,a){ka.call(this,0,t,e,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function Va(t,e,r,n,i,o,a){Ua.call(this,0,t,e,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function ja(t,e,r,n){Fi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new Ga(t,e,r,n)),this.mergeVertices()}function Ga(t,e,r,n){Zi.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var i,o,a=[],s=[],l=[],c=[],u=new He,h=new _e;for(s.push(0,0,0),l.push(0,0,1),c.push(.5,.5),o=0,i=3;o<=e;o++,i+=3){var p=r+o/e*n;u.x=t*Math.cos(p),u.y=t*Math.sin(p),s.push(u.x,u.y,u.z),l.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,c.push(h.x,h.y)}for(i=1;i<=e;i++)a.push(i,i+1,0);this.setIndex(a),this.addAttribute("position",new Hi(s,3)),this.addAttribute("normal",new Hi(l,3)),this.addAttribute("uv",new Hi(c,2))}Aa.prototype=Object.create(Fi.prototype),Aa.prototype.constructor=Aa,Ea.prototype=Object.create(Zi.prototype),Ea.prototype.constructor=Ea,Ea.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],r=this.getAttribute("uv"),n=r?Array.prototype.slice.call(r.array):[],i=this.index;return{position:e,uv:n,index:i?Array.prototype.slice.call(i.array):[]}},Ea.prototype.addShapeList=function(t,e){var r=t.length;e.arrays=this.getArrays();for(var n=0;nNumber.EPSILON){var p=Math.sqrt(u),f=Math.sqrt(l*l+c*c),d=e.x-s/p,m=e.y+a/p,g=((r.x-c/f-d)*c-(r.y+l/f-m)*l)/(a*c-s*l),v=(n=d+a*g-t.x)*n+(i=m+s*g-t.y)*i;if(v<=2)return new _e(n,i);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?l>Number.EPSILON&&(y=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(c)&&(y=!0),y?(n=-s,i=a,o=Math.sqrt(u)):(n=a,i=s,o=Math.sqrt(u/2))}return new _e(n/o,i/o)}for(var V=[],j=0,G=L.length,W=G-1,H=j+1;j=0;N--){for(O=N/y,D=g*Math.cos(O*Math.PI/2),I=v*Math.sin(O*Math.PI/2),j=0,G=L.length;j=0;){r=j,(n=j-1)<0&&(n=t.length-1);var i=0,o=b+2*y;for(i=0;i0||0===t.search(/^data\:image\/jpeg/);o.format=r?kt:Ut,o.needsUpdate=!0,void 0!==e&&e(o)},r,n),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),us.prototype=Object.assign(Object.create(Wn.prototype),{constructor:us,isLight:!0,copy:function(t){return Wn.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Wn.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),hs.prototype=Object.assign(Object.create(us.prototype),{constructor:hs,isHemisphereLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(ps.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),fs.prototype=Object.assign(Object.create(ps.prototype),{constructor:fs,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*ye.RAD2DEG*t.angle,n=this.mapSize.width/this.mapSize.height,i=t.distance||e.far;r===e.fov&&n===e.aspect&&i===e.far||(e.fov=r,e.aspect=n,e.far=i,e.updateProjectionMatrix())}}),ds.prototype=Object.assign(Object.create(us.prototype),{constructor:ds,isSpotLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ms.prototype=Object.assign(Object.create(us.prototype),{constructor:ms,isPointLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),gs.prototype=Object.assign(Object.create(ps.prototype),{constructor:gs}),vs.prototype=Object.assign(Object.create(us.prototype),{constructor:vs,isDirectionalLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),ys.prototype=Object.assign(Object.create(us.prototype),{constructor:ys,isAmbientLight:!0}),_s.prototype=Object.assign(Object.create(us.prototype),{constructor:_s,isRectAreaLight:!0,copy:function(t){return us.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=us.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var xs,bs={arraySlice:function(t,e,r){return bs.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,l=0;l!==e;++l)i[a++]=t[s+l];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};function ws(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function Ss(t,e,r,n){ws.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Ms(t,e,r,n){ws.call(this,t,e,r,n)}function As(t,e,r,n){ws.call(this,t,e,r,n)}function Es(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=bs.convertArray(e,this.TimeBufferType),this.values=bs.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function Cs(t,e,r,n){Es.call(this,t,e,r,n)}function Ts(t,e,r,n){ws.call(this,t,e,r,n)}function Ps(t,e,r,n){Es.call(this,t,e,r,n)}function Ls(t,e,r,n){Es.call(this,t,e,r,n)}function Rs(t,e,r,n){Es.call(this,t,e,r,n)}function Ns(t,e,r){Es.call(this,t,e,r)}function Is(t,e,r,n){Es.call(this,t,e,r,n)}function Os(t,e,r,n){Es.apply(this,arguments)}function Ds(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=ye.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Fs(t){this.manager=void 0!==t?t:ns,this.textures={}}function zs(t){this.manager=void 0!==t?t:ns}Object.assign(ws.prototype,{evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var s=e[1];t=(i=e[--r-1]))break e}o=r,r=0}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(i=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=bs.arraySlice(r,i,o),this.values=bs.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(t=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){t=!1;break}if(null!==o&&o>s){t=!1;break}o=s}if(void 0!==n&&bs.isTypedArray(n)){a=0;for(var l=n.length;a!==l;++a){var c=n[a];if(isNaN(c)){t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=bs.arraySlice(t,0,i),this.values=bs.arraySlice(e,0,i*r)),this}},Cs.prototype=Object.assign(Object.create(xs),{constructor:Cs,ValueTypeName:"vector"}),Ts.prototype=Object.assign(Object.create(ws.prototype),{constructor:Ts,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=(r-e)/(n-e),c=s+a;s!==c;s+=4)We.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Ps.prototype=Object.assign(Object.create(xs),{constructor:Ps,ValueTypeName:"quaternion",DefaultInterpolation:re,InterpolantFactoryMethodLinear:function(t){return new Ts(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Ls.prototype=Object.assign(Object.create(xs),{constructor:Ls,ValueTypeName:"number"}),Rs.prototype=Object.assign(Object.create(xs),{constructor:Rs,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:ee,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ns.prototype=Object.assign(Object.create(xs),{constructor:Ns,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:ee,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Is.prototype=Object.assign(Object.create(xs),{constructor:Is,ValueTypeName:"color"}),Os.prototype=xs,xs.constructor=Os,Object.assign(Os,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Os._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];bs.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:bs.convertArray(t.times,Array),values:bs.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ls;case"vector":case"vector2":case"vector3":case"vector4":return Cs;case"color":return Is;case"quaternion":return Ps;case"bool":case"boolean":return Ns;case"string":return Rs}throw new Error("Unsupported typeName: "+t)}}),Object.assign(Ds,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,o=r.length;i!==o;++i)e.push(Os.parse(r[i]).scale(n));return new Ds(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e},i=0,o=r.length;i!==o;++i)e.push(Os.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,o=[],a=0;a1){var c=n[h=l[1]];c||(n[h]=c=[]),c.push(s)}}var u=[];for(var h in n)u.push(Ds.CreateFromMorphTargetSequence(h,n[h],e,r));return u},parseAnimation:function(t,e){if(!t)return null;for(var r=function(t,e,r,n,i){if(0!==r.length){var o=[],a=[];bs.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],l=0;l1?t.skinWeights[n+1]:0,s=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new Ve(o,a,s,l))}if(t.skinIndices)for(n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,h=r>2?t.skinIndices[n+2]:0,p=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new Ve(c,u,h,p))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||(e.skinIndices.length,e.vertices.length))}(t,r),function(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0){var u=e.faces,h=t.morphColors[0].colors;for(n=0,i=u.length;n0&&(e.animations=r)}(t,r),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:r}:{geometry:r,materials:Ws.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Xs.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new is(i.manager).load(t,function(t){var r=null;try{r=JSON.parse(t)}catch(t){return void(void 0!==n&&n(t))}var o=r.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()&&i.parse(r,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new Hs,n=new zs,i=0,o=t.length;i0){var o=new ss(new rs(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new qo(a,s):new io(a,s);break;case"LOD":n=new Ho;break;case"Line":n=new $o(i(t.geometry),o(t.material),t.mode);break;case"LineLoop":n=new Qo(i(t.geometry),o(t.material));break;case"LineSegments":n=new Ko(i(t.geometry),o(t.material));break;case"PointCloud":case"Points":n=new ta(i(t.geometry),o(t.material));break;case"Sprite":n=new Wo(o(t.material));break;case"Group":n=new ea;break;default:n=new Wn}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(js.fromArray(t.matrix),js.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.children)for(var l=t.children,c=0;c0)){l=i;break}l=i-1}if(n[i=l]===r)return i/(o-1);var c=n[i];return(i+(r-c)/(n[i+1]-c))/(o-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new He,a=[],s=[],l=[],c=new He,u=new Xe;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new He,l[0]=new He;var h=Number.MAX_VALUE,p=Math.abs(a[0].x),f=Math.abs(a[0].y),d=Math.abs(a[0].z);for(p<=h&&(h=p,o.set(1,0,0)),f<=h&&(h=f,o.set(0,1,0)),d<=h&&o.set(0,0,1),c.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],c),l[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),l[r]=l[r-1].clone(),c.crossVectors(a[r-1],a[r]),c.length()>Number.EPSILON&&(c.normalize(),i=Math.acos(ye.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(u.makeRotationAxis(c,i))),l[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(ye.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(c.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(u.makeRotationAxis(a[r],i*r)),l[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:l}}}),tl.prototype=Object.create(Js.prototype),tl.prototype.constructor=tl,tl.prototype.isLineCurve=!0,tl.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},tl.prototype.getPointAt=function(t){return this.getPoint(t)},tl.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},el.prototype=Object.assign(Object.create(Js.prototype),{constructor:el,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new tl(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n=e){var i=r[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Fi,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:n+1],l=e[n>e.length-3?e.length-1:n+2];return new _e($s(i,o.x,a.x,s.x,l.x),$s(i,o.y,a.y,s.y,l.y))},il.prototype=Object.create(Js.prototype),il.prototype.constructor=il,il.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2,i=this.v3;return new _e(Qs(t,e.x,r.x,n.x,i.x),Qs(t,e.y,r.y,n.y,i.y))},ol.prototype=Object.create(Js.prototype),ol.prototype.constructor=ol,ol.prototype.getPoint=function(t){var e=this.v0,r=this.v1,n=this.v2;return new _e(Ks(t,e.x,r.x,n.x),Ks(t,e.y,r.y,n.y))};var al,sl=Object.assign(Object.create(el.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var c=l.getPoint(0);c.equals(this.currentPoint)||this.lineTo(c.x,c.y)}this.curves.push(l);var u=l.getPoint(1);this.currentPoint.copy(u)}});function ll(t){el.call(this),this.currentPoint=new _e,t&&this.fromPoints(t)}function cl(){ll.apply(this,arguments),this.holes=[]}function ul(){this.subPaths=[],this.currentPath=null}function hl(t){this.data=t}function pl(t){this.manager=void 0!==t?t:ns}ll.prototype=sl,sl.constructor=ll,cl.prototype=Object.assign(Object.create(sl),{constructor:cl,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;rNumber.EPSILON){if(c<0&&(a=e[o],l=-l,s=e[i],c=-c),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=c*(t.x-a.x)-l*(t.y-a.y);if(0===u)return!0;if(u<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n}var i=Ma.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,l,c=[];if(1===o.length)return s=o[0],(l=new cl).curves=s.curves,c.push(l),c;var u=!i(o[0].getPoints());u=t?!u:u;var h,p,f=[],d=[],m=[],g=0;d[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var _=!1,x=[],b=0,w=d.length;b0&&(_||(m=f))}v=0;for(var T=d.length;v0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n){We.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}}),Object.assign(sc.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(lc,{Composite:sc,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new lc.Composite(t,e,r):new lc(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:(Tl=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),Pl=["material","materials","bones"],function(t){var e=Tl.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){var i=r.nodeName.substring(n+1);-1!==Pl.indexOf(i)&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=i)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r=r){var h=r++,p=e[h];n[p.uuid]=u,e[u]=p,n[c]=h,e[h]=l;for(var f=0,d=o;f!==d;++f){var m=i[f],g=m[h],v=m[u];m[u]=g,m[h]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,l=arguments.length;s!==l;++s){var c=arguments[s].uuid,u=i[c];if(void 0!==u)if(delete i[c],u0)for(var l=this._interpolants,c=this._propertyBindings,u=0,h=l.length;u!==h;++u)l[u].evaluate(a),c[u].accumulate(n,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r)e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var l=t<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=ie,n.endingEnd=ie):(n.endingStart=t?this.zeroSlopeAtStart?ie:ne:oe,n.endingEnd=e?this.zeroSlopeAtEnd?ie:ne:oe)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=r,this}}),Object.assign(hc.prototype,i.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,o=t._propertyBindings,a=t._interpolants,s=r.uuid,l=this._bindingsByRootAndName,c=l[s];void 0===c&&(c={},l[s]=c);for(var u=0;u!==i;++u){var h=n[u],p=h.name,f=c[p];if(void 0!==f)o[u]=f;else{if(void 0!==(f=o[u])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,p));continue}var d=e&&e._propertyBindings[u].binding.parsedPath;++(f=new ac(lc.create(r,p,d),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(f,s,p),o[u]=f}a[u].resultBuffer=f.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e.99999?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(Kl.set(t.z,0,-t.x).normalize(),$l=Math.acos(t.y),this.quaternion.setFromAxisAngle(Kl,$l))}),Uc.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},Uc.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Bc.prototype=Object.create(Ko.prototype),Bc.prototype.constructor=Bc;var jc=new He,Gc=new Vc,Wc=new Vc,Hc=new Vc;function Xc(t){Js.call(this),t.length,this.points=t||[],this.closed=!1}function Yc(t,e,r,n){Js.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function qc(t,e,r){Js.call(this),this.v0=t,this.v1=e,this.v2=r}function Zc(t,e){Js.call(this),this.v1=t,this.v2=e}function $c(t,e,r,n,i,o){rl.call(this,t,e,r,r,n,i,o)}Xc.prototype=Object.create(Js.prototype),Xc.prototype.constructor=Xc,Xc.prototype.getPoint=function(t){var e,r,n,i,o=this.points,a=o.length,s=(a-(this.closed?0:1))*t,l=Math.floor(s),c=s-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/o.length)+1)*o.length:0===c&&l===a-1&&(l=a-2,c=1),this.closed||l>0?e=o[(l-1)%a]:(jc.subVectors(o[0],o[1]).add(o[0]),e=jc),r=o[l%a],n=o[(l+1)%a],this.closed||l+2=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()}(wl,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){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;a>1)+"px"})}for(;_',e)}e.addRule(".spin-vml","behavior:url(#default#VML)"),p.prototype.lines=function(e,r){var n=r.scale*(r.length+r.width),i=2*r.scale*n;function a(){return s(t("group",{coordsize:i+" "+i,coordorigin:-n+" "+-n}),{width:i,height:i})}var l,u=-(r.width+r.length)*r.scale*2+"px",h=s(a(),{position:"absolute",top:u,left:u});function p(e,i,l){o(h,o(s(a(),{rotation:360/r.lines*e+"deg",left:~~i}),o(s(t("roundrect",{arcsize:r.corners}),{width:n,height:r.scale*r.width,left:r.scale*r.radius,top:-r.scale*r.width>>1,filter:l}),t("fill",{color:c(r.color,e),opacity:r.opacity}),t("stroke",{opacity:0}))))}if(r.shadow)for(l=1;l<=r.lines;l++)p(l,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(l=1;l<=r.lines;l++)p(l);return o(e,h)},p.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n=3&&"base64"===e[r-2]?new Blob([yu(e[r-1])]):null}pu.now=(uu="undefined"!=typeof window&&window.performance)&&uu.now?uu.now.bind(uu):Date.now,pu.prototype={constructor:pu,start:function(){this.startTime=pu.now(),this.oldTime=this.startTime,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.update(),this.elapsedTime},update:function(){var t=0;if(this.running){var e=pu.now();t=.001*(e-this.oldTime),this.oldTime=e,this.elapsedTime+=t}return t}},mu.spaces=" ",gu.prototype=Object.create(Error.prototype);var bu=/^[a-zA-Z0-9_]*$/,wu=['"',"",'"'];function Su(t,e){t.includes(e)||t.push(e)}function Mu(t,e){var r=t.indexOf(e);-1!==r&&t.splice(r,1)}function Au(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e]=t[e]||[];n.includes(r)||n.push(r)})}function Eu(t,e,r){e.forEach(function(e){e=e.toLowerCase();var n=t[e];if(n){var i=n.indexOf(r);-1!==i&&n.splice(i,1),0===n.length&&delete t[e]}})}var Cu={Timer:pu,encodeQueryComponent:function(t,e){return encodeURIComponent(t).replace(e,function(t){return String.fromCharCode(parseInt(t.substr(1),16))}).replace(/%20/g,"+")},decodeQueryComponent:fu,getUrlParameters:du,getUrlParametersAsDict:function(t){for(var e={},r=du(t),n=0;n0&&(o=Object.create(o))}return o},hexColor:function(t){return"#"+("0000000"+t.toString(16)).substr(-6)},DebugTracer:mu,OutOfMemoryError:gu,allocateTyped:function(t,e){var r=null;try{r=new t(e)}catch(t){throw t instanceof RangeError?new gu(t.message):t}return r},bytesFromBase64:yu,bytesToBase64:vu,arrayFromBase64:function(t,e){return Array.prototype.slice.call(new e(yu(t)))},arrayToBase64:function(t,e){return vu(new e(t).buffer)},compareOptionsWithDefaults:function(t,e){var r=[];if(e&&t){for(var n=Object.keys(t),i=0;i0)return"!"+r.join()}return""},objectsDiff:function t(e,r){var i={};return n.forIn(e,function(e,o){if(e instanceof Object){var a=t(e,r[o]);n.isEmpty(a)||(i[o]=a)}else r&&void 0!==r[o]&&r[o]===e||(i[o]=e)}),i},forInRecursive:function(t,e){!function t(r,i){n.forIn(r,function(r,n){var o=i+(i.length>0?".":"");r instanceof Object?t(r,o+n):void 0!==r&&e(r,o+n)})}(t,"")},enquoteString:function(t){return n.isString(t)?'"'+t.replace(/"/g,'\\"')+'"':t},shotOpen:function(t){"undefined"!=typeof window&&window.open().document.write('')},shotDownload:function(t,e){if(t&&"data:"===t.substr(0,5))if(e||(e=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(xu(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(xu(t)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(t,e,r,n){for(var i=0,o=r.length;ithis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=t),t},update:function(){this._startTime=this.end()},show:function(t){void 0===t&&(t=!0),this.domElement.style.display=t?"block":"none"}};var Ru="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nu=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Iu=function(){function t(t,e){for(var r=0;r=t.reps.length&&(t.reps[ju]=Cu.deriveDeep(n,!0)),void 0!==r&&(t.reps[ju][e]=r)}function rh(t,e,r){if(t){var i=t.indexOf(Xu),o=(c=t.substr(0,i>=0?i:void 0),u=r,(h=c.indexOf(","))>=0?(u.push(c.substr(h+1).split(",")),c.substr(0,h)):c);if(i>=0){var a=t.substr(i+1).split(qu);if(t=o,e){var s=e[t],l=Cu.deriveDeep(s,!0);a.forEach(function(e){var r=e.split(Yu,2),i=decodeURIComponent(r[0]),o=decodeURIComponent(r[1]),a=Wu[Ru(n.get(s,i))];a?n.set(l,i,a(o)):hu.warn('Unknown argument "'+i+'" for option "'+t+'"')}),Object.keys(l).length>0&&(t=[t,l])}}else t=o}var c,u,h;return t}var nh={l:"load",load:String,t:"type",type:String,v:"view",view:String,u:"unit",unit:Number,menu:Gu,o:"object",object:function(t,e){var r=[],n=rh(t,Vu.defaults.objects,r);Array.isArray(n)||(n=[n]),function(t,e,r){void 0===t._objects&&(t._objects=[]);var n={type:r[0],params:e};void 0!==r[1]&&(n.opts=r[1]),t._objects[t._objects.length]=n}(e,r[0],n)},p:"preset",preset:function(t,e){e.preset=t,e.reps=null,th(e)},r:"rep",rep:function(t,e){th(e),(ju=(ju=Number(t))<=e.reps.length?ju<0?0:ju:e.reps.length)===e.reps.length&&(e.reps[ju]=ju>0?Cu.deriveDeep(e.reps[ju-1],!0):Cu.deriveDeep(Vu.defaults.presets.default[0],!0))},s:"select",select:function(t,e){eh(e,"selector",t)},m:"mode",mode:function(t,e){eh(e,"mode",rh(t,Vu.defaults.modes))},c:"color",color:function(t,e){eh(e,"colorer",rh(t,Vu.defaults.colorers))},mt:"material",material:function(t,e){eh(e,"material",rh(t,Vu.defaults.materials))},dup:function(t,e){th(e);var r=e.reps,n=r[ju];++ju>=r.length&&(r[ju]=Cu.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"};function ih(t){ju=0;for(var e={},r=0,i=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Xu+oh(t.opts)),e}}function lh(t){var e=[],r=0;return Cu.forInRecursive(t,function(t,n){e[r++]=n+"="+Cu.enquoteString(t)}),e.join(" ")}function ch(t){return n.isArray(t)?t[0]+(t.length<2?"":" "+lh(t[1])):t}function uh(t){if(t&&t.type){var e=t.type;return n.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(Cu.enquoteString).join(" ")),t.opts&&(e+=" "+lh(t.opts)),e}}function hh(t,e){var r=[],i=0;function o(t,e){null!==e&&void 0!==e&&(r[i++]=t+e)}return n.isEmpty(t)?null:(o("",e),o("s=",Cu.enquoteString(t.selector)),o("m=",ch(t.mode)),o("c=",ch(t.colorer)),o("mt=",ch(t.material)),r.join(" "))}var ph={fromURL:function(t){return ih(Cu.getUrlParameters(t))},fromAttr:function(t){return ih(Cu.getUrlParameters("?"+(t||"")))},adapters:Wu,toURL:function(t){var e=[],r=0;function i(t,n){null!==n&&void 0!==n&&(e[r++]=Ku(t)+Hu+Ku(n))}i("l",t.load),i("u",t.unit),i("p",t.preset),function(t){if(t)for(var e=0,r=t.length;e0&&(o+="?"+e.join("&")),o},toScript:function(t){var e=[],r=0;function n(t,n){null!==n&&void 0!==n&&(e[r++]=t+" "+n)}return n("set","autobuild false"),n("load",t.load),n("unit",t.unit),n("preset",t.preset),function(t){if(t)for(var e=0,r=t.length;e0?t.getString():this.element.name.trim()},mh.prototype.forEachBond=function(t){for(var e=this._bonds,r=0,n=e.length;r=0)return this._hydrogenCount;var t=this.element,e=t.hydrogenValency;if(1===e.length&&0===e[0])return 0;switch(t.number){case 1:return this.getHydrogenCountHydrogen();case 3:case 11:case 19:case 37:case 55:case 87:case 4:case 12:case 20:case 38:case 56:case 88:case 13:case 31:case 49:case 41:case 82:case 83:return this.getHydrogenCountMetal();case 6:case 14:case 32:case 51:return this.getHydrogenCountGroup14();case 50:return this.getHydrogenCountTin();case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 53:case 85:return this.getHydrogenCountNonMetal();case 5:return this.getHydrogenCountBoron();default:return 0}},mh.prototype.getAtomBondsCount=function(){for(var t,e=this.getBonds(),r=0,n=0;n=t){r=e[n];break}return r},mh.prototype.getCharge=function(){return this._charge},mh.prototype.getLocation=function(){return this._location},mh.prototype.getFullName=function(){var t="";return null!==this._residue&&(null!==this._residue._chain&&(t+=this._residue._chain.getName()+"."),t+=this._residue._sequence+"."),t+=this._name.getString()};var gh={UNKNOWN:0,COVALENT:1,AROMATIC:2};function vh(t){return t._position}function yh(t,e,r,n,i){if(this._left=t,this._right=e,this._fixed=i,this._index=-1,t>e)throw new Error("In a bond atom indices must be in increasing order");this._order=r,this._type=n}function _h(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function xh(t,e){for(var r=0,n=e.length;r0?++n:++i}function s(t){"C"===t.element.name&&a(t)}for(var l=[[this.forEachLevelOne,s],[this.forEachLevelOne,a],[this.forEachLevelTwo,s],[this.forEachLevelTwo,a]],c=0;cn)return e.multiplyScalar(-1);if(ir._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,l=0,c=s.length;la&&u!==n&&(o=u,a=u._bonds.length)}var h=t(i),p=t(n).clone().sub(h),f=t(o).clone().sub(h);return f.crossVectors(p,f),f.lengthSq()<1e-4&&f.set(0,1,0),p.normalize(),f.normalize(),p.crossVectors(f,p),p.lengthSq()<1e-4&&p.set(0,1,0),p.normalize(),this._fixDir(h,p,t)},_h.prototype.getName=function(){return this._name},_h.StandardTypes={ALA:new _h("ALA","Alanine","A"),ARG:new _h("ARG","Arginine","R"),ASN:new _h("ASN","Asparagine","N"),ASP:new _h("ASP","Aspartic Acid","D"),CYS:new _h("CYS","Cysteine","C"),GLN:new _h("GLN","Glutamine","Q"),GLU:new _h("GLU","Glutamic Acid","E"),GLY:new _h("GLY","Glycine","G"),HIS:new _h("HIS","Histidine","H"),ILE:new _h("ILE","Isoleucine","I"),LEU:new _h("LEU","Leucine","L"),LYS:new _h("LYS","Lysine","K"),MET:new _h("MET","Methionine","M"),PHE:new _h("PHE","Phenylalanine","F"),PRO:new _h("PRO","Proline","P"),PYL:new _h("PYL","Pyrrolysine","O"),SEC:new _h("SEC","Selenocysteine","U"),SER:new _h("SER","Serine","S"),THR:new _h("THR","Threonine","T"),TRP:new _h("TRP","Tryptophan","W"),TYR:new _h("TYR","Tyrosine","Y"),VAL:new _h("VAL","Valine","V"),A:new _h("A","Adenine","A"),C:new _h("C","Cytosine","C"),G:new _h("G","Guanine","G"),I:new _h("I","Inosine","I"),T:new _h("T","Thymine","T"),U:new _h("U","Uracil","U"),DA:new _h("DA","Adenine","A"),DC:new _h("DC","Cytosine","C"),DG:new _h("DG","Guanine","G"),DI:new _h("DI","Inosine","I"),DT:new _h("DT","Thymine","T"),DU:new _h("DU","Uracil","U"),"+A":new _h("+A","Adenine","A"),"+C":new _h("+C","Cytosine","C"),"+G":new _h("+G","Guanine","G"),"+I":new _h("+I","Inosine","I"),"+T":new _h("+T","Thymine","T"),"+U":new _h("+U","Uracil","U"),WAT:new _h("WAT","Water",""),H2O:new _h("H2O","Water",""),HOH:new _h("HOH","Water",""),DOD:new _h("DOD","Water",""),UNK:new _h("UNK","Unknown",""),UNL:new _h("UNL","Unknown Ligand","")},_h.Flags={PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536};var bh=_h.Flags;xh(bh.WATER,["WAT","H2O","HOH","DOD"]),xh(bh.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),xh(bh.BASIC,["ARG","HIS","LYS"]),xh(bh.ACIDIC,["ASP","GLU"]),xh(bh.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),xh(bh.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),xh(bh.AROMATIC,["PHE","TRP","TYR"]),xh(bh.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),xh(bh.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),xh(bh.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),xh(bh.DNA,["DA","DG","DI","DC","DT","DU"]),xh(bh.RNA,["A","G","I","C","T","U"]);!function(t,e){for(var r=Object.keys(e),n=0,i=r.length;nMath.PI/2&&o.negate(),o},Ch.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new He(a.x,a.y,a.z);if(0==(this._type.flags&_h.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var l=e._controlPoint;n._midPoint=l.clone().lerp(s,.5),n._wingVector=this.calcWing(l,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},Ch.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},Ch.prototype.isConnected=function(t){if(this._chain!==t._chain)return!1;if(this===t)return!0;var e=!1;return this.forEachAtom(function(r){for(var n=r._bonds,i=0,o=n.length;i1){var a=t[1]._wingVector;t[0]._wingVector=new He(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new He(1,0,0))},Th.prototype.updateToFrame=function(t){var e=this._residues,r=null,n=null,i=t._residues,o=e.length;function a(e){return t.getAtomPos(e._index)}for(var s=0;s1?i[e[1]._index]._wingVector:new He(1,0,0)},Th.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new Ch(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(_h.Flags.NUCLEIC|_h.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},Th.prototype.getResidueCount=function(){return this._residues.length},Th.prototype.forEachResidue=function(t){for(var e=this._residues,r=0,n=e.length;r1?i=n>1?this._repeat.toString()+"("+i+")":this._repeat.toString()+i:n>1&&(i="("+i+")"),o>1&&(i+="^"+o.toString()+"+"),1===o&&(i+="^+"),o<-1&&(i+="^"+Math.abs(o).toString()+"-"),-1===o&&(i+="^-")):this._repeat>1&&(i=this._repeat.toString()+i),i};var Ih={},Oh=Object.freeze({default:Ih}); +// Copyright Joyent, Inc. and other Node contributors. +// The above copyright notice and this permission notice shall be included +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +function Dh(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}var Fh=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,zh=function(t){return Fh.exec(t).slice(1)};function kh(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return t=Dh(Yh(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function Uh(t){var e=Bh(t),r="/"===qh(t,-1);return(t=Dh(Yh(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function Bh(t){return"/"===t.charAt(0)}function Vh(){return Uh(Yh(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function jh(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=kh(t).substr(1),e=kh(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;s2&&A.push("'"+this.terminals_[w]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(l+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(c=p.yyleng,s=p.yytext,l=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],C.$=i[i.length-S],C._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(C._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(C,[s,c,l,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(C.$),o.push(C._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},g={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return e.yytext=e.yytext.substr(1,e.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};function v(){this.yy={}}return m.lexer=g,v.prototype=m,m.Parser=v,new v}();void 0!==e&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=$h.readFileSync(Kh.normalize(t[1]),"utf8");return r.parser.parse(e)},e.main===t&&r.main(process.argv.slice(1)))}),Jh=Qh.parser,tp=(Qh.Parser,Qh.parse,Qh.main,{});function ep(t,e){var r=t.toLowerCase();e.prototype.keyword=r,e.prototype.name=t;var n=function(){for(var t=arguments.length,r=Array(t),n=0;n=0&&e.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var t=this._values,e=[],r=0,n=t.length;rthis.priority?"("+this.rhs+")":this.rhs;return this.keyword+" "+t}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),e}();dp.prototype.priority=1;var mp=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||hp,n.rhs=r||hp,n}return Ou(e,sp),Iu(e,[{key:"toString",value:function(){var t=this.lhs.priority&&this.lhs.priority>this.priority?"("+this.lhs+")":this.lhs,e=this.rhs.priority&&this.rhs.priority>this.priority?"("+this.rhs+")":this.rhs;return t+" "+this.keyword+" "+e}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),e}();mp.prototype.priority=1e3,fp("Not",1,function(t){function e(){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Ou(e,dp),Iu(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),fp("And",2,function(t){function e(){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Ou(e,mp),Iu(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),fp("Or",3,function(t){function e(){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Ou(e,mp),Iu(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var gp=Object.create(tp);function vp(t){this._complex=t,this._selector=gp.keyword("All")(),this._boundaries={boundingBox:new vn,boundingSphere:new yn}}function yp(t){vp.call(this,t),this.chains=[],this.matrices=[]}function _p(){if(this.constructor===_p)throw new Error("Can not instantiate abstract class!")}function xp(t){this._complex=t,this._index=-1,this._residueIndices=[],this._cycles=[],this._subDivs=[],this._residueCount=0}gp.Selector=sp,gp.RangeListSelector=cp,gp.ValueListSelector=up,gp.Range=rp,gp.RangeList=ip,gp.ValueList=ap,gp.PrefixOperator=dp,gp.InfixOperator=mp,gp.Context=Object.create({}),gp.GetSelector=function(t){if(!gp.Context.hasOwnProperty(t))throw{message:"selector "+t+" is not registered"};return gp.Context[t]||hp},gp.ClearContext=function(){Object.keys(gp.Context).forEach(function(t){delete gp.Context[t]})},gp.keyword=function(t){return tp[t.toLowerCase()]||tp.none},gp.parse=function(t){var e={};try{e.selector=Jh.parse(t)}catch(t){e.selector=hp,e.error=t.message}return e},Jh.yy=gp,Jh.yy.parseError=Jh.parseError,vp.prototype.constructor=vp,vp.prototype.computeBoundaries=function(){var t,e=this._complex._atoms,r=e.length,n=this._selector,i=this._boundaries.boundingBox;if(i.makeEmpty(),1===r){i.expandByPoint(e[0]._position);var o=i.getCenter(),a=2*e[0].element.radius;i.setFromCenterAndSize(o,new He(a,a,a))}else for(t=0;t0?this._selector=gp.keyword("Chain")(this.chains):this._selector=gp.keyword("None")()},_p.prototype.id="__",xp.prototype.getResidues=function(){return this._complex._residues},xp.prototype.getResidueCount=function(){return this._residueCount},xp.prototype.forEachResidue=function(t){for(var e=this._complex._residues,r=this._residueIndices,n=0,i=r.length;ne?t:e,i=r+(n<<14),o=(r+89237*n&wp-1)*bp,a=0;a=bp)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");o=this.numPairs*Sp,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};function Ep(t){var e=t.element;if(e)return e.radiusBonding;throw new Error("_getBondingRadius: Logic error.")}function Cp(t,e,r){return tr?r:t}function Tp(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function Pp(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function Lp(t){this._complex=t,this._maxRad=1.8;var e=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=e.min.clone(),this._vBoxMax=e.max.clone(),this._pairCollection=null}Lp.prototype._addExistingPairs=function(){for(var t=this._complex.getAtoms(),e=t.length,r=0,n=this._pairCollection;r=a))for(var b=-1;b<=1;++b){var w=v+b;if(!(w<0||w>=o))for(var S=-1;S<=1;++S){var M=g+S;if(!(M<0||M>=i))for(var A=t[x*l+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},Lp.prototype._addPairs=function(){for(var t=this._complex._atoms,e=0,r=0;e125e3);this.xB=t,this.yB=e,this.zB=r,this.invPairDist=i;for(var f=[],d=0;d.1)&&Rp.dot(Np)>=0});function Up(t,e){for(var r=0;r3}function Xp(t){return!0}function Yp(t){this._complex=t;for(var e=new Array(t._bonds.length),r=new Array(t._bonds.length),n=0,i=e.length;n>1;t;)e<<=1,t>>=1;return e}function Kp(t,e){var r;this._box=t.clone(),this._count=t.size().divide(e).floor(),this._last=this._count.clone().subScalar(1),this._cellSize=t.size().divide(this._count);var n=this._count.x*this._count.y*this._count.z;for(this._voxels=Cu.allocateTyped(Int32Array,n),r=0;ri[l]?++l:++s}return!1},Yp.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Bp(t,e),a=e._position.clone().sub(o._position),s=this._currStart,l=this,c=this._bondMarks,u=this._checkBond;c[t._index]=!0,u=void 0===u?Gp:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!c[o._index]&&!l._haveSameCycle(i,t,o)){var h,p,f,d=Bp(o,e),m=d._position.clone().sub(e._position),g=d===s?-2:1-(p=m,f=(h=a).dot(p)/Math.sqrt(h.lengthSq()*p.lengthSq()),ye.clamp(f,-1,1)),v=m.cross(a);if(kp(v,r)){for(var y=0;ys?1:0},qp.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},qp.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},qp.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=dh.ByName.H.name,l=0;r.forEach(function(t){var e=t.getHydrogenCount();n=t.element,i[n.name]?i[n.name]+=1:i[n.name]=1,e>0&&(i[s]?i[s]+=e:i[s]=e),l+=t.getCharge()});var c=Object.keys(i);return i.C?c.sort(this._atomNameCompareCWithH.bind(this)):c.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),c.forEach(function(t){var e=t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase();i[t]>1?o+=e+i[t].toString():o+=e}),null===e?(0!==l&&(c.length>1&&(o="("+o+")"),l>1&&(o+="^{"+l.toString()+"+}"),1===l&&(o+="^+"),l<-1&&(o+="^{"+Math.abs(l).toString()+"-}"),-1===l&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(c.length,l),o},qp.prototype._buildPartFormula=function(t){return t.owner instanceof qp||t.owner instanceof xp?this._buildFormulaSimple(t,null):t.owner instanceof Nh?t.owner.buildChemicalFormula(this,t):""},qp.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},qp.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[i]?r[i]+=n:r[i]=n)}});var o=Object.keys(r);return o.sort(n._atomNameCompareCWithoutH.bind(n)),{seq:o,data:r}}for(var a,s=[r,!1],l=0;ldh.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{"}return""},qp.prototype.buildChemicalFormula=function(){var t=[],e=null,r=null,n={},i=null,o=this,a=this._checkFormulaBuildable();if(""!==a)return a;this.forEachAtom(function(t){n[t.getSerial()]&&hu.warn("Broken complex. Formula can be invalid..."),n[t.getSerial()]={atom:t,taken:null}}),this.forEachSGroup(function(o){0===o._charge&&1===o._repeat||(r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)}),e.atoms.length>0&&t.push(e),e=null)}),this.forEachComponent(function(o){r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o.forEachResidue(function(t){t._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)})}),e.atoms.length>0&&t.push(e),e=null}),Object.keys(n).forEach(function(t){null===t.taken&&(null===e&&(e={owner:o,atoms:[],repeatCount:1}),e.atoms.push(t.atom),t.taken=o)}),null!==e&&e.atoms.length>0&&t.push(e),t.sort(function(t,e){return o._partCompareFunc(t,e)});for(var s=t.length-1,l=t.length-2;s>=0&&l>=0;){var c=t[s],u=t[l];c.owner instanceof qp||c.owner instanceof xp?u.owner instanceof qp||u.owner instanceof xp?(0===this._partCompareFuncInt(u,c,!1)&&(u.repeatCount+=c.repeatCount,t.splice(s,1)),l--,s--):l--:--s===l&&l--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},qp.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},qp.prototype.splitUnifiedSerial=function(t){var e=Math.floor(t/16777216),r=t-16777216*e,n=Math.floor(r/65536);return{chain:e,serial:r-65536*n,iCode:n}},qp.prototype._fillCmpEdit=function(){var t=this,e=this._components;function r(){var r=new xp(t);return r._index=e.length,e[r._index]=r,r}this.forEachChain(function(t){var e=t._residues,n=e.length;if(!(n<1))for(var i=r(),o=e[0]._index,a=0;a=0&&t=0;e--){var i=n[e];null===i._left||null===i._right?n.splice(e,1):(i._left._bonds.push(i),i._right._bonds.push(i))}var o=this._residues;for(e=0,r=o.length;e1?t.x/(this._dimX-1):0,e.y=this._dimY>1?t.y/(this._dimY-1):0,e.z=this._dimZ>1?t.z/(this._dimZ-1):0,e},Zp.prototype.computeGradient=function(){if(1!==this._dimVec)return null;var t=new Zp(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),e=this.getCellSize(),r=new He(-.5/e.x,-.5/e.y,-.5/e.z);function n(t,e,r){return Math.min(r,Math.max(e,t))}var i=this._dimX,o=this._dimY,a=this._dimZ,s=this._data;function l(t,e,r){return s[r*i*o+e*i+t]}for(var c=0;c=0;r=this._atoms[r+1])e(this._atoms[r])},Kp.prototype._forEachVoxelWithinRadius=function(t,e,r){var n,i,o,a,s,l,c,u,h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C=new _e,T=new _e,P=new _e;P.set(t.z-e,t.z+e),P.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var L=P.x;L<=P.y;++L){s=[this._box.min.z+L*this._cellSize.z,this._box.min.z+(L+1)*this._cellSize.z],u=t.z-e<=s[0]&&s[1]<=t.z+e,_=t,x=e,b=s[0],w=s[1],void 0,void 0,void 0,void 0,S=b-_.z,M=w-_.z,A=Math.sqrt(Math.max(x*x-S*S,0)),E=Math.sqrt(Math.max(x*x-M*M,0)),n=[Math.min(A,E),b<=_.z&&w>=_.z?x:Math.max(A,E)],T.set(t.y-n[1],t.y+n[1]),T.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var R=T.x;R<=T.y;++R){a=[this._box.min.y+R*this._cellSize.y,this._box.min.y+(R+1)*this._cellSize.y],c=t.y-n[0]<=a[0]&&a[1]<=t.y+n[0],h=t,p=n[1],f=a[0],d=a[1],void 0,void 0,void 0,void 0,m=f-h.y,g=d-h.y,v=Math.sqrt(Math.max(p*p-m*m,0)),y=Math.sqrt(Math.max(p*p-g*g,0)),i=[Math.min(v,y),f<=h.y&&d>=h.y?p:Math.max(v,y)],C.set(t.x-i[1],t.x+i[1]),C.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var N=C.x;N<=C.y;++N)o=[this._box.min.x+N*this._cellSize.x,this._box.min.x+(N+1)*this._cellSize.x],l=t.x-i[0]<=o[0]&&o[1]<=t.x+i[0],r(N+this._count.x*(R+this._count.y*L),l&&c&&u)}}},Kp.prototype.forEachAtomWithinRadius=function(t,e,r){var n=this,i=e*e;n._forEachVoxelWithinRadius(t,e,function(e,o){o?n._forEachAtomInVoxel(e,r):n._forEachAtomInVoxel(e,function(e){t.distanceToSquared(e._position)=0;l=s[l+1])if(t._position.distanceToSquared(s[l]._position)=1?this.fov=t:this.fov=ye.radToDeg(2*Math.atan(Math.tan(.5*ye.degToRad(t))/this.aspect))},Yn.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*ye.degToRad(e))},zi.prototype.copyAtList=function(t,e){for(var r=this.itemSize,n=0,i=e.length;n1e-5;)e=n,n=t/((i=1+r*n)*i);return 1/i}for(var i=new Ji(2,2,t,e),o=i.getAttribute("position"),a=0;a65535,l=o*e,c=this._index=Cu.allocateTyped(s?Uint32Array:Uint16Array,l);this._positions=Cu.allocateTyped(Float32Array,3*a),this._normals=Cu.allocateTyped(Float32Array,3*a),this._colors=Cu.allocateTyped(Float32Array,3*a);var u=this._alpha=Cu.allocateTyped(Float32Array,a);n.fill(u,1);for(var h=0;h0,l=!1===o&&e>0,c=(i+1)*n+s*(n+1)+l*(n+1),u=(2*i+s+l)*n,h=r/2,p=new zi(Cu.allocateTyped(Float32Array,3*c),3),f=new zi(Cu.allocateTyped(Float32Array,3*c),3),d=new ji(Cu.allocateTyped(Uint16Array,u*Df),1),m=new zi(Cu.allocateTyped(Float32Array,2*c),2),g=0,v=0,y=-(e-t)/r,_=0;_<=i;_++){if(_!==i)for(var x=0;x65535;this._index=Cu.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=Cu.allocateTyped(Float32Array,4*e),this._colors=Cu.allocateTyped(Float32Array,3*e),this._directions=Cu.allocateTyped(Float32Array,3*e);var i=this._alpha=Cu.allocateTyped(Float32Array,e);n.fill(i,1);for(var o=this._index,a=0,s=0,l=0;l117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=Cu.allocateTyped(Float32Array,32*e),this.hasIntersection=Cu.allocateTyped(Int32Array,e),this.bitsInside=Cu.allocateTyped(Int32Array,e),0},xd.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},xd.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var bd=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0];function wd(){this._arrSize=8,this.p=new Array(this._arrSize),this.g=new Array(this._arrSize),this.val=new Array(this._arrSize);for(var t=0;t0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(l,c,f)},Md.prototype._polygonize=function(){for(var t=xd.prototype.striIndicesMarchCube,e=[0,1,2,3,4,5,6,7,0,1,2,3],r=[1,2,3,0,5,6,7,4,4,5,6,7],n=new Array(12),i=new Array(12),o=0;o<12;++o)n[o]=new He,i[o]=new He;return function(a,s,l){var c=a.cubeIndex;for(o=0;o<12;++o)bd[c]&1<s?s:c+e,h=-1,p=c;pV&&(j=G,V=A[G]);if(j<0||!n.includesAtom(M[j])){P[i]=-1;continue}}P[i]=L++;var W=D=0&&nt>=0&&it>=0&&(this._indices[3*et]=rt,this._indices[3*et+1]=nt,this._indices[3*et+2]=it,++et)}this._position=new Float32Array(this._position.buffer.slice(0,3*L*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*L*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*L*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*et*4))}},Md.prototype.toMesh=function(){var t=new Zi;return t.setIndex(new zi(this._indices,1)),t.addAttribute("position",new zi(this._position,3)),t.addAttribute("normal",new zi(this._normals,3)),t.addAttribute("color",new zi(this._colors,3)),t.computeBoundingSphere(),t},Ad.prototype=Object.create(_d.prototype),Ad.prototype.constructor=Ad,Ad.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new He(1,0,0),this.yAxis=new He(0,1,0),this.zAxis=new He(0,0,1),this.origin=new He(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},Ad.prototype._findMinMax=function(t){for(var e=t.length/4,r=[t[0],t[1],t[2],t[3]],n=[t[0],t[1],t[2],t[3]],i=1;i4&&(e.gridSpacing*=i[3]);var a=e.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var l=0;l<3;++l)i[l]-=a,o[l]+=a;for(l=0;l<3;++l)r[l]=Math.ceil((o[l]-i[l])/e.gridSpacing);return this.xAxis.x=(r[0]-1)*e.gridSpacing,this.yAxis.y=(r[1]-1)*e.gridSpacing,this.zAxis.z=(r[2]-1)*e.gridSpacing,this.origin.x=i[0],this.origin.y=i[1],this.origin.z=i[2],{bbox:n,dim:r}},Ad.prototype._makeSurface=function(t,e){var r=new Md;r.compute(t.volMap,this.origin,e.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0&&(r.setColorVolTex(t.volTexMap,t.atomMap,t.atomWeightMap,this._visibilitySelector),this.setIndex(new zi(r._indices,1)),this.addAttribute("position",new zi(r._position,3)),this.addAttribute("normal",new zi(r._normals,3)),this.addAttribute("color",new zi(r._colors,3)))},Ad.prototype._calcSurface=function(t){var e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==e.posRad.length){var r=this._findNumVoxels(e.posRad,t),n=new vn(this.origin,new He(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var Ed=Jp.Volume;function Cd(t,e){Ad.call(this,t,e)}function Td(t,e,r,n){var i,o,a,s,l,c,u,h,p,f,d,m,g,v,y,_,x,b=4,w=t.posRad,S=t.colors,M=t.atoms,A=w.length/b,E=e.bbox,C=E.minPosRad,T=E.maxPosRad,P=-1,L=null,R=null,N=null,I=new He(0,0,0),O=new He(0,0,0),D=new He(0,0,0);function F(){a=r.probeRadius,s=r.scaleFactor,l=r.probePositions,N=r.visibilitySelector,i=Cu.allocateTyped(Float32Array,A),o=0;for(var t=0;to&&(o=n),i[t]=n*n}!function(){s=r.scaleFactor,c=e.dim,x=Math.min(5,2+Math.floor(a*s));var t=c[0]*c[1]*c[2];u=function(t,e,r){for(var n=Cu.allocateTyped(t,e),i=0;iP&&(P=N)}this.neighbourListLength=27*P+1,this.withinRadii=function(e,r,n,i,l){var c=0,u=h(e,o),d=h(r,a),m=h(n,s),g=Math.max(0,u-1),x=Math.max(0,d-1),w=Math.max(0,m-1),S=Math.min(v-1,u+1),T=Math.min(y-1,d+1),P=Math.min(_-1,m+1);for(p=g;p<=S;++p){var L=p*b;for(M=x;M<=T;++M)for(var R=M*_,N=w;N<=P;++N)for(var I=A[f=L+R+N],O=I+E[f],D=I;D=0;){if(o!==n&&o!==i&&U(o,t,e,r))return P=o,o;o=_[++a]}return P=-1,-1}function U(t,e,r,n){var o=b*t,a=i[t],s=w[o]-e,l=w[o+1]-r,c=w[o+2]-n;return s*s+l*l+c*c0&&ML[$]&&(L[$]=J,R[$]=M[t]),u[$]<0&&(u[$]=-u[$]);var et=Math.sqrt(Q),rt=a/et,nt=K*rt,it=X*rt,ot=G*rt;if(-1===k(nt+=r,it+=n,ot+=o,t,-1)){var at=a-et;at=0;)t0){r=1/r;var n=3*t;h[n]*=r,h[n+1]*=r,h[n+2]*=r}}}()}this.build=function(){V(),this.volTexMap=h,this.weightsMap=L,this.atomMap=R,this.volMap=u}}Cd.prototype=Object.create(Ad.prototype),Cd.prototype.constructor=Cd,Cd.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new Ed(Float32Array,this.numVoxels,e),volTexMap:new Ed(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new Ed(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},Cd.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,l=this.numVoxels,c=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=l[0]-1,m=l[1]-1,g=l[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,U),W=y.getDirectIdx(N,V,U),H=N*h-a[A],X=N;X<=I;++X,H+=h,G+=x,W+=w){var Y=-(H*H+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var Z=3*M;b[W]+=q*s[Z],b[W+1]+=q*s[Z+1],b[W+2]+=q*s[Z+2]}}}},Cd.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;oc?e:c,u+=e;var h=Math.floor(s/c);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=c;var p=h,f=h*h,d=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),g=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),v=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),y=0,_=m*h,x=g*h,b=v*h;for(l=0;l=0?C:0,T=T>=0?T:0,P=P>=0?P:0,L=L=0;s=this._atomsList[2*s+1]){e(a[this._atomsList[2*s]])}},Nd.prototype.getClosestAtom=function(t){var e=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(t,function(n){var i=t.distanceToSquared(n.coord);im)){var v=t.radius+i._probeRadius;(p=n-v*v)<0&&(p=-p),f=Math.exp(g*p),c+=e*f,u+=r*f,h+=d*f,o++}},y=0;y0&&(p=1/Math.sqrt(n),c*=p,u*=p,h*=p),r[y].x=c,r[y].y=u,r[y].z=h;return 0},Nd.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,l=0,c=0,u=n*n,h=[],p=[],f=0,d=function(t){var e=o-t.coord.x,r=a-t.coord.y,n=s-t.coord.z,d=e*e+r*r+n*n;if(!(d>u)){var m=t.radius+i._probeRadius;(l=d-m*m)<0&&(l=-l),c=1/(.8+l),h.push([t.colorX,t.colorY,t.colorZ]),p.push(c),f+=c}},m=0;m=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var F=new Dr(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(l=this.atomColors[D].x,c=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var z=this.complex.monomerTypeArray[h].color;l=z.r,c=z.g,u=z.b}1!==this.colorMode&&0!==this.colorMode&&(l=this.atomColors[D].x,c=this.atomColors[D].y,u=this.atomColors[D].z),F.set(E,C,T),s[x]=new Rd(F,L),s[x].colorX=l,s[x].colorY=c,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Od.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var Dd=Jp.Element;function Fd(t,e){_d.call(this,t,e)}function zd(t,e){su.call(this),this._opts=e,this.items=[],this.needsUpdate=!1;var r=-50,n=-50;switch(e.horizontalAlign){case"left":r=0;break;case"right":r=-100}switch(e.verticalAlign){case"top":n=-100;break;case"bottom":n=0}var i=new He(e.dx||0,e.dy||0,e.dz||0);this.userData={translation:"translate("+r+"%, "+n+"%)",offset:i}}Fd.prototype=Object.create(_d.prototype),Fd.prototype.constructor=Fd,Fd.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},Fd.prototype._fromGeo=function(t){var e=null,r=Cu.allocateTyped(Float32Array,3*t._numVertices),n=Cu.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=Cu.allocateTyped(Float32Array,3*t._numVertices));var i,o=Cu.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?l:i,s.x-lr.x&&(r.x=s.x+l),s.y+l>r.y&&(r.y=s.y+l),s.z+l>r.z&&(r.z=s.z+l)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},Fd.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),l=r*s,c=n*s,u=i*s;a.x=t.x*(1-l)+e.x*l,a.y=t.y*(1-c)+e.y*c,a.z=t.z*(1-u)+e.z*u},Fd.prototype.buildEdgePoint=function(t,e,r,n,i,o){if(r[t]^r[e]){var a=(0-n.pointsValuesLinear[i+24+t])/(n.pointsValuesLinear[i+24+e]-n.pointsValuesLinear[i+24+t]),s=n.pointsValuesLinear[i+3*t+0],l=n.pointsValuesLinear[i+3*t+1],c=n.pointsValuesLinear[i+3*t+2],u=n.pointsValuesLinear[i+3*e+0],h=n.pointsValuesLinear[i+3*e+1],p=n.pointsValuesLinear[i+3*e+2];o.x=s*(1-a)+u*a,o.y=l*(1-a)+h*a,o.z=c*(1-a)+p*a}},Fd.prototype.isTriangleVisible=function(t,e,r){var n=this.voxelWorld.getClosestAtom(t),i=this.voxelWorld.getClosestAtom(e),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&(this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom))},Fd.prototype.addTriangle=function(t,e,r){if(this.visibilitySelector&&!this.isTriangleVisible(t,e,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,t),o=this.addVertexToGeo(n,e),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0},Fd.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,l=t-1,c=t,u=t*t,h=new Array(12);for(a=0;a<12;a++)h[a]=new He;var p=[];for(a=0;a<8;a++)p[a]=1;for(var f=new He,d=0,m=0,g=0;ge.length/2||2*Object.keys(Dd.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},Fd.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,l=new He,c=new He,u=0;u=0;r=this.hashEntries[2*r+1]){var c=this.hashEntries[2*r+0];if(i.copy(t._vertices[c]),i.x-=e.x,i.y-=e.y,i.z-=e.z,i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return c}if(t._numVertices>=this.maxNumVertices)return-1;var u=t._numVertices;if(t._vertices[u].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var h=this.hashLines[l+1];this.hashLines[l+1]=r,this.hashEntries[2*r+0]=u,this.hashEntries[2*r+1]=h,this.hashLines[l+0]++}return t._numVertices++,u},Fd.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){var a,s,l;for(var c=t*t,u=(t-1)/(n.x-r.x),h=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),f=2*e*(2*e),d=1/(t-1),m=0;m=0?y:0,_=_>=0?_:0,x=x>=0?x:0,b=b<=t-1?b:t-1,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1;for(var M=_;M<=w;M++)for(var A=M*c,E=x;E<=S;E++)for(var C=E*t,T=y;T<=b;T++){a=A+C+T;var P=T*d,L=r.x*(1-P)+n.x*P;P=M*d;var R=r.y*(1-P)+n.y*P;P=E*d;var N=r.z*(1-P)+n.z*P,I=L-g.x,O=R-g.y,D=N-g.z,F=I*I+O*O+D*D;F0?(o[a]<0&&(o[a]=l),l>o[a]&&(o[a]=l)):l>o[a]&&(o[a]=l))}}return 0},Fd.prototype._innerBuild=function(){var t,e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=e.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.clusterizationType=this._opts.clusterizationType,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var r=new Array(this.atoms.length);this.convertToAtomsColored(e,r);var n=this.vBoxMin=new He,i=this.vBoxMax=new He;this.getBoundingBox(r,n,i);var o=this.marCubeResoultion=4*this.meshResolution,a=o,s=a*a*a,l=Cu.allocateTyped(Float32Array,s),c=this.meshResolution,u=4,h=this.atoms.length;h>=100&&(u=Math.floor(Math.pow(2*h,1/3))),c>u&&(c=u);var p=this.probeRadius*this.atomRadiusScale,f=null,d=null;this.clusterizationType>0?(f=new Id(this.complex,this.atoms,r,n,i,c,this.colorMode),d=1===this.clusterizationType?f.buildKMeans():f.buildSimple(),n.x-=3.5,n.y-=3.5,n.z-=3.5,i.x+=3.5,i.y+=3.5,i.z+=3.5,this.calculateGridCorners(l,a,n,i,d,p)):this.calculateGridCorners(l,a,n,i,r,p);var m=o-1,g=new xd;if((t=g.create(m))<0)return t;var v=new He;v.x=(i.x-n.x)/m,v.y=(i.y-n.y)/m,v.z=(i.z-n.z)/m;var y=this.getNumIntersectedCells(a,m,l,g),_=Math.floor(1.2*y),x=Math.floor(1.2*y*2);if(this.geoOut=new Od(_,x,this.useVertexColors),(t=this.createVertexHash(_,x))<0)return t;var b=p;if(this.excludeProbe&&(b=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Nd(d.length,d,n,i,b):this.voxelWorld=new Nd(r.length,r,n,i,b),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,l,v,g),this.excludeProbe){if(this.modifyExcludedFromGeo(a,p,n,i,this.geoOut,l),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,y=this.getNumIntersectedCells(a,m,l,g),_=Math.floor(1.2*y),x=Math.floor(1.2*y*2),this.geoOut=new Od(_,x,this.useVertexColors),(t=this.createVertexHash(_,x))<0)return t;t=this.buildGeoFromCorners(a,n,i,l,v,g)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var w=6.5;this.excludeProbe&&(w-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,w)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==f&&f.destroy(),g.destroy(),t},zd.prototype=Object.create(su.prototype),zd.prototype.constructor=zd,zd.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||function(t,e){var r=document.createElement("div");if(r.className=e,"string"==typeof t){var n=document.createElement("span");n.style.fontSize="150%";for(var i=t.split("\n"),o=0,a=i.length;o=0;--e)this.remove(t[e]);var r=this.geometry.items,i=this.geometry.userData,o=r.length;for(e=0;e0?n:[new Xe];for(var o=this._createMeshes(t),a=0,s=o.length;a>16&255,r=t>>8&255,n=255&t;return.2126*e+.7152*r+.0722*n>127?(e=3*e/10,r=3*r/10,n=3*n/10):(e=255-3*(255-e)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),e<<16|r<<8|n},inverse:function(t){return 255-(t>>16&255)<<16|255-(t>>8&255)<<8|255-(255&t)}};function cm(t,e){var r;if(lm.hasOwnProperty(e))r=Cu.hexColor(lm[e](t));else{var n=parseInt(e,16);r=!Number.isNaN(n)&&e.toLowerCase().startsWith("0x")?Cu.hexColor(n):"#000000"}return r}var um={serial:function(t){return t.getSerial()},name:function(t){return t.getVisualName()},elem:function(t){return t.element.name},residue:function(t){return t._residue.getType().getName()},sequence:function(t){return t._residue.getSequence()},chain:function(t){return t._residue.getChain().getName()},hetatm:function(t){return t.isHet()},water:function(t){return"HOH"===t._residue.getType().getName()||"WAT"===t._residue.getType().getName()}},hm=function(t,e){return e.replace(/\{\{(\s*\w+\s*)\}\}/g,function(e){var r=e.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),um.hasOwnProperty(r)?um[r](t):"null"})};function pm(t,e,r,n,i,o,a){this._geoArgs=this._makeGeoArgs(e,n,r,o),nm.call(this,t,e,r,n,i,o,a)}function fm(t,e,r,n){var i=Math.sin(t);return e.clone().multiplyScalar(Math.sin((1-n)*t)/i).addScaledVector(r,Math.sin(n*t)/i)}function dm(t,e,r,n,i,o,a){nm.call(this,t,e,r,n,i,o,a)}pm.prototype=Object.create(nm.prototype),pm.prototype.constructor=pm,pm.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},pm.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;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},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}); +(function(){var t,e,n,i,o,a,s,l,c,u,h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C=Object.prototype.hasOwnProperty,T=function(t,e){for(var r in e)C.call(e,r)&&(t[r]=e[r]);function n(){this.constructor=t}return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};p={method:(n={METHOD_NEAREST:"nearest",METHOD_LINEAR:"linear",METHOD_CUBIC:"cubic",METHOD_LANCZOS:"lanczos",METHOD_SINC:"sinc",CLIP_CLAMP:"clamp",CLIP_ZERO:"zero",CLIP_PERIODIC:"periodic",CLIP_MIRROR:"mirror",CUBIC_TENSION_DEFAULT:0,CUBIC_TENSION_CATMULL_ROM:0}).METHOD_CUBIC,cubicTension:n.CUBIC_TENSION_DEFAULT,clip:n.CLIP_CLAMP,scaleTo:0,sincFilterSize:2,sincWindow:void 0},c=function(t,e){return Math.max(0,Math.min(t,e-1))},h=function(t,e){return(t%=e)<0&&(t+=e),t},u=function(t,e){var r;return(t=h(t,r=2*(e-1)))>e-1&&(t=r-t),t},t=function(){function t(t,e){if(this.array=t.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[e.clip]))throw"Invalid clip: "+e.clip}return t.prototype.getClippedInput=function(t){return 0<=t&&t=o;i<=o?r++:r--)n+=this.kernel(t-r)*this.getClippedInput(r);return n},r}(),f=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?c++:c--)e.push(new h(f(t,c),r));return e}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;ri&&t[e-1]._isValid?e-1:e}function s(e){return e1&&0!==E&&(c.lerpVectors(y,_,.15/w),u.lerpVectors(y,_,1-.15/w)),E*=.15,c.addScaledVector(S,E),u.addScaledVector(S,E),o.setItem(h,c,u),o.setColor(h++,i.getAtomColor(g,r),i.getAtomColor(v,r))}}o.finalize(),this._chunksIdc=p},Om.prototype.updateToFrame=function(t){for(var e=this._selection.chunks,r=this._selection.bonds,n=this._mode,i=this._colorer,o=this._geo,a=n.drawMultiorderBonds(),s=n.showAromaticLoops(),l=new He,c=new He,u=new He,h=0,p=t.needsColorUpdate(i),f=0,d=e.length;f1&&0!==E&&(c.lerpVectors(y,_,.15/w),u.lerpVectors(y,_,1-.15/w)),E*=.15,c.addScaledVector(S,E),u.addScaledVector(S,E),o.setItem(h,c,u),p&&o.setColor(h,t.getAtomColor(i,g),t.getAtomColor(i,v)),h++}}o.finalize()};var Dm=im,Fm=om,zm=am,km=pm,Um=gm,Bm=vm,Vm=xm,jm=bm,Gm=Lm,Wm=Rm,Hm=Im,Xm=Om;function Ym(t,e,r,n,i,o,a,s){var l=this;ef.call(l),this._complex=r;var c=r.getAtoms(),u=r.getTransforms();r.forEachComponent(function(h){var p=[],f=0;if(h.forEachAtom(function(t){l._checkAtom(t,a)&&(p[f++]=t._index)}),0!==f){var d=new t(e,{atoms:c,chunks:p,parent:r},n,i,u,o,s);d._component=h,l.add(d)}})}function qm(t,e,r,n,i,o,a,s){this._mode=i,Ym.call(this,t,e,r,n,i,o,a,s)}function Zm(t,e,r,n,i,o,a,s){var l=this;ef.call(l),this._complex=r;var c=r.getResidues(),u=r.getTransforms();r.forEachComponent(function(h){var p=0,f=[];if(h.forEachResidue(function(t){l._checkResidue(t,a)&&(f[p++]=t._index)}),0!==p){var d=new t(e,{residues:c,chunks:f,parent:r},n,i,u,o,s);d._component=h,l.add(d)}})}function $m(t,e,r,n,i,o,a,s){Zm.call(this,t,e,r,n,i,o,a,s)}function Km(t,e,r,n,i,o,a,s){var l=this;ef.call(l),this._complex=r;var c=r.getResidues(),u=r.getTransforms();r.forEachComponent(function(h){for(var p=h.getMaskedSubdivSequences(a),f=0,d=[],m=0,g=p.length;m0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:c,chunks:p,parent:r},n,i,u,o,s);g._component=h,l.add(g)})}function tg(t,e,r){var n=document.createElement("div");if(n.className="label label-sgroup",n.style.color=e,"string"==typeof r){var i=document.createElement("span");i.style.fontSize="150%";var o=document.createElement("span"),a=document.createTextNode(r);o.appendChild(a),i.appendChild(o),n.appendChild(i)}else n.appendChild(r);var s=new tf(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var l=s.getElement();return l.style.visibility="visible",l.style.textAlign="center",l.style.verticalAlign="middle",s}function eg(t,e,r,n,i,o,a,s){ef.call(this);for(var l=new ef,c=0;c0&&l.add(p)}return l},pg.prototype=Object.create(hg.prototype),pg.prototype.constructor=pg,pg.prototype.update=function(){var t=this._staticGroups;"no"===this.settings.now.labels?this.depGroups=this.depGroups.slice(0,t):(this.depGroups[t]="TextLabelsGeo",this.depGroups[t+1]="SGroupsLabels")},pg.prototype.buildGeometry=function(t,e,r,n){return this.update(),hg.prototype.buildGeometry.call(this,t,e,r,n)},Cu.deriveClass(dg,pg,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),dg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},dg.prototype.calcAtomRadius=function(){return this.opts.atom},dg.prototype.getAromaticOffset=function(){return this.opts.offsarom},dg.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},dg.prototype.showAromaticLoops=function(){return this.opts.showarom},dg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Cu.deriveClass(mg,pg,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),mg.prototype.calcAtomRadius=function(t){return this.opts.bond},mg.prototype.calcStickRadius=function(){return this.opts.bond},mg.prototype.calcSpaceFraction=function(){return this.opts.space},mg.prototype.getAromRadius=function(){return this.opts.aromrad},mg.prototype.showAromaticLoops=function(){return this.opts.showarom},mg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},mg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Cu.deriveClass(gg,pg,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),gg.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},gg.prototype.calcStickRadius=function(){return this.opts.bond},gg.prototype.getAromRadius=function(){return this.opts.aromrad},gg.prototype.showAromaticLoops=function(){return this.opts.showarom},gg.prototype.calcSpaceFraction=function(){return this.opts.space},gg.prototype.drawMultiorderBonds=function(){return this.opts.multibond},gg.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Cu.deriveClass(vg,hg,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),vg.prototype.calcAtomRadius=function(t){return t.element.radius},Cu.deriveClass(yg,hg,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),yg.prototype.calcStickRadius=function(){return this.opts.radius},Cu.deriveClass(_g,hg,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),_g.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},_g.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},_g.prototype.getTension=function(){return this.opts.tension},_g.prototype.buildGeometry=function(t,e,r,n){var i=this.opts.radius;return this.TUBE_RADIUS=new _e(i,i),hg.prototype.buildGeometry.call(this,t,e,r,n)},Cu.deriveClass(xg,hg,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),xg.prototype.getResidueStartRadius=function(t){var e=t.getSecondary();if(!e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?r.start:r.center:this.TUBE_RADIUS},xg.prototype.getResidueEndRadius=function(t){var e=t.getSecondary();if(null===e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?this.ARROW_END:r.center:this.TUBE_RADIUS},xg.prototype.getResidueRadius=function(t,e){var r=this.getResidueStartRadius(t);if(0===e)return r;var n=this.getResidueEndRadius(t);return 2===e?n:r.clone().lerp(n,e/2)},xg.prototype.calcStickRadius=function(t){return this.opts.radius},xg.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},xg.prototype.getTension=function(){return this.opts.tension},xg.prototype.buildGeometry=function(t,e,r,n){var i=this.opts.radius,o=this.opts.depth;this.TUBE_RADIUS=new _e(i,i),this.ARROW_END=new _e(o,i);var a={},s=this.opts.ss;for(var l in s)a[l]={center:new _e(o,s[l].width),start:new _e(o,s[l].arrow)};return this.secCache=a,hg.prototype.buildGeometry.call(this,t,e,r,n)};var bg=Jp.selectors;function wg(){return{wireframe:this.opts.wireframe,zClip:this.opts.zClip}}function Sg(t){hg.call(this,t),this.depGroups=this.depGroups.slice(0);for(var e=this.surfaceNames,r=this.depGroups,n=0,i=e.length;n=256?e-256:e))%this.chainColors.length,this.chainColors[e]},getSecondaryColor:function(t,e){var r=this.secondaryColors[t];return r instanceof Object&&(r=r[e]),void 0===r?this.defaultSecondaryColor:r},getSequentialColor:function(t){var e=this.colors,r=e.length;return t<0?e[t%r+r]:e[t%r]},getGradientColor:function(t,e){var r,n,i,o,a=this.gradients[e];if(a){var s=a.length,l=t*(s-1),c=Math.floor(l),u=Ig(c+1,0,s-1);return c=Ig(c,0,s-1),r=a[c],n=a[u],(o=1-(i=l-c))*(r>>16&255)+i*(n>>16&255)<<16|o*(r>>8&255)+i*(n>>8&255)<<8|o*(255&r)+i*(255&n)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}};for(var Dg=Og.prototype.namedColorsArray,Fg=Og.prototype.namedColors,zg=0,kg=Dg.length;zg=0?this.opts.carbon:this.palette.getElementColor(r)},$g.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},Cu.deriveClass(Kg,Zg,{id:"RT",name:"Residue Type",shortName:"Residue"}),Kg.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Kg.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},Cu.deriveClass(Qg,Zg,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Qg.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Qg.prototype.getResidueColor=function(t,e){var r=t._chain;if(r.minSequence===Number.POSITIVE_INFINITY&&r.maxSequence===Number.NEGATIVE_INFINITY)return this.palette.defaultNamedColor;var n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},Cu.deriveClass(Jg,Zg,{id:"CH",name:"Chain",shortName:"Chain"}),Jg.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Jg.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},Cu.deriveClass(tv,Zg,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),tv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},tv.prototype.getResidueColor=function(t,e){if(t._type.flags&_h.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&_h.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},Cu.deriveClass(ev,Zg,{id:"UN",name:"Uniform",shortName:"Uniform"}),ev.prototype.getAtomColor=function(t,e){return this.opts.color},ev.prototype.getResidueColor=function(t,e){return this.opts.color},Cu.deriveClass(rv,Zg,{id:"CO",name:"Conditional",shortName:"Conditional"}),rv.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},rv.prototype.getResidueColor=function(t,e){for(var r=this._subsetCached,n=!0,i=t._atoms,o=0,a=i.length;or.max?1:0:(t._temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultElementColor},iv.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._temperature&&t._role===Jp.Element.Constants.Lead&&(n=t._temperature)}),n>0){var i=0;return i=r.min===r.max?n>r.max?1:0:(n-r.min)/(r.max-r.min),this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Cu.deriveClass(ov,Zg,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),ov.prototype.getAtomColor=function(t,e){var r=this.opts;if(t._occupancy&&r){var n=1-t._occupancy;return this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultElementColor},ov.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._occupancy&&t._role===Jp.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Cu.deriveClass(av,Zg,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),av.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},av.prototype.getResidueColor=function(t,e){var r=this.palette.defaultResidueColor;if(t._type.hydrophobicity){r=this.palette.getGradientColor((t._type.hydrophobicity- -4.5)/9,this.opts.gradient)}return r},Cu.deriveClass(sv,Zg,{id:"MO",name:"Molecule",shortName:"Molecule"}),sv.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},sv.prototype.getResidueColor=function(t,e){var r=t._molecule,n=e.getMoleculeCount();return n>1?this.palette.getGradientColor((r._index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)};var lv=[],cv={};!function(t){for(var e=0,r=t.length;e0){(e=new ea).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return hu.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<0?this._reprList[0]:null,this._selectionBit=t.length,this._reprUsedBits|=1<=0&&tthis._reprList.length)return hu.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,hu.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],i={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var o=!1;if(e.selector){var a=wv.parse(e.selector).selector,s=String(a);i.selector!==s&&(r.selectorString=i.selector=s,r.selector=a,r.markAtoms(this._complex),o=!0,hu.debug("rep["+t+"].selector changed to"+s))}if(e.mode){var l=e.mode;n.isEqual(i.mode,l)||(i.mode=l,r.setMode(Ng.create(e.mode)),o=!0,hu.debug("rep["+t+"].mode changed to "+l),!r.mode.isSurface||"ultra"!==Vu.now.resolution&&"high"!==Vu.now.resolution||(hu.report('Surface resolution was changed to "medium" to avoid hang-ups.'),Vu.now.resolution="medium"))}if(e.colorer){var c=e.colorer;n.isEqual(i.colorer,c)||(i.colorer=c,r.colorer=uv.create(e.colorer),o=!0,hu.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var u=e.material;n.isEqual(i.material,u)||(i.material=u,r.setMaterialPreset(gv.get(e.material)),o=!0,hu.debug("rep["+t+"].material changed to"+u))}o&&(r.needsRebuild=!0)}return i},Sv.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},Sv.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<=Sv.NUM_REPRESENTATION_BITS;++e,t>>=1)if(0==(1&t))return e;return-1},Sv.prototype.repAdd=function(t){if(this._reprList.length>=Sv.NUM_REPRESENTATION_BITS)return-1;var e=this._getFreeReprIdx();if(e<0)return-1;var r=this.buildSelectorFromMask(1<=e||e<=1)){var r=this._reprList[t];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length)||this._reprList[t].show(!e)},Sv.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=wv.chain(r),o=o?wv.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=wv.and(wv.chain(s),wv.residx(i(e[s]))),o=o?wv.or(o,a):a);t.length>0&&(a=wv.serial(i(t)),o=o?wv.or(o,a):a),o||(o=wv.none())}return o},Sv.prototype.buildSelectorFromMask=function(t){var e=this._complex,r=[],n={},i=[];return e.forEachChain(function(e){e._mask&t&&r.push(e._name)}),e.forEachResidue(function(e){if(e._mask&t&&!(e._chain._mask&t)){var r=e._chain._name;r in n?n[r].push(e._index):n[r]=[e._index]}}),e.forEachAtom(function(e){e._mask&t&&!(e._residue._mask&t)&&i.push(e._serial)}),this._buildSelectorFromSortedLists(i,n,r)},Sv.prototype.getSelectedComponent=function(){var t=1<=0):n<8+y.indices.length&&(this.cullFlag[n]=!0);var w=this.geometry.getAttribute("position"),S=0;for(n=0;n=3&&(u+=3*(r.indices.length-2));var h=0,p=new Uint16Array(u);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),l>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)})})},Fv.prototype.mean=function(){return this._prof?this._prof.rawMean():0},Fv.prototype.min=function(){return this._prof?this._prof.min():0};var zv=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Nu(this,t),this._list=[],this._byType={},r.forEach(function(t){return e.register(t)})}return Iu(t,[{key:"register",value:function(t){Su(this._list,t),Au(this._byType,t.types,t)}},{key:"unregister",value:function(t){Mu(this._list,t),Eu(this._byType,t.types,t)}},{key:"find",value:function(t){var e=[];if(t.type)e=this._byType[t.type.toLowerCase()]||[];else if(t.source)return this._list.filter(function(e){return e.canProbablyLoad&&e.canProbablyLoad(t.source)});return[].concat(zu(e))}},{key:"all",get:function(){return[].concat(zu(this._list))}},{key:"types",get:function(){return Object.keys(this._byType)}}]),t}(),kv=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n._source=t,n._options=r||{},n._abort=!1,n._agent=null,n}return Ou(e,su),Iu(e,[{key:"load",value:function(t){return t?this._loadOLD(t):this._abort?Promise.reject(new Error("Loading aborted")):this.loadAsync()}},{key:"loadAsync",value:function(){return Promise.reject(new Error("Loading from this source is not implemented"))}},{key:"_loadOLD",value:function(t){return t.progress&&this.addEventListener("progress",function(e){e.lengthComputable&&e.total>0?t.progress(e.loaded/e.total):t.progress()}),this.load().then(function(e){t.ready(e)}).catch(function(e){t.error(e)})}},{key:"abort",value:function(){this._abort=!0,this._agent&&this._agent.abort()}}],[{key:"extractName",value:function(t){}}]),e}();yf(kv.prototype);var Uv=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Ou(e,kv),Iu(e,[{key:"loadAsync",value:function(){var t=this;return new Promise(function(e,r){var n=t._source,i=t._agent=new FileReader;i.addEventListener("load",function(){e(i.result)}),i.addEventListener("error",function(){r(i.error)}),i.addEventListener("abort",function(){r(new Error("Loading aborted"))}),i.addEventListener("progress",function(e){t.dispatchEvent(e)}),t._binary?i.readAsArrayBuffer(n):i.readAsText(n)})}}],[{key:"canLoad",value:function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)}},{key:"canProbablyLoad",value:function(t){return File&&t instanceof File||Blob&&t instanceof Blob}},{key:"extractName",value:function(t){return t&&t.name}}]),e}();Uv.types=["file","blob"];var Bv=/^(https?|ftp):\/\//i,Vv=function(t){function e(t,r){Nu(this,e);var n=Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r));return r=n._options,n._binary=!0===r.binary,n}return Ou(e,kv),Iu(e,[{key:"loadAsync",value:function(){var t=this;return new Promise(function(e,r){var n=t._source,i=t._agent=new XMLHttpRequest;i.addEventListener("load",function(){200===i.status?e(i.response):r(new Error("HTTP "+i.status+" while fetching "+n))}),i.addEventListener("error",function(){r(new Error("HTTP request failed"))}),i.addEventListener("abort",function(){r(new Error("Loading aborted"))}),i.addEventListener("progress",function(e){t.dispatchEvent(e)}),i.open("GET",n),t._binary?i.responseType="arraybuffer":i.responseType="text",i.send()})}}],[{key:"canLoad",value:function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)}},{key:"canProbablyLoad",value:function(t){return n.isString(t)&&Bv.test(t)}},{key:"extractName",value:function(t){if(t){var e=(t.indexOf("?")+1||t.lastIndexOf("#")+1||t.length+1)-1;return t.slice(t.lastIndexOf("/",e)+1,e)}}}]),e}();Vv.types=["url"];var jv=function(t){function e(t,r){return Nu(this,e),Du(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r))}return Ou(e,kv),Iu(e,[{key:"loadAsync",value:function(){return Promise.resolve(this._source)}}],[{key:"canLoad",value:function(t,e){return void 0!==t&&void 0!==e&&"immediate"===e.sourceType}},{key:"canProbablyLoad",value:function(t){return!1}}]),e}();jv.types=["immediate"];var Gv=new zv([Uv,Vv,jv]),Wv=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Nu(this,t),this._list=[],this._byFormat={},this._byExt={},r.forEach(function(t){return e.register(t)})}return Iu(t,[{key:"register",value:function(t){Su(this._list,t),Au(this._byFormat,t.formats,t),Au(this._byExt,t.extensions,t)}},{key:"unregister",value:function(t){Mu(this._list,t),Eu(this._byFormat,t.formats,t),Eu(this._byExt,t.extensions,t)}},{key:"find",value:function(t){var e=[];return t.format?e=this._byFormat[t.format.toLowerCase()]||[]:t.ext&&(e=this._byExt[t.ext.toLowerCase()]||[]),0===e.length&&!t.format&&t.data?this._list.filter(function(e){return e.canProbablyParse&&e.canProbablyParse(t.data)}):[].concat(zu(e))}},{key:"all",get:function(){return[].concat(zu(this._list))}},{key:"formats",get:function(){return Object.keys(this._byFormat)}},{key:"extensions",get:function(){return Object.keys(this._byExt)}}]),t}(),Hv=function(){function t(e,r){Nu(this,t),this._data=e,this._options=r||{},this._abort=!1}return Iu(t,[{key:"parseSync",value:function(){throw new Error("Parsing this type of data is not implemented")}},{key:"parse",value:function(t){var e=this;return t?this._parseOLD(t):new Promise(function(t,r){setTimeout(function(){try{return e._abort?r(new Error("Parsing aborted")):t(e.parseSync())}catch(t){return r(t)}})})}},{key:"_parseOLD",value:function(t){return this.parse().then(function(e){t.ready(e)}).catch(function(e){t.error(e)})}},{key:"abort",value:function(){this._abort=!0}}],[{key:"checkDataTypeOptions",value:function(t,e,r){var n=t.fileType,i=t.fileName;return r=(r||"."+e).toLowerCase(),Boolean(n&&n.toLowerCase()===e.toLowerCase()||!n&&i&&i.toLowerCase().endsWith(r))}}]),t}();function Xv(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}yf(Hv.prototype),Xv.prototype.id=290,Xv.prototype.parse=function(t){var e=this._matrix;if(" SMTRY"===t.readString(12,18)){var r=t.readCharCode(19)-49,n=t.readString(20,80).trim().split(/\s+/),i=parseInt(n[0],10);null!==this._matrix&&i===this._matrixIndex||(this._matrixIndex=i,this._matrix=e=new Xe,this.matrices[this.matrices.length]=e);var o=e.elements;o[r]=parseFloat(n[1]),o[r+4]=parseFloat(n[2]),o[r+8]=parseFloat(n[3]),o[r+12]=parseFloat(n[4])}};var Yv=Jp.Assembly;function qv(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}qv.prototype.id=350,qv.prototype.parse=function(t){var e=this._assembly,r=this._matrix;if(e&&" BIOMT"===t.readString(12,18)){var n=t.readCharCode(19)-49,i=t.readString(20,80).trim().split(/\s+/),o=parseInt(i[0],10);null!==this._matrix&&o===this._matrixIndex||(this._matrixIndex=o,this._matrix=r=new Xe,e.addMatrix(r));var a=r.elements;a[n]=parseFloat(i[1]),a[n+4]=parseFloat(i[2]),a[n+8]=parseFloat(i[3]),a[n+12]=parseFloat(i[4])}else if(e&&"CHAINS:"===t.readString(35,41))for(var s=t.readString(42,80).split(","),l=0,c=s.length;l0&&e.addChain(u)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new Yv(this._complex),this.assemblies.push(e))};var Zv=function(){function t(e){Nu(this,t),this._data=e,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=e.length,this.next()}return Iu(t,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(t){return(t=this._start+t-1)=this._end}},{key:"next",value:function(){var t=this._next+1;this._start=tthis._nextCR&&(this._nextCR=(this._data.indexOf("\r",this._start)+1||this._end+1)-1),this._start>this._nextLF&&(this._nextLF=(this._data.indexOf("\n",this._start)+1||this._end+1)-1),this._next=this._nextCR+1e&&a.addBond(e,r,0,ey.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,ey.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,ey.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,ey.BondType.UNKNOWN,!0)},ny.prototype._parseCOMPND=function(t){var e=t.readString(11,80),r=e.indexOf(":");if(this._compndCurrToken=r>0?e.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(e.substring(r+1,e.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=e.substring(r+1,e.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=e.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}};var oy={290:Xv,350:qv};ny.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(n.isUndefined(r)){var i=oy[e];n.isFunction(i)&&(this._remarks[e]=r=new i(this._complex))}n.isUndefined(r)||r.parse(t)},ny.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},ny.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},ny.prototype._parseSTRUCTURE=function(t,e,r){var n=t.readInt(8,10),i=t.readString(12,14).trim(),o=t.readString(41,70).trim(),a=t.readInt(72,76),s=t.readInt(39,40),l=t.readInt(15,16),c=t.readInt(42,45),u=t.readInt(57,60),h=t.readString(e[0],e[2]+1).charCodeAt(0),p=t.readString(e[2],e[2]+1).charCodeAt(0),f=t.readInt(e[1],e[1]+3),d=t.readString(e[1]+4,e[1]+4),m=0;d.length>0&&(m=d.charCodeAt(0));var g,v=t.readInt(e[3],e[3]+3),y=0;(d=t.readString(e[3]+4,e[3]+4)).length>0&&(y=d.charCodeAt(0));var _=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=g=new Jv(i,l),r(g)):g=_;var x=new ty(g,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,v,y),s,c,u);g.addStrand(x)}else r(g=new Qv(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,v,y),s,o,a))},ny.prototype._parseHEADER=function(t){var e=this._complex.metadata;e.classification=t.readString(11,50).trim(),e.date=t.readString(51,59).trim();var r=t.readString(63,66).trim();e.id=r,r&&(this._complex.name=r)},ny.prototype._parseTITLE=function(t){var e=this._complex.metadata;e.title=e.title||[];var r=t.readInt(9,10)||1;e.title[r-1]=t.readString(11,80).trim()};var ay={HEADER:ny.prototype._parseHEADER,"TITLE ":ny.prototype._parseTITLE,"ATOM ":ny.prototype._parseATOM,HETATM:ny.prototype._parseATOM,ENDMDL:ny.prototype._parseENDMDL,CONECT:ny.prototype._parseCONECT,COMPND:ny.prototype._parseCOMPND,REMARK:ny.prototype._parseREMARK,"HELIX ":ny.prototype._parseHELIX,"SHEET ":ny.prototype._parseSHEET,"ATOM 1":ny.prototype._parseATOM,"ATOM 2":ny.prototype._parseATOM,"ATOM 3":ny.prototype._parseATOM,"ATOM 4":ny.prototype._parseATOM,"ATOM 5":ny.prototype._parseATOM,"ATOM 6":ny.prototype._parseATOM,"ATOM 7":ny.prototype._parseATOM,"ATOM 8":ny.prototype._parseATOM,"ATOM 9":ny.prototype._parseATOM};ny.prototype.parseSync=function(){for(var t=new Zv(this._data),e=this._complex=new $v;!t.end();){var r=t.readString(1,6),i=ay[r];n.isFunction(i)&&i.call(this,t),t.next()}if(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0===e.getAtomCount())throw new Error("The data does not contain valid atoms");return e},ny.formats=["pdb"],ny.extensions=[".pdb",".ent"];var sy=Jp.Complex,ly=Jp.Element,cy=Jp.AtomName,uy=Jp.SGroup,hy=Jp.Bond,py={A:0,S:1,D:2,T:3};function fy(t,e){Hv.call(this,t,e),this._complex=null,this._sheet=null,this._residue=null,this._serialAtomMap=null,this._modelId=1,this._lastMolId=-1,this._readOnlyOneMolecule=!1,this._options.fileType="cml"}fy.prototype=Object.create(Hv.prototype),fy.prototype.constructor=fy,fy.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\]*\?>\s*<(?:cml|molecule)\b/i;fy.canProbablyParse=function(t){return n.isString(t)&&dy.test(t)},fy.prototype._rebuidBondIndexes=function(t,e){for(var r=t.length,n=0;n1&&a.splice(1,a.length-1),a.forEach(function(t){var e=function(t){var e,n=[];if(t.molecule&&t.molecule.atomArray&&t.molecule.atomArray.atom)Array.isArray(t.molecule.atomArray.atom)?n=t.molecule.atomArray.atom:n.push(t.molecule.atomArray.atom);else if(!t.molecule){var o={atomLabels:null,labelsCount:1};return o}t.molecule.molecule&&i._extractSGroups(t.molecule.molecule,n);for(var a=n.length,s=0;s1)c[u].order=p;else{var f=py[h];void 0!==f&&(c[u].order=f,"A"===h&&(c[u].type=hy.BondType.AROMATIC))}}a=n.length;for(var d=0;d0&&o.push(e)}),o},fy.prototype._packLabel=function(t,e){return(e<<16)+t},fy.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},fy.prototype._breadWidthSearch=function(t,e){var r,n=new Array(t.length);for(r=0;r0;){o++;var s=-1;for(r=0;r0;){var l=i.shift();if(l)for(var c=0;c=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},fy.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new sy;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new sy},fy.formats=["cml"],fy.extensions=[".cml"];var my=r(function(t,e){(function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t){var n=new ArrayBuffer(function t(e){var n=typeof e;if("string"===n){if(32>(i=r(e)))return 1+i;if(256>i)return 2+i;if(65536>i)return 3+i;if(4294967296>i)return 5+i}if(e instanceof Uint8Array){if(256>(i=e.byteLength))return 2+i;if(65536>i)return 3+i;if(4294967296>i)return 5+i}if("number"===n){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===n||null===e)return 1;if("object"===n){var i,o=0;if(Array.isArray(e)){i=e.length;for(var a=0;i>a;a++)o+=t(e[a])}else{var s=Object.keys(e);for(i=s.length,a=0;i>a;a++){var l=s[a];o+=t(l)+t(e[l])}}if(16>i)return 1+o;if(65536>i)return 3+o;if(4294967296>i)return 5+o;throw new Error("Array or object too long 0x"+i.toString(16))}throw new Error("Unknown type "+n)}(t));return function t(n,i,o){var a=typeof n;if("string"===a){if(32>(s=r(n)))return i.setUint8(o,160|s),e(i,o+1,n),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,n),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,n),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,n),5+s}if(n instanceof Uint8Array){var s=n.byteLength,l=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),l.set(n,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),l.set(n,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),l.set(n,o+5),5+s}if("number"===a){if(!isFinite(n))throw new Error("Number not finite: "+n);if(Math.floor(n)!==n)return i.setUint8(o,203),i.setFloat64(o+1,n),9;if(n>=0){if(128>n)return i.setUint8(o,n),1;if(256>n)return i.setUint8(o,204),i.setUint8(o+1,n),2;if(65536>n)return i.setUint8(o,205),i.setUint16(o+1,n),3;if(4294967296>n)return i.setUint8(o,206),i.setUint32(o+1,n),5;throw new Error("Number too big 0x"+n.toString(16))}if(n>=-32)return i.setInt8(o,n),1;if(n>=-128)return i.setUint8(o,208),i.setInt8(o+1,n),2;if(n>=-32768)return i.setUint8(o,209),i.setInt16(o+1,n),3;if(n>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,n),5;throw new Error("Number too small -0x"+(-n).toString(16).substr(1))}if(null===n)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,n?195:194),1;if("object"===a){var c=0,u=Array.isArray(n);if(u)s=n.length;else{var h=Object.keys(n);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),c=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),c=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),c=5),u)for(var p=0;s>p;p++)c+=t(n[p],i,o+c);else for(p=0;s>p;p++){var f=h[p];c+=t(f,i,o+c),c+=t(n[f],i,o+c)}return c}throw new Error("Unknown type "+a)}(t,new DataView(n),0),new Uint8Array(n)}function i(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function o(t){return i(DataView,t)}function a(t){return i(Uint8Array,t)}function s(t){return i(Int8Array,t)}function l(t){return i(Int32Array,t,4)}function c(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)e[n]=t[i]<<8^t[i+1]<<0;return e}function u(t,e){var r=t.length/4;e||(e=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)e[n]=t[i]<<24^t[i+1]<<16^t[i+2]<<8^t[i+3]<<0;return e}function h(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=o(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return a(e)}function p(t,e,r){var n=t.length,i=1/e;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=t[o]*i;return r}function f(t,e,r){var n=t.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(t[i]*e);return r}function d(t,e){var r,n;if(!e){var i=0;for(r=0,n=t.length;n>r;r+=2)i+=t[r+1];e=new t.constructor(i)}var o=0;for(r=0,n=t.length;n>r;r+=2)for(var a=t[r],s=t[r+1],l=0;s>l;++l)e[o]=a,++o;return e}function m(t){if(0===t.length)return new Int32Array;var e,r,n=2;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]?(i[o]=t[e-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=t[t.length-1],i[o+1]=a,i}function g(t,e){var r=t.length;e||(e=new t.constructor(r)),r&&(e[0]=t[0]);for(var n=1;r>n;++n)e[n]=t[n]+e[n-1];return e}function v(t,e){var r=t.length;e||(e=new t.constructor(r)),e[0]=t[0];for(var n=1;r>n;++n)e[n]=t[n]-t[n-1];return e}function y(t,e){var r,n,i=t instanceof Int8Array?127:32767,o=-i-1,a=t.length;if(!e){var s=0;for(r=0;a>r;++r)t[r]o&&++s;e=new Int32Array(s)}for(r=0,n=0;a>r;){for(var l=0;t[r]===i||t[r]===o;)l+=t[r],++r;l+=t[r],++r,e[n]=l,++n}return e}function _(t,e,r){return p(y(t,l(r)),e,r)}function x(t,e,r){var n,o,a,s=y(t,l(r));return n=s,o=e,a=i(Float32Array,s,4),p(g(n,l(a)),o,a)}function b(t,e,r){return function(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r)0===(c=t[r])?++a:a+=c===n||c===i?2:c>0?Math.ceil(c/n):Math.ceil(c/i);var s=e?new Int8Array(a):new Int16Array(a),l=0;for(r=0;o>r;++r){var c;if((c=t[r])>=0)for(;c>=n;)s[l]=n,++l,c-=n;else for(;i>=c;)s[l]=i,++l,c-=i;s[l]=c,++l}return s}(v(f(t,e),n),r);var n}function w(t,e,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,t),a.setInt32(4,e),r&&o.set(r,8),o.set(n,12),o}function S(t){return w(2,t.length,void 0,a(t))}function M(t){return w(4,t.length,void 0,h(t))}function A(t,e){return w(5,t.length/e,h([e]),a(t))}function E(t){return w(6,t.length,void 0,h(m(t)))}function C(t){return w(8,t.length,void 0,h(m(v(t))))}function T(t,e){return w(9,t.length,h([e]),h(m(f(t,e))))}function P(t,e){return w(10,t.length,h([e]),function(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=o(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return a(e)}(b(t,e)))}function L(t){var e={};return z.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=M(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=S(t.bondOrderList)),e.xCoordList=P(t.xCoordList,1e3),e.yCoordList=P(t.yCoordList,1e3),e.zCoordList=P(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=P(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=C(t.atomIdList)),t.altLocList&&(e.altLocList=E(t.altLocList)),t.occupancyList&&(e.occupancyList=T(t.occupancyList,100)),e.groupIdList=C(t.groupIdList),e.groupTypeList=M(t.groupTypeList),t.secStructList&&(e.secStructList=S(t.secStructList)),t.insCodeList&&(e.insCodeList=E(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=C(t.sequenceIndexList)),e.chainIdList=A(t.chainIdList,4),t.chainNameList&&(e.chainNameList=A(t.chainNameList,4)),e}function R(t){function e(t){for(var e={},r=0;t>r;r++){e[o()]=o()}return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;if(e>65535){for(var n=[],i=0;ir;r++)e[r]=o();return e}function o(){var o,l,c=t[a];if(0==(128&c))return a++,c;if(128==(240&c))return l=15&c,a++,e(l);if(144==(240&c))return l=15&c,a++,i(l);if(160==(224&c))return l=31&c,a++,n(l);if(224==(224&c))return o=s.getInt8(a),a++,o;switch(c){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return l=s.getUint8(a+1),a+=2,r(l);case 197:return l=s.getUint16(a+1),a+=3,r(l);case 198:return l=s.getUint32(a+1),a+=5,r(l);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return l=s.getUint8(a+1),a+=2,n(l);case 218:return l=s.getUint16(a+1),a+=3,n(l);case 219:return l=s.getUint32(a+1),a+=5,n(l);case 220:return l=s.getUint16(a+1),a+=3,i(l);case 221:return l=s.getUint32(a+1),a+=5,i(l);case 222:return l=s.getUint16(a+1),a+=3,e(l);case 223:return l=s.getUint32(a+1),a+=5,e(l)}throw new Error("Unknown type 0x"+c.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function N(t,e,r,n){switch(t){case 1:return function(t,e){var r=t.length;e||(e=new Float32Array(r/4));for(var n=o(e),i=o(t),a=0,s=0,l=r/4;l>a;++a,s+=4)n.setFloat32(s,i.getFloat32(s),!0);return e}(e);case 2:return s(e);case 3:return c(e);case 4:return u(e);case 5:return a(e);case 6:return d(u(e),new Uint8Array(r));case 7:return d(u(e));case 8:return g(d(u(e)),m);case 9:return i=u(e),h=u(n)[0],p(d(i,l(f)),h,f);case 10:return x(c(e),u(n)[0]);case 11:return p(c(e),u(n)[0]);case 12:return _(c(e),u(n)[0]);case 13:return _(s(e),u(n)[0]);case 14:return y(c(e));case 15:return y(s(e))}var i,h,f,m}function I(t,e){var r=(e=e||{}).ignoreFields,n={};return k.forEach(function(e){var i,a,s,l,c,u=!!r&&-1!==r.indexOf(e),h=t[e];u||void 0===h||(h instanceof Uint8Array?n[e]=N.apply(null,(a=o(i=h),s=a.getInt32(0),l=a.getInt32(4),c=i.subarray(8,12),[s,i=i.subarray(12),l,c])):n[e]=h)}),n}function O(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function D(t,e){return t instanceof ArrayBuffer&&(t=new Uint8Array(t)),I(t instanceof Uint8Array?R(t):t,e)}function F(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=D(i.response);r(t)}catch(t){n(t)}},!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",e+t.toUpperCase()),i.send()}var z=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],k=z.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),U="//mmtf.rcsb.org/v1.0/",B=U+"full/",V=U+"reduced/";t.encode=function(t){return n(L(t))},t.decode=D,t.traverse=function(t,e,r){var n,i,o,a,s,l,c=(r=r||{}).firstModelOnly,u=e.onModel,h=e.onChain,p=e.onGroup,f=e.onAtom,d=e.onBond,m=0,g=0,v=0,y=0,_=0,x=-1,b=t.chainNameList,w=t.secStructList,S=t.insCodeList,M=t.sequenceIndexList,A=t.atomIdList,E=t.bFactorList,C=t.altLocList,T=t.occupancyList,P=t.bondAtomList,L=t.bondOrderList;for(n=0,i=t.chainsPerModel.length;i>n&&!(c&&m>0);++n){var R=t.chainsPerModel[m];for(u&&u({chainCount:R,modelIndex:m}),o=0;R>o;++o){var N=t.groupsPerChain[g];if(h){var I=O(t.chainIdList.subarray(4*g,4*g+4)),D=null;b&&(D=O(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:D})}for(a=0;N>a;++a){var F=t.groupList[t.groupTypeList[v]],z=F.atomNameList.length;if(p){var k=null;w&&(k=w[v]);var U=null;t.insCodeList&&(U=String.fromCharCode(S[v]));var B=null;M&&(B=M[v]),p({atomCount:z,groupIndex:v,chainIndex:g,modelIndex:m,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:F.groupName,singleLetterCode:F.singleLetterCode,chemCompType:F.chemCompType,secStruct:k,insCode:U,sequenceIndex:B})}for(s=0;z>s;++s){if(f){var V=null;A&&(V=A[y]);var j=null;E&&(j=E[y]);var G=null;C&&(G=String.fromCharCode(C[y]));var W=null;T&&(W=T[y]),f({atomIndex:y,groupIndex:v,chainIndex:g,modelIndex:m,atomId:V,element:F.elementList[s],atomName:F.atomNameList[s],formalCharge:F.formalChargeList[s],xCoord:t.xCoordList[y],yCoord:t.yCoordList[y],zCoord:t.zCoordList[y],bFactor:j,altLoc:G,occupancy:W})}y+=1}if(d){var H=F.bondAtomList;for(s=0,l=F.bondOrderList.length;l>s;++s)d({atomIndex1:y-z+H[2*s],atomIndex2:y-z+H[2*s+1],bondOrder:F.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,d&&P)for(s=0,l=P.length;l>s;s+=2){var X=P[s],Y=P[s+1];(X>=_&&x>=X||Y>=_&&x>=Y)&&d({atomIndex1:X,atomIndex2:Y,bondOrder:L?L[s/2]:null})}m+=1}},t.fetch=function(t,e,r){F(t,B,e,r)},t.fetchReduced=function(t,e,r){F(t,V,e,r)},t.version="v1.1.0dev",t.fetchUrl=B,t.fetchReducedUrl=V,t.encodeMsgpack=n,t.encodeMmtf=L,t.decodeMsgpack=R,t.decodeMmtf=I})(e)}),gy=Jp.Complex,vy=Jp.Chain,yy=Jp.Atom,_y=Jp.AtomName,xy=Jp.Element,by=Jp.Helix,wy=Jp.Sheet,Sy=Jp.Strand,My=Jp.Bond,Ay=Jp.Assembly,Ey=Jp.Molecule;function Cy(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=this._complex._atoms.length)){var r=Math.min(t.atomIndex1,t.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[e],t.bondOrder,My.BondType.UNKNOWN,!0)}},Ty.prototype._updateSecStructure=function(t,e,r){if(!n.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof by||this._ssStruct instanceof Sy)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof by||this._ssStruct instanceof Sy)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!n.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var i=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:i=new by(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(i);break;case 3:var o=new wy("",0);t._sheets.push(o),i=new Sy(o,e,null,0);break;default:i={type:"mmtf"+this._ssType}}this._ssStruct=i,e._secondary=i}},Ty.prototype._updateMolecules=function(t){var e=t.entityList;if(e)for(var r=t.chainsPerModel[0],n=0;n=r)){var c=this._complex._chains[l];a=a.concat(c._residues.slice())}}var u=new Ey(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},Ty.prototype._traverse=function(t){var e=this,r={onModel:function(t){e._onModel(t)},onChain:function(t){e._onChain(t)},onGroup:function(t){e._onGroup(t)},onAtom:function(t){e._onAtom(t)},onBond:function(t){e._onBond(t)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,my.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},Ty.prototype._linkAtomsToResidues=function(){for(var t=0;t=e))for(var a=this._complex._chains[o],s=0;s0&&u.addChain(r[m])}u.matrices=h,t.structures.push(u)}}}},Uy._parseToObject=function(t){var e,r,i,o,a=0,s=0,l=t.length,c=NaN,u=!0,h=1,p=1,f=0,d="unexpected character",m={},g={},v=[],y=0,_="",x=[],b=0;function w(t){return 32===t||10===t||13===t||9===t}function S(t,e,r){for(var n=e.length,i=-1;r=l||w(t.charCodeAt(a+1)))){if(u&&59===c){s=a;var r=0;do{if(-1===(s=S(10,t,s+1)))return d="unterminated text block found",null;++r}while(s+1=l);return e=t.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=r,p=1,u=!1,e}if(39===c||34===c){s=a;do{if(-1===(s=S(c,t,s+1)))return d="unterminated quoted string found",null}while(s+10){for(var A=0;A-e.near?"hidden":"visible",s=1e4*(e.far- -this._vector.z)/(e.far-e.near),l=t.getElement();if(void 0===r.fog)l.style.color=i(t.userData.color),"transparent"!==t.userData.background&&(l.style.background=i(t.userData.background));else{var c=ye.smoothstep(-this._vector.z,r.fog.near,r.fog.far);l.style.color=n(t.userData.color,r.fog.color,c),"transparent"!==t.userData.background&&(l.style.background=n(t.userData.background,r.fog.color,c))}this._vector.applyMatrix4(this._projectionMatrix);var u=(t.userData!=={}?t.userData.translation:"translate(-50%, -50%) ")+"translate("+(this._vector.x*this._widthHalf+this._widthHalf)+"px,"+(-this._vector.y*this._heightHalf+this._heightHalf)+"px)";l.style.visibility=a,l.style.WebkitTransform=u,l.style.MozTransform=u,l.style.oTransform=u,l.style.transform=u,l.style.zIndex=Number(s).toFixed(0),l.parentNode!==this._domElement&&this._domElement.appendChild(l)}for(var h=0,p=t.children.length;h0&&(this._altObj.setObjects(a.objects),this._altObj.pivot=a.pivot,"axis"in a?this._altObj.axis=a.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new _e(o*n,o*i)),this.dispatchEvent({type:"change",action:"translate"}))}else o*=10*(Vu.now.inversePanning?-1:1),this.camera.translateX(o*n),this.camera.translateY(o*i),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},Jy.prototype.reset=function(){this._state=Ky.NONE,this.object.quaternion.copy(new We(0,0,0,1))},Jy.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===Ky.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===Ky.NONE)if(0===t.button){this._affectedObj.stop();var e=!1;if(t.altKey){var r=this.getAltObj();(e=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=e?this._altObj:this._mainObj,this._state=e&&t.ctrlKey&&this._isTranslationAllowed?Ky.TRANSLATE:Ky.ROTATE}else 2===t.button&&(this._state=Ky.TRANSLATE_PIVOT);this._state===Ky.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==Ky.TRANSLATE&&this._state!==Ky.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},Jy.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==Ky.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Ky.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this.rotateByMouse(t.altKey&&!this._isAltObjFreeRotationAllowed||t.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case Ky.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case Ky.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},Jy.prototype.mousewheel=function(t){if(!1!==this.enabled&&Vu.now.zooming&&this._state===Ky.NONE&&!t.shiftKey){t.preventDefault();var e=0;t.wheelDelta?e=t.wheelDelta/40:t.detail&&(e=-t.detail/3);var r=1+.05*e;this.scale(r),this.dispatchEvent({type:"change",action:"zoom",factor:r})}},Jy.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==Ky.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=Ky.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Jy.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=Ky.ROTATE,this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=Ky.SCALE_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(e*e+r*r),this._scaleStart=this.object.scale.x,this._originalPinchCenter=new _e(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY)),this._originalCameraPos.copy(this.camera.position);break;default:this._state=Ky.NONE}},Jy.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==Ky.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case Ky.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case Ky.SCALE_PAN:if(Vu.now.zooming){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=Math.sqrt(e*e+r*r);var n=this.object.scale.x,i=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(i),this.dispatchEvent({type:"change",action:"zoom",factor:0===n?1:i/n})}if(Vu.now.panning){var o=new _e(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));o.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*o.x,this.camera.position.y=this._originalCameraPos.y+.1*o.y,this.dispatchEvent({type:"change",action:"pan"})}}},Jy.prototype.keydownup=function(t){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(t.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[t.keyCode]="keydown"===t.type,t.preventDefault(),t.stopPropagation()}},Jy.prototype.getKeyBindObject=function(){return window.top},Jy.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new He;if(Vu.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=n_?t-i_:t}function c_(t,e,r){this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=r,"function"==typeof e?(this._framesRequestLength=1,this._downloadDataFn=e):this.parseBinaryData(e,!0),this.reset(),this.setFrame(0)}function u_(t,e){if(this.constructor===u_)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=n.merge(Cu.deriveDeep(Vu.now.objects[this.type],!0),e),this.needsRebuild=!1}function h_(t,e){if(u_.call(this,t,e),t.length<2)throw new Error("Wrong number of argumets on line object creation!");this._id1=t[0],this._id2=t[1]}c_.prototype._prepareBuffer=function(t,e){if(void 0!==t&&null!==t||(t=0),void 0!==e&&null!==e||(e=t+this._framesRequestLength),void 0!==this._framesCount&&(e=Math.min(this._framesCount-1,e)),this._downloadDataFn){var r=this;this._buffer||(this._buffer={}),this._buffer.state="downloading",this.isLoading=!0,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),this._downloadDataFn({start:t,end:e+1},function(n){if(r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),r._buffer={data:n,state:"ready",start:t,end:e},null!==r._frameRequest){var i=r._frameRequest;r._frameRequest=null,r.setFrame(i)}},function(){r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onError&&r._callbacks.onError("Streaming failed")})}},c_.prototype._parseBuffer=function(){if(this._buffer&&"ready"===this._buffer.state){this._framesRange={start:this._buffer.start,end:this._buffer.end},this.parseBinaryData(this._buffer.data,!1);var t=(this._buffer.end+1)%this._framesCount;if(t>=this._framesCount&&(t=0),this._buffer={state:"none"},this._prepareBuffer(t,t+this._framesRequestLength),null!==this._frameRequest){var e=this._frameRequest;this._frameRequest=null,this.setFrame(e)}}},c_.prototype.parseBinaryData=function(t){var e=new DataView(t),r=0,n=e.getUint32(r,!0);r+=4;var i=e.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n;this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||t.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=e.getUint32(r,!0),l=0;s>1e3&&l>>28,y=l_((268435200&g)>>>8>>0),_=l_(((255&g)<<12|(4293918720&m)>>>20)>>0),x=l_((1048575&m)>>0);p[d]=0,v>0&&v<4?p[d]=1:4===v&&(p[d]=2),u[h++]=y/100,u[h++]=_/100,u[h++]=x/100}c.push(s_(p,a))}this._secondaryData=c,this._data=u},c_.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},c_.prototype.needsColorUpdate=function(t){return t instanceof tv},c_.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},c_.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},c_.prototype._updateSecondary=function(){var t,e=this._residues,r=e.length;for(t=0;t=this._framesRange.start&&t<=this._framesRange.end)this._currFrame=t,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=t,this._buffer){switch(this._buffer.state){case"none":this._prepareBuffer(t);break;case"ready":this._parseBuffer()}}else this._prepareBuffer(t)},c_.prototype.disableEvents=function(){this._callbacks=null},c_.prototype.getAtomPos=(r_=new He,function(t){var e=this._data,r=3*(this._atomsCount*(this._currFrame-this._framesRange.start)+t);return r_.set(e[r],e[r+1],e[r+2]),r_}),c_.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},u_.prototype.type="__",u_.prototype.identify=function(){var t={type:this.type,params:this.params},e=Cu.objectsDiff(this.opts,Vu.now.modes[this.id]);return n.isEmpty(e)||(t.opts=e),t},u_.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+Cu.compareOptionsWithDefaults(this.opts,Vu.defaults.objects[this.type])},u_.prototype.getGeometry=function(){return this._mesh},u_.prototype.destroy=function(){this._mesh&&mf.destroyObject(this._mesh)},Cu.deriveClass(h_,u_,{type:"line"}),h_.prototype.constructor=h_,h_.prototype._getAtomFromName=function(t,e){var r=t.getAtomByFullname(e);if(!r)throw new Error(e+" - Wrong atom format it must be '#CHAIN_NAME.#NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r},h_.prototype.build=function(t){var e=new Fi;this._atom1=this._getAtomFromName(t,this._id1),this._atom2=this._getAtomFromName(t,this._id2),e.vertices[0]=this._atom1._position.clone(),e.vertices[1]=this._atom2._position.clone(),e.dynamic=!0,e.computeLineDistances(),e.computeBoundingBox(),this._line=new Zd.Line(e,new lf({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new Dr(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(t,e){},this._mesh=this._line;var r=t.getTransforms();r.length>0&&(this._mesh=new ea,this._mesh.add(this._line),mf.applyTransformsToMeshes(this._mesh,r))},h_.prototype.updateToFrame=function(t){if(this._atom1&&this._atom2&&this._line){var e=this._line.geometry;e.vertices[0].copy(t.getAtomPos(this._atom1._index)),e.vertices[1].copy(t.getAtomPos(this._atom2._index)),e.computeLineDistances(),e.computeBoundingSphere(),e.verticesNeedUpdate=!0}};var p_="varying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n",f_="uniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = vec2(1, 1) / srcTexSize;\r\n\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = grad;\r\n}\r\n",d_=Ur.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new _e(512,512)},opacity:{type:"f",value:1}}]);function m_(t){return new dn({uniforms:function(t){var e=Ur.clone(d_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:p_,fragmentShader:f_,transparent:!0,depthTest:!1,depthWrite:!1})}var g_="// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\nvec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {return texture2D( tex, pos + off * res ).xyz;}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {return texture2D( tex, pos).xyz;}\r\n//=====================================================================//\r\nvoid main() {\r\n// renaming\r\n vec2 posM = vUv;\r\n// get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n// find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n// calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n// exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n// calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0/spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\r\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n}\r\n",v_=Ur.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new _e(1/512,1/512)}}]);function y_(t){return new dn({uniforms:function(t){var e=Ur.clone(v_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:p_,fragmentShader:g_,transparent:!0,depthTest:!1,depthWrite:!1})}var __="#define MAX_SAMPLES_COUNT 32\r\n\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nuniform vec2 fogNearFar;\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (- projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n vec2 viewRay = vec2(projPos.x * aspectRatio * tanHalfFOV, projPos.y * tanHalfFOV); // TODO mode to vs\r\n // reconstruct viewposition in right-handed sc with z from viewer\r\n viewPos.xy = vec2(viewRay.x * viewPos.z, viewRay.y * viewPos.z);\r\n return viewPos;\r\n}\r\n\r\nvec3 GetDerivative( vec3 p0, vec3 p1, vec3 p2 )\r\n{\r\n vec3 v1 = p1 - p0;\r\n vec3 v2 = p0 - p2;\r\n return ( dot( v1, v1 ) < dot( v2, v2 ) ) ? v1 : v2;\r\n}\r\n\r\nvec3 RestoreNormalFromDepth(vec2 texcoords, vec3 p) {\r\n\r\n vec2 offset1 = vec2(srcTexelSize.x, 0.0);\r\n vec2 offset2 = vec2(0.0, srcTexelSize.y);\r\n\r\n vec3 p1 = ViewPosFromDepth(texcoords + offset1);\r\n vec3 p2 = ViewPosFromDepth(texcoords + offset2);\r\n vec3 p3 = ViewPosFromDepth(texcoords - offset1);\r\n vec3 p4 = ViewPosFromDepth(texcoords - offset2);\r\n\r\n vec3 dx = GetDerivative(p, p3, p1);\r\n vec3 dy = GetDerivative(p, p4, p2);\r\n vec3 normal = cross(dx, dy);\r\n return normalize(normal);\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n // restore normal from depth buffer\r\n vec3 normal = RestoreNormalFromDepth(vUv, viewPos); \r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n // project sample to screen to get sample's screen pos\r\n vec4 offset = vec4(samplePos, 1.0);\r\n offset = projMatrix * offset;\r\n offset.xy /= offset.w;\r\n offset.xy = (-offset.xy + vec2(1.0)) * 0.5;\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(offset.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // add fog to the AO value\r\n AO *= 1.0 - smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z);\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / 32.0 * factor); // TODO use MAX_SAMPLES_COUNT\r\n vec3 color = texture2D(diffuseTexture, vUv).rgb;\r\n // check if the fragment doesn't belong to background\r\n if (abs(- viewPos.z - camNearFar.y) < 0.1) { // FIXME remove temporal fix for background darkening\r\n gl_FragColor = vec4(1.0);\r\n return;\r\n }\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}",x_="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )) * weight;\r\n weightSum += weight;\r\n }\r\n gl_FragColor = res / weightSum;\r\n}\r\n",b_="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)) * weight;\r\n weightSum += weight;\r\n }\r\n res /= weightSum;\r\n vec3 color = texture2D(diffuseTexture, vec2(x, y)).rgb;\r\n gl_FragColor = vec4(color * res.rgb, 1.0);\r\n}",w_=Ur.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new _e(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new _e(1/512,1/512)},camNearFar:{type:"v2",value:new _e(1,10)},projMatrix:{type:"mat4",value:new Xe},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:null},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1},fogNearFar:{type:"v2",value:new _e(100,100)}}]),S_=Ur.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new _e(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new _e(1,10)},projMatrix:{type:"mat4",value:new Xe},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]);function M_(t,e){var r=Ur.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}var A_={AOMaterial:function(t){return new dn({uniforms:M_(t,w_),vertexShader:p_,fragmentShader:__,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new dn({uniforms:M_(t,S_),vertexShader:p_,fragmentShader:x_,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new dn({uniforms:M_(t,S_),vertexShader:p_,fragmentShader:b_,transparent:!1,depthTest:!1,depthWrite:!1})}},E_="uniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",C_=Ur.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);function T_(t){return new dn({uniforms:function(t){var e=Ur.clone(C_);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:p_,fragmentShader:E_,transparent:!1,depthTest:!1,depthWrite:!1})}function P_(){this.position=new He(0,0,0),this.scale=1,this.orientation=new We(0,0,0,1)}P_.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};function L_(){}L_.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},L_.prototype.isMoving=function(){return this._isMoving},L_.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},L_.prototype.start=function(){this._startTime=Date.now();var t=Vu.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},L_.prototype.getCurrentView=function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var t=this.createView(),e=Date.now();if(e>this._endTime)return t=this._dstView,this._reset(),{success:!0,view:t};var r=(e-this._startTime)/(this._endTime-this._startTime);return t.position.copy(this._srcView.position),t.position.lerp(this._dstView.position,r),t.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,t.orientation.copy(this._srcView.orientation),t.orientation.slerp(this._dstView.orientation,r),{success:!0,view:t}},L_.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},L_.prototype.createView=function(){return new P_};var R_=new L_,N_=Vu.now.fbxprec,I_='; FBX 6.1.0 project file\n; Copyright (C) 1997-2007 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n FBXHeaderExtension: {\n FBXHeaderVersion: 1003\n FBXVersion: 6100\n CreationTimeStamp: {\n Version: 1000\n Year: 2015\n Month: 12\n Day: 7\n Hour: 17\n Minute: 34\n Second: 53\n Millisecond: 369\n }\n Creator: "FBX SDK/FBX Plugins build 20080212"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nreationTime: "2015-12-07 17:34:53:369"\nreator: "FBX SDK/FBX Plugins build 20080212"\n\n; Document Description\n;------------------------------------------------------------------\n\n Document: {\n Name: ""\n}\n\n; Document References\n;------------------------------------------------------------------\n\n References: {\n}\n\n; Object definitions\n;------------------------------------------------------------------\n\n Definitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "SceneInfo" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n}\n\n; Object properties\n;------------------------------------------------------------------\n\n Objects: {\n Model: "Model::Sphere01", "Mesh" {\n Version: 232\n Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "InheritType", "enum", "",1\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Lcl Translation", "Lcl Translation", "A+",-0.169204741716385,-0.507614195346832,0\n Property: "Lcl Rotation", "Lcl Rotation", "A+",0,0,0\n Property: "Lcl Scaling", "Lcl Scaling", "A+",1,1,1\n Property: "Visibility", "Visibility", "A+",1\n Property: "BBoxMin", "Vector3D", "N",0,0,0\n Property: "BBoxMax", "Vector3D", "N",0,0,0\n }\n MultiLayer: 0\n MultiTake: 1\n Shading: T\n Culling: "CullingOff"\n',O_='NodeAttributeName: "Geometry::Sphere01"\n}\nceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n Type: "UserData"\n Version: 100\n MetaData: {\n Version: 100\n Title: ""\n Subject: ""\n Author: ""\n Keywords: ""\n Revision: ""\n Comment: ""\n }\n Properties60: {\n Property: "DocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "SrcDocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "Original", "Compound", ""\n Property: "Original|ApplicationVendor", "KString", "", "Autodesk"\n Property: "Original|ApplicationName", "KString", "", "3ds Max"\n Property: "Original|ApplicationVersion", "KString", "", "2009.0"\n Property: "Original|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n Property: "Original|FileName", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "LastSaved", "Compound", ""\n Property: "LastSaved|ApplicationVendor", "KString", "", "Autodesk"\n Property: "LastSaved|ApplicationName", "KString", "", "3ds Max"\n Property: "LastSaved|ApplicationVersion", "KString", "", "2009.0"\n Property: "LastSaved|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n }\n}\nlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",2\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",1\n Property: "FrontAxisSign", "int", "",-1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",2.54\n }\n}\n}\n\n; Object relations\n;------------------------------------------------------------------\n\n Relations: {\n Model: "Model::Sphere01", "Mesh" {\n }\n SceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n }\n}\n\n; Object connections\n;------------------------------------------------------------------\n\n Connections: {\n Connect: "OO", "Model::Sphere01", "Model::Scene"\n}\n\n;Object data\n;------------------------------------------------------------------\n\n ObjectData: {\n}\n;Takes and animation section\n;----------------------------------------------------\n\n Takes: {\n Current: "Take 001"\n}\n;Version 5 settings\n;------------------------------------------------------------------\n\n Version5: {\n AmbientRenderSettings: {\n Version: 101\n AmbientLightColor: 0.533333003520966,0.533333003520966,0.533333003520966,1\n }\n FogOptions: {\n FlogEnable: 0\n FogMode: 0\n FogDensity: 0.002\n FogStart: 0.3\n FogEnd: 1000\n FogColor: 1,1,1,1\n }\n Settings: {\n FrameRate: "30"\n TimeFormat: 1\n SnapOnFrames: 0\n ReferenceTimeIndex: -1\n TimeLineStartTime: 0\n TimeLineStopTime: 153953860000\n }\n RendererSetting: {\n DefaultCamera: ""\n DefaultViewingMode: 0\n }\n}\n\n';function D_(t){var e;switch(t.code){case FileError.QUOTA_EXCEEDED_ERR:e="QUOTA_EXCEEDED_ERR";break;case FileError.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case FileError.SECURITY_ERR:e="SECURITY_ERR";break;case FileError.INVALID_MODIFICATION_ERR:e="INVALID_MODIFICATION_ERR";break;case FileError.INVALID_STATE_ERR:e="INVALID_STATE_ERR";break;default:e="Unknown Error"}throw new Error(e)}var F_=null;function z_(){}function k_(t){for(var e=[],r=0,n=t.length;r0?t.write(o):i()},t.truncate(0))},D_)},D_))};function G_(t,e){this.context=t,this._opts=n.merge({path:"/"},e)}yf(G_.prototype),G_.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?e(t[0],i):r(i)}),i}var o=document.createElement("a");return o.href="https://webvr.info",o.innerHTML="WEBVR NOT SUPPORTED",o.style.left="calc(50% - 90px)",o.style.width="180px",o.style.textDecoration="none",n(o),o}}]),t}(),sx=Jp.selectors,lx=Jp.Atom,cx=Jp.Residue,ux=Jp.Chain,hx=Jp.Molecule,px=0,fx=1,dx=2,mx=Cu.createElement;function gx(t){var e=t.lastIndexOf(".");return e>=0&&(t=t.substr(0,e)),t}function vx(t,e,r){void 0!==r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function yx(t){su.call(this),this._opts=n.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||n.head(document.getElementsByClassName("miew-container"))||document.body,this._containerRoot=this._container,this._running=!1,this._halting=!1,this._building=!1,this._needRender=!0,this._hotKeysEnabled=!0,this.settings=Vu;var e=hu;e.console=!1,e.level="info",this.logger=e,this._cookies=new G_(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loading=[],this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._srvTopoSource=null,this._srvAnimSource=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;yx.registeredPlugins.forEach(function(t){t.call(r)})}function _x(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}yx.prototype=Object.create(su.prototype),yx.prototype.constructor=yx,yx.prototype.getMaxRepresentationCount=function(){return Sv.NUM_REPRESENTATION_BITS},yx.prototype.init=function(){var t=this._container,e=Cu.createElement("div",{class:"miew-canvas"});_x(t,e),this._container=e;var r=document.createDocumentFragment();if(r.appendChild(this._msgMode=mx("div",{class:"mode-message overlay"},mx("p",{},"COMPONENT EDIT MODE"))),r.appendChild(this._msgAtomInfo=mx("div",{class:"atom-info overlay"},mx("p",{},""))),t.appendChild(r),null!==this._gfx)return!0;var n=this;this._showMessage("Viewer is being initialized...");try{this._initGfx(),this._initListeners(),this._spinner=new ou({lines:13,length:28,width:14,radius:42,color:"#fff",zIndex:700}),window.top.addEventListener("keydown",function(t){n._onKeyDown(t)}),window.top.addEventListener("keyup",function(t){n._onKeyUp(t)}),this._objectControls=new Jy(this._gfx.root,this._gfx.pivot,this._gfx.camera,this._gfx.renderer.domElement,function(){return n._getAltObj()}),this._objectControls.addEventListener("change",function(t){switch(t.action){case"rotate":n.dispatchEvent({type:"rotate",angle:t.angle});break;case"zoom":n.dispatchEvent({type:"zoom",factor:t.factor})}n.dispatchEvent({type:"transform"}),n._needRender=!0});var i=this._gfx;this._picker=new t_(i.root,i.camera,i.renderer.domElement),this._picker.addEventListener("newpick",function(t){n._onPick(t)}),this._picker.addEventListener("dblclick",function(t){n._onDblClick(t)}),this._onThemeChanged()}catch(t){if("TypeError"!==t.name||"Cannot read property 'getExtension' of null"!==t.message)throw this._showMessage("Viewer initialization failed."),t;return this._showMessage("Could not create WebGL context."),!1}var o=this._opts&&this._opts.load;if(o){var a=this._opts&&this._opts.type;this.load(o,{fileType:a,keepRepsInfo:!0})}return!0},yx.prototype.term=function(){this._showMessage("Viewer has been terminated."),this._loading.forEach(function(t){t.cancel()}),this._loading.length=0,this.halt(),this._gfx=null},yx.prototype._showMessage=function(t){var e=document.createElement("div");e.setAttribute("class","miew-message"),e.appendChild(document.createElement("p")).appendChild(document.createTextNode(t)),_x(this._container,e)},yx.prototype._showCanvas=function(){_x(this._container,this._gfx.renderer.domElement)},yx.prototype._initGfx=function(){var t={width:this._container.clientWidth,height:this._container.clientHeight},e={preserveDrawingBuffer:!0};Vu.now.antialias&&(e.antialias=!0),t.renderer2d=new $y,t.renderer=new ko(e),of.init(t.renderer),t.renderer.getContext().getExtension("EXT_frag_depth")||(Vu.now.zSprites=!1),t.renderer.getContext().getExtension("WEBGL_depth_texture")||(Vu.now.ao=!1),t.renderer.autoClear=!1,t.renderer.setPixelRatio(window.devicePixelRatio),t.renderer.setSize(t.width,t.height),t.renderer.setClearColor(Vu.now.themes[Vu.now.theme]),t.renderer.clearColor(),t.renderer2d.setSize(t.width,t.height),t.camera=new Yn(Vu.now.camFov,t.width/t.height,Vu.now.camNear,Vu.now.camFar),t.camera.setMinimalFov(Vu.now.camFov),t.camera.position.z=Vu.now.camDistance,t.camera.updateProjectionMatrix(),t.camera.layers.set(mf.LAYERS.DEFAULT),t.camera.layers.enable(mf.LAYERS.VOLUME),t.camera.layers.enable(mf.LAYERS.VOLUME_BFPLANE),t.stereoCam=new tc,t.scene=new Vo,t.scene.fog=new Bo(Vu.now.themes[Vu.now.theme],Vu.now.camNear,Vu.now.camFar),t.root=new mf.RCGroup,t.scene.add(t.root),t.pivot=new mf.RCGroup,t.root.add(t.pivot),t.selectionScene=new Vo,t.selectionRoot=new ea,t.selectionRoot.matrixAutoUpdate=!1,t.selectionScene.add(t.selectionRoot),t.selectionPivot=new ea,t.selectionPivot.matrixAutoUpdate=!1,t.selectionRoot.add(t.selectionPivot);var r=new vs(16777215,.45);r.position.set(0,.414,1),r.layers.enable(mf.LAYERS.TRANSPARENT),t.scene.add(r);var n=new ys(6710886);n.layers.enable(mf.LAYERS.TRANSPARENT),t.scene.add(n),t.axes=new e_(t.root,t.camera),t.offscreenBuf=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:_t,format:Ut,depthBuffer:!0}),t.renderer.getContext().getExtension("WEBGL_depth_texture")&&(t.offscreenBuf.depthTexture=new ia,t.offscreenBuf.depthTexture.type=Tt),t.offscreenBuf2=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.offscreenBuf3=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.offscreenBuf4=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.volBFTex=t.offscreenBuf3,t.volFFTex=t.offscreenBuf4,t.volWFFTex=t.offscreenBuf,t.renderer.getContext().getExtension("OES_texture_float")?(t.offscreenBuf5=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,type:Rt,depthBuffer:!1}),t.offscreenBuf6=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,type:Rt,depthBuffer:!1}),t.offscreenBuf7=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,type:Rt,depthBuffer:!0}),t.volBFTex=t.offscreenBuf5,t.volFFTex=t.offscreenBuf6,t.volWFFTex=t.offscreenBuf7):this.logger.warn("Device doesn't support OES_texture_float extension"),t.stereoBufL=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),t.stereoBufR=new je(t.width*window.devicePixelRatio,t.height*window.devicePixelRatio,{minFilter:wt,magFilter:wt,format:Ut,depthBuffer:!1}),this._toggleWebVR("WEBVR"===Vu.now.stereo,t),this._gfx=t,this._showCanvas(),this._container.appendChild(t.renderer2d.getElement());var i=new Lu;i.domElement.style.position="absolute",i.domElement.style.right="0",i.domElement.style.bottom="0",this._container.appendChild(i.domElement),this._fps=i,this._fps.show(Vu.now.fps)},yx.prototype._initListeners=function(){var t=this;window.addEventListener("resize",function(){t._onResize()})},yx.prototype._makeUniqueVisualName=function(t){if(!t)return Math.random().toString();for(var e=t,r=1;this._visuals.hasOwnProperty(e);)e=t+" ("+r.toString()+")",r++;return e},yx.prototype._addVisual=function(t){if(!t)return null;var e=this._makeUniqueVisualName(t.name);return t.name=e,this._visuals[e]=t,this._gfx.pivot.add(t),t.getSelectionGeo&&this._gfx.selectionPivot.add(t.getSelectionGeo()),e},yx.prototype._removeVisual=function(t){var e="",r=null;t instanceof vf?(e=t.name,r=t):"string"==typeof t&&(e=t,r=this._visuals[e]),r&&this._visuals.hasOwnProperty(e)&&this._visuals[e]===r&&(e===this._curVisualName&&(this._curVisualName=void 0),delete this._visuals[e],r.release(),this._needRender=!0)},yx.prototype._forEachVisual=function(t){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&t(this._visuals[e])},yx.prototype._releaseAllVisuals=function(){if(this._gfx&&this._gfx.pivot){for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&this._visuals[t].release();this._visuals={}}},yx.prototype._forEachComplexVisual=function(t){if(this._gfx&&this._gfx.pivot)for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e]instanceof Sv&&t(this._visuals[e])},yx.prototype._getComplexVisual=function(t){t=t||this._curVisualName;var e=null,r=null;return this._forEachComplexVisual(function(n){e=n,n.name===t&&(r=n)}),r||e},yx.prototype._getVolumeVisual=function(){var t=null;return this._forEachVisual(function(e){e instanceof Ov&&(t=e)}),t},yx.prototype._getVisualForComplex=function(t){if(!t)return null;var e=null;return this._forEachComplexVisual(function(r){r.getComplex()===t&&(e=r)}),e},yx.prototype.getVisuals=function(){return Object.keys(this._visuals)},yx.prototype.getCurrentVisual=function(){return this._curVisualName},yx.prototype.setCurrentVisual=function(t){this._visuals[t]&&(this._curVisualName=t)},yx.prototype.run=function(){var t=this;if(!this._running){if(this._running=!0,this._halting)return void(this._halting=!1);this._objectControls.enable(!0),(this._getWebVRDevice()||window).requestAnimationFrame(function(){return t._onTick()})}},yx.prototype.halt=function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._halting=!0)},yx.prototype.enableHotKeys=function(t){this._hotKeysEnabled=t,this._objectControls.enableHotkeys(t)},yx.prototype._onResize=function(){this._needRender=!0;var t=this._gfx;t.width=this._container.clientWidth,t.height=this._container.clientHeight,t.camera.aspect=t.width/t.height,t.camera.setMinimalFov(Vu.now.camFov),t.camera.updateProjectionMatrix(),t.renderer.setSize(t.width,t.height),t.renderer2d.setSize(t.width,t.height),this.dispatchEvent({type:"resize"})},yx.prototype._resizeOffscreenBuffers=function(t,e,r){var n=this._gfx,i="NONE"===(r=r||"NONE")||"ANAGLYPH"===r,o=i?1:.5;n.offscreenBuf.setSize(o*t,e),n.offscreenBuf2.setSize(o*t,e),n.offscreenBuf3.setSize(o*t,e),n.offscreenBuf5&&n.offscreenBuf5.setSize(o*t,e),n.offscreenBuf6&&n.offscreenBuf6.setSize(o*t,e),n.offscreenBuf7&&n.offscreenBuf7.setSize(o*t,e),i&&(n.stereoBufL.setSize(t,e),n.stereoBufR.setSize(t,e))},yx.prototype._onTick=function(){var t=this;if(this._halting)return this._running=!1,void(this._halting=!1);this._fps.update();var e=this._getWebVRDevice();(e||window).requestAnimationFrame(function(){return t._onTick()}),this._onUpdate(),this._needRender&&(this._onRender(),this._needRender=!Vu.now.suspendRender||"WEBVR"===Vu.now.stereo||!!e)},yx.prototype._toggleWebVR=(W_=new Yn,H_=!1,X_=null,function(t,e){var r=e?e.renderer:null;if(!r)throw new Error("No renderer is available to toggle WebVR");if(!e.camera)throw new Error("No camera is available to toggle WebVR");t?(W_.copy(e.camera),H_=!0,r.vr.enabled=!0,X_?X_.style.display="block":(X_=ax.createButton(r),document.body.appendChild(X_))):(r.vr.enabled=!1,X_&&(X_.style.display="none"),H_&&(e.camera.copy(W_),this._onResize())),this._needRender=!0}),yx.prototype._getWebVRDevice=function(){var t=this._gfx.renderer.vr;return t&&t.enabled?t.getDevice():null},yx.prototype._getBSphereRadius=function(){var t=0;return this._forEachVisual(function(e){t=Math.max(t,e.getBoundaries().boundingSphere.radius)}),t*this._objectControls.getScale()},yx.prototype._updateFog=function(){var t,e,r,n=this._gfx;Vu.now.fog?(void 0!==n.scene.fog&&null!==n.scene.fog||(n.scene.fog=new Bo(Vu.now.themes[Vu.now.theme]),this._setUberMaterialValues({fog:Vu.now.fog})),t=n.scene.fog,e=n.camera.position.z,r=this._getBSphereRadius(),t.near=e-r*Vu.now.fogNearFactor,t.far=e+r*Vu.now.fogFarFactor):n.scene.fog&&(n.scene.fog=void 0,this._setUberMaterialValues({fog:Vu.now.fog}))},yx.prototype._onUpdate=function(){void 0!==this.isScriptingCommandAvailable&&this.isScriptingCommandAvailable()&&!this._building&&this.callNextCmd(),this._objectControls.update(),this._forEachComplexVisual(function(t){t.getComplex().update()}),Vu.now.autobuild&&!this._loading.length&&!this._building&&this._needRebuild()&&this.rebuild(),this._loading.length||this._building||this._needRebuild()||this._updateView(),this._updateFog()},yx.prototype._onRender=function(){var t=this._gfx;t.scene.updateMatrixWorld(),t.camera.updateMatrixWorld(),this._clipPlaneUpdateValue(this._getBSphereRadius()),this._fogFarUpdateValue(),t.renderer.clearTarget(null),this._renderFrame(Vu.now.stereo)},yx.prototype._renderFrame=(Y_=new T_,function(t){var e=this._gfx,r=e.renderer;"NONE"!==t&&(e.stereoCam.aspect="ANAGLYPH"===t?1:.5,e.camera.focus=e.camera.position.z,e.stereoCam.update(e.camera));var n=r.getSize();switch(this._resizeOffscreenBuffers(n.width*window.devicePixelRatio,n.height*window.devicePixelRatio,t),t){case"WEBVR":case"NONE":this._renderScene(e.camera,!1);break;case"SIMPLE":case"DISTORTED":r.setScissorTest(!0),r.setScissor(0,0,n.width/2,n.height),r.setViewport(0,0,n.width/2,n.height),this._renderScene(this._gfx.stereoCam.cameraL,"DISTORTED"===t),r.setScissor(n.width/2,0,n.width/2,n.height),r.setViewport(n.width/2,0,n.width/2,n.height),this._renderScene(this._gfx.stereoCam.cameraR,"DISTORTED"===t),r.setScissorTest(!1);break;case"ANAGLYPH":this._renderScene(this._gfx.stereoCam.cameraL,!1,e.stereoBufL),this._renderScene(this._gfx.stereoCam.cameraR,!1,e.stereoBufR),Y_.uniforms.srcL.value=e.stereoBufL,Y_.uniforms.srcR.value=e.stereoBufR,e.renderer.renderScreenQuad(Y_)}e.renderer2d.render(e.scene,e.camera),Vu.now.axes&&e.axes&&!e.renderer.vr.enabled&&e.axes.render(r)}),yx.prototype._onThemeChanged=(q_=/\s*theme-\w+\b/g,function(){var t=Vu.now.theme,e=this._containerRoot;e.className=e.className.replace(q_,"")+" theme-"+t;var r=this._gfx;if(r){var n=Vu.now.themes[t];r.scene.fog&&r.scene.fog.color.set(n),r.renderer.setClearColor(n)}}),yx.prototype._setUberMaterialValues=function(t){this._gfx.root.traverse(function(e){(e instanceof io||e instanceof Ko||e instanceof $o)&&e.material instanceof lf&&(e.material.setValues(t),e.material.needsUpdate=!0)})},yx.prototype._renderScene=function(t,e,r){e=e||!1,r=r||null;var n=this._gfx;if(n.renderer.setClearColor(Vu.now.themes[Vu.now.theme],1),n.renderer.clearTarget(r),n.renderer.vr.enabled)n.renderer.render(n.scene,t);else{n.renderer.clearTarget(n.offscreenBuf),"prepass"===Vu.now.transparency?this._renderWithPrepassTransparency(t,n.offscreenBuf):"standard"===Vu.now.transparency&&n.renderer.render(n.scene,t,n.offscreenBuf);var i=null!==this._getComplexVisual(),o=this._getVolumeVisual(),a=i&&Vu.now.fxaa,s=null!==o&&null!=o.getMesh().material,l=s||a||e?n.offscreenBuf2:r,c=n.offscreenBuf;i&&Vu.now.ao?this._performAO(c,n.offscreenBuf.depthTexture,l,n.offscreenBuf3,n.offscreenBuf2):n.renderer.renderScreenQuadFromTex(c.texture,1,l),this._renderSelection(t,c,l),s&&(n.renderer.renderScreenQuadFromTex(l.texture,1,n.offscreenBuf),l=n.offscreenBuf,this._renderVolume(o,t,l,n.volBFTex,n.volFFTex,n.volWFFTex),a||e||n.renderer.renderScreenQuadFromTex(l.texture,1,r)),c=l,a&&(l=e?n.offscreenBuf3:r,this._performFXAA(c,l),c=l),e&&(l=r,this._performDistortion(c,l,!0))}},yx.prototype._performDistortion=(Z_=new Vo,$_=new Xn(-1,1,1,-1,-500,1e3),K_=new dn({uniforms:{srcTex:{type:"t",value:null},aberration:{type:"fv3",value:new He(1)}},vertexShader:"varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }",fragmentShader:"varying vec2 vUv; uniform sampler2D srcTex; uniform vec3 aberration;void main() {vec2 uv = vUv * 2.0 - 1.0;gl_FragColor.r = texture2D(srcTex, 0.5 * (uv * aberration[0] + 1.0)).r;gl_FragColor.g = texture2D(srcTex, 0.5 * (uv * aberration[1] + 1.0)).g;gl_FragColor.b = texture2D(srcTex, 0.5 * (uv * aberration[2] + 1.0)).b;gl_FragColor.a = 1.0;}",transparent:!1,depthTest:!1,depthWrite:!1}),Q_=mf.buildDistorionMesh(10,10,Vu.now.debug.stereoBarrel),Z_.add(new Zd.Mesh(Q_,K_)),function(t,e,r){this._gfx.renderer.clearTarget(e),r?(K_.uniforms.srcTex.value=t.texture,K_.uniforms.aberration.value.set(.995,1,1.01),this._gfx.renderer.render(Z_,$_,e)):this._gfx.renderer.renderScreenQuadFromTexWithDistortion(t,Vu.now.debug.stereoBarrel,e)}),yx.prototype._renderSelection=(J_=new m_,function(t,e,r){var n=this._gfx;n.renderer.setClearColor("black",0),n.renderer.clearTarget(e,!0,!1,!1),n.selectionPivot.children.length>0?(n.selectionRoot.matrix=n.root.matrix,n.selectionPivot.matrix=n.pivot.matrix,n.renderer.render(n.selectionScene,t,e)):n.renderer.renderDummyQuad(e),n.renderer.renderScreenQuadFromTex(e.texture,.6,r),J_.uniforms.srcTex.value=e.texture,J_.uniforms.srcTexSize.value.set(e.width,e.height),n.renderer.renderScreenQuad(J_,r)}),yx.prototype._checkVolumeRenderingSupport=function(t){if(!t)return!1;var e=this._gfx,r=e.renderer.getRenderTarget();e.renderer.setRenderTarget(t);var n=e.renderer.getContext(),i=n.checkFramebufferStatus(n.FRAMEBUFFER);return e.renderer.setRenderTarget(r),i===n.FRAMEBUFFER_COMPLETE||(this.logger.warn("Device doesn't support electron density rendering"),!1)},yx.prototype._renderVolume=(ex=new Nv.BackFacePosMaterial,rx=new Nv.FrontFacePosMaterial,nx=(new Xe).makeTranslation(.5,.5,.5),ix=new Xe,function(t,e,r,n,i,o){var a=this._gfx;if(void 0===tx&&(tx=this._checkVolumeRenderingSupport(n)),tx){var s=t.getMesh();s.rebuild(e),a.renderer.setClearColor("black",0),a.renderer.clearTarget(n),a.renderer.clearTarget(i),a.renderer.clearTarget(o),e.layers.set(mf.LAYERS.VOLUME_BFPLANE),a.renderer.render(a.scene,e,n),e.layers.set(mf.LAYERS.VOLUME),a.scene.overrideMaterial=ex,a.renderer.render(a.scene,e,n),e.layers.set(mf.LAYERS.VOLUME),a.scene.overrideMaterial=rx,a.renderer.render(a.scene,e,i),a.scene.overrideMaterial=null,e.layers.set(mf.LAYERS.DEFAULT),ix.getInverse(s.matrixWorld),lf.prototype.uberOptions.world2colorMatrix.multiplyMatrices(nx,ix),this._setUberMaterialValues({colorFromPos:!0}),a.renderer.render(a.scene,e,o),this._setUberMaterialValues({colorFromPos:!1});var l=s.material;l.uniforms._BFRight.value=n.texture,l.uniforms._FFRight.value=i.texture,l.uniforms._WFFRight.value=o.texture,e.layers.set(mf.LAYERS.VOLUME),a.renderer.render(a.scene,e,r),e.layers.set(mf.LAYERS.DEFAULT)}}),yx.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(mf.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(mf.LAYERS.PREPASS_TRANSPARENT),r.renderer.context.colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,t,e),r.renderer.context.colorMask(!0,!0,!0,!0),t.layers.set(mf.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(mf.LAYERS.DEFAULT)},yx.prototype._performFXAA=(ox=new y_,function(t,e){if(void 0!==t&&void 0!==e){var r=this._gfx;r.renderer.setClearColor(Vu.now.themes[Vu.now.theme],1),r.renderer.clearTarget(e),ox.uniforms.srcTex.value=t.texture,ox.uniforms.srcTexelSize.value.set(1/t.width,1/t.height),ox.transparent=!0,r.renderer.renderScreenQuad(ox,e)}}),yx.prototype._performAO=function(){var t=new A_.AOMaterial,e=new A_.HorBilateralBlurMaterial,r=new A_.VertBilateralBlurMaterial,n=new Ye(new Uint8Array([0,0,0,66,0,0,77,0,0,155,62,0,0,247,0,33,0,0,0,0,0,235,0,0,0,0,0,176,44,0,232,46,0,0,29,0,0,0,0,78,197,0,93,0,0,0,0,0]),4,4,kt,At,300,gt,gt,_t,_t,1);n.needsUpdate=!0;var i=[new He(.295184,.077723,.068429),new He(-.271976,-.365221,.838363),new He(.547713,.467576,.488515),new He(.662808,-.031733,.584758),new He(-.025717,.218955,.657094),new He(-.310153,-.365223,.370701),new He(-.101407,-.006313,.747665),new He(-.769138,.360399,.086847),new He(-.271988,-.27514,.905353),new He(.09674,-.566901,.700151),new He(.562872,-.735136,.094647),new He(.379877,.359278,.190061),new He(.519064,-.023055,.405068),new He(-.301036,.114696,.088885),new He(-.282922,.598305,.487214),new He(-.181859,.25167,.679702),new He(-.191463,-.635818,.512919),new He(-.293655,.427423,.078921),new He(-.267983,.680534,.13288),new He(.139611,.319637,.477439),new He(-.352086,.31104,.653913),new He(.321032,.805279,.487345),new He(.073516,.820734,.414183),new He(-.155324,.589983,.41146),new He(.335976,.170782,.527627),new He(.46346,-.355658,.167689),new He(.222654,.59655,.769406),new He(.922138,-.04207,.147555),new He(-.72705,-.329192,.369826),new He(-.090731,.53382,.463767),new He(-.323457,-.876559,.238524),new He(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,l,c,u){if(void 0!==a&&void 0!==s&&void 0!==l&&void 0!==c&&void 0!==u){var h=this._gfx;t.uniforms.diffuseTexture.value=a.texture,t.uniforms.depthTexture.value=s,t.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),t.uniforms.camNearFar.value.set(h.camera.near,h.camera.far),t.uniforms.projMatrix.value=h.camera.projectionMatrix,t.uniforms.aspectRatio.value=h.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*ye.DEG2RAD*h.camera.fov),t.uniforms.samplesKernel.value=i;var p=new He,f=new We,d=new He;h.root.matrix.decompose(p,f,d),t.uniforms.kernelRadius.value=Vu.now.debug.ssaoKernelRadius*d.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=Vu.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var m=h.scene.fog;m&&t.uniforms.fogNearFar.value.set(m.near,m.far),t.transparent=!1,h.renderer.renderScreenQuad(t,u),e.uniforms.aoMap.value=u.texture,e.uniforms.srcTexelSize.value.set(1/u.width,1/u.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,h.renderer.renderScreenQuad(e,c),r.uniforms.aoMap.value=c.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/c.width,1/c.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,h.renderer.renderScreenQuad(r,l)}}}(),yx.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(px),this._resetObjects(),this._gfx&&(mf.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},yx.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},yx.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(px),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},yx.prototype.load=function(t,e){var r=this;e=n.merge({},e,{context:this}),this.settings.now.use.multiFile||(this._loading.length&&(this._loading.forEach(function(t){t.cancel()}),this._loading.length=0),e.animation||this.reset(!0)),this.dispatchEvent({type:"load",options:e,source:t});var i=new ku;this._loading.push(i),i.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),this._spinner.spin(this._container);var o,a,s,l=function(t){var e=r._loading.indexOf(i);return-1!==e&&r._loading.splice(e,1),r._spinner.stop(),r._refreshTitle(),t};return(o=t,a=e,s=i,new Promise(function(t){if(s.shouldCancel())throw new Error("Operation cancelled");o=function(t,e){if(!n.isString(t))return t;var r=bx.exec(t);if(r){var i=Fu(r,3),o=i[1],a=void 0===o?"pdb":o,s=i[2];switch(a=a.toLowerCase(),s=s.toUpperCase(),a){case"pdb":t="http://files.rcsb.org/download/"+s+".pdb";break;case"cif":t="http://files.rcsb.org/download/"+s+".cif";break;case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s;break;case"ccp4":t="https://www.ebi.ac.uk/pdbe/coordinates/files/"+s.toLowerCase()+".ccp4";break;default:throw new Error("Unexpected data format shortcut")}return e.fileType=a,e.fileName=s+"."+a,e.sourceType="url",t}var l=wx.exec(t);if(l){var c=l[1].toLowerCase();return t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+c+"/JSON?record_type=3d",e.fileType="pubchem",e.fileName=c+".json",e.sourceType="url",t}return"url"!==e.sourceType&&void 0!==e.sourceType||(e.sourceType="url",Sx.test(t)||(t=Cu.resolveURL(t))),t}(o,a);var e=n.head(qy.loaders.find({type:a.sourceType,source:o}));if(!e)throw new Error("Could not find suitable loader for this source");var r=a.fileName||e.extractName(o);if(r){var i=Cu.splitFileName(r),l=Fu(i,2),c=l[0],u=l[1];n.defaults(a,{name:c,fileExt:u,fileName:r})}!function(t){var e=t.binary;if(void 0!==t.fileType){var r=n.head(qy.parsers.find({format:t.fileType}));if(!r)throw new Error("Could not find suitable parser for this format");e=r.binary||!1}if(void 0===e&&void 0!==t.fileExt){var i=n.head(qy.parsers.find({ext:t.fileExt}));i&&(e=i.binary||!1)}void 0!==t.fileExt&&".man"===t.fileExt.toLowerCase()&&(t.binary=!0,t.animation=!0),void 0!==e&&void 0!==t.binary&&t.binary!==e&&t.context.logger.warn("Overriding incorrect binary mode"),t.binary=e||!1}(a);var h=n.get(a,"preset.expression");if(!n.isUndefined(h)&&(h=JSON.parse(h))&&h.settings)for(var p=["singleUnit","draft.waterBondingHack"],f=0,d=p.length;f0?vx(v.logger,"Fetching",t.loaded/t.total):vx(v.logger,"Fetching")});var y=v.load().then(function(t){return a.context.logger.info("Fetching finished"),s.notify({type:"fetchingFinished",data:t}),t}).catch(function(t){throw a.context.logger.debug(t.message),t.stack&&a.context.logger.debug(t.stack),a.context.logger.error("Fetching failed"),s.notify({type:"fetchingFinished",error:t}),t});t(y)})).then(function(t){return r=t,n=e,o=i,new Promise(function(t,e){if(o.shouldCancel())throw new Error("Operation cancelled");if(o.notify({type:"convert"}),n.mdFile){for(var i=new Array(r.length),a=0;a0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},yx.prototype.rebuild=function(){if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuild"}),this._rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual(function(e){e.needsRebuild()&&t.push(e.rebuild().then(function(){return new Promise(function(t){e.rebuildSelectionGeometry(),t()})}))});var e=this;this._spinner.spin(this._container),Promise.all(t).then(function(){e._spinner.stop(),e._needRender=!0,e._refreshTitle(),e._building=!1})}},yx.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},yx.prototype._refreshTitle=function(t){var e;t=void 0===t?"":t;var r=this._getComplexVisual();if(r){e=r.getComplex().name;var n=r.repGet(r.repCurrent());e+=n?" – "+n.mode.name+" Mode":""}else e=Object.keys(this._visuals).length>0?"Unknown":"No Data";e+=t,this.dispatchEvent({type:"titleChanged",data:e})},yx.prototype.setNeedRender=function(){this._needRender=!0},yx.prototype._extractRepresentation=function(){var t=this,e=[];this._forEachComplexVisual(function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<0&&(this.logger.report("New representation from selection for complexes: "+e.join(", ")),this.dispatchEvent({type:"repAdd"}))},yx.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},yx.prototype.applyPreset=function(t){for(var e=Vu.now.presets,r=[t||Vu.defaults.preset,Vu.defaults.preset,Object.keys(e)[0]],n=null,i=0;!n&&i0&&t.push(e)}),1===t.length){var e=t[0].beginFragmentEdit();e&&(this._editors=[e],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(dx),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},yx.prototype._applyFragmentEdit=function(){if(this._editMode===dx){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new He(0,0,0)}},yx.prototype.resetPivot=function(){var t=new vn;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},yx.prototype.setPivotResidue=function(t){var e=this._getVisualForComplex(t.getChain().getComplex());if(e){var r=this._gfx.pivot.position;if(t._controlPoint)r.copy(t._controlPoint);else{for(var n=0,i=0,o=0,a=t._atoms.length,s=0;s=5&&(e._gfxScore=1e3/r.mean()),t>0&&(e._gfxScore=.5*t),e._spinner.stop(),n()})):n()})},yx.prototype.screenshot=function(t,e){var r,n,i,o=this._gfx;if(e=e||t||o.height,(t=t||o.width)===o.width&&e===o.height)r=o.renderer.domElement.toDataURL("image/png");else{var a=o.camera.aspect,s=o.camera.fov,l=(i=o.camera.fov,Math.tan(ye.degToRad(.5*i)))*Math.min(o.width,o.height)/o.height,c=t/e;o.camera.aspect=c,o.camera.fov=(n=l/Math.min(c,1),2*ye.radToDeg(Math.atan(n))),o.camera.updateProjectionMatrix(),o.renderer.setSize(t,e),this._renderFrame("NONE"),r=o.renderer.domElement.toDataURL("image/png"),o.camera.aspect=a,o.camera.fov=s,o.camera.updateProjectionMatrix(),o.renderer.setSize(o.width,o.height),this._needRender=!0}return r},yx.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);Cu.shotDownload(n,t)},yx.prototype._tweakResolution=function(){var t=[["poor",100],["low",500],["medium",1e3],["high",5e3],["ultra",Number.MAX_VALUE]],e=0;if(this._forEachComplexVisual(function(t){e+=t.getComplex().getAtomCount()}),e>0)for(var r=1e6*this._gfxScore/e,n=0;ni?(a=!1,r.preset="empty"):Vu.now.preset!==Vu.defaults.preset&&(r.preset=Vu.now.preset);for(var s=[],l=!0,c=0,u=i;c0&&(e._objects=s),t.view&&(e.view=this.view()),t.settings){var u=this.settings.getDiffs(!1);n.isEmpty(u)||(e.settings=u)}return e},yx.prototype.get=function(t,e){return Vu.get(t,e)},yx.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*Vu.now.draft.clipPlaneFactor,Vu.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&A.push("'"+this.terminals_[w]+"'");T=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(l+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(T,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(c=p.yyleng,s=p.yytext,l=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],C.$=i[i.length-S],C._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(C._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(C,[s,c,l,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(C.$),o.push(C._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},wt={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 41;case 4:return 34;case 5:return 96;case 6:case 7:return 97;case 8:return 8;case 9:return 6;case 10:return 100;case 11:return 7;case 12:return 9;case 13:return 79;case 14:return 81;case 15:return 12;case 16:return 14;case 17:return 16;case 18:return 17;case 19:return 18;case 20:return 19;case 21:return 82;case 22:return 84;case 23:return 22;case 24:return 24;case 25:return 25;case 26:return 26;case 27:return 29;case 28:return 33;case 29:return 32;case 30:return 85;case 31:return 86;case 32:return 36;case 33:return 40;case 34:return 42;case 35:return 51;case 36:return 53;case 37:return 54;case 38:return 44;case 39:return 46;case 40:return 43;case 41:return 55;case 42:return 57;case 43:return 58;case 44:return 61;case 45:return 62;case 46:return 63;case 47:return 65;case 48:return 66;case 49:return 67;case 50:return 68;case 51:return 69;case 52:return 70;case 53:return 71;case 54:return 73;case 55:return 72;case 56:case 57:return 90;case 58:case 59:return 91;case 60:case 61:case 62:return 93;case 63:return 30;case 64:return 35;case 65:return 77;case 66:return 74;case 67:return 78;case 68:return 76;case 69:return e.yytext=e.yytext.substr(1,e.yyleng-2),13;case 70:return 37;case 71:return 5;case 72:return 102;case 73:return 103;case 74:return"\\";case 75:return 27;case 76:return 59;case 77:return 28;case 78:return 56;case 79:return 75}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],inclusive:!0}}};function St(){this.yy={}}return bt.lexer=wt,St.prototype=bt,bt.Parser=St,new St}();void 0!==e&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=$h.readFileSync(Kh.normalize(t[1]),"utf8");return r.parser.parse(e)},e.main===t&&r.main(process.argv.slice(1)))}),Ax=Mx.parser,Ex=(Mx.Parser,Mx.parse,Mx.main,{$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = #aromatic radius"," atom = #atom radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},CA:{$help:[" Cartoon"," arrow = #arrow size"," depth = #depth of surface"," heightSegmentsRatio = "," radius = #tube radius"," tension = #"," width = #secondary width\n"]},LN:{$help:[" Lines"," atom = #atom radius"," chunkarom = "," multibond = #use multibond"," showarom = #show aromatic"," offsarom = \n"]},LC:{$help:[" Licorice"," aromrad = #aromatic radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = "," radius = #tube radius"," tension = \n"]},SA:{$help:[" Surface"," zClip = #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = "," scale = "," wireframe = "," zClip = #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = #clip z plane\n"]},TX:{$help:[" Text mode",' template = string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = {"left", "right", "center"}',' verticalAlign = {"top", "bottom", "middle"}'," dx = #offset along x"," dy = #offset along y"," dz = #offset along z"," fg = #text color modificator"," could be keyword, named color or hex"," fg = #back color modificator"," could be keyword, named color or hex"," showBg = #if set show background"," plate under text"]}}),Cx={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = #RGB->HEX->dec\n"],color:{$help:Object.keys(qg.get(Vu.now.palette).namedColors).sort().join("\n")}}},Tx={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Px={$help:["Short (packed) representation description as a set of variables"," s="," selector property"," m=[!:[,...]]"," render mode property"," c=[!:[,...]]"," color mode property"," mt="," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Ex,c:Cx,mt:Tx},Lx={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Ex,colorers:Cx},Rx={$help:["help (| )","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (||-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [] []"," Add new item to representation set with"," default or params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Px},rep:{$help:["rep [|] []"," set current representation by name or index"," edit current representation by "],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Px},remove:{$help:["remove (|)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector "," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode [=...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Ex},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Cx},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Tx},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:Lx},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:Lx},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset []","Reset current representation or set preset to "],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit []","Change current biological structure view. Zero value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view []","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [] [(x|y|z) []]...","Rotate scene"]},scale:{$help:["scale ","Scale scene"]},select:{$help:["select [as ]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within of as ","Build within named selector"," DISTANCE "," SELECTOR_STRING "," SELECTOR_NAME "]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [ []]","Make a screenshot of the scene"," WIDTH in pixels"," HEIGHT in pixels, equal to WIDTH by default"]},line:{$help:["line [=]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj ","Remove scene object by its index. Indices could be obtained by command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]},file_list:{$help:["file_list [(|FILE_NAME)] [-f=]","Report registered files on server or presets in file if defined FILE_ID or FILE_NAME"," also you can use -f flag for fast search"," entity by starting part of name"]},file_register:{$help:["file_register ","Try register current opened file to server"]},file_delete:{$help:["file_delete (|FILE_NAME) [-f]","Delete file from server"," if -f not set then file will be deleted"," only when it has not got any presets in it"," if -f set then file will be deleted anyway"]},preset_add:{$help:["preset_add ","Create new preset from current viewer state"," to current opened file on server"]},preset_delete:{$help:["preset_delete (|)","Delete preset from server"]},preset_update:{$help:["preset_update <(|)","Update due the current viewer state"]},preset_rename:{$help:["preset_rename (|) ","Rename preset"]},preset_open:{$help:["preset_open (|)","Load preset"]},create_scenario:{$help:["create_scenario "," Creates scenario context for future work with them"]},reset_scenario:{$help:["reset_scenario"," Clear current scenario context"]},add_scenario_item:{$help:["add_scenario_item"," pdb=( | )"," prst=(|)"," delay="," desc=\n"," Add item to context and update scenario on server"," Pay attention that order of arguments is important"]},delete_scenario:{$help:["delete_scenario (|)"," Deletes scenario from server"]},list_scenario:{$help:["list_scenario [-e [|]]"," Report scenario list, when -e is set reports expanded"," If set -e then reports only requested scenario"]}};function Nx(t){var e=gp.keyword(t[0]);if(!e||!e.SelectorClass)return null;var r=null,n=e.SelectorClass.prototype;return n instanceof gp.PrefixOperator&&2===t.length?r=e(Nx(t[1])):n instanceof gp.InfixOperator&&3===t.length?r=e(Nx(t[1]),Nx(t[2])):n instanceof gp.RangeListSelector&&2===t.length?r=e(function(t){for(var e,r=[],n=0;n"},Gx.prototype.add=function(t,e){if(void 0!==e){if(this.representationMap.hasOwnProperty(t))return"This name has already existed, registered without name";this.representationMap[t.toString()]=e,this.representationID[e]=t.toString()}return"Representation "+t+" successfully added"},Gx.prototype.remove=function(t){t&&this.representationID.hasOwnProperty(t)&&(delete this.representationMap[this.representationID[t]],delete this.representationID[t]);var e=Object.keys(this.representationID).sort();for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];n>t&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}},Gx.prototype.clear=function(){this.representationMap={},this.representationID={}};var Wx=new Gx;function Hx(){}Hx.prototype.list=function(t,e,r){var n="";if(t&&void 0!==e&&(void 0===r||"-e"===r))for(var i=t.repCount(),o=0;o"===s?"":s)+"\n",void 0!==n&&(i+=' selection : "'+c+'"\n',i+=" mode : ("+l.id+"), "+l.name+"\n",i+=" colorer : ("+u.id+"), "+u.name+"\n",i+=" material : ("+h.id+"), "+h.name+"\n"),i},Hx.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},Hx.prototype.listObjs=function(t){var e=t._objects;if(!e||!Array.isArray(e)||0===e.length)return"There are no objects on the scene";for(var r=[],n=0,i=e.length;n0)throw{message:t+' must be a "'+Ru(n.get(Bx.defaults,t))+'"'};if("theme"===t){for(var o=Object.keys(Bx.defaults.themes),a=!1,s=0;s1?(void 0!==i&&i("There are two or more files, please specify one by file_id"),o.finish(t)):void 0!==r?r(s[0].id):o.finish(t)}else o.finish(t)},function(e){void 0!==e&&void 0!==i&&i(e),o.finish(t)})},Zx.prototype.requestPdbID=function(t,e,r,n){var i=this;var o=e.split("/");if(t.awaitWhileCMDisInProcess(),1!==o.length)void 0!==n&&n("Path can contain only file name or id"),i.finish(t);else{var a=Number(o[0]);Number.isNaN(a)?t.srvTopologyFind(o[0],function(e){e instanceof Array?e.length<1?(void 0!==n&&n("File not found"),i.finish(t)):e.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(e[0].id):i.finish(t):i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)}):r(a)}},Zx.prototype.requestPresetId=function(t,e,r,i){var o=this,a=e.split("/");function s(e){void 0!==e&&void 0!==i&&i(e),o.finish(t)}function l(e){if(e instanceof Array){var s=n.filter(e,function(t){return t.name.toLowerCase()===a[1].toLowerCase()||t.id===Number(a[1])});s.length<1?(void 0!==i&&i("Preset not found"),o.finish(t)):s.length>1?(void 0!==i&&i("There are two or more presets, please specify one by preset_id"),o.finish(t)):void 0!==r?r(s[0].id):o.finish(t)}else o.finish(t)}t.awaitWhileCMDisInProcess(),2!==a.length?(void 0!==i&&i("Path can has 2 levels only (pdb/preset)"),o.finish(t)):this.requestPdbID(t,a[0],function(e){t.srvPresetList(e,l,s)},s)},Zx.prototype.createScenario=function(t){this.scenarioContext=new qx(t)},Zx.prototype.resetScenario=function(){this.scenarioContext=new qx},Zx.prototype.deleteScenario=function(t,e,r,n){var i=this;function o(r){void 0!==r&&e(r),i.finish(t)}function a(e){void 0!==e&&r(e),i.finish(t)}function s(e){t.srvScenarioDelete(e,o,a),i.finish(t)}this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?s(n):this.requestScenarioID(t,n,s,a)},Zx.prototype.listScenario=function(t,e,r,n){var i=this;this.init(t,e),t.awaitWhileCMDisInProcess(),t.srvScenarioList(function(r){if(r instanceof Array){for(var o="",a=0,s=r.length;a"),void i.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void i.finish(t)):(r("internal interpreter error"),void i.finish(t));var l,c,u,h,p=arguments[3],f=arguments[4],d=arguments[5],m=arguments[6];if(n.isString(p))this.requestPdbID(t,p,function(t){t>=0&&(o[3]=t,i.addScenarioItem.apply(i,o))},s);else if(n.isString(f))this.requestPresetId(t,p+"/"+f,function(t){t>=0&&(o[4]=t,i.addScenarioItem.apply(i,o))},s);else{if("number"!=typeof p||"number"!=typeof f)return s("Internal error"),void i.finish(t);l=p,c=f,u=d,h=m,i.scenarioContext.script.addItem(i.scenarioContext.id,new function(t,e,r,n){return this.pdbId=-1,this.presetId=-1,this.delay=-1,this.description="",void 0!==t&&(this.pdbId=t),void 0!==e&&(this.presetId=e),void 0!==r&&(this.delay=r),void 0!==n&&(this.description=n),this}(l,c,u,h)),t.srvScenarioAdd(i.scenarioContext.id,i.scenarioContext.name,JSON.stringify(i.scenarioContext.script),a,s)}},Zx.prototype.init=function(t,e){var r=this;this.isOnApllyPresetEventInitialized||(t.addEventListener("presetApplyFinished",function(){r.finish(t),void 0!==e&&e("Preset applied")}),this.isOnApllyPresetEventInitialized=!0)},Zx.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},Zx.prototype.fileList=function(t,e,r,n,i){var o=this;function a(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),s.finish(t)):void 0===a?o.call(t,i[0].id,c,h):o.call(t,i[0].id,a,c,h)}else s.finish(t)}function h(e){void 0!==e&&r(e),s.finish(t)}2!==l.length?(r("Path can has 2 levels only (pdb/preset)"),s.finish(t)):t.srvTopologyFind(l[0],function(e){e instanceof Array?e.length<1?(r("File not found"),s.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),s.finish(t)):t.srvPresetList(e[0].id,u,h):s.finish(t)},h)},Zx.prototype.coroutineWithFileName=function(t,e,r,n,i){var o=this,a=arguments;this.init(t),t.awaitWhileCMDisInProcess();var s=n.split("/");function l(r){void 0!==r&&e(r),o.finish(t)}function c(e){void 0!==e&&r(e),o.finish(t)}1!==s.length?(r("Path can contain only file name or id"),o.finish(t)):t.srvTopologyFind(s[0],function(e){if(e instanceof Array)if(e.length<1)r("File not found");else if(e.length>1)r("There are two or more files, please specify one by file_id");else switch(a.length){case 5:i.call(t,e[0].id,l,c);break;case 6:i.call(t,e[0].id,a[5],l,c);break;case 9:i.call(a[5],a[6],a[7],a[8],e[0].id);break;case 10:i.call(a[5],a[6],a[7],a[8],e[0].id,a[9]);break;default:o.finish(t)}o.finish(t)},c)};var $x=new Zx;function Kx(t){var e={s:"selector",m:"mode",c:"colorer",mt:"material",mode:"modes",color:"colorers",colorer:"colorers",select:"selector",material:"materials",selector:"selector"}[t];return void 0===e?t:e}function Qx(t){if(t instanceof this.constructor)return t;t instanceof Array?this._values=t.slice(0):this._values=t?[t]:[]}Qx.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},Qx.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},Qx.prototype.toJSO=function(t,e,r){for(var i={},o=this._values,a=0,s=o.length;a0},yx.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={success:!1};try{Ax.parse(t),e.success=!0}catch(t){e.error=t.message,Ax.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},yx.JSONConverter=Ix,Ax.yy=Jx,Ax.yy.parseError=Ax.parseError,yx}); //# sourceMappingURL=Miew.min.js.map diff --git a/dist/Miew.module.js b/dist/Miew.module.js index 02d6a84e..a7683d54 100644 --- a/dist/Miew.module.js +++ b/dist/Miew.module.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.10 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.11 Copyright (c) 2015-2018 EPAM Systems, Inc. */ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -62047,12 +62047,17 @@ function getUrlParametersAsDict(url) { function resolveURL(str) { if (typeof URL !== 'undefined') { - if (typeof window !== 'undefined') { - return new URL(str, window.location).href; - } else { - return new URL(str).href; + try { + if (typeof window !== 'undefined') { + return new URL(str, window.location).href; + } else { + return new URL(str).href; + } + } catch (error) { + // IE 11 has a URL object with no constructor available so just try a different approach instead } - } else if (typeof document !== 'undefined') { + } + if (typeof document !== 'undefined') { var anchor = document.createElement('a'); anchor.href = str; return anchor.href; @@ -62081,7 +62086,7 @@ function generateRegExp(symbolStr) { //////////////////////////////////////////////////////////////////////////// // Create HTML element -function createElement$2(tag, attrs, content) { +function createElement(tag, attrs, content) { var element = document.createElement(tag); var i, n; if (attrs) { @@ -62435,7 +62440,7 @@ var utils = { getUrlParametersAsDict: getUrlParametersAsDict, resolveURL: resolveURL, generateRegExp: generateRegExp, - createElement: createElement$2, + createElement: createElement, deriveClass: deriveClass, deriveDeep: deriveDeep, hexColor: hexColor, @@ -64182,7 +64187,7 @@ Element.getByName = function (element) { * @exports Atom * @constructor */ -function Atom$1(residue, name, type, position, role, het, serial, location, occupancy, temperature, charge) { +function Atom(residue, name, type, position, role, het, serial, location, occupancy, temperature, charge) { this._index = -1; this._residue = residue; if (name instanceof AtomName) { @@ -64212,9 +64217,9 @@ function Atom$1(residue, name, type, position, role, het, serial, location, occu this.flags = 0x0000; if (type.name === 'H') { - this.flags |= Atom$1.Flags.HYDROGEN; + this.flags |= Atom.Flags.HYDROGEN; } else if (type.name === 'C') { - this.flags |= Atom$1.Flags.CARBON; + this.flags |= Atom.Flags.CARBON; } } @@ -64224,7 +64229,7 @@ function Atom$1(residue, name, type, position, role, het, serial, location, occu * @enum {number} * @readonly */ -Atom$1.Flags = { +Atom.Flags = { CARBON: 0x0001, // OXYGEN: 0x0002, // NITROGEN: 0x0004, @@ -64237,39 +64242,39 @@ Atom$1.Flags = { * Get atom full name. * @returns {AtomName} Atom full name. */ -Atom$1.prototype.getName = function () { +Atom.prototype.getName = function () { return this._name; }; -Atom$1.prototype.getPosition = function () { +Atom.prototype.getPosition = function () { return this._position; }; -Atom$1.prototype.getResidue = function () { +Atom.prototype.getResidue = function () { return this._residue; }; -Atom$1.prototype.getSerial = function () { +Atom.prototype.getSerial = function () { return this._serial; }; -Atom$1.prototype.getBonds = function () { +Atom.prototype.getBonds = function () { return this._bonds; }; -Atom$1.prototype.isHet = function () { +Atom.prototype.isHet = function () { return this._het; }; -Atom$1.prototype.isHydrogen = function () { +Atom.prototype.isHydrogen = function () { return this.element.number === 1; }; -Atom$1.prototype.getValence = function () { +Atom.prototype.getValence = function () { return this._valence === -1 ? 0 : this._valence; }; -Atom$1.prototype.getVisualName = function () { +Atom.prototype.getVisualName = function () { var name = this.getName(); if (name.getString().length > 0) { return name.getString(); @@ -64278,7 +64283,7 @@ Atom$1.prototype.getVisualName = function () { } }; -Atom$1.prototype.forEachBond = function (process) { +Atom.prototype.forEachBond = function (process) { var bonds = this._bonds; for (var i = 0, n = bonds.length; i < n; ++i) { process(bonds[i]); @@ -64286,7 +64291,7 @@ Atom$1.prototype.forEachBond = function (process) { }; /** @deprecated Old-fashioned atom labels, to be removed in the next major version. */ -Atom$1.prototype.isLabelVisible = function () { +Atom.prototype.isLabelVisible = function () { if (this.getName().getNode() !== null) { return true; } @@ -64306,7 +64311,7 @@ Atom$1.prototype.isLabelVisible = function () { return true; }; -Atom$1.prototype.getHydrogenCountBoron = function () { +Atom.prototype.getHydrogenCountBoron = function () { //examples //BH3*BH4(1-)*BH2(1+)*BH3(2-)*BH(2+) var valence = 3; //hardcoded as 3 @@ -64314,7 +64319,7 @@ Atom$1.prototype.getHydrogenCountBoron = function () { return Math.max(0, hc); }; -Atom$1.prototype.getHydrogenCountTin = function () { +Atom.prototype.getHydrogenCountTin = function () { var valence = this._valence; if (valence === -1) { valence = this.getAtomBondsCount() - Math.abs(this.getCharge()) + this._radicalCount; @@ -64328,11 +64333,11 @@ Atom$1.prototype.getHydrogenCountTin = function () { return Math.max(0, defVal - valence); }; -Atom$1.prototype.getHydrogenCountMetal = function () { +Atom.prototype.getHydrogenCountMetal = function () { return 0; }; -Atom$1.prototype.getHydrogenCountGroup14 = function () { +Atom.prototype.getHydrogenCountGroup14 = function () { var valence = this._valence; if (valence === -1) { valence = this.getAtomBondsCount() - Math.abs(this.getCharge()) + this._radicalCount; @@ -64343,7 +64348,7 @@ Atom$1.prototype.getHydrogenCountGroup14 = function () { return Math.max(0, defVal - valence); }; -Atom$1.prototype.getHydrogenCountNonMetal = function () { +Atom.prototype.getHydrogenCountNonMetal = function () { // apply from Reaxys Drawing Guidelines (Version 2.04 // January 2012) Standard Valence – (Valence + Charge + Number of Radical(s)) var valence = this._valence; @@ -64356,7 +64361,7 @@ Atom$1.prototype.getHydrogenCountNonMetal = function () { return Math.max(0, defVal - valence); }; -Atom$1.prototype.getHydrogenCountHydrogen = function () { +Atom.prototype.getHydrogenCountHydrogen = function () { if (this.getAtomBondsCount() === 0 && this.getCharge() === 0 && this.getValence() === 0 && this._radicalCount === 0) { return 1; } @@ -64364,7 +64369,7 @@ Atom$1.prototype.getHydrogenCountHydrogen = function () { return 0; }; -Atom$1.prototype.getHydrogenCount = function () { +Atom.prototype.getHydrogenCount = function () { if (this._hydrogenCount >= 0) { return this._hydrogenCount; } @@ -64431,7 +64436,7 @@ function getCylinderCount(bondOrder) { return bondOrder < 2 ? 1 : bondOrder; } -Atom$1.prototype.getAtomBondsCount = function () { +Atom.prototype.getAtomBondsCount = function () { var explicitBonds = this.getBonds(); var ebCount = 0; for (var i = 0; i < explicitBonds.length; i++) { @@ -64440,7 +64445,7 @@ Atom$1.prototype.getAtomBondsCount = function () { return ebCount; }; -Atom$1.prototype.findSuitableValence = function (valence) { +Atom.prototype.findSuitableValence = function (valence) { var val = this.element.hydrogenValency; var defVal = val[val.length - 1]; for (var i = 0; i < val.length; i++) { @@ -64452,15 +64457,15 @@ Atom$1.prototype.findSuitableValence = function (valence) { return defVal; }; -Atom$1.prototype.getCharge = function () { +Atom.prototype.getCharge = function () { return this._charge; }; -Atom$1.prototype.getLocation = function () { +Atom.prototype.getLocation = function () { return this._location; }; -Atom$1.prototype.getFullName = function () { +Atom.prototype.getFullName = function () { var name = ''; if (this._residue !== null) { if (this._residue._chain !== null) { @@ -64865,7 +64870,7 @@ var cCylinderTarget = [{ * @exports Residue * @constructor */ -function Residue$1(chain, type, sequence, icode) { +function Residue(chain, type, sequence, icode) { this._chain = chain; this._component = null; this._type = type; @@ -64890,34 +64895,34 @@ function Residue$1(chain, type, sequence, icode) { } // Getters and setters -Residue$1.prototype.getChain = function () { +Residue.prototype.getChain = function () { return this._chain; }; -Residue$1.prototype.getMolecule = function () { +Residue.prototype.getMolecule = function () { return this._molecule; }; -Residue$1.prototype.getType = function () { +Residue.prototype.getType = function () { return this._type; }; -Residue$1.prototype.getSequence = function () { +Residue.prototype.getSequence = function () { return this._sequence; }; -Residue$1.prototype.getSecondary = function () { +Residue.prototype.getSecondary = function () { return this._secondary; }; -Residue$1.prototype.getICode = function () { +Residue.prototype.getICode = function () { return this._icode; }; // Other methods -Residue$1.prototype.addAtom = function (name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge) { - var atom = new Atom$1(this, name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge); +Residue.prototype.addAtom = function (name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge) { + var atom = new Atom(this, name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge); var complex = this._chain.getComplex(); complex.addAtom(atom); this._atoms.push(atom); // TODO: change to range @@ -64925,11 +64930,11 @@ Residue$1.prototype.addAtom = function (name, type, xyz, role, het, serial, altL return atom; }; -Residue$1.prototype.getAtomCount = function () { +Residue.prototype.getAtomCount = function () { return this._atoms.length; }; -Residue$1.prototype.forEachAtom = function (process) { +Residue.prototype.forEachAtom = function (process) { var atoms = this._atoms; for (var i = 0, n = atoms.length; i < n; ++i) { if (process(atoms[i])) { @@ -64938,7 +64943,7 @@ Residue$1.prototype.forEachAtom = function (process) { } }; -Residue$1.prototype._findAtomByName = function (name) { +Residue.prototype._findAtomByName = function (name) { var res = null; this.forEachAtom(function (atom) { if (atom._name._name === name) { @@ -64950,7 +64955,7 @@ Residue$1.prototype._findAtomByName = function (name) { return res; }; -Residue$1.prototype._findFirstAtomInList = function (names) { +Residue.prototype._findFirstAtomInList = function (names) { var res = null; for (var i = 0; i < names.length; ++i) { res = this._findAtomByName(names[i]); @@ -64961,7 +64966,7 @@ Residue$1.prototype._findFirstAtomInList = function (names) { return res; }; -Residue$1.prototype.collectMask = function () { +Residue.prototype.collectMask = function () { var mask = 0xffffffff; var atoms = this._atoms; for (var i = 0, n = atoms.length; i < n; ++i) { @@ -64970,7 +64975,7 @@ Residue$1.prototype.collectMask = function () { this._mask = mask; }; -Residue$1.prototype.getCylinderTargetList = function () { +Residue.prototype.getCylinderTargetList = function () { var type = this._type._name; for (var i = 0, n = cCylinderTarget.length; i < n; ++i) { for (var j = 0, m = cCylinderTarget[i].types.length; j < m; ++j) { @@ -64982,7 +64987,7 @@ Residue$1.prototype.getCylinderTargetList = function () { return null; }; -Residue$1.prototype._detectLeadWing = function (dst, next, getAtomPosition) { +Residue.prototype._detectLeadWing = function (dst, next, getAtomPosition) { var leadAtom = this._findFirstAtomInList(cNucleicControlNames); var wingStart = this._findFirstAtomInList(cNucleicWing1Names); var wingEnd = this._findFirstAtomInList(cNucleicWing2Names); @@ -65013,7 +65018,7 @@ Residue$1.prototype._detectLeadWing = function (dst, next, getAtomPosition) { dst._cylinders = [getAtomPosition(cylSource), getAtomPosition(cylTarget)]; }; -Residue$1.prototype.calcWing = function (prevLeadPos, currLeadPos, prevWingPos, prevWing) { +Residue.prototype.calcWing = function (prevLeadPos, currLeadPos, prevWingPos, prevWing) { var vectorA = currLeadPos.clone().sub(prevLeadPos); var vectorB = prevLeadPos.clone().sub(prevWingPos); vectorB.crossVectors(vectorA, vectorB); @@ -65024,7 +65029,7 @@ Residue$1.prototype.calcWing = function (prevLeadPos, currLeadPos, prevWingPos, return vectorB; }; -Residue$1.prototype._innerFinalize = function (prevRes, prev, nextRes, dst, getAtomPosition) { +Residue.prototype._innerFinalize = function (prevRes, prev, nextRes, dst, getAtomPosition) { var bFirstInChain = prev === null; var lp = getAtomPosition(this._leadAtom); @@ -65044,14 +65049,14 @@ Residue$1.prototype._innerFinalize = function (prevRes, prev, nextRes, dst, getA dst._controlPoint = currLeadPos; }; -Residue$1.prototype._finalize2 = function (prev, next) { +Residue.prototype._finalize2 = function (prev, next) { //Should be called AFTER first finalize this._innerFinalize(prev, prev, next, this, function (atom) { return atom._position; }); }; -Residue$1.prototype.isConnected = function (anotherResidue) { +Residue.prototype.isConnected = function (anotherResidue) { if (this._chain !== anotherResidue._chain) { return false; } @@ -65073,7 +65078,7 @@ Residue$1.prototype.isConnected = function (anotherResidue) { return res; }; -Residue$1.prototype._finalize = function () { +Residue.prototype._finalize = function () { var self = this; this._firstAtom = this._atoms[0]; this._lastAtom = this._atoms[this._atoms.length - 1]; @@ -65120,7 +65125,7 @@ Residue$1.prototype._finalize = function () { * @exports Chain * @constructor */ -function Chain$1(complex, name) { +function Chain(complex, name) { this._complex = complex; this._name = name; this._mask = 1 | 0; @@ -65132,15 +65137,15 @@ function Chain$1(complex, name) { this.maxSequence = Number.NEGATIVE_INFINITY; } -Chain$1.prototype.getComplex = function () { +Chain.prototype.getComplex = function () { return this._complex; }; -Chain$1.prototype.getName = function () { +Chain.prototype.getName = function () { return this._name; }; -Chain$1.prototype.getResidues = function () { +Chain.prototype.getResidues = function () { return this._residues; }; @@ -65150,7 +65155,7 @@ Chain$1.prototype.getResidues = function () { * @param {string} iCode insertion code * @returns {*} Residue or null if not found */ -Chain$1.prototype.findResidue = function (seqNum, iCode) { +Chain.prototype.findResidue = function (seqNum, iCode) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -65163,7 +65168,7 @@ Chain$1.prototype.findResidue = function (seqNum, iCode) { return null; }; -Chain$1.prototype._finalize = function () { +Chain.prototype._finalize = function () { var residues = this._residues; var prev = null; @@ -65187,7 +65192,7 @@ Chain$1.prototype._finalize = function () { } }; -Chain$1.prototype.updateToFrame = function (frameData) { +Chain.prototype.updateToFrame = function (frameData) { var residues = this._residues; var prev = null; var prevData = null; @@ -65216,12 +65221,12 @@ Chain$1.prototype.updateToFrame = function (frameData) { * @param {string} iCode - Insertion code. * @returns {Residue} - Newly created residue instance. */ -Chain$1.prototype.addResidue = function (name, sequence, iCode) { +Chain.prototype.addResidue = function (name, sequence, iCode) { var type = this._complex.getResidueType(name); if (type === null) { type = this._complex.addResidueType(name); } - var residue = new Residue$1(this, type, sequence, iCode); + var residue = new Residue(this, type, sequence, iCode); this._complex.addResidue(residue); this._residues.push(residue); // TODO: change to range @@ -65237,18 +65242,18 @@ Chain$1.prototype.addResidue = function (name, sequence, iCode) { return residue; }; -Chain$1.prototype.getResidueCount = function () { +Chain.prototype.getResidueCount = function () { return this._residues.length; }; -Chain$1.prototype.forEachResidue = function (process) { +Chain.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Chain$1.prototype.collectMask = function () { +Chain.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -65293,7 +65298,7 @@ Helix.prototype.getName = function () { }; Helix.prototype._finalize = function (residueHash, complex) { - if (this._start instanceof Residue$1 && this._end instanceof Residue$1) { + if (this._start instanceof Residue && this._end instanceof Residue) { // no need to convert unified serial numbers to actual references return; } @@ -65360,7 +65365,7 @@ Strand.prototype.getStart = function () { }; Strand.prototype._finalize = function (serialAtomMap, residueHash, complex) { - if (this._start instanceof Residue$1 && this._end instanceof Residue$1) { + if (this._start instanceof Residue && this._end instanceof Residue) { // no need to convert unified serial numbers to actual references return; } @@ -66955,7 +66960,7 @@ defineSelector('PolarH', function (_Selector3) { createClass(PolarHSelector, [{ key: 'includesAtom', value: function includesAtom(atom) { - return (atom.flags & Atom$1.Flags.NONPOLARH) === Atom$1.Flags.HYDROGEN; + return (atom.flags & Atom.Flags.NONPOLARH) === Atom.Flags.HYDROGEN; } }]); return PolarHSelector; @@ -66972,7 +66977,7 @@ defineSelector('NonPolarH', function (_Selector4) { createClass(NonPolarHSelector, [{ key: 'includesAtom', value: function includesAtom(atom) { - return (atom.flags & Atom$1.Flags.NONPOLARH) === Atom$1.Flags.NONPOLARH; + return (atom.flags & Atom.Flags.NONPOLARH) === Atom.Flags.NONPOLARH; } }]); return NonPolarHSelector; @@ -67169,38 +67174,38 @@ defineOperator('Or', 3, function (_InfixOperator2) { ////////////////////////////////////////////////////////////////////////////// -var selectors$1 = Object.create(keywords); +var selectors = Object.create(keywords); // TODO: Provide consistent module exports -selectors$1.Selector = Selector; -selectors$1.RangeListSelector = RangeListSelector; -selectors$1.ValueListSelector = ValueListSelector; -selectors$1.Range = Range; -selectors$1.RangeList = RangeList; -selectors$1.ValueList = ValueList; -selectors$1.PrefixOperator = PrefixOperator; -selectors$1.InfixOperator = InfixOperator; -selectors$1.Context = Object.create({}); - -selectors$1.GetSelector = function (key) { - if (!selectors$1.Context.hasOwnProperty(key)) { +selectors.Selector = Selector; +selectors.RangeListSelector = RangeListSelector; +selectors.ValueListSelector = ValueListSelector; +selectors.Range = Range; +selectors.RangeList = RangeList; +selectors.ValueList = ValueList; +selectors.PrefixOperator = PrefixOperator; +selectors.InfixOperator = InfixOperator; +selectors.Context = Object.create({}); + +selectors.GetSelector = function (key) { + if (!selectors.Context.hasOwnProperty(key)) { var exc = { message: 'selector ' + key + ' is not registered' }; throw exc; } - return selectors$1.Context[key] || NULL_SELECTOR; + return selectors.Context[key] || NULL_SELECTOR; }; -selectors$1.ClearContext = function () { - Object.keys(selectors$1.Context).forEach(function (k) { - delete selectors$1.Context[k]; +selectors.ClearContext = function () { + Object.keys(selectors.Context).forEach(function (k) { + delete selectors.Context[k]; }); }; -selectors$1.keyword = function (key) { +selectors.keyword = function (key) { return keywords[key.toLowerCase()] || keywords.none; }; -selectors$1.parse = function (str) { +selectors.parse = function (str) { var res = {}; try { res.selector = SelectionParser_1.parse(str); @@ -67211,7 +67216,7 @@ selectors$1.parse = function (str) { return res; }; -SelectionParser_1.yy = selectors$1; +SelectionParser_1.yy = selectors; SelectionParser_1.yy.parseError = SelectionParser_1.parseError; // FIXME: workaround for incorrect JISON parser generator for AMD module ////////////////////////////////////////////////////////////////////////////// @@ -67225,7 +67230,7 @@ SelectionParser_1.yy.parseError = SelectionParser_1.parseError; // FIXME: workar */ function BioStructure(complex) { this._complex = complex; - this._selector = selectors$1.keyword('All')(); + this._selector = selectors.keyword('All')(); this._boundaries = { boundingBox: new Box3(), boundingSphere: new Sphere() @@ -67348,9 +67353,9 @@ Assembly.prototype.getTransforms = function () { Assembly.prototype.finalize = function () { if (this.chains.length > 0) { - this._selector = selectors$1.keyword('Chain')(this.chains); + this._selector = selectors.keyword('Chain')(this.chains); } else { - this._selector = selectors$1.keyword('None')(); + this._selector = selectors.keyword('None')(); } }; @@ -67545,7 +67550,7 @@ var cInvalidVal = -1; // 89237 is a large simple number, can be used for pseudo random hash code create var cBigPrime = 89237; -function PairCollection(maxPairsEstimate) { +function AtomPairs(maxPairsEstimate) { var i = 0; this.numPairs = 0; @@ -67563,7 +67568,7 @@ function PairCollection(maxPairsEstimate) { /** * Destroy all pairs memory */ -PairCollection.prototype.destroy = function () { +AtomPairs.prototype.destroy = function () { this.intBuffer = null; this.hashBuffer = null; }; @@ -67573,7 +67578,7 @@ PairCollection.prototype.destroy = function () { * @param {number} indexA - Index of the 1st vertex. * @param {number} indexB - Index of the 2nd vertex. */ -PairCollection.prototype.addPair = function (indexA, indexB) { +AtomPairs.prototype.addPair = function (indexA, indexB) { var ia = indexA < indexB ? indexA : indexB; var ib = indexA > indexB ? indexA : indexB; var codeToAdd = ia + (ib << cMaxNeighbours); @@ -67860,7 +67865,7 @@ AutoBond.prototype._buildInner = function () { this._calcBoundingBox(); var volMap = this._buildGridMap(); - this._pairCollection = new PairCollection(atoms.length * cEstBondsMultiplier); + this._pairCollection = new AtomPairs(atoms.length * cEstBondsMultiplier); this._addExistingPairs(); this._findPairs(volMap); this._addPairs(); @@ -68325,7 +68330,7 @@ Complex.prototype.getAtomByFullname = function (fullName) { * @returns {Chain} - Newly created chain. */ Complex.prototype.addChain = function (name) { - var result = new Chain$1(this, name); + var result = new Chain(this, name); this._chains.push(result); // TODO: keep chains in dictionary with an (ordered?) array of keys return result; }; @@ -68704,7 +68709,7 @@ Complex.prototype.buildChemicalFormula = function () { //now join the same parts var i = formulaParts.length - 1; var j = formulaParts.length - 2; - for (; i >= 0 && j >= 0;) { + while (i >= 0 && j >= 0) { var pi = formulaParts[i]; var pj = formulaParts[j]; if (!(pi.owner instanceof Complex || pi.owner instanceof Component)) { @@ -69005,11 +69010,11 @@ Complex.prototype.finalize = function (opts) { // mark non-polar hydrogens for (i = 0, n = atoms.length; i < n; ++i) { var atom = atoms[i]; - if (atom.flags & Atom$1.Flags.HYDROGEN && atom._bonds.length === 1) { + if (atom.flags & Atom.Flags.HYDROGEN && atom._bonds.length === 1) { var _bond = atom._bonds[0]; var other = _bond._left !== atom && _bond._left || _bond._right; - if (other.flags & Atom$1.Flags.CARBON) { - atom.flags |= Atom$1.Flags.NONPOLARH; + if (other.flags & Atom.Flags.CARBON) { + atom.flags |= Atom.Flags.NONPOLARH; } } } @@ -69082,7 +69087,7 @@ Complex.prototype.markAtoms = function (selector, mask) { var setMask = mask; var clearMask = ~setMask; var count = 0; - var totalSelector = selectors$1.keyword('And')(selector, this.getSelector()); + var totalSelector = selectors.keyword('And')(selector, this.getSelector()); this.forEachAtom(function (atom) { if (totalSelector.includesAtom(atom)) { @@ -69927,7 +69932,7 @@ VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, di * @exports Molecule * @constructor */ -function Molecule$1(complex, name, index) { +function Molecule(complex, name, index) { this._complex = complex; this._name = name || ''; this._residues = []; @@ -69935,30 +69940,30 @@ function Molecule$1(complex, name, index) { this._index = index || -1; // start with 1 } -Molecule$1.prototype.getComplex = function () { +Molecule.prototype.getComplex = function () { return this._complex; }; -Molecule$1.prototype.getName = function () { +Molecule.prototype.getName = function () { return this._name; }; -Molecule$1.prototype.getResidues = function () { +Molecule.prototype.getResidues = function () { return this._residues; }; -Molecule$1.prototype.getIndex = function () { +Molecule.prototype.getIndex = function () { return this._index; }; -Molecule$1.prototype.forEachResidue = function (process) { +Molecule.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Molecule$1.prototype.collectMask = function () { +Molecule.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -69968,13 +69973,13 @@ Molecule$1.prototype.collectMask = function () { }; var chem = { - Atom: Atom$1, + Atom: Atom, Element: Element, AtomName: AtomName, Bond: Bond, - Residue: Residue$1, + Residue: Residue, ResidueType: ResidueType, - Chain: Chain$1, + Chain: Chain, Helix: Helix, Strand: Strand, Sheet: Sheet, @@ -69983,8 +69988,8 @@ var chem = { Complex: Complex, Volume: Volume, VoxelWorld: VoxelWorld, - selectors: selectors$1, - Molecule: Molecule$1 + selectors: selectors, + Molecule: Molecule }; /** @@ -70837,19 +70842,19 @@ CollisionSphere.prototype.raycast = function () { ////////////////////////////////////////////////////////////////////////////// -function CollisionSpheresGeo(count) { +function SphereCollisionGeo(count) { this._objects = new Array(count); this.boundingSphere = null; this.boundingBox = null; } -CollisionSpheresGeo.constructor = CollisionSpheresGeo; +SphereCollisionGeo.constructor = SphereCollisionGeo; -CollisionSpheresGeo.prototype.setSphere = function (idx, position, radius) { +SphereCollisionGeo.prototype.setSphere = function (idx, position, radius) { this._objects[idx] = new CollisionSphere(position, radius); }; -CollisionSpheresGeo.prototype.raycast = function (raycaster, intersects) { +SphereCollisionGeo.prototype.raycast = function (raycaster, intersects) { // TODO raycast with bounding sphere? How to deal with updates? for (var i = 0, n = this._objects.length; i < n; ++i) { var inters = this._objects[i].raycast(raycaster); @@ -70860,7 +70865,7 @@ CollisionSpheresGeo.prototype.raycast = function (raycaster, intersects) { } }; -CollisionSpheresGeo.prototype.computeBoundingBox = function () { +SphereCollisionGeo.prototype.computeBoundingBox = function () { var objects = this._objects; var boundingBox = this.boundingBox; if (boundingBox === null) { @@ -70872,7 +70877,7 @@ CollisionSpheresGeo.prototype.computeBoundingBox = function () { } }; -CollisionSpheresGeo.prototype.computeBoundingSphere = function () { +SphereCollisionGeo.prototype.computeBoundingSphere = function () { this.computeBoundingBox(); var objects = this._objects; var boundingBox = this.boundingBox; @@ -70913,13 +70918,13 @@ function setArrayXYZW(arr, idx, x, y, z, w) { function InstancedSpheresGeometry(spheresCount, sphereComplexity, useZSprites) { InstancedBufferGeometry.call(this); - CollisionSpheresGeo.call(this, spheresCount); + SphereCollisionGeo.call(this, spheresCount); this._sphGeometry = useZSprites ? new PlaneBufferGeometry(2, 2, 1, 1) : new SphereBufferGeometry(1, sphereComplexity * 2, sphereComplexity, 0, Math.PI * 2, 0, Math.PI); this._init(spheresCount, this._sphGeometry); } InstancedSpheresGeometry.prototype = Object.create(InstancedBufferGeometry.prototype); -lodash.mixin(InstancedSpheresGeometry.prototype, CollisionSpheresGeo.prototype); +lodash.mixin(InstancedSpheresGeometry.prototype, SphereCollisionGeo.prototype); InstancedSpheresGeometry.prototype.constructor = InstancedSpheresGeometry; InstancedSpheresGeometry.prototype.setItem = function (itemIdx, itemPos, itemRad) { @@ -70985,14 +70990,14 @@ InstancedSpheresGeometry.prototype._init = function (spheresCount, sphereGeo) { * THREE.BufferGeometry. * @constructor */ -function RaycastableObjectsGeometry() { +function RaycastableBufferGeometry() { BufferGeometry.call(this); } -RaycastableObjectsGeometry.prototype = Object.create(BufferGeometry.prototype); -RaycastableObjectsGeometry.prototype.constructor = RaycastableObjectsGeometry; +RaycastableBufferGeometry.prototype = Object.create(BufferGeometry.prototype); +RaycastableBufferGeometry.prototype.constructor = RaycastableBufferGeometry; -RaycastableObjectsGeometry.prototype.raycast = function () { +RaycastableBufferGeometry.prototype.raycast = function () { // This method was copied from three.js var vA = new Vector3(); var vB = new Vector3(); @@ -71092,7 +71097,7 @@ RaycastableObjectsGeometry.prototype.raycast = function () { }(); var MAX_IDC_16BIT = 65535; -var VEC_SIZE$1 = 3; +var VEC_SIZE = 3; var tmpColor$1 = new Color(); /** @@ -71102,7 +71107,7 @@ var tmpColor$1 = new Color(); * @constructor */ function ChunkedObjectsGeometry(chunkGeo, chunksCount) { - RaycastableObjectsGeometry.call(this); + RaycastableBufferGeometry.call(this); if (this.constructor === ChunkedObjectsGeometry) { throw new Error('Can not instantiate abstract class!'); @@ -71113,7 +71118,7 @@ function ChunkedObjectsGeometry(chunkGeo, chunksCount) { this._init(chunkGeo, chunksCount); } -ChunkedObjectsGeometry.prototype = Object.create(RaycastableObjectsGeometry.prototype); +ChunkedObjectsGeometry.prototype = Object.create(RaycastableBufferGeometry.prototype); ChunkedObjectsGeometry.prototype.constructor = ChunkedObjectsGeometry; ChunkedObjectsGeometry.prototype.startUpdate = function () { @@ -71131,7 +71136,7 @@ ChunkedObjectsGeometry.prototype.setColor = function (chunkIdx, colorVal) { var colors = this._colors; var chunkSize = this._chunkSize; for (var i = chunkIdx * chunkSize, end = i + chunkSize; i < end; ++i) { - var idx = i * VEC_SIZE$1; + var idx = i * VEC_SIZE; colors[idx] = tmpColor$1.r; colors[idx + 1] = tmpColor$1.g; colors[idx + 2] = tmpColor$1.b; @@ -71156,7 +71161,7 @@ ChunkedObjectsGeometry.prototype.setOpacity = function (chunkIndices, value) { ChunkedObjectsGeometry.prototype.raycast = function (raycaster, intersects) { var inters = []; - RaycastableObjectsGeometry.prototype.raycast.call(this, raycaster, inters); + RaycastableBufferGeometry.prototype.raycast.call(this, raycaster, inters); // TODO faceIdx to chunkIdx var facesPerChunk = this._chunkGeo.index.count / 3; for (var i = 0, n = inters.length; i < n; ++i) { @@ -71181,7 +71186,7 @@ ChunkedObjectsGeometry.prototype.getSubset = function (chunkIndices) { var dstNorm = geom._normals; var dstColor = geom._colors; - var chunkSize = this._chunkSize * VEC_SIZE$1; + var chunkSize = this._chunkSize * VEC_SIZE; for (var i = 0, n = chunkIndices.length; i < n; ++i) { var dstPtOffset = i * chunkSize; @@ -71205,9 +71210,9 @@ ChunkedObjectsGeometry.prototype._init = function (chunkGeo, chunksCount) { var use32bitIndex = pointsCount > MAX_IDC_16BIT; var indexSize = chunkIndexSize * chunksCount; var index = this._index = utils.allocateTyped(use32bitIndex ? Uint32Array : Uint16Array, indexSize); - this._positions = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE$1); - this._normals = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE$1); - this._colors = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE$1); + this._positions = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE); + this._normals = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE); + this._colors = utils.allocateTyped(Float32Array, pointsCount * VEC_SIZE); var alpha = this._alpha = utils.allocateTyped(Float32Array, pointsCount); lodash.fill(alpha, 1.0); @@ -71221,31 +71226,31 @@ ChunkedObjectsGeometry.prototype._init = function (chunkGeo, chunksCount) { } this.setIndex(new BufferAttribute(this._index, 1)); - this.addAttribute('position', new BufferAttribute(this._positions, VEC_SIZE$1)); - this.addAttribute('normal', new BufferAttribute(this._normals, VEC_SIZE$1)); - this.addAttribute('color', new BufferAttribute(this._colors, VEC_SIZE$1)); + this.addAttribute('position', new BufferAttribute(this._positions, VEC_SIZE)); + this.addAttribute('normal', new BufferAttribute(this._normals, VEC_SIZE)); + this.addAttribute('color', new BufferAttribute(this._colors, VEC_SIZE)); this.addAttribute('alphaColor', new BufferAttribute(alpha, 1)); }; -var VEC_SIZE = 3; +var VEC_SIZE$1 = 3; function SimpleSpheresGeometry(spheresCount, sphereComplexity) { var sphGeometry = new SphereBufferGeometry(1, sphereComplexity * 2, sphereComplexity, 0, Math.PI * 2, 0, Math.PI); ChunkedObjectsGeometry.call(this, sphGeometry, spheresCount); - CollisionSpheresGeo.call(this, spheresCount); + SphereCollisionGeo.call(this, spheresCount); var normals = this._normals; var geoNormals = sphGeometry.attributes.normal.array; var chunkSize = this._chunkSize; this._chunkPos = this._chunkGeo.attributes.position.array; - this._tmpPositions = utils.allocateTyped(Float32Array, chunkSize * VEC_SIZE); + this._tmpPositions = utils.allocateTyped(Float32Array, chunkSize * VEC_SIZE$1); for (var i = 0; i < spheresCount; ++i) { - normals.set(geoNormals, chunkSize * VEC_SIZE * i); + normals.set(geoNormals, chunkSize * VEC_SIZE$1 * i); } } SimpleSpheresGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); -lodash.mixin(SimpleSpheresGeometry.prototype, CollisionSpheresGeo.prototype); +lodash.mixin(SimpleSpheresGeometry.prototype, SphereCollisionGeo.prototype); SimpleSpheresGeometry.prototype.constructor = SimpleSpheresGeometry; SimpleSpheresGeometry.prototype.setItem = function (itemIdx, itemPos, itemRad) { @@ -71260,7 +71265,7 @@ SimpleSpheresGeometry.prototype.setItem = function (itemIdx, itemPos, itemRad) { tmpPos[idx + 2] = itemPos.z + geoPos[idx + 2] * itemRad; } - this._positions.set(tmpPos, chunkSize * itemIdx * VEC_SIZE); + this._positions.set(tmpPos, chunkSize * itemIdx * VEC_SIZE$1); this.setSphere(itemIdx, itemPos, itemRad); }; @@ -71270,7 +71275,7 @@ var centerPos = new Vector3(); var tmpVector = new Vector3(); var normMtx = new Matrix3(); -function Simple2CCylinderGeometry(instanceCount, polyComplexity) { +function Simple2CCylindersGeometry(instanceCount, polyComplexity) { var cylGeometry = new CylinderBufferGeometry(1, 1, 1.0, Math.max(3, polyComplexity), 2, true); ChunkedObjectsGeometry.call(this, cylGeometry, 2 * instanceCount); @@ -71280,10 +71285,10 @@ function Simple2CCylinderGeometry(instanceCount, polyComplexity) { this._tmpVector = utils.allocateTyped(Float32Array, chunkSize * VEC_SIZE$2); } -Simple2CCylinderGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); -Simple2CCylinderGeometry.prototype.constructor = Simple2CCylinderGeometry; +Simple2CCylindersGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); +Simple2CCylindersGeometry.prototype.constructor = Simple2CCylindersGeometry; -Simple2CCylinderGeometry.prototype.setItem = function (itemIdx, botPos, topPos, itemRad) { +Simple2CCylindersGeometry.prototype.setItem = function (itemIdx, botPos, topPos, itemRad) { var chunkSize = this._chunkSize; var firstOffset = chunkSize * 2 * itemIdx * VEC_SIZE$2; var secondOffset = firstOffset + chunkSize * VEC_SIZE$2; @@ -71326,7 +71331,7 @@ Simple2CCylinderGeometry.prototype.setItem = function (itemIdx, botPos, topPos, this._normals.set(tmpArray, secondOffset); }; -Simple2CCylinderGeometry.prototype.setColor = function (itemIdx, colorVal1, colorVal2) { +Simple2CCylindersGeometry.prototype.setColor = function (itemIdx, colorVal1, colorVal2) { var first = 2 * itemIdx; parentSetColor.call(this, first, colorVal1); @@ -71540,7 +71545,7 @@ function Instanced2CCylindersGeometry(instanceCount, polyComplexity, useZSprites this._cylGeometry = useZSprites ? new PlaneBufferGeometry(2, 2, 1, 1) : new CylinderBufferGeometry$1(1, 1, 1.0, Math.max(3, polyComplexity), 2, openEnded); this._init(instanceCount, this._cylGeometry, this._useZSprites); - this._collisionGeo = new Simple2CCylinderGeometry(instanceCount, 3); + this._collisionGeo = new Simple2CCylindersGeometry(instanceCount, 3); } Instanced2CCylindersGeometry.prototype = Object.create(InstancedBufferGeometry.prototype); @@ -71718,7 +71723,7 @@ function _createExtrudedChunkGeometry(shape, ringsCount) { return geo; } -function ExtrudedObjectsGroup(shape, ringsCount, chunksCount) { +function ExtrudedObjectsGeometry(shape, ringsCount, chunksCount) { var chunkGeo = _createExtrudedChunkGeometry(shape, ringsCount); ChunkedObjectsGeometry.call(this, chunkGeo, chunksCount); this._ringsCount = ringsCount; @@ -71729,10 +71734,10 @@ function ExtrudedObjectsGroup(shape, ringsCount, chunksCount) { } } -ExtrudedObjectsGroup.prototype = Object.create(ChunkedObjectsGeometry.prototype); -ExtrudedObjectsGroup.prototype.constructor = ExtrudedObjectsGroup; +ExtrudedObjectsGeometry.prototype = Object.create(ChunkedObjectsGeometry.prototype); +ExtrudedObjectsGeometry.prototype.constructor = ExtrudedObjectsGeometry; -ExtrudedObjectsGroup.prototype.setItem = function (itemIdx, matrices) { +ExtrudedObjectsGeometry.prototype.setItem = function (itemIdx, matrices) { var shape = this._chunkGeo._positions; var ptsCount = shape.length; var innerPtIdx = 0; @@ -72159,7 +72164,7 @@ var tmpVector$2 = new Vector3(); function TwoColorLinesGeometry(segmentsCount) { LinesGeometry.call(this, segmentsCount * 2); this._init(segmentsCount); - this._collisionGeo = new Simple2CCylinderGeometry(segmentsCount, 3); + this._collisionGeo = new Simple2CCylindersGeometry(segmentsCount, 3); } TwoColorLinesGeometry.prototype = Object.create(LinesGeometry.prototype); @@ -72219,7 +72224,7 @@ var tempPos2 = new Vector3(); function CrossGeometry(chunksCount) { ChunkedLinesGeometry.call(this, chunksCount, vecCount / 2 | 0, false); - this._collisionGeo = new CollisionSpheresGeo(chunksCount); + this._collisionGeo = new SphereCollisionGeo(chunksCount); } CrossGeometry.prototype = Object.create(ChunkedLinesGeometry.prototype); @@ -72269,7 +72274,7 @@ var tmpColor$4 = new Color(); * @constructor */ function IsoSurfaceGeometry(spheresCount, opts) { - RaycastableObjectsGeometry.call(this); + RaycastableBufferGeometry.call(this); this._opts = opts; this.zClip = this._opts.zClip; @@ -72277,7 +72282,7 @@ function IsoSurfaceGeometry(spheresCount, opts) { this._colors = utils.allocateTyped(Float32Array, spheresCount * COLOR_SIZE$2); } -IsoSurfaceGeometry.prototype = Object.create(RaycastableObjectsGeometry.prototype); +IsoSurfaceGeometry.prototype = Object.create(RaycastableBufferGeometry.prototype); IsoSurfaceGeometry.prototype.constructor = IsoSurfaceGeometry; IsoSurfaceGeometry.prototype.setItem = function (chunkIdx, pos, radius) { @@ -75437,9 +75442,9 @@ LabelsGeometry.prototype.getSubset = function () { var geometries = { InstancedSpheresGeometry: InstancedSpheresGeometry, SimpleSpheresGeometry: SimpleSpheresGeometry, - Simple2CCylindersGeometry: Simple2CCylinderGeometry, - Instanced2CCylinderGeometry: Instanced2CCylindersGeometry, - ExtrudedObjectsGeometry: ExtrudedObjectsGroup, + Simple2CCylindersGeometry: Simple2CCylindersGeometry, + Instanced2CCylindersGeometry: Instanced2CCylindersGeometry, + ExtrudedObjectsGeometry: ExtrudedObjectsGeometry, ChunkedLinesGeometry: ChunkedLinesGeometry, TwoColorLinesGeometry: TwoColorLinesGeometry, CrossGeometry: CrossGeometry, @@ -75591,14 +75596,14 @@ TextMesh.prototype.update = function () { var Mesh$3 = UberObject(Mesh); -function ThickLineSegments(geometry, material) { +function ThickLineMesh(geometry, material) { Mesh$3.call(this, geometry, material); } -ThickLineSegments.prototype = Object.create(Mesh$3.prototype); -ThickLineSegments.prototype.constructor = ThickLineSegments; +ThickLineMesh.prototype = Object.create(Mesh$3.prototype); +ThickLineMesh.prototype.constructor = ThickLineMesh; -ThickLineSegments.prototype._onBeforeRender = function (renderer, scene, camera) { +ThickLineMesh.prototype._onBeforeRender = function (renderer, scene, camera) { var material = this.material; if (!material.uberOptions) { return; @@ -75616,7 +75621,7 @@ var meshes = { Line: UberObject(Line), LineSegments: UberObject(LineSegments), Mesh: UberObject(Mesh), - ThickLineMesh: ThickLineSegments + ThickLineMesh: ThickLineMesh }; function setMatParams(params, uniforms) { @@ -75629,7 +75634,7 @@ function setMatParams(params, uniforms) { function _createInstancedCylinders(useZSprites, openEnded) { return { Geometry: function Geometry(a, b) { - return new geometries.Instanced2CCylinderGeometry(a, b, useZSprites, openEnded); + return new geometries.Instanced2CCylindersGeometry(a, b, useZSprites, openEnded); }, Object: meshes.ZSprite, initMaterial: setMatParams({ @@ -75996,14 +76001,14 @@ AtomsSurfaceGroup.prototype._makeGeoArgs = function (selection, mode, _colorer, /* This is a stub class keep it until SAS/SES is refactored */ -function AtomsSurfaceGroup$2(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { +function AtomsSASSESGroupStub(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { AtomsSphereGroup.call(this, geoParams, selection, colorer, mode, transforms, polyComplexity, material); } -AtomsSurfaceGroup$2.prototype = Object.create(AtomsSphereGroup.prototype); -AtomsSurfaceGroup$2.prototype.constructor = AtomsSurfaceGroup$2; +AtomsSASSESGroupStub.prototype = Object.create(AtomsSphereGroup.prototype); +AtomsSASSESGroupStub.prototype.constructor = AtomsSASSESGroupStub; -AtomsSurfaceGroup$2.prototype._makeGeoArgs = function (selection, mode, colorer, _polyComplexity) { +AtomsSASSESGroupStub.prototype._makeGeoArgs = function (selection, mode, colorer, _polyComplexity) { var selectedAtoms = []; var atoms = selection.atoms; var chunks = selection.chunks; @@ -76432,32 +76437,32 @@ NucleicItemGroup.prototype.updateToFrame = function (frameData) { geo.finishUpdate(); }; -function NucleicCylindersItemGroup(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { +function NucleicCylindersGroup(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { this._stickRad = mode.calcStickRadius(); this._geoArgs = [selection.chunks.length, polyComplexity]; NucleicItemGroup.call(this, geoParams, selection, colorer, mode, transforms, polyComplexity, material); } -NucleicCylindersItemGroup.prototype = Object.create(NucleicItemGroup.prototype); -NucleicCylindersItemGroup.prototype.constructor = NucleicCylindersItemGroup; +NucleicCylindersGroup.prototype = Object.create(NucleicItemGroup.prototype); +NucleicCylindersGroup.prototype.constructor = NucleicCylindersGroup; -NucleicCylindersItemGroup.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { +NucleicCylindersGroup.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { var geo = this._geo; geo.setItem(chunkIdx, cyl1, cyl2, this._stickRad); geo.setColor(chunkIdx, color, color); }; -function NucleicCylindersItemGroup$1(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { +function NucleicSpheresGroup(geoParams, selection, colorer, mode, transforms, polyComplexity, material) { this._stickRad = mode.calcStickRadius(); this._geoArgs = [selection.chunks.length * 2, polyComplexity]; NucleicItemGroup.call(this, geoParams, selection, colorer, mode, transforms, polyComplexity, material); } -NucleicCylindersItemGroup$1.prototype = Object.create(NucleicItemGroup.prototype); -NucleicCylindersItemGroup$1.prototype.constructor = NucleicCylindersItemGroup$1; +NucleicSpheresGroup.prototype = Object.create(NucleicItemGroup.prototype); +NucleicSpheresGroup.prototype.constructor = NucleicSpheresGroup; -NucleicCylindersItemGroup$1.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { +NucleicSpheresGroup.prototype._processItem = function (chunkIdx, cyl1, cyl2, color) { var geo = this._geo; var stickRad = this._stickRad; var idx = chunkIdx * 2; @@ -77031,7 +77036,7 @@ function _calcPoints(residues, firstIdx, lastIdx, boundaries) { return { centerPoints: centerPoints, topPoints: topPoints }; } -function MatrixHelper(residues, startIdx, endIdx, segmentsCount, tension, boundaries) { +function CartoonHelper(residues, startIdx, endIdx, segmentsCount, tension, boundaries) { var pointsArrays = _calcPoints(residues, startIdx, endIdx, boundaries); this._topInterp = _buildStructureInterpolator(pointsArrays.topPoints, tension); this._centerInterp = _buildStructureInterpolator(pointsArrays.centerPoints, tension); @@ -77041,7 +77046,7 @@ function MatrixHelper(residues, startIdx, endIdx, segmentsCount, tension, bounda this._segmentsCount = segmentsCount; } -MatrixHelper.prototype.prepareMatrices = function (idx, firstRad, secondRad) { +CartoonHelper.prototype.prepareMatrices = function (idx, firstRad, secondRad) { var mtcCount = this._segmentsCount; var outMtc = new Array(mtcCount); var currRad = new Vector2(0, 0); @@ -77084,7 +77089,7 @@ function _loopThrough(subDiv, residues, segmentsHeight, tension, mode, callback) var boundaries = subDiv[subDivI].boundaries; for (var i = 0, n = subs.length; i < n; ++i) { var idc = [subs[i].start, subs[i].end]; - var matrixHelper = new MatrixHelper(residues, idc[0], idc[1], segmentsHeight, tension, boundaries); + var matrixHelper = new CartoonHelper(residues, idc[0], idc[1], segmentsHeight, tension, boundaries); var prevLast = null; var startIdx = subs[i].start * 2; var endIdx = subs[i].end * 2 + 1; @@ -77560,19 +77565,19 @@ BondsLinesGroup.prototype.updateToFrame = function (frameData) { var groups = { AtomsSphereGroup: AtomsSphereGroup, AtomsSurfaceGroup: AtomsSurfaceGroup, - AtomsSASSESGroup_stub: AtomsSurfaceGroup$2, + AtomsSASSESGroupStub: AtomsSASSESGroupStub, AtomsTextGroup: AtomsTextGroup, AromaticTorusGroup: AromaticTorusGroup, AromaticLinesGroup: AromaticLinesGroup, - NucleicCylindersGroup: NucleicCylindersItemGroup, - NucleicSpheresGroup: NucleicCylindersItemGroup$1, + NucleicCylindersGroup: NucleicCylindersGroup, + NucleicSpheresGroup: NucleicSpheresGroup, ResiduesSubseqGroup: ResiduesSubseqGroup, ResiduesTraceGroup: ResiduesTraceGroup, BondsCylinderGroup: BondsCylinderGroup, BondsLinesGroup: BondsLinesGroup }; -function ComponentsAtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function AtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77601,14 +77606,14 @@ function ComponentsAtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, }); } -ComponentsAtomsProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsAtomsProcessor.prototype.constructor = ComponentsAtomsProcessor; +AtomsProcessor.prototype = Object.create(RCGroup.prototype); +AtomsProcessor.prototype.constructor = AtomsProcessor; -ComponentsAtomsProcessor.prototype._checkAtom = function (atom, mask) { +AtomsProcessor.prototype._checkAtom = function (atom, mask) { return atom._mask & mask; }; -ComponentsAtomsProcessor.prototype.getSubset = function (mask, innerOnly) { +AtomsProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77627,10 +77632,10 @@ ComponentsAtomsProcessor.prototype.getSubset = function (mask, innerOnly) { function OrphanAtomsProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { this._mode = mode; - ComponentsAtomsProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); + AtomsProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); } -OrphanAtomsProcessor.prototype = Object.create(ComponentsAtomsProcessor.prototype); +OrphanAtomsProcessor.prototype = Object.create(AtomsProcessor.prototype); OrphanAtomsProcessor.prototype.constructor = OrphanAtomsProcessor; OrphanAtomsProcessor.prototype._checkAtom = function (atom, mask) { @@ -77651,7 +77656,7 @@ OrphanAtomsProcessor.prototype._checkAtom = function (atom, mask) { return true; }; -function ComponentsResiduesProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function ResiduesProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77680,14 +77685,14 @@ function ComponentsResiduesProcessor(ResidueGroup, geoParams, complex, colorer, }); } -ComponentsResiduesProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsResiduesProcessor.prototype.constructor = ComponentsResiduesProcessor; +ResiduesProcessor.prototype = Object.create(RCGroup.prototype); +ResiduesProcessor.prototype.constructor = ResiduesProcessor; -ComponentsResiduesProcessor.prototype._checkResidue = function (residue, mask) { +ResiduesProcessor.prototype._checkResidue = function (residue, mask) { return residue._mask & mask; }; -ComponentsResiduesProcessor.prototype.getSubset = function (mask, innerOnly) { +ResiduesProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77704,18 +77709,18 @@ ComponentsResiduesProcessor.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -function ComponentNucleicProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { - ComponentsResiduesProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); +function NucleicProcessor(AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { + ResiduesProcessor.call(this, AtomsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material); } -ComponentNucleicProcessor.prototype = Object.create(ComponentsResiduesProcessor.prototype); -ComponentNucleicProcessor.prototype.constructor = ComponentNucleicProcessor; +NucleicProcessor.prototype = Object.create(ResiduesProcessor.prototype); +NucleicProcessor.prototype.constructor = NucleicProcessor; -ComponentNucleicProcessor.prototype._checkResidue = function (residue, mask) { +NucleicProcessor.prototype._checkResidue = function (residue, mask) { return mask & residue._mask && residue._cylinders !== null; }; -function ComponentsSubseqsProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function SubseqsProcessor(ResidueGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77750,10 +77755,10 @@ function ComponentsSubseqsProcessor(ResidueGroup, geoParams, complex, colorer, m }); } -ComponentsSubseqsProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsSubseqsProcessor.prototype.constructor = ComponentsSubseqsProcessor; +SubseqsProcessor.prototype = Object.create(RCGroup.prototype); +SubseqsProcessor.prototype.constructor = SubseqsProcessor; -ComponentsSubseqsProcessor.prototype.getSubset = function (mask, innerOnly) { +SubseqsProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77770,7 +77775,7 @@ ComponentsSubseqsProcessor.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -function ComponentsAtomsProcessor$1(BondsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function BondsProcessor(BondsGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); this._complex = complex; @@ -77801,10 +77806,10 @@ function ComponentsAtomsProcessor$1(BondsGroup, geoParams, complex, colorer, mod }); } -ComponentsAtomsProcessor$1.prototype = Object.create(RCGroup.prototype); -ComponentsAtomsProcessor$1.prototype.constructor = ComponentsAtomsProcessor$1; +BondsProcessor.prototype = Object.create(RCGroup.prototype); +BondsProcessor.prototype.constructor = BondsProcessor; -ComponentsAtomsProcessor$1.prototype.getSubset = function (mask, innerOnly) { +BondsProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77821,7 +77826,7 @@ ComponentsAtomsProcessor$1.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -function ComponentsAromaticProcessor(AromaticGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { +function AromaticProcessor(AromaticGroup, geoParams, complex, colorer, mode, polyComplexity, mask, material) { var self = this; RCGroup.call(self); @@ -77862,10 +77867,10 @@ function ComponentsAromaticProcessor(AromaticGroup, geoParams, complex, colorer, }); } -ComponentsAromaticProcessor.prototype = Object.create(RCGroup.prototype); -ComponentsAromaticProcessor.prototype.constructor = ComponentsAromaticProcessor; +AromaticProcessor.prototype = Object.create(RCGroup.prototype); +AromaticProcessor.prototype.constructor = AromaticProcessor; -ComponentsAromaticProcessor.prototype.getSubset = function (mask, innerOnly) { +AromaticProcessor.prototype.getSubset = function (mask, innerOnly) { var totalSubset = []; var children = this.children; var meshIdx = 0; @@ -77943,13 +77948,13 @@ function SGroupProcessor(AtomsGroup, geoParams, complex, _colorer, _mode, _polyC SGroupProcessor.prototype = Object.create(RCGroup.prototype); var processors = { - Atoms: ComponentsAtomsProcessor, + Atoms: AtomsProcessor, OrphanAtoms: OrphanAtomsProcessor, - Residues: ComponentsResiduesProcessor, - Nucleic: ComponentNucleicProcessor, - Subseqs: ComponentsSubseqsProcessor, - Bonds: ComponentsAtomsProcessor$1, - Aromatic: ComponentsAromaticProcessor, + Residues: ResiduesProcessor, + Nucleic: NucleicProcessor, + Subseqs: SubseqsProcessor, + Bonds: BondsProcessor, + Aromatic: AromaticProcessor, SGroups: SGroupProcessor }; @@ -78033,7 +78038,7 @@ GroupsFactory.ContactSurfaceGeo = function (caps, settings, renderParams) { GroupsFactory.SASSESSurfaceGeo = function (caps, settings, renderParams) { var gfxTriplet = MeshCreator.createSASSES(caps, settings, renderParams); - return _bakeGroup(gfxTriplet, processors.Atoms, groups.AtomsSASSESGroup_stub); + return _bakeGroup(gfxTriplet, processors.Atoms, groups.AtomsSASSESGroupStub); }; GroupsFactory.TextLabelsGeo = function (caps, settings) { @@ -78450,7 +78455,7 @@ CartoonMode.prototype.buildGeometry = function (complex, colorer, mask, material return Mode.prototype.buildGeometry.call(this, complex, colorer, mask, material); }; -var selectors$4 = chem.selectors; +var selectors$2 = chem.selectors; function getRenderParams$1() { return { @@ -78481,7 +78486,7 @@ SurfaceMode.prototype.calcAtomRadius = function (atom) { SurfaceMode.prototype.getVisibilitySelector = function () { var visibilitySelector = null; if (this.opts.subset !== '') { - var res = selectors$4.parse(this.opts.subset); + var res = selectors$2.parse(this.opts.subset); if (!res.error) { visibilitySelector = res.selector; } @@ -78489,18 +78494,18 @@ SurfaceMode.prototype.getVisibilitySelector = function () { return visibilitySelector; }; -function QuickSurfMode(opts) { +function QuickSurfaceMode(opts) { SurfaceMode.call(this, opts); } -utils.deriveClass(QuickSurfMode, SurfaceMode, { +utils.deriveClass(QuickSurfaceMode, SurfaceMode, { id: 'QS', name: 'Quick Surface', shortName: 'Quick Surf', surfaceNames: ['QuickSurfGeo'] }); -QuickSurfMode.prototype.getSurfaceOpts = function () { +QuickSurfaceMode.prototype.getSurfaceOpts = function () { return { useBeads: false, isoValue: this.opts.isoValue, @@ -78568,11 +78573,11 @@ utils.deriveClass(IsoSurfaceSESMode, IsoSurfaceMode, { shortName: 'SES' }); -function ContactSurfMode(opts) { +function ContactSurfaceMode(opts) { SurfaceMode.call(this, opts); } -utils.deriveClass(ContactSurfMode, SurfaceMode, { +utils.deriveClass(ContactSurfaceMode, SurfaceMode, { id: 'CS', name: 'Contact Surface', shortName: 'Contact Surf', @@ -78580,7 +78585,7 @@ utils.deriveClass(ContactSurfMode, SurfaceMode, { surfaceNames: ['ContactSurfaceGeo'] }); -ContactSurfMode.prototype.getSurfaceOpts = function () { +ContactSurfaceMode.prototype.getSurfaceOpts = function () { return { probeRadius: this.opts.probeRadius, radScale: this.opts.polyComplexity[this.settings.now.resolution], @@ -78627,7 +78632,7 @@ TextMode.prototype.getLabelOpts = function () { var modeList = []; var modeDict = {}; -var ag = [LinesMode, LicoriceMode, BallsAndSticksMode, VanDerWaalsMode, TraceMode, TubeMode, CartoonMode, QuickSurfMode, IsoSurfaceSASMode, IsoSurfaceSESMode, ContactSurfMode, TextMode]; +var ag = [LinesMode, LicoriceMode, BallsAndSticksMode, VanDerWaalsMode, TraceMode, TubeMode, CartoonMode, QuickSurfaceMode, IsoSurfaceSASMode, IsoSurfaceSESMode, ContactSurfaceMode, TextMode]; (function (plugins) { for (var i = 0, n = plugins.length; i < n; ++i) { @@ -78827,14 +78832,14 @@ Palette.prototype = { var namedColorsArray = Palette.prototype.namedColorsArray; var namedColors = Palette.prototype.namedColors; -for (var i$1 = 0, length = namedColorsArray.length; i$1 < length; ++i$1) { - var namedColor = namedColorsArray[i$1]; +for (var i = 0, length = namedColorsArray.length; i < length; ++i) { + var namedColor = namedColorsArray[i]; namedColors[namedColor[0]] = namedColor[1]; } -var palette$1 = new Palette('Jmol', 'JM'); +var palette = new Palette('Jmol', 'JM'); -palette$1.colors = [ +palette.colors = [ /* eslint-disable no-magic-numbers */ 0x0000FF, // blue 0x0055FF, // @@ -78856,7 +78861,7 @@ palette$1.colors = [ 0x5500FF]; // DO NOT EDIT MANUALLY! Autogenerated from atom_types.csv by atom_types.py. -palette$1.elementColors = { +palette.elementColors = { /* eslint-disable no-magic-numbers */ H: 0xFFFFFF, D: 0xFFFFC0, @@ -78972,10 +78977,10 @@ palette$1.elementColors = { /* eslint-enable no-magic-numbers */ }; -palette$1.defaultResidueColor = 0xBEA06E; +palette.defaultResidueColor = 0xBEA06E; // DO NOT EDIT MANUALLY! Autogenerated from residue_types.csv by residue_types.py. -palette$1.residueColors = { +palette.residueColors = { /* eslint-disable no-magic-numbers */ 'ALA': 0xC8C8C8, 'ARG': 0x145AFF, @@ -79018,7 +79023,7 @@ palette$1.residueColors = { /* eslint-enable no-magic-numbers */ }; -palette$1.chainColors = [ +palette.chainColors = [ // ' '->0 'A'->1, 'B'->2 0xFFffffff, // ' ' & '0' white // @@ -79051,7 +79056,7 @@ palette$1.chainColors = [ 0xFFB8860B, // darkgoldenrod 0xFFB22222]; -palette$1.secondaryColors = { +palette.secondaryColors = { 'helix': { 1: 0xFF0080, // RH alpha 3: 0x600080, // RH pi @@ -79063,9 +79068,9 @@ palette$1.secondaryColors = { 'rna': 0xFD0162 }; -var palette$2 = new Palette('VMD', 'VM'); +var palette$1 = new Palette('VMD', 'VM'); -palette$2.colors = [ +palette$1.colors = [ /* eslint-disable no-magic-numbers */ 0x0000FF, // blue 0xFF0000, // red @@ -79086,10 +79091,10 @@ palette$2.colors = [ /* eslint-enable no-magic-numbers */ ]; -palette$2.defaultElementColor = 0x804D00; +palette$1.defaultElementColor = 0x804D00; // DO NOT EDIT MANUALLY! Autogenerated from atom_types.csv by atom_types.py. -palette$2.elementColors = { +palette$1.elementColors = { /* eslint-disable no-magic-numbers */ H: 0xFFFFFF, C: 0x40BFBF, @@ -79100,10 +79105,10 @@ palette$2.elementColors = { /* eslint-enable no-magic-numbers */ }; -palette$2.defaultResidueColor = 0x40C0C0; +palette$1.defaultResidueColor = 0x40C0C0; // DO NOT EDIT MANUALLY! Autogenerated from residue_types.csv by residue_types.py. -palette$2.residueColors = { +palette$1.residueColors = { /* eslint-disable no-magic-numbers */ 'ALA': 0x0000FF, 'ARG': 0xFFFFFF, @@ -79146,22 +79151,22 @@ palette$2.residueColors = { /* eslint-enable no-magic-numbers */ }; -palette$2.chainColors = [0xFFFFFF].concat(palette$2.colors); +palette$1.chainColors = [0xFFFFFF].concat(palette$1.colors); -palette$2.secondaryColors = { +palette$1.secondaryColors = { 'helix': { 1: 0xA600A6, 5: 0x0000FF }, 'strand': 0xFFFF00 }; var paletteList = []; var paletteDict = {}; -var ag$2 = [palette$1, palette$2]; +var ag$1 = [palette, palette$1]; -for (var i = 0, n = ag$2.length; i < n; ++i) { - var palette = ag$2[i]; - paletteList.push(palette); - if (palette.id) { - paletteDict[palette.id] = palette; +for (var i$1 = 0, n = ag$1.length; i$1 < n; ++i$1) { + var palette$2 = ag$1[i$1]; + paletteList.push(palette$2); + if (palette$2.id) { + paletteDict[palette$2.id] = palette$2; } } @@ -79386,8 +79391,8 @@ UniformColorer.prototype.getResidueColor = function (_residue, _complex) { */ function ConditionalColorer(opts) { Colorer.call(this, opts); - var parsed = selectors$1.parse(this.opts.subset); - this._subsetCached = parsed.error ? selectors$1.none() : parsed.selector; + var parsed = selectors.parse(this.opts.subset); + this._subsetCached = parsed.error ? selectors.none() : parsed.selector; } utils.deriveClass(ConditionalColorer, Colorer, { @@ -79595,7 +79600,7 @@ MoleculeColorer.prototype.getResidueColor = function (residue, _complex) { */ var colorerList = []; var colorerDict = {}; -var ag$1 = [ElementColorer, ResidueTypeColorer, SequenceColorer, ChainColorer, SecondaryStructureColorer, UniformColorer, ConditionalColorer, ConformationColorer, TemperatureColorer, OccupancyColorer, HydrophobicityColorer, MoleculeColorer]; +var ag$2 = [ElementColorer, ResidueTypeColorer, SequenceColorer, ChainColorer, SecondaryStructureColorer, UniformColorer, ConditionalColorer, ConformationColorer, TemperatureColorer, OccupancyColorer, HydrophobicityColorer, MoleculeColorer]; (function (plugins) { for (var i = 0, n = plugins.length; i < n; ++i) { @@ -79611,7 +79616,7 @@ var ag$1 = [ElementColorer, ResidueTypeColorer, SequenceColorer, ChainColorer, S } } } -})(ag$1); +})(ag$2); // NOTE: workaround for https://github.com/gfranko/amdclean/issues/115 var exports$2 = /** @alias module:gfx/colorers */{ @@ -82516,7 +82521,7 @@ var Helix$2 = chem.Helix; var Sheet$2 = chem.Sheet; var Strand$2 = chem.Strand; var Bond$2 = chem.Bond; -var Molecule$3 = chem.Molecule; +var Molecule$2 = chem.Molecule; var TAG_LENGTH = 6; @@ -82632,7 +82637,7 @@ PDBParser.prototype._finalizeMolecules = function () { var chain = chainDict[name]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$3(this._complex, m._name, i + 1); + var molecule = new Molecule$2(this._complex, m._name, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -83668,8 +83673,8 @@ var mmtf = createCommonjsModule(function (module, exports) { }); var Complex$4 = chem.Complex; -var Chain$3 = chem.Chain; -var Atom$3 = chem.Atom; +var Chain$2 = chem.Chain; +var Atom$2 = chem.Atom; var AtomName$3 = chem.AtomName; var Element$5 = chem.Element; var Helix$3 = chem.Helix; @@ -83677,7 +83682,7 @@ var Sheet$3 = chem.Sheet; var Strand$3 = chem.Strand; var Bond$4 = chem.Bond; var Assembly$3 = chem.Assembly; -var Molecule$4 = chem.Molecule; +var Molecule$3 = chem.Molecule; function ArrayComparator(original) { this._original = Array.from(original); @@ -83761,7 +83766,7 @@ MMTFParser.prototype._onChain = function (chainData) { return; } - var chain = new Chain$3(this._complex, chainData.chainName); + var chain = new Chain$2(this._complex, chainData.chainName); this._complex._chains[chainData.chainIndex] = chain; chain._index = chainData.chainIndex; }; @@ -83792,7 +83797,7 @@ MMTFParser.prototype._onAtom = function (atomData) { } var altLoc = !atomData.altLoc.charCodeAt(0) ? '' : atomData.altLoc; - var atom = new Atom$3(atomData.groupIndex, // we store residue index here to replace it later with actual reference + var atom = new Atom$2(atomData.groupIndex, // we store residue index here to replace it later with actual reference new AtomName$3(atomData.atomName), Element$5.getByName(atomData.element.toUpperCase()), new Vector3(atomData.xCoord, atomData.yCoord, atomData.zCoord), Element$5.Role[atomData.atomName], false, // hetero atoms will be marked later atomData.atomId, altLoc, atomData.occupancy, atomData.bFactor, atomData.formalCharge); @@ -83880,7 +83885,7 @@ MMTFParser.prototype._updateMolecules = function (mmtfData) { var chain = this._complex._chains[chainIndex]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$4(this._complex, entity.description, i + 1); + var molecule = new Molecule$3(this._complex, entity.description, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -84117,7 +84122,7 @@ var Helix$4 = chem.Helix; var Sheet$4 = chem.Sheet; var Strand$4 = chem.Strand; var Assembly$4 = chem.Assembly; -var Molecule$5 = chem.Molecule; +var Molecule$4 = chem.Molecule; var cRequiredAtomFields = ['auth_seq_id', 'Cartn_x', 'Cartn_y', 'Cartn_z', 'label_atom_id']; @@ -84251,7 +84256,7 @@ CIFParser.prototype._extractMolecules = function (complex, complexData) { var molecules = complex.getMolecules(); for (i = 0; i < count; i++) { var molecule = this.molecules[i]; - molecules[i] = new Molecule$5(complex, molecule.name, i + 1); + molecules[i] = new Molecule$4(complex, molecule.name, i + 1); molecules[i]._residues = molecule.residues; } }; @@ -84468,14 +84473,12 @@ CIFParser.prototype._extractConfs = function (complex, helicesData) { var helClass = helClasses[i] || ' '; var struct; // TODO Add turns and strands(!)? - switch (type) { - case 'helix': - var idx = complex._helices.length; - struct = new Helix$4(idx, name, start[0], end[0], helClass, comment, length); - complex.addHelix(struct); - break; - default: - struct = null; + if (type === 'helix') { + var idx = complex._helices.length; + struct = new Helix$4(idx, name, start[0], end[0], helClass, comment, length); + complex.addHelix(struct); + } else { + struct = null; } if (!struct) { continue; @@ -84878,7 +84881,7 @@ CIFParser._parseToObject = function (source) { state = 0; } else { // .................................................................................................. - if (!Number.isNaN(code) && _storeValue(_parseValue()) !== null) { + if (_storeValue(_parseValue()) !== null) { continue; } state = 666; @@ -85040,12 +85043,10 @@ Ccp4Model.prototype.load = function (buffer) { yaxis.multiplyScalar(header.extent[yIndex] - 1); zaxis.multiplyScalar(header.extent[zIndex] - 1); - switch (header.type) { - case 2: - this._data = new Float32Array(buffer, 1024 + header.nsymbt, header.extent[0] * header.extent[1] * header.extent[2]); - break; - default: - throw new Error('CCP4: Unsupported format ' + header.type); + if (header.type === 2) { + this._data = new Float32Array(buffer, 1024 + header.nsymbt, header.extent[0] * header.extent[1] * header.extent[2]); + } else { + throw new Error('CCP4: Unsupported format ' + header.type); } this._bboxSize = new Vector3(xaxis.length(), yaxis.length(), zaxis.length()); @@ -86952,7 +86953,7 @@ function overrideUniforms$1(params) { return uniforms; } -function createOutlineMaterial(params) { +function OutlineMaterial(params) { var settings = { uniforms: overrideUniforms$1(params), vertexShader: vertexShader$1, @@ -86983,7 +86984,7 @@ function overrideUniforms$2(params) { return uniforms; } -function createFXAAMaterial(params) { +function FXAAMaterial(params) { var settings = { uniforms: overrideUniforms$2(params), vertexShader: vertexShader$1, @@ -87103,7 +87104,7 @@ function overrideUniforms$4(params) { return uniforms; } -function createAnaglyphMaterial(params) { +function AnaglyphMaterial(params) { var settings = { uniforms: overrideUniforms$4(params), vertexShader: vertexShader$1, @@ -87424,7 +87425,7 @@ function exportBonds(queue, complex, bondsFileName) { queue.add(bondsFileName, 'TED', false, true); } -function exportAll(complex, reprList, fullReport) { +function fbxExport(complex, reprList, fullReport) { prec = settings.now.fbxprec; window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; function onInitFS(fs) { @@ -87657,21 +87658,21 @@ var WEBVR = function () { return WEBVR; }(); -/* global "0.7.10":false */ +/* global "0.7.11":false */ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -var selectors = chem.selectors; -var Atom = chem.Atom; -var Residue = chem.Residue; -var Chain = chem.Chain; -var Molecule = chem.Molecule; +var selectors$4 = chem.selectors; +var Atom$3 = chem.Atom; +var Residue$2 = chem.Residue; +var Chain$3 = chem.Chain; +var Molecule$5 = chem.Molecule; var EDIT_MODE = { COMPLEX: 0, COMPONENT: 1, FRAGMENT: 2 }; -var createElement = utils.createElement; +var createElement$2 = utils.createElement; function updateFogRange(fog, center, radius) { fog.near = center - radius * settings.now.fogNearFactor; @@ -87721,7 +87722,7 @@ function reportProgress(log, action, percent) { * @exports Miew * @constructor */ -function Miew$1(opts) { +function Miew(opts) { EventDispatcher$1.call(this); this._opts = lodash.merge({ settingsCookie: 'settings', @@ -87795,15 +87796,15 @@ function Miew$1(opts) { } var self = this; - Miew$1.registeredPlugins.forEach(function (plugin) { + Miew.registeredPlugins.forEach(function (plugin) { plugin.call(self); }); } -Miew$1.prototype = Object.create(EventDispatcher$1.prototype); -Miew$1.prototype.constructor = Miew$1; +Miew.prototype = Object.create(EventDispatcher$1.prototype); +Miew.prototype.constructor = Miew; -Miew$1.prototype.getMaxRepresentationCount = function () { +Miew.prototype.getMaxRepresentationCount = function () { return ComplexVisual.NUM_REPRESENTATION_BITS; }; @@ -87813,15 +87814,15 @@ Miew$1.prototype.getMaxRepresentationCount = function () { * @throws Forwards exception raised during initialization. * @see Miew#term */ -Miew$1.prototype.init = function () { +Miew.prototype.init = function () { var container = this._container; var elem = utils.createElement('div', { 'class': 'miew-canvas' }); _setContainerContents(container, elem); this._container = elem; var frag = document.createDocumentFragment(); - frag.appendChild(this._msgMode = createElement('div', { 'class': 'mode-message overlay' }, createElement('p', {}, 'COMPONENT EDIT MODE'))); - frag.appendChild(this._msgAtomInfo = createElement('div', { 'class': 'atom-info overlay' }, createElement('p', {}, ''))); + frag.appendChild(this._msgMode = createElement$2('div', { 'class': 'mode-message overlay' }, createElement$2('p', {}, 'COMPONENT EDIT MODE'))); + frag.appendChild(this._msgAtomInfo = createElement$2('div', { 'class': 'atom-info overlay' }, createElement$2('p', {}, ''))); container.appendChild(frag); if (this._gfx !== null) { @@ -87906,7 +87907,7 @@ Miew$1.prototype.init = function () { * Terminate the viewer completely. * @see Miew#init */ -Miew$1.prototype.term = function () { +Miew.prototype.term = function () { this._showMessage('Viewer has been terminated.'); this._loading.forEach(function (job) { job.cancel(); @@ -87935,7 +87936,7 @@ function _setContainerContents(container, element) { * @param {string} msg - Message to show. * @private */ -Miew$1.prototype._showMessage = function (msg) { +Miew.prototype._showMessage = function (msg) { var element = document.createElement('div'); element.setAttribute('class', 'miew-message'); element.appendChild(document.createElement('p')).appendChild(document.createTextNode(msg)); @@ -87946,7 +87947,7 @@ Miew$1.prototype._showMessage = function (msg) { * Display WebGL canvas inside the viewer container, hiding any message shown. * @private */ -Miew$1.prototype._showCanvas = function () { +Miew.prototype._showCanvas = function () { _setContainerContents(this._container, this._gfx.renderer.domElement); }; @@ -87954,7 +87955,7 @@ Miew$1.prototype._showCanvas = function () { * Initialize WebGL and set 3D scene up. * @private */ -Miew$1.prototype._initGfx = function () { +Miew.prototype._initGfx = function () { var gfx = { width: this._container.clientWidth, height: this._container.clientHeight @@ -88105,7 +88106,7 @@ Miew$1.prototype._initGfx = function () { * Setup event listeners. * @private */ -Miew$1.prototype._initListeners = function () { +Miew.prototype._initListeners = function () { var self = this; window.addEventListener('resize', function _onResize() { self._onResize(); @@ -88116,7 +88117,7 @@ Miew$1.prototype._initListeners = function () { * Try to add numbers to the base name to make it unique among visuals * @private */ -Miew$1.prototype._makeUniqueVisualName = function (baseName) { +Miew.prototype._makeUniqueVisualName = function (baseName) { if (!baseName) { return Math.random().toString(); } @@ -88135,7 +88136,7 @@ Miew$1.prototype._makeUniqueVisualName = function (baseName) { * Add visual to the viewer * @private */ -Miew$1.prototype._addVisual = function (visual) { +Miew.prototype._addVisual = function (visual) { if (!visual) { return null; } @@ -88157,7 +88158,7 @@ Miew$1.prototype._addVisual = function (visual) { * Remove visual from the viewer * @private */ -Miew$1.prototype._removeVisual = function (visual) { +Miew.prototype._removeVisual = function (visual) { var name = ''; var obj = null; if (visual instanceof Visual) { @@ -88186,7 +88187,7 @@ Miew$1.prototype._removeVisual = function (visual) { * Call specified function for each Visual * @private */ -Miew$1.prototype._forEachVisual = function (callback) { +Miew.prototype._forEachVisual = function (callback) { for (var name in this._visuals) { if (this._visuals.hasOwnProperty(name)) { callback(this._visuals[name]); @@ -88198,7 +88199,7 @@ Miew$1.prototype._forEachVisual = function (callback) { * Release (destroy) all visuals in the scene * @private */ -Miew$1.prototype._releaseAllVisuals = function () { +Miew.prototype._releaseAllVisuals = function () { if (!this._gfx || !this._gfx.pivot) { return; } @@ -88216,7 +88217,7 @@ Miew$1.prototype._releaseAllVisuals = function () { * Call specified function for each ComplexVisual * @private */ -Miew$1.prototype._forEachComplexVisual = function (callback) { +Miew.prototype._forEachComplexVisual = function (callback) { if (!this._gfx || !this._gfx.pivot) { return; } @@ -88232,7 +88233,7 @@ Miew$1.prototype._forEachComplexVisual = function (callback) { * Returns ComplexVisual with specified name, or current (if not found), or any, or null * @private */ -Miew$1.prototype._getComplexVisual = function (name) { +Miew.prototype._getComplexVisual = function (name) { name = name || this._curVisualName; var any = null; var named = null; @@ -88249,7 +88250,7 @@ Miew$1.prototype._getComplexVisual = function (name) { * Returns first found VolumeVisual (no more than one should be present actually) * @private */ -Miew$1.prototype._getVolumeVisual = function () { +Miew.prototype._getVolumeVisual = function () { var any = null; this._forEachVisual(function (visual) { if (visual instanceof VolumeVisual) { @@ -88263,7 +88264,7 @@ Miew$1.prototype._getVolumeVisual = function () { * Returns ComplexVisual corresponding to specified complex * @private */ -Miew$1.prototype._getVisualForComplex = function (complex) { +Miew.prototype._getVisualForComplex = function (complex) { if (!complex) { return null; } @@ -88280,14 +88281,14 @@ Miew$1.prototype._getVisualForComplex = function (complex) { /* * Get a list of names of visuals currently shown by the viewer */ -Miew$1.prototype.getVisuals = function () { +Miew.prototype.getVisuals = function () { return Object.keys(this._visuals); }; /* * Get current visual */ -Miew$1.prototype.getCurrentVisual = function () { +Miew.prototype.getCurrentVisual = function () { return this._curVisualName; }; @@ -88295,7 +88296,7 @@ Miew$1.prototype.getCurrentVisual = function () { * Set current visual. * All further operations will be performed on this visual (complex) if not stated otherwise. */ -Miew$1.prototype.setCurrentVisual = function (name) { +Miew.prototype.setCurrentVisual = function (name) { if (!this._visuals[name]) { return; } @@ -88308,7 +88309,7 @@ Miew$1.prototype.setCurrentVisual = function (name) { * Has no effect if already running. * @see Miew#halt */ -Miew$1.prototype.run = function () { +Miew.prototype.run = function () { var _this = this; if (!this._running) { @@ -88332,7 +88333,7 @@ Miew$1.prototype.run = function () { * Will be processed during the next frame. * @see Miew#run */ -Miew$1.prototype.halt = function () { +Miew.prototype.halt = function () { if (this._running) { this._discardComponentEdit(); this._discardFragmentEdit(); @@ -88346,7 +88347,7 @@ Miew$1.prototype.halt = function () { * on hot keys. * @param enabled - start (true) or stop (false) response on hot keys. */ -Miew$1.prototype.enableHotKeys = function (enabled) { +Miew.prototype.enableHotKeys = function (enabled) { this._hotKeysEnabled = enabled; this._objectControls.enableHotkeys(enabled); }; @@ -88355,7 +88356,7 @@ Miew$1.prototype.enableHotKeys = function (enabled) { * Callback which processes window resize. * @private */ -Miew$1.prototype._onResize = function () { +Miew.prototype._onResize = function () { this._needRender = true; var gfx = this._gfx; @@ -88372,7 +88373,7 @@ Miew$1.prototype._onResize = function () { this.dispatchEvent({ type: 'resize' }); }; -Miew$1.prototype._resizeOffscreenBuffers = function (width, height, stereo) { +Miew.prototype._resizeOffscreenBuffers = function (width, height, stereo) { var gfx = this._gfx; stereo = stereo || 'NONE'; var isAnaglyph = stereo === 'NONE' || stereo === 'ANAGLYPH'; @@ -88399,7 +88400,7 @@ Miew$1.prototype._resizeOffscreenBuffers = function (width, height, stereo) { * Callback which processes update/render frames. * @private */ -Miew$1.prototype._onTick = function () { +Miew.prototype._onTick = function () { var _this2 = this; if (this._halting) { @@ -88426,7 +88427,7 @@ Miew$1.prototype._onTick = function () { * 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 () { +Miew.prototype._toggleWebVR = function () { var _mainCamera = new PerspectiveCamera(); var _cameraWasStored = false; @@ -88469,12 +88470,12 @@ Miew$1.prototype._toggleWebVR = function () { }; }(); -Miew$1.prototype._getWebVRDevice = function () { +Miew.prototype._getWebVRDevice = function () { var vr = this._gfx.renderer.vr; return vr && vr.enabled ? vr.getDevice() : null; }; -Miew$1.prototype._getBSphereRadius = function () { +Miew.prototype._getBSphereRadius = function () { // calculate radius that would include all visuals var radius = 0; this._forEachVisual(function (visual) { @@ -88483,7 +88484,7 @@ Miew$1.prototype._getBSphereRadius = function () { return radius * this._objectControls.getScale(); }; -Miew$1.prototype._updateFog = function () { +Miew.prototype._updateFog = function () { var gfx = this._gfx; if (settings.now.fog) { @@ -88498,7 +88499,7 @@ Miew$1.prototype._updateFog = function () { } }; -Miew$1.prototype._onUpdate = function () { +Miew.prototype._onUpdate = function () { if (this.isScriptingCommandAvailable !== undefined && this.isScriptingCommandAvailable() && !this._building) { this.callNextCmd(); @@ -88521,7 +88522,7 @@ Miew$1.prototype._onUpdate = function () { this._updateFog(); }; -Miew$1.prototype._onRender = function () { +Miew.prototype._onRender = function () { var gfx = this._gfx; // update all matrices @@ -88536,9 +88537,9 @@ Miew$1.prototype._onRender = function () { this._renderFrame(settings.now.stereo); }; -Miew$1.prototype._renderFrame = function () { +Miew.prototype._renderFrame = function () { - var _anaglyphMat = new createAnaglyphMaterial(); + var _anaglyphMat = new AnaglyphMaterial(); return function (stereo) { var gfx = this._gfx; @@ -88595,7 +88596,7 @@ Miew$1.prototype._renderFrame = function () { }; }(); -Miew$1.prototype._onThemeChanged = function () { +Miew.prototype._onThemeChanged = function () { var themeRE = /\s*theme-\w+\b/g; return function () { var theme = settings.now.theme; @@ -88613,7 +88614,7 @@ Miew$1.prototype._onThemeChanged = function () { }; }(); -Miew$1.prototype._setUberMaterialValues = function (values) { +Miew.prototype._setUberMaterialValues = function (values) { this._gfx.root.traverse(function (obj) { if ((obj instanceof Mesh || obj instanceof LineSegments || obj instanceof Line) && obj.material instanceof UberMaterial) { obj.material.setValues(values); @@ -88622,7 +88623,7 @@ Miew$1.prototype._setUberMaterialValues = function (values) { }); }; -Miew$1.prototype._renderScene = function () { +Miew.prototype._renderScene = function () { return function (camera, distortion, target) { distortion = distortion || false; target = target || null; @@ -88693,7 +88694,7 @@ Miew$1.prototype._renderScene = function () { }; }(); -Miew$1.prototype._performDistortion = function () { +Miew.prototype._performDistortion = function () { var _scene = new Scene(); var _camera = new OrthographicCamera(-1.0, 1.0, 1.0, -1.0, -500, 1000); @@ -88727,9 +88728,9 @@ Miew$1.prototype._performDistortion = function () { }; }(); -Miew$1.prototype._renderSelection = function () { +Miew.prototype._renderSelection = function () { - var _outlineMaterial = new createOutlineMaterial(); + var _outlineMaterial = new OutlineMaterial(); return function (camera, srcBuffer, targetBuffer) { @@ -88760,7 +88761,7 @@ Miew$1.prototype._renderSelection = function () { }; }(); -Miew$1.prototype._checkVolumeRenderingSupport = function (renderTarget) { +Miew.prototype._checkVolumeRenderingSupport = function (renderTarget) { if (!renderTarget) { return false; } @@ -88780,7 +88781,7 @@ Miew$1.prototype._checkVolumeRenderingSupport = function (renderTarget) { } }; -Miew$1.prototype._renderVolume = function () { +Miew.prototype._renderVolume = function () { var volumeBFMat = new VolumeMaterial$1.BackFacePosMaterial(); var volumeFFMat = new VolumeMaterial$1.FrontFacePosMaterial(); @@ -88853,7 +88854,7 @@ Miew$1.prototype._renderVolume = function () { * 2. Realization doesn't use camera layers because scene traversing is used for material changes and * we can use it to select needed meshes and don't complicate meshes builders with layers */ -Miew$1.prototype._renderWithPrepassTransparency = function () { +Miew.prototype._renderWithPrepassTransparency = function () { return function (camera, targetBuffer) { var gfx = this._gfx; @@ -88877,9 +88878,9 @@ Miew$1.prototype._renderWithPrepassTransparency = function () { }; }(); -Miew$1.prototype._performFXAA = function () { +Miew.prototype._performFXAA = function () { - var _fxaaMaterial = new createFXAAMaterial(); + var _fxaaMaterial = new FXAAMaterial(); return function (srcBuffer, targetBuffer) { @@ -88902,7 +88903,7 @@ Miew$1.prototype._performFXAA = function () { }; }(); -Miew$1.prototype._performAO = function () { +Miew.prototype._performAO = function () { var _aoMaterial = new ao.AOMaterial(); var _horBlurMaterial = new ao.HorBilateralBlurMaterial(); @@ -88983,7 +88984,7 @@ Miew$1.prototype._performAO = function () { * Reset the viewer, unload molecules. * @param {boolean=} keepReps - Keep representations while resetting viewer state. */ -Miew$1.prototype.reset = function () /* keepReps */{ +Miew.prototype.reset = function () /* keepReps */{ if (this._picker) { this._picker.reset(); } @@ -89003,7 +89004,7 @@ Miew$1.prototype.reset = function () /* keepReps */{ this.setNeedRender(); }; -Miew$1.prototype._resetScene = function () { +Miew.prototype._resetScene = function () { this._objectControls.reset(); this._objectControls.allowTranslation(true); this._objectControls.allowAltObjFreeRotation(true); @@ -89012,7 +89013,7 @@ Miew$1.prototype._resetScene = function () { this.rebuildAll(); }; -Miew$1.prototype.resetView = function () { +Miew.prototype.resetView = function () { // reset controls if (this._picker) { this._picker.reset(); @@ -89037,7 +89038,7 @@ Miew$1.prototype.resetView = function () { * @param {boolean=} opts.keepRepsInfo - prevent reset of object and reps information. * @returns {Promise} name of the visual that was added to the viewer */ -Miew$1.prototype.load = function (source, opts) { +Miew.prototype.load = function (source, opts) { var _this3 = this; opts = lodash.merge({}, opts, { @@ -89100,12 +89101,12 @@ Miew$1.prototype.load = function (source, opts) { * Unload molecule (delete corresponding visual). * @param {string=} name - name of the visual */ -Miew$1.prototype.unload = function (name) { +Miew.prototype.unload = function (name) { this._removeVisual(name || this.getCurrentVisual()); this.resetPivot(); }; -Miew$1.prototype._startAnimation = function (fileData) { +Miew.prototype._startAnimation = function (fileData) { this._stopAnimation(); var self = this; var visual = this._getComplexVisual(); @@ -89136,7 +89137,7 @@ Miew$1.prototype._startAnimation = function (fileData) { this._continueAnimation(); }; -Miew$1.prototype._startMdAnimation = function (mdFile, pdbFile) { +Miew.prototype._startMdAnimation = function (mdFile, pdbFile) { this._stopAnimation(); var self = this; var visual = this._getComplexVisual(); @@ -89167,7 +89168,7 @@ Miew$1.prototype._startMdAnimation = function (mdFile, pdbFile) { this._continueAnimation(); }; -Miew$1.prototype._pauseAnimation = function () { +Miew.prototype._pauseAnimation = function () { if (this._animInterval === null) { return; } @@ -89185,7 +89186,7 @@ Miew$1.prototype._pauseAnimation = function () { } }; -Miew$1.prototype._continueAnimation = function () { +Miew.prototype._continueAnimation = function () { this._isAnimating = true; var minFrameTime = 1000 / settings.now.maxfps; minFrameTime = Number.isNaN(minFrameTime) ? 0 : minFrameTime; @@ -89222,7 +89223,7 @@ Miew$1.prototype._continueAnimation = function () { }, minFrameTime); }; -Miew$1.prototype._stopAnimation = function () { +Miew.prototype._stopAnimation = function () { if (this._animInterval === null) { return; } @@ -89243,7 +89244,7 @@ Miew$1.prototype._stopAnimation = function () { * @param {object} opts - TODO: Options. * @private */ -Miew$1.prototype._onLoad = function (dataSource, opts) { +Miew.prototype._onLoad = function (dataSource, opts) { var gfx = this._gfx; var visualName = null; @@ -89346,7 +89347,7 @@ Miew$1.prototype._onLoad = function (dataSource, opts) { return visualName; }; -Miew$1.prototype.resetEd = function () { +Miew.prototype.resetEd = function () { if (this._edLoader) { this._edLoader.abort(); this._edLoader = null; @@ -89358,7 +89359,7 @@ Miew$1.prototype.resetEd = function () { this._needRender = true; }; -Miew$1.prototype.loadEd = function (source) { +Miew.prototype.loadEd = function (source) { var _this4 = this; this.resetEd(); @@ -89387,7 +89388,7 @@ Miew$1.prototype.loadEd = function (source) { }); }; -Miew$1.prototype._onLoadEd = function (dataSource) { +Miew.prototype._onLoadEd = function (dataSource) { dataSource.normalize(); var volumeVisual = new VolumeVisual('volume', dataSource); @@ -89398,7 +89399,7 @@ Miew$1.prototype._onLoadEd = function (dataSource) { return visualName; }; -Miew$1.prototype._needRebuild = function () { +Miew.prototype._needRebuild = function () { var needsRebuild = false; this._forEachComplexVisual(function (visual) { needsRebuild = needsRebuild || visual.needsRebuild(); @@ -89406,7 +89407,7 @@ Miew$1.prototype._needRebuild = function () { return needsRebuild; }; -Miew$1.prototype._rebuildObjects = function () { +Miew.prototype._rebuildObjects = function () { var self = this; var gfx = this._gfx; var i, n; @@ -89437,7 +89438,7 @@ Miew$1.prototype._rebuildObjects = function () { }, 10); }; -Miew$1.prototype.changeUnit = function (unitIdx, name) { +Miew.prototype.changeUnit = function (unitIdx, name) { var visual = this._getComplexVisual(name); if (unitIdx === undefined) { var unit = visual ? visual.getComplex().getCurrentStructure() : 0; @@ -89457,7 +89458,7 @@ Miew$1.prototype.changeUnit = function (unitIdx, name) { /** * Start to rebuild geometry asynchronously. */ -Miew$1.prototype.rebuild = function () { +Miew.prototype.rebuild = function () { if (this._building) { this.logger.warn('Miew.rebuild(): already building!'); return; @@ -89497,14 +89498,14 @@ Miew$1.prototype.rebuild = function () { }; /** Mark all representations for rebuilding */ -Miew$1.prototype.rebuildAll = function () { +Miew.prototype.rebuildAll = function () { this._forEachComplexVisual(function (visual) { visual.setNeedsRebuild(); }); // this.rebuild(); // TODO: isn't implicit rebuild enough? }; -Miew$1.prototype._refreshTitle = function (appendix) { +Miew.prototype._refreshTitle = function (appendix) { var title; appendix = appendix === undefined ? '' : appendix; var visual = this._getComplexVisual(); @@ -89520,11 +89521,11 @@ Miew$1.prototype._refreshTitle = function (appendix) { this.dispatchEvent({ type: 'titleChanged', data: title }); }; -Miew$1.prototype.setNeedRender = function () { +Miew.prototype.setNeedRender = function () { this._needRender = true; }; -Miew$1.prototype._extractRepresentation = function () { +Miew.prototype._extractRepresentation = function () { var _this5 = this; var changed = []; @@ -89563,7 +89564,7 @@ Miew$1.prototype._extractRepresentation = function () { * Change current representation list. * @param {array} reps - Representation list. */ -Miew$1.prototype._setReps = function (reps) { +Miew.prototype._setReps = function (reps) { reps = reps || this._opts && this._opts.reps || []; this._forEachComplexVisual(function (visual) { return visual.resetReps(reps); @@ -89574,7 +89575,7 @@ Miew$1.prototype._setReps = function (reps) { * Apply existing preset to current scene. * @param preset */ -Miew$1.prototype.applyPreset = function (preset) { +Miew.prototype.applyPreset = function (preset) { var presets = settings.now.presets; var presList = [preset || settings.defaults.preset, settings.defaults.preset, Object.keys(presets)[0]]; var reps = null; @@ -89592,7 +89593,7 @@ Miew$1.prototype.applyPreset = function (preset) { * Reset current representation list to initial values. * @param {string} [preset] - The source preset in case of uninitialized representation list. */ -Miew$1.prototype.resetReps = function (preset) { +Miew.prototype.resetReps = function (preset) { var reps = this._opts && this._opts.reps; if (reps) { this._setReps(reps); @@ -89605,7 +89606,7 @@ Miew$1.prototype.resetReps = function (preset) { * Get number of representations created so far. * @returns {number} Number of reps. */ -Miew$1.prototype.repCount = function (name) { +Miew.prototype.repCount = function (name) { var visual = this._getComplexVisual(name); return visual ? visual.repCount() : 0; }; @@ -89616,7 +89617,7 @@ Miew$1.prototype.repCount = function (name) { * @param {string=} [name] - Complex name. Defaults to the current one. * @returns {number} The current index. */ -Miew$1.prototype.repCurrent = function (index, name) { +Miew.prototype.repCurrent = function (index, name) { var visual = this._getComplexVisual(name); var newIdx = visual ? visual.repCurrent(index) : -1; if (index && newIdx !== index) { @@ -89635,7 +89636,7 @@ Miew$1.prototype.repCurrent = function (index, name) { * @param {string=} rep.material - Material id. * @returns {?object} Representation description. */ -Miew$1.prototype.rep = function (index, rep) { +Miew.prototype.rep = function (index, rep) { // FIXME support targeting visual by name var visual = this._getComplexVisual(''); return visual ? visual.rep(index, rep) : null; @@ -89646,7 +89647,7 @@ Miew$1.prototype.rep = function (index, rep) { * @param {number=} index - Zero-based index, up to {@link Miew#repCount}(). Defaults to the current one. * @returns {?object} Representation. */ -Miew$1.prototype.repGet = function (index, name) { +Miew.prototype.repGet = function (index, name) { var visual = this._getComplexVisual(name); return visual ? visual.repGet(index) : null; }; @@ -89656,7 +89657,7 @@ Miew$1.prototype.repGet = function (index, name) { * @param {object=} rep - Representation description. * @returns {number} Index of the new representation. */ -Miew$1.prototype.repAdd = function (rep, name) { +Miew.prototype.repAdd = function (rep, name) { var visual = this._getComplexVisual(name); return visual ? visual.repAdd(rep) : -1; }; @@ -89665,7 +89666,7 @@ Miew$1.prototype.repAdd = function (rep, name) { * Remove representation. * @param {number=} index - Zero-based representation index. */ -Miew$1.prototype.repRemove = function (index, name) { +Miew.prototype.repRemove = function (index, name) { var visual = this._getComplexVisual(name); return visual ? visual.repRemove(index) : null; }; @@ -89675,13 +89676,13 @@ Miew$1.prototype.repRemove = function (index, name) { * @param {number} index - Zero-based representation index. * @param {boolean=} hide - Specify false to make rep visible, true to hide (by default). */ -Miew$1.prototype.repHide = function (index, hide, name) { +Miew.prototype.repHide = function (index, hide, name) { this._needRender = true; var visual = this._getComplexVisual(name); return visual ? visual.repHide(index, hide) : null; }; -Miew$1.prototype._setEditMode = function (mode) { +Miew.prototype._setEditMode = function (mode) { this._editMode = mode; @@ -89698,7 +89699,7 @@ Miew$1.prototype._setEditMode = function (mode) { this.dispatchEvent({ type: 'editModeChanged', data: mode === EDIT_MODE.COMPLEX }); }; -Miew$1.prototype._enterComponentEditMode = function () { +Miew.prototype._enterComponentEditMode = function () { if (this._editMode !== EDIT_MODE.COMPLEX) { return; @@ -89723,7 +89724,7 @@ Miew$1.prototype._enterComponentEditMode = function () { this._objectControls.keysTranslateObj(true); }; -Miew$1.prototype._applyComponentEdit = function () { +Miew.prototype._applyComponentEdit = function () { if (this._editMode !== EDIT_MODE.COMPONENT) { return; } @@ -89742,7 +89743,7 @@ Miew$1.prototype._applyComponentEdit = function () { this.rebuildAll(); }; -Miew$1.prototype._discardComponentEdit = function () { +Miew.prototype._discardComponentEdit = function () { if (this._editMode !== EDIT_MODE.COMPONENT) { return; } @@ -89761,7 +89762,7 @@ Miew$1.prototype._discardComponentEdit = function () { this._needRender = true; }; -Miew$1.prototype._enterFragmentEditMode = function () { +Miew.prototype._enterFragmentEditMode = function () { if (this._editMode !== EDIT_MODE.COMPLEX) { return; @@ -89794,7 +89795,7 @@ Miew$1.prototype._enterFragmentEditMode = function () { this._needRender = true; }; -Miew$1.prototype._applyFragmentEdit = function () { +Miew.prototype._applyFragmentEdit = function () { if (this._editMode !== EDIT_MODE.FRAGMENT) { return; } @@ -89814,7 +89815,7 @@ Miew$1.prototype._applyFragmentEdit = function () { this.rebuildAll(); }; -Miew$1.prototype._discardFragmentEdit = function () { +Miew.prototype._discardFragmentEdit = function () { if (this._editMode !== EDIT_MODE.FRAGMENT) { return; } @@ -89835,13 +89836,13 @@ Miew$1.prototype._discardFragmentEdit = function () { }; /** @deprecated Move object instead of panning the camera */ -Miew$1.prototype.resetPan = function () { +Miew.prototype.resetPan = function () { this._gfx.camera.position.x = 0.0; this._gfx.camera.position.y = 0.0; this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype._onPick = function (event) { +Miew.prototype._onPick = function (event) { if (!settings.now.picking) { // picking is disabled return; @@ -89900,7 +89901,7 @@ Miew$1.prototype._onPick = function (event) { this._updateInfoPanel(); }; -Miew$1.prototype._onDblClick = function (event) { +Miew.prototype._onDblClick = function (event) { if ('atom' in event.obj) { this.setPivotAtom(event.obj.atom); } else if ('residue' in event.obj) { @@ -89913,7 +89914,7 @@ Miew$1.prototype._onDblClick = function (event) { this._needRender = true; }; -Miew$1.prototype._onKeyDown = function (event) { +Miew.prototype._onKeyDown = function (event) { if (!this._running || !this._hotKeysEnabled) { return; } @@ -89979,20 +89980,17 @@ Miew$1.prototype._onKeyDown = function (event) { } }; -Miew$1.prototype._onKeyUp = function (event) { +Miew.prototype._onKeyUp = function (event) { if (!this._running || !this._hotKeysEnabled) { return; } - switch (event.keyCode) { - case 'X'.charCodeAt(0): - this._extractRepresentation(); - break; - default: + if (event.keyCode === 'X'.charCodeAt(0)) { + this._extractRepresentation(); } }; -Miew$1.prototype._updateInfoPanel = function () { +Miew.prototype._updateInfoPanel = function () { var info = this._msgAtomInfo.getElementsByTagName('p')[0]; var atom, residue; @@ -90018,7 +90016,7 @@ Miew$1.prototype._updateInfoPanel = function () { var aName = ''; var coordLine = ''; - if (this._lastPick instanceof Atom) { + if (this._lastPick instanceof Atom$3) { atom = this._lastPick; residue = atom._residue; @@ -90036,13 +90034,13 @@ Miew$1.prototype._updateInfoPanel = function () { } coordLine = 'Coord: (' + atom._position.x.toFixed(2).toString() + ', ' + atom._position.y.toFixed(2).toString() + ', ' + atom._position.z.toFixed(2).toString() + ')'; - } else if (this._lastPick instanceof Residue) { + } else if (this._lastPick instanceof Residue$2) { residue = this._lastPick; secondLine = residue._type._fullName + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim(); - } else if (this._lastPick instanceof Chain) { + } else if (this._lastPick instanceof Chain$3) { secondLine = 'chain ' + this._lastPick._name; - } else if (this._lastPick instanceof Molecule) { + } else if (this._lastPick instanceof Molecule$5) { secondLine = 'molecule ' + this._lastPick._name; } @@ -90068,7 +90066,7 @@ Miew$1.prototype._updateInfoPanel = function () { this._msgAtomInfo.style.opacity = 1.0; }; -Miew$1.prototype._getAltObj = function () { +Miew.prototype._getAltObj = function () { if (this._editors) { var altObj = null; for (var i = 0; i < this._editors.length; ++i) { @@ -90093,7 +90091,7 @@ Miew$1.prototype._getAltObj = function () { }; }; -Miew$1.prototype.resetPivot = function () { +Miew.prototype.resetPivot = function () { var boundingBox = new Box3(); this._forEachVisual(function (visual) { boundingBox.union(visual.getBoundaries().boundingBox); @@ -90104,7 +90102,7 @@ Miew$1.prototype.resetPivot = function () { this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype.setPivotResidue = function (residue) { +Miew.prototype.setPivotResidue = function (residue) { var visual = this._getVisualForComplex(residue.getChain().getComplex()); if (!visual) { return; @@ -90131,7 +90129,7 @@ Miew$1.prototype.setPivotResidue = function (residue) { this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype.setPivotAtom = function (atom) { +Miew.prototype.setPivotAtom = function (atom) { var visual = this._getVisualForComplex(atom.getResidue().getChain().getComplex()); if (!visual) { return; @@ -90144,7 +90142,7 @@ Miew$1.prototype.setPivotAtom = function (atom) { this.dispatchEvent({ type: 'transform' }); }; -Miew$1.prototype.benchmarkGfx = function (force) { +Miew.prototype.benchmarkGfx = function (force) { var self = this; var prof = new GfxProfiler(this._gfx.renderer); @@ -90180,7 +90178,7 @@ Miew$1.prototype.benchmarkGfx = function (force) { * if width is omitted too. * @returns {string} Data URL representing the image contents. */ -Miew$1.prototype.screenshot = function (width, height) { +Miew.prototype.screenshot = function (width, height) { var gfx = this._gfx; function Fov2Tan(fov) { @@ -90242,12 +90240,12 @@ Miew$1.prototype.screenshot = function (width, height) { * @param {number} [height] - Height of an image. Defaults to the width (square) or canvas height, * if width is omitted too. */ -Miew$1.prototype.screenshotSave = function (filename, width, height) { +Miew.prototype.screenshotSave = function (filename, width, height) { var uri = this.screenshot(width, height); utils.shotDownload(uri, filename); }; -Miew$1.prototype._tweakResolution = function () { +Miew.prototype._tweakResolution = function () { var maxPerf = [['poor', 100], ['low', 500], ['medium', 1000], ['high', 5000], ['ultra', Number.MAX_VALUE]]; var atomCount = 0; @@ -90267,7 +90265,7 @@ Miew$1.prototype._tweakResolution = function () { } }; -Miew$1.prototype._autoChangeResolution = function (resolution) { +Miew.prototype._autoChangeResolution = function (resolution) { if (resolution !== settings.now.resolution) { this.logger.report('Your rendering resolution was changed to "' + resolution + '" for best performance.'); } @@ -90277,11 +90275,11 @@ Miew$1.prototype._autoChangeResolution = function (resolution) { /** * Save current settings to cookies. */ -Miew$1.prototype.saveSettings = function () { +Miew.prototype.saveSettings = function () { this._cookies.setCookie(this._opts.settingsCookie, JSON.stringify(this.settings.getDiffs(true))); }; -Miew$1.prototype._loadSettings = function () { +Miew.prototype._loadSettings = function () { try { var cookie = this._cookies.getCookie(this._opts.settingsCookie); var diffs = cookie ? JSON.parse(cookie) : {}; @@ -90294,7 +90292,7 @@ Miew$1.prototype._loadSettings = function () { /** * Load settings from cookies. */ -Miew$1.prototype.restoreSettings = function () { +Miew.prototype.restoreSettings = function () { var oldSettings = lodash.cloneDeep(this.settings.now); this._loadSettings(); var changes = utils.objectsDiff(this.settings.now, oldSettings); @@ -90304,7 +90302,7 @@ Miew$1.prototype.restoreSettings = function () { /** * Reset current settings to the defaults. */ -Miew$1.prototype.resetSettings = function () { +Miew.prototype.resetSettings = function () { var oldSettings = lodash.cloneDeep(this.settings.now); this.settings.reset(); var changes = utils.objectsDiff(this.settings.now, oldSettings); @@ -90316,9 +90314,9 @@ Miew$1.prototype.resetSettings = function () { * @param {string|object} opts - See {@link Miew} constructor. * @see {@link Miew#set}, {@link Miew#repAdd}, {@link Miew#rep}. */ -Miew$1.prototype.setOptions = function (opts) { +Miew.prototype.setOptions = function (opts) { if (typeof opts === 'string') { - opts = Miew$1.options.fromAttr(opts); + opts = Miew.options.fromAttr(opts); } if (opts.reps) { this._opts.reps = null; @@ -90360,7 +90358,7 @@ Miew$1.prototype.setOptions = function (opts) { } }; -Miew$1.prototype.info = function (name) { +Miew.prototype.info = function (name) { var visual = this._getComplexVisual(name); if (!visual) { return {}; @@ -90381,7 +90379,7 @@ Miew$1.prototype.info = function (name) { * OBJECTS SEGMENT */ -Miew$1.prototype.addObject = function (objData, bThrow) { +Miew.prototype.addObject = function (objData, bThrow) { var Ctor = null; // TODO change this to factory when better times come. @@ -90406,7 +90404,7 @@ Miew$1.prototype.addObject = function (objData, bThrow) { this._needRender = true; }; -Miew$1.prototype._addSceneObject = function (sceneObject) { +Miew.prototype._addSceneObject = function (sceneObject) { var visual = this._getComplexVisual(); if (sceneObject.build && visual) { sceneObject.build(visual.getComplex()); @@ -90416,7 +90414,7 @@ Miew$1.prototype._addSceneObject = function (sceneObject) { objects[objects.length] = sceneObject; }; -Miew$1.prototype._updateObjsToFrame = function (frameData) { +Miew.prototype._updateObjsToFrame = function (frameData) { var objs = this._objects; for (var i = 0, n = objs.length; i < n; ++i) { if (objs[i].updateToFrame) { @@ -90425,7 +90423,7 @@ Miew$1.prototype._updateObjsToFrame = function (frameData) { } }; -Miew$1.prototype._resetObjects = function () { +Miew.prototype._resetObjects = function () { var objs = this._opts._objects; this._objects = []; @@ -90436,7 +90434,7 @@ Miew$1.prototype._resetObjects = function () { } }; -Miew$1.prototype.removeObject = function (index) { +Miew.prototype.removeObject = function (index) { var obj = this._objects[index]; if (!obj) { throw new Error('Scene object with index ' + index + ' does not exist'); @@ -90455,7 +90453,7 @@ Miew$1.prototype.removeObject = function (index) { * @param {boolean} [opts.view=false] - when this flag is true, a view information is included * @returns {string} URL */ -Miew$1.prototype.getURL = function (opts) { +Miew.prototype.getURL = function (opts) { return options.toURL(this.getState(lodash.defaults(opts, { compact: true, settings: false, @@ -90472,7 +90470,7 @@ Miew$1.prototype.getURL = function (opts) { * @param {boolean} [opts.view=true] - when this flag is true, a view information is included * @returns {string} script */ -Miew$1.prototype.getScript = function (opts) { +Miew.prototype.getScript = function (opts) { return options.toScript(this.getState(lodash.defaults(opts, { compact: true, settings: true, @@ -90485,7 +90483,7 @@ Miew$1.prototype.getScript = function (opts) { * @param {boolean} compareWithDefaults - when this flag is true, reps list is compared (if possible) * to preset's defaults and only diffs are generated */ -Miew$1.prototype._compareReps = function (complexVisual, compareWithDefaults) { +Miew.prototype._compareReps = function (complexVisual, compareWithDefaults) { var ans = {}; var repCount = 0; @@ -90524,7 +90522,7 @@ Miew$1.prototype._compareReps = function (complexVisual, compareWithDefaults) { * @param {boolean} [opts.view=false] - when this flag is true, a view information is included * @returns {Object} State object. */ -Miew$1.prototype.getState = function (opts) { +Miew.prototype.getState = function (opts) { var state = {}; opts = lodash.defaults(opts, { @@ -90590,11 +90588,11 @@ Miew$1.prototype.getState = function (opts) { * @param {*=} value - Default value. * @returns {*} Parameter value. */ -Miew$1.prototype.get = function (param, value) { +Miew.prototype.get = function (param, value) { return settings.get(param, value); }; -Miew$1.prototype._clipPlaneUpdateValue = function (radius) { +Miew.prototype._clipPlaneUpdateValue = function (radius) { var clipPlaneValue = Math.max(this._gfx.camera.position.z - radius * settings.now.draft.clipPlaneFactor, settings.now.camNear); var opts = { clipPlaneValue: clipPlaneValue }; @@ -90612,7 +90610,7 @@ Miew$1.prototype._clipPlaneUpdateValue = function (radius) { } }; -Miew$1.prototype._fogFarUpdateValue = function () { +Miew.prototype._fogFarUpdateValue = function () { if (this._picker !== null) { if (this._gfx.scene.fog) { this._picker.fogFarValue = this._gfx.scene.fog.far; @@ -90627,7 +90625,7 @@ Miew$1.prototype._fogFarUpdateValue = function () { * @param changes - differences with previous settings * @private */ -Miew$1.prototype._onSettingsChanged = function (changes) { +Miew.prototype._onSettingsChanged = function (changes) { if (!(changes instanceof Object)) { return; } @@ -90679,7 +90677,7 @@ Miew$1.prototype._onSettingsChanged = function (changes) { * @param {string|object} params - Parameter name or path (e.g. 'modes.BS.atom') or even settings object. * @param {*=} value - Value. */ -Miew$1.prototype.set = function (params, value) { +Miew.prototype.set = function (params, value) { if (typeof params === 'string' && value !== undefined) { // slow but avoids code duplication var key = params; @@ -90698,7 +90696,7 @@ Miew$1.prototype.set = function (params, value) { * @param {string} expression - string expression of selection * @param {boolean=} append - true to append selection atoms to current selection, false to rewrite selection */ -Miew$1.prototype.select = function (expression, append) { +Miew.prototype.select = function (expression, append) { var visual = this._getComplexVisual(); if (!visual) { return; @@ -90706,7 +90704,7 @@ Miew$1.prototype.select = function (expression, append) { var sel = expression; if (lodash.isString(expression)) { - sel = selectors.parse(expression).selector; + sel = selectors$4.parse(expression).selector; } visual.select(sel, append); @@ -90723,7 +90721,7 @@ var VIEW_VERSION = '1'; * * @param {string=} expression - Optional string encoded the view */ -Miew$1.prototype.view = function (expression) { +Miew.prototype.view = function (expression) { var self = this; var pivot = this._gfx.pivot; var transform = []; @@ -90791,7 +90789,7 @@ Miew$1.prototype.view = function (expression) { /* * Update current view due to viewinterpolator state */ -Miew$1.prototype._updateView = function () { +Miew.prototype._updateView = function () { var self = this; var pivot = this._gfx.pivot; @@ -90821,7 +90819,7 @@ Miew$1.prototype._updateView = function () { * @param {number} y - translation value (Ang) along model's Y axis * @param {number} z - translation value (Ang) along model's Z axis */ -Miew$1.prototype.translate = function (x, y, z) { +Miew.prototype.translate = function (x, y, z) { this._objectControls.translatePivot(x, y, z); this.dispatchEvent({ type: 'transform' }); this._needRender = true; @@ -90833,7 +90831,7 @@ Miew$1.prototype.translate = function (x, y, z) { * @param {number} y - rotation angle around Y axis in radians * @param {number} z - rotation angle around Z axis in radians */ -Miew$1.prototype.rotate = function (x, y, z) { +Miew.prototype.rotate = function (x, y, z) { this._objectControls.rotate(new Quaternion().setFromEuler(new Euler(x, y, z, 'XYZ'))); this.dispatchEvent({ type: 'transform' }); this._needRender = true; @@ -90843,7 +90841,7 @@ Miew$1.prototype.rotate = function (x, y, z) { * Scale object by factor * @param {number} factor - scale multiplier */ -Miew$1.prototype.scale = function (factor) { +Miew.prototype.scale = function (factor) { if (factor <= 0) { throw new RangeError('Scale should be greater than zero'); } @@ -90858,7 +90856,7 @@ Miew$1.prototype.scale = function (factor) { * @param {number} y - vertical panning * @deprecated Move object instead of panning the camera */ -Miew$1.prototype.pan = function (x, y) { +Miew.prototype.pan = function (x, y) { this._gfx.camera.translateX(x); this._gfx.camera.translateY(y); this._needRender = true; @@ -90870,14 +90868,14 @@ Miew$1.prototype.pan = function (x, y) { * @param {number} radius - distance * @returns {Selector} selector describing result group of atoms */ -Miew$1.prototype.within = function (selector, radius) { +Miew.prototype.within = function (selector, radius) { var visual = this._getComplexVisual(); if (!visual) { - return selectors.None(); + return selectors$4.None(); } if (selector instanceof String) { - selector = selectors.parse(selector); + selector = selectors$4.parse(selector); } var res = visual.within(selector, radius); @@ -90893,7 +90891,7 @@ Miew$1.prototype.within = function (selector, radius) { * @param {string} fullAtomName - full atom name, like A.38.CG * @returns {Object} {x, y} or false if atom not found */ -Miew$1.prototype.projected = function (fullAtomName, complexName) { +Miew.prototype.projected = function (fullAtomName, complexName) { var visual = this._getComplexVisual(complexName); if (!visual) { return false; @@ -91119,7 +91117,7 @@ function _convertData(data, opts, job) { var bytes = new Uint8Array(byteNumbers); var blob = new File([bytes], opts.fileName); console.time('convert'); - Miew$1.prototype.srvTopologyConvert(blob, opts.mdFile, function (success, newData, message) { + Miew.prototype.srvTopologyConvert(blob, opts.mdFile, function (success, newData, message) { console.timeEnd('convert'); if (success) { opts.converted = true; @@ -91182,11 +91180,11 @@ function _parseData(data, opts, job) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.10" !== 'undefined' && "0.7.10" || '0.0.0-dev'; +Miew.prototype.VERSION = typeof "0.7.11" !== 'undefined' && "0.7.11" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); -lodash.assign(Miew$1, /** @lends Miew */{ - VERSION: Miew$1.prototype.VERSION, +lodash.assign(Miew, /** @lends Miew */{ + VERSION: Miew.prototype.VERSION, registeredPlugins: [], @@ -91201,7 +91199,7 @@ lodash.assign(Miew$1, /** @lends Miew */{ utils: utils, gfx: { Representation: Representation, - fbxExport: exportAll + fbxExport: fbxExport }, /** @@ -92556,9 +92554,9 @@ var help = { function parseRange(node) { if (node instanceof Array) { - return new selectors$1.Range(node[0], node[1]); + return new selectors.Range(node[0], node[1]); } else { - return new selectors$1.Range(node, node); + return new selectors.Range(node, node); } } @@ -92567,7 +92565,7 @@ function parseRangeList(node) { for (var i = 0; i < node.length; ++i) { args.push(parseRange(node[i])); } - return new selectors$1.RangeList(args); + return new selectors.RangeList(args); } function parseValueList(node) { @@ -92575,26 +92573,26 @@ function parseValueList(node) { for (var i = 0; i < node.length; ++i) { args.push(node[i]); } - return new selectors$1.ValueList(args); + return new selectors.ValueList(args); } function _createSelectorFromNode(node) { - var factory = selectors$1.keyword(node[0]); + var factory = selectors.keyword(node[0]); if (!factory || !factory.SelectorClass) { return null; } var selector = null; var proto = factory.SelectorClass.prototype; - if (proto instanceof selectors$1.PrefixOperator && node.length === 2) { + if (proto instanceof selectors.PrefixOperator && node.length === 2) { selector = factory(_createSelectorFromNode(node[1])); - } else if (proto instanceof selectors$1.InfixOperator && node.length === 3) { + } else if (proto instanceof selectors.InfixOperator && node.length === 3) { selector = factory(_createSelectorFromNode(node[1]), _createSelectorFromNode(node[2])); - } else if (proto instanceof selectors$1.RangeListSelector && node.length === 2) { + } else if (proto instanceof selectors.RangeListSelector && node.length === 2) { selector = factory(parseRangeList(node[1])); - } else if (proto instanceof selectors$1.ValueListSelector && node.length === 2) { + } else if (proto instanceof selectors.ValueListSelector && node.length === 2) { selector = factory(parseValueList(node[1])); - } else if (proto instanceof selectors$1.Selector && node.length === 1) { + } else if (proto instanceof selectors.Selector && node.length === 1) { selector = factory(); } @@ -92615,13 +92613,13 @@ var JSONtoSelectorConverter = function () { return JSONtoSelectorConverter; }(); -var selectors$5 = Miew$1.chem.selectors; -var modes$1 = Miew$1.modes; -var colorers$1 = Miew$1.colorers; -var materials$1 = Miew$1.materials; -var palettes$1 = Miew$1.palettes; -var options$1 = Miew$1.options; -var settings$1 = Miew$1.settings; +var selectors$5 = Miew.chem.selectors; +var modes$1 = Miew.modes; +var colorers$1 = Miew.colorers; +var materials$1 = Miew.materials; +var palettes$1 = Miew.palettes; +var options$1 = Miew.options; +var settings$1 = Miew.settings; function None() {} @@ -93539,7 +93537,7 @@ cliutils.notimplemented = function () { return this.NULL; }; -Miew$1.prototype.script = function (script, _printCallback, _errorCallback) { +Miew.prototype.script = function (script, _printCallback, _errorCallback) { MiewCLIParser_1.yy.miew = this; MiewCLIParser_1.yy.echo = _printCallback; MiewCLIParser_1.yy.error = _errorCallback; @@ -93554,19 +93552,19 @@ Miew$1.prototype.script = function (script, _printCallback, _errorCallback) { this.cmdQueue = this.cmdQueue.concat(script.split('\n')); }; -Miew$1.prototype.awaitWhileCMDisInProcess = function () { +Miew.prototype.awaitWhileCMDisInProcess = function () { this.commandInAction = true; }; -Miew$1.prototype.finishAwaitingCMDInProcess = function () { +Miew.prototype.finishAwaitingCMDInProcess = function () { this.commandInAction = false; }; -Miew$1.prototype.isScriptingCommandAvailable = function () { +Miew.prototype.isScriptingCommandAvailable = function () { return this.commandInAction !== undefined && !this.commandInAction && this.cmdQueue !== undefined && this.cmdQueue.length > 0; }; -Miew$1.prototype.callNextCmd = function () { +Miew.prototype.callNextCmd = function () { if (this.isScriptingCommandAvailable()) { var cmd = this.cmdQueue.shift(); @@ -93585,11 +93583,11 @@ Miew$1.prototype.callNextCmd = function () { return ''; }; -Miew$1.JSONConverter = JSONtoSelectorConverter; +Miew.JSONConverter = JSONtoSelectorConverter; MiewCLIParser_1.yy = cliutils; // FIXME: workaround for incorrect JISON parser generator for AMD module MiewCLIParser_1.yy.parseError = MiewCLIParser_1.parseError; -export default Miew$1; +export default Miew; //# sourceMappingURL=Miew.module.js.map diff --git a/package.json b/package.json index d707c26c..a8985bce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miew", - "version": "0.7.10", + "version": "0.7.11", "description": "Miew - 3D Molecular Viewer", "author": "EPAM Systems, Inc.", "main": "dist/Miew.js", diff --git a/sonar-project.properties b/sonar-project.properties index 779d173d..ca9870ab 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.10 +sonar.projectVersion=0.7.11 sonar.links.homepage=https://github.com/epam/miew sonar.links.ci=https://travis-ci.org/epam/miew