diff --git a/CHANGELOG.md b/CHANGELOG.md index 736b5fe3..c3d2ce42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.7.8] - 2017-11-27 +### Added +- Show the chain/molecule information when pick mode is set to chain/molecule. + +### Fixed +- Fix a crash during typing in the Load panel introduced with the previous release. +- Fix a hangup caused by uppercase letters in terminal commands. +- Fix a picking near the terminal window border. +- Fix incorrect formatting in terminal (upgraded jquery.terminal to v1.10.1). +- Fix surface parameter values in UI. Now they are not global and belong to a mode instance as they + should be. +- Fix useless assignments in the code. + ## [0.7.7] - 2017-11-20 + +Demo application was accidentally broken in this release. Hotfix is available +in [0.7.7+hotfix] and later releases. + ### Added - `Parser#parseSync()` - a synchronous method for parsing. - Unit tests for the `Parser` class. @@ -134,7 +151,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Update dependencies to the latest supported versions. - Move the project to GitHub. -[Unreleased]: https://github.com/epam/miew/compare/v0.7.7...HEAD +[Unreleased]: https://github.com/epam/miew/compare/v0.7.8...HEAD +[0.7.8]: https://github.com/epam/miew/compare/v0.7.7...v0.7.8 +[0.7.7+hotfix]: https://github.com/epam/miew/tree/v0.7.7+hotfix [0.7.7]: https://github.com/epam/miew/compare/v0.7.6...v0.7.7 [0.7.6]: https://github.com/epam/miew/compare/v0.7.5...v0.7.6 [0.7.5]: https://github.com/epam/miew/compare/v0.7.4...v0.7.5 diff --git a/dist/Miew.js b/dist/Miew.js index 597ddea4..8bf5f33e 100644 --- a/dist/Miew.js +++ b/dist/Miew.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.7 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.8 Copyright (c) 2015-2017 EPAM Systems, Inc. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -64982,7 +64982,7 @@ Residue$1.prototype._finalize = function () { * @exports Chain * @constructor */ -function Chain(complex, name) { +function Chain$1(complex, name) { this._complex = complex; this._name = name; this._mask = 1 | 0; @@ -64994,15 +64994,15 @@ function Chain(complex, name) { this.maxSequence = Number.NEGATIVE_INFINITY; } -Chain.prototype.getComplex = function () { +Chain$1.prototype.getComplex = function () { return this._complex; }; -Chain.prototype.getName = function () { +Chain$1.prototype.getName = function () { return this._name; }; -Chain.prototype.getResidues = function () { +Chain$1.prototype.getResidues = function () { return this._residues; }; @@ -65012,7 +65012,7 @@ Chain.prototype.getResidues = function () { * @param {string} iCode insertion code * @returns {*} Residue or null if not found */ -Chain.prototype.findResidue = function (seqNum, iCode) { +Chain$1.prototype.findResidue = function (seqNum, iCode) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -65025,7 +65025,7 @@ Chain.prototype.findResidue = function (seqNum, iCode) { return null; }; -Chain.prototype._finalize = function () { +Chain$1.prototype._finalize = function () { var residues = this._residues; var prev = null; @@ -65049,7 +65049,7 @@ Chain.prototype._finalize = function () { } }; -Chain.prototype.updateToFrame = function (frameData) { +Chain$1.prototype.updateToFrame = function (frameData) { var residues = this._residues; var prev = null; var prevData = null; @@ -65078,7 +65078,7 @@ Chain.prototype.updateToFrame = function (frameData) { * @param {string} iCode - Insertion code. * @returns {Residue} - Newly created residue instance. */ -Chain.prototype.addResidue = function (name, sequence, iCode) { +Chain$1.prototype.addResidue = function (name, sequence, iCode) { var type = this._complex.getResidueType(name); if (type === null) { type = this._complex.addResidueType(name); @@ -65099,18 +65099,18 @@ Chain.prototype.addResidue = function (name, sequence, iCode) { return residue; }; -Chain.prototype.getResidueCount = function () { +Chain$1.prototype.getResidueCount = function () { return this._residues.length; }; -Chain.prototype.forEachResidue = function (process) { +Chain$1.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Chain.prototype.collectMask = function () { +Chain$1.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -68184,7 +68184,7 @@ Complex.prototype.getAtomByFullname = function (fullName) { * @returns {Chain} - Newly created chain. */ Complex.prototype.addChain = function (name) { - var result = new Chain(this, name); + var result = new Chain$1(this, name); this._chains.push(result); // TODO: keep chains in dictionary with an (ordered?) array of keys return result; }; @@ -69786,7 +69786,7 @@ VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, di * @exports Molecule * @constructor */ -function Molecule(complex, name, index) { +function Molecule$1(complex, name, index) { this._complex = complex; this._name = name || ''; this._residues = []; @@ -69794,30 +69794,30 @@ function Molecule(complex, name, index) { this._index = index || -1; // start with 1 } -Molecule.prototype.getComplex = function () { +Molecule$1.prototype.getComplex = function () { return this._complex; }; -Molecule.prototype.getName = function () { +Molecule$1.prototype.getName = function () { return this._name; }; -Molecule.prototype.getResidues = function () { +Molecule$1.prototype.getResidues = function () { return this._residues; }; -Molecule.prototype.getIndex = function () { +Molecule$1.prototype.getIndex = function () { return this._index; }; -Molecule.prototype.forEachResidue = function (process) { +Molecule$1.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Molecule.prototype.collectMask = function () { +Molecule$1.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -69833,7 +69833,7 @@ var chem = { Bond: Bond, Residue: Residue$1, ResidueType: ResidueType, - Chain: Chain, + Chain: Chain$1, Helix: Helix, Strand: Strand, Sheet: Sheet, @@ -69843,7 +69843,7 @@ var chem = { Volume: Volume, VoxelWorld: VoxelWorld, selectors: selectors$1, - Molecule: Molecule + Molecule: Molecule$1 }; /** @@ -81157,14 +81157,14 @@ VolumeMesh.prototype._updateVertices = function () { var cornerMark = [0, 0, 0, 0, 0, 0, 0, 0]; var edgeMark = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; - var curEdgeIdx = 0; var curEdge = new Vector3(); + var curEdgeInter = null; function CheckX() { if (norm.x === 0) return 0; var x = -(norm.dot(curEdge) + D) / norm.x; if (-size.x <= x && x <= size.x) { - edgeIntersections[curEdgeIdx].set(x, curEdge.y, curEdge.z); + curEdgeInter.set(x, curEdge.y, curEdge.z); if (x === size.x) return 2; if (x === -size.x) return -2; return 1; @@ -81176,7 +81176,7 @@ VolumeMesh.prototype._updateVertices = function () { if (norm.y === 0) return 0; var y = -(norm.dot(curEdge) + D) / norm.y; if (-size.y <= y && y <= size.y) { - edgeIntersections[curEdgeIdx].set(curEdge.x, y, curEdge.z); + curEdgeInter.set(curEdge.x, y, curEdge.z); if (y === size.y) return 2; if (y === -size.y) return -2; return 1; @@ -81188,7 +81188,7 @@ VolumeMesh.prototype._updateVertices = function () { if (norm.z === 0) return 0; var z = -(norm.dot(curEdge) + D) / norm.z; if (-size.z <= z && z <= size.z) { - edgeIntersections[curEdgeIdx].set(curEdge.x, curEdge.y, z); + curEdgeInter.set(curEdge.x, curEdge.y, z); if (z === size.z) return 2; if (z === -size.z) return -2; return 1; @@ -81197,21 +81197,24 @@ VolumeMesh.prototype._updateVertices = function () { } // for each edge - for (curEdgeIdx = 0; curEdgeIdx < 12; ++curEdgeIdx) { - curEdge.set(edges[curEdgeIdx][2], edges[curEdgeIdx][3], edges[curEdgeIdx][4]); + for (var curEdgeIdx = 0; curEdgeIdx < 12; ++curEdgeIdx) { + var curEdgeSource = edges[curEdgeIdx]; + curEdgeInter = edgeIntersections[curEdgeIdx]; + + curEdge.set(curEdgeSource[2], curEdgeSource[3], curEdgeSource[4]); curEdge.multiply(size); // calculate intersection point var flag = 0; - if (edges[curEdgeIdx][2] === 0) flag = CheckX(); - if (edges[curEdgeIdx][3] === 0) flag = CheckY(); - if (edges[curEdgeIdx][4] === 0) flag = CheckZ(); + if (curEdgeSource[2] === 0) flag = CheckX(); + if (curEdgeSource[3] === 0) flag = CheckY(); + if (curEdgeSource[4] === 0) flag = CheckZ(); // mark corresponding corner (if plane cuts through one) if (flag === -2) { - cornerMark[edges[curEdgeIdx][0]] = 1; + cornerMark[curEdgeSource[0]] = 1; } else if (flag === 2) { - cornerMark[edges[curEdgeIdx][1]] = 1; + cornerMark[curEdgeSource[1]] = 1; } else if (flag === 0) { // edge is not intersected by the plane (doesn't produce a vertex) edgeMark[curEdgeIdx] = 0; @@ -82164,7 +82167,7 @@ var Helix$2 = chem.Helix; var Sheet$2 = chem.Sheet; var Strand$2 = chem.Strand; var Bond$2 = chem.Bond; -var Molecule$2 = chem.Molecule; +var Molecule$3 = chem.Molecule; var TAG_LENGTH = 6; @@ -82272,7 +82275,7 @@ PDBParser.prototype._finalizeMolecules = function () { var chain = chainDict[name]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$2(this._complex, m._name, i + 1); + var molecule = new Molecule$3(this._complex, m._name, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -82959,9 +82962,8 @@ CMLParser.prototype._selectComponents = function (text) { } var atom; - var i = 0; var count = atoms.length; - for (i = 0; i < count; i++) { + for (var i = 0; i < count; i++) { atom = atoms[i]; atom.edges = []; } @@ -82978,8 +82980,8 @@ CMLParser.prototype._selectComponents = function (text) { count = localBond.length; self._rebuidBondIndexes(atoms, localBond); - function addCurrBond() { - bond = localBond[i]; + function addCurrBond(index) { + bond = localBond[index]; atom = atoms[bond.start]; if (!atom) { return false; @@ -82993,33 +82995,33 @@ CMLParser.prototype._selectComponents = function (text) { return true; } - for (i = 0; i < count; i++) { - if (!addCurrBond()) { + for (var _i = 0; _i < count; _i++) { + if (!addCurrBond(_i)) { //ignore invalid bond continue; } var orderAttr = bond.xmlNode.getAttribute('order'); var tc = parseInt(orderAttr, 10); // the default bond order is unknown - localBond[i].order = 0; - localBond[i].type = Bond$3.BondType.UNKNOWN; + localBond[_i].order = 0; + localBond[_i].type = Bond$3.BondType.UNKNOWN; if (tc > 1) { - localBond[i].order = tc; + localBond[_i].order = tc; } else { // another option - bond order is a string var order = cOrderCharCodes[orderAttr]; if (order !== undefined) { - localBond[i].order = order; + localBond[_i].order = order; if (orderAttr === 'A') { - localBond[i].type = Bond$3.BondType.AROMATIC; + localBond[_i].type = Bond$3.BondType.AROMATIC; } } } } count = atoms.length; - for (i = 0; i < count; i++) { - atom = atoms[i]; + for (var _i2 = 0; _i2 < count; _i2++) { + atom = atoms[_i2]; atom.edges.sort(); } @@ -83346,7 +83348,7 @@ var mmtf = createCommonjsModule(function (module, exports) { }); var Complex$5 = chem.Complex; -var Chain$2 = chem.Chain; +var Chain$3 = chem.Chain; var Atom$3 = chem.Atom; var AtomName$3 = chem.AtomName; var Element$5 = chem.Element; @@ -83355,7 +83357,7 @@ var Sheet$3 = chem.Sheet; var Strand$3 = chem.Strand; var Bond$4 = chem.Bond; var Assembly$3 = chem.Assembly; -var Molecule$3 = chem.Molecule; +var Molecule$4 = chem.Molecule; function ArrayComparator(original) { this._original = Array.from(original); @@ -83427,7 +83429,7 @@ MMTFParser.prototype._onChain = function (chainData) { return; } - var chain = new Chain$2(this._complex, chainData.chainName); + var chain = new Chain$3(this._complex, chainData.chainName); this._complex._chains[chainData.chainIndex] = chain; chain._index = chainData.chainIndex; }; @@ -83546,7 +83548,7 @@ MMTFParser.prototype._updateMolecules = function (mmtfData) { var chain = this._complex._chains[chainIndex]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$3(this._complex, entity.description, i + 1); + var molecule = new Molecule$4(this._complex, entity.description, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -83783,7 +83785,7 @@ var Helix$4 = chem.Helix; var Sheet$4 = chem.Sheet; var Strand$4 = chem.Strand; var Assembly$4 = chem.Assembly; -var Molecule$4 = chem.Molecule; +var Molecule$5 = chem.Molecule; var cRequiredAtomFields = ['auth_seq_id', 'Cartn_x', 'Cartn_y', 'Cartn_z', 'label_atom_id']; @@ -83912,7 +83914,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$4(complex, molecule.name, i + 1); + molecules[i] = new Molecule$5(complex, molecule.name, i + 1); molecules[i]._residues = molecule.residues; } }; @@ -87242,7 +87244,7 @@ Cookies.prototype._exists = function (key) { return document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)')); }; -/* global "0.7.7":false */ +/* global "0.7.8":false */ ////////////////////////////////////////////////////////////////////////////// @@ -87251,6 +87253,8 @@ Cookies.prototype._exists = function (key) { var selectors = chem.selectors; var Atom = chem.Atom; var Residue = chem.Residue; +var Chain = chem.Chain; +var Molecule = chem.Molecule; var EDIT_MODE = { COMPLEX: 0, COMPONENT: 1, FRAGMENT: 2 }; @@ -87759,7 +87763,7 @@ Miew$1.prototype._addVisual = function (visual) { */ Miew$1.prototype._removeVisual = function (visual) { var name = ''; - var obj = visual; + var obj = null; if (visual instanceof Visual) { name = visual.name; obj = visual; @@ -87768,7 +87772,7 @@ Miew$1.prototype._removeVisual = function (visual) { obj = this._visuals[name]; } - if (!this._visuals.hasOwnProperty(name) || this._visuals[name] !== obj) { + if (!obj || !this._visuals.hasOwnProperty(name) || this._visuals[name] !== obj) { return; } @@ -89560,17 +89564,21 @@ Miew$1.prototype._updateInfoPanel = function () { aName = an.getString(); } var location = atom._location !== 32 ? String.fromCharCode(atom._location) : ''; // 32 is code of white-space - secondLine = atom.element.fullName + ' #' + atom._serial + location + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim() + '.'; + secondLine = atom.element.fullName + ' #' + atom._serial + location + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim() + '.'; if (typeof aName === 'string') { // add atom name to second line in plain text form secondLine += aName; } - coordLine = 'Coord: (' + atom._position.x.toFixed(2).toString() + ', ' + atom._position.y.toFixed(2).toString() + ', ' + atom._position.z.toFixed(2).toString() + ')'; + 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) { residue = this._lastPick; - secondLine = residue._type._fullName + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim(); + secondLine = residue._type._fullName + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim(); + } else if (this._lastPick instanceof Chain) { + secondLine = 'chain ' + this._lastPick._name; + } else if (this._lastPick instanceof Molecule) { + secondLine = 'molecule ' + this._lastPick._name; } info.appendChild(document.createTextNode(firstLine)); @@ -90638,7 +90646,7 @@ function _parseData(data, opts, master, context) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.7" !== 'undefined' && "0.7.7" || '0.0.0-dev'; +Miew$1.prototype.VERSION = typeof "0.7.8" !== 'undefined' && "0.7.8" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew$1, /** @lends Miew */{ @@ -90827,19 +90835,19 @@ case 26: this.$ = yy.echo(yy.utils.listSelector(yy.miew, yy.Context)); break; case 27: -this.$ = yy.miew.select(yy.utils.checkArg($$[$0-1], $$[$0], true)); +this.$ = yy.miew.select(yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0], true)); break; case 28: -this.$ = yy.Context[$$[$0].toLowerCase()] = yy.utils.checkArg($$[$0-3], $$[$0-2], true); yy.miew.select(yy.Context[$$[$0].toLowerCase()]); +this.$ = yy.Context[$$[$0].toLowerCase()] = yy.utils.checkArg($$[$0-3].toLowerCase(), $$[$0-2], true); yy.miew.select(yy.Context[$$[$0].toLowerCase()]); break; case 29: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {selector : yy.utils.checkArg($$[$0-1], $$[$0])}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {selector : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0])}); break; case 30: this.$ = yy.Context[$$[$0].toLowerCase()] = yy.miew.within(yy.utils.checkArg("select", $$[$0-2], true), Number($$[$0-4])); break; case 31: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {material : yy.utils.checkArg($$[$0-1], $$[$0].toUpperCase())}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {material : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; case 34: this.$ = yy.echo(yy.miew.view()); @@ -91013,16 +91021,16 @@ case 114: this.$ = yy.miew.rep($$[$0-1], $$[$0]); yy.miew.repCurrent($$[$0-1]); break; case 115: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : yy.utils.checkArg($$[$0-1], $$[$0].toUpperCase())}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; case 116: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : new Array(yy.utils.checkArg($$[$0-2], $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; case 117: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : yy.utils.checkArg($$[$0-1], $$[$0].toUpperCase())}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; case 118: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : new Array(yy.utils.checkArg($$[$0-2], $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; case 119: this.$ = Number(yy.representations.get($$[$0])); @@ -92252,9 +92260,11 @@ CLIUtils.prototype.checkArg = function (key, arg, modificate) { 'materials': materials$1 }; - var modificator = key; - while (modificator !== undefined && modificator[modificator.length - 1] !== 's') { - modificator = keyRemap(modificator); + var modificator = key, + temp = void 0; + while (modificator !== temp) { + temp = modificator; + modificator = keyRemap(temp); } if (modificators[modificator].get(arg) === undefined) { diff --git a/dist/Miew.min.js b/dist/Miew.min.js index 48409410..eb2c78dc 100644 --- a/dist/Miew.min.js +++ b/dist/Miew.min.js @@ -1,9 +1,9 @@ -/** Miew - 3D Molecular Viewer v0.7.7 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:Wp++}),this.uuid=Gp.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:Xh,this.wrapT=void 0!==o?o:Xh,this.magFilter=void 0!==a?a:Kh,this.minFilter=void 0!==s?s:Jh,this.anisotropy=void 0!==u?u:1,this.format=void 0!==c?c:dp,this.type=void 0!==l?l:tp,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:Op,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=Gp.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=Kh),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:qh,this.minFilter=void 0!==u?u:qh,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function p(t,e,r,n,o,a,s,c,l,u){t=void 0!==t?t:[],e=void 0!==e?e:kh,i.call(this,t,e,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=Yp[i];if(void 0===o&&(o=new Float32Array(i),Yp[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=qp[e];void 0===r&&(r=new Int32Array(e),qp[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):(Zp.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Zp))}function M(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):($p.set(e.elements),t.uniformMatrix4fv(this.addr,!1,$p))}function A(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Hp,n)}function E(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Xp,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){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}}function R(t,e){t.uniform1fv(this.addr,e)}function N(t,e){t.uniform1iv(this.addr,e)}function I(t,e){t.uniform2fv(this.addr,d(e,this.size,2))}function O(t,e){t.uniform3fv(this.addr,d(e,this.size,3))}function D(t,e){t.uniform4fv(this.addr,d(e,this.size,4))}function z(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 k(t,e){t.uniformMatrix4fv(this.addr,!1,d(e,this.size,16))}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.setTexture2D(e[o]||Hp,i[o])}function B(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]||Xp,i[o])}function V(t){switch(t){case 5126:return R;case 35664:return I;case 35665:return O;case 35666:return D;case 35674:return z;case 35675:return F;case 35676:return k;case 35678:return U;case 35680:return B;case 5124:case 35670:return N;case 35667:case 35671:return C;case 35668:case 35672:return T;case 35669:case 35673:return P}}function j(t,e,r){this.id=t,this.addr=r,this.setValue=L(e.type)}function G(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=V(e.type)}function W(t){this.id=t,f.call(this)}function H(t,e){t.seq.push(e),t.map[e.id]=e}function X(t,e,r){var n=t.name,i=n.length;for(Kp.lastIndex=0;;){var o=Kp.exec(n),a=Kp.lastIndex,s=o[1],c="]"===o[2],l=o[3];if(c&&(s|=0),void 0===l||"["===l&&a+2===i){H(r,void 0===l?new j(s,t,e):new G(s,t,e));break}var u=r.map[s];void 0===u&&H(r,u=new W(s)),r=u}}function Y(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/h.w,w.x=b*y,w.y=b,e.uniform3f(d.screenPosition,S.x,S.y,S.z),e.uniform2f(d.scale,w.x,w.y),e.uniform1f(d.rotation,R.rotation),e.uniform1f(d.opacity,R.opacity),e.uniform3f(d.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 K(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 Q(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]);u=e.createBuffer(),h=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h),e.bufferData(e.ELEMENT_ARRAY_BUFFER,r,e.STATIC_DRAW),p=a(),f={position:e.getAttribLocation(p,"position"),uv:e.getAttribLocation(p,"uv")},d={uvOffset:e.getUniformLocation(p,"uvOffset"),uvScale:e.getUniformLocation(p,"uvScale"),rotation:e.getUniformLocation(p,"rotation"),scale:e.getUniformLocation(p,"scale"),color:e.getUniformLocation(p,"color"),map:e.getUniformLocation(p,"map"),opacity:e.getUniformLocation(p,"opacity"),modelViewMatrix:e.getUniformLocation(p,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(p,"projectionMatrix"),fogType:e.getUniformLocation(p,"fogType"),fogDensity:e.getUniformLocation(p,"fogDensity"),fogNear:e.getUniformLocation(p,"fogNear"),fogFar:e.getUniformLocation(p,"fogFar"),fogColor:e.getUniformLocation(p,"fogColor"),alphaTest:e.getUniformLocation(p,"alphaTest")};var n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=8,n.height=8;var i=n.getContext("2d");i.fillStyle="white",i.fillRect(0,0,8,8),m=new K(n)}function a(){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}function s(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var u,h,p,f,d,m,g=new l,v=new c,y=new l;this.render=function(i,a,c){if(0!==i.length){void 0===p&&o(),r.useProgram(p),r.initAttributes(),r.enableAttribute(f.position),r.enableAttribute(f.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,u),e.vertexAttribPointer(f.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(f.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h),e.uniformMatrix4fv(d.projectionMatrix,!1,c.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(d.map,0);var l=0,_=0,x=a.fog;x?(e.uniform3f(d.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(d.fogNear,x.near),e.uniform1f(d.fogFar,x.far),e.uniform1i(d.fogType,1),l=1,_=1):x.isFogExp2&&(e.uniform1f(d.fogDensity,x.density),e.uniform1i(d.fogType,2),l=2,_=2)):(e.uniform1i(d.fogType,0),l=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==Zu&&(S=qu),L.renderReverseSided&&(S===qu?S=$u:S===$u&&(S=qu)),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 Rt(){Object.defineProperty(this,"id",{value:vt()}),this.uuid=Gp.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 Nt(t,e,r,n,i,o){yt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new It(t,e,r,n,i,o)),this.mergeVertices()}function It(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(jt),n.length>1&&n.sort(Gt)}}}function Ht(){var t={};return{get:function(e,r){var n=e.id+","+r.id,i=t[n];return void 0===i&&(i=new Wt,t[n]=i),i},dispose:function(){t={}}}}function Xt(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Yt(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,c=s.length,l=e[i.id];if(void 0===l){for(l=[],p=0;p65535?Et:Mt)(i,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),o[r.id]=n,n}}}function Kt(){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 q,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"SpotLight":r={position:new l,direction:new l,color:new q,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 q,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 q,groundColor:new q};break;case"RectAreaLight":r={color:new q,position:new l,halfWidth:new l,halfHeight:new l}}return t[e.id]=r,r}}}function Qt(){var t=new Kt,e={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},r=new l,n=new u,i=new u;return{setup:function(o,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=o.length;v/gm,function(t,e){var r=ef[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return ue(r)})}function he(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=oe(n.extensions,o,e),y=ae(s),_=a.createProgram();n.isRawShaderMaterial?(d=[y,"\n"].filter(ce).join("\n"),m=[v,y,"\n"].filter(ce).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(ce).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!==Ih?"#define TONE_MAPPING":"",o.toneMapping!==Ih?ef.tonemapping_pars_fragment:"",o.toneMapping!==Ih?ie("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?ef.encodings_pars_fragment:"",o.mapEncoding?re("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?re("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?re("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?ne("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ce).join("\n")),c=le(c=ue(c),o),l=le(l=ue(l),o),n.isShaderMaterial||(c=he(c),l=he(l));var x=d+c,b=m+l,w=te(a,a.VERTEX_SHADER,x),S=te(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 Y(a,_,t)),P};var L;return this.getAttributes=function(){return void 0===L&&(L=se(a,_)),L},this.destroy=function(){a.deleteProgram(_),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return this.getUniforms()}},attributes:{get:function(){return this.getAttributes()}}}),this.id=sf++,this.code=r,this.usedTimes=1,this.program=_,this.vertexShader=w,this.fragmentShader=S,this}function fe(t,e,r){function n(t){var e=t.skeleton.bones;if(r.floatVertexTextures)return 1024;var n=r.maxVertexUniforms,i=Math.floor((n-20)/4),o=Math.min(i,e.length);return o0,maxBones:f,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numClippingPlanes:l,numClipIntersection:u,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.receiveShadow&&s.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Zu,flipSided:e.side===$u,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");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 Gp.isPowerOfTwo(t.width)&&Gp.isPowerOfTwo(t.height)}function l(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Gp.nearestPowerOfTwo(t.width),e.height=Gp.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}function u(t){return t.wrapS!==Xh||t.wrapT!==Xh||t.minFilter!==qh&&t.minFilter!==Kh}function h(t,e){return t.generateMipmaps&&e&&t.minFilter!==qh&&t.minFilter!==Kh}function p(e){return e===qh||e===$h||e===Zh?t.NEAREST:t.LINEAR}function f(t){var e=t.target;e.removeEventListener("dispose",f),m(e),a.textures--}function d(t){var e=t.target;e.removeEventListener("dispose",d),g(e),a.textures--}function m(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)}function g(e){var r=n.get(e),i=n.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),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)}}function v(e,i){var o=n.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a);else if(!1!==a.complete)return void _(o,e,i)}r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function y(r,a,s){var c;if(s?(t.texParameteri(r,t.TEXTURE_WRAP_S,o.convert(a.wrapS)),t.texParameteri(r,t.TEXTURE_WRAP_T,o.convert(a.wrapT)),t.texParameteri(r,t.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(t.texParameteri(r,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(r,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS!==Xh||a.wrapT,t.texParameteri(r,t.TEXTURE_MAG_FILTER,p(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,p(a.minFilter)),a.minFilter!==qh&&a.minFilter),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===ap&&null===e.get("OES_texture_float_linear"))return;if(a.type===sp&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||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 _(e,n,p){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",f),e.__webglTexture=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+p),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var d=s(n.image,i.maxTextureSize);u(n)&&!1===c(d)&&(d=l(d));var m=c(d),g=o.convert(n.format),v=o.convert(n.type);y(t.TEXTURE_2D,n,m);var _,x=n.mipmaps;if(n.isDepthTexture){var b=t.DEPTH_COMPONENT;if(n.type===ap){if(!M)throw new Error("Float Depth Texture only supported in WebGL2.0");b=t.DEPTH_COMPONENT32F}else M&&(b=t.DEPTH_COMPONENT16);n.format===yp&&b===t.DEPTH_COMPONENT&&n.type!==np&&n.type!==op&&(n.type=np,v=o.convert(n.type)),n.format===_p&&(b=t.DEPTH_STENCIL,n.type!==hp&&(n.type=hp,v=o.convert(n.type))),r.texImage2D(t.TEXTURE_2D,0,b,d.width,d.height,0,g,v,null)}else if(n.isDataTexture)if(x.length>0&&m){for(var w=0,S=x.length;w-1&&r.compressedTexImage2D(t.TEXTURE_2D,w,g,_.width,_.height,0,_.data):r.texImage2D(t.TEXTURE_2D,w,g,_.width,_.height,0,g,v,_.data);else if(x.length>0&&m){for(var w=0,S=x.length;w0&&u.__version!==e.version){u.__image__webglTextureCube||(e.addEventListener("dispose",f),u.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+l),r.bindTexture(t.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var p=e&&e.isCompressedTexture,d=e.image[0]&&e.image[0].isDataTexture,m=[],g=0;g<6;g++)m[g]=p||d?d?e.image[g].image:e.image[g]:s(e.image[g],i.maxCubemapSize);var v=c(m[0]),_=o.convert(e.format),x=o.convert(e.type);for(y(t.TEXTURE_CUBE_MAP,e,v),g=0;g<6;g++)if(p)for(var b,w=m[g].mipmaps,S=0,M=w.length;S-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,S,_,b.width,b.height,0,b.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,S,_,b.width,b.height,0,_,x,b.data);else d?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,_,m[g].width,m[g].height,0,_,x,m[g].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,_,_,x,m[g]);h(e,v)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),u.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+l),r.bindTexture(t.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",d),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,l=c(e);if(s)for(i.__webglFramebuffer=[],u=0;u<6;u++)i.__webglFramebuffer[u]=t.createFramebuffer();else i.__webglFramebuffer=t.createFramebuffer();if(s){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),y(t.TEXTURE_CUBE_MAP,e.texture,l);for(var u=0;u<6;u++)x(i.__webglFramebuffer[u],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+u);h(e.texture,l)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),y(t.TEXTURE_2D,e.texture,l),x(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),h(e.texture,l)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&S(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(h(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 me(){var t={};return{get:function(e){var r=e.uuid,n=t[r];return void 0===n&&(n={},t[r]=n),n},remove:function(e){delete t[e.uuid]},clear:function(){t={}}}}function ge(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(Ah),c(!1),l(Gu),i(t.CULL_FACE),i(t.BLEND),s(eh),{buffers:{color:p,depth:f,stencil:d},initAttributes:function(){for(var t=0,e=g.length;t0&&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}}function ye(t){mt.call(this),this.cameras=t||[]}function _e(t){function e(){if(null!==n&&n.isPresenting){var e=n.getEyeParameters("left"),i=e.renderWidth,o=e.renderHeight;d=t.getPixelRatio(),f=t.getSize(),t.setDrawingBufferSize(2*i,o,1)}else r.enabled&&t.setDrawingBufferSize(f.width,f.height,d)}var r=this,n=null,i=null;"VRFrameData"in window&&(i=new window.VRFrameData);var a=new u,s=new u,c=new u,l=new mt;l.bounds=new o(0,0,.5,1),l.layers.enable(1);var h=new mt;h.bounds=new o(.5,0,.5,1),h.layers.enable(2);var p=new ye([l,h]);p.layers.enable(1),p.layers.enable(2);var f,d;window.addEventListener("vrdisplaypresentchange",e,!1),this.enabled=!1,this.standing=!1,this.getDevice=function(){return n},this.setDevice=function(t){void 0!==t&&(n=t)},this.getCamera=function(t){if(null===n)return t;n.depthNear=t.near,n.depthFar=t.far,n.getFrameData(i);var e=i.pose;null!==e.position?t.position.fromArray(e.position):t.position.set(0,0,0),null!==e.orientation&&t.quaternion.fromArray(e.orientation),t.updateMatrixWorld();var r=n.stageParameters;if(this.standing&&r&&(s.fromArray(r.sittingToStandingTransform),c.getInverse(s),t.matrixWorld.multiply(s),t.matrixWorldInverse.multiply(c)),!1===n.isPresenting)return t;l.near=t.near,h.near=t.near,l.far=t.far,h.far=t.far,p.matrixWorld.copy(t.matrixWorld),p.matrixWorldInverse.copy(t.matrixWorldInverse),l.matrixWorldInverse.fromArray(i.leftViewMatrix),h.matrixWorldInverse.fromArray(i.rightViewMatrix),this.standing&&r&&(l.matrixWorldInverse.multiply(c),h.matrixWorldInverse.multiply(c));var o=t.parent;null!==o&&(a.getInverse(o.matrixWorld),l.matrixWorldInverse.multiply(a),h.matrixWorldInverse.multiply(a)),l.matrixWorld.getInverse(l.matrixWorldInverse),h.matrixWorld.getInverse(h.matrixWorldInverse),l.projectionMatrix.fromArray(i.leftProjectionMatrix),h.projectionMatrix.fromArray(i.rightProjectionMatrix),p.projectionMatrix.copy(l.projectionMatrix);var u=n.getLayers();if(u.length){var f=u[0];null!==f.leftBounds&&4===f.leftBounds.length&&l.bounds.fromArray(f.leftBounds),null!==f.rightBounds&&4===f.rightBounds.length&&h.bounds.fromArray(f.rightBounds)}return p},this.getStandingMatrix=function(){return s},this.submitFrame=function(){n&&n.isPresenting&&n.submitFrame()},this.dispose=function(){window.removeEventListener("vrdisplaypresentchange",e)}}function xe(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}}}function be(){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=Ot.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?(Lt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):Lt.enableAttribute(c),Et.bindBuffer(Et.ARRAY_BUFFER,f),Et.vertexAttribPointer(c,h,d,u,v*m,(n*v+y)*m)}else l.isInstancedBufferAttribute?(Lt.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):Lt.enableAttribute(c),Et.bindBuffer(Et.ARRAY_BUFFER,f),Et.vertexAttribPointer(c,h,d,u,0,n*h*m)}else if(void 0!==a){var _=a[s];if(void 0!==_)switch(_.length){case 2:Et.vertexAttrib2fv(c,_);break;case 3:Et.vertexAttrib3fv(c,_);break;case 4:Et.vertexAttrib4fv(c,_);break;default:Et.vertexAttrib1fv(c,_)}}}}Lt.disableUnusedAttributes()}}function d(){ne||((ee.getDevice()||window).requestAnimationFrame(m),ne=!0)}function m(t){null!==ie&&ie(t),(ee.getDevice()||window).requestAnimationFrame(m)}function g(t,e,r){if(t.visible){if(t.layers.test(e.layers))if(t.isLight)G.push(t),t.castShadow&&W.push(t);else if(t.isSprite)t.frustumCulled&&!yt.intersectsSprite(t)||X.push(t);else if(t.isLensFlare)q.push(t);else if(t.isImmediateRenderObject)r&&St.setFromMatrixPosition(t.matrixWorld).applyMatrix4(wt),H.push(t,null,t.material,St.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||yt.intersectsObject(t))){r&&St.setFromMatrixPosition(t.matrixWorld).applyMatrix4(wt);var n=zt.update(t),i=t.material;if(Array.isArray(i))for(var o=n.groups,a=0,s=o.length;a=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p<$.maxMorphNormals;p++)h["morphNormal"+p]>=0&&t.numSupportedMorphNormals++}var f=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=_t.numPlanes,n.numIntersection=_t.numIntersection,f.clippingPlanes=_t.uniform),n.fog=e,n.lightsHash=Ft.state.hash,t.lights&&(f.ambientLightColor.value=Ft.state.ambient,f.directionalLights.value=Ft.state.directional,f.spotLights.value=Ft.state.spot,f.rectAreaLights.value=Ft.state.rectArea,f.pointLights.value=Ft.state.point,f.hemisphereLights.value=Ft.state.hemi,f.directionalShadowMap.value=Ft.state.directionalShadowMap,f.directionalShadowMatrix.value=Ft.state.directionalShadowMatrix,f.spotShadowMap.value=Ft.state.spotShadowMap,f.spotShadowMatrix.value=Ft.state.spotShadowMatrix,f.pointShadowMap.value=Ft.state.pointShadowMap,f.pointShadowMatrix.value=Ft.state.pointShadowMatrix);var d=n.program.getUniforms(),m=Y.seqWithValue(d.seq,f);n.uniformsList=m}function x(t,e,r,n){ht=0;var i=Nt.get(r);if(xt&&(bt||t!==nt)){var o=t===nt&&r.id===et;_t.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!==Ft.state.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===_t.numPlanes&&i.numIntersection===_t.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(_(r,e,n),r.needsUpdate=!1);var a=!1,s=!1,c=!1,l=i.program,u=l.getUniforms(),p=i.shader.uniforms;if(Lt.useProgram(l.program)&&(a=!0,s=!0,c=!0),r.id!==et&&(et=r.id,s=!0),a||t!==nt){if(u.setValue(Et,"projectionMatrix",t.projectionMatrix),Pt.logarithmicDepthBuffer&&u.setValue(Et,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),nt!==(it||t)&&(nt=it||t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var f=u.map.cameraPosition;void 0!==f&&f.setValue(Et,St.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&u.setValue(Et,"viewMatrix",t.matrixWorldInverse)}if(r.skinning){u.setOptional(Et,n,"bindMatrix"),u.setOptional(Et,n,"bindMatrixInverse");var d=n.skeleton;if(d){var m=d.bones;if(Pt.floatVertexTextures){if(void 0===d.boneTexture){var g=Math.sqrt(4*m.length);g=Gp.nextPowerOfTwo(Math.ceil(g)),g=Math.max(g,4);var v=new Float32Array(g*g*4);v.set(d.boneMatrices);var y=new h(v,g,g,dp,ap);d.boneMatrices=v,d.boneTexture=y,d.boneTextureSize=g}u.setValue(Et,"boneTexture",d.boneTexture),u.setValue(Et,"boneTextureSize",d.boneTextureSize)}else u.setOptional(Et,d,"boneMatrices")}}return(s||r.forceUniformsUpdate)&&(u.setValue(Et,"toneMappingExposure",$.toneMappingExposure),u.setValue(Et,"toneMappingWhitePoint",$.toneMappingWhitePoint),r.lights&&O(p,c),e&&r.fog&&A(p,e),r.isMeshBasicMaterial?b(p,r):r.isMeshLambertMaterial?(b(p,r),E(p,r)):r.isMeshPhongMaterial?(b(p,r),r.isMeshToonMaterial?T(p,r):C(p,r)):r.isMeshStandardMaterial?(b(p,r),r.isMeshPhysicalMaterial?L(p,r):P(p,r)):r.isMeshDepthMaterial?(b(p,r),R(p,r)):r.isMeshDistanceMaterial?(b(p,r),N(p,r)):r.isMeshNormalMaterial?(b(p,r),I(p,r)):r.isLineBasicMaterial?(w(p,r),r.isLineDashedMaterial&&S(p,r)):r.isPointsMaterial?M(p,r):r.isShadowMaterial&&(p.color.value=r.color,p.opacity.value=r.opacity),void 0!==p.ltcMat&&(p.ltcMat.value=Jp.LTC_MAT_TEXTURE),void 0!==p.ltcMag&&(p.ltcMag.value=Jp.LTC_MAG_TEXTURE),Y.upload(Et,i.uniformsList,p,$)),u.setValue(Et,"modelViewMatrix",n.modelViewMatrix),u.setValue(Et,"normalMatrix",n.normalMatrix),u.setValue(Et,"modelMatrix",n.matrixWorld),l}function b(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 w(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function S(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function M(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*dt,t.scale.value=.5*ft,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}function A(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)}function E(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function C(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(t,e){C(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function P(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)}function L(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,P(t,e)}function R(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function N(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}function I(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)}function O(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}var D=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),z=void 0!==t.context?t.context:null,F=void 0!==t.alpha&&t.alpha,k=void 0===t.depth||t.depth,U=void 0===t.stencil||t.stencil,B=void 0!==t.antialias&&t.antialias,V=void 0===t.premultipliedAlpha||t.premultipliedAlpha,j=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,G=[],W=[],H=null,X=[],q=[];this.domElement=D,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=Oh,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var $=this,K=!1,J=null,tt=null,et=-1,rt="",nt=null,it=null,ot=new o,at=new o,ut=null,ht=0,pt=D.width,ft=D.height,dt=1,mt=new o(0,0,pt,ft),gt=new o(0,0,pt,ft),vt=!1,yt=new st,_t=new be,xt=!1,bt=!1,wt=new u,St=new l,Mt={geometries:0,textures:0},At={frame:0,calls:0,vertices:0,faces:0,points:0};this.info={render:At,memory:Mt,programs:null};var Et;try{var Ct={alpha:F,depth:k,stencil:U,antialias:B,premultipliedAlpha:V,preserveDrawingBuffer:j};if(null===(Et=z||D.getContext("webgl",Ct)||D.getContext("experimental-webgl",Ct)))throw null!==D.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Et.getShaderPrecisionFormat&&(Et.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),D.addEventListener("webglcontextlost",n,!1),D.addEventListener("webglcontextrestored",i,!1)}catch(t){}var Tt,Pt,Lt,Nt,It,Ot,Dt,zt,Ft,kt,Ut,Bt,jt,Gt,Wt,Xt,Kt,te;r();var ee=new _e($);this.vr=ee;var re=new ct($,zt,Pt.maxTextureSize);this.shadowMap=re,this.getContext=function(){return Et},this.getContextAttributes=function(){return Et.getContextAttributes()},this.forceContextLoss=function(){var t=Tt.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=Tt.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return dt},this.setPixelRatio=function(t){void 0!==t&&(dt=t,this.setSize(pt,ft,!1))},this.getSize=function(){return{width:pt,height:ft}},this.setSize=function(t,e,r){var n=ee.getDevice();n&&n.isPresenting||(pt=t,ft=e,D.width=t*dt,D.height=e*dt,!1!==r&&(D.style.width=t+"px",D.style.height=e+"px"),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(){return{width:pt*dt,height:ft*dt}},this.setDrawingBufferSize=function(t,e,r){pt=t,ft=e,dt=r,D.width=t*r,D.height=e*r,this.setViewport(0,0,t,e)},this.setViewport=function(t,e,r,n){mt.set(t,ft-e-n,r,n),Lt.viewport(ot.copy(mt).multiplyScalar(dt))},this.setScissor=function(t,e,r,n){gt.set(t,ft-e-n,r,n),Lt.scissor(at.copy(gt).multiplyScalar(dt))},this.setScissorTest=function(t){Lt.setScissorTest(vt=t)},this.getClearColor=Bt.getClearColor,this.setClearColor=Bt.setClearColor,this.getClearAlpha=Bt.getClearAlpha,this.setClearAlpha=Bt.setClearAlpha,this.clear=function(t,e,r){var n=0;(void 0===t||t)&&(n|=Et.COLOR_BUFFER_BIT),(void 0===e||e)&&(n|=Et.DEPTH_BUFFER_BIT),(void 0===r||r)&&(n|=Et.STENCIL_BUFFER_BIT),Et.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,r,n){this.setRenderTarget(t),this.clear(e,r,n)},this.dispose=function(){D.removeEventListener("webglcontextlost",n,!1),D.removeEventListener("webglcontextrestored",i,!1),Ut.dispose(),ee.dispose()},this.renderBufferImmediate=function(t,e,r){Lt.initAttributes();var n=Nt.get(t);t.hasPositions&&!n.position&&(n.position=Et.createBuffer()),t.hasNormals&&!n.normal&&(n.normal=Et.createBuffer()),t.hasUvs&&!n.uv&&(n.uv=Et.createBuffer()),t.hasColors&&!n.color&&(n.color=Et.createBuffer());var i=e.getAttributes();if(t.hasPositions&&(Et.bindBuffer(Et.ARRAY_BUFFER,n.position),Et.bufferData(Et.ARRAY_BUFFER,t.positionArray,Et.DYNAMIC_DRAW),Lt.enableAttribute(i.position),Et.vertexAttribPointer(i.position,3,Et.FLOAT,!1,0,0)),t.hasNormals){if(Et.bindBuffer(Et.ARRAY_BUFFER,n.normal),!r.isMeshPhongMaterial&&!r.isMeshStandardMaterial&&!r.isMeshNormalMaterial&&!0===r.flatShading)for(var o=0,a=3*t.count;o0&&m.renderInstances(n,w,M):m.render(w,M)}},this.compile=function(t,e){G.length=0,W.length=0,t.traverse(function(t){t.isLight&&(G.push(t),t.castShadow&&W.push(t))}),Ft.setup(G,W,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&&Et.readPixels(e,r,n,i,te.convert(l),te.convert(u),o)}finally{s&&Et.bindFramebuffer(Et.FRAMEBUFFER,tt)}}}}}function Me(t,e){this.name="",this.color=new q(t),this.density=void 0!==e?e:25e-5}function Ae(t,e,r){this.name="",this.color=new q(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function Ee(){pt.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Ce(t,e,r,n,i){pt.call(this),this.lensFlares=[],this.positionScreen=new l,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function Te(t){J.call(this),this.type="SpriteMaterial",this.color=new q(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Pe(t){pt.call(this),this.type="Sprite",this.material=void 0!==t?t:new Te}function Le(){pt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Re(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 je(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 Ge(t,e,r,n,o,a,s,c,l,u){if((u=void 0!==u?u:yp)!==yp&&u!==_p)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===yp&&(r=np),void 0===r&&u===_p&&(r=hp),i.call(this,null,n,o,a,s,c,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:qh,this.minFilter=void 0!==c?c:qh,this.flipY=!1,this.generateMipmaps=!1}function We(t){Rt.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&&(m[t+0]+=1),r<.2&&(m[t+2]+=1),n<.2&&(m[t+4]+=1))}}function s(t){d.push(t.x,t.y,t.z)}function c(e,r){var n=3*e;r.x=t[n+0],r.y=t[n+1],r.z=t[n+2]}function u(){for(var t=new l,e=new l,r=new l,i=new l,o=new n,a=new n,s=new n,c=0,u=0;c0)&&m.push(w,S,A),(c!==r-1||u0&&u(!0),e>0&&u(!1)),this.setIndex(p),this.addAttribute("position",new Ct(f,3)),this.addAttribute("normal",new Ct(d,3)),this.addAttribute("uv",new Ct(m,2))}function Mr(t,e,r,n,i,o,a){wr.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 Ar(t,e,r,n,i,o,a){Sr.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 Er(t,e,r,n){yt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new Cr(t,e,r,n)),this.mergeVertices()}function Cr(t,e,r,i){Rt.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 Ct(c,3)),this.addAttribute("normal",new Ct(u,3)),this.addAttribute("uv",new Ct(h,2))}function Tr(t){J.call(this),this.type="ShadowMaterial",this.color=new q(0),this.opacity=1,this.lights=!0,this.transparent=!0,this.setValues(t)}function Pr(t){tt.call(this,t),this.type="RawShaderMaterial"}function Lr(t){J.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new q(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 q(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 Rr(t){Lr.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function Nr(t){J.call(this),this.type="MeshPhongMaterial",this.color=new q(16777215),this.specular=new q(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(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=Lh,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 Ir(t){Nr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Or(t){J.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){J.call(this),this.type="MeshLambertMaterial",this.color=new q(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Lh,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 zr(t){Oe.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function Fr(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 kr(t){this.manager=void 0!==t?t:pf}function Ur(t){this.manager=void 0!==t?t:pf,this._parser=null}function Br(t){this.manager=void 0!==t?t:pf,this._parser=null}function Vr(t){this.manager=void 0!==t?t:pf}function jr(t){this.manager=void 0!==t?t:pf}function Gr(t){this.manager=void 0!==t?t:pf}function Wr(t,e){pt.call(this),this.type="Light",this.color=new q(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Hr(t,e,r){Wr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(pt.DefaultUp),this.updateMatrix(),this.groundColor=new q(e)}function Xr(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new n(512,512),this.map=null,this.matrix=new u}function Yr(){Xr.call(this,new mt(50,1,.5,500))}function qr(t,e,r,n,i,o){Wr.call(this,t,e),this.type="SpotLight",this.position.copy(pt.DefaultUp),this.updateMatrix(),this.target=new pt,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 Yr}function $r(t,e,r,n){Wr.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 Xr(new mt(90,1,.5,500))}function Zr(){Xr.call(this,new dt(-5,5,5,-5,.5,500))}function Kr(t,e){Wr.call(this,t,e),this.type="DirectionalLight",this.position.copy(pt.DefaultUp),this.updateMatrix(),this.target=new pt,this.shadow=new Zr}function Qr(t,e){Wr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Jr(t,e,r,n){Wr.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 tn(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 en(t,e,r,n){tn.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function rn(t,e,r,n){tn.call(this,t,e,r,n)}function nn(t,e,r,n){tn.call(this,t,e,r,n)}function on(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=ff.convertArray(e,this.TimeBufferType),this.values=ff.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function an(t,e,r,n){on.call(this,t,e,r,n)}function sn(t,e,r,n){tn.call(this,t,e,r,n)}function cn(t,e,r,n){on.call(this,t,e,r,n)}function ln(t,e,r,n){on.call(this,t,e,r,n)}function un(t,e,r,n){on.call(this,t,e,r,n)}function hn(t,e,r){on.call(this,t,e,r)}function pn(t,e,r,n){on.call(this,t,e,r,n)}function fn(t,e,r,n){on.apply(this,arguments)}function dn(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=Gp.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function mn(t){this.manager=void 0!==t?t:pf,this.textures={}}function gn(t){this.manager=void 0!==t?t:pf}function vn(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function yn(t){"boolean"==typeof t&&(t=void 0),this.manager=void 0!==t?t:pf,this.withCredentials=!1}function _n(t){this.manager=void 0!==t?t:pf,this.texturePath=""}function xn(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 bn(t,e){var r=1-t;return r*r*e}function wn(t,e){return 2*(1-t)*t*e}function Sn(t,e){return t*t*e}function Mn(t,e,r,n){return bn(t,e)+wn(t,r)+Sn(t,n)}function An(t,e){var r=1-t;return r*r*r*e}function En(t,e){var r=1-t;return 3*r*r*t*e}function Cn(t,e){return 3*(1-t)*t*t*e}function Tn(t,e){return t*t*t*e}function Pn(t,e,r,n,i){return An(t,e)+En(t,r)+Cn(t,n)+Tn(t,i)}function Ln(){this.arcLengthDivisions=200}function Rn(t,e){Ln.call(this),this.v1=t,this.v2=e}function Nn(){Ln.call(this),this.curves=[],this.autoClose=!1}function In(t,e,r,n,i,o,a,s){Ln.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 On(t){Ln.call(this),this.points=void 0===t?[]:t}function Dn(t,e,r,n){Ln.call(this),this.v0=t,this.v1=e,this.v2=r,this.v3=n}function zn(t,e,r){Ln.call(this),this.v0=t,this.v1=e,this.v2=r}function Fn(t){Nn.call(this),this.currentPoint=new n,t&&this.fromPoints(t)}function kn(){Fn.apply(this,arguments),this.holes=[]}function Un(){this.subPaths=[],this.currentPath=null}function Bn(t){this.data=t}function Vn(t){this.manager=void 0!==t?t:pf}function jn(t){this.manager=void 0!==t?t:pf}function Gn(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new mt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new mt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Wn(t,e,r){pt.call(this),this.type="CubeCamera";var n=new mt(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new l(1,0,0)),this.add(n);var i=new mt(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new l(-1,0,0)),this.add(i);var o=new mt(90,1,t,e);o.up.set(0,0,1),o.lookAt(new l(0,1,0)),this.add(o);var a=new mt(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new l(0,-1,0)),this.add(a);var c=new mt(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new l(0,0,1)),this.add(c);var u=new mt(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new l(0,0,-1)),this.add(u);var h={format:fp,magFilter:Kh,minFilter:Kh};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 Hn(){pt.call(this),this.type="AudioListener",this.context=bf.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Xn(t){pt.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 Yn(t){Xn.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function qn(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 $n(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 Zn(t,e,r){var n=r||Kn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function Kn(t,e,r){this.path=e,this.parsedPath=r||Kn.parseTrackName(e),this.node=Kn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Qn(t){this.uuid=Gp.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 Jn(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:Lp,endingEnd:Lp},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=Pp,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 ti(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function ei(t){"string"==typeof t&&(t=arguments[1]),this.value=t}function ri(){Rt.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function ni(t,e,r,n){this.uuid=Gp.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function ii(t,e){this.uuid=Gp.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 oi(t,e,r){ii.call(this,t,e),this.meshPerAttribute=r||1}function ai(t,e,r){_t.call(this,t,e),this.meshPerAttribute=r||1}function si(t,e,r,n){this.ray=new Ft(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 ci(t,e){return t.distance-e.distance}function li(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 Yi(t){var e=!1;this.enable=function(t){e=t};for(var r=0,n=Object.keys(t),i=0,o=n.length;i=3&&"base64"===e[r-2]?new Blob([Zi(e[r-1])]):null}function Ji(t,e,r){var n=document.createElement(t);return n.id=e,n.style.cssText=r,n}function to(){this.domElement=Ji("div","stats","padding:8px"),this._text=Ji("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=kf(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}function eo(){Vi.call(this),this._cancellationRequested=!1}function ro(){this.old=null,this.now={},this._changed={},this.reset()}function no(t){return!(!t||"0"===t||Bu.isString(t)&&"false"===t.toLowerCase())}function io(t){return Ff.encodeQueryComponent(t,Jf)}function oo(t){return Ff.encodeQueryComponent(t,td)}function ao(t){var e=t.reps;if(!e){var r=Bf.now.presets,n=t.preset||Bf.now.preset;(e=r[n])||(Of.warn('Unknown preset "'+n+'"'),e=r[n=Object.keys(r)[0]]),t.preset=n,t.reps=Ff.deriveDeep(e,!0)}}function so(t,e,r){ao(t);var n=t.reps[Xf];n.hasOwnProperty(e)&&++Xf>=t.reps.length&&(t.reps[Xf]=Ff.deriveDeep(n,!0)),void 0!==r&&(t.reps[Xf][e]=r)}function co(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}function lo(t,e){var r=t.indexOf(",");return r>=0?(e.push(t.substr(r+1).split(",")),t.substr(0,r)):t}function uo(t,e,r){if(t){var n=t.indexOf($f),i=lo(t.substr(0,n>=0?n:void 0),r);if(n>=0){var o=t.substr(n+1).split(Kf);if(t=i,e){var a=e[t],s=Ff.deriveDeep(a,!0);o.forEach(function(e){var r=e.split(Zf,2),n=decodeURIComponent(r[0]),i=decodeURIComponent(r[1]),o=Yf[Vf(Bu.get(a,n))];o?Bu.set(s,n,o(i)):Of.warn('Unknown argument "'+n+'" for option "'+t+'"')}),Object.keys(s).length>0&&(t=[t,s])}}else t=i}return t}function ho(t){Xf=0;for(var e={},r=0,n=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=$f+po(t.opts)),e}}function go(t){var e=[],r=0;return Ff.forInRecursive(t,function(t,n){e[r++]=n+"="+Ff.enquoteString(t)}),e.join(" ")}function vo(t){return Bu.isArray(t)?t[0]+(t.length<2?"":" "+go(t[1])):t}function yo(t){if(t&&t.type){var e=t.type;return Bu.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(Ff.enquoteString).join(" ")),t.opts&&(e+=" "+go(t.opts)),e}}function _o(t,e){function r(t,e){null!==e&&void 0!==e&&(n[i++]=t+e)}var n=[],i=0;return Bu.isEmpty(t)?null:(r("",e),r("s=",Ff.enquoteString(t.selector)),r("m=",vo(t.mode)),r("c=",vo(t.colorer)),r("mt=",vo(t.material)),n.join(" "))}function xo(t,e){this._node=e||null,this._name=t||null,null===this._node&&null===this._name&&(this._name="Unknown")}function bo(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 wo(t,e,r,n,i,o,a,s,c,l,u){this._index=-1,this._residue=t,this._name=e instanceof xo?e:new xo(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|=wo.Flags.HYDROGEN:"C"===r.name&&(this.flags|=wo.Flags.CARBON)}function So(t){return t<2?1:t}function Mo(t){return t._position}function Ao(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 Eo(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function Co(t,e){for(var r=0,n=e.length;r0)return t;var i=e*r,o=Ch[i];if(void 0===o&&(o=new Float32Array(i),Ch[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=Th[e];void 0===r&&(r=new Int32Array(e),Th[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):(Lh.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Lh))}function M(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Ph.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Ph))}function A(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Ah,n)}function E(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Eh,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 z(t,e){t.uniformMatrix3fv(this.addr,!1,d(e,this.size,9))}function F(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]||Ah,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]||Eh,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 z;case 35676:return F;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(Rh.lastIndex=0;;){var o=Rh.exec(n),a=Rh.lastIndex,s=o[1],c="]"===o[2],l=o[3];if(c&&(s|=0),void 0===l||"["===l&&a+2===i){G(r,void 0===l?new B(s,t,e):new V(s,t,e));break}var u=r.map[s];void 0===u&&G(r,u=new j(s)),r=u}}function H(t,e,r){f.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,b=R.size*R.scale/g.w,w.x=b*y,w.y=b,e.uniform3f(f.screenPosition,S.x,S.y,S.z),e.uniform2f(f.scale,w.x,w.y),e.uniform1f(f.rotation,R.rotation),e.uniform1f(f.opacity,R.opacity),e.uniform3f(f.color,R.color.r,R.color.g,R.color.b),r.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),i.setTexture2D(R.texture,1),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0))}}}r.enable(e.CULL_FACE),r.enable(e.DEPTH_TEST),r.buffers.depth.setMask(!0),r.reset()}}}function $(t,e,r,n,o,a,s,c,l){i.call(this,t,e,r,n,o,a,s,c,l),this.needsUpdate=!0}function Z(t,e,r,n,i){function o(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),r=new Uint16Array([0,1,2,0,2,3]);s=e.createBuffer(),u=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.bufferData(e.ELEMENT_ARRAY_BUFFER,r,e.STATIC_DRAW),h=function(){var t=e.createProgram(),r=e.createShader(e.VERTEX_SHADER),n=e.createShader(e.FRAGMENT_SHADER);return e.shaderSource(r,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),e.shaderSource(n,["precision "+i.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),e.compileShader(r),e.compileShader(n),e.attachShader(t,r),e.attachShader(t,n),e.linkProgram(t),t}(),p={position:e.getAttribLocation(h,"position"),uv:e.getAttribLocation(h,"uv")},f={uvOffset:e.getUniformLocation(h,"uvOffset"),uvScale:e.getUniformLocation(h,"uvScale"),rotation:e.getUniformLocation(h,"rotation"),scale:e.getUniformLocation(h,"scale"),color:e.getUniformLocation(h,"color"),map:e.getUniformLocation(h,"map"),opacity:e.getUniformLocation(h,"opacity"),modelViewMatrix:e.getUniformLocation(h,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(h,"projectionMatrix"),fogType:e.getUniformLocation(h,"fogType"),fogDensity:e.getUniformLocation(h,"fogDensity"),fogNear:e.getUniformLocation(h,"fogNear"),fogFar:e.getUniformLocation(h,"fogFar"),fogColor:e.getUniformLocation(h,"fogColor"),alphaTest:e.getUniformLocation(h,"alphaTest")};var n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=8,n.height=8;var o=n.getContext("2d");o.fillStyle="white",o.fillRect(0,0,8,8),d=new $(n)}function a(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var s,u,h,p,f,d,m=new l,g=new c,v=new l;this.render=function(i,c,l){if(0!==i.length){void 0===h&&o(),r.useProgram(h),r.initAttributes(),r.enableAttribute(p.position),r.enableAttribute(p.uv),r.disableUnusedAttributes(),r.disable(e.CULL_FACE),r.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(p.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(p.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u),e.uniformMatrix4fv(f.projectionMatrix,!1,l.projectionMatrix.elements),r.activeTexture(e.TEXTURE0),e.uniform1i(f.map,0);var y=0,_=0,x=c.fog;x?(e.uniform3f(f.fogColor,x.color.r,x.color.g,x.color.b),x.isFog?(e.uniform1f(f.fogNear,x.near),e.uniform1f(f.fogFar,x.far),e.uniform1i(f.fogType,1),y=1,_=1):x.isFogExp2&&(e.uniform1f(f.fogDensity,x.density),e.uniform1i(f.fogType,2),y=2,_=2)):(e.uniform1i(f.fogType,0),y=0,_=0);for(var b=0,w=i.length;b0:s&&s.isGeometry&&(h=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&r.skinning;var p=e.isSkinnedMesh&&r.skinning,f=0;h&&(f|=g),p&&(f|=v),c=l[f]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var d=c.uuid,m=r.uuid,y=b[d];void 0===y&&(y={},b[d]=y);var w=y[m];void 0===w&&(w=c.clone(),y[m]=w),c=w}c.visible=r.visible,c.wireframe=r.wireframe;var S=r.side;return L.renderSingleSided&&S==Ll&&(S=Tl),L.renderReverseSided&&(S===Tl?S=Pl:S===Pl&&(S=Tl)),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=Sh.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=Dh[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return $t(r)})}function Zt(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,v=function(t,e,r){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Yt).join("\n")}(n.extensions,o,e),y=function(t){var e=[];for(var r in t){var n=t[r];!1!==n&&e.push("#define "+r+" "+n)}return e.join("\n")}(s),_=a.createProgram();n.isRawShaderMaterial?(d=[y,"\n"].filter(Yt).join("\n"),m=[v,y,"\n"].filter(Yt).join("\n")):(d=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Yt).join("\n"),m=[v,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,y,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+g,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+p:"",o.envMap?"#define "+f:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+u:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==fu?"#define TONE_MAPPING":"",o.toneMapping!==fu?Dh.tonemapping_pars_fragment:"",o.toneMapping!==fu?function(t,e){var r;switch(e){case du:r="Linear";break;case mu:r="Reinhard";break;case gu:r="Uncharted2";break;case vu: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?Dh.encodings_pars_fragment:"",o.mapEncoding?Xt("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Xt("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Xt("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?function(t,e){var r=Ht(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Yt).join("\n")),c=qt(c=$t(c),o),l=qt(l=$t(l),o),n.isShaderMaterial||(c=Zt(c),l=Zt(l));var x=d+c,b=m+l,w=Wt(a,a.VERTEX_SHADER,x),S=Wt(a,a.FRAGMENT_SHADER,b);a.attachShader(_,w),a.attachShader(_,S),void 0!==n.index0AttributeName?a.bindAttribLocation(_,0,n.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(_,0,"position"),a.linkProgram(_);var M=a.getProgramInfoLog(_),A=a.getShaderInfoLog(w),E=a.getShaderInfoLog(S),C=!0,T=!0;!1===a.getProgramParameter(_,a.LINK_STATUS)?C=!1:""!==M||""!==A&&""!==E||(T=!1),T&&(this.diagnostics={runnable:C,material:n,programLog:M,vertexShader:{log:A,prefix:d},fragmentShader:{log:E,prefix:m}}),a.deleteShader(w),a.deleteShader(S);var P;this.getUniforms=function(){return void 0===P&&(P=new H(a,_,t)),P};var L;return this.getAttributes=function(){return void 0===L&&(L=function(t,e,r){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o0,maxBones:p,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numClippingPlanes:c,numClipIntersection:l,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&a.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Ll,flipSided:e.side===Pl,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 Sh.isPowerOfTwo(t.width)&&Sh.isPowerOfTwo(t.height)}function l(t,e){return t.generateMipmaps&&e&&t.minFilter!==Tu&&t.minFilter!==Ru}function u(e){return e===Tu||e===Pu||e===Lu?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!==Eu||t.wrapT!==Eu||t.minFilter!==Tu&&t.minFilter!==Ru})(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=Sh.nearestPowerOfTwo(t.width),e.height=Sh.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===Bu){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===Qu&&x===t.DEPTH_COMPONENT&&n.type!==Fu&&n.type!==Uu&&(n.type=Fu,g=o.convert(n.type)),n.format===Ju&&(x=t.DEPTH_STENCIL,n.type!==Hu&&(n.type=Hu,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===Qu)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(r.depthTexture.format!==Ju)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(r.__webglFramebuffer,e)}else if(i){r.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[o]),r.__webglDepthbuffer[o]=t.createRenderbuffer(),g(r.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),g(r.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}var y="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=f,this.setTextureCube=function(e,u){var p=n.get(e);if(6===e.image.length)if(e.version>0&&p.__version!==e.version){p.__image__webglTextureCube||(e.addEventListener("dispose",h),p.__image__webglTextureCube=t.createTexture(),a.textures++),r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,p.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var f=e&&e.isCompressedTexture,m=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=f||m?m?e.image[v].image:e.image[v]:s(e.image[v],i.maxCubemapSize);var y=c(g[0]),_=o.convert(e.format),x=o.convert(e.type);for(d(t.TEXTURE_CUBE_MAP,e,y),v=0;v<6;v++)if(f)for(var b,w=g[v].mipmaps,S=0,M=w.length;S-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,b.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,S,_,b.width,b.height,0,_,x,b.data);else m?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,g[v].width,g[v].height,0,_,x,g[v].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,_,_,x,g[v]);l(e,y)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),p.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+u),r.bindTexture(t.TEXTURE_CUBE_MAP,p.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",p),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,u=c(e);if(s)for(i.__webglFramebuffer=[],h=0;h<6;h++)i.__webglFramebuffer[h]=t.createFramebuffer();else i.__webglFramebuffer=t.createFramebuffer();if(s){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),d(t.TEXTURE_CUBE_MAP,e.texture,u);for(var h=0;h<6;h++)m(i.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);l(e.texture,u)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),d(t.TEXTURE_2D,e.texture,u),m(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),l(e.texture,u)&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&v(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(l(i,c(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function te(t){ft.call(this),this.cameras=t||[]}function ee(t,e){return{convert:function(r){var n;if(r===Au)return t.REPEAT;if(r===Eu)return t.CLAMP_TO_EDGE;if(r===Cu)return t.MIRRORED_REPEAT;if(r===Tu)return t.NEAREST;if(r===Pu)return t.NEAREST_MIPMAP_NEAREST;if(r===Lu)return t.NEAREST_MIPMAP_LINEAR;if(r===Ru)return t.LINEAR;if(r===Nu)return t.LINEAR_MIPMAP_NEAREST;if(r===Iu)return t.LINEAR_MIPMAP_LINEAR;if(r===Ou)return t.UNSIGNED_BYTE;if(r===ju)return t.UNSIGNED_SHORT_4_4_4_4;if(r===Gu)return t.UNSIGNED_SHORT_5_5_5_1;if(r===Wu)return t.UNSIGNED_SHORT_5_6_5;if(r===Du)return t.BYTE;if(r===zu)return t.SHORT;if(r===Fu)return t.UNSIGNED_SHORT;if(r===ku)return t.INT;if(r===Uu)return t.UNSIGNED_INT;if(r===Bu)return t.FLOAT;if(r===Vu&&null!==(n=e.get("OES_texture_half_float")))return n.HALF_FLOAT_OES;if(r===Xu)return t.ALPHA;if(r===Yu)return t.RGB;if(r===qu)return t.RGBA;if(r===$u)return t.LUMINANCE;if(r===Zu)return t.LUMINANCE_ALPHA;if(r===Qu)return t.DEPTH_COMPONENT;if(r===Ju)return t.DEPTH_STENCIL;if(r===Bl)return t.FUNC_ADD;if(r===Vl)return t.FUNC_SUBTRACT;if(r===jl)return t.FUNC_REVERSE_SUBTRACT;if(r===Hl)return t.ZERO;if(r===Xl)return t.ONE;if(r===Yl)return t.SRC_COLOR;if(r===ql)return t.ONE_MINUS_SRC_COLOR;if(r===$l)return t.SRC_ALPHA;if(r===Zl)return t.ONE_MINUS_SRC_ALPHA;if(r===Kl)return t.DST_ALPHA;if(r===Ql)return t.ONE_MINUS_DST_ALPHA;if(r===Jl)return t.DST_COLOR;if(r===tu)return t.ONE_MINUS_DST_COLOR;if(r===eu)return t.SRC_ALPHA_SATURATE;if((r===th||r===eh||r===rh||r===nh)&&null!==(n=e.get("WEBGL_compressed_texture_s3tc"))){if(r===th)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===eh)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===rh)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===nh)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((r===ih||r===oh||r===ah||r===sh)&&null!==(n=e.get("WEBGL_compressed_texture_pvrtc"))){if(r===ih)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===oh)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===ah)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===sh)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(r===ch&&null!==(n=e.get("WEBGL_compressed_texture_etc1")))return n.COMPRESSED_RGB_ETC1_WEBGL;if((r===Gl||r===Wl)&&null!==(n=e.get("EXT_blend_minmax"))){if(r===Gl)return n.MIN_EXT;if(r===Wl)return n.MAX_EXT}return r===Hu&&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(ou),c(!1),l(Sl),i(t.CULL_FACE),i(t.BLEND),s(Dl),{buffers:{color:p,depth:f,stencil:d},initAttributes:function(){for(var t=0,e=g.length;t65535?Mt:wt)(i,1),e.update(n,t.ELEMENT_ARRAY_BUFFER),o[r.id]=n,n}}}(vt,Et,mt),Lt=new function(t,e){var r={};return{update:function(n){var i=e.frame,o=n.geometry,a=t.get(n,o);return r[a.id]!==i&&(o.isGeometry&&a.updateFromObject(n),t.update(a),r[a.id]=i),a},clear:function(){r={}}}}(Ct,gt),Ut=new function(t){var e={},r=new Float32Array(8);return{update:function(n,i,o,a){var s=n.morphTargetInfluences,c=s.length,l=e[i.id];if(void 0===l){for(l=[],p=0;p=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p=0&&t.numSupportedMorphNormals++}var f=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=ct.numPlanes,n.numIntersection=ct.numIntersection,f.clippingPlanes=ct.uniform),n.fog=e,n.lightsHash=Nt.state.hash,t.lights&&(f.ambientLightColor.value=Nt.state.ambient,f.directionalLights.value=Nt.state.directional,f.spotLights.value=Nt.state.spot,f.rectAreaLights.value=Nt.state.rectArea,f.pointLights.value=Nt.state.point,f.hemisphereLights.value=Nt.state.hemi,f.directionalShadowMap.value=Nt.state.directionalShadowMap,f.directionalShadowMatrix.value=Nt.state.directionalShadowMatrix,f.spotShadowMap.value=Nt.state.spotShadowMap,f.spotShadowMatrix.value=Nt.state.spotShadowMatrix,f.pointShadowMap.value=Nt.state.pointShadowMap,f.pointShadowMatrix.value=Nt.state.pointShadowMatrix);var d=n.program.getUniforms(),m=H.seqWithValue(d.seq,f);n.uniformsList=m}function g(t,e,r,n){W=0;var i=St.get(r);if(lt&&(ut||t!==U)){var o=t===U&&r.id===F;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!==F&&(F=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=Sh.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,qu,Bu);d.boneMatrices=b,d.boneTexture=w,d.boneTextureSize=x}u.setValue(vt,"boneTexture",d.boneTexture),u.setValue(vt,"boneTextureSize",d.boneTextureSize)}else u.setOptional(vt,d,"boneMatrices")}}return(s||r.forceUniformsUpdate)&&(u.setValue(vt,"toneMappingExposure",I.toneMappingExposure),u.setValue(vt,"toneMappingWhitePoint",I.toneMappingWhitePoint),r.lights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(p,c),e&&r.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(p,e),r.isMeshBasicMaterial?v(p,r):r.isMeshLambertMaterial?(v(p,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(p,r)):r.isMeshPhongMaterial?(v(p,r),r.isMeshToonMaterial?function(t,e){y(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(p,r):y(p,r)):r.isMeshStandardMaterial?(v(p,r),r.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,_(t,e)}(p,r):_(p,r)):r.isMeshDepthMaterial?(v(p,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(p,r)):r.isMeshDistanceMaterial?(v(p,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(p,r)):r.isMeshNormalMaterial?(v(p,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(p,r)):r.isLineBasicMaterial?(function(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}(p,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(p,r)):r.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*K,t.scale.value=.5*$,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}(p,r):r.isShadowMaterial&&(p.color.value=r.color,p.opacity.value=r.opacity),void 0!==p.ltcMat&&(p.ltcMat.value=Ih.LTC_MAT_TEXTURE),void 0!==p.ltcMag&&(p.ltcMag.value=Ih.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=du,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var I=this,O=!1,D=null,z=null,F=-1,k="",U=null,B=null,V=new o,j=new o,G=null,W=0,Y=x.width,$=x.height,K=1,J=new o(0,0,Y,$),tt=new o(0,0,Y,$),et=!1,rt=new ot,ct=new function(){function t(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=l.value,!0!==i||null===a){var u=n+4*o,h=e.matrixWorldInverse;c.getNormalMatrix(h),(null===a||a.length=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize,p=Et.get(l);if(void 0===p)continue;var f=p.buffer,d=p.type,m=p.bytesPerElement;if(l.isInterleavedBufferAttribute){var g=l.data,v=g.stride,y=l.offset;g&&g.isInstancedInterleavedBuffer?(bt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=g.meshPerAttribute*g.count)):bt.enableAttribute(c),vt.bindBuffer(vt.ARRAY_BUFFER,f),vt.vertexAttribPointer(c,h,d,u,v*m,(n*v+y)*m)}else l.isInstancedBufferAttribute?(bt.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=l.meshPerAttribute*l.count)):bt.enableAttribute(c),vt.bindBuffer(vt.ARRAY_BUFFER,f),vt.vertexAttribPointer(c,h,d,u,0,n*h*m)}else if(void 0!==a){var _=a[s];if(void 0!==_)switch(_.length){case 2:vt.vertexAttrib2fv(c,_);break;case 3:vt.vertexAttrib3fv(c,_);break;case 4:vt.vertexAttrib4fv(c,_);break;default:vt.vertexAttrib1fv(c,_)}}}}bt.disableUnusedAttributes()}}(i,s,n),null!==u&&vt.bindBuffer(vt.ELEMENT_ARRAY_BUFFER,f.buffer));var m=0;null!==u?m=u.count:void 0!==h&&(m=h.count);var v=n.drawRange.start*p,y=n.drawRange.count*p,_=null!==a?a.start*p:0,x=null!==a?a.count*p:1/0,b=Math.max(v,_),w=Math.min(m,v+y,_+x)-1,S=Math.max(0,w-b+1);if(0!==S){if(o.isMesh)if(!0===i.wireframe)bt.setLineWidth(i.wireframeLinewidth*e()),d.setMode(vt.LINES);else switch(o.drawMode){case hh:d.setMode(vt.TRIANGLES);break;case ph:d.setMode(vt.TRIANGLE_STRIP);break;case fh: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,z)}}}}}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:Qu)!==Qu&&u!==Ju)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===Qu&&(r=Fu),void 0===r&&u===Ju&&(r=Hu),i.call(this,null,n,o,a,s,c,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:Tu,this.minFilter=void 0!==c?c:Tu,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 ze(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 Fe(t,e,r,n,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function Fe(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=uu,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=uu,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:Hh}function yr(t){this.manager=void 0!==t?t:Hh,this._parser=null}function _r(t){this.manager=void 0!==t?t:Hh,this._parser=null}function xr(t){this.manager=void 0!==t?t:Hh}function br(t){this.manager=void 0!==t?t:Hh}function wr(t){this.manager=void 0!==t?t:Hh}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 zr(t,e,r,n){Ir.call(this,t,e,r,n)}function Fr(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=Xh.convertArray(e,this.TimeBufferType),this.values=Xh.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function kr(t,e,r,n){Fr.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){Fr.call(this,t,e,r,n)}function Vr(t,e,r,n){Fr.call(this,t,e,r,n)}function jr(t,e,r,n){Fr.call(this,t,e,r,n)}function Gr(t,e,r){Fr.call(this,t,e,r)}function Wr(t,e,r,n){Fr.call(this,t,e,r,n)}function Hr(t,e,r,n){Fr.apply(this,arguments)}function Xr(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=Sh.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Yr(t){this.manager=void 0!==t?t:Hh,this.textures={}}function qr(t){this.manager=void 0!==t?t:Hh}function $r(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function Zr(t){"boolean"==typeof t&&(t=void 0),this.manager=void 0!==t?t:Hh,this.withCredentials=!1}function Kr(t){this.manager=void 0!==t?t:Hh,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:Hh}function dn(t){this.manager=void 0!==t?t:Hh}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:Yu,magFilter:Ru,minFilter:Ru};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=tp.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=Sh.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:uh,endingEnd:uh},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=lh,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=Sh.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function Ln(t,e){this.uuid=Sh.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&&fp.debug(i+e+" {"),n++;var o=t.apply(this,arguments);return n--,r&&fp.debug(i+"} // "+e),o}}var r=!1;this.enable=function(t){r=t};for(var n=0,i=Object.keys(t),o=0,a=i.length;o=3&&"base64"===e[r-2]?new Blob([wi(e[r-1])]):null}function Ai(t,e,r){var n=document.createElement(t);return n.id=e,n.style.cssText=r,n}function Ei(){this.domElement=Ai("div","stats","padding:8px"),this._text=Ai("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=vp(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}function Ci(){fi.call(this),this._cancellationRequested=!1}function Ti(){this.old=null,this.now={},this._changed={},this.reset()}function Pi(t){return!(!t||"0"===t||xl.isString(t)&&"false"===t.toLowerCase())}function Li(t){return gp.encodeQueryComponent(t,Np)}function Ri(t){return gp.encodeQueryComponent(t,Ip)}function Ni(t){var e=t.reps;if(!e){var r=_p.now.presets,n=t.preset||_p.now.preset;(e=r[n])||(fp.warn('Unknown preset "'+n+'"'),e=r[n=Object.keys(r)[0]]),t.preset=n,t.reps=gp.deriveDeep(e,!0)}}function Ii(t,e,r){Ni(t);var n=t.reps[Ap];n.hasOwnProperty(e)&&++Ap>=t.reps.length&&(t.reps[Ap]=gp.deriveDeep(n,!0)),void 0!==r&&(t.reps[Ap][e]=r)}function Oi(t,e,r){if(t){var n=t.indexOf(Tp),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(Lp);if(t=i,e){var a=e[t],s=gp.deriveDeep(a,!0);o.forEach(function(e){var r=e.split(Pp,2),n=decodeURIComponent(r[0]),i=decodeURIComponent(r[1]),o=Ep[xp(xl.get(a,n))];o?xl.set(s,n,o(i)):fp.warn('Unknown argument "'+n+'" for option "'+t+'"')}),Object.keys(s).length>0&&(t=[t,s])}}else t=i}return t}function Di(t){Ap=0;for(var e={},r=0,n=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Tp+zi(t.opts)),e}}function Ui(t){var e=[],r=0;return gp.forInRecursive(t,function(t,n){e[r++]=n+"="+gp.enquoteString(t)}),e.join(" ")}function Bi(t){return xl.isArray(t)?t[0]+(t.length<2?"":" "+Ui(t[1])):t}function Vi(t){if(t&&t.type){var e=t.type;return xl.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(gp.enquoteString).join(" ")),t.opts&&(e+=" "+Ui(t.opts)),e}}function ji(t,e){function r(t,e){null!==e&&void 0!==e&&(n[i++]=t+e)}var n=[],i=0;return xl.isEmpty(t)?null:(r("",e),r("s=",gp.enquoteString(t.selector)),r("m=",Bi(t.mode)),r("c=",Bi(t.colorer)),r("mt=",Bi(t.material)),n.join(" "))}function Gi(t,e){this._node=e||null,this._name=t||null,null===this._node&&null===this._name&&(this._name="Unknown")}function Wi(t,e,r,n,i,o,a){this.number=t,this.name=e,this.fullName=r,this.weight=n,this.radius=i,this.radiusBonding=o,this.hydrogenValency=a}function Hi(t,e,r,n,i,o,a,s,c,l,u){this._index=-1,this._residue=t,this._name=e instanceof Gi?e:new Gi(e),this.element=r,this._position=n,this._role=i,this._mask=1,this._index=-1,this._het=o,this._serial=a,this._location=(s||" ").charCodeAt(0),this._occupancy=c||1,this._temperature=l,this._charge=u,this._hydrogenCount=-1,this._radicalCount=0,this._valence=-1,this._bonds=[],this.flags=0,"H"===r.name?this.flags|=Hi.Flags.HYDROGEN:"C"===r.name&&(this.flags|=Hi.Flags.CARBON)}function Xi(t){return t<2?1:t}function Yi(t,e,r,n,i){if(this._left=t,this._right=e,this._fixed=i,this._index=-1,t>e)throw new Error("In a bond atom indices must be in increasing order");this._order=r,this._type=n}function qi(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function $i(t,e){for(var r=0,n=e.length;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 Do(){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=Oo(Go(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function zo(t){var e=Fo(t),r="/"===md(t,-1);return(t=Oo(Go(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function Fo(t){return"/"===t.charAt(0)}function ko(){return zo(Go(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 Uo(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=Do(t).substr(1),e=Do(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 ta(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function ea(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function ra(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 na(t){for(var e=Ao.BondType.UNKNOWN,r=t._residues,n=0,i=r.length;n3}function pa(t){return!0}function fa(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 va(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 ya(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 _a(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=Ff.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 _t(Ff.allocateTyped(Float32Array,3*u),3),d=new _t(Ff.allocateTyped(Float32Array,3*u),3),m=new Mt(Ff.allocateTyped(Uint16Array,h*am),1),g=new _t(Ff.allocateTyped(Float32Array,2*u),2),v=0,y=0,_=-(e-t)/r,x=0;x<=i;x++){if(x!==i)for(var b=0;bE&&(E=P)}this.neighbourListLength=27*E+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),A=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(b=A;b<=T;++b)for(var R=b*g,N=E;N<=P;++N)for(var I=w[a=L+R+N],O=I+S[a],D=I;Dx&&(x=e),_[t]=e*e}s(),c(),u(),W=-1}function o(t,e,r){for(var n=Ff.allocateTyped(t,e),i=0;i=0;){if(o!==n&&o!==i&&p(o,t,e,r))return W=o,o;o=O[++a]}return W=-1,-1}function p(t,e,r,n){var i=z*t,o=_[t],a=F[i]-e,s=F[i+1]-r,c=F[i+2]-n;return a*a+s*s+c*cH[Z]&&(H[Z]=J,X[Z]=U[t]),A[Z]<0&&(A[Z]=-A[Z]);var et=Math.sqrt(Q),rt=o/et,nt=K*rt,it=G*rt,ot=N*rt;if(nt+=r,it+=n,ot+=i,-1===h(nt,it,ot,t,-1)){var at=o-et;at=0;)t0&&f0){r=1/r;var n=3*t;E[n]*=r,E[n+1]*=r,E[n+2]*=r}}}function y(){i(),f(),d(),v()}var _,x,b,w,S,M,A,E,C,T,P,L,R,N,I,O,D,z=4,F=t.posRad,k=t.colors,U=t.atoms,B=F.length/z,V=e.bbox,j=V.minPosRad,G=V.maxPosRad,W=-1,H=null,X=null,Y=null,q=new l(0,0,0),$=new l(0,0,0),Z=new l(0,0,0);this.build=function(){y(),this.volTexMap=E,this.weightsMap=H,this.atomMap=X,this.volMap=A}}function fs(t,e){ls.call(this,t,e)}function ds(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 ms(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 gs(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 vs(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 gc(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 ba(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 vc(t,e,r,n,i,o,a,s){var c=this;wa.call(c);for(var u=new wa,h=0;h>16&255)+r*(e>>16&255)<<16|n*(t>>8&255)+r*(e>>8&255)<<8|n*(255&t)+r*(255&e)}function Bc(t,e){this.name=t||"Custom",this.id=e||"CP"}function Vc(t){if(this.constructor===Vc)throw new Error("Can not instantiate abstract class!");this.opts=Bu.merge(Ff.deriveDeep(Bf.now.colorers[this.id],!0),t),this.palette=hg.any}function jc(t){Vc.call(this,t)}function Gc(t){Vc.call(this,t)}function Wc(t){Vc.call(this,t)}function Hc(t){Vc.call(this,t)}function Xc(t){Vc.call(this,t)}function Yc(t){Vc.call(this,t)}function qc(t){Vc.call(this,t);var e=Od.parse(this.opts.subset);this._subsetCached=e.error?Od.none():e.selector}function $c(t){Vc.call(this,t)}function Zc(t){Vc.call(this,t)}function Kc(t){Vc.call(this,t)}function Qc(t){Vc.call(this,t)}function Jc(t){Vc.call(this,t)}function tl(t){return new q(t,t,t)}function el(t,e,r,n){this.index=t,this.mode=e,this.colorer=r,this.selector=n,this.selectorString="",this.count=0,this.material=new Sa,this.material.setValues({clipPlane:Bf.now.draft.clipPlane}),this.materialPreset=_g.any,this.needsRebuild=!0,this.visible=!0,this.setMode(e)}function rl(t,e,r){var n=t.children;if(n)for(var i=0,o=n.length;i0&&(e.data=window.atob(t.substring(r+1)),e.fileType=t.substring(0,r).toLowerCase())}pl.call(this,t,e)}function gl(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}function vl(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}function yl(t){var e=4===t.trim().length;return t.slice(0,e?1:2).trim()}function _l(t,e){Cg.call(this,t,e),this._complex=null,this._chain=null,this._residue=null,this._sheet=null,this._serialAtomMap=null,this._modelId=1,this._compaundFound=!1,this._biomoleculeFound=!1,this._allowedChainsIDs=null,this._lastMolId=-1,this._remarks={},this._remark=null,this._molecules=[],this._molecule=null,this._compndCurrToken="",e.fileType="pdb"}function xl(t,e){Cg.call(this,t,e),this._complex=null,e.fileType="mol"}function bl(t,e){Cg.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,e.fileType="cml"}function wl(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=bv?t-wv:t}function Vl(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 jl(t,e){if(this.constructor===jl)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=Bu.merge(Ff.deriveDeep(Bf.now.objects[this.type],!0),e),this.needsRebuild=!1}function Gl(t,e){if(jl.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 Wl(t){var e=tf.clone(Cv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Hl(t){return new tt({uniforms:Wl(t),vertexShader:Av,fragmentShader:Ev,transparent:!0,depthTest:!1,depthWrite:!1})}function Xl(t){var e=tf.clone(Pv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Yl(t){return new tt({uniforms:Xl(t),vertexShader:Av,fragmentShader:Tv,transparent:!0,depthTest:!1,depthWrite:!1})}function ql(t,e){var r=tf.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}function $l(t){var e=tf.clone(Fv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Zl(t){return new tt({uniforms:$l(t),vertexShader:Av,fragmentShader:zv,transparent:!1,depthTest:!1,depthWrite:!1})}function Kl(){this.position=new l(0,0,0),this.scale=1,this.orientation=new c(0,0,0,1)}function Ql(){}function Jl(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 tu(t,e,r,n,i){jv.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))},Jl)},Jl)}function eu(){}function ru(t){for(var e=[],r=0,n=t.length;r=0&&(t=t.substr(0,e)),t}function yu(t){if("string"==typeof t)if(t.match(/^[0-9A-Z]{4}$/i))t=t.toUpperCase();else if(t.match(/^data\/[0-9A-Z]{4}\.pdb$/i))t=t.substr(5,4).toUpperCase();else{var e=document.createElement("a");e.href=t,t=e.href}return t}function _u(t){var e=!1;return t.forEachComponent(function(t){t.forEachResidue(function(t){t._isValid&&(e=!0)})}),e}function xu(t,e,r){r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function bu(t){Vi.call(this),this._opts=Bu.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||Bu.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=Bf;var e=Of;e.console=!1,e.level="info",this.logger=e,this._cookies=new mu(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loader=null,this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._fileSource=null,this._fileSourceAnim=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;bu.registeredPlugins.forEach(function(t){t.call(r)})}function wu(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}function Su(t,e,r,n){return new Promise(function(i,o){if(e=e||{},t instanceof File&&t.name.match(/.man$/i)&&(e.binary=!0,e.animation=!0),t instanceof File&&(t.name.match(/.mmtf$/i)||t.name.match(/.ccp4$/i))?e.binary=!0:Bu.isString(t)&&t.match(/.mmtf$/i)&&(e.binary=!0),!e.mdFile&&!e.fileType&&"string"==typeof t){var a=t.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/);if(a){var s=a[2].trim(),c=a[1];switch(c){case"pubchem":case"pubchem+json":c="pubchem+json",t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+encodeURIComponent(s)+"/JSON?record_type=3d",e.sourceType="url",e.fileName=s+".json";break;default:if(s.match(/^\w{4}$/i))switch(c=c||"pdb"){case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s,e.sourceType="url";break;case"cif":case"pdb":t="http://files.rcsb.org/view/"+s+"."+c,e.sourceType="url"}else c=void 0}c&&(e.fileType=c)}}"mmtf"===e.fileType&&(e.binary=!0);var l=yv.loaders.create(n,t,e),u=Bu.get(e,"preset.expression");if(!Bu.isUndefined(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit","draft.waterBondingHack"],p=0,f=h.length;p=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function no(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return t=ro(ho(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function io(t){var e=oo(t),r="/"===qp(t,-1);return(t=ro(ho(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function oo(t){return"/"===t.charAt(0)}function ao(){return io(ho(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function so(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=no(t).substr(1),e=no(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;sr?r:t}function So(t){this._complex=t,this._maxRad=1.8;var e=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=e.min.clone(),this._vBoxMax=e.max.clone(),this._pairCollection=null}function Mo(t,e){for(var r=0;r3}function Ro(t){return!0}function No(t){this._complex=t;for(var e=new Array(t._bonds.length),r=new Array(t._bonds.length),n=0,i=e.length;n>1;t;)e<<=1,t>>=1;return e}function zo(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 Fo(t,e,r,n){var i,o=r-t.y,a=n-t.y,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.y&&n>=t.y?e:Math.max(s,c),[l,i]}function ko(t,e){var r;this._box=t.clone(),this._count=t.size().divide(e).floor(),this._last=this._count.clone().subScalar(1),this._cellSize=t.size().divide(this._count);var n=this._count.x*this._count.y*this._count.z;for(this._voxels=gp.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(gp.allocateTyped(Float32Array,3*u),3),d=new vt(gp.allocateTyped(Float32Array,3*u),3),m=new wt(gp.allocateTyped(Uint16Array,h*Bf),1),g=new vt(gp.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=gp.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 z=o,o;o=E[++a]}return z=-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&&fF[Z]&&(F[Z]=J,k[Z]=R[t]),v[Z]<0&&(v[Z]=-v[Z]);var et=Math.sqrt(Q),rt=o/et,nt=K*rt,it=X*rt,ot=G*rt;if(nt+=r,it+=n,ot+=i,-1===a(nt,it,ot,t,-1)){var at=o-et;at0){r=1/r;var n=3*t;y[n]*=r,y[n+1]*=r,y[n+2]*=r}}}()}var h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C,T=4,P=t.posRad,L=t.colors,R=t.atoms,N=P.length/T,I=e.bbox,O=I.minPosRad,D=I.maxPosRad,z=-1,F=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=F,this.atomMap=k,this.volMap=v}}function Ma(t,e){ba.call(this,t,e)}function Aa(t,e){this.coord=new l,this.coord.copy(t),this.radius=e,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null}function Ea(t,e,r,n,i){this._numAtoms=t,this._atoms=e,this._vBoxMin=new l,this._vBoxMax=new l,this._vBoxMin.copy(r),this._vBoxMax.copy(n),this._probeRadius=i,this._atomsList=null,this._voxelList=null}function Ca(t,e,r,n,i,o,a){this.complex=t,this.atoms=r,this.pdbAtoms=e,this.numVoxels=o,this.colorMode=a,this.vBoxMin=new l,this.vBoxMax=new l,this.vBoxMin.copy(n),this.vBoxMax.copy(i),this.voxelsRefs=null,this.voxels=null}function Ta(t,e,r){this._maxNumVertices=t,this._maxNumTriangles=e,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,r&&(this._colors=new Array(t)),this._indices=new Array(3*e),this._numVertices=0,this._numTriangles=0;var n;for(n=0;n0?n:[new u];for(var o=this._createMeshes(t),a=0,s=o.length;as&&t[e-1]._isValid?e-1:e}function o(e){return e0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:l,chunks:p,parent:r},n,i,u,o,s);g._component=h,c.add(g)})}function xs(t,e,r){var n=document.createElement("div");if(n.className="label label-sgroup",n.style.color=e,"string"==typeof r){var i=document.createElement("span");i.style.fontSize="150%";var o=document.createElement("span"),a=document.createTextNode(r);o.appendChild(a),i.appendChild(o),n.appendChild(i)}else n.appendChild(r);var s=new Bo(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var c=s.getElement();return c.style.visibility="visible",c.style.textAlign="center",c.style.verticalAlign="middle",s}function bs(t,e,r,n,i,o,a,s){Vo.call(this);for(var c=new Vo,u=0;u0&&(e.data=window.atob(t.substring(r+1)),e.fileType=t.substring(0,r).toLowerCase())}mc.call(this,t,e)}function _c(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}function xc(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}function bc(t,e){sm.call(this,t,e),this._complex=null,this._chain=null,this._residue=null,this._sheet=null,this._serialAtomMap=null,this._modelId=1,this._compaundFound=!1,this._biomoleculeFound=!1,this._allowedChainsIDs=null,this._lastMolId=-1,this._remarks={},this._remark=null,this._molecules=[],this._molecule=null,this._compndCurrToken="",e.fileType="pdb"}function wc(t,e){sm.call(this,t,e),this._complex=null,e.fileType="mol"}function Sc(t,e){sm.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,e.fileType="cml"}function Mc(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=eg?t-rg:t}function jc(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 Gc(t,e){if(this.constructor===Gc)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=xl.merge(gp.deriveDeep(_p.now.objects[this.type],!0),e),this.needsRebuild=!1}function Wc(t,e){if(Gc.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 Hc(t){return new Q({uniforms:function(t){var e=Oh.clone(sg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:og,fragmentShader:ag,transparent:!0,depthTest:!1,depthWrite:!1})}function Xc(t){return new Q({uniforms:function(t){var e=Oh.clone(lg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:og,fragmentShader:cg,transparent:!0,depthTest:!1,depthWrite:!1})}function Yc(t,e){var r=Oh.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}function qc(t){return new Q({uniforms:function(t){var e=Oh.clone(vg);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}(t),vertexShader:og,fragmentShader:gg,transparent:!1,depthTest:!1,depthWrite:!1})}function $c(){this.position=new l(0,0,0),this.scale=1,this.orientation=new c(0,0,0,1)}function Zc(){}function Kc(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 Qc(){}function Jc(t){for(var e=[],r=0,n=t.length;r=0&&(t=t.substr(0,e)),t}function al(t){if("string"==typeof t)if(t.match(/^[0-9A-Z]{4}$/i))t=t.toUpperCase();else if(t.match(/^data\/[0-9A-Z]{4}\.pdb$/i))t=t.substr(5,4).toUpperCase();else{var e=document.createElement("a");e.href=t,t=e.href}return t}function sl(t,e,r){r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function cl(t){fi.call(this),this._opts=xl.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.getElementById("miew-container")||xl.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=_p;var e=fp;e.console=!1,e.level="info",this.logger=e,this._cookies=new il(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loader=null,this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._fileSource=null,this._fileSourceAnim=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;cl.registeredPlugins.forEach(function(t){t.call(r)})}function ll(t,e){for(var r=t;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(e)}function ul(t){return t instanceof Array?new df.Range(t[0],t[1]):new df.Range(t,t)}function hl(t){var e=df.keyword(t[0]);if(!e||!e.SelectorClass)return null;var r=null,n=e.SelectorClass.prototype;return n instanceof df.PrefixOperator&&2===t.length?r=e(hl(t[1])):n instanceof df.InfixOperator&&3===t.length?r=e(hl(t[1]),hl(t[2])):n instanceof df.RangeListSelector&&2===t.length?r=e(function(t){for(var e=[],r=0;r * Copyright JS Foundation and other contributors @@ -11,7 +11,7 @@ function Oo(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 z(t,e){for(var r=t.length;r--&&b(e,t[r],0)>-1;);return r}function F(t,e){for(var r=t.length,n=0;r--;)t[r]===e&&++n;return n}function k(t){return"\\"+Ar[t]}function U(t,e){return null==t?et:t[e]}function B(t){return _r.test(t)}function V(t){return xr.test(t)}function j(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}function G(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function W(t,e){return function(r){return t(e(r))}}function H(t,e){for(var r=-1,n=t.length,i=0,o=[];++r>>1,zt=[["ary",xt],["bind",ft],["bindKey",dt],["curry",gt],["curryRight",vt],["flip",wt],["partial",yt],["partialRight",_t],["rearg",bt]],Ft="[object Arguments]",kt="[object Array]",Ut="[object AsyncFunction]",Bt="[object Boolean]",Vt="[object Date]",jt="[object DOMException]",Gt="[object Error]",Wt="[object Function]",Ht="[object GeneratorFunction]",Xt="[object Map]",Yt="[object Number]",qt="[object Null]",$t="[object Object]",Zt="[object Proxy]",Kt="[object RegExp]",Qt="[object Set]",Jt="[object String]",te="[object Symbol]",ee="[object Undefined]",re="[object WeakMap]",ne="[object WeakSet]",ie="[object ArrayBuffer]",oe="[object DataView]",ae="[object Float32Array]",se="[object Float64Array]",ce="[object Int8Array]",le="[object Int16Array]",ue="[object Int32Array]",he="[object Uint8Array]",pe="[object Uint8ClampedArray]",fe="[object Uint16Array]",de="[object Uint32Array]",me=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,ve=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ye=/&(?:amp|lt|gt|quot|#39);/g,_e=/[&<>"']/g,xe=RegExp(ye.source),be=RegExp(_e.source),we=/<%-([\s\S]+?)%>/g,Se=/<%([\s\S]+?)%>/g,Me=/<%=([\s\S]+?)%>/g,Ae=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ee=/^\w*$/,Ce=/^\./,Te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pe=/[\\^$.*+?()[\]{}|]/g,Le=RegExp(Pe.source),Re=/^\s+|\s+$/g,Ne=/^\s+/,Ie=/\s+$/,Oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,De=/\{\n\/\* \[wrapped with (.+)\] \*/,ze=/,? & /,Fe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ke=/\\(\\)?/g,Ue=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Be=/\w*$/,Ve=/^[-+]0x[0-9a-f]+$/i,je=/^0b[01]+$/i,Ge=/^\[object .+?Constructor\]$/,We=/^0o[0-7]+$/i,He=/^(?:0|[1-9]\d*)$/,Xe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ye=/($^)/,qe=/['\n\r\u2028\u2029\\]/g,$e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ze="\\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",Ke="[\\ud800-\\udfff]",Qe="["+Ze+"]",Je="["+$e+"]",tr="\\d+",er="[\\u2700-\\u27bf]",rr="[a-z\\xdf-\\xf6\\xf8-\\xff]",nr="[^\\ud800-\\udfff"+Ze+tr+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ir="\\ud83c[\\udffb-\\udfff]",or="[^\\ud800-\\udfff]",ar="(?:\\ud83c[\\udde6-\\uddff]){2}",sr="[\\ud800-\\udbff][\\udc00-\\udfff]",cr="[A-Z\\xc0-\\xd6\\xd8-\\xde]",lr="(?:"+rr+"|"+nr+")",ur="(?:"+cr+"|"+nr+")",hr="(?:"+Je+"|"+ir+")"+"?",pr="[\\ufe0e\\ufe0f]?"+hr+("(?:\\u200d(?:"+[or,ar,sr].join("|")+")[\\ufe0e\\ufe0f]?"+hr+")*"),fr="(?:"+[er,ar,sr].join("|")+")"+pr,dr="(?:"+[or+Je+"?",Je,ar,sr,Ke].join("|")+")",mr=RegExp("['’]","g"),gr=RegExp(Je,"g"),vr=RegExp(ir+"(?="+ir+")|"+dr+pr,"g"),yr=RegExp([cr+"?"+rr+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Qe,cr,"$"].join("|")+")",ur+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Qe,cr+lr,"$"].join("|")+")",cr+"?"+lr+"+(?:['’](?:d|ll|m|re|s|t|ve))?",cr+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",tr,fr].join("|"),"g"),_r=RegExp("[\\u200d\\ud800-\\udfff"+$e+"\\ufe0e\\ufe0f]"),xr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,br=["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"],wr=-1,Sr={};Sr[ae]=Sr[se]=Sr[ce]=Sr[le]=Sr[ue]=Sr[he]=Sr[pe]=Sr[fe]=Sr[de]=!0,Sr[Ft]=Sr[kt]=Sr[ie]=Sr[Bt]=Sr[oe]=Sr[Vt]=Sr[Gt]=Sr[Wt]=Sr[Xt]=Sr[Yt]=Sr[$t]=Sr[Kt]=Sr[Qt]=Sr[Jt]=Sr[re]=!1;var Mr={};Mr[Ft]=Mr[kt]=Mr[ie]=Mr[oe]=Mr[Bt]=Mr[Vt]=Mr[ae]=Mr[se]=Mr[ce]=Mr[le]=Mr[ue]=Mr[Xt]=Mr[Yt]=Mr[$t]=Mr[Kt]=Mr[Qt]=Mr[Jt]=Mr[te]=Mr[he]=Mr[pe]=Mr[fe]=Mr[de]=!0,Mr[Gt]=Mr[Wt]=Mr[re]=!1;var Ar={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Er=parseFloat,Cr=parseInt,Tr="object"==typeof Uu&&Uu&&Uu.Object===Object&&Uu,Pr="object"==typeof self&&self&&self.Object===Object&&self,Lr=Tr||Pr||Function("return this")(),Rr=e&&!e.nodeType&&e,Nr=Rr&&!0&&t&&!t.nodeType&&t,Ir=Nr&&Nr.exports===Rr,Or=Ir&&Tr.process,Dr=function(){try{return Or&&Or.binding&&Or.binding("util")}catch(t){}}(),zr=Dr&&Dr.isArrayBuffer,Fr=Dr&&Dr.isDate,kr=Dr&&Dr.isMap,Ur=Dr&&Dr.isRegExp,Br=Dr&&Dr.isSet,Vr=Dr&&Dr.isTypedArray,jr=A("length"),Gr=E({"À":"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"}),Wr=E({"&":"&","<":"<",">":">",'"':""","'":"'"}),Hr=E({"&":"&","<":"<",">":">",""":'"',"'":"'"}),Xr=function t(e){function v(t){if(ea(t)&&!Wc(t)&&!(t instanceof Q)){if(t instanceof q)return t;if(Wa.call(t,"__wrapped__"))return Ao(t)}return new q(t)}function E(){}function q(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=et}function Q(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}function J(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function hr(t,e,r,n,i,o){var s,c=e&ct,l=e<,u=e&ut;if(r&&(s=i?r(t,n,i,o):r(t)),s!==et)return s;if(!ta(t))return t;var h=Wc(t);if(h){if(s=Qi(t),!c)return ai(t,s)}else{var p=tc(t),f=p==Wt||p==Ht;if(Xc(t))return qn(t,c);if(p==$t||p==Ft||f&&!i){if(s=l||f?{}:Ji(t),!c)return l?li(t,sr(s,t)):ci(t,ar(s,t))}else{if(!Mr[p])return i?t:{};s=to(t,p,hr,c)}}o||(o=new Ke);var d=o.get(t);if(d)return d;o.set(t,s);var m=h?et:(u?l?Vi:Bi:l?ga:ma)(t);return a(m||t,function(n,i){m&&(n=t[i=n]),nr(s,i,hr(n,e,r,i,t,o))}),s}function pr(t){var e=ma(t);return function(r){return fr(r,t,e)}}function fr(t,e,r){var n=r.length;if(null==t)return!n;for(t=Da(t);n--;){var i=r[n],o=e[i],a=t[i];if(a===et&&!(i in t)||!o(a))return!1}return!0}function dr(t,e,r){if("function"!=typeof t)throw new ka(it);return nc(function(){t.apply(et,r)},e)}function vr(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,N(r))),n?(o=h,a=!1):e.length>=rt&&(o=O,a=!1,e=new Ze(e));t:for(;++ii?0:i+r),(n=n===et||n>i?i:ca(n))<0&&(n+=i),n=r>n?0:la(n);r0&&r(s)?e>1?Tr(s,e-1,r,n,i):f(i,s):n||(i[i.length]=s)}return i}function Pr(t,e){return t&&Ws(t,e,ma)}function Rr(t,e){return t&&Hs(t,e,ma)}function Nr(t,e){return l(e,function(e){return Ko(t[e])})}function Or(t,e){for(var r=0,n=(e=Xn(e,t)).length;null!=t&&re}function qr(t,e){return null!=t&&Wa.call(t,e)}function $r(t,e){return null!=t&&e in Da(t)}function Zr(t,e,r){return t>=xs(e,r)&&t<_s(e,r)}function Kr(t,e,r){for(var n=r?h:u,i=t[0].length,o=t.length,a=o,s=La(o),c=1/0,l=[];a--;){var f=t[a];a&&e&&(f=p(f,N(e))),c=xs(f.length,c),s[a]=!r&&(e||i>=120&&f.length>=120)?new Ze(a&&f):et}f=t[0];var d=-1,m=s[0];t:for(;++d-1;)s!==t&&is.call(s,c,1),is.call(t,c,1);return t}function bn(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;no(i)?is.call(t,i,1):kn(t,i)}}return t}function wn(t,e){return t+fs(Ss()*(e-t+1))}function Sn(t,e,r,n){for(var i=-1,o=_s(ps((e-t)/(r||1)),0),a=La(o);o--;)a[n?o:++i]=t,t+=r;return a}function Mn(t,e){var r="";if(!t||e<1||e>Lt)return r;do{e%2&&(r+=t),(e=fs(e/2))&&(t+=t)}while(e);return r}function An(t,e){return ic(go(t,e,Sa),t+"")}function En(t){return Je(ya(t))}function Cn(t,e){var r=ya(t);return bo(r,ur(e,0,r.length))}function Tn(t,e,r,n){if(!ta(t))return t;for(var i=-1,o=(e=Xn(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=La(i);++n>>1,a=t[o];null!==a&&!oa(a)&&(r?a<=e:a=rt){var l=e?null:Zs(t);if(l)return X(l);a=!1,i=O,c=new Ze}else c=e?[]:s;t:for(;++n=n?t:Ln(t,e,r)}function qn(t,e){if(e)return t.slice();var r=t.length,n=ts?ts(r):new t.constructor(r);return t.copy(n),n}function $n(t){var e=new t.constructor(t.byteLength);return new Ja(e).set(new Ja(t)),e}function Zn(t,e){var r=e?$n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function Kn(t,e,n){return d(e?n(G(t),ct):G(t),r,new t.constructor)}function Qn(t){var e=new t.constructor(t.source,Be.exec(t));return e.lastIndex=t.lastIndex,e}function Jn(t,e,r){return d(e?r(X(t),ct):X(t),n,new t.constructor)}function ti(t){return Us?Da(Us.call(t)):{}}function ei(t,e){var r=e?$n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function ri(t,e){if(t!==e){var r=t!==et,n=null===t,i=t==t,o=oa(t),a=e!==et,s=null===e,c=e==e,l=oa(e);if(!s&&!l&&!o&&t>e||o&&a&&c&&!s&&!l||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!l&&t=s?c:c*("desc"==r[n]?-1:1)}return t.index-e.index}function ii(t,e,r,n){for(var i=-1,o=t.length,a=r.length,s=-1,c=e.length,l=_s(o-a,0),u=La(c+l),h=!n;++s1?r[i-1]:et,a=i>2?r[2]:et;for(o=t.length>3&&"function"==typeof o?(i--,o):et,a&&io(r[0],r[1],a)&&(o=i<3?et:o,i=1),e=Da(e);++n-1?i[o?e[a]:a]:et}}function xi(t){return Ui(function(e){var r=e.length,n=r,i=q.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new ka(it);if(i&&!a&&"wrapper"==ji(o))var a=new q([],!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&pt?new Ze:et;for(o.set(t,e),o.set(e,t);++u1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Oe,"{\n/* [wrapped with "+e+"] */\n")}function ro(t){return Wc(t)||Gc(t)||!!(os&&t&&t[os])}function no(t,e){return!!(e=null==e?Lt:e)&&("number"==typeof t||He.test(t))&&t>-1&&t%1==0&&t0){if(++e>=At)return arguments[0]}else e=0;return t.apply(et,arguments)}}function bo(t,e){var r=-1,n=t.length,i=n-1;for(e=e===et?n:e;++r0&&(r=e.apply(this,arguments)),t<=1&&(e=et),r}}function jo(t,e,r){var n=Ni(t,gt,et,et,et,et,et,e=r?et:e);return n.placeholder=jo.placeholder,n}function Go(t,e,r){var n=Ni(t,vt,et,et,et,et,et,e=r?et:e);return n.placeholder=Go.placeholder,n}function Wo(t,e,r){function n(e){var r=u,n=h;return u=h=et,g=e,f=t.apply(n,r)}function i(t){return g=t,d=nc(s,e),v?n(t):f}function o(t){var r=e-(t-m);return y?xs(r,p-(t-g)):r}function a(t){var r=t-m;return m===et||r>=e||r<0||y&&t-g>=p}function s(){var t=Nc();if(a(t))return c(t);d=nc(s,o(t))}function c(t){return d=et,_&&u?n(t):(u=h=et,f)}function l(){var t=Nc(),r=a(t);if(u=arguments,h=this,m=t,r){if(d===et)return i(m);if(y)return d=nc(s,e),n(m)}return d===et&&(d=nc(s,e)),f}var u,h,p,f,d,m,g=0,v=!1,y=!1,_=!0;if("function"!=typeof t)throw new ka(it);return e=ua(e)||0,ta(r)&&(v=!!r.leading,p=(y="maxWait"in r)?_s(ua(r.maxWait)||0,e):p,_="trailing"in r?!!r.trailing:_),l.cancel=function(){d!==et&&$s(d),g=0,u=m=h=d=et},l.flush=function(){return d===et?f:c(Nc())},l}function Ho(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ka(it);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(Ho.Cache||$e),r}function Xo(t){if("function"!=typeof t)throw new ka(it);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 Yo(t,e){return t===e||t!=t&&e!=e}function qo(t){return null!=t&&Jo(t.length)&&!Ko(t)}function $o(t){return ea(t)&&qo(t)}function Zo(t){if(!ea(t))return!1;var e=jr(t);return e==Gt||e==jt||"string"==typeof t.message&&"string"==typeof t.name&&!na(t)}function Ko(t){if(!ta(t))return!1;var e=jr(t);return e==Wt||e==Ht||e==Ut||e==Zt}function Qo(t){return"number"==typeof t&&t==ca(t)}function Jo(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Lt}function ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ea(t){return null!=t&&"object"==typeof t}function ra(t){return"number"==typeof t||ea(t)&&jr(t)==Yt}function na(t){if(!ea(t)||jr(t)!=$t)return!1;var e=es(t);if(null===e)return!0;var r=Wa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ga.call(r)==qa}function ia(t){return"string"==typeof t||!Wc(t)&&ea(t)&&jr(t)==Jt}function oa(t){return"symbol"==typeof t||ea(t)&&jr(t)==te}function aa(t){if(!t)return[];if(qo(t))return ia(t)?K(t):ai(t);if(as&&t[as])return j(t[as]());var e=tc(t);return(e==Xt?G:e==Qt?X:ya)(t)}function sa(t){return t?(t=ua(t))===Pt||t===-Pt?(t<0?-1:1)*Rt:t==t?t:0:0===t?t:0}function ca(t){var e=sa(t),r=e%1;return e==e?r?e-r:e:0}function la(t){return t?ur(ca(t),0,It):0}function ua(t){if("number"==typeof t)return t;if(oa(t))return Nt;if(ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Re,"");var r=je.test(t);return r||We.test(t)?Cr(t.slice(2),r?2:8):Ve.test(t)?Nt:+t}function ha(t){return si(t,ga(t))}function pa(t){return null==t?"":zn(t)}function fa(t,e,r){var n=null==t?et:Or(t,e);return n===et?r:n}function da(t,e){return null!=t&&Ki(t,e,$r)}function ma(t){return qo(t)?Qe(t):sn(t)}function ga(t){return qo(t)?Qe(t,!0):cn(t)}function va(t,e){if(null==t)return{};var r=p(Vi(t),function(t){return[t]});return e=Wi(e),yn(t,r,function(t,r){return e(t,r[0])})}function ya(t){return null==t?[]:I(t,ma(t))}function _a(t){return Sl(pa(t).toLowerCase())}function xa(t){return(t=pa(t))&&t.replace(Xe,Gr).replace(gr,"")}function ba(t,e,r){return t=pa(t),(e=r?et:e)===et?V(t)?tt(t):y(t):t.match(e)||[]}function wa(t){return function(){return t}}function Sa(t){return t}function Ma(t){return an("function"==typeof t?t:hr(t,ct))}function Aa(t,e,r){var n=ma(e),i=Nr(e,n);null!=r||ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Nr(e,ma(e)));var o=!(ta(r)&&"chain"in r&&!r.chain),s=Ko(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__=ai(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,f([this.value()],arguments))})}),t}function Ea(){}function Ca(t){return oo(t)?A(wo(t)):_n(t)}function Ta(){return[]}function Pa(){return!1}var La=(e=null==e?Lr:Xr.defaults(Lr.Object(),e,Xr.pick(Lr,br))).Array,Ra=e.Date,Na=e.Error,Ia=e.Function,Oa=e.Math,Da=e.Object,za=e.RegExp,Fa=e.String,ka=e.TypeError,Ua=La.prototype,Ba=Ia.prototype,Va=Da.prototype,ja=e["__core-js_shared__"],Ga=Ba.toString,Wa=Va.hasOwnProperty,Ha=0,Xa=function(){var t=/[^.]+$/.exec(ja&&ja.keys&&ja.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ya=Va.toString,qa=Ga.call(Da),$a=Lr._,Za=za("^"+Ga.call(Wa).replace(Pe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ka=Ir?e.Buffer:et,Qa=e.Symbol,Ja=e.Uint8Array,ts=Ka?Ka.allocUnsafe:et,es=W(Da.getPrototypeOf,Da),rs=Da.create,ns=Va.propertyIsEnumerable,is=Ua.splice,os=Qa?Qa.isConcatSpreadable:et,as=Qa?Qa.iterator:et,ss=Qa?Qa.toStringTag:et,cs=function(){try{var t=Yi(Da,"defineProperty");return t({},"",{}),t}catch(t){}}(),ls=e.clearTimeout!==Lr.clearTimeout&&e.clearTimeout,us=Ra&&Ra.now!==Lr.Date.now&&Ra.now,hs=e.setTimeout!==Lr.setTimeout&&e.setTimeout,ps=Oa.ceil,fs=Oa.floor,ds=Da.getOwnPropertySymbols,ms=Ka?Ka.isBuffer:et,gs=e.isFinite,vs=Ua.join,ys=W(Da.keys,Da),_s=Oa.max,xs=Oa.min,bs=Ra.now,ws=e.parseInt,Ss=Oa.random,Ms=Ua.reverse,As=Yi(e,"DataView"),Es=Yi(e,"Map"),Cs=Yi(e,"Promise"),Ts=Yi(e,"Set"),Ps=Yi(e,"WeakMap"),Ls=Yi(Da,"create"),Rs=Ps&&new Ps,Ns={},Is=So(As),Os=So(Es),Ds=So(Cs),zs=So(Ts),Fs=So(Ps),ks=Qa?Qa.prototype:et,Us=ks?ks.valueOf:et,Bs=ks?ks.toString:et,Vs=function(){function t(){}return function(e){if(!ta(e))return{};if(rs)return rs(e);t.prototype=e;var r=new t;return t.prototype=et,r}}();v.templateSettings={escape:we,evaluate:Se,interpolate:Me,variable:"",imports:{_:v}},v.prototype=E.prototype,v.prototype.constructor=v,q.prototype=Vs(E.prototype),q.prototype.constructor=q,Q.prototype=Vs(E.prototype),Q.prototype.constructor=Q,J.prototype.clear=function(){this.__data__=Ls?Ls(null):{},this.size=0},J.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},J.prototype.get=function(t){var e=this.__data__;if(Ls){var r=e[t];return r===ot?et:r}return Wa.call(e,t)?e[t]:et},J.prototype.has=function(t){var e=this.__data__;return Ls?e[t]!==et:Wa.call(e,t)},J.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ls&&e===et?ot:e,this},Fe.prototype.clear=function(){this.__data__=[],this.size=0},Fe.prototype.delete=function(t){var e=this.__data__,r=ir(e,t);return!(r<0||(r==e.length-1?e.pop():is.call(e,r,1),--this.size,0))},Fe.prototype.get=function(t){var e=this.__data__,r=ir(e,t);return r<0?et:e[r][1]},Fe.prototype.has=function(t){return ir(this.__data__,t)>-1},Fe.prototype.set=function(t,e){var r=this.__data__,n=ir(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},$e.prototype.clear=function(){this.size=0,this.__data__={hash:new J,map:new(Es||Fe),string:new J}},$e.prototype.delete=function(t){var e=Hi(this,t).delete(t);return this.size-=e?1:0,e},$e.prototype.get=function(t){return Hi(this,t).get(t)},$e.prototype.has=function(t){return Hi(this,t).has(t)},$e.prototype.set=function(t,e){var r=Hi(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Ze.prototype.add=Ze.prototype.push=function(t){return this.__data__.set(t,ot),this},Ze.prototype.has=function(t){return this.__data__.has(t)},Ke.prototype.clear=function(){this.__data__=new Fe,this.size=0},Ke.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ke.prototype.get=function(t){return this.__data__.get(t)},Ke.prototype.has=function(t){return this.__data__.has(t)},Ke.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Fe){var n=r.__data__;if(!Es||n.length1?t[e-1]:et;return r="function"==typeof r?(t.pop(),r):et,Oo(t,r)}),Sc=Ui(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return lr(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Q&&no(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:zo,args:[i],thisArg:et}),new q(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(et),t})):this.thru(i)}),Mc=ui(function(t,e,r){Wa.call(t,r)?++t[r]:cr(t,r,1)}),Ac=_i(Eo),Ec=_i(Co),Cc=ui(function(t,e,r){Wa.call(t,r)?t[r].push(e):cr(t,r,[e])}),Tc=An(function(t,e,r){var n=-1,o="function"==typeof e,a=qo(t)?La(t.length):[];return js(t,function(t){a[++n]=o?i(e,t,r):Jr(t,e,r)}),a}),Pc=ui(function(t,e,r){cr(t,r,e)}),Lc=ui(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),Rc=An(function(t,e){if(null==t)return[];var r=e.length;return r>1&&io(t,e[0],e[1])?e=[]:r>2&&io(e[0],e[1],e[2])&&(e=[e[0]]),gn(t,Tr(e,1),[])}),Nc=us||function(){return Lr.Date.now()},Ic=An(function(t,e,r){var n=ft;if(r.length){var i=H(r,Gi(Ic));n|=yt}return Ni(t,n,e,r,i)}),Oc=An(function(t,e,r){var n=ft|dt;if(r.length){var i=H(r,Gi(Oc));n|=yt}return Ni(e,n,t,r,i)}),Dc=An(function(t,e){return dr(t,1,e)}),zc=An(function(t,e,r){return dr(t,ua(e)||0,r)});Ho.Cache=$e;var Fc=qs(function(t,e){var r=(e=1==e.length&&Wc(e[0])?p(e[0],N(Wi())):p(Tr(e,1),N(Wi()))).length;return An(function(n){for(var o=-1,a=xs(n.length,r);++o=e}),Gc=tn(function(){return arguments}())?tn:function(t){return ea(t)&&Wa.call(t,"callee")&&!ns.call(t,"callee")},Wc=La.isArray,Hc=zr?N(zr):function(t){return ea(t)&&jr(t)==ie},Xc=ms||Pa,Yc=Fr?N(Fr):function(t){return ea(t)&&jr(t)==Vt},qc=kr?N(kr):function(t){return ea(t)&&tc(t)==Xt},$c=Ur?N(Ur):function(t){return ea(t)&&jr(t)==Kt},Zc=Br?N(Br):function(t){return ea(t)&&tc(t)==Qt},Kc=Vr?N(Vr):function(t){return ea(t)&&Jo(t.length)&&!!Sr[jr(t)]},Qc=Ti(ln),Jc=Ti(function(t,e){return t<=e}),tl=hi(function(t,e){if(lo(e)||qo(e))si(e,ma(e),t);else for(var r in e)Wa.call(e,r)&&nr(t,r,e[r])}),el=hi(function(t,e){si(e,ga(e),t)}),rl=hi(function(t,e,r,n){si(e,ga(e),t,n)}),nl=hi(function(t,e,r,n){si(e,ma(e),t,n)}),il=Ui(lr),ol=An(function(t){return t.push(et,Ii),i(rl,et,t)}),al=An(function(t){return t.push(et,Oi),i(hl,et,t)}),sl=wi(function(t,e,r){t[e]=r},wa(Sa)),cl=wi(function(t,e,r){Wa.call(t,e)?t[e].push(r):t[e]=[r]},Wi),ll=An(Jr),ul=hi(function(t,e,r){fn(t,e,r)}),hl=hi(function(t,e,r,n){fn(t,e,r,n)}),pl=Ui(function(t,e){var r={};if(null==t)return r;var n=!1;e=p(e,function(e){return e=Xn(e,t),n||(n=e.length>1),e}),si(t,Vi(t),r),n&&(r=hr(r,ct|lt|ut,Di));for(var i=e.length;i--;)kn(r,e[i]);return r}),fl=Ui(function(t,e){return null==t?{}:vn(t,e)}),dl=Ri(ma),ml=Ri(ga),gl=gi(function(t,e,r){return e=e.toLowerCase(),t+(r?_a(e):e)}),vl=gi(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),yl=gi(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),_l=mi("toLowerCase"),xl=gi(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),bl=gi(function(t,e,r){return t+(r?" ":"")+Sl(e)}),wl=gi(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Sl=mi("toUpperCase"),Ml=An(function(t,e){try{return i(t,et,e)}catch(t){return Zo(t)?t:new Na(t)}}),Al=Ui(function(t,e){return a(e,function(e){e=wo(e),cr(t,e,Ic(t[e],t))}),t}),El=xi(),Cl=xi(!0),Tl=An(function(t,e){return function(r){return Jr(r,t,e)}}),Pl=An(function(t,e){return function(r){return Jr(t,r,e)}}),Ll=Mi(p),Rl=Mi(c),Nl=Mi(g),Il=Ci(),Ol=Ci(!0),Dl=Si(function(t,e){return t+e},0),zl=Li("ceil"),Fl=Si(function(t,e){return t/e},1),kl=Li("floor"),Ul=Si(function(t,e){return t*e},1),Bl=Li("round"),Vl=Si(function(t,e){return t-e},0);return v.after=function(t,e){if("function"!=typeof e)throw new ka(it);return t=ca(t),function(){if(--t<1)return e.apply(this,arguments)}},v.ary=Bo,v.assign=tl,v.assignIn=el,v.assignInWith=rl,v.assignWith=nl,v.at=il,v.before=Vo,v.bind=Ic,v.bindAll=Al,v.bindKey=Oc,v.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Wc(t)?t:[t]},v.chain=Do,v.chunk=function(t,e,r){e=(r?io(t,e,r):e===et)?1:_s(ca(e),0);var n=null==t?0:t.length;if(!n||e<1)return[];for(var i=0,o=0,a=La(ps(n/e));i>>0)?(t=pa(t))&&("string"==typeof e||null!=e&&!$c(e))&&!(e=zn(e))&&B(t)?Yn(K(t),0,r):t.split(e,r):[]},v.spread=function(t,e){if("function"!=typeof t)throw new ka(it);return e=null==e?0:_s(ca(e),0),An(function(r){var n=r[e],o=Yn(r,0,e);return n&&f(o,n),i(t,this,o)})},v.tail=function(t){var e=null==t?0:t.length;return e?Ln(t,1,e):[]},v.take=function(t,e,r){return t&&t.length?(e=r||e===et?1:ca(e),Ln(t,0,e<0?0:e)):[]},v.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?(e=r||e===et?1:ca(e),e=n-e,Ln(t,e<0?0:e,n)):[]},v.takeRightWhile=function(t,e){return t&&t.length?Bn(t,Wi(e,3),!1,!0):[]},v.takeWhile=function(t,e){return t&&t.length?Bn(t,Wi(e,3)):[]},v.tap=function(t,e){return e(t),t},v.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ka(it);return ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Wo(t,e,{leading:n,maxWait:e,trailing:i})},v.thru=zo,v.toArray=aa,v.toPairs=dl,v.toPairsIn=ml,v.toPath=function(t){return Wc(t)?p(t,wo):oa(t)?[t]:ai(oc(pa(t)))},v.toPlainObject=ha,v.transform=function(t,e,r){var n=Wc(t),i=n||Xc(t)||Kc(t);if(e=Wi(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:ta(t)&&Ko(o)?Vs(es(t)):{}}return(i?a:Pr)(t,function(t,n,i){return e(r,t,n,i)}),r},v.unary=function(t){return Bo(t,1)},v.union=dc,v.unionBy=mc,v.unionWith=gc,v.uniq=function(t){return t&&t.length?Fn(t):[]},v.uniqBy=function(t,e){return t&&t.length?Fn(t,Wi(e,2)):[]},v.uniqWith=function(t,e){return e="function"==typeof e?e:et,t&&t.length?Fn(t,et,e):[]},v.unset=function(t,e){return null==t||kn(t,e)},v.unzip=Io,v.unzipWith=Oo,v.update=function(t,e,r){return null==t?t:Un(t,e,Hn(r))},v.updateWith=function(t,e,r,n){return n="function"==typeof n?n:et,null==t?t:Un(t,e,Hn(r),n)},v.values=ya,v.valuesIn=function(t){return null==t?[]:I(t,ga(t))},v.without=vc,v.words=ba,v.wrap=function(t,e){return kc(Hn(e),t)},v.xor=yc,v.xorBy=_c,v.xorWith=xc,v.zip=bc,v.zipObject=function(t,e){return Gn(t||[],e||[],nr)},v.zipObjectDeep=function(t,e){return Gn(t||[],e||[],Tn)},v.zipWith=wc,v.entries=dl,v.entriesIn=ml,v.extend=el,v.extendWith=rl,Aa(v,v),v.add=Dl,v.attempt=Ml,v.camelCase=gl,v.capitalize=_a,v.ceil=zl,v.clamp=function(t,e,r){return r===et&&(r=e,e=et),r!==et&&(r=(r=ua(r))==r?r:0),e!==et&&(e=(e=ua(e))==e?e:0),ur(ua(t),e,r)},v.clone=function(t){return hr(t,ut)},v.cloneDeep=function(t){return hr(t,ct|ut)},v.cloneDeepWith=function(t,e){return e="function"==typeof e?e:et,hr(t,ct|ut,e)},v.cloneWith=function(t,e){return e="function"==typeof e?e:et,hr(t,ut,e)},v.conformsTo=function(t,e){return null==e||fr(t,e,ma(e))},v.deburr=xa,v.defaultTo=function(t,e){return null==t||t!=t?e:t},v.divide=Fl,v.endsWith=function(t,e,r){t=pa(t),e=zn(e);var n=t.length,i=r=r===et?n:ur(ca(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},v.eq=Yo,v.escape=function(t){return(t=pa(t))&&be.test(t)?t.replace(_e,Wr):t},v.escapeRegExp=function(t){return(t=pa(t))&&Le.test(t)?t.replace(Pe,"\\$&"):t},v.every=function(t,e,r){var n=Wc(t)?c:yr;return r&&io(t,e,r)&&(e=et),n(t,Wi(e,3))},v.find=Ac,v.findIndex=Eo,v.findKey=function(t,e){return _(t,Wi(e,3),Pr)},v.findLast=Ec,v.findLastIndex=Co,v.findLastKey=function(t,e){return _(t,Wi(e,3),Rr)},v.floor=kl,v.forEach=Fo,v.forEachRight=ko,v.forIn=function(t,e){return null==t?t:Ws(t,Wi(e,3),ga)},v.forInRight=function(t,e){return null==t?t:Hs(t,Wi(e,3),ga)},v.forOwn=function(t,e){return t&&Pr(t,Wi(e,3))},v.forOwnRight=function(t,e){return t&&Rr(t,Wi(e,3))},v.get=fa,v.gt=Vc,v.gte=jc,v.has=function(t,e){return null!=t&&Ki(t,e,qr)},v.hasIn=da,v.head=Po,v.identity=Sa,v.includes=function(t,e,r,n){t=qo(t)?t:ya(t),r=r&&!n?ca(r):0;var i=t.length;return r<0&&(r=_s(i+r,0)),ia(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&b(t,e,r)>-1},v.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:ca(r);return i<0&&(i=_s(n+i,0)),b(t,e,i)},v.inRange=function(t,e,r){return e=sa(e),r===et?(r=e,e=0):r=sa(r),t=ua(t),Zr(t,e,r)},v.invoke=ll,v.isArguments=Gc,v.isArray=Wc,v.isArrayBuffer=Hc,v.isArrayLike=qo,v.isArrayLikeObject=$o,v.isBoolean=function(t){return!0===t||!1===t||ea(t)&&jr(t)==Bt},v.isBuffer=Xc,v.isDate=Yc,v.isElement=function(t){return ea(t)&&1===t.nodeType&&!na(t)},v.isEmpty=function(t){if(null==t)return!0;if(qo(t)&&(Wc(t)||"string"==typeof t||"function"==typeof t.splice||Xc(t)||Kc(t)||Gc(t)))return!t.length;var e=tc(t);if(e==Xt||e==Qt)return!t.size;if(lo(t))return!sn(t).length;for(var r in t)if(Wa.call(t,r))return!1;return!0},v.isEqual=function(t,e){return en(t,e)},v.isEqualWith=function(t,e,r){var n=(r="function"==typeof r?r:et)?r(t,e):et;return n===et?en(t,e,et,r):!!n},v.isError=Zo,v.isFinite=function(t){return"number"==typeof t&&gs(t)},v.isFunction=Ko,v.isInteger=Qo,v.isLength=Jo,v.isMap=qc,v.isMatch=function(t,e){return t===e||nn(t,e,Xi(e))},v.isMatchWith=function(t,e,r){return r="function"==typeof r?r:et,nn(t,e,Xi(e),r)},v.isNaN=function(t){return ra(t)&&t!=+t},v.isNative=function(t){if(ec(t))throw new Na(nt);return on(t)},v.isNil=function(t){return null==t},v.isNull=function(t){return null===t},v.isNumber=ra,v.isObject=ta,v.isObjectLike=ea,v.isPlainObject=na,v.isRegExp=$c,v.isSafeInteger=function(t){return Qo(t)&&t>=-Lt&&t<=Lt},v.isSet=Zc,v.isString=ia,v.isSymbol=oa,v.isTypedArray=Kc,v.isUndefined=function(t){return t===et},v.isWeakMap=function(t){return ea(t)&&tc(t)==re},v.isWeakSet=function(t){return ea(t)&&jr(t)==ne},v.join=function(t,e){return null==t?"":vs.call(t,e)},v.kebabCase=vl,v.last=Lo,v.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==et&&(i=(i=ca(r))<0?_s(n+i,0):xs(i,n-1)),e==e?$(t,e,i):x(t,S,i,!0)},v.lowerCase=yl,v.lowerFirst=_l,v.lt=Qc,v.lte=Jc,v.max=function(t){return t&&t.length?_r(t,Sa,Yr):et},v.maxBy=function(t,e){return t&&t.length?_r(t,Wi(e,2),Yr):et},v.mean=function(t){return M(t,Sa)},v.meanBy=function(t,e){return M(t,Wi(e,2))},v.min=function(t){return t&&t.length?_r(t,Sa,ln):et},v.minBy=function(t,e){return t&&t.length?_r(t,Wi(e,2),ln):et},v.stubArray=Ta,v.stubFalse=Pa,v.stubObject=function(){return{}},v.stubString=function(){return""},v.stubTrue=function(){return!0},v.multiply=Ul,v.nth=function(t,e){return t&&t.length?mn(t,ca(e)):et},v.noConflict=function(){return Lr._===this&&(Lr._=$a),this},v.noop=Ea,v.now=Nc,v.pad=function(t,e,r){t=pa(t);var n=(e=ca(e))?Z(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Ai(fs(i),r)+t+Ai(ps(i),r)},v.padEnd=function(t,e,r){t=pa(t);var n=(e=ca(e))?Z(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Ss();return xs(t+i*(e-t+Er("1e-"+((i+"").length-1))),e)}return wn(t,e)},v.reduce=function(t,e,r){var n=Wc(t)?d:C,i=arguments.length<3;return n(t,Wi(e,4),r,i,js)},v.reduceRight=function(t,e,r){var n=Wc(t)?m:C,i=arguments.length<3;return n(t,Wi(e,4),r,i,Gs)},v.repeat=function(t,e,r){return e=(r?io(t,e,r):e===et)?1:ca(e),Mn(pa(t),e)},v.replace=function(){var t=arguments,e=pa(t[0]);return t.length<3?e:e.replace(t[1],t[2])},v.result=function(t,e,r){var n=-1,i=(e=Xn(e,t)).length;for(i||(i=1,t=et);++nLt)return[];var r=It,n=xs(t,It);e=Wi(e),t-=It;for(var i=L(n,e);++r=o)return t;var s=r-Z(n);if(s<1)return n;var c=a?Yn(a,0,s).join(""):t.slice(0,s);if(i===et)return c+n;if(a&&(s+=c.length-s),$c(i)){if(t.slice(s).search(i)){var l,u=c;for(i.global||(i=za(i.source,pa(Be.exec(i))+"g")),i.lastIndex=0;l=i.exec(u);)var h=l.index;c=c.slice(0,h===et?s:h)}}else if(t.indexOf(zn(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},v.unescape=function(t){return(t=pa(t))&&xe.test(t)?t.replace(ye,Hr):t},v.uniqueId=function(t){var e=++Ha;return pa(t)+e},v.upperCase=wl,v.upperFirst=Sl,v.each=Fo,v.eachRight=ko,v.first=Po,Aa(v,function(){var t={};return Pr(v,function(e,r){Wa.call(v.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),v.VERSION="4.17.4",a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){v[t].placeholder=v}),a(["drop","take"],function(t,e){Q.prototype[t]=function(r){r=r===et?1:_s(ca(r),0);var n=this.__filtered__&&!e?new Q(this):this.clone();return n.__filtered__?n.__takeCount__=xs(r,n.__takeCount__):n.__views__.push({size:xs(r,It),type:t+(n.__dir__<0?"Right":"")}),n},Q.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==Ct||3==r;Q.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Wi(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),a(["head","last"],function(t,e){var r="take"+(e?"Right":"");Q.prototype[t]=function(){return this[r](1).value()[0]}}),a(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");Q.prototype[t]=function(){return this.__filtered__?new Q(this):this[r](1)}}),Q.prototype.compact=function(){return this.filter(Sa)},Q.prototype.find=function(t){return this.filter(t).head()},Q.prototype.findLast=function(t){return this.reverse().find(t)},Q.prototype.invokeMap=An(function(t,e){return"function"==typeof t?new Q(this):this.map(function(r){return Jr(r,t,e)})}),Q.prototype.reject=function(t){return this.filter(Xo(Wi(t)))},Q.prototype.slice=function(t,e){t=ca(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Q(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==et&&(r=(e=ca(e))<0?r.dropRight(-e):r.take(e-t)),r)},Q.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Q.prototype.toArray=function(){return this.take(It)},Pr(Q.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=v[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(v.prototype[e]=function(){var e=this.__wrapped__,a=n?[1]:arguments,s=e instanceof Q,c=a[0],l=s||Wc(e),u=function(t){var e=i.apply(v,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 Q(this);var g=t.apply(e,a);return g.__actions__.push({func:zo,args:[u],thisArg:et}),new q(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=Ua[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);v.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Wc(i)?i:[],t)}return this[r](function(r){return e.apply(Wc(r)?r:[],t)})}}),Pr(Q.prototype,function(t,e){var r=v[e];if(r){var n=r.name+"";(Ns[n]||(Ns[n]=[])).push({name:e,func:r})}}),Ns[bi(et,dt).name]=[{name:"wrapper",func:et}],Q.prototype.clone=function(){var t=new Q(this.__wrapped__);return t.__actions__=ai(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=ai(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=ai(this.__views__),t},Q.prototype.reverse=function(){if(this.__filtered__){var t=new Q(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Q.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Wc(t),n=e<0,i=r?t.length:0,o=$i(0,i,this.__views__),a=o.start,s=o.end,c=s-a,l=n?s:a-1,u=this.__iteratees__,h=u.length,p=0,f=xs(c,this.__takeCount__);if(!r||!n&&i==c&&f==c)return Vn(t,this.__actions__);var d=[];t:for(;c--&&p=this.__values__.length;return{done:t,value:t?et:this.__values__[this.__index__++]}},v.prototype.plant=function(t){for(var e,r=this;r instanceof E;){var n=Ao(r);n.__index__=0,n.__values__=et,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},v.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Q){var e=t;return this.__actions__.length&&(e=new Q(this)),(e=e.reverse()).__actions__.push({func:zo,args:[No],thisArg:et}),new q(e,this.__chain__)}return this.thru(No)},v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=function(){return Vn(this.__wrapped__,this.__actions__)},v.prototype.first=v.prototype.head,as&&(v.prototype[as]=function(){return this}),v}();"function"==typeof et&&"object"==typeof et.amd&&et.amd?(Lr._=Xr,et(function(){return Xr})):Nr?((Nr.exports=Xr)._=Xr,Rr._=Xr):Lr._=Xr}).call(Uu)});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*Gp.DEG2RAD},radToDeg:function(t){return t*Gp.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 Wp=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=Gp.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 Hh:t.x=t.x-Math.floor(t.x);break;case Xh:t.x=t.x<0?0:1;break;case Yh: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 Hh:t.y=t.y-Math.floor(t.y);break;case Xh:t.y=t.y<0?0:1;break;case Yh: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),s.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(Gp.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(u.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,c,l,u,h,p,f,d,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new u).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t=new l;return function(e){var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,this}}(),makeRotationFromEuler:function(t){!t||t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),c=Math.sin(n),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=p+f*c,e[5]=h-d*c,e[9]=-a*s,e[2]=d-h*c,e[6]=f+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=f*c-p,e[8]=h*c+d,e[1]=s*u,e[5]=d*c+h,e[9]=p*c-f,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-c*l,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=_*u+w,e[5]=o*l,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*l,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,n=t._y,i=t._z,o=t._w,a=r+r,s=n+n,c=i+i,l=r*a,u=r*s,h=r*c,p=n*s,f=n*c,d=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(l+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(l+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new l,e=new l,r=new l;return function(n,i,o){var a=this.elements;return r.subVectors(n,i),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(o,r),0===t.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(o,r)),t.normalize(),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],l=r[1],u=r[5],h=r[9],p=r[13],f=r[2],d=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],z=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*z,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*z,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*z,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*z,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute: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=Gp.euclideanModulo(e,1),r=Gp.clamp(r,0,1),n=Gp.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=Qp[t];void 0!==u&&this.setHex(u)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),c=Math.min(i,o,a),l=(c+s)/2;if(c===s)e=0,r=0;else{var u=s-c;switch(r=l<=.5?u/(s+c):u/(2-s-c),s){case i:e=(o-a)/u+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},rf={basic:{uniforms:tf.merge([Jp.common,Jp.specularmap,Jp.envmap,Jp.aomap,Jp.lightmap,Jp.fog]),vertexShader:ef.meshbasic_vert,fragmentShader:ef.meshbasic_frag},lambert:{uniforms:tf.merge([Jp.common,Jp.specularmap,Jp.envmap,Jp.aomap,Jp.lightmap,Jp.emissivemap,Jp.fog,Jp.lights,{emissive:{value:new q(0)}}]),vertexShader:ef.meshlambert_vert,fragmentShader:ef.meshlambert_frag},phong:{uniforms:tf.merge([Jp.common,Jp.specularmap,Jp.envmap,Jp.aomap,Jp.lightmap,Jp.emissivemap,Jp.bumpmap,Jp.normalmap,Jp.displacementmap,Jp.gradientmap,Jp.fog,Jp.lights,{emissive:{value:new q(0)},specular:{value:new q(1118481)},shininess:{value:30}}]),vertexShader:ef.meshphong_vert,fragmentShader:ef.meshphong_frag},standard:{uniforms:tf.merge([Jp.common,Jp.envmap,Jp.aomap,Jp.lightmap,Jp.emissivemap,Jp.bumpmap,Jp.normalmap,Jp.displacementmap,Jp.roughnessmap,Jp.metalnessmap,Jp.fog,Jp.lights,{emissive:{value:new q(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:ef.meshphysical_vert,fragmentShader:ef.meshphysical_frag},points:{uniforms:tf.merge([Jp.points,Jp.fog]),vertexShader:ef.points_vert,fragmentShader:ef.points_frag},dashed:{uniforms:tf.merge([Jp.common,Jp.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ef.linedashed_vert,fragmentShader:ef.linedashed_frag},depth:{uniforms:tf.merge([Jp.common,Jp.displacementmap]),vertexShader:ef.depth_vert,fragmentShader:ef.depth_frag},normal:{uniforms:tf.merge([Jp.common,Jp.bumpmap,Jp.normalmap,Jp.displacementmap,{opacity:{value:1}}]),vertexShader:ef.normal_vert,fragmentShader:ef.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ef.cube_vert,fragmentShader:ef.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ef.equirect_vert,fragmentShader:ef.equirect_frag},distanceRGBA:{uniforms:tf.merge([Jp.common,Jp.displacementmap,{referencePosition:{value:new l},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ef.distanceRGBA_vert,fragmentShader:ef.distanceRGBA_frag},shadow:{uniforms:tf.merge([Jp.lights,{color:{value:new q(0)},opacity:{value:1}}]),vertexShader:ef.shadow_vert,fragmentShader:ef.shadow_frag}};rf.physical={uniforms:tf.merge([rf.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:ef.meshphysical_vert,fragmentShader:ef.meshphysical_frag},Object.assign($.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)}}),K.prototype=Object.create(i.prototype),K.prototype.constructor=K;var nf=0;Object.assign(J.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!==eh&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==qu&&(n.side=this.side),this.vertexColors!==Ku&&(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"})}}),tt.prototype=Object.create(J.prototype),tt.prototype.constructor=tt,tt.prototype.isShaderMaterial=!0,tt.prototype.copy=function(t){return J.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=tf.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},tt.prototype.toJSON=function(t){var e=J.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},et.prototype=Object.create(J.prototype),et.prototype.constructor=et,et.prototype.isMeshDepthMaterial=!0,et.prototype.copy=function(t){return J.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},rt.prototype=Object.create(J.prototype),rt.prototype.constructor=rt,rt.prototype.isMeshDistanceMaterial=!0,rt.prototype.copy=function(t){return J.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(nt.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 it;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(it.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new nt;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 nt;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(ot.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 ot;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(st.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 it;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 it;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}}),ut.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ut.DefaultOrder="XYZ",Object.defineProperties(ut.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(ut.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=Gp.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(ht.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 nt),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new it),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 ot).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 yt).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e0,s=o[1]&&o[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(v=0;v0){u=[];for(v=0;v65535?Et:Mt)(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 _t(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;return void 0!==r&&((new ot).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0),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 pt;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 Ct(3*e.vertices.length,3),n=new Ct(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 Ct(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 Pt).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new _t(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new _t(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new _t(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new _t(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new _t(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Lt(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new _t(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 Ct(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new Ct(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 nt);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 nt,e=new l;return function(){null===this.boundingSphere&&(this.boundingSphere=new it);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 Rt).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);return 0===e||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(kt.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=Gp.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(Ut,{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=Ut.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Ut.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 Ut.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new at).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Ut.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Ut.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new at,e=[new kt,new kt,new kt],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 gt(l,u,p,Ut.normal(s,c,h)),f.faceIndex=l),f}var i=new u,o=new Ft,a=new it,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=F);for(var k=0,U=z.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(pt.prototype),{constructor:Le,copy:function(t){pt.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa||(f.applyMatrix4(this.matrixWorld),(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else for(var y=0,_=g.length/3-1;y<_;y+=d)u.fromArray(g,3*y),h.fromArray(g,3*y+3),(M=e.distanceSqToSegment(u,h,f,p))>a||(f.applyMatrix4(this.matrixWorld),(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else if(s.isGeometry)for(var w=s.vertices,S=w.length,y=0;ya)){f.applyMatrix4(this.matrixWorld);var A=n.ray.origin.distanceTo(f);An.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ze.prototype=Object.assign(Object.create(De.prototype),{constructor:ze,isLineSegments:!0}),Fe.prototype=Object.assign(Object.create(De.prototype),{constructor:Fe,isLineLoop:!0}),ke.prototype=Object.create(J.prototype),ke.prototype.constructor=ke,ke.prototype.isPointsMaterial=!0,ke.prototype.copy=function(t){return J.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Ue.prototype=Object.assign(Object.create(pt.prototype),{constructor:Ue,isPoints:!0,raycast:function(){var t=new u,e=new Ft,r=new it;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(cf.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;d0&&!(--b<0);)for(a=x;an&&(a=0);var s=o(m[t],m[i],m[a],r[e]);if(!s)return!1;var c=r.length-1,l=e-1;l<0&&(l=c);var u=e+1;return u>c&&(u=0),!!(s=o(r[e],r[l],r[u],m[t]))}(a,w)&&!function(t,e){var r,n;for(r=0;r0)return!0;return!1}(s,c)&&!function(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}(s,c)){n=w,g.splice(y,1),h=m.slice(0,a+1),p=m.slice(a),f=r.slice(n),d=r.slice(0,n+1),m=h.concat(f).concat(d).concat(p),x=a;break}if(n>=0)break;v[u]=!0}if(n>=0)break}return m}(t,e),v=cf.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=T+2*A;for(i=0;i=0;V--){for(G=V/A,W=S*Math.cos(G*Math.PI/2),j=M*Math.sin(G*Math.PI/2),Z=0,K=B.length;Z0||0===t.search(/^data\:image\/jpeg/);a.format=r?fp:dp,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}}),Wr.prototype=Object.assign(Object.create(pt.prototype),{constructor:Wr,isLight:!0,copy:function(t){return pt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=pt.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}}),Hr.prototype=Object.assign(Object.create(Wr.prototype),{constructor:Hr,isHemisphereLight:!0,copy:function(t){return Wr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Xr.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}}),Yr.prototype=Object.assign(Object.create(Xr.prototype),{constructor:Yr,isSpotLightShadow:!0,update:function(t){var e=this.camera,r=2*Gp.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())}}),qr.prototype=Object.assign(Object.create(Wr.prototype),{constructor:qr,isSpotLight:!0,copy:function(t){return Wr.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}}),$r.prototype=Object.assign(Object.create(Wr.prototype),{constructor:$r,isPointLight:!0,copy:function(t){return Wr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Zr.prototype=Object.assign(Object.create(Xr.prototype),{constructor:Zr}),Kr.prototype=Object.assign(Object.create(Wr.prototype),{constructor:Kr,isDirectionalLight:!0,copy:function(t){return Wr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Qr.prototype=Object.assign(Object.create(Wr.prototype),{constructor:Qr,isAmbientLight:!0}),Jr.prototype=Object.assign(Object.create(Wr.prototype),{constructor:Jr,isRectAreaLight:!0,copy:function(t){return Wr.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Wr.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var ff={arraySlice:function(t,e,r){return ff.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(tn.prototype,{evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var a=e[1];t=i)break e}o=r,r=0}}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=ff.arraySlice(r,i,o),this.values=ff.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&&ff.isTypedArray(n))for(var a=0,c=n.length;a!==c;++a){var l=n[a];if(isNaN(l)){t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(var d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=ff.arraySlice(t,0,i),this.values=ff.arraySlice(e,0,i*r)),this}},an.prototype=Object.assign(Object.create(df),{constructor:an,ValueTypeName:"vector"}),sn.prototype=Object.assign(Object.create(tn.prototype),{constructor:sn,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}}),cn.prototype=Object.assign(Object.create(df),{constructor:cn,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new sn(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),ln.prototype=Object.assign(Object.create(df),{constructor:ln,ValueTypeName:"number"}),un.prototype=Object.assign(Object.create(df),{constructor:un,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),hn.prototype=Object.assign(Object.create(df),{constructor:hn,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),pn.prototype=Object.assign(Object.create(df),{constructor:pn,ValueTypeName:"color"}),fn.prototype=df,df.constructor=fn,Object.assign(fn,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=fn._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];ff.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:ff.convertArray(t.times,Array),values:ff.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 ln;case"vector":case"vector2":case"vector3":case"vector4":return an;case"color":return pn;case"quaternion":return cn;case"bool":case"boolean":return hn;case"string":return un}throw new Error("Unsupported typeName: "+t)}}),Object.assign(dn,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,o=r.length;i!==o;++i)e.push(fn.parse(r[i]).scale(n));return new dn(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(fn.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(dn.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=[];ff.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[n+1]:0,c=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new o(a,s,c,l))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,p=r>2?t.skinIndices[n+2]:0,f=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new o(u,h,p,f))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||(e.skinIndices.length,e.vertices.length))}function r(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0)for(var h=e.faces,p=t.morphColors[0].colors,n=0,i=h.length;n0&&(e.animations=r)}return function(n,o){void 0!==n.data&&(n=n.data),void 0!==n.scale?n.scale=1/n.scale:n.scale=1;var a=new yt;return t(n,a),e(n,a),r(n,a),i(n,a),a.computeFaceNormals(),a.computeBoundingSphere(),void 0===n.materials||0===n.materials.length?{geometry:a}:{geometry:a,materials:vn.prototype.initMaterials(n.materials,o,this.crossOrigin)}}}()}),Object.assign(_n.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new kr(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 yn,n=new gn,i=0,o=t.length;i0){var i=new Vr(new Fr(e));i.setCrossOrigin(this.crossOrigin);for(var o=0,a=t.length;o0?new Ie(s,c):new Bt(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 Fe(i(e.geometry),o(e.material));break;case"LineSegments":a=new ze(i(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new Ue(i(e.geometry),o(e.material));break;case"Sprite":a=new Pe(o(e.material));break;case"Group":a=new Be;break;default:a=new pt}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(Gp.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(Gp.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(Ln.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(Ln.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 yt,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(xn(o,a.x,s.x,c.x,l.x),xn(o,a.y,s.y,c.y,l.y))},(Dn.prototype=Object.create(Ln.prototype)).constructor=Dn,Dn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,o=this.v3;return new n(Pn(t,e.x,r.x,i.x,o.x),Pn(t,e.y,r.y,i.y,o.y))},(zn.prototype=Object.create(Ln.prototype)).constructor=zn,zn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new n(Mn(t,e.x,r.x,i.x),Mn(t,e.y,r.y,i.y))};var _f=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)}});Fn.prototype=_f,_f.constructor=Fn,kn.prototype=Object.assign(Object.create(_f),{constructor:kn,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;r1){for(var v=!1,y=[],_=0,x=p.length;_Number.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})(S.p,p[A].p)&&(_!==A&&y.push({froms:_,tos:A,hole:w}),M?(M=!1,h[A].push(S)):v=!0);M&&h[_].push(S)}y.length>0&&(v||(f=h))}for(var E,m=0,C=p.length;m0){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(Zn.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(Kn,{Composite:Zn,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new Kn.Composite(t,e,r):new Kn(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;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:Lp:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:Lp: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(ti.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 $n(Kn.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))}}(),Pi.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()},Pi.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Li.prototype=Object.create(ze.prototype),Li.prototype.constructor=Li;var Mf=new l,Af=new Ri,Ef=new Ri,Cf=new Ri;Ni.prototype=Object.create(Ln.prototype),Ni.prototype.constructor=Ni,Ni.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]:(Mf.subVectors(e[0],e[1]).add(e[0]),a=Mf),s=e[i%r],c=e[(i+1)%r],this.closed||i+2-1}function l(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function T(t,e){for(var r=t.length;r--&&g(e,t[r],0)>-1;);return r}function P(t){return"\\"+cr[t]}function L(t){return rr.test(t)}function R(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function N(t,e){return function(r){return t(e(r))}}function I(t,e){for(var r=-1,n=t.length,i=0,o=[];++r>>1,_t=[["ary",nt],["bind",Z],["bindKey",K],["curry",J],["curryRight",tt],["flip",ot],["partial",et],["partialRight",rt],["rearg",it]],xt="[object Arguments]",bt="[object Array]",wt="[object AsyncFunction]",St="[object Boolean]",Mt="[object Date]",At="[object DOMException]",Et="[object Error]",Ct="[object Function]",Tt="[object GeneratorFunction]",Pt="[object Map]",Lt="[object Number]",Rt="[object Null]",Nt="[object Object]",It="[object Proxy]",Ot="[object RegExp]",Dt="[object Set]",zt="[object String]",Ft="[object Symbol]",kt="[object Undefined]",Ut="[object WeakMap]",Bt="[object WeakSet]",Vt="[object ArrayBuffer]",jt="[object DataView]",Gt="[object Float32Array]",Wt="[object Float64Array]",Ht="[object Int8Array]",Xt="[object Int16Array]",Yt="[object Int32Array]",qt="[object Uint8Array]",$t="[object Uint8ClampedArray]",Zt="[object Uint16Array]",Kt="[object Uint32Array]",Qt=/\b__p \+= '';/g,Jt=/\b(__p \+=) '' \+/g,te=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ee=/&(?:amp|lt|gt|quot|#39);/g,re=/[&<>"']/g,ne=RegExp(ee.source),ie=RegExp(re.source),oe=/<%-([\s\S]+?)%>/g,ae=/<%([\s\S]+?)%>/g,se=/<%=([\s\S]+?)%>/g,ce=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,le=/^\w*$/,ue=/^\./,he=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,pe=/[\\^$.*+?()[\]{}|]/g,fe=RegExp(pe.source),de=/^\s+|\s+$/g,me=/^\s+/,ge=/\s+$/,ve=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ye=/\{\n\/\* \[wrapped with (.+)\] \*/,_e=/,? & /,xe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,be=/\\(\\)?/g,we=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Se=/\w*$/,Me=/^[-+]0x[0-9a-f]+$/i,Ae=/^0b[01]+$/i,Ee=/^\[object .+?Constructor\]$/,Ce=/^0o[0-7]+$/i,Te=/^(?:0|[1-9]\d*)$/,Pe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Le=/($^)/,Re=/['\n\r\u2028\u2029\\]/g,Ne="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ie="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Oe="[\\ud800-\\udfff]",De="["+Ie+"]",ze="["+Ne+"]",Fe="\\d+",ke="[\\u2700-\\u27bf]",Ue="[a-z\\xdf-\\xf6\\xf8-\\xff]",Be="[^\\ud800-\\udfff"+Ie+Fe+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",Ve="\\ud83c[\\udffb-\\udfff]",je="[^\\ud800-\\udfff]",Ge="(?:\\ud83c[\\udde6-\\uddff]){2}",We="[\\ud800-\\udbff][\\udc00-\\udfff]",He="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Xe="(?:"+Ue+"|"+Be+")",Ye="(?:"+He+"|"+Be+")",qe="(?:"+ze+"|"+Ve+")"+"?",$e="[\\ufe0e\\ufe0f]?"+qe+("(?:\\u200d(?:"+[je,Ge,We].join("|")+")[\\ufe0e\\ufe0f]?"+qe+")*"),Ze="(?:"+[ke,Ge,We].join("|")+")"+$e,Ke="(?:"+[je+ze+"?",ze,Ge,We,Oe].join("|")+")",Qe=RegExp("['’]","g"),Je=RegExp(ze,"g"),tr=RegExp(Ve+"(?="+Ve+")|"+Ke+$e,"g"),er=RegExp([He+"?"+Ue+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[De,He,"$"].join("|")+")",Ye+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[De,He+Xe,"$"].join("|")+")",He+"?"+Xe+"+(?:['’](?:d|ll|m|re|s|t|ve))?",He+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)",Fe,Ze].join("|"),"g"),rr=RegExp("[\\u200d\\ud800-\\udfff"+Ne+"\\ufe0e\\ufe0f]"),nr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ir=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],or=-1,ar={};ar[Gt]=ar[Wt]=ar[Ht]=ar[Xt]=ar[Yt]=ar[qt]=ar[$t]=ar[Zt]=ar[Kt]=!0,ar[xt]=ar[bt]=ar[Vt]=ar[St]=ar[jt]=ar[Mt]=ar[Et]=ar[Ct]=ar[Pt]=ar[Lt]=ar[Nt]=ar[Ot]=ar[Dt]=ar[zt]=ar[Ut]=!1;var sr={};sr[xt]=sr[bt]=sr[Vt]=sr[jt]=sr[St]=sr[Mt]=sr[Gt]=sr[Wt]=sr[Ht]=sr[Xt]=sr[Yt]=sr[Pt]=sr[Lt]=sr[Nt]=sr[Ot]=sr[Dt]=sr[zt]=sr[Ft]=sr[qt]=sr[$t]=sr[Zt]=sr[Kt]=!0,sr[Et]=sr[Ct]=sr[Ut]=!1;var cr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lr=parseFloat,ur=parseInt,hr="object"==typeof _l&&_l&&_l.Object===Object&&_l,pr="object"==typeof self&&self&&self.Object===Object&&self,fr=hr||pr||Function("return this")(),dr=e&&!e.nodeType&&e,mr=dr&&!0&&t&&!t.nodeType&&t,gr=mr&&mr.exports===dr,vr=gr&&hr.process,yr=function(){try{return vr&&vr.binding&&vr.binding("util")}catch(t){}}(),_r=yr&&yr.isArrayBuffer,xr=yr&&yr.isDate,br=yr&&yr.isMap,wr=yr&&yr.isRegExp,Sr=yr&&yr.isSet,Mr=yr&&yr.isTypedArray,Ar=_("length"),Er=x({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Cr=x({"&":"&","<":"<",">":">",'"':""","'":"'"}),Tr=x({"&":"&","<":"<",">":">",""":'"',"'":"'"}),Pr=function t(e){function x(t){if(to(t)&&!Ws(t)&&!(t instanceof Oe)){if(t instanceof Ie)return t;if(Wo.call(t,"__wrapped__"))return Mi(t)}return new Ie(t)}function Ne(){}function Ie(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=k}function Oe(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=gt,this.__views__=[]}function De(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function $e(t,e,i,a,s,c){var l,u=e&H,h=e&X,f=e&Y;if(i&&(l=s?i(t,a,s,c):i(t)),l!==k)return l;if(!Ji(t))return t;var d=Ws(t);if(d){if(l=function(t){var e=t.length,r=t.constructor(e);return e&&"string"==typeof t[0]&&Wo.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return En(t,l)}else{var m=ts(t),g=m==Ct||m==Tt;if(Xs(t))return xn(t,u);if(m==Nt||m==xt||g&&!s){if(l=h||g?{}:ci(t),!u)return h?function(t,e){return Cn(t,Ja(t),e)}(t,function(e,r){return e&&Cn(t,go(t),e)}(l)):function(t,e){return Cn(t,Qa(t),e)}(t,He(l,t))}else{if(!sr[m])return s?t:{};l=function(t,e,i,o){var a=t.constructor;switch(e){case Vt:return bn(t);case St:case Mt:return new a(+t);case jt:return function(t,e){var r=e?bn(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,o);case Gt:case Wt:case Ht:case Xt:case Yt:case qt:case $t:case Zt:case Kt:return wn(t,o);case Pt:return function(t,e,n){return p(e?n(R(t),H):R(t),r,new t.constructor)}(t,o,i);case Lt:case zt:return new a(t);case Ot:return function(t){var e=new t.constructor(t.source,Se.exec(t));return e.lastIndex=t.lastIndex,e}(t);case Dt:return function(t,e,r){return p(e?r(O(t),H):O(t),n,new t.constructor)}(t,o,i);case Ft:return function(t){return Ua?Do(Ua.call(t)):{}}(t)}}(t,m,$e,u)}}c||(c=new Ue);var v=c.get(t);if(v)return v;c.set(t,l);var y=d?k:(f?h?ti:Jn:h?go:mo)(t);return o(y||t,function(r,n){y&&(r=t[n=r]),Ge(l,n,$e(r,e,i,n,t,c))}),l}function Ze(t,e,r){var n=r.length;if(null==t)return!n;for(t=Do(t);n--;){var i=r[n],o=e[i],a=t[i];if(a===k&&!(i in t)||!o(a))return!1}return!0}function Ke(t,e,r){if("function"!=typeof t)throw new ko(V);return ns(function(){t.apply(k,r)},e)}function tr(t,e,r,n){var i=-1,o=c,a=!0,s=t.length,h=[],p=e.length;if(!s)return h;r&&(e=u(e,M(r))),n?(o=l,a=!1):e.length>=U&&(o=E,a=!1,e=new ke(e));t:for(;++i0&&r(s)?e>1?hr(s,e-1,r,n,i):h(i,s):n||(i[i.length]=s)}return i}function pr(t,e){return t&&Wa(t,e,mo)}function dr(t,e){return t&&Ha(t,e,mo)}function mr(t,e){return s(e,function(e){return Zi(t[e])})}function vr(t,e){for(var r=0,n=(e=yn(e,t)).length;null!=t&&re}function Rr(t,e){return null!=t&&Wo.call(t,e)}function Nr(t,e){return null!=t&&e in Do(t)}function Ir(t,e,r){for(var n=r?l:c,i=t[0].length,o=t.length,a=o,s=Lo(o),h=1/0,p=[];a--;){var f=t[a];a&&e&&(f=u(f,M(e))),h=xa(f.length,h),s[a]=!r&&(e||i>=120&&f.length>=120)?new ke(a&&f):k}f=t[0];var d=-1,m=s[0];t:for(;++d=s)return c;var l=r[n];return c*("desc"==l?-1:1)}}return t.index-e.index}(t,e,r)})}function $r(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)s!==t&&ia.call(s,c,1),ia.call(t,c,1);return t}function Kr(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;ui(i)?ia.call(t,i,1):un(t,i)}}return t}function Qr(t,e){return t+fa(Sa()*(e-t+1))}function Jr(t,e){var r="";if(!t||e<1||e>ft)return r;do{e%2&&(r+=t),(e=fa(e/2))&&(t+=t)}while(e);return r}function tn(t,e){return is(vi(t,e,So),t+"")}function en(t,e,r,n){if(!Ji(t))return t;for(var i=-1,o=(e=yn(e,t)).length,a=o-1,s=t;null!=s&&++ii?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Lo(i);++n>>1,a=t[o];null!==a&&!io(a)&&(r?a<=e:a=U){var h=e?null:Za(t);if(h)return O(h);a=!1,i=E,u=new ke}else u=e?[]:s;t:for(;++n=n?t:rn(t,e,r)}function xn(t,e){if(e)return t.slice();var r=t.length,n=ta?ta(r):new t.constructor(r);return t.copy(n),n}function bn(t){var e=new t.constructor(t.byteLength);return new Jo(e).set(new Jo(t)),e}function wn(t,e){var r=e?bn(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Sn(t,e){if(t!==e){var r=t!==k,n=null===t,i=t==t,o=io(t),a=e!==k,s=null===e,c=e==e,l=io(e);if(!s&&!l&&!o&&t>e||o&&a&&c&&!s&&!l||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!l&&t1?r[i-1]:k,a=i>2?r[2]:k;for(o=t.length>3&&"function"==typeof o?(i--,o):k,a&&hi(r[0],r[1],a)&&(o=i<3?k:o,i=1),e=Do(e);++n-1?i[o?e[a]:a]:k}}function zn(t){return Qn(function(e){var r=e.length,n=r,i=Ie.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new ko(V);if(i&&!a&&"wrapper"==ei(o))var a=new Ie([],!0)}for(n=a?n:r;++n1&&y.reverse(),h&&cs))return!1;var l=o.get(t);if(l&&o.get(e))return l==e;var u=-1,h=!0,p=r&$?new ke:k;for(o.set(t,e),o.set(e,t);++u-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(ve,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return o(_t,function(r){var n="_."+r[0];e&r[1]&&!c(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(ye);return e?e[1].split(_e):[]}(n),r)))}function xi(t){var e=0,r=0;return function(){var n=ba(),i=lt-(n-r);if(r=n,i>0){if(++e>=ct)return arguments[0]}else e=0;return t.apply(k,arguments)}}function bi(t,e){var r=-1,n=t.length,i=n-1;for(e=e===k?n:e;++r0&&(r=e.apply(this,arguments)),t<=1&&(e=k),r}}function Vi(t,e,r){var n=Yn(t,J,k,k,k,k,k,e=r?k:e);return n.placeholder=Vi.placeholder,n}function ji(t,e,r){var n=Yn(t,tt,k,k,k,k,k,e=r?k:e);return n.placeholder=ji.placeholder,n}function Gi(t,e,r){function n(e){var r=c,n=l;return c=l=k,d=e,h=t.apply(n,r)}function i(t){var r=t-f;return f===k||r>=e||r<0||g&&t-d>=u}function o(){var t=Ns();if(i(t))return a(t);p=ns(o,function(t){var r=e-(t-f);return g?xa(r,u-(t-d)):r}(t))}function a(t){return p=k,v&&c?n(t):(c=l=k,h)}function s(){var t=Ns(),r=i(t);if(c=arguments,l=this,f=t,r){if(p===k)return function(t){return d=t,p=ns(o,e),m?n(t):h}(f);if(g)return p=ns(o,e),n(f)}return p===k&&(p=ns(o,e)),h}var c,l,u,h,p,f,d=0,m=!1,g=!1,v=!0;if("function"!=typeof t)throw new ko(V);return e=lo(e)||0,Ji(r)&&(m=!!r.leading,u=(g="maxWait"in r)?_a(lo(r.maxWait)||0,e):u,v="trailing"in r?!!r.trailing:v),s.cancel=function(){p!==k&&$a(p),d=0,c=f=l=p=k},s.flush=function(){return p===k?h:a(Ns())},s}function Wi(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ko(V);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Wi.Cache||Fe),r}function Hi(t){if("function"!=typeof t)throw new ko(V);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Xi(t,e){return t===e||t!=t&&e!=e}function Yi(t){return null!=t&&Qi(t.length)&&!Zi(t)}function qi(t){return to(t)&&Yi(t)}function $i(t){if(!to(t))return!1;var e=Ar(t);return e==Et||e==At||"string"==typeof t.message&&"string"==typeof t.name&&!ro(t)}function Zi(t){if(!Ji(t))return!1;var e=Ar(t);return e==Ct||e==Tt||e==wt||e==It}function Ki(t){return"number"==typeof t&&t==so(t)}function Qi(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=ft}function Ji(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function to(t){return null!=t&&"object"==typeof t}function eo(t){return"number"==typeof t||to(t)&&Ar(t)==Lt}function ro(t){if(!to(t)||Ar(t)!=Nt)return!1;var e=ea(t);if(null===e)return!0;var r=Wo.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Go.call(r)==qo}function no(t){return"string"==typeof t||!Ws(t)&&to(t)&&Ar(t)==zt}function io(t){return"symbol"==typeof t||to(t)&&Ar(t)==Ft}function oo(t){if(!t)return[];if(Yi(t))return no(t)?F(t):En(t);if(aa&&t[aa])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[aa]());var e=ts(t);return(e==Pt?R:e==Dt?O:yo)(t)}function ao(t){return t?(t=lo(t))===pt||t===-pt?(t<0?-1:1)*dt:t==t?t:0:0===t?t:0}function so(t){var e=ao(t),r=e%1;return e==e?r?e-r:e:0}function co(t){return t?qe(so(t),0,gt):0}function lo(t){if("number"==typeof t)return t;if(io(t))return mt;if(Ji(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ji(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(de,"");var r=Ae.test(t);return r||Ce.test(t)?ur(t.slice(2),r?2:8):Me.test(t)?mt:+t}function uo(t){return Cn(t,go(t))}function ho(t){return null==t?"":cn(t)}function po(t,e,r){var n=null==t?k:vr(t,e);return n===k?r:n}function fo(t,e){return null!=t&&si(t,e,Nr)}function mo(t){return Yi(t)?Be(t):Br(t)}function go(t){return Yi(t)?Be(t,!0):Vr(t)}function vo(t,e){if(null==t)return{};var r=u(ti(t),function(t){return[t]});return e=ni(e),$r(t,r,function(t,r){return e(t,r[0])})}function yo(t){return null==t?[]:A(t,mo(t))}function _o(t){return Sc(ho(t).toLowerCase())}function xo(t){return(t=ho(t))&&t.replace(Pe,Er).replace(Je,"")}function bo(t,e,r){return t=ho(t),(e=r?k:e)===k?function(t){return nr.test(t)}(t)?function(t){return t.match(er)||[]}(t):function(t){return t.match(xe)||[]}(t):t.match(e)||[]}function wo(t){return function(){return t}}function So(t){return t}function Mo(t){return Ur("function"==typeof t?t:$e(t,H))}function Ao(t,e,r){var n=mo(e),i=mr(e,n);null!=r||Ji(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=mr(e,mo(e)));var a=!(Ji(r)&&"chain"in r&&!r.chain),s=Zi(t);return o(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__);return(r.__actions__=En(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,h([this.value()],arguments))})}),t}function Eo(){}function Co(t){return pi(t)?_(wi(t)):function(t){return function(e){return vr(e,t)}}(t)}function To(){return[]}function Po(){return!1}var Lo=(e=null==e?fr:Pr.defaults(fr.Object(),e,Pr.pick(fr,ir))).Array,Ro=e.Date,No=e.Error,Io=e.Function,Oo=e.Math,Do=e.Object,zo=e.RegExp,Fo=e.String,ko=e.TypeError,Uo=Lo.prototype,Bo=Io.prototype,Vo=Do.prototype,jo=e["__core-js_shared__"],Go=Bo.toString,Wo=Vo.hasOwnProperty,Ho=0,Xo=function(){var t=/[^.]+$/.exec(jo&&jo.keys&&jo.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Yo=Vo.toString,qo=Go.call(Do),$o=fr._,Zo=zo("^"+Go.call(Wo).replace(pe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ko=gr?e.Buffer:k,Qo=e.Symbol,Jo=e.Uint8Array,ta=Ko?Ko.allocUnsafe:k,ea=N(Do.getPrototypeOf,Do),ra=Do.create,na=Vo.propertyIsEnumerable,ia=Uo.splice,oa=Qo?Qo.isConcatSpreadable:k,aa=Qo?Qo.iterator:k,sa=Qo?Qo.toStringTag:k,ca=function(){try{var t=ai(Do,"defineProperty");return t({},"",{}),t}catch(t){}}(),la=e.clearTimeout!==fr.clearTimeout&&e.clearTimeout,ua=Ro&&Ro.now!==fr.Date.now&&Ro.now,ha=e.setTimeout!==fr.setTimeout&&e.setTimeout,pa=Oo.ceil,fa=Oo.floor,da=Do.getOwnPropertySymbols,ma=Ko?Ko.isBuffer:k,ga=e.isFinite,va=Uo.join,ya=N(Do.keys,Do),_a=Oo.max,xa=Oo.min,ba=Ro.now,wa=e.parseInt,Sa=Oo.random,Ma=Uo.reverse,Aa=ai(e,"DataView"),Ea=ai(e,"Map"),Ca=ai(e,"Promise"),Ta=ai(e,"Set"),Pa=ai(e,"WeakMap"),La=ai(Do,"create"),Ra=Pa&&new Pa,Na={},Ia=Si(Aa),Oa=Si(Ea),Da=Si(Ca),za=Si(Ta),Fa=Si(Pa),ka=Qo?Qo.prototype:k,Ua=ka?ka.valueOf:k,Ba=ka?ka.toString:k,Va=function(){function t(){}return function(e){if(!Ji(e))return{};if(ra)return ra(e);t.prototype=e;var r=new t;return t.prototype=k,r}}();x.templateSettings={escape:oe,evaluate:ae,interpolate:se,variable:"",imports:{_:x}},(x.prototype=Ne.prototype).constructor=x,(Ie.prototype=Va(Ne.prototype)).constructor=Ie,(Oe.prototype=Va(Ne.prototype)).constructor=Oe,De.prototype.clear=function(){this.__data__=La?La(null):{},this.size=0},De.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},De.prototype.get=function(t){var e=this.__data__;if(La){var r=e[t];return r===j?k:r}return Wo.call(e,t)?e[t]:k},De.prototype.has=function(t){var e=this.__data__;return La?e[t]!==k:Wo.call(e,t)},De.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=La&&e===k?j:e,this},ze.prototype.clear=function(){this.__data__=[],this.size=0},ze.prototype.delete=function(t){var e=this.__data__,r=We(e,t);return!(r<0||(r==e.length-1?e.pop():ia.call(e,r,1),--this.size,0))},ze.prototype.get=function(t){var e=this.__data__,r=We(e,t);return r<0?k:e[r][1]},ze.prototype.has=function(t){return We(this.__data__,t)>-1},ze.prototype.set=function(t,e){var r=this.__data__,n=We(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Fe.prototype.clear=function(){this.size=0,this.__data__={hash:new De,map:new(Ea||ze),string:new De}},Fe.prototype.delete=function(t){var e=ii(this,t).delete(t);return this.size-=e?1:0,e},Fe.prototype.get=function(t){return ii(this,t).get(t)},Fe.prototype.has=function(t){return ii(this,t).has(t)},Fe.prototype.set=function(t,e){var r=ii(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},ke.prototype.add=ke.prototype.push=function(t){return this.__data__.set(t,j),this},ke.prototype.has=function(t){return this.__data__.has(t)},Ue.prototype.clear=function(){this.__data__=new ze,this.size=0},Ue.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ue.prototype.get=function(t){return this.__data__.get(t)},Ue.prototype.has=function(t){return this.__data__.has(t)},Ue.prototype.set=function(t,e){var r=this.__data__;if(r instanceof ze){var n=r.__data__;if(!Ea||n.length1?t[e-1]:k;return r="function"==typeof r?(t.pop(),r):k,Ii(t,r)}),Ss=Qn(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return Ye(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Oe&&ui(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:Di,args:[i],thisArg:k}),new Ie(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(k),t})):this.thru(i)}),Ms=Tn(function(t,e,r){Wo.call(t,r)?++t[r]:Xe(t,r,1)}),As=Dn(Ai),Es=Dn(Ei),Cs=Tn(function(t,e,r){Wo.call(t,r)?t[r].push(e):Xe(t,r,[e])}),Ts=tn(function(t,e,r){var n=-1,o="function"==typeof e,a=Yi(t)?Lo(t.length):[];return ja(t,function(t){a[++n]=o?i(e,t,r):Or(t,e,r)}),a}),Ps=Tn(function(t,e,r){Xe(t,r,e)}),Ls=Tn(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),Rs=tn(function(t,e){if(null==t)return[];var r=e.length;return r>1&&hi(t,e[0],e[1])?e=[]:r>2&&hi(e[0],e[1],e[2])&&(e=[e[0]]),qr(t,hr(e,1),[])}),Ns=ua||function(){return fr.Date.now()},Is=tn(function(t,e,r){var n=Z;if(r.length){var i=I(r,ri(Is));n|=et}return Yn(t,n,e,r,i)}),Os=tn(function(t,e,r){var n=Z|K;if(r.length){var i=I(r,ri(Os));n|=et}return Yn(e,n,t,r,i)}),Ds=tn(function(t,e){return Ke(t,1,e)}),zs=tn(function(t,e,r){return Ke(t,lo(e)||0,r)});Wi.Cache=Fe;var Fs=qa(function(t,e){var r=(e=1==e.length&&Ws(e[0])?u(e[0],M(ni())):u(hr(e,1),M(ni()))).length;return tn(function(n){for(var o=-1,a=xa(n.length,r);++o=e}),Gs=Dr(function(){return arguments}())?Dr:function(t){return to(t)&&Wo.call(t,"callee")&&!na.call(t,"callee")},Ws=Lo.isArray,Hs=_r?M(_r):function(t){return to(t)&&Ar(t)==Vt},Xs=ma||Po,Ys=xr?M(xr):function(t){return to(t)&&Ar(t)==Mt},qs=br?M(br):function(t){return to(t)&&ts(t)==Pt},$s=wr?M(wr):function(t){return to(t)&&Ar(t)==Ot},Zs=Sr?M(Sr):function(t){return to(t)&&ts(t)==Dt},Ks=Mr?M(Mr):function(t){return to(t)&&Qi(t.length)&&!!ar[Ar(t)]},Qs=Gn(jr),Js=Gn(function(t,e){return t<=e}),tc=Pn(function(t,e){if(di(e)||Yi(e))Cn(e,mo(e),t);else for(var r in e)Wo.call(e,r)&&Ge(t,r,e[r])}),ec=Pn(function(t,e){Cn(e,go(e),t)}),rc=Pn(function(t,e,r,n){Cn(e,go(e),t,n)}),nc=Pn(function(t,e,r,n){Cn(e,mo(e),t,n)}),ic=Qn(Ye),oc=tn(function(t){return t.push(k,qn),i(rc,k,t)}),ac=tn(function(t){return t.push(k,$n),i(hc,k,t)}),sc=kn(function(t,e,r){t[e]=r},wo(So)),cc=kn(function(t,e,r){Wo.call(t,e)?t[e].push(r):t[e]=[r]},ni),lc=tn(Or),uc=Pn(function(t,e,r){Xr(t,e,r)}),hc=Pn(function(t,e,r,n){Xr(t,e,r,n)}),pc=Qn(function(t,e){var r={};if(null==t)return r;var n=!1;e=u(e,function(e){return e=yn(e,t),n||(n=e.length>1),e}),Cn(t,ti(t),r),n&&(r=$e(r,H|X|Y,Zn));for(var i=e.length;i--;)un(r,e[i]);return r}),fc=Qn(function(t,e){return null==t?{}:function(t,e){return $r(t,e,function(e,r){return fo(t,r)})}(t,e)}),dc=Xn(mo),mc=Xn(go),gc=In(function(t,e,r){return e=e.toLowerCase(),t+(r?_o(e):e)}),vc=In(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),yc=In(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),_c=Nn("toLowerCase"),xc=In(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),bc=In(function(t,e,r){return t+(r?" ":"")+Sc(e)}),wc=In(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Sc=Nn("toUpperCase"),Mc=tn(function(t,e){try{return i(t,k,e)}catch(t){return $i(t)?t:new No(t)}}),Ac=Qn(function(t,e){return o(e,function(e){e=wi(e),Xe(t,e,Is(t[e],t))}),t}),Ec=zn(),Cc=zn(!0),Tc=tn(function(t,e){return function(r){return Or(r,t,e)}}),Pc=tn(function(t,e){return function(r){return Or(t,r,e)}}),Lc=Bn(u),Rc=Bn(a),Nc=Bn(f),Ic=jn(),Oc=jn(!0),Dc=Un(function(t,e){return t+e},0),zc=Hn("ceil"),Fc=Un(function(t,e){return t/e},1),kc=Hn("floor"),Uc=Un(function(t,e){return t*e},1),Bc=Hn("round"),Vc=Un(function(t,e){return t-e},0);return x.after=function(t,e){if("function"!=typeof e)throw new ko(V);return t=so(t),function(){if(--t<1)return e.apply(this,arguments)}},x.ary=Ui,x.assign=tc,x.assignIn=ec,x.assignInWith=rc,x.assignWith=nc,x.at=ic,x.before=Bi,x.bind=Is,x.bindAll=Ac,x.bindKey=Os,x.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Ws(t)?t:[t]},x.chain=Oi,x.chunk=function(t,e,r){e=(r?hi(t,e,r):e===k)?1:_a(so(e),0);var n=null==t?0:t.length;if(!n||e<1)return[];for(var i=0,o=0,a=Lo(pa(n/e));ii?0:i+r),(n=n===k||n>i?i:so(n))<0&&(n+=i),n=r>n?0:co(n);r>>0)?(t=ho(t))&&("string"==typeof e||null!=e&&!$s(e))&&!(e=cn(e))&&L(t)?_n(F(t),0,r):t.split(e,r):[]},x.spread=function(t,e){if("function"!=typeof t)throw new ko(V);return e=null==e?0:_a(so(e),0),tn(function(r){var n=r[e],o=_n(r,0,e);return n&&h(o,n),i(t,this,o)})},x.tail=function(t){var e=null==t?0:t.length;return e?rn(t,1,e):[]},x.take=function(t,e,r){return t&&t.length?(e=r||e===k?1:so(e),rn(t,0,e<0?0:e)):[]},x.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?(e=r||e===k?1:so(e),e=n-e,rn(t,e<0?0:e,n)):[]},x.takeRightWhile=function(t,e){return t&&t.length?pn(t,ni(e,3),!1,!0):[]},x.takeWhile=function(t,e){return t&&t.length?pn(t,ni(e,3)):[]},x.tap=function(t,e){return e(t),t},x.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ko(V);return Ji(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Gi(t,e,{leading:n,maxWait:e,trailing:i})},x.thru=Di,x.toArray=oo,x.toPairs=dc,x.toPairsIn=mc,x.toPath=function(t){return Ws(t)?u(t,wi):io(t)?[t]:En(os(ho(t)))},x.toPlainObject=uo,x.transform=function(t,e,r){var n=Ws(t),i=n||Xs(t)||Ks(t);if(e=ni(e,4),null==r){var a=t&&t.constructor;r=i?n?new a:[]:Ji(t)&&Zi(a)?Va(ea(t)):{}}return(i?o:pr)(t,function(t,n,i){return e(r,t,n,i)}),r},x.unary=function(t){return Ui(t,1)},x.union=ds,x.unionBy=ms,x.unionWith=gs,x.uniq=function(t){return t&&t.length?ln(t):[]},x.uniqBy=function(t,e){return t&&t.length?ln(t,ni(e,2)):[]},x.uniqWith=function(t,e){return e="function"==typeof e?e:k,t&&t.length?ln(t,k,e):[]},x.unset=function(t,e){return null==t||un(t,e)},x.unzip=Ni,x.unzipWith=Ii,x.update=function(t,e,r){return null==t?t:hn(t,e,vn(r))},x.updateWith=function(t,e,r,n){return n="function"==typeof n?n:k,null==t?t:hn(t,e,vn(r),n)},x.values=yo,x.valuesIn=function(t){return null==t?[]:A(t,go(t))},x.without=vs,x.words=bo,x.wrap=function(t,e){return ks(vn(e),t)},x.xor=ys,x.xorBy=_s,x.xorWith=xs,x.zip=bs,x.zipObject=function(t,e){return mn(t||[],e||[],Ge)},x.zipObjectDeep=function(t,e){return mn(t||[],e||[],en)},x.zipWith=ws,x.entries=dc,x.entriesIn=mc,x.extend=ec,x.extendWith=rc,Ao(x,x),x.add=Dc,x.attempt=Mc,x.camelCase=gc,x.capitalize=_o,x.ceil=zc,x.clamp=function(t,e,r){return r===k&&(r=e,e=k),r!==k&&(r=(r=lo(r))==r?r:0),e!==k&&(e=(e=lo(e))==e?e:0),qe(lo(t),e,r)},x.clone=function(t){return $e(t,Y)},x.cloneDeep=function(t){return $e(t,H|Y)},x.cloneDeepWith=function(t,e){return e="function"==typeof e?e:k,$e(t,H|Y,e)},x.cloneWith=function(t,e){return e="function"==typeof e?e:k,$e(t,Y,e)},x.conformsTo=function(t,e){return null==e||Ze(t,e,mo(e))},x.deburr=xo,x.defaultTo=function(t,e){return null==t||t!=t?e:t},x.divide=Fc,x.endsWith=function(t,e,r){t=ho(t),e=cn(e);var n=t.length,i=r=r===k?n:qe(so(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},x.eq=Xi,x.escape=function(t){return(t=ho(t))&&ie.test(t)?t.replace(re,Cr):t},x.escapeRegExp=function(t){return(t=ho(t))&&fe.test(t)?t.replace(pe,"\\$&"):t},x.every=function(t,e,r){var n=Ws(t)?a:function(t,e){var r=!0;return ja(t,function(t,n,i){return r=!!e(t,n,i)}),r};return r&&hi(t,e,r)&&(e=k),n(t,ni(e,3))},x.find=As,x.findIndex=Ai,x.findKey=function(t,e){return d(t,ni(e,3),pr)},x.findLast=Es,x.findLastIndex=Ei,x.findLastKey=function(t,e){return d(t,ni(e,3),dr)},x.floor=kc,x.forEach=zi,x.forEachRight=Fi,x.forIn=function(t,e){return null==t?t:Wa(t,ni(e,3),go)},x.forInRight=function(t,e){return null==t?t:Ha(t,ni(e,3),go)},x.forOwn=function(t,e){return t&&pr(t,ni(e,3))},x.forOwnRight=function(t,e){return t&&dr(t,ni(e,3))},x.get=po,x.gt=Vs,x.gte=js,x.has=function(t,e){return null!=t&&si(t,e,Rr)},x.hasIn=fo,x.head=Ti,x.identity=So,x.includes=function(t,e,r,n){t=Yi(t)?t:yo(t),r=r&&!n?so(r):0;var i=t.length;return r<0&&(r=_a(i+r,0)),no(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&g(t,e,r)>-1},x.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:so(r);return i<0&&(i=_a(n+i,0)),g(t,e,i)},x.inRange=function(t,e,r){return e=ao(e),r===k?(r=e,e=0):r=ao(r),t=lo(t),function(t,e,r){return t>=xa(e,r)&&t<_a(e,r)}(t,e,r)},x.invoke=lc,x.isArguments=Gs,x.isArray=Ws,x.isArrayBuffer=Hs,x.isArrayLike=Yi,x.isArrayLikeObject=qi,x.isBoolean=function(t){return!0===t||!1===t||to(t)&&Ar(t)==St},x.isBuffer=Xs,x.isDate=Ys,x.isElement=function(t){return to(t)&&1===t.nodeType&&!ro(t)},x.isEmpty=function(t){if(null==t)return!0;if(Yi(t)&&(Ws(t)||"string"==typeof t||"function"==typeof t.splice||Xs(t)||Ks(t)||Gs(t)))return!t.length;var e=ts(t);if(e==Pt||e==Dt)return!t.size;if(di(t))return!Br(t).length;for(var r in t)if(Wo.call(t,r))return!1;return!0},x.isEqual=function(t,e){return zr(t,e)},x.isEqualWith=function(t,e,r){var n=(r="function"==typeof r?r:k)?r(t,e):k;return n===k?zr(t,e,k,r):!!n},x.isError=$i,x.isFinite=function(t){return"number"==typeof t&&ga(t)},x.isFunction=Zi,x.isInteger=Ki,x.isLength=Qi,x.isMap=qs,x.isMatch=function(t,e){return t===e||Fr(t,e,oi(e))},x.isMatchWith=function(t,e,r){return r="function"==typeof r?r:k,Fr(t,e,oi(e),r)},x.isNaN=function(t){return eo(t)&&t!=+t},x.isNative=function(t){if(es(t))throw new No(B);return kr(t)},x.isNil=function(t){return null==t},x.isNull=function(t){return null===t},x.isNumber=eo,x.isObject=Ji,x.isObjectLike=to,x.isPlainObject=ro,x.isRegExp=$s,x.isSafeInteger=function(t){return Ki(t)&&t>=-ft&&t<=ft},x.isSet=Zs,x.isString=no,x.isSymbol=io,x.isTypedArray=Ks,x.isUndefined=function(t){return t===k},x.isWeakMap=function(t){return to(t)&&ts(t)==Ut},x.isWeakSet=function(t){return to(t)&&Ar(t)==Bt},x.join=function(t,e){return null==t?"":va.call(t,e)},x.kebabCase=vc,x.last=Pi,x.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==k&&(i=(i=so(r))<0?_a(n+i,0):xa(i,n-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,i):m(t,v,i,!0)},x.lowerCase=yc,x.lowerFirst=_c,x.lt=Qs,x.lte=Js,x.max=function(t){return t&&t.length?rr(t,So,Lr):k},x.maxBy=function(t,e){return t&&t.length?rr(t,ni(e,2),Lr):k},x.mean=function(t){return y(t,So)},x.meanBy=function(t,e){return y(t,ni(e,2))},x.min=function(t){return t&&t.length?rr(t,So,jr):k},x.minBy=function(t,e){return t&&t.length?rr(t,ni(e,2),jr):k},x.stubArray=To,x.stubFalse=Po,x.stubObject=function(){return{}},x.stubString=function(){return""},x.stubTrue=function(){return!0},x.multiply=Uc,x.nth=function(t,e){return t&&t.length?Yr(t,so(e)):k},x.noConflict=function(){return fr._===this&&(fr._=$o),this},x.noop=Eo,x.now=Ns,x.pad=function(t,e,r){t=ho(t);var n=(e=so(e))?z(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Vn(fa(i),r)+t+Vn(pa(i),r)},x.padEnd=function(t,e,r){t=ho(t);var n=(e=so(e))?z(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Sa();return xa(t+i*(e-t+lr("1e-"+((i+"").length-1))),e)}return Qr(t,e)},x.reduce=function(t,e,r){var n=Ws(t)?p:b,i=arguments.length<3;return n(t,ni(e,4),r,i,ja)},x.reduceRight=function(t,e,r){var n=Ws(t)?function(t,e,r,n){var i=null==t?0:t.length;for(n&&i&&(r=t[--i]);i--;)r=e(r,t[i],i,t);return r}:b,i=arguments.length<3;return n(t,ni(e,4),r,i,Ga)},x.repeat=function(t,e,r){return e=(r?hi(t,e,r):e===k)?1:so(e),Jr(ho(t),e)},x.replace=function(){var t=arguments,e=ho(t[0]);return t.length<3?e:e.replace(t[1],t[2])},x.result=function(t,e,r){var n=-1,i=(e=yn(e,t)).length;for(i||(i=1,t=k);++nft)return[];var r=gt,n=xa(t,gt);e=ni(e),t-=gt;for(var i=S(n,e);++r=o)return t;var s=r-z(n);if(s<1)return n;var c=a?_n(a,0,s).join(""):t.slice(0,s);if(i===k)return c+n;if(a&&(s+=c.length-s),$s(i)){if(t.slice(s).search(i)){var l,u=c;for(i.global||(i=zo(i.source,ho(Se.exec(i))+"g")),i.lastIndex=0;l=i.exec(u);)var h=l.index;c=c.slice(0,h===k?s:h)}}else if(t.indexOf(cn(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},x.unescape=function(t){return(t=ho(t))&&ne.test(t)?t.replace(ee,Tr):t},x.uniqueId=function(t){var e=++Ho;return ho(t)+e},x.upperCase=wc,x.upperFirst=Sc,x.each=zi,x.eachRight=Fi,x.first=Ti,Ao(x,function(){var t={};return pr(x,function(e,r){Wo.call(x.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),x.VERSION="4.17.4",o(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){x[t].placeholder=x}),o(["drop","take"],function(t,e){Oe.prototype[t]=function(r){r=r===k?1:_a(so(r),0);var n=this.__filtered__&&!e?new Oe(this):this.clone();return n.__filtered__?n.__takeCount__=xa(r,n.__takeCount__):n.__views__.push({size:xa(r,gt),type:t+(n.__dir__<0?"Right":"")}),n},Oe.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),o(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==ut||3==r;Oe.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:ni(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),o(["head","last"],function(t,e){var r="take"+(e?"Right":"");Oe.prototype[t]=function(){return this[r](1).value()[0]}}),o(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");Oe.prototype[t]=function(){return this.__filtered__?new Oe(this):this[r](1)}}),Oe.prototype.compact=function(){return this.filter(So)},Oe.prototype.find=function(t){return this.filter(t).head()},Oe.prototype.findLast=function(t){return this.reverse().find(t)},Oe.prototype.invokeMap=tn(function(t,e){return"function"==typeof t?new Oe(this):this.map(function(r){return Or(r,t,e)})}),Oe.prototype.reject=function(t){return this.filter(Hi(ni(t)))},Oe.prototype.slice=function(t,e){t=so(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Oe(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==k&&(r=(e=so(e))<0?r.dropRight(-e):r.take(e-t)),r)},Oe.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Oe.prototype.toArray=function(){return this.take(gt)},pr(Oe.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=x[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(x.prototype[e]=function(){var e=this.__wrapped__,a=n?[1]:arguments,s=e instanceof Oe,c=a[0],l=s||Ws(e),u=function(t){var e=i.apply(x,h([t],a));return n&&p?e[0]:e};l&&r&&"function"==typeof c&&1!=c.length&&(s=l=!1);var p=this.__chain__,f=!!this.__actions__.length,d=o&&!p,m=s&&!f;if(!o&&l){e=m?e:new Oe(this);var g=t.apply(e,a);return g.__actions__.push({func:Di,args:[u],thisArg:k}),new Ie(g,p)}return d&&m?t.apply(this,a):(g=this.thru(u),d?n?g.value()[0]:g.value():g)})}),o(["pop","push","shift","sort","splice","unshift"],function(t){var e=Uo[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);x.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Ws(i)?i:[],t)}return this[r](function(r){return e.apply(Ws(r)?r:[],t)})}}),pr(Oe.prototype,function(t,e){var r=x[e];if(r){var n=r.name+"";(Na[n]||(Na[n]=[])).push({name:e,func:r})}}),Na[Fn(k,K).name]=[{name:"wrapper",func:k}],Oe.prototype.clone=function(){var t=new Oe(this.__wrapped__);return t.__actions__=En(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=En(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=En(this.__views__),t},Oe.prototype.reverse=function(){if(this.__filtered__){var t=new Oe(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Oe.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Ws(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?k:this.__values__[this.__index__++]}},x.prototype.plant=function(t){for(var e,r=this;r instanceof Ne;){var n=Mi(r);n.__index__=0,n.__values__=k,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},x.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Oe){var e=t;return this.__actions__.length&&(e=new Oe(this)),(e=e.reverse()).__actions__.push({func:Di,args:[Ri],thisArg:k}),new Ie(e,this.__chain__)}return this.thru(Ri)},x.prototype.toJSON=x.prototype.valueOf=x.prototype.value=function(){return fn(this.__wrapped__,this.__actions__)},x.prototype.first=x.prototype.head,aa&&(x.prototype[aa]=function(){return this}),x}();"function"==typeof k&&"object"==typeof k.amd&&k.amd?(fr._=Pr,k(function(){return Pr})):mr?((mr.exports=Pr)._=Pr,dr._=Pr):fr._=Pr}).call(_l)});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*Sh.DEG2RAD},radToDeg:function(t){return t*Sh.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 Mh=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=Sh.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 Au:t.x=t.x-Math.floor(t.x);break;case Eu:t.x=t.x<0?0:1;break;case Cu: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 Au:t.y=t.y-Math.floor(t.y);break;case Eu:t.y=t.y<0?0:1;break;case Cu: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(Sh.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(u.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,c,l,u,h,p,f,d,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new u).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t=new l;return function(e){var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,this}}(),makeRotationFromEuler:function(t){!t||t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),c=Math.sin(n),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=p+f*c,e[5]=h-d*c,e[9]=-a*s,e[2]=d-h*c,e[6]=f+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=f*c-p,e[8]=h*c+d,e[1]=s*u,e[5]=d*c+h,e[9]=p*c-f,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-c*l,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=_*u+w,e[5]=o*l,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*l,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t._x,n=t._y,i=t._z,o=t._w,a=r+r,s=n+n,c=i+i,l=r*a,u=r*s,h=r*c,p=n*s,f=n*c,d=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(l+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(l+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new l,e=new l,r=new l;return function(n,i,o){var a=this.elements;return r.subVectors(n,i),0===r.lengthSq()&&(r.z=1),r.normalize(),t.crossVectors(o,r),0===t.lengthSq()&&(1===Math.abs(o.z)?r.x+=1e-4:r.z+=1e-4,r.normalize(),t.crossVectors(o,r)),t.normalize(),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],l=r[1],u=r[5],h=r[9],p=r[13],f=r[2],d=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],z=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*z,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*z,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*z,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*z,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute: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=Sh.euclideanModulo(e,1),r=Sh.clamp(r,0,1),n=Sh.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=Nh[t];void 0!==u&&this.setHex(u)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),c=Math.min(i,o,a),l=(c+s)/2;if(c===s)e=0,r=0;else{var u=s-c;switch(r=l<=.5?u/(s+c):u/(2-s-c),s){case i:e=(o-a)/u+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},zh={basic:{uniforms:Oh.merge([Ih.common,Ih.specularmap,Ih.envmap,Ih.aomap,Ih.lightmap,Ih.fog]),vertexShader:Dh.meshbasic_vert,fragmentShader:Dh.meshbasic_frag},lambert:{uniforms:Oh.merge([Ih.common,Ih.specularmap,Ih.envmap,Ih.aomap,Ih.lightmap,Ih.emissivemap,Ih.fog,Ih.lights,{emissive:{value:new X(0)}}]),vertexShader:Dh.meshlambert_vert,fragmentShader:Dh.meshlambert_frag},phong:{uniforms:Oh.merge([Ih.common,Ih.specularmap,Ih.envmap,Ih.aomap,Ih.lightmap,Ih.emissivemap,Ih.bumpmap,Ih.normalmap,Ih.displacementmap,Ih.gradientmap,Ih.fog,Ih.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30}}]),vertexShader:Dh.meshphong_vert,fragmentShader:Dh.meshphong_frag},standard:{uniforms:Oh.merge([Ih.common,Ih.envmap,Ih.aomap,Ih.lightmap,Ih.emissivemap,Ih.bumpmap,Ih.normalmap,Ih.displacementmap,Ih.roughnessmap,Ih.metalnessmap,Ih.fog,Ih.lights,{emissive:{value:new X(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Dh.meshphysical_vert,fragmentShader:Dh.meshphysical_frag},points:{uniforms:Oh.merge([Ih.points,Ih.fog]),vertexShader:Dh.points_vert,fragmentShader:Dh.points_frag},dashed:{uniforms:Oh.merge([Ih.common,Ih.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Dh.linedashed_vert,fragmentShader:Dh.linedashed_frag},depth:{uniforms:Oh.merge([Ih.common,Ih.displacementmap]),vertexShader:Dh.depth_vert,fragmentShader:Dh.depth_frag},normal:{uniforms:Oh.merge([Ih.common,Ih.bumpmap,Ih.normalmap,Ih.displacementmap,{opacity:{value:1}}]),vertexShader:Dh.normal_vert,fragmentShader:Dh.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Dh.cube_vert,fragmentShader:Dh.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Dh.equirect_vert,fragmentShader:Dh.equirect_frag},distanceRGBA:{uniforms:Oh.merge([Ih.common,Ih.displacementmap,{referencePosition:{value:new l},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Dh.distanceRGBA_vert,fragmentShader:Dh.distanceRGBA_frag},shadow:{uniforms:Oh.merge([Ih.lights,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:Dh.shadow_vert,fragmentShader:Dh.shadow_frag}};zh.physical={uniforms:Oh.merge([zh.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Dh.meshphysical_vert,fragmentShader:Dh.meshphysical_frag},Object.assign(Y.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new n).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new n).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new n;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),($.prototype=Object.create(i.prototype)).constructor=$;var Fh=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!==Dl&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==Tl&&(n.side=this.side),this.vertexColors!==Rl&&(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=Oh.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=Sh.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],c=i[1],l=i[5],u=i[9],h=i[2],p=i[6],f=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,l))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===e&&(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,l),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new u;return function(e,r,n){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new c;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new l(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(lt.prototype,{set:function(t){this.mask=1<1){for(var e=0;e1){for(var e=0;e0){o.children=[];for(s=0;s0&&(i.geometries=l),u.length>0&&(i.materials=u),h.length>0&&(i.textures=h),p.length>0&&(i.images=p)}return i.object=o,i},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;r0)for(m=0;m0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rt),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(t&&t.isGeometry){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,l=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new nt).getNormalMatrix(e));for(var f=0,d=a.length;f=0;r--){var d=p[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a0,x=v.vertexNormals.length>0,b=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,S=0;if(S=t(S,0,0),S=t(S,1,!0),S=t(S,2,!1),S=t(S,3,y),S=t(S,4,_),S=t(S,5,x),S=t(S,6,b),S=t(S,7,w),u.push(S),u.push(v.a,v.b,v.c),u.push(v.materialIndex),y){var M=this.faceVertexUvs[0][c];u.push(n(M[0]),n(M[1]),n(M[2]))}if(_&&u.push(e(v.normal)),x){var A=v.vertexNormals;u.push(e(A[0]),e(A[1]),e(A[2]))}if(b&&u.push(r(v.color)),w){var E=v.vertexColors;u.push(r(E[0]),r(E[1]),r(E[2]))}}return i.data={},i.data.vertices=s,i.data.normals=h,f.length>0&&(i.data.colors=f),m.length>0&&(i.data.uvs=[m]),i.data.faces=u,i},clone:function(){return(new gt).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e0,s=o[1]&&o[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(v=0;v0){u=[];for(v=0;v65535?Mt:wt)(t,1):this.index=t},addAttribute:function(t,e){if(e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute){if("index"!==t)return this.attributes[t]=e,this;this.setIndex(e)}else this.addAttribute(t,new vt(arguments[1],arguments[2]))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){(new nt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new u;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new u;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new u;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new u;return function(e,r,n){return t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t=new u;return function(e,r,n){return t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t=new ut;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new At(3*e.vertices.length,3),n=new At(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new At(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var n;return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Ct).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new vt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new vt(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new vt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new vt(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new vt(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Tt(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new vt(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var c=[],l=t.morphTargets[s],u=0,h=l.length;u0){var d=new At(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new At(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:function(){var t=new et,e=new l;return function(){null===this.boundingSphere&&(this.boundingSphere=new rt);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(n);for(var i=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Pt).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(r=0,n=l.length;r0)if(s=p*d-f,c=p*f-d,u=h*g,s>=0)if(c>=-u)if(c<=u){var v=1/g;l=(s*=v)*(s+p*(c*=v)+2*f)+c*(p*s+c+2*d)+m}else c=h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c=-h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c<=-u?l=-(s=Math.max(0,-(-p*h+f)))*s+(c=s>0?-h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m:c<=u?(s=0,l=(c=Math.min(Math.max(-h,-d),h))*(c+2*d)+m):l=-(s=Math.max(0,-(p*h+f)))*s+(c=s>0?h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m;else c=p>0?-h:h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),l}}(),intersectSphere:function(){var t=new l;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,c=n+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(r=(t.min.x-h.x)*c,n=(t.max.x-h.x)*c):(r=(t.max.x-h.x)*c,n=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,o=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,o=(t.min.y-h.y)*l),r>o||i>n?null:((i>r||r!=r)&&(r=i),(o=0?(a=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),r>s||a>n?null:((a>r||r!=r)&&(r=a),(s=0?r:n,e)))},intersectsBox:function(){var t=new l;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new l,e=new l,r=new l,n=new l;return function(i,o,a,s,c){e.subVectors(o,i),r.subVectors(a,i),n.crossVectors(e,r);var l,u=this.direction.dot(n);if(u>0){if(s)return null;l=1}else{if(!(u<0))return null;l=-1,u=-u}t.subVectors(this.origin,i);var h=l*this.direction.dot(r.crossVectors(t,r));if(h<0)return null;var p=l*this.direction.dot(e.cross(t));if(p<0)return null;if(h+p>u)return null;var f=-l*t.dot(n);return f<0?null:this.at(f/u,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(zt.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=Sh.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(Ft,{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=Ft.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Ft.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 Ft.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 Ft.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Ft.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new it,e=[new zt,new zt,new zt],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,Ft.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=F);for(var k=0,U=z.length;ko)){var a=n.ray.origin.distanceTo(t);an.far||i.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),le.prototype=Object.assign(Object.create(ut.prototype),{constructor:le,copy:function(t){ut.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa)){f.applyMatrix4(this.matrixWorld);(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else for(var y=0,_=g.length/3-1;y<_;y+=d){u.fromArray(g,3*y),h.fromArray(g,3*y+3);if(!((M=e.distanceSqToSegment(u,h,f,p))>a)){f.applyMatrix4(this.matrixWorld);(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}else if(s.isGeometry)for(var w=s.vertices,S=w.length,y=0;ya)){f.applyMatrix4(this.matrixWorld);var A=n.ray.origin.distanceTo(f);An.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),me.prototype=Object.assign(Object.create(de.prototype),{constructor:me,isLineSegments:!0}),ge.prototype=Object.assign(Object.create(de.prototype),{constructor:ge,isLineLoop:!0}),(ve.prototype=Object.create(K.prototype)).constructor=ve,ve.prototype.isPointsMaterial=!0,ve.prototype.copy=function(t){return K.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},ye.prototype=Object.assign(Object.create(ut.prototype),{constructor:ye,isPoints:!0,raycast:function(){var t=new u,e=new Dt,r=new rt;return function(n,i){function o(t,r){var o=e.distanceSqToPoint(t);if(on.far)return;i.push({distance:l,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=n.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),r.radius+=u,!1!==n.ray.intersectsSphere(r)){t.getInverse(c),e.copy(n.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),p=h*h,f=new l;if(s.isBufferGeometry){var d=s.index,m=s.attributes.position.array;if(null!==d)for(var g=d.array,v=0,y=g.length;v=-Number.EPSILON&&T>=-Number.EPSILON&&C>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],c=[],l=[];if(Vh.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=Vh.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var f=Math.sqrt(h),d=Math.sqrt(l*l+u*u),m=e.x-c/f,g=e.y+s/f,v=((r.x-u/d-m)*u-(r.y+l/d-g)*l)/(s*u-c*l),y=(i=m+s*v-t.x)*i+(o=g+c*v-t.y)*o;if(y<=2)return new n(i,o);a=Math.sqrt(y/2)}else{var _=!1;s>Number.EPSILON?l>Number.EPSILON&&(_=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(_=!0):Math.sign(c)===Math.sign(u)&&(_=!0),_?(i=-c,o=s,a=Math.sqrt(h)):(i=s,o=c,a=Math.sqrt(h/2))}return new n(i/a,o/a)}function o(t,e){var r,n;for($=t.length;--$>=0;){r=$,(n=$-1)<0&&(n=t.length-1);var i=0,o=C+2*M;for(i=0;i=0;B--){for(j=B/M,G=w*Math.cos(j*Math.PI/2),V=S*Math.sin(j*Math.PI/2),$=0,Z=U.length;$0||0===t.search(/^data\:image\/jpeg/);a.format=r?Yu:qu,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*Sh.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 Xh={arraySlice:function(t,e,r){return Xh.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==r?r:t.length)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,c=0;c!==e;++c)i[a++]=t[s+c];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};Object.assign(Ir.prototype,{evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var a=e[1];t=i)break e}o=r,r=0}}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=Xh.arraySlice(r,i,o),this.values=Xh.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&&Xh.isTypedArray(n))for(var a=0,c=n.length;a!==c;++a){var l=n[a];if(isNaN(l)){t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(var d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=Xh.arraySlice(t,0,i),this.values=Xh.arraySlice(e,0,i*r)),this}},kr.prototype=Object.assign(Object.create(Yh),{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(Yh),{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(Yh),{constructor:Vr,ValueTypeName:"number"}),jr.prototype=Object.assign(Object.create(Yh),{constructor:jr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Gr.prototype=Object.assign(Object.create(Yh),{constructor:Gr,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Wr.prototype=Object.assign(Object.create(Yh),{constructor:Wr,ValueTypeName:"color"}),Hr.prototype=Yh,Yh.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=[];Xh.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:Xh.convertArray(t.times,Array),values:Xh.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=[];Xh.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[n+1]:0,c=r>2?t.skinWeights[n+2]:0,l=r>3?t.skinWeights[n+3]:0;e.skinWeights.push(new o(a,s,c,l))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,p=r>2?t.skinIndices[n+2]:0,f=r>3?t.skinIndices[n+3]:0;e.skinIndices.push(new o(u,h,p,f))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||(e.skinIndices.length,e.vertices.length))}(t,r),function(t,e){var r=t.scale;if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0)for(var h=e.faces,p=t.morphColors[0].colors,n=0,i=h.length;n0&&(e.animations=r)}(t,r),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:r};return{geometry:r,materials:$r.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Kr.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new vr(i.manager).load(t,function(t){var r=null;try{r=JSON.parse(t)}catch(t){return void(void 0!==n&&n(t))}var o=r.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()&&i.parse(r,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new Zr,n=new qr,i=0,o=t.length;i0){var o=new xr(new gr(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new pe(s,c):new kt(s,c);break;case"LOD":a=new le;break;case"Line":a=new de(i(e.geometry),o(e.material),e.mode);break;case"LineLoop":a=new ge(i(e.geometry),o(e.material));break;case"LineSegments":a=new me(i(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new ye(i(e.geometry),o(e.material));break;case"Sprite":a=new ce(o(e.material));break;case"Group":a=new _e;break;default:a=new ut}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var l=e.children,u=0;u0)){c=i;break}c=i-1}if(i=c,n[i]===r)return i/(o-1);var l=n[i];return(i+(r-l)/(n[i+1]-l))/(o-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new l,a=[],s=[],c=[],h=new l,p=new u;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new l,c[0]=new l;var f=Number.MAX_VALUE,d=Math.abs(a[0].x),m=Math.abs(a[0].y),g=Math.abs(a[0].z);for(d<=f&&(f=d,o.set(1,0,0)),m<=f&&(f=m,o.set(0,1,0)),g<=f&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),c[r]=c[r-1].clone(),h.crossVectors(a[r-1],a[r]),h.length()>Number.EPSILON&&(h.normalize(),i=Math.acos(Sh.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(Sh.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 Qh=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=Qh,Qh.constructor=ln,un.prototype=Object.assign(Object.create(Qh),{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=Vh.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return r(o);var a,s,c,l=[];if(1===o.length)return s=o[0],c=new un,c.curves=s.curves,l.push(c),l;var u=!i(o[0].getPoints());u=t?!u:u;var h,p=[],f=[],d=[],m=0;f[m]=void 0,d[m]=[];for(var g=0,v=o.length;g1){for(var y=!1,_=[],x=0,b=f.length;x0&&(y||(d=p))}for(var C,g=0,T=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n){c.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}}),Object.assign(wn.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(Sn,{Composite:wn,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new Sn.Composite(t,e,r):new Sn(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),e=["material","materials","bones"];return function(r){var n=t.exec(r);if(!n)throw new Error("PropertyBinding: Cannot parse trackName: "+r);var i={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},o=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==o&&-1!==o){var a=i.nodeName.substring(o+1);-1!==e.indexOf(a)&&(i.nodeName=i.nodeName.substring(0,o),i.objectName=a)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+r);return i}}(),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=function(t){for(var r=0;r=r){var h=r++,p=e[h];n[p.uuid]=u,e[u]=p,n[l]=h,e[h]=c;for(var f=0,d=o;f!==d;++f){var m=i[f],g=m[h],v=m[u];m[u]=g,m[h]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,c=arguments.length;s!==c;++s){var l=arguments[s].uuid,u=i[l];if(void 0!==u)if(delete i[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(a),l[u].accumulate(n,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:uh:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:uh: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 np=new l,ip=new ni,op=new ni,ap=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]:(np.subVectors(e[0],e[1]).add(e[0]),a=np),s=e[i%r],c=e[(i+1)%r],this.closed||i+2=0;n--){var i=t[n];"."===i?t.splice( var target = document.getElementById('foo') var spinner = new Spinner(opts).spin(target) */ -!function(e,r){t.exports?t.exports=r():e.Spinner=r()}(Uu,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:Ki,forInRecursive:function(t,e){function r(t,n){Bu.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 Bu.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(Qi(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Qi(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"}},Ff.deriveClass(eo,Vi),eo.prototype.cancel=function(){this._cancellationRequested=!0,this.dispatchEvent("cancel")},eo.prototype.isCancellationRequested=function(){return this._cancellationRequested},eo.prototype.notify=function(t){this.dispatchEvent({type:"notification",slaveEvent:t})};var Uf={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:2,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},labels:"no",antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},theme:"dark",themes:{dark:2105376,light:13421772},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5,waterBondingHack:!1},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,ao:!1,autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,panning:!1,inversePanning:!1,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};ro.prototype={constructor:ro,defaults:Uf,set:function(t,e){Bu.set(this.now,t,e),this._changed[t]=!0},get:function(t,e){return Bu.get(this.now,t,e)},reset:function(){this.now=Bu.cloneDeep(Uf),this.old=null,this._changed={}},checkpoint:function(){this.old=Bu.cloneDeep(this.now),this._changed={}},undo:function(){this.now=Bu.cloneDeep(this.old),this._changed={}},changed:function(){if(!this.old)return[];var t=this.old,e=this.now;return Bu.filter(Object.keys(this._changed),function(r){return Bu.get(t,r)!==Bu.get(e,r)})},override:function(t){Bu.merge(this.now,t)},applyDiffs:function(t){if(t.hasOwnProperty("VERSION")&&0!==t.VERSION)throw new Error("Settings version does not match!");this.reset(),Bu.merge(this.now,t)},getDiffs:function(t){var e=Ff.objectsDiff(this.now,Uf);return t&&(e.VERSION=0),e},setPluginOpts:function(t,e){Uf.plugins[t]=Bu.cloneDeep(e),this.now.plugins[t]=Bu.cloneDeep(e)}};var Bf=new ro,Vf="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},jf=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Gf=function(){function t(t,e){for(var r=0;r0?Ff.deriveDeep(e.reps[Xf-1],!0):Ff.deriveDeep(Bf.defaults.presets.default[0],!0))},s:"select",select:function(t,e){so(e,"selector",t)},m:"mode",mode:function(t,e){so(e,"mode",uo(t,Bf.defaults.modes))},c:"color",color:function(t,e){so(e,"colorer",uo(t,Bf.defaults.colorers))},mt:"material",material:function(t,e){so(e,"material",uo(t,Bf.defaults.materials))},dup:function(t,e){ao(e);var r=e.reps,n=r[Xf];++Xf>=r.length&&(r[Xf]=Ff.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"},rd={fromURL:function(t){return ho(Ff.getUrlParameters(t))},fromAttr:function(t){return ho(Ff.getUrlParameters("?"+(t||"")))},adapters:Yf,toURL:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=io(t)+qf+io(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()},wo.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}},wo.prototype.getAtomBondsCount=function(){for(var t=this.getBonds(),e=0,r=0;r=t){r=e[n];break}return r},wo.prototype.getCharge=function(){return this._charge},wo.prototype.getLocation=function(){return this._location},wo.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 nd={UNKNOWN:0,COVALENT:1,AROMATIC:2};Ao.BondType=nd,Ao.prototype.BondType=nd,Ao.prototype.getLeft=function(){return this._left},Ao.prototype.getRight=function(){return this._right},Ao.prototype.getOrder=function(){return this._order},Ao.prototype.calcLength=function(){return this._left._position.distanceTo(this._right._position)},Ao.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)},Eo.prototype.getName=function(){return this._name},Eo.StandardTypes={ALA:new Eo("ALA","Alanine","A"),ARG:new Eo("ARG","Arginine","R"),ASN:new Eo("ASN","Asparagine","N"),ASP:new Eo("ASP","Aspartic Acid","D"),CYS:new Eo("CYS","Cysteine","C"),GLN:new Eo("GLN","Glutamine","Q"),GLU:new Eo("GLU","Glutamic Acid","E"),GLY:new Eo("GLY","Glycine","G"),HIS:new Eo("HIS","Histidine","H"),ILE:new Eo("ILE","Isoleucine","I"),LEU:new Eo("LEU","Leucine","L"),LYS:new Eo("LYS","Lysine","K"),MET:new Eo("MET","Methionine","M"),PHE:new Eo("PHE","Phenylalanine","F"),PRO:new Eo("PRO","Proline","P"),PYL:new Eo("PYL","Pyrrolysine","O"),SEC:new Eo("SEC","Selenocysteine","U"),SER:new Eo("SER","Serine","S"),THR:new Eo("THR","Threonine","T"),TRP:new Eo("TRP","Tryptophan","W"),TYR:new Eo("TYR","Tyrosine","Y"),VAL:new Eo("VAL","Valine","V"),A:new Eo("A","Adenine","A"),C:new Eo("C","Cytosine","C"),G:new Eo("G","Guanine","G"),I:new Eo("I","Inosine","I"),T:new Eo("T","Thymine","T"),U:new Eo("U","Uracil","U"),DA:new Eo("DA","Adenine","A"),DC:new Eo("DC","Cytosine","C"),DG:new Eo("DG","Guanine","G"),DI:new Eo("DI","Inosine","I"),DT:new Eo("DT","Thymine","T"),DU:new Eo("DU","Uracil","U"),"+A":new Eo("+A","Adenine","A"),"+C":new Eo("+C","Cytosine","C"),"+G":new Eo("+G","Guanine","G"),"+I":new Eo("+I","Inosine","I"),"+T":new Eo("+T","Thymine","T"),"+U":new Eo("+U","Uracil","U"),WAT:new Eo("WAT","Water",""),H2O:new Eo("H2O","Water",""),HOH:new Eo("HOH","Water",""),DOD:new Eo("DOD","Water",""),UNK:new Eo("UNK","Unknown",""),UNL:new Eo("UNL","Unknown Ligand","")},Eo.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 id=Eo.Flags;Co(id.WATER,["WAT","H2O","HOH","DOD"]),Co(id.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),Co(id.BASIC,["ARG","HIS","LYS"]),Co(id.ACIDIC,["ASP","GLU"]),Co(id.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),Co(id.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),Co(id.AROMATIC,["PHE","TRP","TYR"]),Co(id.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),Co(id.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),Co(id.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),Co(id.DNA,["DA","DG","DI","DC","DT","DU"]),Co(id.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},To.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&Eo.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)},To.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},To.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))},Po.prototype.updateToFrame=function(t){for(var e=this._residues,r=null,n=null,i=t._residues,o=e.length,a=0;a1?i[e[1]._index]._wingVector:new l(1,0,0)},Po.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new To(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(Eo.Flags.NUCLEIC|Eo.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},Po.prototype.getResidueCount=function(){return this._residues.length},Po.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 ud={},hd=Object.freeze({default:ud}),pd=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,fd=function(t){return pd.exec(t).slice(1)},dd={extname:jo,basename:Vo,dirname:Bo,sep:"/",delimiter:":",relative:Uo,join:ko,isAbsolute:Fo,normalize:zo,resolve:Do},md="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)},gd=Object.freeze({resolve:Do,normalize:zo,isAbsolute:Fo,join:ko,relative:Uo,sep:"/",delimiter:":",dirname:Bo,basename:Vo,extname:jo,default:dd}),vd=hd&&ud||hd,yd=gd&&dd||gd,_d=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){var e=this,r=[0],n=[],i=[null],o=[],a=this.table,s="",c=0,l=0,u=1,h=o.slice.call(arguments,1),p=Object.create(this.lexer),f={yy:{}};for(var d in this.yy)Object.prototype.hasOwnProperty.call(this.yy,d)&&(f.yy[d]=this.yy[d]);p.setInput(t,f.yy),f.yy.lexer=p,f.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;o.push(m);var g=p.options&&p.options.ranges;"function"==typeof f.yy.parseError?this.parseError=f.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var v,y,_,x,b,w,S,M,A,E={};;){if(_=r[r.length-1],this.defaultActions[_]?x=this.defaultActions[_]:(null!==v&&void 0!==v||(v=function(){var t;return"number"!=typeof(t=n.pop()||p.lex()||u)&&(t instanceof Array&&(t=(n=t).pop()),t=e.symbols_[t]||t),t}()),x=a[_]&&a[_][v]),void 0===x||!x.length||!x[0]){var C="";A=[];for(w in a[_])this.terminals_[w]&&w>2&&A.push("'"+this.terminals_[w]+"'");C=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(c+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(C,{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):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],E.$=i[i.length-S],E._$={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&&(E._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(E,[s,l,c,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(E.$),o.push(E._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);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];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;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=vd.readFileSync(yd.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),xd=_d.parser,bd=(_d.Parser,_d.parse,_d.main,{}),wd=function(){function t(e,r){jf(this,t),this.min=e,this.max=void 0===r?e:r}return Gf(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}(),Sd=function(){function t(e){if(jf(this,t),e instanceof this.constructor)return e;e instanceof Array?this._values=e.slice(0):this._values=e?[e]:[]}return Gf(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}();Nd.prototype.priority=1;var Id=function(t){function e(t,r){jf(this,e);var n=Hf(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||Rd,n.rhs=r||Rd,n}return Wf(e,Cd),Gf(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}();Id.prototype.priority=1e3,Xo("Not",1,function(t){function e(){return jf(this,e),Hf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Wf(e,Nd),Gf(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),Xo("And",2,function(t){function e(){return jf(this,e),Hf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Wf(e,Id),Gf(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),Xo("Or",3,function(t){function e(){return jf(this,e),Hf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Wf(e,Id),Gf(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var Od=Object.create(bd);Od.Selector=Cd,Od.RangeListSelector=Pd,Od.ValueListSelector=Ld,Od.Range=wd,Od.RangeList=Md,Od.ValueList=Ed,Od.PrefixOperator=Nd,Od.InfixOperator=Id,Od.Context=Object.create({}),Od.GetSelector=function(t){if(!Od.Context.hasOwnProperty(t))throw{message:"selector "+t+" is not registered"};return Od.Context[t]||Rd},Od.ClearContext=function(){Object.keys(Od.Context).forEach(function(t){delete Od.Context[t]})},Od.keyword=function(t){return bd[t.toLowerCase()]||bd.none},Od.parse=function(t){var e={};try{e.selector=xd.parse(t)}catch(t){e.selector=Rd,e.error=t.message}return e},xd.yy=Od,xd.yy.parseError=xd.parseError,Yo.prototype.constructor=Yo,Yo.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=Od.keyword("Chain")(this.chains):this._selector=Od.keyword("None")()},$o.prototype.id="__",Zo.prototype.getResidues=function(){return this._complex._residues},Zo.prototype.getResidueCount=function(){return this._residueCount},Zo.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&zd-1)*Dd,a=0;a=Dd)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*Fd,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};ra.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)}}}}}}}}},ra.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}}();ca.prototype.update=function(){for(var t=this.atoms,e=new l,r=t.length,n=0;ni[c]?++c:++s}return!1},fa.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=oa(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?la:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!l[o._index]&&!c._haveSameCycle(i,t,o)){var h=oa(o,e),p=h._position.clone().sub(e._position),f=h===s?-2:1-aa(a,p),d=p.cross(a);if(Vd(d,r)){for(var m=0;ms?1:0},da.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},da.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},da.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=bo.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},da.prototype._buildPartFormula=function(t){return t.owner instanceof da||t.owner instanceof Zo?this._buildFormulaSimple(t,null):t.owner instanceof Io?t.owner.buildChemicalFormula(this,t):""},da.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},da.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=bo.ByName.H.name,s=[r,!1],c=0;cbo.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{";return""},da.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()]&&Of.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 da||l.owner instanceof Zo?u.owner instanceof da||u.owner instanceof Zo?(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},da.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},da.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}},da.prototype._fillCmpEdit=function(){function t(){var t=new Zo(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},ma.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 ma(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])},_a.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=va(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=ya(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)}}},_a.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=Gp.radToDeg(2*Math.atan(Math.tan(.5*Gp.degToRad(t))/this.aspect))},mt.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*Gp.degToRad(e))},_t.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}(a*a+s*s);i.setXY(o,c*a,c*s)}return n},RCGroup:wa,fillArray:function(t,e,r,n){r=void 0!==r?r:0,n=void 0!==n?n:t.length;for(var i=r;i65535,s=i*e,c=this._index=Ff.allocateTyped(a?Uint32Array:Uint16Array,s);this._positions=Ff.allocateTyped(Float32Array,3*o),this._normals=Ff.allocateTyped(Float32Array,3*o),this._colors=Ff.allocateTyped(Float32Array,3*o);var l=this._alpha=Ff.allocateTyped(Float32Array,o);Bu.fill(l,1);for(var u=0;u65535;this._index=Ff.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=Ff.allocateTyped(Float32Array,4*e),this._colors=Ff.allocateTyped(Float32Array,3*e),this._directions=Ff.allocateTyped(Float32Array,3*e);var n=this._alpha=Ff.allocateTyped(Float32Array,e);Bu.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=Ff.allocateTyped(Float32Array,32*e),this.hasIntersection=Ff.allocateTyped(Int32Array,e),this.bitsInside=Ff.allocateTyped(Int32Array,e),0},is.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},is.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 Pm=[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];as.prototype.constructor=as,ss.prototype.constructor=ss,cs.prototype.constructor=cs,cs.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)},cs.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)},cs.prototype._polygonize=function(){for(var t=is.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)Pm[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))}},cs.prototype.toMesh=function(){var t=new Rt;return t.setIndex(new _t(this._indices,1)),t.addAttribute("position",new _t(this._position,3)),t.addAttribute("normal",new _t(this._normals,3)),t.addAttribute("color",new _t(this._colors,3)),t.computeBoundingSphere(),t},ls.prototype=Object.create(ns.prototype),ls.prototype.constructor=ls,ls.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)},ls.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}},ls.prototype._makeSurface=function(t,e){var r=new cs;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 _t(r._indices,1)),this.addAttribute("position",new _t(r._position,3)),this.addAttribute("normal",new _t(r._normals,3)),this.addAttribute("color",new _t(r._colors,3)))},ls.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 nt(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 Lm=jd.Volume;(us.prototype=Object.create(ls.prototype)).constructor=us,us.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new Lm(Float32Array,this.numVoxels,e),volTexMap:new Lm(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new Lm(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},us.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,c=this.numVoxels,l=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=c[0]-1,m=c[1]-1,g=c[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,U),W=y.getDirectIdx(N,V,U),H=N*h-a[A],X=N;X<=I;++X,H+=h,G+=x,W+=w){var Y=-(H*H+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var $=3*M;b[W]+=q*s[$],b[W+1]+=q*s[$+1],b[W+2]+=q*s[$+2]}}}},us.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]])},ms.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++}}),n=l*l+u*u+h*h,o>0&&(p=1/Math.sqrt(n),l*=p,u*=p,h*=p),r[v].x=l,r[v].y=u,r[v].z=h;return 0},ms.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,c=0,l=0,u=n,h=u*u,p=[],f=[],d=0,m=0;mh)){var m=t.radius+i._probeRadius;(c=u-m*m)<0&&(c=-c),l=1/(.8+c),p.push([t.colorX,t.colorY,t.colorZ]),f.push(l),d+=l}});for(var g=0;g=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var z=new q(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 F=this.complex.monomerTypeArray[h].color;c=F.r,l=F.g,u=F.b}1!==this.colorMode&&0!==this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),z.set(E,C,T),s[x]=new ds(z,L),s[x].colorX=c,s[x].colorY=l,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},vs.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var Nm=jd.Element;(ys.prototype=Object.create(ns.prototype)).constructor=ys,ys.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},ys.prototype._fromGeo=function(t){var e=null,r=Ff.allocateTyped(Float32Array,3*t._numVertices),n=Ff.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=Ff.allocateTyped(Float32Array,3*t._numVertices));var i,o=Ff.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},ys.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},ys.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}},ys.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))},ys.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},ys.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(Nm.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},ys.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];if(i.copy(t._vertices[u]),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 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},ys.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){for(var a,s,c,l=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*l,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,z=I*I+O*O+D*D;z0?(o[a]<0&&(o[a]=c),c>o[a]&&(o[a]=c)):c>o[a]&&(o[a]=c))}}return 0},ys.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 l,i=this.vBoxMax=new l;this.getBoundingBox(r,n,i);var o=this.marCubeResoultion=4*this.meshResolution,a=o,s=a*a*a,c=Ff.allocateTyped(Float32Array,s),u=this.meshResolution,h=4,p=this.atoms.length;p>=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 gs(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 is;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 vs(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 ms(m.length,m,n,i,w):this.voxelWorld=new ms(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 vs(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},(xs.prototype=Object.create(Vi.prototype)).constructor=xs,xs.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||_s(r,"label label-"+i);o.worldPos.copy(e),o.style.textAlign=n.horizontalAlign,o.style.verticalAlign=n.verticalAlign,this.items[t]=o},xs.prototype.setColor=function(t,e,r){this.items[t].opts={color:e,background:r}},xs.prototype.startUpdate=function(){return!0},xs.prototype.finishUpdate=function(){this.needsUpdate=!0,this.dispatchEvent({type:"update"})},xs.prototype.finalize=function(){this.finishUpdate()},xs.prototype.raycast=function(){},xs.prototype.setOpacity=function(){},xs.prototype.getSubset=function(){return[]};var Im={InstancedSpheresGeometry:Oa,SimpleSpheresGeometry:Fa,Simple2CCylindersGeometry:ka,Instanced2CCylinderGeometry:Ha,ExtrudedObjectsGeometry:Ya,ChunkedLinesGeometry:ts,TwoColorLinesGeometry:es,CrossGeometry:rs,QuickSurfGeometry:us,ContactSurfaceGeometry:fs,SSIsosurfaceGeometry:ys,LabelsGeometry:xs},Om=function(t){function e(){t.apply(this,arguments),this.onBeforeRender=e.prototype.onBeforeRender}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.onBeforeRender=function(t,e,r,n,i,o){this._onBeforeRender(t,e,r,n,i,o),this._update()},e.prototype._onBeforeRender=function(){},e.prototype._update=function(){var t=this.material;t&&t instanceof Sa&&t.updateUniforms()},e},Dm=Om(Bt);(bs.prototype=Object.create(Dm.prototype)).constructor=bs,bs.prototype._onBeforeRender=function(t,e,r,n,i,o){var a=this.material;a&&a.uniforms.invModelViewMatrix&&(this.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,this.matrixWorld),a.uniforms.invModelViewMatrix.value.getInverse(this.modelViewMatrix))};var zm=Om(Bt);(ws.prototype=Object.create(zm.prototype)).constructor=ws,ws.prototype._onBeforeRender=function(t,e,r){var n=this.geometry,i=this.material;if(n.zClip&&i.uberOptions){var o=(new u).multiplyMatrices(this.matrixWorld,r.matrixWorldInverse),a=(new l).setFromMatrixColumn(o,0).length(),s=(new l).copy(n.boundingSphere.center);this.localToWorld(s),i.uberOptions.zClipValue=r.position.z-s.z-a*(.5*n.boundingSphere.radius)}},(Ss.prototype=Object.create(Be.prototype)).constructor=Ss,Ss.prototype.init=function(){for(var t=this.children,e=t.length-1;e>=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)}},Bm={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()}},Vm=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(),Bm.hasOwnProperty(r)?Bm[r](t):"null"})};(Bs.prototype=Object.create(Os.prototype)).constructor=Bs,Bs.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},Bs.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;a>1)+"px"})}for(var l,u=0,h=(o.lines-1)*(1-o.direction)/2;u',r)}l.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(t,n){function o(){return i(r("group",{coordsize:u+" "+u,coordorigin:-l+" "+-l}),{width:u,height:u})}function s(t,s,c){e(p,e(i(o(),{rotation:360/n.lines*t+"deg",left:~~s}),e(i(r("roundrect",{arcsize:n.corners}),{width:l,height:n.scale*n.width,left:n.scale*n.radius,top:-n.scale*n.width>>1,filter:c}),r("fill",{color:a(n.color,t),opacity:n.opacity}),r("stroke",{opacity:0}))))}var c,l=n.scale*(n.length+n.width),u=2*n.scale*l,h=-(n.width+n.length)*n.scale*2+"px",p=i(o(),{position:"absolute",top:h,left:h});if(n.shadow)for(c=1;c<=n.lines;c++)s(c,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(c=1;c<=n.lines;c++)s(c);return e(t,p)},s.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n0)return"!"+r.join()}return""},objectsDiff:Si,forInRecursive:function(t,e){function r(t,n){xl.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 xl.isString(t)?'"'+t.replace(/"/g,'\\"')+'"':t},shotOpen:function(t){"undefined"!=typeof window&&window.open().document.write('')},shotDownload:function(t,e){if(t&&"data:"===t.substr(0,5))if(e||(e=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(Mi(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Mi(t)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(t,e,r,n){for(var i=0,o=r.length;ithis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=t),t},update:function(){this._startTime=this.end()},show:function(t){void 0===t&&(t=!0),this.domElement.style.display=t?"block":"none"}},gp.deriveClass(Ci,fi),Ci.prototype.cancel=function(){this._cancellationRequested=!0,this.dispatchEvent("cancel")},Ci.prototype.isCancellationRequested=function(){return this._cancellationRequested},Ci.prototype.notify=function(t){this.dispatchEvent({type:"notification",slaveEvent:t})};var yp={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:2,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},labels:"no",antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},theme:"dark",themes:{dark:2105376,light:13421772},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5,waterBondingHack:!1},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,ao:!1,autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,panning:!1,inversePanning:!1,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};Ti.prototype={constructor:Ti,defaults:yp,set:function(t,e){xl.set(this.now,t,e),this._changed[t]=!0},get:function(t,e){return xl.get(this.now,t,e)},reset:function(){this.now=xl.cloneDeep(yp),this.old=null,this._changed={}},checkpoint:function(){this.old=xl.cloneDeep(this.now),this._changed={}},undo:function(){this.now=xl.cloneDeep(this.old),this._changed={}},changed:function(){if(!this.old)return[];var t=this.old,e=this.now;return xl.filter(Object.keys(this._changed),function(r){return xl.get(t,r)!==xl.get(e,r)})},override:function(t){xl.merge(this.now,t)},applyDiffs:function(t){if(t.hasOwnProperty("VERSION")&&0!==t.VERSION)throw new Error("Settings version does not match!");this.reset(),xl.merge(this.now,t)},getDiffs:function(t){var e=gp.objectsDiff(this.now,yp);return t&&(e.VERSION=0),e},setPluginOpts:function(t,e){yp.plugins[t]=xl.cloneDeep(e),this.now.plugins[t]=xl.cloneDeep(e)}};var _p=new Ti,xp="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},bp=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},wp=function(){function t(t,e){for(var r=0;r0?gp.deriveDeep(e.reps[Ap-1],!0):gp.deriveDeep(_p.defaults.presets.default[0],!0))},s:"select",select:function(t,e){Ii(e,"selector",t)},m:"mode",mode:function(t,e){Ii(e,"mode",Oi(t,_p.defaults.modes))},c:"color",color:function(t,e){Ii(e,"colorer",Oi(t,_p.defaults.colorers))},mt:"material",material:function(t,e){Ii(e,"material",Oi(t,_p.defaults.materials))},dup:function(t,e){Ni(e);var r=e.reps,n=r[Ap];++Ap>=r.length&&(r[Ap]=gp.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"},Dp={fromURL:function(t){return Di(gp.getUrlParameters(t))},fromAttr:function(t){return Di(gp.getUrlParameters("?"+(t||"")))},adapters:Ep,toURL:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=Li(t)+Cp+Li(e))}var r=[],n=0;e("l",t.load),e("u",t.unit),e("p",t.preset),function(t){if(t)for(var r=0,n=t.length;r0&&(i+="?"+r.join("&")),i},toScript:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=t+" "+e)}var r=[],n=0;return e("set","autobuild false"),e("load",t.load),e("unit",t.unit),e("preset",t.preset),function(t){if(t)for(var r=0,n=t.length;r0?t.getString():this.element.name.trim()},Hi.prototype.forEachBond=function(t){for(var e=this._bonds,r=0,n=e.length;r=0)return this._hydrogenCount;var t=this.element,e=t.hydrogenValency;if(1===e.length&&0===e[0])return 0;switch(t.number){case 1:return this.getHydrogenCountHydrogen();case 3:case 11:case 19:case 37:case 55:case 87:case 4:case 12:case 20:case 38:case 56:case 88:case 13:case 31:case 49:case 41:case 82:case 83:return this.getHydrogenCountMetal();case 6:case 14:case 32:case 51:return this.getHydrogenCountGroup14();case 50:return this.getHydrogenCountTin();case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 53:case 85:return this.getHydrogenCountNonMetal();case 5:return this.getHydrogenCountBoron();default:return 0}},Hi.prototype.getAtomBondsCount=function(){for(var t=this.getBonds(),e=0,r=0;r=t){r=e[n];break}return r},Hi.prototype.getCharge=function(){return this._charge},Hi.prototype.getLocation=function(){return this._location},Hi.prototype.getFullName=function(){var t="";return null!==this._residue&&(null!==this._residue._chain&&(t+=this._residue._chain.getName()+"."),t+=this._residue._sequence+"."),t+=this._name.getString()};var zp={UNKNOWN:0,COVALENT:1,AROMATIC:2};Yi.BondType=zp,Yi.prototype.BondType=zp,Yi.prototype.getLeft=function(){return this._left},Yi.prototype.getRight=function(){return this._right},Yi.prototype.getOrder=function(){return this._order},Yi.prototype.calcLength=function(){return this._left._position.distanceTo(this._right._position)},Yi.prototype._forEachNeighbour=function(t,e){for(var r=t._bonds,n=0,i=r.length;n0?++o:++a}function i(t){"C"===t.element.name&&n(t)}for(var o=0,a=0,s=t.clone(),c=[[this.forEachLevelOne,i],[this.forEachLevelOne,n],[this.forEachLevelTwo,i],[this.forEachLevelTwo,n]],l=0;lo)return e.multiplyScalar(-1);if(ar._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,c=0,l=s.length;ca&&u!==n&&(o=u,a=u._bonds.length)}var h=t(i),p=t(n).clone().sub(h),f=t(o).clone().sub(h);return f.crossVectors(p,f),f.lengthSq()<1e-4&&f.set(0,1,0),p.normalize(),f.normalize(),p.crossVectors(f,p),p.lengthSq()<1e-4&&p.set(0,1,0),p.normalize(),this._fixDir(h,p,t)},qi.prototype.getName=function(){return this._name},qi.StandardTypes={ALA:new qi("ALA","Alanine","A"),ARG:new qi("ARG","Arginine","R"),ASN:new qi("ASN","Asparagine","N"),ASP:new qi("ASP","Aspartic Acid","D"),CYS:new qi("CYS","Cysteine","C"),GLN:new qi("GLN","Glutamine","Q"),GLU:new qi("GLU","Glutamic Acid","E"),GLY:new qi("GLY","Glycine","G"),HIS:new qi("HIS","Histidine","H"),ILE:new qi("ILE","Isoleucine","I"),LEU:new qi("LEU","Leucine","L"),LYS:new qi("LYS","Lysine","K"),MET:new qi("MET","Methionine","M"),PHE:new qi("PHE","Phenylalanine","F"),PRO:new qi("PRO","Proline","P"),PYL:new qi("PYL","Pyrrolysine","O"),SEC:new qi("SEC","Selenocysteine","U"),SER:new qi("SER","Serine","S"),THR:new qi("THR","Threonine","T"),TRP:new qi("TRP","Tryptophan","W"),TYR:new qi("TYR","Tyrosine","Y"),VAL:new qi("VAL","Valine","V"),A:new qi("A","Adenine","A"),C:new qi("C","Cytosine","C"),G:new qi("G","Guanine","G"),I:new qi("I","Inosine","I"),T:new qi("T","Thymine","T"),U:new qi("U","Uracil","U"),DA:new qi("DA","Adenine","A"),DC:new qi("DC","Cytosine","C"),DG:new qi("DG","Guanine","G"),DI:new qi("DI","Inosine","I"),DT:new qi("DT","Thymine","T"),DU:new qi("DU","Uracil","U"),"+A":new qi("+A","Adenine","A"),"+C":new qi("+C","Cytosine","C"),"+G":new qi("+G","Guanine","G"),"+I":new qi("+I","Inosine","I"),"+T":new qi("+T","Thymine","T"),"+U":new qi("+U","Uracil","U"),WAT:new qi("WAT","Water",""),H2O:new qi("H2O","Water",""),HOH:new qi("HOH","Water",""),DOD:new qi("DOD","Water",""),UNK:new qi("UNK","Unknown",""),UNL:new qi("UNL","Unknown Ligand","")};var Fp=qi.Flags={PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536};$i(Fp.WATER,["WAT","H2O","HOH","DOD"]),$i(Fp.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),$i(Fp.BASIC,["ARG","HIS","LYS"]),$i(Fp.ACIDIC,["ASP","GLU"]),$i(Fp.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),$i(Fp.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),$i(Fp.AROMATIC,["PHE","TRP","TYR"]),$i(Fp.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),$i(Fp.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),$i(Fp.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),$i(Fp.DNA,["DA","DG","DI","DC","DT","DU"]),$i(Fp.RNA,["A","G","I","C","T","U"]);!function(t,e){for(var r=Object.keys(e),n=0,i=r.length;nMath.PI/2&&o.negate(),o},Zi.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new l(a.x,a.y,a.z);if(0==(this._type.flags&qi.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var c=e._controlPoint;n._midPoint=c.clone().lerp(s,.5),n._wingVector=this.calcWing(c,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},Zi.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},Zi.prototype.isConnected=function(t){if(this._chain!==t._chain)return!1;if(this===t)return!0;var e=!1;return this.forEachAtom(function(r){for(var n=r._bonds,i=0,o=n.length;i1){var a=t[1]._wingVector;t[0]._wingVector=new l(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new l(1,0,0))},Ki.prototype.updateToFrame=function(t){function e(e){return t.getAtomPos(e._index)}for(var r=this._residues,n=null,i=null,o=t._residues,a=r.length,s=0;s1?o[r[1]._index]._wingVector:new l(1,0,0)},Ki.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new Zi(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(qi.Flags.NUCLEIC|qi.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},Ki.prototype.getResidueCount=function(){return this._residues.length},Ki.prototype.forEachResidue=function(t){for(var e=this._residues,r=0,n=e.length;r1?i=n>1?this._repeat.toString()+"("+i+")":this._repeat.toString()+i:n>1&&(i="("+i+")"),o>1&&(i+="^"+o.toString()+"+"),1===o&&(i+="^+"),o<-1&&(i+="^"+Math.abs(o).toString()+"-"),-1===o&&(i+="^-")):this._repeat>1&&(i=this._repeat.toString()+i),i};var Gp={},Wp=Object.freeze({default:Gp}),Hp=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Xp=function(t){return Hp.exec(t).slice(1)},Yp={extname:uo,basename:lo,dirname:co,sep:"/",delimiter:":",relative:so,join:ao,isAbsolute:oo,normalize:io,resolve:no},qp="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)},$p=Object.freeze({resolve:no,normalize:io,isAbsolute:oo,join:ao,relative:so,sep:"/",delimiter:":",dirname:co,basename:lo,extname:uo,default:Yp}),Zp=Wp&&Gp||Wp,Kp=$p&&Yp||$p,Qp=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=Zp.readFileSync(Kp.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),Jp=Qp.parser,tf=(Qp.Parser,Qp.parse,Qp.main,{}),ef=function(){function t(e,r){bp(this,t),this.min=e,this.max=void 0===r?e:r}return wp(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}(),rf=function(){function t(e){if(bp(this,t),e instanceof this.constructor)return e;e instanceof Array?this._values=e.slice(0):this._values=e?[e]:[]}return wp(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}();pf.prototype.priority=1;var ff=function(t){function e(t,r){bp(this,e);var n=Mp(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||hf,n.rhs=r||hf,n}return Sp(e,sf),wp(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}();ff.prototype.priority=1e3,mo("Not",1,function(t){function e(){return bp(this,e),Mp(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sp(e,pf),wp(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),mo("And",2,function(t){function e(){return bp(this,e),Mp(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sp(e,ff),wp(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),mo("Or",3,function(t){function e(){return bp(this,e),Mp(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sp(e,ff),wp(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var df=Object.create(tf);df.Selector=sf,df.RangeListSelector=lf,df.ValueListSelector=uf,df.Range=ef,df.RangeList=nf,df.ValueList=af,df.PrefixOperator=pf,df.InfixOperator=ff,df.Context=Object.create({}),df.GetSelector=function(t){if(!df.Context.hasOwnProperty(t)){throw{message:"selector "+t+" is not registered"}}return df.Context[t]||hf},df.ClearContext=function(){Object.keys(df.Context).forEach(function(t){delete df.Context[t]})},df.keyword=function(t){return tf[t.toLowerCase()]||tf.none},df.parse=function(t){var e={};try{e.selector=Jp.parse(t)}catch(t){e.selector=hf,e.error=t.message}return e},Jp.yy=df,Jp.yy.parseError=Jp.parseError,go.prototype.constructor=go,go.prototype.computeBoundaries=function(){var t,e=this._complex._atoms,r=e.length,n=this._selector,i=this._boundaries.boundingBox;if(i.makeEmpty(),1===r){i.expandByPoint(e[0]._position);var o=i.getCenter(),a=2*e[0].element.radius;i.setFromCenterAndSize(o,new l(a,a,a))}else for(t=0;t0?this._selector=df.keyword("Chain")(this.chains):this._selector=df.keyword("None")()},yo.prototype.id="__",_o.prototype.getResidues=function(){return this._complex._residues},_o.prototype.getResidueCount=function(){return this._residueCount},_o.prototype.forEachResidue=function(t){for(var e=this._complex._residues,r=this._residueIndices,n=0,i=r.length;ne?t:e,i=r+(n<<14),o=(r+89237*n&gf-1)*mf,a=0;a=mf)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*vf,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};So.prototype._addExistingPairs=function(){for(var t=this._complex.getAtoms(),e=t.length,r=0,n=this._pairCollection;r=a))for(var b=-1;b<=1;++b){var w=v+b;if(!(w<0||w>=o))for(var S=-1;S<=1;++S){var M=g+S;if(!(M<0||M>=i))for(var A=t[x*c+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},So.prototype._addPairs=function(){for(var t=this._complex._atoms,e=0,r=0;e125e3);this.xB=t,this.yB=e,this.zB=r,this.invPairDist=i;for(var f=[],d=0;d.1)&&t.dot(e)>=0}}();Co.prototype.update=function(){for(var t=this.atoms,e=new l,r=t.length,n=0;ni[c]?++c:++s}return!1},No.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Ao(t,e),a=e._position.clone().sub(o._position),s=this._currStart,c=this,l=this._bondMarks,u=this._checkBond;l[t._index]=!0,u=void 0===u?To:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!l[o._index]&&!c._haveSameCycle(i,t,o)){var h=Ao(o,e),p=h._position.clone().sub(e._position),f=h===s?-2:1-function(t,e){var r=t.dot(e)/Math.sqrt(t.lengthSq()*e.lengthSq());return Sh.clamp(r,-1,1)}(a,p),d=p.cross(a);if(bf(d,r)){for(var m=0;ms?1:0},Io.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},Io.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},Io.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=Wi.ByName.H.name,c=0;r.forEach(function(t){var e=t.getHydrogenCount();n=t.element,i[n.name]?i[n.name]+=1:i[n.name]=1,e>0&&(i[s]?i[s]+=e:i[s]=e),c+=t.getCharge()});var l=Object.keys(i);return i.C?l.sort(this._atomNameCompareCWithH.bind(this)):l.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),l.forEach(function(t){var e=t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase();i[t]>1?o+=e+i[t].toString():o+=e}),null===e?(0!==c&&(l.length>1&&(o="("+o+")"),c>1&&(o+="^{"+c.toString()+"+}"),1===c&&(o+="^+"),c<-1&&(o+="^{"+Math.abs(c).toString()+"-}"),-1===c&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(l.length,c),o},Io.prototype._buildPartFormula=function(t){return t.owner instanceof Io||t.owner instanceof _o?this._buildFormulaSimple(t,null):t.owner instanceof eo?t.owner.buildChemicalFormula(this,t):""},Io.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},Io.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[a]?r[a]+=n:r[a]=n)}});var n=Object.keys(r);return n.sort(o._atomNameCompareCWithoutH.bind(o)),{seq:n,data:r}}for(var i,o=this,a=Wi.ByName.H.name,s=[r,!1],c=0;cWi.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{"}return""},Io.prototype.buildChemicalFormula=function(){var t=[],e=null,r=null,n={},i=null,o=this,a=this._checkFormulaBuildable();if(""!==a)return a;this.forEachAtom(function(t){n[t.getSerial()]&&fp.warn("Broken complex. Formula can be invalid..."),n[t.getSerial()]={atom:t,taken:null}}),this.forEachSGroup(function(o){0===o._charge&&1===o._repeat||(r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)}),e.atoms.length>0&&t.push(e),e=null)}),this.forEachComponent(function(o){r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o.forEachResidue(function(t){t._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)})}),e.atoms.length>0&&t.push(e),e=null});Object.keys(n).forEach(function(t){null===t.taken&&(null===e&&(e={owner:o,atoms:[],repeatCount:1}),e.atoms.push(t.atom),t.taken=o)}),null!==e&&e.atoms.length>0&&t.push(e),t.sort(function(t,e){return o._partCompareFunc(t,e)});for(var s=t.length-1,c=t.length-2;s>=0&&c>=0;){var l=t[s],u=t[c];l.owner instanceof Io||l.owner instanceof _o?u.owner instanceof Io||u.owner instanceof _o?(0===this._partCompareFuncInt(u,l,!1)&&(u.repeatCount+=l.repeatCount,t.splice(s,1)),c--,s--):c--:--s===c&&c--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},Io.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},Io.prototype.splitUnifiedSerial=function(t){var e=Math.floor(t/16777216),r=t-16777216*e,n=Math.floor(r/65536);return{chain:e,serial:r-65536*n,iCode:n}},Io.prototype._fillCmpEdit=function(){function t(){var t=new _o(e);return t._index=r.length,r[t._index]=t,t}var e=this,r=this._components;this.forEachChain(function(e){var r=e._residues,n=r.length;if(!(n<1))for(var i=t(),o=r[0]._index,a=0;a=0&&t=0;e--){var i=n[e];null===i._left||null===i._right?n.splice(e,1):(i._left._bonds.push(i),i._right._bonds.push(i))}var o=this._residues;for(e=0,r=o.length;e1?t.x/(this._dimX-1):0,e.y=this._dimY>1?t.y/(this._dimY-1):0,e.z=this._dimZ>1?t.z/(this._dimZ-1):0,e},Oo.prototype.computeGradient=function(){function t(t,e,r){return Math.min(r,Math.max(e,t))}function e(t,e,r){return c[r*o*a+e*o+t]}if(1!==this._dimVec)return null;for(var r=new Oo(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),n=this.getCellSize(),i=new l(-.5/n.x,-.5/n.y,-.5/n.z),o=this._dimX,a=this._dimY,s=this._dimZ,c=this._data,u=0;u=0;r=this._atoms[r+1])e(this._atoms[r])},ko.prototype._forEachVoxelWithinRadius=function(t,e,r){var i,o,a,s,c,l,u,h,p=new n,f=new n,d=new n;d.set(t.z-e,t.z+e),d.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=d.x;m<=d.y;++m){c=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],h=t.z-e<=c[0]&&c[1]<=t.z+e,i=zo(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=Fo(t,i[1],s[0],s[1]),p.set(t.x-o[1],t.x+o[1]),p.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var v=p.x;v<=p.y;++v)a=[this._box.min.x+v*this._cellSize.x,this._box.min.x+(v+1)*this._cellSize.x],l=t.x-o[0]<=a[0]&&a[1]<=t.x+o[0],r(v+this._count.x*(g+this._count.y*m),l&&u&&h)}}},ko.prototype.forEachAtomWithinRadius=function(t,e,r){var n=this,i=e*e;n._forEachVoxelWithinRadius(t,e,function(e,o){o?n._forEachAtomInVoxel(e,r):n._forEachAtomInVoxel(e,function(e){t.distanceToSquared(e._position)=0;s=a[s+1])if(t._position.distanceToSquared(a[s]._position)=1?this.fov=t:this.fov=Sh.radToDeg(2*Math.atan(Math.tan(.5*Sh.degToRad(t))/this.aspect))},ft.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*Sh.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=gp.allocateTyped(a?Uint32Array:Uint16Array,s);this._positions=gp.allocateTyped(Float32Array,3*o),this._normals=gp.allocateTyped(Float32Array,3*o),this._colors=gp.allocateTyped(Float32Array,3*o);var l=this._alpha=gp.allocateTyped(Float32Array,o);xl.fill(l,1);for(var u=0;u65535;this._index=gp.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=gp.allocateTyped(Float32Array,4*e),this._colors=gp.allocateTyped(Float32Array,3*e),this._directions=gp.allocateTyped(Float32Array,3*e);var n=this._alpha=gp.allocateTyped(Float32Array,e);xl.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=gp.allocateTyped(Float32Array,32*e),this.hasIntersection=gp.allocateTyped(Int32Array,e),this.bitsInside=gp.allocateTyped(Int32Array,e),0},ga.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},ga.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var ld=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0];ya.prototype.constructor=ya,_a.prototype.constructor=_a,xa.prototype.constructor=xa,xa.prototype._prepareAxesAndDirs=function(){var t=this._volumetricData.getCellSize(),e=this._xAxis,r=this._yAxis,n=this._zAxis,i=this._xDir,o=this._yDir,a=this._zDir;e.set(t.x,0,0),r.set(0,t.y,0),n.set(0,0,t.z),i.set(1,0,0),o.set(0,1,0),a.set(0,0,1);var s=new l;return s.crossVectors(i,o),s.dot(a)<0&&(i.negate(),o.negate(),a.negate()),!(i.x<0||i.y<0||i.z<0||o.x<0||o.y<0||o.z<0||a.x<0||a.y<0||a.z<0)&&!(0!==e.y||0!==e.z||0!==r.x||0!==r.z||0!==n.x||0!==n.y)},xa.prototype._vertexInterp=function(t,e,r,n,i,o){var a=e.p[r],s=e.p[n],c=e.g[r],l=e.g[n],u=e.val[r],h=t-u,p=e.val[n]-u,f=0;Math.abs(p)>0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(c,l,f)},xa.prototype._polygonize=function(){for(var t=ga.prototype.striIndicesMarchCube,e=[0,1,2,3,4,5,6,7,0,1,2,3],r=[1,2,3,0,5,6,7,4,4,5,6,7],n=new Array(12),i=new Array(12),o=0;o<12;++o)n[o]=new l,i[o]=new l;return function(a,s,c){var l=a.cubeIndex;for(o=0;o<12;++o)ld[l]&1<s?s:l+e,h=-1,p=l;pV&&(j=G,V=C[G]);if(j<0||!n.includesAtom(E[j])){P[a]=-1;continue}}P[a]=L++;var W=D=0&&nt>=0&&it>=0&&(this._indices[3*et]=rt,this._indices[3*et+1]=nt,this._indices[3*et+2]=it,++et)}this._position=new Float32Array(this._position.buffer.slice(0,3*L*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*L*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*L*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*et*4))}},xa.prototype.toMesh=function(){var t=new Pt;return t.setIndex(new vt(this._indices,1)),t.addAttribute("position",new vt(this._position,3)),t.addAttribute("normal",new vt(this._normals,3)),t.addAttribute("color",new vt(this._colors,3)),t.computeBoundingSphere(),t},(ba.prototype=Object.create(ma.prototype)).constructor=ba,ba.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new l(1,0,0),this.yAxis=new l(0,1,0),this.zAxis=new l(0,0,1),this.origin=new l(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},ba.prototype._findMinMax=function(t){for(var e=t.length/4,r=[t[0],t[1],t[2],t[3]],n=[t[0],t[1],t[2],t[3]],i=1;i4&&(e.gridSpacing*=i[3]);var a=e.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var c=0;c<3;++c)i[c]-=a,o[c]+=a;for(c=0;c<3;++c)r[c]=Math.ceil((o[c]-i[c])/e.gridSpacing);return this.xAxis.x=(r[0]-1)*e.gridSpacing,this.yAxis.y=(r[1]-1)*e.gridSpacing,this.zAxis.z=(r[2]-1)*e.gridSpacing,this.origin.x=i[0],this.origin.y=i[1],this.origin.z=i[2],{bbox:n,dim:r}},ba.prototype._makeSurface=function(t,e){var r=new xa;r.compute(t.volMap,this.origin,e.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0&&(r.setColorVolTex(t.volTexMap,t.atomMap,t.atomWeightMap,this._visibilitySelector),this.setIndex(new vt(r._indices,1)),this.addAttribute("position",new vt(r._position,3)),this.addAttribute("normal",new vt(r._normals,3)),this.addAttribute("color",new vt(r._colors,3)))},ba.prototype._calcSurface=function(t){var e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==e.posRad.length){var r=this._findNumVoxels(e.posRad,t),n=new et(this.origin,new l(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var ud=wf.Volume;(wa.prototype=Object.create(ba.prototype)).constructor=wa,wa.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new ud(Float32Array,this.numVoxels,e),volTexMap:new ud(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new ud(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},wa.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,c=this.numVoxels,l=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=c[0]-1,m=c[1]-1,g=c[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,U),W=y.getDirectIdx(N,V,U),H=N*h-a[A],X=N;X<=I;++X,H+=h,G+=x,W+=w){var Y=-(H*H+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var $=3*M;b[W]+=q*s[$],b[W+1]+=q*s[$+1],b[W+2]+=q*s[$+2]}}}},wa.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;ol?e:l,u+=e;var h=Math.floor(s/l);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=l;var p=h,f=h*h,d=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),g=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),v=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),y=0,_=m*h,x=g*h,b=v*h;for(c=0;c=0?C:0,T=T>=0?T:0,P=P>=0?P:0,L=L=0;s=this._atomsList[2*s+1]){e(a[this._atomsList[2*s]])}},Ea.prototype.getClosestAtom=function(t){var e=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(t,function(n){var i=t.distanceToSquared(n.coord);im)){var v=t.radius+i._probeRadius;(p=n-v*v)<0&&(p=-p),f=Math.exp(g*p),l+=e*f,u+=r*f,h+=d*f,o++}},y=0;y0&&(p=1/Math.sqrt(n),l*=p,u*=p,h*=p),r[y].x=l,r[y].y=u,r[y].z=h;return 0},Ea.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,c=0,l=0,u=n*n,h=[],p=[],f=0,d=function(t){var e=o-t.coord.x,r=a-t.coord.y,n=s-t.coord.z,d=e*e+r*r+n*n;if(!(d>u)){var m=t.radius+i._probeRadius;(c=d-m*m)<0&&(c=-c),l=1/(.8+c),h.push([t.colorX,t.colorY,t.colorZ]),p.push(l),f+=l}},m=0;m=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var z=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 F=this.complex.monomerTypeArray[h].color;c=F.r,l=F.g,u=F.b}1!==this.colorMode&&0!==this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),z.set(E,C,T),s[x]=new Aa(z,L),s[x].colorX=c,s[x].colorY=l,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Ta.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var pd=wf.Element;(Pa.prototype=Object.create(ma.prototype)).constructor=Pa,Pa.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},Pa.prototype._fromGeo=function(t){var e=null,r=gp.allocateTyped(Float32Array,3*t._numVertices),n=gp.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=gp.allocateTyped(Float32Array,3*t._numVertices));var i,o=gp.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?c:i,s.x-cr.x&&(r.x=s.x+c),s.y+c>r.y&&(r.y=s.y+c),s.z+c>r.z&&(r.z=s.z+c)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},Pa.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),c=r*s,l=n*s,u=i*s;a.x=t.x*(1-c)+e.x*c,a.y=t.y*(1-l)+e.y*l,a.z=t.z*(1-u)+e.z*u},Pa.prototype.buildEdgePoint=function(t,e,r,n,i,o){if(r[t]^r[e]){var a=(0-n.pointsValuesLinear[i+24+t])/(n.pointsValuesLinear[i+24+e]-n.pointsValuesLinear[i+24+t]),s=n.pointsValuesLinear[i+3*t+0],c=n.pointsValuesLinear[i+3*t+1],l=n.pointsValuesLinear[i+3*t+2],u=n.pointsValuesLinear[i+3*e+0],h=n.pointsValuesLinear[i+3*e+1],p=n.pointsValuesLinear[i+3*e+2];o.x=s*(1-a)+u*a,o.y=c*(1-a)+h*a,o.z=l*(1-a)+p*a}},Pa.prototype.isTriangleVisible=function(t,e,r){var n=this.voxelWorld.getClosestAtom(t),i=this.voxelWorld.getClosestAtom(e),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&(this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom))},Pa.prototype.addTriangle=function(t,e,r){if(this.visibilitySelector&&!this.isTriangleVisible(t,e,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,t),o=this.addVertexToGeo(n,e),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0},Pa.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,c=t-1,u=t,h=t*t,p=new Array(12);for(a=0;a<12;a++)p[a]=new l;var f=[];for(a=0;a<8;a++)f[a]=1;for(var d=new l,m=0,g=0,v=0;ve.length/2||2*Object.keys(pd.ByAtomicNumber).length!==e.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return e[2*t]},Pa.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,c=new l,u=new l,h=0;h=0;r=this.hashEntries[2*r+1]){var u=this.hashEntries[2*r+0];i.copy(t._vertices[u]),i.x-=e.x,i.y-=e.y,i.z-=e.z;if(i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return u}if(t._numVertices>=this.maxNumVertices)return-1;var h=t._numVertices;if(t._vertices[h].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var p=this.hashLines[c+1];this.hashLines[c+1]=r,this.hashEntries[2*r+0]=h,this.hashEntries[2*r+1]=p,this.hashLines[c+0]++}return t._numVertices++,h},Pa.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){function a(){l>0?(o[s]<0&&(o[s]=l),l>o[s]&&(o[s]=l)):l>o[s]&&(o[s]=l)}for(var s,c,l,u=t*t,h=(t-1)/(n.x-r.x),p=(t-1)/(n.y-r.y),f=(t-1)/(n.z-r.z),d=2*e*(2*e),m=1/(t-1),g=0;g=0?_:0,x=x>=0?x:0,b=b>=0?b:0,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1,M=M<=t-1?M:t-1;for(var A=x;A<=S;A++)for(var E=A*u,C=b;C<=M;C++)for(var T=C*t,P=_;P<=w;P++){s=E+T+P;var L=P*m,R=r.x*(1-L)+n.x*L;L=A*m;var N=r.y*(1-L)+n.y*L;L=C*m;var I=r.z*(1-L)+n.z*L,O=R-v.x,D=N-v.y,z=I-v.z,F=O*O+D*D+z*z;F=100&&(h=Math.floor(Math.pow(2*p,1/3))),u>h&&(u=h);var f=this.probeRadius*this.atomRadiusScale,d=null,m=null;this.clusterizationType>0?(d=new Ca(this.complex,this.atoms,r,n,i,u,this.colorMode),m=1===this.clusterizationType?d.buildKMeans():d.buildSimple(),n.x-=3.5,n.y-=3.5,n.z-=3.5,i.x+=3.5,i.y+=3.5,i.z+=3.5,this.calculateGridCorners(c,a,n,i,m,f)):this.calculateGridCorners(c,a,n,i,r,f);var g=o-1,v=new ga;if((t=v.create(g))<0)return t;var y=new l;y.x=(i.x-n.x)/g,y.y=(i.y-n.y)/g,y.z=(i.z-n.z)/g;var _=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2);if(this.geoOut=new Ta(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;var w=f;if(this.excludeProbe&&(w=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Ea(m.length,m,n,i,w):this.voxelWorld=new Ea(r.length,r,n,i,w),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,c,y,v),this.excludeProbe){if(this.modifyExcludedFromGeo(a,f,n,i,this.geoOut,c),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,_=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2),this.geoOut=new Ta(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;t=this.buildGeoFromCorners(a,n,i,c,y,v)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var S=6.5;this.excludeProbe&&(S-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,S)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==d&&d.destroy(),v.destroy(),t},(La.prototype=Object.create(fi.prototype)).constructor=La,La.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||function(t,e){var r=document.createElement("div");if(r.className=e,"string"==typeof t){var n=document.createElement("span");n.style.fontSize="150%";for(var i=t.split("\n"),o=0,a=i.length;o=0;--e)this.remove(t[e]);var r=this.geometry.items,n=this.geometry.userData,i=r.length;for(e=0;e>16&255,r=t>>8&255,n=255&t;return.2126*e+.7152*r+.0722*n>127?(e=3*e/10,r=3*r/10,n=3*n/10):(e=255-3*(255-e)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),e<<16|r<<8|n},inverse:function(t){return 255-(t>>16&255)<<16|255-(t>>8&255)<<8|255-(255&t)}},xd={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()}},bd=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(),xd.hasOwnProperty(r)?xd[r](t):"null"})};(qa.prototype=Object.create(ja.prototype)).constructor=qa,qa.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},qa.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;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},cc.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 Xm={AtomsSphereGroup:Ds,AtomsSurfaceGroup:zs,AtomsSASSESGroup_stub:Fs,AtomsTextGroup:Bs,AromaticTorusGroup:Ws,AromaticLinesGroup:Hs,NucleicCylindersGroup:qs,NucleicSpheresGroup:$s,ResiduesSubseqGroup:nc,ResiduesTraceGroup:ic,BondsCylinderGroup:sc,BondsLinesGroup:cc};lc.prototype=Object.create(wa.prototype),lc.prototype.constructor=lc,lc.prototype._checkAtom=function(t,e){return t._mask&e},lc.prototype.getSubset=function(t,e){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&s.add(p)}return s},bc.prototype=Object.create(xc.prototype),bc.prototype.constructor=bc,bc.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")},bc.prototype.buildGeometry=function(t,e,r,n){return this.update(),xc.prototype.buildGeometry.call(this,t,e,r,n)},Ff.deriveClass(Sc,bc,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),Sc.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Sc.prototype.calcAtomRadius=function(){return this.opts.atom},Sc.prototype.getAromaticOffset=function(){return this.opts.offsarom},Sc.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},Sc.prototype.showAromaticLoops=function(){return this.opts.showarom},Sc.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Ff.deriveClass(Mc,bc,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Mc.prototype.calcAtomRadius=function(t){return this.opts.bond},Mc.prototype.calcStickRadius=function(){return this.opts.bond},Mc.prototype.calcSpaceFraction=function(){return this.opts.space},Mc.prototype.getAromRadius=function(){return this.opts.aromrad},Mc.prototype.showAromaticLoops=function(){return this.opts.showarom},Mc.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Mc.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Ff.deriveClass(Ac,bc,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Ac.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},Ac.prototype.calcStickRadius=function(){return this.opts.bond},Ac.prototype.getAromRadius=function(){return this.opts.aromrad},Ac.prototype.showAromaticLoops=function(){return this.opts.showarom},Ac.prototype.calcSpaceFraction=function(){return this.opts.space},Ac.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Ac.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},Ff.deriveClass(Ec,xc,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),Ec.prototype.calcAtomRadius=function(t){return t.element.radius},Ff.deriveClass(Cc,xc,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),Cc.prototype.calcStickRadius=function(){return this.opts.radius},Ff.deriveClass(Tc,xc,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),Tc.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},Tc.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Tc.prototype.getTension=function(){return this.opts.tension},Tc.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius;return this.TUBE_RADIUS=new n(o,o),xc.prototype.buildGeometry.call(this,t,e,r,i)},Ff.deriveClass(Pc,xc,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),Pc.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},Pc.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},Pc.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)},Pc.prototype.calcStickRadius=function(t){return this.opts.radius},Pc.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Pc.prototype.getTension=function(){return this.opts.tension},Pc.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,xc.prototype.buildGeometry.call(this,t,e,r,i)};var qm=jd.selectors;Ff.deriveClass(Rc,xc,{isSurface:!0,surfaceNames:[]}),Rc.prototype.calcAtomRadius=function(t){return t.element.radius},Rc.prototype.getVisibilitySelector=function(){var t=null;if(""!==this.opts.subset){var e=qm.parse(this.opts.subset);e.error||(t=e.selector)}return t},Ff.deriveClass(Nc,Rc,{id:"QS",name:"Quick Surface",shortName:"Quick Surf",surfaceNames:["QuickSurfGeo"]}),Nc.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()}},Ff.deriveClass(Ic,Rc,{id:"SU",name:"Surface",shortName:"Surface",surfaceNames:["SASSESSurfaceGeo"]}),Ic.prototype._radScale=1,Ic.prototype._isVertexNormalsRendered=!1,Ic.prototype._isSurfaceTransparent=!1,Ic.prototype._clusterViaKMeans=0,Ic.prototype._excludeProbe=!1,Ic.prototype.calcAtomRadius=function(t){return t.element.radius},Ic.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}},Ff.deriveClass(Oc,Ic,{id:"SA",name:"Solvent Accessible Surface",shortName:"SAS"}),Ff.deriveClass(Dc,Ic,{id:"SE",name:"Solvent Excluded Surface",shortName:"SES"}),Ff.deriveClass(zc,Rc,{id:"CS",name:"Contact Surface",shortName:"Contact Surf",isSurface:!0,surfaceNames:["ContactSurfaceGeo"]}),zc.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()}},Ff.deriveClass(Fc,xc,{id:"TX",name:"Text mode",shortName:"Text",depGroups:["TextLabelsGeo"]}),Fc.prototype.getTemplateOptions=function(){return this.opts.template},Fc.prototype.getLabelOpts=function(){return _.merge(this.opts,{labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0})};var $m=[],Zm={};!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=kc(o+1,0,n-1);return o=kc(o,0,n-1),Uc(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,Jm=Bc.prototype.namedColors,tg=0,eg=Qm.length;tg=0?this.opts.carbon:this.palette.getElementColor(r)},jc.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},Ff.deriveClass(Gc,Vc,{id:"RT",name:"Residue Type",shortName:"Residue"}),Gc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Gc.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},Ff.deriveClass(Wc,Vc,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Wc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Wc.prototype.getResidueColor=function(t,e){var r=t._chain,n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},Ff.deriveClass(Hc,Vc,{id:"CH",name:"Chain",shortName:"Chain"}),Hc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Hc.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},Ff.deriveClass(Xc,Vc,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),Xc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Xc.prototype.getResidueColor=function(t,e){if(t._type.flags&Eo.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&Eo.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},Ff.deriveClass(Yc,Vc,{id:"UN",name:"Uniform",shortName:"Uniform"}),Yc.prototype.getAtomColor=function(t,e){return this.opts.color},Yc.prototype.getResidueColor=function(t,e){return this.opts.color},Ff.deriveClass(qc,Vc,{id:"CO",name:"Conditional",shortName:"Conditional"}),qc.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},qc.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},Zc.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===jd.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},Ff.deriveClass(Kc,Vc,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),Kc.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},Kc.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===jd.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},Ff.deriveClass(Qc,Vc,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),Qc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Qc.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},Ff.deriveClass(Jc,Vc,{id:"MO",name:"Molecule",shortName:"Molecule"}),Jc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Jc.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 pg=[],fg={};!function(t){for(var e=0,r=t.length;e0){(e=new Be).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return Of.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 Of.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,Of.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=bg.parse(e.selector).selector,a=String(o);n.selector!==a&&(r.selectorString=n.selector=a,r.selector=o,r.markAtoms(this._complex),i=!0,Of.debug("rep["+t+"].selector changed to"+a))}if(e.mode){var s=e.mode;Bu.isEqual(n.mode,s)||(n.mode=s,r.setMode(Km.create(e.mode)),i=!0,Of.debug("rep["+t+"].mode changed to "+s),!r.mode.isSurface||"ultra"!==Bf.now.resolution&&"high"!==Bf.now.resolution||(Of.report('Surface resolution was changed to "medium" to avoid hang-ups.'),Bf.now.resolution="medium"))}if(e.colorer){var c=e.colorer;Bu.isEqual(n.colorer,c)||(n.colorer=c,r.colorer=dg.create(e.colorer),i=!0,Of.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var l=e.material;Bu.isEqual(n.material,l)||(n.material=l,r.setMaterialPreset(_g.get(e.material)),i=!0,Of.debug("rep["+t+"].material changed to"+l))}i&&(r.needsRebuild=!0)}return n},al.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},al.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<32;++e,t>>=1)if(0==(1&t))return e;return-1},al.prototype.repAdd=function(t){if(this._reprList.length>=this.getMaxRepresentationCount())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)},al.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=bg.chain(r),o=o?bg.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=bg.and(bg.chain(s),bg.residx(n(e[s]))),o=o?bg.or(o,a):a);t.length>0&&(a=bg.serial(n(t)),o=o?bg.or(o,a):a),o||(o=bg.none())}return o},al.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)},al.prototype.getSelectedComponent=function(){var t=1<=0):n<8+d.indices.length&&(this.cullFlag[n]=!0);var y=this.geometry.getAttribute("position"),_=0;for(n=0;n=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)})},hl.prototype.mean=function(){return this._prof?this._prof.rawMean():0},hl.prototype.min=function(){return this._prof?this._prof.min():0},pl.prototype.abort=function(){this._agent.abort()},Pa(pl.prototype),pl.addCommonHandlers=function(t,e){e.error&&(t.addEventListener("error",function(){e.error("OnError() event fired while loading")}),t.addEventListener("abort",function(){e.error("OnAbort() event fired while loading")})),e.progress&&t.addEventListener("progress",function(t){t.lengthComputable?e.progress(t.loaded/t.total):e.progress()})},(fl.prototype=Object.create(pl.prototype)).constructor=fl,fl.prototype.load=function(t){var e=new FileReader;this._agent=e,t.ready&&e.addEventListener("load",function(e){t.ready(e.target.result)}),pl.addCommonHandlers(e,t),this._binary?e.readAsArrayBuffer(this._source):e.readAsText(this._source)},fl.canLoad=function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)},(dl.prototype=Object.create(pl.prototype)).constructor=dl,dl.prototype.load=function(t){var e=this._source,r=new XMLHttpRequest;this._agent=r,t.ready&&r.addEventListener("load",function(){200===r.status?t.ready(r.response):t.error&&t.error("HTTP "+r.status+" while fetching "+e)}),pl.addCommonHandlers(r,t),r.open("GET",e),this._binary?r.responseType="arraybuffer":r.responseType="text",r.send()},dl.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)},(ml.prototype=Object.create(pl.prototype)).constructor=ml,ml.prototype.load=function(t){t.progress&&t.progress(0),this._options.data&&null!==this._options.data&&""!==this._options.data||t.error&&t.error("No data found!"),t.progress&&t.progress(.5),this._options.dataType&&null!==this._options.dataType&&""!==this._options.dataType||t.error&&t.error("No dataType found!"),t.progress&&t.progress(1),t.ready&&t.ready(this._options.data)},ml.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(3===t.indexOf(":",0)||"message"===r)};var Ag=[];!function(t){for(var e=0,r=t.length;e0&&e.addChain(h)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new Tg(this._complex),this.assemblies.push(e))};var Pg="\n".length,Lg=function(){function t(e){jf(this,t),this._data=e,this._start=0,this._next=-Pg,this._end=e.length,this.next()}return Gf(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+Pg;this._start=t0?e:this._end}}]),t}(),Rg=jd.Complex,Ng=jd.Element,Ig=jd.Helix,Og=jd.Sheet,Dg=jd.Strand,zg=jd.Bond,Fg=jd.Molecule;(_l.prototype=Object.create(Cg.prototype)).constructor=_l,_l.canParse=function(t,e){return!!t&&("string"==typeof t&&(Cg.checkDataTypeOptions(e,"pdb")||Cg.checkDataTypeOptions(e,"pdb",".ent")))},_l.prototype._finalize=function(){this._fixBondsArray(),this._fixChains();var t=this._remarks[290];this._complex.symmetry=Bu.isUndefined(t)?[]:t.matrices;var e=this._remarks[350];this._complex.structures=this._complex.structures.concat(Bu.isUndefined(e)?[]:e.assemblies),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})},_l.prototype._finalizeMolecules=function(){var t,e={},r=this._complex._chains;for(t=0;te&&a.addBond(e,r,0,zg.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,zg.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,zg.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,zg.BondType.UNKNOWN,!0)},_l.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 kg={290:gl,350:vl};_l.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(Bu.isUndefined(r)){var n=kg[e];Bu.isFunction(n)&&(this._remarks[e]=r=new n(this._complex))}Bu.isUndefined(r)||r.parse(t)},_l.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},_l.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},_l.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 Og(i,c),r(y)):y=_;var x=new Dg(y,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,l,u);y.addStrand(x)}else r(y=new Ig(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,o,a))},_l.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)},_l.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 Ug={HEADER:_l.prototype._parseHEADER,"TITLE ":_l.prototype._parseTITLE,"ATOM ":_l.prototype._parseATOM,HETATM:_l.prototype._parseATOM,ENDMDL:_l.prototype._parseENDMDL,CONECT:_l.prototype._parseCONECT,COMPND:_l.prototype._parseCOMPND,REMARK:_l.prototype._parseREMARK,"HELIX ":_l.prototype._parseHELIX,"SHEET ":_l.prototype._parseSHEET,"ATOM 1":_l.prototype._parseATOM,"ATOM 2":_l.prototype._parseATOM,"ATOM 3":_l.prototype._parseATOM,"ATOM 4":_l.prototype._parseATOM,"ATOM 5":_l.prototype._parseATOM,"ATOM 6":_l.prototype._parseATOM,"ATOM 7":_l.prototype._parseATOM,"ATOM 8":_l.prototype._parseATOM,"ATOM 9":_l.prototype._parseATOM};_l.prototype.parseSync=function(){for(var t=new Lg(this._data),e=this._complex=new Rg;!t.end();){var r=t.readString(1,6),n=Ug[r];Bu.isFunction(n)&&n.call(this,t),t.next()}if(this.hasOwnProperty("_abort"))throw new Error("Aborted");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");if(this.hasOwnProperty("_abort"))throw new Error("Aborted");return e};var Bg=jd.Complex;(xl.prototype=Object.create(Cg.prototype)).constructor=xl,xl.prototype.parseSync=function(){var t=this._complex=new Bg;return this._complex=null,t},xl.canParse=function(t,e){return!!t&&("string"==typeof t&&Cg.checkDataTypeOptions(e,"mol"))};var Vg=jd.Complex,jg=jd.Element,Gg=jd.AtomName,Wg=jd.SGroup,Hg=jd.Bond,Xg={A:0,S:1,D:2,T:3};(bl.prototype=Object.create(Cg.prototype)).constructor=bl,bl.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\1)c[a].order=h;else{var p=Xg[u];void 0!==p&&(c[a].order=p,"A"===u&&(c[a].type=Hg.BondType.AROMATIC))}}for(s=e.length,a=0;a1&&s.splice(1,s.length-1),s.forEach(function(t){var r=e(t);r.atoms.length>0&&a.push(r)}),a},bl.prototype._packLabel=function(t,e){return(e<<16)+t},bl.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},bl.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)}},bl.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new Vg;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new Vg};var Yg=e(function(t,e){!function(t,r){r(e)}(0,function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t,i,o){var a=typeof t;if("string"===a){if(32>(s=r(t)))return i.setUint8(o,160|s),e(i,o+1,t),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,t),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,t),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,t),5+s}if(t instanceof Uint8Array){var s=t.byteLength,c=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),c.set(t,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),c.set(t,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),c.set(t,o+5),5+s}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return i.setUint8(o,203),i.setFloat64(o+1,t),9;if(t>=0){if(128>t)return i.setUint8(o,t),1;if(256>t)return i.setUint8(o,204),i.setUint8(o+1,t),2;if(65536>t)return i.setUint8(o,205),i.setUint16(o+1,t),3;if(4294967296>t)return i.setUint8(o,206),i.setUint32(o+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return i.setInt8(o,t),1;if(t>=-128)return i.setUint8(o,208),i.setInt8(o+1,t),2;if(t>=-32768)return i.setUint8(o,209),i.setInt16(o+1,t),3;if(t>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,t?195:194),1;if("object"===a){var l=0,u=Array.isArray(t);if(u)s=t.length;else{var h=Object.keys(t);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),l=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),l=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),l=5),u)for(p=0;s>p;p++)l+=n(t[p],i,o+l);else for(var p=0;s>p;p++){var f=h[p];l+=n(f,i,o+l),l+=n(t[f],i,o+l)}return l}throw new Error("Unknown type "+a)}function i(t){var e=typeof t;if("string"===e){if(32>(n=r(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var n,o=0;if(Array.isArray(t)){n=t.length;for(s=0;n>s;s++)o+=i(t[s])}else{var a=Object.keys(t);n=a.length;for(var s=0;n>s;s++){var c=a[s];o+=i(c)+i(t[c])}}if(16>n)return 1+o;if(65536>n)return 3+o;if(4294967296>n)return 5+o;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+e)}function o(t){var e=new ArrayBuffer(i(t));return n(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function s(t){return a(DataView,t)}function c(t){return a(Uint8Array,t)}function l(t){return a(Int8Array,t)}function u(t){return a(Int32Array,t,4)}function h(t){return a(Float32Array,t,4)}function p(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 f(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)}function d(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 m(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 g(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}function v(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 y(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 _(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 x(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 b(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 w(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 S(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 M(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r)0===(l=t[r])?++a:a+=l===n||l===i?2:l>0?Math.ceil(l/n):Math.ceil(l/i);var s=e?new Int8Array(a):new Int16Array(a),c=0;for(r=0;o>r;++r){var l=t[r];if(l>=0)for(;l>=n;)s[c]=n,++c,l-=n;else for(;i>=l;)s[c]=i,++c,l-=i;s[c]=l,++c}return s}function A(t,e){return b(_(t),e)}function E(t){return x(w(t))}function C(t,e,r){return v(_(t,u(r)),e,r)}function T(t,e){return x(y(t,e))}function P(t,e,r){return v(b(t,u(r)),e,r)}function L(t,e,r){return w(y(t,e),r)}function R(t,e,r){return v(S(t,u(r)),e,r)}function N(t,e,r){var n=S(t,u(r));return P(n,e,h(n))}function I(t,e,r){return M(L(t,e),r)}function O(t){var e=s(t),r=e.getInt32(0),n=e.getInt32(4),i=t.subarray(8,12);return[r,t=t.subarray(12),n,i]}function D(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 z(t){return D(2,t.length,void 0,c(t))}function F(t){return D(4,t.length,void 0,m(t))}function k(t,e){return D(5,t.length/e,m([e]),c(t))}function U(t){return D(6,t.length,void 0,m(x(t)))}function B(t){return D(8,t.length,void 0,m(E(t)))}function V(t,e){return D(9,t.length,m([e]),m(T(t,e)))}function j(t,e){return D(10,t.length,m([e]),f(I(t,e)))}function G(t){var e={};return Z.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=F(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=z(t.bondOrderList)),e.xCoordList=j(t.xCoordList,1e3),e.yCoordList=j(t.yCoordList,1e3),e.zCoordList=j(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=j(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=B(t.atomIdList)),t.altLocList&&(e.altLocList=U(t.altLocList)),t.occupancyList&&(e.occupancyList=V(t.occupancyList,100)),e.groupIdList=B(t.groupIdList),e.groupTypeList=F(t.groupTypeList),t.secStructList&&(e.secStructList=z(t.secStructList,1)),t.insCodeList&&(e.insCodeList=U(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=B(t.sequenceIndexList)),e.chainIdList=k(t.chainIdList,4),t.chainNameList&&(e.chainNameList=k(t.chainNameList,4)),e}function W(t){function e(t){for(var e={},r=0;t>r;r++)e[o()]=o();return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;var n=65535;if(e>n){for(var i=[],o=0;or;r++)e[r]=o();return e}function o(){var o,c,l=t[a];if(0==(128&l))return a++,l;if(128==(240&l))return c=15&l,a++,e(c);if(144==(240&l))return c=15&l,a++,i(c);if(160==(224&l))return c=31&l,a++,n(c);if(224==(224&l))return o=s.getInt8(a),a++,o;switch(l){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,r(c);case 197:return c=s.getUint16(a+1),a+=3,r(c);case 198:return c=s.getUint32(a+1),a+=5,r(c);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return c=s.getUint8(a+1),a+=2,n(c);case 218:return c=s.getUint16(a+1),a+=3,n(c);case 219:return c=s.getUint32(a+1),a+=5,n(c);case 220:return c=s.getUint16(a+1),a+=3,i(c);case 221:return c=s.getUint32(a+1),a+=5,i(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+l.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function H(t,e,r,n){switch(t){case 1:return g(e);case 2:return l(e);case 3:return p(e);case 4:return d(e);case 5:return c(e);case 6:return _(d(e),new Uint8Array(r));case 7:return _(d(e));case 8:return A(d(e));case 9:return C(d(e),d(n)[0]);case 10:return N(p(e),d(n)[0]);case 11:return v(p(e),d(n)[0]);case 12:return R(p(e),d(n)[0]);case 13:return R(l(e),d(n)[0]);case 14:return S(p(e));case 15:return S(l(e))}}function X(t,e){var r=(e=e||{}).ignoreFields,n={};return K.forEach(function(e){var i=!!r&&-1!==r.indexOf(e),o=t[e];i||void 0===o||(o instanceof Uint8Array?n[e]=H.apply(null,O(o)):n[e]=o)}),n}function Y(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function q(t,e){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r;return r=t instanceof Uint8Array?W(t):t,X(r,e)}function $(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=q(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"]),Q="//mmtf.rcsb.org/v1.0/",J=Q+"full/",tt=Q+"reduced/";t.encode=function(t){return o(G(t))},t.decode=q,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=Y(t.chainIdList.subarray(4*g,4*g+4)),O=null;b&&(O=Y(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 F=null;w&&(F=w[v]);var k=null;t.insCodeList&&(k=String.fromCharCode(S[v]));var U=null;M&&(U=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:F,insCode:k,sequenceIndex:U})}for(s=0;z>s;++s){if(f){var B=null;A&&(B=A[y]);var V=null;E&&(V=E[y]);var j=null;C&&(j=String.fromCharCode(C[y]));var G=null;T&&(G=T[y]),f({atomIndex:y,groupIndex:v,chainIndex:g,modelIndex:m,atomId:B,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:V,altLoc:j,occupancy:G})}y+=1}if(d){var W=D.bondAtomList;for(s=0,c=D.bondOrderList.length;c>s;++s)d({atomIndex1:y-z+W[2*s],atomIndex2:y-z+W[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 H=P[s],X=P[s+1];(H>=_&&x>=H||X>=_&&x>=X)&&d({atomIndex1:H,atomIndex2:X,bondOrder:L?L[s/2]:null})}m+=1}},t.fetch=function(t,e,r){$(t,J,e,r)},t.fetchReduced=function(t,e,r){$(t,tt,e,r)},t.version="v1.1.0dev",t.fetchUrl=J,t.fetchReducedUrl=tt,t.encodeMsgpack=o,t.encodeMmtf=G,t.decodeMsgpack=W,t.decodeMmtf=X})}),qg=jd.Complex,$g=jd.Chain,Zg=jd.Atom,Kg=jd.AtomName,Qg=jd.Element,Jg=jd.Helix,tv=jd.Sheet,ev=jd.Strand,rv=jd.Bond,nv=jd.Assembly,iv=jd.Molecule;wl.prototype.constructor=wl,wl.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,rv.BondType.UNKNOWN,!0)}},Sl.prototype._updateSecStructure=function(t,e,r){if(!Bu.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof Jg||this._ssStruct instanceof ev)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof Jg||this._ssStruct instanceof ev)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!Bu.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 Jg(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(n);break;case 3:var i=new tv("",0);t._sheets.push(i),n=new ev(i,e,null,0);break;default:n={type:"mmtf"+this._ssType}}this._ssStruct=n,e._secondary=n}},Sl.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 iv(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},Sl.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,Yg.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},Sl.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)}}}},Cl._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=c||e(t.charCodeAt(a+1)))){if(u&&59===l){s=a;var i=0;do{if(-1===(s=r(10,t,s+1)))return d="unterminated text block found",null;++i}while(s+1=c);return n=t.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=i,p=1,u=!1,n}if(39===l||34===l){s=a;do{if(-1===(s=r(l,t,s+1)))return d="unterminated quoted string found",null}while(s+10){for(var w=0;w-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=Gp.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*(Bf.now.inversePanning?-1:1),this.camera.translateX(a*i),this.camera.translateY(a*o),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},zl.prototype.reset=function(){this._state=xv.NONE,this.object.quaternion.copy(new c(0,0,0,1))},zl.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===xv.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===xv.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?xv.TRANSLATE:xv.ROTATE}else 2===t.button&&(this._state=xv.TRANSLATE_PIVOT);this._state===xv.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==xv.TRANSLATE&&this._state!==xv.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},zl.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==xv.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case xv.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 xv.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case xv.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},zl.prototype.mousewheel=function(t){if(!1!==this.enabled&&Bf.now.zooming&&this._state===xv.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})}},zl.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==xv.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=xv.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},zl.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=xv.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=xv.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=xv.NONE}},zl.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==xv.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case xv.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 xv.SCALE_PAN:if(Bf.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(Bf.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"})}}},zl.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()}},zl.prototype.getKeyBindObject=function(){return window.top},zl.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new l;if(Bf.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)}}},Vl.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=Bl((268435200&g)>>>8>>0),_=Bl(((255&g)<<12|(4293918720&m)>>>20)>>0),x=Bl((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(Ul(p,a))}this._secondaryData=l,this._data=u},Vl.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},Vl.prototype.needsColorUpdate=function(t){return t instanceof Xc},Vl.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},Vl.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},Vl.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){var e=this;switch(this._buffer.state){case"none":this._prepareBuffer(t);break;case"ready":e._parseBuffer()}}else this._prepareBuffer(t)},Vl.prototype.disableEvents=function(){this._callbacks=null},Vl.prototype.getAtomPos=function(){var t=new l;return function(e){var r=this,n=r._data,i=3*(r._atomsCount*(r._currFrame-r._framesRange.start)+e);return t.set(n[i],n[i+1],n[i+2]),t}}(),Vl.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},jl.prototype.type="__",jl.prototype.identify=function(){var t={type:this.type,params:this.params},e=Ff.objectsDiff(this.opts,Bf.now.modes[this.id]);return Bu.isEmpty(e)||(t.opts=e),t},jl.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+Ff.compareOptionsWithDefaults(this.opts,Bf.defaults.objects[this.type])},jl.prototype.getGeometry=function(){return this._mesh},jl.prototype.destroy=function(){this._mesh&&$d.destroyObject(this._mesh)},Ff.deriveClass(Gl,jl,{type:"line"}),Gl.prototype.constructor=Gl,Gl.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},Gl.prototype.build=function(t){var e=new yt;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 km.Line(e,new Sa({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new q(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 Be,this._mesh.add(this._line),$d.applyTransformsToMeshes(this._mesh,r))},Gl.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 Av="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",Ev="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",Cv=tf.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new n(512,512)},opacity:{type:"f",value:1}}]),Tv="// 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",Pv=tf.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)}}]),Lv="#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}",Rv="#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",Nv="#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}",Iv=tf.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)}}]),Ov=tf.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}}]),Dv={AOMaterial:function(t){return new tt({uniforms:ql(t,Iv),vertexShader:Av,fragmentShader:Lv,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new tt({uniforms:ql(t,Ov),vertexShader:Av,fragmentShader:Rv,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new tt({uniforms:ql(t,Ov),vertexShader:Av,fragmentShader:Nv,transparent:!1,depthTest:!1,depthWrite:!1})}},zv="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",Fv=tf.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);Kl.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};Ql.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},Ql.prototype.isMoving=function(){return this._isMoving},Ql.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},Ql.prototype.start=function(){this._startTime=Date.now();var t=Bf.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},Ql.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}},Ql.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},Ql.prototype.createView=function(){return new Kl};var kv=new Ql,Uv=Bf.now.fbxprec,Bv='; 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',Vv='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',jv=null;eu.prototype.queue=[],eu.prototype.busy=!1,eu.prototype.add=function(t,e,r,n){this.queue.push([t,e,r,n]),this.busy||this.next()},eu.prototype.next=function(){var t=this.queue.shift(),e=this;t&&!e.busy&&(this.busy=!0,tu(t[0],t[1],t[2],t[3],function(){e.busy=!1,e.next()}))};Pa(mu.prototype),mu.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e,r)):i.renderer.renderDummyQuad(r),i.renderer.renderScreenQuadFromTex(r.texture,.6,n),t.uniforms.srcTex.value=r.texture,t.uniforms.srcTexSize.value.set(r.width,r.height),i.renderer.renderScreenQuad(t,n)}}(),bu.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)},bu.prototype._renderVolume=function(){var t,e=new Mg.BackFacePosMaterial,r=new Mg.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($d.LAYERS.VOLUME_BFPLANE),h.renderer.render(h.scene,a,c),a.layers.set($d.LAYERS.VOLUME),h.scene.overrideMaterial=e,h.renderer.render(h.scene,a,c),a.layers.set($d.LAYERS.VOLUME),h.scene.overrideMaterial=r,h.renderer.render(h.scene,a,l),h.scene.overrideMaterial=null,a.layers.set($d.LAYERS.DEFAULT),i.getInverse(p.matrixWorld),Sa.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($d.LAYERS.VOLUME),h.renderer.render(h.scene,a,s),a.layers.set($d.LAYERS.DEFAULT)}}}(),bu.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set($d.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set($d.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($d.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set($d.LAYERS.DEFAULT)},bu.prototype._performFXAA=function(){var t=new Yl;return function(e,r){if(void 0!==e&&void 0!==r){var n=this._gfx;n.renderer.setClearColor(Bf.now.themes[Bf.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)}}}(),bu.prototype._performAO=function(){var t=new Dv.AOMaterial,e=new Dv.HorBilateralBlurMaterial,r=new Dv.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,fp,tp,300,Hh,Hh,qh,qh,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*Gp.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=Bf.now.debug.ssaoKernelRadius*g.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=Bf.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)}}}(),bu.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(Xv.COMPLEX),this._resetObjects(),this._gfx&&($d.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},bu.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},bu.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(Xv.COMPLEX),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},bu.prototype.load=function(t,e){var r=this;r._loader&&r._loader.cancel(),r.dispatchEvent({type:"load",options:e}),t instanceof File&&t.name.match(/.man$/i)?this._fileSourceAnim=yu(t):this._fileSource=yu(t),e&&e.mdFile&&(this._fileSourceAnim=e.mdFile),this.settings.now.use.multiFile||e&&e.animation||this.reset(!0),r._loader=new eo,r._loader.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),r._spinner.spin(this._container);var n=function(t){return r._loader=null,r._spinner.stop(),r._refreshTitle(),t};return Su(t,e,r._loader,r).then(function(t){return Mu(t.data,t.opts,t.master)}).then(function(t){return Au(t.data,t.opts,t.master,r)}).then(function(t){return r._onLoad(t.data,t.opts)}).then(function(t){return n(t)}).catch(function(t){throw n(),r.logger.error("Could not load data"),r.logger.debug(t),t})},bu.prototype.unload=function(t){this._removeVisual(t||this.getCurrentVisual()),this.resetPivot()},bu.prototype._startAnimation=function(t){this._stopAnimation();var e=this,r=this._getComplexVisual();if(null!==r){try{this._frameInfo=new Vl(r.getComplex(),t,{onLoadStatusChanged:function(){e.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:e._isAnimating,isLoading:!e._frameInfo||e._frameInfo.isLoading}})},onError:function(t){e._stopAnimation(),e.logger.error(t)}})}catch(t){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")},bu.prototype._startMdAnimation=function(t,e){this._stopAnimation();var r=this,n=this._getComplexVisual();if(null!==n){try{this._frameInfo=new Vl(n.getComplex(),this.srvStreamMdFn(t,e),{onLoadStatusChanged:function(){r.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:r._isAnimating,isLoading:!r._frameInfo||r._frameInfo.isLoading}})},onError:function(t){r._stopAnimation(),r.logger.error(t)}})}catch(t){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")},bu.prototype._pauseAnimation=function(){null!==this._animInterval&&(this._isAnimating=!1,clearInterval(this._animInterval),this._animInterval=null,this._frameInfo&&this.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:this._isAnimating,isLoading:this._frameInfo.isLoading}}))},bu.prototype._continueAnimation=function(){this._isAnimating=!0;var t=1e3/Bf.now.maxfps;t=Number.isNaN(t)?0:t;var e=this,r=e._gfx.pivot,n=this._getComplexVisual();n&&(n.resetSelectionMask(),n.rebuildSelectionGeometry(),this._msgAtomInfo.style.opacity=0),this._animInterval=setInterval(function(){if(e.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:e._isAnimating,isLoading:e._frameInfo.isLoading}}),e._frameInfo.frameIsReady){r.updateToFrame(e._frameInfo),e._updateObjsToFrame(e._frameInfo),e._refreshTitle(" Frame "+e._frameInfo._currFrame+" of "+e._frameInfo._framesCount+" time interval - "+e._frameInfo._timeStep);try{e._frameInfo.nextFrame()}catch(t){return e.logger.error("Error during animation"),void e._stopAnimation()}e._needRender=!0}},t)},bu.prototype._stopAnimation=function(){null!==this._animInterval&&(clearInterval(this._animInterval),this._frameInfo.disableEvents(),this._frameInfo=null,this._animInterval=null,this._fileSourceAnim=null,this.dispatchEvent({type:"mdPlayerStateChanged",state:null}))},bu.prototype._onLoad=function(t,e){var r=this._gfx,n=null;if(e.animation)return this._refreshTitle(),this._startAnimation(t),null;if(this._stopAnimation(),e&&e.keepRepsInfo||(this._opts.reps=null,this._opts._objects=null),"Complex"===t.id){var i=t;e.fileName?i.name=i.name||vu(e.fileName).toUpperCase():e.amberFileName?i.name=i.name||vu(e.amberFileName).toUpperCase():i.name="Dynamic "+e.fileType+" molecule",n=this._addVisual(new al(i.name,i)),this._curVisualName=n;var o=this.info();if(this.logger.info("Parsed "+e.fileName+" ("+o.atoms+" atoms, "+o.bonds+" bonds, "+o.residues+" residues, "+o.chains+" chains)."),Bu.isNumber(this._opts.unit)&&i.setCurrentStructure(this._opts.unit),e.preset)this.srvPresetApply(e.preset);else if(Bf.now.autoPreset)switch(e.fileType){case"cml":this.resetReps("small");break;case"pdb":case"mmtf":case"cif":_u(i)?this.resetReps("macro"):this.resetReps("small");break;default:this.resetReps("default")}else this.resetReps("default")}else"Volume"===t.id&&(this.resetEd(),n=this._onLoadEd(t));return r.camera.updateProjectionMatrix(),this._updateFog(),r.root.resetTransform(),this.resetPivot(),this.resetPan(),this._objectControls.setScale(Bf.now.radiusToFit/this._getBSphereRadius()),this._resetObjects(),Bf.now.autoResolution&&this._tweakResolution(),this._opts.view&&(this.view(this._opts.view),delete this._opts.view),e.error?this.dispatchEvent({type:"onParseError",error:e.error}):this.dispatchEvent({type:"onParseDone"}),this._refreshTitle(),e.convertedFile&&e.mdFile&&this._startMdAnimation(e.mdFile,e.convertedFile),n},bu.prototype.resetEd=function(){this._edLoader&&(this._edLoader.abort(),this._edLoader=null),this._removeVisual(this._getVolumeVisual()),this._needRender=!0},bu.prototype.loadEd=function(t){var e=this;this.resetEd(),(this._edLoader=yv.loaders.create(e,t,{binary:!0})).load({ready:function(t){yv.parsers.create(e,t,{fileType:"ccp4"}).parse({ready:function(t){e._onLoadEd(t)},progress:function(t){xu(e.logger,"Parsing ED",t)}})},progress:function(t){xu(e.logger,"Loading ED",t)}})},bu.prototype._onLoadEd=function(t){t.normalize();var e=new ll("volume",t);e.getMesh().layers.set($d.LAYERS.VOLUME);var r=this._addVisual(e);return this._needRender=!0,r},bu.prototype._needRebuild=function(){var t=!1;return this._forEachComplexVisual(function(e){t=t||e.needsRebuild()}),t},bu.prototype._rebuildObjects=function(){var t,e,r=this,n=this._gfx,i=[];for(t=0;t0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},bu.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})}},bu.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},bu.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})},bu.prototype.setNeedRender=function(){this._needRender=!0},bu.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"}))},bu.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},bu.prototype.applyPreset=function(t){for(var e=Bf.now.presets,r=[t||Bf.defaults.preset,Bf.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(Xv.FRAGMENT),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},bu.prototype._applyFragmentEdit=function(){if(this._editMode===Xv.FRAGMENT){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new l(0,0,0)}},bu.prototype.resetPivot=function(){var t=new nt;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},bu.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()})},bu.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(Gp.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*Gp.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},bu.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);Ff.shotDownload(n,t)},bu.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"):Bf.now.preset!==Bf.defaults.preset&&(r.preset=Bf.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);Bu.isEmpty(l)||(e.settings=l)}return e},bu.prototype.get=function(t,e){return Bf.get(t,e)},bu.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*Bf.now.draft.clipPlaneFactor,Bf.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]+"'");C=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(c+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(C,{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):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],E.$=i[i.length-S],E._$={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&&(E._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(E,[s,l,c,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(E.$),o.push(E._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);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];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;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=vd.readFileSync(yd.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),Zv=$v.parser,Kv=($v.Parser,$v.parse,$v.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"]}}),Qv={$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(hg.get(Bf.now.palette).namedColors).sort().join("\n")}}},Jv={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},ty={$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:Kv,c:Qv,mt:Jv},ey={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Kv,colorers:Qv},ry={$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:ty},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:ty},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:Kv},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Qv},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Jv},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:ey},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:ey},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"]}},ny=function(){function t(){jf(this,t)}return Gf(t,[{key:"createSelectorFromNode",value:function(t){return Pu(t)}}]),t}(),iy=bu.chem.selectors,oy=bu.modes,ay=bu.colorers,sy=bu.materials,cy=bu.palettes,ly=bu.options,uy=bu.settings,hy=function(){var t=new Lu;return function(){return t}}();Ru.prototype.get=function(t){return this.representationMap[t]||this.representationID[t]||""},Ru.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"},Ru.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])}},Ru.prototype.clear=function(){this.representationMap={},this.representationID={}};var py=new Ru;Nu.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},Nu.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},Nu.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 "'+Vf(Bu.get(uy.defaults,t))+'"'};if("theme"===t){for(var i=Object.keys(uy.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)})},zu.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)}},zu.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=Bu.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)},zu.prototype.createScenario=function(t){this.scenarioContext=new Du(t)},zu.prototype.resetScenario=function(){this.scenarioContext=new Du},zu.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)},zu.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(Bu.isString(s))this.requestPdbID(t,s,function(t){t>=0&&(a[3]=t,o.addScenarioItem.apply(o,a))},i);else if(Bu.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 Iu(e,r,a,s)),t.srvScenarioAdd(o.scenarioContext.id,o.scenarioContext.name,JSON.stringify(o.scenarioContext.script),n,i)}(s,c,l,u)}},zu.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)},zu.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},zu.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)},zu.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 dy=new zu;ku.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},ku.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},ku.prototype.toJSO=function(t,e,r){for(var n={},i=this._values,o=0,a=i.length;o0},bu.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={};e.success=!1;try{Zv.parse(t),e.success=!0}catch(t){e.error=t.message,Zv.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},bu.JSONConverter=ny,Zv.yy=my,Zv.yy.parseError=Zv.parseError,bu}); +(function(){var t,r,n,i,o,a,s,c,l,u,h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C=Object.prototype.hasOwnProperty,T=function(t,e){function r(){this.constructor=t}for(var n in e)C.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};p={method:(n={METHOD_NEAREST:"nearest",METHOD_LINEAR:"linear",METHOD_CUBIC:"cubic",METHOD_LANCZOS:"lanczos",METHOD_SINC:"sinc",CLIP_CLAMP:"clamp",CLIP_ZERO:"zero",CLIP_PERIODIC:"periodic",CLIP_MIRROR:"mirror",CUBIC_TENSION_DEFAULT:0,CUBIC_TENSION_CATMULL_ROM:0}).METHOD_CUBIC,cubicTension:n.CUBIC_TENSION_DEFAULT,clip:n.CLIP_CLAMP,scaleTo:0,sincFilterSize:2,sincWindow:void 0},l=function(t,e){return Math.max(0,Math.min(t,e-1))},h=function(t,e){return(t%=e)<0&&(t+=e),t},u=function(t,e){var r;return r=2*(e-1),(t=h(t,r))>e-1&&(t=r-t),t},t=function(){function t(t,e){if(this.array=t.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[e.clip]))throw"Invalid clip: "+e.clip}return t.prototype.getClippedInput=function(t){return 0<=t&&t=o;i<=o?r++:r--)n+=this.kernel(t-r)*this.getClippedInput(r);return n},r}(),f=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?l++:l--)r.push(new h(f(t,l),e));return r}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;r1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),o.setColor(p++,i.getAtomColor(v,r),i.getAtomColor(y,r))}}o.finalize(),this._chunksIdc=f},ps.prototype.updateToFrame=function(t){for(var e=this._selection.chunks,r=this._selection.bonds,n=this._mode,i=this._colorer,o=this._geo,a=n.drawMultiorderBonds(),s=n.showAromaticLoops(),c=new l,u=new l,h=new l,p=0,f=t.needsColorUpdate(i),d=0,m=e.length;d1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),f&&o.setColor(p,t.getAtomColor(i,v),t.getAtomColor(i,y)),p++}}o.finalize()};var Ed={AtomsSphereGroup:Ga,AtomsSurfaceGroup:Wa,AtomsSASSESGroup_stub:Ha,AtomsTextGroup:qa,AromaticTorusGroup:Ka,AromaticLinesGroup:Qa,NucleicCylindersGroup:es,NucleicSpheresGroup:rs,ResiduesSubseqGroup:cs,ResiduesTraceGroup:ls,BondsCylinderGroup:hs,BondsLinesGroup:ps};(fs.prototype=Object.create(Vo.prototype)).constructor=fs,fs.prototype._checkAtom=function(t,e){return t._mask&e},fs.prototype.getSubset=function(t,e){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&s.add(h)}return s},(As.prototype=Object.create(Ms.prototype)).constructor=As,As.prototype.update=function(){var t=this._staticGroups;"no"===this.settings.now.labels?this.depGroups=this.depGroups.slice(0,t):(this.depGroups[t]="TextLabelsGeo",this.depGroups[t+1]="SGroupsLabels")},As.prototype.buildGeometry=function(t,e,r,n){return this.update(),Ms.prototype.buildGeometry.call(this,t,e,r,n)},gp.deriveClass(Cs,As,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),Cs.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Cs.prototype.calcAtomRadius=function(){return this.opts.atom},Cs.prototype.getAromaticOffset=function(){return this.opts.offsarom},Cs.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},Cs.prototype.showAromaticLoops=function(){return this.opts.showarom},Cs.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gp.deriveClass(Ts,As,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Ts.prototype.calcAtomRadius=function(t){return this.opts.bond},Ts.prototype.calcStickRadius=function(){return this.opts.bond},Ts.prototype.calcSpaceFraction=function(){return this.opts.space},Ts.prototype.getAromRadius=function(){return this.opts.aromrad},Ts.prototype.showAromaticLoops=function(){return this.opts.showarom},Ts.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Ts.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gp.deriveClass(Ps,As,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),Ps.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},Ps.prototype.calcStickRadius=function(){return this.opts.bond},Ps.prototype.getAromRadius=function(){return this.opts.aromrad},Ps.prototype.showAromaticLoops=function(){return this.opts.showarom},Ps.prototype.calcSpaceFraction=function(){return this.opts.space},Ps.prototype.drawMultiorderBonds=function(){return this.opts.multibond},Ps.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gp.deriveClass(Ls,Ms,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),Ls.prototype.calcAtomRadius=function(t){return t.element.radius},gp.deriveClass(Rs,Ms,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),Rs.prototype.calcStickRadius=function(){return this.opts.radius},gp.deriveClass(Ns,Ms,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),Ns.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},Ns.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Ns.prototype.getTension=function(){return this.opts.tension},Ns.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius;return this.TUBE_RADIUS=new n(o,o),Ms.prototype.buildGeometry.call(this,t,e,r,i)},gp.deriveClass(Is,Ms,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),Is.prototype.getResidueStartRadius=function(t){var e=t.getSecondary();if(!e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?r.start:r.center:this.TUBE_RADIUS},Is.prototype.getResidueEndRadius=function(t){var e=t.getSecondary();if(null===e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?this.ARROW_END:r.center:this.TUBE_RADIUS},Is.prototype.getResidueRadius=function(t,e){var r=this.getResidueStartRadius(t);if(0===e)return r;var n=this.getResidueEndRadius(t);return 2===e?n:r.clone().lerp(n,e/2)},Is.prototype.calcStickRadius=function(t){return this.opts.radius},Is.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},Is.prototype.getTension=function(){return this.opts.tension},Is.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius,a=this.opts.depth;this.TUBE_RADIUS=new n(o,o),this.ARROW_END=new n(a,o);var s={},c=this.opts.ss;for(var l in c)s[l]={center:new n(a,c[l].width),start:new n(a,c[l].arrow)};return this.secCache=s,Ms.prototype.buildGeometry.call(this,t,e,r,i)};var Td=wf.selectors;gp.deriveClass(Ds,Ms,{isSurface:!0,surfaceNames:[]}),Ds.prototype.calcAtomRadius=function(t){return t.element.radius},Ds.prototype.getVisibilitySelector=function(){var t=null;if(""!==this.opts.subset){var e=Td.parse(this.opts.subset);e.error||(t=e.selector)}return t},gp.deriveClass(zs,Ds,{id:"QS",name:"Quick Surface",shortName:"Quick Surf",surfaceNames:["QuickSurfGeo"]}),zs.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()}},gp.deriveClass(Fs,Ds,{id:"SU",name:"Surface",shortName:"Surface",surfaceNames:["SASSESSurfaceGeo"]}),Fs.prototype._radScale=1,Fs.prototype._isVertexNormalsRendered=!1,Fs.prototype._isSurfaceTransparent=!1,Fs.prototype._clusterViaKMeans=0,Fs.prototype._excludeProbe=!1,Fs.prototype.calcAtomRadius=function(t){return t.element.radius},Fs.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}},gp.deriveClass(ks,Fs,{id:"SA",name:"Solvent Accessible Surface",shortName:"SAS"}),gp.deriveClass(Us,Fs,{id:"SE",name:"Solvent Excluded Surface",shortName:"SES"}),gp.deriveClass(Bs,Ds,{id:"CS",name:"Contact Surface",shortName:"Contact Surf",isSurface:!0,surfaceNames:["ContactSurfaceGeo"]}),Bs.prototype.getSurfaceOpts=function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},gp.deriveClass(Vs,Ms,{id:"TX",name:"Text mode",shortName:"Text",depGroups:["TextLabelsGeo"]}),Vs.prototype.getTemplateOptions=function(){return this.opts.template},Vs.prototype.getLabelOpts=function(){return _.merge(this.opts,{labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0})};var Pd=[],Ld={};!function(t){for(var e=0,r=t.length;e=256?e-256:e))%this.chainColors.length,this.chainColors[e]},getSecondaryColor:function(t,e){var r=this.secondaryColors[t];return r instanceof Object&&(r=r[e]),void 0===r?this.defaultSecondaryColor:r},getSequentialColor:function(t){var e=this.colors,r=e.length;return t<0?e[t%r+r]:e[t%r]},getGradientColor:function(t,e){var r=this.gradients[e];if(r){var n=r.length,i=t*(n-1),o=Math.floor(i),a=js(o+1,0,n-1);return o=js(o,0,n-1),function(t,e,r){var n=1-r;return n*(t>>16&255)+r*(e>>16&255)<<16|n*(t>>8&255)+r*(e>>8&255)<<8|n*(255&t)+r*(255&e)}(r[o],r[a],i-o)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}}).namedColorsArray,Id=Gs.prototype.namedColors,Od=0,Dd=Nd.length;Od=0?this.opts.carbon:this.palette.getElementColor(r)},Hs.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},gp.deriveClass(Xs,Ws,{id:"RT",name:"Residue Type",shortName:"Residue"}),Xs.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Xs.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},gp.deriveClass(Ys,Ws,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Ys.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ys.prototype.getResidueColor=function(t,e){var r=t._chain,n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},gp.deriveClass(qs,Ws,{id:"CH",name:"Chain",shortName:"Chain"}),qs.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},qs.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},gp.deriveClass($s,Ws,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),$s.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},$s.prototype.getResidueColor=function(t,e){if(t._type.flags&qi.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&qi.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},gp.deriveClass(Zs,Ws,{id:"UN",name:"Uniform",shortName:"Uniform"}),Zs.prototype.getAtomColor=function(t,e){return this.opts.color},Zs.prototype.getResidueColor=function(t,e){return this.opts.color},gp.deriveClass(Ks,Ws,{id:"CO",name:"Conditional",shortName:"Conditional"}),Ks.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},Ks.prototype.getResidueColor=function(t,e){for(var r=this._subsetCached,n=!0,i=t._atoms,o=0,a=i.length;or.max?1:0:(t._temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultElementColor},Js.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._temperature&&t._role===wf.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},gp.deriveClass(tc,Ws,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),tc.prototype.getAtomColor=function(t,e){var r=this.opts;if(t._occupancy&&r){var n=1-t._occupancy;return this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultElementColor},tc.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._occupancy&&t._role===wf.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},gp.deriveClass(ec,Ws,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),ec.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},ec.prototype.getResidueColor=function(t,e){var r=this.palette.defaultResidueColor;if(t._type.hydrophobicity){r=this.palette.getGradientColor((t._type.hydrophobicity- -4.5)/9,this.opts.gradient)}return r},gp.deriveClass(rc,Ws,{id:"MO",name:"Molecule",shortName:"Molecule"}),rc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},rc.prototype.getResidueColor=function(t,e){var r=t._molecule,n=e.getMoleculeCount();return n>1?this.palette.getGradientColor((r._index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)};var Xd=[],Yd={};!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 fp.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 fp.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,fp.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=em.parse(e.selector).selector,a=String(o);n.selector!==a&&(r.selectorString=n.selector=a,r.selector=o,r.markAtoms(this._complex),i=!0,fp.debug("rep["+t+"].selector changed to"+a))}if(e.mode){var s=e.mode;xl.isEqual(n.mode,s)||(n.mode=s,r.setMode(Rd.create(e.mode)),i=!0,fp.debug("rep["+t+"].mode changed to "+s),!r.mode.isSurface||"ultra"!==_p.now.resolution&&"high"!==_p.now.resolution||(fp.report('Surface resolution was changed to "medium" to avoid hang-ups.'),_p.now.resolution="medium"))}if(e.colorer){var c=e.colorer;xl.isEqual(n.colorer,c)||(n.colorer=c,r.colorer=qd.create(e.colorer),i=!0,fp.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var l=e.material;xl.isEqual(n.material,l)||(n.material=l,r.setMaterialPreset(Jd.get(e.material)),i=!0,fp.debug("rep["+t+"].material changed to"+l))}i&&(r.needsRebuild=!0)}return n},lc.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},lc.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<32;++e,t>>=1)if(0==(1&t))return e;return-1},lc.prototype.repAdd=function(t){if(this._reprList.length>=this.getMaxRepresentationCount())return-1;var e=this._getFreeReprIdx();if(e<0)return-1;var r=this.buildSelectorFromMask(1<=e||e<=1)){var r=this._reprList[t];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length)){this._reprList[t].show(!e)}},lc.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=em.chain(r),o=o?em.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=em.and(em.chain(s),em.residx(n(e[s]))),o=o?em.or(o,a):a);t.length>0&&(a=em.serial(n(t)),o=o?em.or(o,a):a),o||(o=em.none())}return o},lc.prototype.buildSelectorFromMask=function(t){var e=this._complex,r=[],n={},i=[];return e.forEachChain(function(e){e._mask&t&&r.push(e._name)}),e.forEachResidue(function(e){if(e._mask&t&&!(e._chain._mask&t)){var r=e._chain._name;r in n?n[r].push(e._index):n[r]=[e._index]}}),e.forEachAtom(function(e){e._mask&t&&!(e._residue._mask&t)&&i.push(e._serial)}),this._buildSelectorFromSortedLists(i,n,r)},lc.prototype.getSelectedComponent=function(){var t=1<=0):a<8+_.indices.length&&(this.cullFlag[a]=!0);var S=this.geometry.getAttribute("position"),M=0;for(a=0;a=3&&(h+=3*(r.indices.length-2));var p=0,f=new Uint16Array(h);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),c>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)}requestAnimationFrame(s)})},dc.prototype.mean=function(){return this._prof?this._prof.rawMean():0},dc.prototype.min=function(){return this._prof?this._prof.min():0},mc.prototype.abort=function(){this._agent.abort()},Xo(mc.prototype),mc.addCommonHandlers=function(t,e){e.error&&(t.addEventListener("error",function(){e.error("OnError() event fired while loading")}),t.addEventListener("abort",function(){e.error("OnAbort() event fired while loading")})),e.progress&&t.addEventListener("progress",function(t){t.lengthComputable?e.progress(t.loaded/t.total):e.progress()})},(gc.prototype=Object.create(mc.prototype)).constructor=gc,gc.prototype.load=function(t){var e=new FileReader;this._agent=e,t.ready&&e.addEventListener("load",function(e){t.ready(e.target.result)}),mc.addCommonHandlers(e,t),this._binary?e.readAsArrayBuffer(this._source):e.readAsText(this._source)},gc.canLoad=function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)},(vc.prototype=Object.create(mc.prototype)).constructor=vc,vc.prototype.load=function(t){var e=this._source,r=new XMLHttpRequest;this._agent=r,t.ready&&r.addEventListener("load",function(){200===r.status?t.ready(r.response):t.error&&t.error("HTTP "+r.status+" while fetching "+e)}),mc.addCommonHandlers(r,t),r.open("GET",e),this._binary?r.responseType="arraybuffer":r.responseType="text",r.send()},vc.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)},(yc.prototype=Object.create(mc.prototype)).constructor=yc,yc.prototype.load=function(t){t.progress&&t.progress(0),this._options.data&&null!==this._options.data&&""!==this._options.data||t.error&&t.error("No data found!"),t.progress&&t.progress(.5),this._options.dataType&&null!==this._options.dataType&&""!==this._options.dataType||t.error&&t.error("No dataType found!"),t.progress&&t.progress(1),t.ready&&t.ready(this._options.data)},yc.canLoad=function(t,e){var r=e.sourceType;if("string"!=typeof t)return!1;return 3===t.indexOf(":",0)||"message"===r};var om=[];!function(t){for(var e=0,r=t.length;e0&&e.addChain(h)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new cm(this._complex),this.assemblies.push(e))};var lm="\n".length,um=function(){function t(e){bp(this,t),this._data=e,this._start=0,this._next=-lm,this._end=e.length,this.next()}return wp(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+lm;this._start=t0?e:this._end}}]),t}(),hm=wf.Complex,pm=wf.Element,fm=wf.Helix,dm=wf.Sheet,mm=wf.Strand,gm=wf.Bond,vm=wf.Molecule;(bc.prototype=Object.create(sm.prototype)).constructor=bc,bc.canParse=function(t,e){return!!t&&("string"==typeof t&&(sm.checkDataTypeOptions(e,"pdb")||sm.checkDataTypeOptions(e,"pdb",".ent")))},bc.prototype._finalize=function(){this._fixBondsArray(),this._fixChains();var t=this._remarks[290];this._complex.symmetry=xl.isUndefined(t)?[]:t.matrices;var e=this._remarks[350];this._complex.structures=this._complex.structures.concat(xl.isUndefined(e)?[]:e.assemblies),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})},bc.prototype._finalizeMolecules=function(){var t,e={},r=this._complex._chains;for(t=0;te&&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)},bc.prototype._parseCOMPND=function(t){var e=t.readString(11,80),r=e.indexOf(":");if(this._compndCurrToken=r>0?e.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(e.substring(r+1,e.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=e.substring(r+1,e.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=e.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}};var ym={290:_c,350:xc};bc.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(xl.isUndefined(r)){var n=ym[e];xl.isFunction(n)&&(this._remarks[e]=r=new n(this._complex))}xl.isUndefined(r)||r.parse(t)},bc.prototype._parseHELIX=function(t){this._parseSTRUCTURE(t,[20,22,32,34],function(t){this._complex.addHelix(t)}.bind(this))},bc.prototype._parseSHEET=function(t){this._parseSTRUCTURE(t,[22,23,33,34],function(t){this._complex.addSheet(t)}.bind(this))},bc.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 dm(i,c),r(y)):y=_;var x=new mm(y,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,l,u);y.addStrand(x)}else r(y=new fm(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,o,a))},bc.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)},bc.prototype._parseTITLE=function(t){var e=this._complex.metadata;e.title=e.title||[];var r=t.readInt(9,10)||1;e.title[r-1]=t.readString(11,80).trim()};var _m={HEADER:bc.prototype._parseHEADER,"TITLE ":bc.prototype._parseTITLE,"ATOM ":bc.prototype._parseATOM,HETATM:bc.prototype._parseATOM,ENDMDL:bc.prototype._parseENDMDL,CONECT:bc.prototype._parseCONECT,COMPND:bc.prototype._parseCOMPND,REMARK:bc.prototype._parseREMARK,"HELIX ":bc.prototype._parseHELIX,"SHEET ":bc.prototype._parseSHEET,"ATOM 1":bc.prototype._parseATOM,"ATOM 2":bc.prototype._parseATOM,"ATOM 3":bc.prototype._parseATOM,"ATOM 4":bc.prototype._parseATOM,"ATOM 5":bc.prototype._parseATOM,"ATOM 6":bc.prototype._parseATOM,"ATOM 7":bc.prototype._parseATOM,"ATOM 8":bc.prototype._parseATOM,"ATOM 9":bc.prototype._parseATOM};bc.prototype.parseSync=function(){for(var t=new um(this._data),e=this._complex=new hm;!t.end();){var r=t.readString(1,6),n=_m[r];xl.isFunction(n)&&n.call(this,t),t.next()}if(this.hasOwnProperty("_abort"))throw new Error("Aborted");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");if(this.hasOwnProperty("_abort"))throw new Error("Aborted");return e};var xm=wf.Complex;(wc.prototype=Object.create(sm.prototype)).constructor=wc,wc.prototype.parseSync=function(){var t=this._complex=new xm;return this._complex=null,t},wc.canParse=function(t,e){return!!t&&("string"==typeof t&&sm.checkDataTypeOptions(e,"mol"))};var bm=wf.Complex,wm=wf.Element,Sm=wf.AtomName,Mm=wf.SGroup,Am=wf.Bond,Em={A:0,S:1,D:2,T:3};(Sc.prototype=Object.create(sm.prototype)).constructor=Sc,Sc.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\1&&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=Em[p];void 0!==d&&(l[h].order=d,"A"===p&&(l[h].type=Am.BondType.AROMATIC))}}s=n.length;for(var m=0;m0&&o.push(e)}),o},Sc.prototype._packLabel=function(t,e){return(e<<16)+t},Sc.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},Sc.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)}},Sc.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n1){var n=new bm;return n.joinComplexes(t),n.originalCML=t[0].originalCML,n}return 1===t.length?t[0]:new bm};var Cm=e(function(t,e){!function(t,r){r(e)}(0,function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t,i,o){var a=typeof t;if("string"===a){if(32>(s=r(t)))return i.setUint8(o,160|s),e(i,o+1,t),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,t),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,t),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,t),5+s}if(t instanceof Uint8Array){var s=t.byteLength,c=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),c.set(t,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),c.set(t,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),c.set(t,o+5),5+s}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return i.setUint8(o,203),i.setFloat64(o+1,t),9;if(t>=0){if(128>t)return i.setUint8(o,t),1;if(256>t)return i.setUint8(o,204),i.setUint8(o+1,t),2;if(65536>t)return i.setUint8(o,205),i.setUint16(o+1,t),3;if(4294967296>t)return i.setUint8(o,206),i.setUint32(o+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return i.setInt8(o,t),1;if(t>=-128)return i.setUint8(o,208),i.setInt8(o+1,t),2;if(t>=-32768)return i.setUint8(o,209),i.setInt16(o+1,t),3;if(t>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,t?195:194),1;if("object"===a){var l=0,u=Array.isArray(t);if(u)s=t.length;else{var h=Object.keys(t);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),l=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),l=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),l=5),u)for(p=0;s>p;p++)l+=n(t[p],i,o+l);else for(var p=0;s>p;p++){var f=h[p];l+=n(f,i,o+l),l+=n(t[f],i,o+l)}return l}throw new Error("Unknown type "+a)}function i(t){var e=typeof t;if("string"===e){if(32>(n=r(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var n,o=0;if(Array.isArray(t)){n=t.length;for(s=0;n>s;s++)o+=i(t[s])}else{var a=Object.keys(t);n=a.length;for(var s=0;n>s;s++){var c=a[s];o+=i(c)+i(t[c])}}if(16>n)return 1+o;if(65536>n)return 3+o;if(4294967296>n)return 5+o;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+e)}function o(t){var e=new ArrayBuffer(i(t));return n(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function s(t){return a(DataView,t)}function c(t){return a(Uint8Array,t)}function l(t){return a(Int8Array,t)}function u(t){return a(Int32Array,t,4)}function h(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)e[n]=t[i]<<8^t[i+1]<<0;return e}function p(t,e){var r=t.length/4;e||(e=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)e[n]=t[i]<<24^t[i+1]<<16^t[i+2]<<8^t[i+3]<<0;return e}function f(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=s(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return c(e)}function d(t,e,r){var n=t.length,i=1/e;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=t[o]*i;return r}function m(t,e,r){var n=t.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(t[i]*e);return r}function g(t,e){var r,n;if(!e){var i=0;for(r=0,n=t.length;n>r;r+=2)i+=t[r+1];e=new t.constructor(i)}var o=0;for(r=0,n=t.length;n>r;r+=2)for(var a=t[r],s=t[r+1],c=0;s>c;++c)e[o]=a,++o;return e}function v(t){if(0===t.length)return new Int32Array;var e,r,n=2;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]?(i[o]=t[e-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=t[t.length-1],i[o+1]=a,i}function y(t,e){var r=t.length;e||(e=new t.constructor(r)),r&&(e[0]=t[0]);for(var n=1;r>n;++n)e[n]=t[n]+e[n-1];return e}function _(t,e){var r=t.length;e||(e=new t.constructor(r)),e[0]=t[0];for(var n=1;r>n;++n)e[n]=t[n]-t[n-1];return e}function x(t,e){var r,n,i=t instanceof Int8Array?127:32767,o=-i-1,a=t.length;if(!e){var s=0;for(r=0;a>r;++r)t[r]o&&++s;e=new Int32Array(s)}for(r=0,n=0;a>r;){for(var c=0;t[r]===i||t[r]===o;)c+=t[r],++r;c+=t[r],++r,e[n]=c,++n}return e}function b(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r){0===(l=t[r])?++a:a+=l===n||l===i?2:l>0?Math.ceil(l/n):Math.ceil(l/i)}var s=e?new Int8Array(a):new Int16Array(a),c=0;for(r=0;o>r;++r){var l=t[r];if(l>=0)for(;l>=n;)s[c]=n,++c,l-=n;else for(;i>=l;)s[c]=i,++c,l-=i;s[c]=l,++c}return s}function w(t,e,r){return d(x(t,u(r)),e,r)}function S(t,e,r){var n=x(t,u(r));return function(t,e,r){return d(y(t,u(r)),e,r)}(n,e,function(t){return a(Float32Array,t,4)}(n))}function M(t,e,r){return b(function(t,e,r){return _(m(t,e),r)}(t,e),r)}function A(t){var e=s(t),r=e.getInt32(0),n=e.getInt32(4),i=t.subarray(8,12);return[r,t=t.subarray(12),n,i]}function E(t,e,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,t),a.setInt32(4,e),r&&o.set(r,8),o.set(n,12),o}function C(t){return E(2,t.length,void 0,c(t))}function T(t){return E(4,t.length,void 0,f(t))}function P(t,e){return E(5,t.length/e,f([e]),c(t))}function L(t){return E(6,t.length,void 0,f(v(t)))}function R(t){return E(8,t.length,void 0,f(function(t){return v(_(t))}(t)))}function N(t,e){return E(9,t.length,f([e]),f(function(t,e){return v(m(t,e))}(t,e)))}function I(t,e){return E(10,t.length,f([e]),function(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=s(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return c(e)}(M(t,e)))}function O(t){var e={};return V.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=T(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=C(t.bondOrderList)),e.xCoordList=I(t.xCoordList,1e3),e.yCoordList=I(t.yCoordList,1e3),e.zCoordList=I(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=I(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=R(t.atomIdList)),t.altLocList&&(e.altLocList=L(t.altLocList)),t.occupancyList&&(e.occupancyList=N(t.occupancyList,100)),e.groupIdList=R(t.groupIdList),e.groupTypeList=T(t.groupTypeList),t.secStructList&&(e.secStructList=C(t.secStructList)),t.insCodeList&&(e.insCodeList=L(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=R(t.sequenceIndexList)),e.chainIdList=P(t.chainIdList,4),t.chainNameList&&(e.chainNameList=P(t.chainNameList,4)),e}function D(t){function e(t){for(var e={},r=0;t>r;r++){e[o()]=o()}return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;var n=65535;if(e>n){for(var i=[],o=0;or;r++)e[r]=o();return e}function o(){var o,c,l=t[a];if(0==(128&l))return a++,l;if(128==(240&l))return c=15&l,a++,e(c);if(144==(240&l))return c=15&l,a++,i(c);if(160==(224&l))return c=31&l,a++,n(c);if(224==(224&l))return o=s.getInt8(a),a++,o;switch(l){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,r(c);case 197:return c=s.getUint16(a+1),a+=3,r(c);case 198:return c=s.getUint32(a+1),a+=5,r(c);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return c=s.getUint8(a+1),a+=2,n(c);case 218:return c=s.getUint16(a+1),a+=3,n(c);case 219:return c=s.getUint32(a+1),a+=5,n(c);case 220:return c=s.getUint16(a+1),a+=3,i(c);case 221:return c=s.getUint32(a+1),a+=5,i(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+l.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function z(t,e,r,n){switch(t){case 1:return function(t,e){var r=t.length;e||(e=new Float32Array(r/4));for(var n=s(e),i=s(t),o=0,a=0,c=r/4;c>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return e}(e);case 2:return l(e);case 3:return h(e);case 4:return p(e);case 5:return c(e);case 6:return g(p(e),new Uint8Array(r));case 7:return g(p(e));case 8:return function(t,e){return y(g(t),e)}(p(e));case 9:return function(t,e,r){return d(g(t,u(r)),e,r)}(p(e),p(n)[0]);case 10:return S(h(e),p(n)[0]);case 11:return d(h(e),p(n)[0]);case 12:return w(h(e),p(n)[0]);case 13:return w(l(e),p(n)[0]);case 14:return x(h(e));case 15:return x(l(e))}}function F(t,e){var r=(e=e||{}).ignoreFields,n={};return j.forEach(function(e){var i=!!r&&-1!==r.indexOf(e),o=t[e];i||void 0===o||(o instanceof Uint8Array?n[e]=z.apply(null,A(o)):n[e]=o)}),n}function k(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function U(t,e){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r;return r=t instanceof Uint8Array?D(t):t,F(r,e)}function B(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=U(i.response);r(t)}catch(t){n(t)}},!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",e+t.toUpperCase()),i.send()}var V=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],j=V.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),G="//mmtf.rcsb.org/v1.0/",W=G+"full/",H=G+"reduced/";t.encode=function(t){return o(O(t))},t.decode=U,t.traverse=function(t,e,r){var n,i,o,a,s,c,l=(r=r||{}).firstModelOnly,u=e.onModel,h=e.onChain,p=e.onGroup,f=e.onAtom,d=e.onBond,m=0,g=0,v=0,y=0,_=0,x=-1,b=t.chainNameList,w=t.secStructList,S=t.insCodeList,M=t.sequenceIndexList,A=t.atomIdList,E=t.bFactorList,C=t.altLocList,T=t.occupancyList,P=t.bondAtomList,L=t.bondOrderList;for(n=0,i=t.chainsPerModel.length;i>n&&!(l&&m>0);++n){var R=t.chainsPerModel[m];for(u&&u({chainCount:R,modelIndex:m}),o=0;R>o;++o){var N=t.groupsPerChain[g];if(h){var I=k(t.chainIdList.subarray(4*g,4*g+4)),O=null;b&&(O=k(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var D=t.groupList[t.groupTypeList[v]],z=D.atomNameList.length;if(p){var F=null;w&&(F=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:F,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){B(t,W,e,r)},t.fetchReduced=function(t,e,r){B(t,H,e,r)},t.version="v1.1.0dev",t.fetchUrl=W,t.fetchReducedUrl=H,t.encodeMsgpack=o,t.encodeMmtf=O,t.decodeMsgpack=D,t.decodeMmtf=F})}),Tm=wf.Complex,Pm=wf.Chain,Lm=wf.Atom,Rm=wf.AtomName,Nm=wf.Element,Im=wf.Helix,Om=wf.Sheet,Dm=wf.Strand,zm=wf.Bond,Fm=wf.Assembly,km=wf.Molecule;Mc.prototype.constructor=Mc,Mc.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,zm.BondType.UNKNOWN,!0)}},Ac.prototype._updateSecStructure=function(t,e,r){if(!xl.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof Im||this._ssStruct instanceof Dm)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof Im||this._ssStruct instanceof Dm)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!xl.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var n=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:n=new Im(0,"",e,null,[3,-1,1,-1,5][this._ssType],"",0),t._helices.push(n);break;case 3:var i=new Om("",0);t._sheets.push(i),n=new Dm(i,e,null,0);break;default:n={type:"mmtf"+this._ssType}}this._ssStruct=n,e._secondary=n}},Ac.prototype._updateMolecules=function(t){var e=t.entityList;if(e)for(var r=t.chainsPerModel[0],n=0;n=r)){var l=this._complex._chains[c];a=a.concat(l._residues.slice())}}var u=new km(this._complex,i.description,n+1);u._residues=a,this._complex._molecules[n]=u}},Ac.prototype._traverse=function(t){var e=this,r={onModel:function(t){e._onModel(t)},onChain:function(t){e._onChain(t)},onGroup:function(t){e._onGroup(t)},onAtom:function(t){e._onAtom(t)},onBond:function(t){e._onBond(t)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,Cm.traverse(t,r),this._updateSecStructure(this._complex),this._updateMolecules(t)},Ac.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)}}}},Pc._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=Sh.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*(_p.now.inversePanning?-1:1),this.camera.translateX(a*i),this.camera.translateY(a*o),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},Fc.prototype.reset=function(){this._state=tg.NONE,this.object.quaternion.copy(new c(0,0,0,1))},Fc.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===tg.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===tg.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?tg.TRANSLATE:tg.ROTATE}else 2===t.button&&(this._state=tg.TRANSLATE_PIVOT);this._state===tg.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==tg.TRANSLATE&&this._state!==tg.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},Fc.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==tg.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case tg.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 tg.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case tg.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},Fc.prototype.mousewheel=function(t){if(!1!==this.enabled&&_p.now.zooming&&this._state===tg.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})}},Fc.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==tg.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=tg.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Fc.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=tg.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=tg.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=tg.NONE}},Fc.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==tg.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case tg.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 tg.SCALE_PAN:if(_p.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(_p.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"})}}},Fc.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()}},Fc.prototype.getKeyBindObject=function(){return window.top},Fc.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new l;if(_p.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)}}},jc.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=Vc((268435200&g)>>>8>>0),_=Vc(((255&g)<<12|(4293918720&m)>>>20)>>0),x=Vc((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(Bc(p,a))}this._secondaryData=l,this._data=u},jc.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},jc.prototype.needsColorUpdate=function(t){return t instanceof $s},jc.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},jc.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},jc.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)},jc.prototype.disableEvents=function(){this._callbacks=null},jc.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}}(),jc.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},Gc.prototype.type="__",Gc.prototype.identify=function(){var t={type:this.type,params:this.params},e=gp.objectsDiff(this.opts,_p.now.modes[this.id]);return xl.isEmpty(e)||(t.opts=e),t},Gc.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+gp.compareOptionsWithDefaults(this.opts,_p.defaults.objects[this.type])},Gc.prototype.getGeometry=function(){return this._mesh},Gc.prototype.destroy=function(){this._mesh&&Pf.destroyObject(this._mesh)},gp.deriveClass(Wc,Gc,{type:"line"}),Wc.prototype.constructor=Wc,Wc.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},Wc.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 yd.Line(e,new jo({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new X(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(t,e){},this._mesh=this._line;var r=t.getTransforms();r.length>0&&(this._mesh=new _e,this._mesh.add(this._line),Pf.applyTransformsToMeshes(this._mesh,r))},Wc.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 og="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",ag="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",sg=Oh.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new n(512,512)},opacity:{type:"f",value:1}}]),cg="// 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",lg=Oh.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)}}]),ug="#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}",hg="#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",pg="#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}",fg=Oh.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)}}]),dg=Oh.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}}]),mg={AOMaterial:function(t){return new Q({uniforms:Yc(t,fg),vertexShader:og,fragmentShader:ug,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new Q({uniforms:Yc(t,dg),vertexShader:og,fragmentShader:hg,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new Q({uniforms:Yc(t,dg),vertexShader:og,fragmentShader:pg,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",vg=Oh.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);$c.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};Zc.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},Zc.prototype.isMoving=function(){return this._isMoving},Zc.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},Zc.prototype.start=function(){this._startTime=Date.now();var t=_p.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},Zc.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}},Zc.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},Zc.prototype.createView=function(){return new $c};var yg=new Zc,_g=_p.now.fbxprec,xg='; 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',bg='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',wg=null;Qc.prototype.queue=[],Qc.prototype.busy=!1,Qc.prototype.add=function(t,e,r,n){this.queue.push([t,e,r,n]),this.busy||this.next()},Qc.prototype.next=function(){var t=this.queue.shift(),e=this;t&&!e.busy&&(this.busy=!0,function(t,e,r,n,i){wg.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))},Kc)},Kc)}(t[0],t[1],t[2],t[3],function(){e.busy=!1,e.next()}))};Xo(il.prototype),il.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e,r)):i.renderer.renderDummyQuad(r),i.renderer.renderScreenQuadFromTex(r.texture,.6,n),t.uniforms.srcTex.value=r.texture,t.uniforms.srcTexSize.value.set(r.width,r.height),i.renderer.renderScreenQuad(t,n)}}(),cl.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)},cl.prototype._renderVolume=function(){var t,e=new im.BackFacePosMaterial,r=new im.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(Pf.LAYERS.VOLUME_BFPLANE),h.renderer.render(h.scene,a,c),a.layers.set(Pf.LAYERS.VOLUME),h.scene.overrideMaterial=e,h.renderer.render(h.scene,a,c),a.layers.set(Pf.LAYERS.VOLUME),h.scene.overrideMaterial=r,h.renderer.render(h.scene,a,l),h.scene.overrideMaterial=null,a.layers.set(Pf.LAYERS.DEFAULT),i.getInverse(p.matrixWorld),jo.prototype.uberOptions.world2colorMatrix.multiplyMatrices(n,i),this._setUberMaterialValues({colorFromPos:!0}),h.renderer.render(h.scene,a,u),this._setUberMaterialValues({colorFromPos:!1});var f=p.material;f.uniforms._BFRight.value=c.texture,f.uniforms._FFRight.value=l.texture,f.uniforms._WFFRight.value=u.texture,a.layers.set(Pf.LAYERS.VOLUME),h.renderer.render(h.scene,a,s),a.layers.set(Pf.LAYERS.DEFAULT)}}}(),cl.prototype._renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(Pf.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(Pf.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(Pf.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(Pf.LAYERS.DEFAULT)},cl.prototype._performFXAA=function(){var t=new Xc;return function(e,r){if(void 0!==e&&void 0!==r){var n=this._gfx;n.renderer.setClearColor(_p.now.themes[_p.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)}}}(),cl.prototype._performAO=function(){var t=new mg.AOMaterial,e=new mg.HorBilateralBlurMaterial,r=new mg.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,Yu,Ou,300,Au,Au,Tu,Tu,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*Sh.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=_p.now.debug.ssaoKernelRadius*g.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=_p.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)}}}(),cl.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(Tg.COMPLEX),this._resetObjects(),this._gfx&&(Pf.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},cl.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},cl.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(Tg.COMPLEX),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},cl.prototype.load=function(t,e){var r=this;r._loader&&r._loader.cancel(),r.dispatchEvent({type:"load",options:e}),t instanceof File&&t.name.match(/.man$/i)?this._fileSourceAnim=al(t):this._fileSource=al(t),e&&e.mdFile&&(this._fileSourceAnim=e.mdFile),this.settings.now.use.multiFile||e&&e.animation||this.reset(!0),r._loader=new Ci,r._loader.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),r._spinner.spin(this._container);var n=function(t){return r._loader=null,r._spinner.stop(),r._refreshTitle(),t};return function(t,e,r,n){return new Promise(function(i,o){if(e=e||{},t instanceof File&&t.name.match(/.man$/i)&&(e.binary=!0,e.animation=!0),t instanceof File&&(t.name.match(/.mmtf$/i)||t.name.match(/.ccp4$/i))?e.binary=!0:xl.isString(t)&&t.match(/.mmtf$/i)&&(e.binary=!0),!e.mdFile&&!e.fileType&&"string"==typeof t){var a=t.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/);if(a){var s=a[2].trim(),c=a[1];switch(c){case"pubchem":case"pubchem+json":c="pubchem+json",t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+encodeURIComponent(s)+"/JSON?record_type=3d",e.sourceType="url",e.fileName=s+".json";break;default:if(s.match(/^\w{4}$/i))switch(c=c||"pdb"){case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s,e.sourceType="url";break;case"cif":case"pdb":t="http://files.rcsb.org/view/"+s+"."+c,e.sourceType="url"}else c=void 0}c&&(e.fileType=c)}}"mmtf"===e.fileType&&(e.binary=!0);var l=Qm.loaders.create(n,t,e),u=xl.get(e,"preset.expression");if(!xl.isUndefined(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit","draft.waterBondingHack"],p=0,f=h.length;p0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},cl.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})}},cl.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},cl.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})},cl.prototype.setNeedRender=function(){this._needRender=!0},cl.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"}))},cl.prototype._setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},cl.prototype.applyPreset=function(t){for(var e=_p.now.presets,r=[t||_p.defaults.preset,_p.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(Tg.FRAGMENT),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},cl.prototype._applyFragmentEdit=function(){if(this._editMode===Tg.FRAGMENT){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new l(0,0,0)}},cl.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"})},cl.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()})},cl.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(Sh.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*Sh.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},cl.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);gp.shotDownload(n,t)},cl.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"):_p.now.preset!==_p.defaults.preset&&(r.preset=_p.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);xl.isEmpty(l)||(e.settings=l)}return e},cl.prototype.get=function(t,e){return _p.get(t,e)},cl.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*_p.now.draft.clipPlaneFactor,_p.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=Zp.readFileSync(Kp.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}),Ng=Rg.parser,Ig=(Rg.Parser,Rg.parse,Rg.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"]}}),Og={$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(Hd.get(_p.now.palette).namedColors).sort().join("\n")}}},Dg={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},zg={$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:Ig,c:Og,mt:Dg},Fg={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Ig,colorers:Og},kg={$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:zg},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:zg},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:Ig},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Og},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Dg},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:Fg},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:Fg},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset []","Reset current representation or set preset to "],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit []","Change current biological structure view. Zero value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view []","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [] [(x|y|z) []]...","Rotate scene"]},scale:{$help:["scale ","Scale scene"]},select:{$help:["select [as ]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within of as ","Build within named selector"," DISTANCE "," SELECTOR_STRING "," SELECTOR_NAME "]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [ []]","Make a screenshot of the scene"," WIDTH in pixels"," HEIGHT in pixels, equal to WIDTH by default"]},line:{$help:["line [=]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj ","Remove scene object by its index. Indices could be obtained by command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]},file_list:{$help:["file_list [(|FILE_NAME)] [-f=]","Report registered files on server or presets in file if defined FILE_ID or FILE_NAME"," also you can use -f flag for fast search"," entity by starting part of name"]},file_register:{$help:["file_register ","Try register current opened file to server"]},file_delete:{$help:["file_delete (|FILE_NAME) [-f]","Delete file from server"," if -f not set then file will be deleted"," only when it has not got any presets in it"," if -f set then file will be deleted anyway"]},preset_add:{$help:["preset_add ","Create new preset from current viewer state"," to current opened file on server"]},preset_delete:{$help:["preset_delete (|)","Delete preset from server"]},preset_update:{$help:["preset_update <(|)","Update due the current viewer state"]},preset_rename:{$help:["preset_rename (|) ","Rename preset"]},preset_open:{$help:["preset_open (|)","Load preset"]},create_scenario:{$help:["create_scenario "," Creates scenario context for future work with them"]},reset_scenario:{$help:["reset_scenario"," Clear current scenario context"]},add_scenario_item:{$help:["add_scenario_item"," pdb=( | )"," prst=(|)"," delay="," desc=\n"," Add item to context and update scenario on server"," Pay attention that order of arguments is important"]},delete_scenario:{$help:["delete_scenario (|)"," Deletes scenario from server"]},list_scenario:{$help:["list_scenario [-e [|]]"," Report scenario list, when -e is set reports expanded"," If set -e then reports only requested scenario"]}},Ug=function(){function t(){bp(this,t)}return wp(t,[{key:"createSelectorFromNode",value:function(t){return hl(t)}}]),t}(),Bg=cl.chem.selectors,Vg=cl.modes,jg=cl.colorers,Gg=cl.materials,Wg=cl.palettes,Hg=cl.options,Xg=cl.settings,Yg=function(){var t=new function(){};return function(){return t}}();pl.prototype.get=function(t){return this.representationMap[t]||this.representationID[t]||""},pl.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"},pl.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])}},pl.prototype.clear=function(){this.representationMap={},this.representationID={}};var qg=new pl;fl.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},fl.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},fl.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 "'+xp(xl.get(Xg.defaults,t))+'"'};if("theme"===t){for(var i=Object.keys(Xg.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)})},gl.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)}},gl.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=xl.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)},gl.prototype.createScenario=function(t){this.scenarioContext=new ml(t)},gl.prototype.resetScenario=function(){this.scenarioContext=new ml},gl.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)},gl.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(xl.isString(s))this.requestPdbID(t,s,function(t){t>=0&&(a[3]=t,o.addScenarioItem.apply(o,a))},i);else if(xl.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)}},gl.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)},gl.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},gl.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)},gl.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 Zg=new gl;yl.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},yl.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},yl.prototype.toJSO=function(t,e,r){for(var n={},i=this._values,o=0,a=i.length;o0},cl.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={};e.success=!1;try{Ng.parse(t),e.success=!0}catch(t){e.error=t.message,Ng.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},cl.JSONConverter=Ug,Ng.yy=Kg,Ng.yy.parseError=Ng.parseError,cl}); //# sourceMappingURL=Miew.min.js.map diff --git a/dist/Miew.module.js b/dist/Miew.module.js index 1a2a938f..56a357dc 100644 --- a/dist/Miew.module.js +++ b/dist/Miew.module.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.7 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.8 Copyright (c) 2015-2017 EPAM Systems, Inc. */ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -64976,7 +64976,7 @@ Residue$1.prototype._finalize = function () { * @exports Chain * @constructor */ -function Chain(complex, name) { +function Chain$1(complex, name) { this._complex = complex; this._name = name; this._mask = 1 | 0; @@ -64988,15 +64988,15 @@ function Chain(complex, name) { this.maxSequence = Number.NEGATIVE_INFINITY; } -Chain.prototype.getComplex = function () { +Chain$1.prototype.getComplex = function () { return this._complex; }; -Chain.prototype.getName = function () { +Chain$1.prototype.getName = function () { return this._name; }; -Chain.prototype.getResidues = function () { +Chain$1.prototype.getResidues = function () { return this._residues; }; @@ -65006,7 +65006,7 @@ Chain.prototype.getResidues = function () { * @param {string} iCode insertion code * @returns {*} Residue or null if not found */ -Chain.prototype.findResidue = function (seqNum, iCode) { +Chain$1.prototype.findResidue = function (seqNum, iCode) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -65019,7 +65019,7 @@ Chain.prototype.findResidue = function (seqNum, iCode) { return null; }; -Chain.prototype._finalize = function () { +Chain$1.prototype._finalize = function () { var residues = this._residues; var prev = null; @@ -65043,7 +65043,7 @@ Chain.prototype._finalize = function () { } }; -Chain.prototype.updateToFrame = function (frameData) { +Chain$1.prototype.updateToFrame = function (frameData) { var residues = this._residues; var prev = null; var prevData = null; @@ -65072,7 +65072,7 @@ Chain.prototype.updateToFrame = function (frameData) { * @param {string} iCode - Insertion code. * @returns {Residue} - Newly created residue instance. */ -Chain.prototype.addResidue = function (name, sequence, iCode) { +Chain$1.prototype.addResidue = function (name, sequence, iCode) { var type = this._complex.getResidueType(name); if (type === null) { type = this._complex.addResidueType(name); @@ -65093,18 +65093,18 @@ Chain.prototype.addResidue = function (name, sequence, iCode) { return residue; }; -Chain.prototype.getResidueCount = function () { +Chain$1.prototype.getResidueCount = function () { return this._residues.length; }; -Chain.prototype.forEachResidue = function (process) { +Chain$1.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Chain.prototype.collectMask = function () { +Chain$1.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -68178,7 +68178,7 @@ Complex.prototype.getAtomByFullname = function (fullName) { * @returns {Chain} - Newly created chain. */ Complex.prototype.addChain = function (name) { - var result = new Chain(this, name); + var result = new Chain$1(this, name); this._chains.push(result); // TODO: keep chains in dictionary with an (ordered?) array of keys return result; }; @@ -69780,7 +69780,7 @@ VoxelWorld.prototype._forEachAtomWithinDistFromGroup = function (forEachAtom, di * @exports Molecule * @constructor */ -function Molecule(complex, name, index) { +function Molecule$1(complex, name, index) { this._complex = complex; this._name = name || ''; this._residues = []; @@ -69788,30 +69788,30 @@ function Molecule(complex, name, index) { this._index = index || -1; // start with 1 } -Molecule.prototype.getComplex = function () { +Molecule$1.prototype.getComplex = function () { return this._complex; }; -Molecule.prototype.getName = function () { +Molecule$1.prototype.getName = function () { return this._name; }; -Molecule.prototype.getResidues = function () { +Molecule$1.prototype.getResidues = function () { return this._residues; }; -Molecule.prototype.getIndex = function () { +Molecule$1.prototype.getIndex = function () { return this._index; }; -Molecule.prototype.forEachResidue = function (process) { +Molecule$1.prototype.forEachResidue = function (process) { var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { process(residues[i]); } }; -Molecule.prototype.collectMask = function () { +Molecule$1.prototype.collectMask = function () { var mask = 0xffffffff; var residues = this._residues; for (var i = 0, n = residues.length; i < n; ++i) { @@ -69827,7 +69827,7 @@ var chem = { Bond: Bond, Residue: Residue$1, ResidueType: ResidueType, - Chain: Chain, + Chain: Chain$1, Helix: Helix, Strand: Strand, Sheet: Sheet, @@ -69837,7 +69837,7 @@ var chem = { Volume: Volume, VoxelWorld: VoxelWorld, selectors: selectors$1, - Molecule: Molecule + Molecule: Molecule$1 }; /** @@ -81151,14 +81151,14 @@ VolumeMesh.prototype._updateVertices = function () { var cornerMark = [0, 0, 0, 0, 0, 0, 0, 0]; var edgeMark = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; - var curEdgeIdx = 0; var curEdge = new Vector3(); + var curEdgeInter = null; function CheckX() { if (norm.x === 0) return 0; var x = -(norm.dot(curEdge) + D) / norm.x; if (-size.x <= x && x <= size.x) { - edgeIntersections[curEdgeIdx].set(x, curEdge.y, curEdge.z); + curEdgeInter.set(x, curEdge.y, curEdge.z); if (x === size.x) return 2; if (x === -size.x) return -2; return 1; @@ -81170,7 +81170,7 @@ VolumeMesh.prototype._updateVertices = function () { if (norm.y === 0) return 0; var y = -(norm.dot(curEdge) + D) / norm.y; if (-size.y <= y && y <= size.y) { - edgeIntersections[curEdgeIdx].set(curEdge.x, y, curEdge.z); + curEdgeInter.set(curEdge.x, y, curEdge.z); if (y === size.y) return 2; if (y === -size.y) return -2; return 1; @@ -81182,7 +81182,7 @@ VolumeMesh.prototype._updateVertices = function () { if (norm.z === 0) return 0; var z = -(norm.dot(curEdge) + D) / norm.z; if (-size.z <= z && z <= size.z) { - edgeIntersections[curEdgeIdx].set(curEdge.x, curEdge.y, z); + curEdgeInter.set(curEdge.x, curEdge.y, z); if (z === size.z) return 2; if (z === -size.z) return -2; return 1; @@ -81191,21 +81191,24 @@ VolumeMesh.prototype._updateVertices = function () { } // for each edge - for (curEdgeIdx = 0; curEdgeIdx < 12; ++curEdgeIdx) { - curEdge.set(edges[curEdgeIdx][2], edges[curEdgeIdx][3], edges[curEdgeIdx][4]); + for (var curEdgeIdx = 0; curEdgeIdx < 12; ++curEdgeIdx) { + var curEdgeSource = edges[curEdgeIdx]; + curEdgeInter = edgeIntersections[curEdgeIdx]; + + curEdge.set(curEdgeSource[2], curEdgeSource[3], curEdgeSource[4]); curEdge.multiply(size); // calculate intersection point var flag = 0; - if (edges[curEdgeIdx][2] === 0) flag = CheckX(); - if (edges[curEdgeIdx][3] === 0) flag = CheckY(); - if (edges[curEdgeIdx][4] === 0) flag = CheckZ(); + if (curEdgeSource[2] === 0) flag = CheckX(); + if (curEdgeSource[3] === 0) flag = CheckY(); + if (curEdgeSource[4] === 0) flag = CheckZ(); // mark corresponding corner (if plane cuts through one) if (flag === -2) { - cornerMark[edges[curEdgeIdx][0]] = 1; + cornerMark[curEdgeSource[0]] = 1; } else if (flag === 2) { - cornerMark[edges[curEdgeIdx][1]] = 1; + cornerMark[curEdgeSource[1]] = 1; } else if (flag === 0) { // edge is not intersected by the plane (doesn't produce a vertex) edgeMark[curEdgeIdx] = 0; @@ -82158,7 +82161,7 @@ var Helix$2 = chem.Helix; var Sheet$2 = chem.Sheet; var Strand$2 = chem.Strand; var Bond$2 = chem.Bond; -var Molecule$2 = chem.Molecule; +var Molecule$3 = chem.Molecule; var TAG_LENGTH = 6; @@ -82266,7 +82269,7 @@ PDBParser.prototype._finalizeMolecules = function () { var chain = chainDict[name]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$2(this._complex, m._name, i + 1); + var molecule = new Molecule$3(this._complex, m._name, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -82953,9 +82956,8 @@ CMLParser.prototype._selectComponents = function (text) { } var atom; - var i = 0; var count = atoms.length; - for (i = 0; i < count; i++) { + for (var i = 0; i < count; i++) { atom = atoms[i]; atom.edges = []; } @@ -82972,8 +82974,8 @@ CMLParser.prototype._selectComponents = function (text) { count = localBond.length; self._rebuidBondIndexes(atoms, localBond); - function addCurrBond() { - bond = localBond[i]; + function addCurrBond(index) { + bond = localBond[index]; atom = atoms[bond.start]; if (!atom) { return false; @@ -82987,33 +82989,33 @@ CMLParser.prototype._selectComponents = function (text) { return true; } - for (i = 0; i < count; i++) { - if (!addCurrBond()) { + for (var _i = 0; _i < count; _i++) { + if (!addCurrBond(_i)) { //ignore invalid bond continue; } var orderAttr = bond.xmlNode.getAttribute('order'); var tc = parseInt(orderAttr, 10); // the default bond order is unknown - localBond[i].order = 0; - localBond[i].type = Bond$3.BondType.UNKNOWN; + localBond[_i].order = 0; + localBond[_i].type = Bond$3.BondType.UNKNOWN; if (tc > 1) { - localBond[i].order = tc; + localBond[_i].order = tc; } else { // another option - bond order is a string var order = cOrderCharCodes[orderAttr]; if (order !== undefined) { - localBond[i].order = order; + localBond[_i].order = order; if (orderAttr === 'A') { - localBond[i].type = Bond$3.BondType.AROMATIC; + localBond[_i].type = Bond$3.BondType.AROMATIC; } } } } count = atoms.length; - for (i = 0; i < count; i++) { - atom = atoms[i]; + for (var _i2 = 0; _i2 < count; _i2++) { + atom = atoms[_i2]; atom.edges.sort(); } @@ -83340,7 +83342,7 @@ var mmtf = createCommonjsModule(function (module, exports) { }); var Complex$5 = chem.Complex; -var Chain$2 = chem.Chain; +var Chain$3 = chem.Chain; var Atom$3 = chem.Atom; var AtomName$3 = chem.AtomName; var Element$5 = chem.Element; @@ -83349,7 +83351,7 @@ var Sheet$3 = chem.Sheet; var Strand$3 = chem.Strand; var Bond$4 = chem.Bond; var Assembly$3 = chem.Assembly; -var Molecule$3 = chem.Molecule; +var Molecule$4 = chem.Molecule; function ArrayComparator(original) { this._original = Array.from(original); @@ -83421,7 +83423,7 @@ MMTFParser.prototype._onChain = function (chainData) { return; } - var chain = new Chain$2(this._complex, chainData.chainName); + var chain = new Chain$3(this._complex, chainData.chainName); this._complex._chains[chainData.chainIndex] = chain; chain._index = chainData.chainIndex; }; @@ -83540,7 +83542,7 @@ MMTFParser.prototype._updateMolecules = function (mmtfData) { var chain = this._complex._chains[chainIndex]; residues = residues.concat(chain._residues.slice()); } - var molecule = new Molecule$3(this._complex, entity.description, i + 1); + var molecule = new Molecule$4(this._complex, entity.description, i + 1); molecule._residues = residues; this._complex._molecules[i] = molecule; } @@ -83777,7 +83779,7 @@ var Helix$4 = chem.Helix; var Sheet$4 = chem.Sheet; var Strand$4 = chem.Strand; var Assembly$4 = chem.Assembly; -var Molecule$4 = chem.Molecule; +var Molecule$5 = chem.Molecule; var cRequiredAtomFields = ['auth_seq_id', 'Cartn_x', 'Cartn_y', 'Cartn_z', 'label_atom_id']; @@ -83906,7 +83908,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$4(complex, molecule.name, i + 1); + molecules[i] = new Molecule$5(complex, molecule.name, i + 1); molecules[i]._residues = molecule.residues; } }; @@ -87236,7 +87238,7 @@ Cookies.prototype._exists = function (key) { return document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)')); }; -/* global "0.7.7":false */ +/* global "0.7.8":false */ ////////////////////////////////////////////////////////////////////////////// @@ -87245,6 +87247,8 @@ Cookies.prototype._exists = function (key) { var selectors = chem.selectors; var Atom = chem.Atom; var Residue = chem.Residue; +var Chain = chem.Chain; +var Molecule = chem.Molecule; var EDIT_MODE = { COMPLEX: 0, COMPONENT: 1, FRAGMENT: 2 }; @@ -87753,7 +87757,7 @@ Miew$1.prototype._addVisual = function (visual) { */ Miew$1.prototype._removeVisual = function (visual) { var name = ''; - var obj = visual; + var obj = null; if (visual instanceof Visual) { name = visual.name; obj = visual; @@ -87762,7 +87766,7 @@ Miew$1.prototype._removeVisual = function (visual) { obj = this._visuals[name]; } - if (!this._visuals.hasOwnProperty(name) || this._visuals[name] !== obj) { + if (!obj || !this._visuals.hasOwnProperty(name) || this._visuals[name] !== obj) { return; } @@ -89554,17 +89558,21 @@ Miew$1.prototype._updateInfoPanel = function () { aName = an.getString(); } var location = atom._location !== 32 ? String.fromCharCode(atom._location) : ''; // 32 is code of white-space - secondLine = atom.element.fullName + ' #' + atom._serial + location + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim() + '.'; + secondLine = atom.element.fullName + ' #' + atom._serial + location + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim() + '.'; if (typeof aName === 'string') { // add atom name to second line in plain text form secondLine += aName; } - coordLine = 'Coord: (' + atom._position.x.toFixed(2).toString() + ', ' + atom._position.y.toFixed(2).toString() + ', ' + atom._position.z.toFixed(2).toString() + ')'; + 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) { residue = this._lastPick; - secondLine = residue._type._fullName + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim(); + secondLine = residue._type._fullName + ': ' + residue._chain._name + '.' + residue._type._name + residue._sequence + residue._icode.trim(); + } else if (this._lastPick instanceof Chain) { + secondLine = 'chain ' + this._lastPick._name; + } else if (this._lastPick instanceof Molecule) { + secondLine = 'molecule ' + this._lastPick._name; } info.appendChild(document.createTextNode(firstLine)); @@ -90632,7 +90640,7 @@ function _parseData(data, opts, master, context) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.7" !== 'undefined' && "0.7.7" || '0.0.0-dev'; +Miew$1.prototype.VERSION = typeof "0.7.8" !== 'undefined' && "0.7.8" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew$1, /** @lends Miew */{ @@ -90821,19 +90829,19 @@ case 26: this.$ = yy.echo(yy.utils.listSelector(yy.miew, yy.Context)); break; case 27: -this.$ = yy.miew.select(yy.utils.checkArg($$[$0-1], $$[$0], true)); +this.$ = yy.miew.select(yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0], true)); break; case 28: -this.$ = yy.Context[$$[$0].toLowerCase()] = yy.utils.checkArg($$[$0-3], $$[$0-2], true); yy.miew.select(yy.Context[$$[$0].toLowerCase()]); +this.$ = yy.Context[$$[$0].toLowerCase()] = yy.utils.checkArg($$[$0-3].toLowerCase(), $$[$0-2], true); yy.miew.select(yy.Context[$$[$0].toLowerCase()]); break; case 29: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {selector : yy.utils.checkArg($$[$0-1], $$[$0])}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {selector : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0])}); break; case 30: this.$ = yy.Context[$$[$0].toLowerCase()] = yy.miew.within(yy.utils.checkArg("select", $$[$0-2], true), Number($$[$0-4])); break; case 31: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {material : yy.utils.checkArg($$[$0-1], $$[$0].toUpperCase())}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {material : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; case 34: this.$ = yy.echo(yy.miew.view()); @@ -91007,16 +91015,16 @@ case 114: this.$ = yy.miew.rep($$[$0-1], $$[$0]); yy.miew.repCurrent($$[$0-1]); break; case 115: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : yy.utils.checkArg($$[$0-1], $$[$0].toUpperCase())}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; case 116: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : new Array(yy.utils.checkArg($$[$0-2], $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {mode : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; case 117: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : yy.utils.checkArg($$[$0-1], $$[$0].toUpperCase())}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : yy.utils.checkArg($$[$0-1].toLowerCase(), $$[$0].toUpperCase())}); break; case 118: -this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : new Array(yy.utils.checkArg($$[$0-2], $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); +this.$ = yy.miew.rep(yy.miew.repCurrent(), {colorer : new Array(yy.utils.checkArg($$[$0-2].toLowerCase(), $$[$0-1].toUpperCase()), $$[$0].toJSO(yy.utils, $$[$0-2], $$[$0-1].toUpperCase()))}); break; case 119: this.$ = Number(yy.representations.get($$[$0])); @@ -92246,9 +92254,11 @@ CLIUtils.prototype.checkArg = function (key, arg, modificate) { 'materials': materials$1 }; - var modificator = key; - while (modificator !== undefined && modificator[modificator.length - 1] !== 's') { - modificator = keyRemap(modificator); + var modificator = key, + temp = void 0; + while (modificator !== temp) { + temp = modificator; + modificator = keyRemap(temp); } if (modificators[modificator].get(arg) === undefined) { diff --git a/package.json b/package.json index 66e2a8ac..8a403c04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miew", - "version": "0.7.7", + "version": "0.7.8", "description": "Miew - 3D Molecular Viewer", "author": "EPAM Systems, Inc.", "main": "dist/Miew.js", diff --git a/sonar-project.properties b/sonar-project.properties index f736cf47..bcb9f1f7 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.7 +sonar.projectVersion=0.7.8 sonar.links.homepage=https://github.com/epam/miew sonar.links.ci=https://travis-ci.org/epam/miew