diff --git a/.github/workflows/build-extension.yml b/.github/workflows/build-extension.yml index d2189713..d08d57ae 100644 --- a/.github/workflows/build-extension.yml +++ b/.github/workflows/build-extension.yml @@ -47,7 +47,7 @@ jobs: yarn- - name: Install dependencies - run: python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 jupyterlab_widgets~=1.0.0 + run: python -m pip install -U jupyterlab jupyter_packaging jupyterlab_widgets - name: Build the extension working-directory: js run: | diff --git a/README.md b/README.md index 0dc784b3..5add8096 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Released version ``` Jupyterlab: `nglview` works best with jupyterlab >= 3.0 and no further steps needed. +Known to work versions: nglview==3.0.8 ipywidgets==8.1.1 jupyterlab>4 works (Jan 08 20224) ## Notes diff --git a/devtools/nglview-jupyterlab.sh b/devtools/nglview-jupyterlab.sh index aa180783..f646d972 100644 --- a/devtools/nglview-jupyterlab.sh +++ b/devtools/nglview-jupyterlab.sh @@ -1,3 +1,4 @@ -conda create -n lab python=3.8 -y +conda create -n lab python=3.11 -y source activate lab -conda install jupyterlab=3 nglview -c conda-forge -y +# conda install jupyterlab=3 nglview -c conda-forge -y +conda install jupyterlab=3 -c conda-forge -y diff --git a/js/nglview-js-widgets/__init__.py b/js/nglview-js-widgets/__init__.py deleted file mode 100644 index 63040033..00000000 --- a/js/nglview-js-widgets/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ - -import json -from pathlib import Path - -from ._version import __version__ - -HERE = Path(__file__).parent.resolve() - -with (HERE / "labextension" / "package.json").open() as fid: - data = json.load(fid) - -def _jupyter_labextension_paths(): - return [{ - "src": "labextension", - "dest": data["name"] - }] - diff --git a/js/nglview-js-widgets/_version.py b/js/nglview-js-widgets/_version.py deleted file mode 100644 index b96d38b7..00000000 --- a/js/nglview-js-widgets/_version.py +++ /dev/null @@ -1,19 +0,0 @@ -import json -from pathlib import Path - -__all__ = ["__version__"] - -def _fetchVersion(): - HERE = Path(__file__).parent.resolve() - - for settings in HERE.rglob("package.json"): - try: - with settings.open() as f: - return json.load(f)["version"] - except FileNotFoundError: - pass - - raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}") - -__version__ = _fetchVersion() - diff --git a/js/package.json b/js/package.json index 4e492cc0..43fc670a 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "nglview-js-widgets", - "version": "3.0.8", + "version": "3.0.9", "description": "nglview-js-widgets", "keywords": [ "ipython", @@ -55,16 +55,16 @@ "test": "mocha" }, "dependencies": { - "@jupyter-widgets/base": "^4.0.0", + "@jupyter-widgets/base": "^1 || ^2.0.2 || ^3 || ^4 || ^5 || ^6", "@jupyter-widgets/jupyterlab-manager": "^3.0.0", "jquery": "^3.2.1", "jquery-ui": "^1.12.1", "lodash": "^4.17.4", - "ngl": "2.0.0-dev.39", + "ngl": "2.2.2", "underscore": "^1.8.3" }, "devDependencies": { - "@jupyterlab/builder": "^3.0.0", + "@jupyterlab/builder": "^3.0.5", "@types/chai": "^4.1.4", "@types/expect.js": "^0.3.29", "@types/mocha": "^2.2.48", @@ -78,7 +78,7 @@ "file-loader": "^1.1.6", "json-loader": "^0.5.4", "mkdirp": "^1.0.3", - "ngl": "2.0.0-dev.39", + "ngl": "2.2.2", "npm-run-all": "^4.1.5", "prettier": "^2.1.1", "rimraf": "^3.0.2", @@ -103,5 +103,6 @@ }, "directories": { "test": "test" - } + }, + "packageManager": "yarn@1.22.1" } diff --git a/js/src/fullscreen.ts b/js/src/fullscreen.ts index 0bd43a73..9ae081f8 100644 --- a/js/src/fullscreen.ts +++ b/js/src/fullscreen.ts @@ -27,7 +27,7 @@ export class FullscreenView extends BaseView{ stage : any render() { - this.stage = new NGL.Stage() + this.stage = new NGL.Stage(null, null) var that = this this.model.on("msg:custom", function(msg){ that.on_msg(msg) diff --git a/nglview/_frontend.py b/nglview/_frontend.py index 597c3ffb..18e4dced 100644 --- a/nglview/_frontend.py +++ b/nglview/_frontend.py @@ -1 +1 @@ -__frontend_version__ = '3.0.8' \ No newline at end of file +__frontend_version__ = '3.0.9' \ No newline at end of file diff --git a/nglview/scripts/__init__.py b/nglview/scripts/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/nglview/scripts/app.py b/nglview/scripts/app.py deleted file mode 100644 index a7fd4e22..00000000 --- a/nglview/scripts/app.py +++ /dev/null @@ -1,40 +0,0 @@ -import socket -from itertools import chain - -from notebook.notebookapp import NotebookApp, random_ports -from tornado import httpserver - - -class NGLViewApp(NotebookApp): - def get_port(self, port=None): - - # user-given port - uport = [ - port, - ] if port is not None else [ - self.port, - ] - - def func(): - return - - self.http_server = httpserver.HTTPServer(func) - success = None - - for port in chain(uport, random_ports(self.port, - self.port_retries + 1)): - try: - self.http_server.listen(port, self.ip) - except (OSError, socket.error): - pass - else: - self.port = port - success = True - break - if not success: - self.log.critical( - 'ERROR: the notebook server could not be started because ' - 'no available port could be found.') - self.exit(1) - self.http_server.stop() - return self.port diff --git a/nglview/scripts/cmd_example.py b/nglview/scripts/cmd_example.py deleted file mode 100644 index 340038ec..00000000 --- a/nglview/scripts/cmd_example.py +++ /dev/null @@ -1,21 +0,0 @@ -CMD_EXAMPLE = """Example - - # open notebook and display pdb file - nglview 1tsu.pdb - - # open notebook and display trajectory - nglview 1tsu.parm7 -c traj.nc - - # open notebook and display trajectory by reading all files ending with .nc - # make sure to use quote " " - nglview 1tsu.parm7 -c "*.nc" - - # open notebook and copy myscript.py content to 1st cell - nglview myscript.py - - # open my_notebook.ipynb notebook and run 1st cell - nglview my_notebook.ipynb - - # running Jupyter notebook remotely - nglview 1tsu.parm7 -c traj.nc --remote -""" diff --git a/nglview/scripts/nglview.py b/nglview/scripts/nglview.py deleted file mode 100755 index 5d0fef27..00000000 --- a/nglview/scripts/nglview.py +++ /dev/null @@ -1,246 +0,0 @@ -#!/usr/bin/env python - -import argparse -import json -import os -import subprocess -import sys - -from .cmd_example import CMD_EXAMPLE - -bin_path = os.path.join(sys.prefix, 'bin') - -simple_source = """ -import nglview as nv -""".strip() - -demo_source = """ -import nglview as nv - -view = nv.demo(gui=True) -view -""".strip() - -density_source = """ -import nglview as nv - -view = nv.NGLWidget(gui=True) -view.add_component('filename') -view -""".strip() - - -def _is_density_data(filename): - from nglview.utils import FileManager - - try: - fm = FileManager(filename) - - return fm.ext.lower() in ['dx', 'ccp4', 'mrc', 'map', 'dxbin', 'cube'] - except ValueError: - return False - - -notebook_dict = { - "cells": [{ - "cell_type": - "code", - "execution_count": - 'null', - "metadata": { - "collapsed": True - }, - "outputs": [], - "source": [ - "import nglview as nv\n", "import pytraj as pt\n", "\n", - "traj = pt.iterload('test.nc', top='prmtop')\n", - "view = nv.show_pytraj(traj)\n", "view" - ] - }], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython", - "version": "3.5.1" - } - }, - "nbformat": - 4, - "nbformat_minor": - 0 -} - -remote_msg = """ -Try to use port = {port} - -\033[32m In your local machine, run: \033[0m - - {client_cm} - -\033[32m NOTE: you might want to replace {hostname} by full hostname with domain name \033[0m - -\033[32m Then open your web browser, copy and paste: \033[0m - http://localhost:{port}/notebooks/{notebook_name} -""" - - -def get_remote_port(port=None, notebook_path=''): - import os, socket - from nglview.scripts.app import NGLViewApp - port = NGLViewApp().get_port(port=port) - - username = os.getlogin() - hostname = socket.gethostname() - client_cm = "ssh -NL localhost:{port}:localhost:{port} {username}@{hostname}".format( - username=username, hostname=hostname, port=port) - base_notebook_name = os.path.basename(notebook_path) - print( - remote_msg.format(client_cm=client_cm, - port=port, - hostname=hostname, - notebook_name=base_notebook_name)) - return port - - -def main(notebook_dict=notebook_dict, cmd=None): - # typte: (Dict, List[str]) -> None - pyv_full_string = ','.join(str(i) for i in sys.version_info) - pyv_short_string = str(sys.version_info[0]) - default_jexe = ' '.join((sys.executable, '-m jupyter_core')) - - parser = argparse.ArgumentParser( - description='NGLView: An IPython/Jupyter widget to ' - 'interactively view molecular structures and trajectories.', - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog=CMD_EXAMPLE) - parser.add_argument( - 'command', - nargs='?', - help= - 'command could be a topology filename (.pdb, .mol2, .parm7, ...) or \n' - 'could be a python script (.py), a notebook (.ipynb). ' - 'If not given, a notebook will be created with only nglview imported') - parser.add_argument('traj', - nargs='?', - help='coordinate filename, optional') - parser.add_argument('-c', '--crd', help='coordinate filename') - parser.add_argument('--browser', help='web browser') - parser.add_argument('-j', - '--jexe', - default=default_jexe, - help='jupyter path') - parser.add_argument('--notebook-name', - default='tmpnb_ngl.ipynb', - help='notebook name') - parser.add_argument('--port', type=int, help='port number') - parser.add_argument('--remote', - action='store_true', - help='create remote notebook') - parser.add_argument('--clean', - action='store_true', - help='delete temp file after closing notebook') - parser.add_argument('--auto', - action='store_true', - help='Run 1st cell right after openning notebook') - parser.add_argument( - '--symlink', - action='store_true', - help='Create symlink for nglview-js-widgets (developer mode)') - args = parser.parse_args(cmd) - - command = args.command - if command in ['install', 'enable', 'uninstall']: - cmds = [ - 'jupyter', 'nbextension', command, '--py', '--sys-prefix', - 'nglview' - ] - if command == 'install': - cmds.append('--overwrite') - if args.symlink: - cmds.append('--symlink') - subprocess.check_call(cmds) - sys.exit(0) - - crd = args.traj if args.traj is not None else args.crd - if crd is None: - crd = command - - browser = '--browser ' + args.browser if args.browser else '' - - create_new_nb = False - - if command is not None and command.endswith('.ipynb'): - notebook_name = command - else: - notebook_name = args.notebook_name - if command is None: - # create a notebook and import nglview - notebook_dict['cells'][0]['source'] = simple_source - nb_json = json.dumps(notebook_dict) - nb_json = nb_json.replace('"null"', 'null') - elif command.endswith('.py'): - # a Python script - pycontent = open(command).read().strip() - notebook_dict['cells'][0]['source'] = pycontent - nb_json = json.dumps(notebook_dict) - elif command == 'demo': - # running demo - notebook_dict['cells'][0]['source'] = demo_source - nb_json = json.dumps(notebook_dict) - nb_json = nb_json.replace('"null"', 'null').replace( - 'test.nc', crd).replace('prmtop', command) - elif _is_density_data(command): - # check if density data - notebook_dict['cells'][0]['source'] = density_source.replace( - 'filename', command) - nb_json = json.dumps(notebook_dict) - else: - nb_json = json.dumps(notebook_dict) - nb_json = nb_json.replace('"null"', 'null').replace( - 'test.nc', crd).replace('prmtop', command) - assert os.path.exists(command), '{} does not exists'.format( - command) - - nb_json = nb_json.replace('"null"', 'null') - - with open(notebook_name, 'w') as fh: - fh.write(nb_json) - create_new_nb = True - - dirname = os.path.dirname(os.path.abspath(notebook_name)) - if not args.remote: - cm = '{jupyter} notebook {notebook_name} {browser}'.format( - jupyter=args.jexe, notebook_name=notebook_name, browser=browser) - else: - port = get_remote_port(args.port, notebook_name) - cm = '{jupyter} notebook --no-browser --port {port} ' \ - '--notebook-dir {dirname}'.format(jupyter=args.jexe, - port=port, - dirname=dirname) - print('NOTE: make sure to open {} in your local machine\n'.format( - notebook_name)) - - try: - subprocess.check_call(cm.split()) - except KeyboardInterrupt: - if args.clean and create_new_nb: - print(f"deleting {notebook_name}") - os.remove(notebook_name) - if args.auto: - disable_extension(jupyter=args.jexe) - - -if __name__ == '__main__': - main(cmd=sys.argv[1:]) diff --git a/nglview/static/index.js b/nglview/static/index.js index e5879e25..044d54aa 100644 --- a/nglview/static/index.js +++ b/nglview/static/index.js @@ -60,7 +60,7 @@ define(["@jupyter-widgets/base"], function(__WEBPACK_EXTERNAL_MODULE_22__) { ret /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 110); +/******/ return __webpack_require__(__webpack_require__.s = 109); /******/ }) /************************************************************************/ /******/ ([ @@ -68,14 +68,14 @@ define(["@jupyter-widgets/base"], function(__WEBPACK_EXTERNAL_MODULE_22__) { ret /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - * jQuery JavaScript Library v3.7.0 + * jQuery JavaScript Library v3.7.1 * https://jquery.com/ * * Copyright OpenJS Foundation and other contributors * Released under the MIT license * https://jquery.org/license * - * Date: 2023-05-11T18:29Z + * Date: 2023-08-28T13:37Z */ ( function( global, factory ) { @@ -216,7 +216,7 @@ function toType( obj ) { -var version = "3.7.0", +var version = "3.7.1", rhtmlSuffix = /HTML$/i, @@ -480,9 +480,14 @@ jQuery.extend( { // Do not traverse comment nodes ret += jQuery.text( node ); } - } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + } + if ( nodeType === 1 || nodeType === 11 ) { return elem.textContent; - } else if ( nodeType === 3 || nodeType === 4 ) { + } + if ( nodeType === 9 ) { + return elem.documentElement.textContent; + } + if ( nodeType === 3 || nodeType === 4 ) { return elem.nodeValue; } @@ -1195,12 +1200,17 @@ function setDocument( node ) { documentElement.msMatchesSelector; // Support: IE 9 - 11+, Edge 12 - 18+ - // Accessing iframe documents after unload throws "permission denied" errors (see trac-13936) - // Support: IE 11+, Edge 17 - 18+ - // IE/Edge sometimes throw a "Permission denied" error when strict-comparing - // two documents; shallow comparisons work. - // eslint-disable-next-line eqeqeq - if ( preferredDoc != document && + // Accessing iframe documents after unload throws "permission denied" errors + // (see trac-13936). + // Limit the fix to IE & Edge Legacy; despite Edge 15+ implementing `matches`, + // all IE 9+ and Edge Legacy versions implement `msMatchesSelector` as well. + if ( documentElement.msMatchesSelector && + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + preferredDoc != document && ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { // Support: IE 9 - 11+, Edge 12 - 18+ @@ -2763,12 +2773,12 @@ jQuery.find = find; jQuery.expr[ ":" ] = jQuery.expr.pseudos; jQuery.unique = jQuery.uniqueSort; -// These have always been private, but they used to be documented -// as part of Sizzle so let's maintain them in the 3.x line -// for backwards compatibility purposes. +// These have always been private, but they used to be documented as part of +// Sizzle so let's maintain them for now for backwards compatibility purposes. find.compile = compile; find.select = select; find.setDocument = setDocument; +find.tokenize = tokenize; find.escape = jQuery.escapeSelector; find.getText = jQuery.text; @@ -5982,7 +5992,7 @@ function domManip( collection, args, callback, ignored ) { if ( hasScripts ) { doc = scripts[ scripts.length - 1 ].ownerDocument; - // Reenable scripts + // Re-enable scripts jQuery.map( scripts, restoreScript ); // Evaluate executable scripts on first document insertion @@ -6439,7 +6449,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); trChild = document.createElement( "div" ); table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; - tr.style.cssText = "border:1px solid"; + tr.style.cssText = "box-sizing:content-box;border:1px solid"; // Support: Chrome 86+ // Height set through cssText does not get applied. @@ -6451,7 +6461,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); // In our bodyBackground.html iframe, // display for all div elements is set to "inline", // which causes a problem only in Android 8 Chrome 86. - // Ensuring the div is display: block + // Ensuring the div is `display: block` // gets around this issue. trChild.style.display = "block"; @@ -10619,7 +10629,9 @@ jQuery.fn.extend( { }, hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + return this + .on( "mouseenter", fnOver ) + .on( "mouseleave", fnOut || fnOver ); } } ); @@ -10843,7 +10855,7 @@ var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', // The largest integer that can be represented exactly. var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(33))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(115))) /***/ }), /* 2 */ @@ -10939,7 +10951,7 @@ return $.ui.version = "1.13.2"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isObject_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__setup_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__has_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__collectNonEnumProps_js__ = __webpack_require__(64); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__collectNonEnumProps_js__ = __webpack_require__(63); @@ -10983,8 +10995,8 @@ function tagTester(name) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = cb; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__underscore_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__baseIteratee_js__ = __webpack_require__(73); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__iteratee_js__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__baseIteratee_js__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__iteratee_js__ = __webpack_require__(73); @@ -11071,7 +11083,7 @@ _.prototype.toString = function() { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createSizePropertyCheck_js__ = __webpack_require__(62); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createSizePropertyCheck_js__ = __webpack_require__(61); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__getLength_js__ = __webpack_require__(11); @@ -11112,7 +11124,7 @@ if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__shallowProperty_js__ = __webpack_require__(63); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__shallowProperty_js__ = __webpack_require__(62); // Internal helper to obtain the `length` property of an object. @@ -11123,7 +11135,7 @@ if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist /* 12 */ /***/ (function(module, exports) { -module.exports = {"name":"nglview-js-widgets","version":"3.0.8","description":"nglview-js-widgets","keywords":["ipython","ipywidgets","jupyter","jupyterlab","jupyterlab-extension","molecular graphics","molecular structure","science","widgets"],"homepage":"https://github.com/nglviewer/nglview/js","bugs":{"url":"https://github.com/nglviewer/nglview/issues"},"license":"MIT","author":{"name":"Alexander Rose, Hai Nguyen","email":"alexander.rose@weirdbyte.de, hainm.comp@gmail.com"},"files":["dist","src","lib","style/index.js"],"main":"lib/index.js","repository":{"type":"git","url":"https://github.com/nglviewer/nglview.git"},"scripts":{"prepublish":"jlpm build:prod && webpack && jlpm run copy:labextension","copy:labextension":"cp -r nglview-js-widgets/labextension/* ../nglview/staticlab/","build":"jlpm run build:lib && jlpm run build:labextension:dev","build:prod":"jlpm run build:lib && jlpm run build:labextension","build:labextension":"jupyter labextension build .","build:labextension:dev":"jupyter labextension build --development True .","build:lib":"tsc","clean":"jlpm run clean:lib","clean:lib":"rimraf lib tsconfig.tsbuildinfo","clean:labextension":"rimraf myextension/labextension","clean:all":"jlpm run clean:lib && jlpm run clean:labextension","eslint":"eslint . --ext .ts,.tsx --fix","eslint:check":"eslint . --ext .ts,.tsx","install:extension":"jupyter labextension develop --overwrite .","prepare":"jlpm run clean && jlpm run build:prod","watch":"run-p watch:src watch:labextension","watch:src":"tsc -w","watch:labextension":"jupyter labextension watch .","test":"mocha"},"dependencies":{"@jupyter-widgets/base":"^4.0.0","@jupyter-widgets/jupyterlab-manager":"^3.0.0","jquery":"^3.2.1","jquery-ui":"^1.12.1","lodash":"^4.17.4","ngl":"2.0.0-dev.39","underscore":"^1.8.3"},"devDependencies":{"@jupyterlab/builder":"^3.0.0","@types/chai":"^4.1.4","@types/expect.js":"^0.3.29","@types/mocha":"^2.2.48","@types/node":"^16.0.0","@types/requirejs":"^2.1.31","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","babel-register":"^6.11.6","css-loader":"^0.23.1","eslint":"^7.14.0","file-loader":"^1.1.6","json-loader":"^0.5.4","mkdirp":"^1.0.3","ngl":"2.0.0-dev.39","npm-run-all":"^4.1.5","prettier":"^2.1.1","rimraf":"^3.0.2","style-loader":"^0.13.1","typescript":"~4.1.3","webpack":"^3.12.0"},"sideEffects":["style/*.css","style/index.js"],"styleModule":"style/index.js","jupyterlab":{"extension":"lib/jupyterlab-plugin","outputDir":"nglview-js-widgets/labextension","sharedPackages":{"@jupyter-widgets/base":{"bundled":false,"singleton":true}}},"directories":{"test":"test"}} +module.exports = {"name":"nglview-js-widgets","version":"3.0.9","description":"nglview-js-widgets","keywords":["ipython","ipywidgets","jupyter","jupyterlab","jupyterlab-extension","molecular graphics","molecular structure","science","widgets"],"homepage":"https://github.com/nglviewer/nglview/js","bugs":{"url":"https://github.com/nglviewer/nglview/issues"},"license":"MIT","author":{"name":"Alexander Rose, Hai Nguyen","email":"alexander.rose@weirdbyte.de, hainm.comp@gmail.com"},"files":["dist","src","lib","style/index.js"],"main":"lib/index.js","repository":{"type":"git","url":"https://github.com/nglviewer/nglview.git"},"scripts":{"prepublish":"jlpm build:prod && webpack && jlpm run copy:labextension","copy:labextension":"cp -r nglview-js-widgets/labextension/* ../nglview/staticlab/","build":"jlpm run build:lib && jlpm run build:labextension:dev","build:prod":"jlpm run build:lib && jlpm run build:labextension","build:labextension":"jupyter labextension build .","build:labextension:dev":"jupyter labextension build --development True .","build:lib":"tsc","clean":"jlpm run clean:lib","clean:lib":"rimraf lib tsconfig.tsbuildinfo","clean:labextension":"rimraf myextension/labextension","clean:all":"jlpm run clean:lib && jlpm run clean:labextension","eslint":"eslint . --ext .ts,.tsx --fix","eslint:check":"eslint . --ext .ts,.tsx","install:extension":"jupyter labextension develop --overwrite .","prepare":"jlpm run clean && jlpm run build:prod","watch":"run-p watch:src watch:labextension","watch:src":"tsc -w","watch:labextension":"jupyter labextension watch .","test":"mocha"},"dependencies":{"@jupyter-widgets/base":"^1 || ^2.0.2 || ^3 || ^4 || ^5 || ^6","@jupyter-widgets/jupyterlab-manager":"^3.0.0","jquery":"^3.2.1","jquery-ui":"^1.12.1","lodash":"^4.17.4","ngl":"2.2.2","underscore":"^1.8.3"},"devDependencies":{"@jupyterlab/builder":"^3.0.5","@types/chai":"^4.1.4","@types/expect.js":"^0.3.29","@types/mocha":"^2.2.48","@types/node":"^16.0.0","@types/requirejs":"^2.1.31","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","babel-register":"^6.11.6","css-loader":"^0.23.1","eslint":"^7.14.0","file-loader":"^1.1.6","json-loader":"^0.5.4","mkdirp":"^1.0.3","ngl":"2.2.2","npm-run-all":"^4.1.5","prettier":"^2.1.1","rimraf":"^3.0.2","style-loader":"^0.13.1","typescript":"~4.1.3","webpack":"^3.12.0"},"sideEffects":["style/*.css","style/index.js"],"styleModule":"style/index.js","jupyterlab":{"extension":"lib/jupyterlab-plugin","outputDir":"nglview-js-widgets/labextension","sharedPackages":{"@jupyter-widgets/base":{"bundled":false,"singleton":true}}},"directories":{"test":"test"},"packageManager":"yarn@1.22.1"} /***/ }), /* 13 */ @@ -11973,51766 +11985,962 @@ return $.widget; "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Version", function() { return Version; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StaticDatasource", function() { return StaticDatasource; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MdsrvDatasource", function() { return MdsrvDatasource; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Colormaker", function() { return Colormaker; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Selection", function() { return Selection; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PdbWriter", function() { return PdbWriter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SdfWriter", function() { return SdfWriter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StlWriter", function() { return StlWriter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewer", function() { return Viewer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collection", function() { return Collection; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ComponentCollection", function() { return ComponentCollection; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepresentationCollection", function() { return RepresentationCollection; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepresentationElement", function() { return RepresentationElement; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Component", function() { return Component; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeComponent", function() { return ShapeComponent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StructureComponent", function() { return StructureComponent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SurfaceComponent", function() { return SurfaceComponent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeComponent", function() { return VolumeComponent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Assembly", function() { return Assembly; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrajectoryPlayer", function() { return TrajectoryPlayer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Superposition", function() { return Superposition; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frames", function() { return Frames; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Queue", function() { return Queue; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Counter", function() { return Counter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BufferRepresentation", function() { return BufferRepresentation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrowBuffer", function() { return ArrowBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuffer", function() { return BoxBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeBuffer", function() { return ConeBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuffer", function() { return CylinderBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EllipsoidBuffer", function() { return EllipsoidBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuffer", function() { return MeshBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctahedronBuffer", function() { return OctahedronBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointBuffer", function() { return PointBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuffer", function() { return SphereBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TetrahedronBuffer", function() { return TetrahedronBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBuffer", function() { return TextBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuffer", function() { return TorusBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WidelineBuffer", function() { return WideLineBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Shape", function() { return Shape; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Structure", function() { return Structure; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Kdtree", function() { return Kdtree$1; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpatialHash", function() { return SpatialHash; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MolecularSurface", function() { return MolecularSurface; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Volume", function() { return Volume; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MouseActions", function() { return MouseActions; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyActions", function() { return KeyActions; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingProxy", function() { return PickingProxy; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setDebug", function() { return setDebug; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeasurementDefaultParams", function() { return MeasurementDefaultParams; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setMeasurementDefaultParams", function() { return setMeasurementDefaultParams; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScriptExtensions", function() { return ScriptExtensions; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColormakerRegistry", function() { return ColormakerRegistry$1; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DatasourceRegistry", function() { return DatasourceRegistry; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecompressorRegistry", function() { return DecompressorRegistry; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParserRegistry", function() { return ParserRegistry$1; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepresentationRegistry", function() { return RepresentationRegistry; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setListingDatasource", function() { return setListingDatasource; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setTrajectoryDatasource", function() { return setTrajectoryDatasource; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ListingDatasource", function() { return ListingDatasource; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrajectoryDatasource", function() { return TrajectoryDatasource; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autoLoad", function() { return autoLoad; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDataInfo", function() { return getDataInfo; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFileInfo", function() { return getFileInfo; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "superpose", function() { return superpose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "guessElement", function() { return guessElement; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "concatStructures", function() { return concatStructures; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return flatten; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return throttle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "download", function() { return download; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQuery", function() { return getQuery; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "uniqueArray", function() { return uniqueArray; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LeftMouseButton", function() { return LeftMouseButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MiddleMouseButton", function() { return MiddleMouseButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RightMouseButton", function() { return RightMouseButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UIStageParameters", function() { return UIStageParameters; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StructureComponentDefaultParameters", function() { return StructureComponentDefaultParameters; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AngleRepresentation", function() { return zh; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrowBuffer", function() { return hu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Assembly", function() { return La; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesRepresentation", function() { return ed; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackboneRepresentation", function() { return rd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BallAndStickRepresentation", function() { return id; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseRepresentation", function() { return sd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuffer", function() { return fu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BufferRepresentation", function() { return Tc; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CartoonRepresentation", function() { return dd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collection", function() { return hl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Colormaker", function() { return zt; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColormakerRegistry", function() { return Fe; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Component", function() { return ll; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ComponentCollection", function() { return $l; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeBuffer", function() { return au; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ContactRepresentation", function() { return ud; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Counter", function() { return ui; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuffer", function() { return td; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DatasourceRegistry", function() { return Le; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return De; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecompressorRegistry", function() { return Ge; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DihedralHistogramRepresentation", function() { return gd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DihedralRepresentation", function() { return md; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceRepresentation", function() { return bd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EllipsoidBuffer", function() { return wu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frames", function() { return pl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HelixorientRepresentation", function() { return Ad; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HyperballRepresentation", function() { return Bd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Kdtree", function() { return $a; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyActions", function() { return ta; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LabelRepresentation", function() { return $d; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LeftMouseButton", function() { return tr; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LicoriceRepresentation", function() { return _d; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineRepresentation", function() { return Rd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ListingDatasource", function() { return We; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MdsrvDatasource", function() { return eg; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeasurementDefaultParams", function() { return Te; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuffer", function() { return Uo; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MiddleMouseButton", function() { return er; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MolecularSurface", function() { return zd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MolecularSurfaceRepresentation", function() { return Vd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MouseActions", function() { return Ko; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctahedronBuffer", function() { return Pu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParserRegistry", function() { return ze; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PdbWriter", function() { return ai; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingProxy", function() { return br; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointBuffer", function() { return Wc; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointRepresentation", function() { return Gd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Queue", function() { return Nr; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepresentationCollection", function() { return dl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepresentationElement", function() { return nl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RepresentationRegistry", function() { return Ne; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonRepresentation", function() { return Wd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RightMouseButton", function() { return ir; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RocketRepresentation", function() { return qd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RopeRepresentation", function() { return Xd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScriptExtensions", function() { return Re; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SdfWriter", function() { return ci; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Selection", function() { return pe; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Shape", function() { return Mc; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeComponent", function() { return Ll; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpacefillRepresentation", function() { return Yd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpatialHash", function() { return Ts; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuffer", function() { return Gc; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Fl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StaticDatasource", function() { return tg; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StlWriter", function() { return di; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Structure", function() { return Cc; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StructureComponent", function() { return Tl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StructureComponentDefaultParameters", function() { return Ml; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StructureRepresentation", function() { return Sh; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Superposition", function() { return fl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SurfaceComponent", function() { return Bl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TetrahedronBuffer", function() { return Bu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBuffer", function() { return Eh; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuffer", function() { return Fu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TraceRepresentation", function() { return Qd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrajectoryDatasource", function() { return qe; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrajectoryPlayer", function() { return yl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeRepresentation", function() { return Jd; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UIStageParameters", function() { return og; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UnitcellRepresentation", function() { return tu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValidationRepresentation", function() { return eu; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Version", function() { return ag; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewer", function() { return Ji; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Volume", function() { return Eo; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeComponent", function() { return Dl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WidelineBuffer", function() { return Nh; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "autoLoad", function() { return ni; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "concatStructures", function() { return ic; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "download", function() { return dt; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return at; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDataInfo", function() { return si; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFileInfo", function() { return ri; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQuery", function() { return rt; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "guessElement", function() { return tc; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setDebug", function() { return Oe; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setListingDatasource", function() { return Xe; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setMeasurementDefaultParams", function() { return Be; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setTrajectoryDatasource", function() { return Ye; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "superpose", function() { return kl; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return ut; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "uniqueArray", function() { return gt; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_three__ = __webpack_require__(52); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix3", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["x"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix4", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["y"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["W"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["X"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Box3", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["d"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["J"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Euler", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["n"]; }); -/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["G"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["i"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_chroma_js__ = __webpack_require__(112); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Euler", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["n"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix3", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["y"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix4", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["z"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["H"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["K"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["X"]; }); +/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return __WEBPACK_IMPORTED_MODULE_0_three__["Y"]; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_chroma_js__ = __webpack_require__(111); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_chroma_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_chroma_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_signals__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_signals__ = __webpack_require__(33); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_signals___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_signals__); /* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_2_signals__, "Signal")) __webpack_require__.d(__webpack_exports__, "Signal", function() { return __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_sprintf_js__ = __webpack_require__(114); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_sprintf_js__ = __webpack_require__(113); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_sprintf_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_promise_polyfill__ = __webpack_require__(115); +function rt(t){if("undefined"==typeof window)return;const e=new RegExp(`${t}=([^&#=]*)`).exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}function st(t,e){return void 0!==t?t:e}function nt(t,e){const i=Object.assign({},t);for(const r in e){void 0===t[r]&&(i[r]=e[r])}return i}function ot(t,e){for(const i in e){const r=e[i];void 0!==r&&(t[i]=r)}return t}function at(t,e){e=st(e,[]);for(let i=0;ie?(o&&(clearTimeout(o),o=null),a=l,n=t.apply(r,s),o||(r=s=null)):o||!1===i.trailing||(o=setTimeout(c,h)),n}}function mt(t,e){return te?1:0}function pt(t,e,i=mt){let r=0,s=t.length-1;for(;r<=s;){const n=r+s>>1,o=i(e,t[n]);if(o>0)r=n+1;else{if(!(o<0))return n;s=n-1}}return-r-1}function ft(t,e,i){const r=function(t,e){let i=t.length-1;if(t[i]>1;t[s]>=e?i=s-1:r=s+1}return i+1}(t,e),s=function(t,e){if(t[0]>e)return-1;let i=0,r=t.length-1;for(;i<=r;){const s=i+r>>1;t[s]>e?r=s-1:i=s+1}return i-1}(t,i);return-1===r||-1===s||r>s?0:s-r+1}function gt(t){return t.sort().filter((function(t,e,i){return 0===e||t!==i[e-1]}))}function yt(t){const e=28672;if(t.length>e){const i=[];for(let r=0;r65535?Uint32Array:Uint16Array)(t)}function vt(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function wt(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function At(t){return wt(t,e)}function _t(t){return wt(t,i)}function St(t){return wt(t,r)}function Ct(t){return e=t,i=Float32Array,e instanceof i?e:new i(e);var e,i}function Pt(t){return st(t,"").toString().toLowerCase()}class It{constructor(t){this.name=t,this._dict={}}add(t,e){this._dict[Pt(t)]=e}get(t){return this._dict[Pt(t)]}get names(){return Object.keys(this._dict)}}function kt(t){return.01745*t}const Mt="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Tt=new Array(36);function Bt(){let t,e=0;for(let i=0;i<36;i++)8===i||13===i||18===i||23===i?Tt[i]="-":14===i?Tt[i]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Tt[i]=Mt[19===i?3&t|8:t]);return Tt.join("")}function Dt(t,e,i){return Math.max(e,Math.min(i,t))}function $t(t,e,i){return t+(e-t)*i}function Ot(t,e,i,r,s,n){const o=(i-t)*n,a=(r-e)*n,c=s*s;return(2*e-2*i+o+a)*(s*c)+(-3*e+3*i-2*o-a)*c+o*s+e}function Rt(t,e,i){var r;return r=function(t,e,i){return(t-e)/(i-e)}(i,t,e),(i=Dt(r,0,1))*i*(3-2*i)}var Et="sRGB";const Ft={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},Lt=new s;function Nt(t,e,i){const r=i.value;return i.value=function(t,e){let i=r.bind(this,t,e)();return"linear"==Et?(Lt.set(i),Lt.convertSRGBToLinear(),Lt.getHex()):i},i}class zt{constructor(t={}){this.parameters=nt(t,Ft),"string"==typeof this.parameters.value&&(this.parameters.value=Lt.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())}getScale(t={}){const e=nt(t,this.parameters);return"rainbow"===e.scale?e.scale=["red","orange","yellow","green","blue"]:"rwb"===e.scale&&(e.scale=["red","white","blue"]),e.reverse&&(e.domain=e.domain.slice().reverse()),__WEBPACK_IMPORTED_MODULE_1_chroma_js__["scale"](e.scale).mode(e.mode).domain(e.domain).out("num")}colorToArray(t,e=[],i=0){return e[i]=(t>>16&255)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(255&t)/255,e}atomColorToArray(t,e,i){return this.colorToArray(this.atomColor?this.atomColor(t):0,e,i)}bondColor(t,e){return this.atomProxy&&this.atomColor?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):0}bondColorToArray(t,e,i,r){return this.colorToArray(this.bondColor(t,e),i,r)}volumeColorToArray(t,e,i){return this.colorToArray(this.volumeColor?this.volumeColor(t):0,e,i)}positionColorToArray(t,e,i){return this.colorToArray(this.positionColor?this.positionColor(t):0,e,i)}}var Vt;!function(t){t[t.PROTEIN=1]="PROTEIN",t[t.NUCLEIC=2]="NUCLEIC",t[t.RNA=3]="RNA",t[t.DNA=4]="DNA",t[t.POLYMER=5]="POLYMER",t[t.WATER=6]="WATER",t[t.HELIX=7]="HELIX",t[t.SHEET=8]="SHEET",t[t.TURN=9]="TURN",t[t.BACKBONE=10]="BACKBONE",t[t.SIDECHAIN=11]="SIDECHAIN",t[t.ALL=12]="ALL",t[t.HETERO=13]="HETERO",t[t.ION=14]="ION",t[t.SACCHARIDE=15]="SACCHARIDE",t[t.SUGAR=15]="SUGAR",t[t.BONDED=16]="BONDED",t[t.RING=17]="RING",t[t.AROMATICRING=18]="AROMATICRING",t[t.METAL=19]="METAL",t[t.POLARH=20]="POLARH",t[t.NONE=21]="NONE"}(Vt||(Vt={}));const Gt=["*","","ALL"],Ut=["NONE"],jt=[Vt.BACKBONE,Vt.SIDECHAIN,Vt.BONDED,Vt.RING,Vt.AROMATICRING,Vt.METAL,Vt.POLARH],Ht=[Vt.POLYMER,Vt.WATER],Wt=["ALA","GLY","SER"],qt=["CYS","SER","THR"],Xt=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Yt=["PHE","TRP","TYR","HIS"],Kt=["ASN","GLN"],Zt=["ASP","GLU"],Qt=["ARG","HIS","LYS"],Jt=["ARG","ASP","GLU","HIS","LYS"],te=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],ee=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],ie=["HIS","PHE","PRO","TRP","TYR"],re=["ALA","GLY","ILE","LEU","VAL"];function se(t,e){if(void 0===e.atomname&&void 0===e.element&&void 0===e.altloc&&void 0===e.atomindex&&void 0===e.keyword&&void 0===e.inscode&&void 0===e.resname&&void 0===e.sstruc&&void 0===e.resno&&void 0===e.chainname&&void 0===e.model)return-1;if(void 0!==e.keyword){if(e.keyword===Vt.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===Vt.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===Vt.BONDED&&!t.isBonded())return!1;if(e.keyword===Vt.RING&&!t.isRing())return!1;if(e.keyword===Vt.AROMATICRING&&!t.isAromatic())return!1;if(e.keyword===Vt.HETERO&&!t.isHetero())return!1;if(e.keyword===Vt.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Vt.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Vt.RNA&&!t.isRna())return!1;if(e.keyword===Vt.DNA&&!t.isDna())return!1;if(e.keyword===Vt.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Vt.WATER&&!t.isWater())return!1;if(e.keyword===Vt.HELIX&&!t.isHelix())return!1;if(e.keyword===Vt.SHEET&&!t.isSheet())return!1;if(e.keyword===Vt.TURN&&!t.isTurn())return!1;if(e.keyword===Vt.ION&&!t.isIon())return!1;if(e.keyword===Vt.SACCHARIDE&&!t.isSaccharide())return!1;if(e.keyword===Vt.METAL&&!t.isMetal())return!1;if(e.keyword===Vt.POLARH&&!t.isPolarHydrogen())return!1}if(void 0!==e.atomname&&e.atomname!==t.atomname)return!1;if(void 0!==e.element&&e.element!==t.element)return!1;if(void 0!==e.altloc&&e.altloc!==t.altloc)return!1;if(void 0!==e.atomindex&&pt(e.atomindex,t.index)<0)return!1;if(void 0!==e.resname)if(Array.isArray(e.resname)){if(!e.resname.includes(t.resname))return!1}else if(e.resname!==t.resname)return!1;if(void 0!==e.sstruc&&e.sstruc!==t.sstruc)return!1;if(void 0!==e.resno)if(Array.isArray(e.resno)&&2===e.resno.length){if(e.resno[0]>t.resno||e.resno[1]t.resno||e.resno[1]0?t:null}function he(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return void 0!==t.keyword&&!jt.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))}))),ce(i,se)}function de(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return!(void 0===t.keyword||!jt.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))}))),ce(i,ne)}function ue(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return void 0!==t.keyword&&!Ht.includes(t.keyword)||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode))))))}))),ce(i,oe)}function me(t,e=!1){let i=t;return e&&(i=le(t,(function(t){return void 0!==t.keyword||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||(void 0!==t.atomname||(void 0!==t.element||(void 0!==t.altloc||(void 0!==t.sstruc||void 0!==t.inscode)))))))}))),ce(i,ae)}class pe{constructor(t){this.signals={stringChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.setString(t)}get type(){return"selection"}setString(t,e){if(void 0===t&&(t=this.string||""),t===this.string)return;try{this.selection=function(t){let e={operator:void 0,rules:[]};if(!t)return e;let i,r,s=e;const n=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());const o=t.split(/\s+/),a=t=>{i={operator:t,rules:[]},void 0===s?(s=i,e=i):(s.rules.push(i),n.push(s),s=i)},c=function(t){r=s,s=n.pop(),void 0===s&&(a(t),l(r))},l=function(t){s.rules.push(t)};let h=!1;for(let t=0;t0)if("NOT"===i)h=1;else if(1===h)h=2;else{if(2!==h)throw new Error("something went wrong with 'not'");h=!1,c()}if("AND"===i){if("OR"===s.operator){const t=s.rules.pop();a("AND"),l(t)}else s.operator="AND";continue}if("OR"===i){"AND"===s.operator?c("OR"):s.operator="OR";continue}if("NOT"===e.toUpperCase()){h=1,a(),s.negate=!0;continue}if(+i!=+i){const t=Vt[i];if(void 0!==t){l({keyword:t});continue}}if("HYDROGEN"===i){l({operator:"OR",rules:[{element:"H"},{element:"D"}]});continue}if("SMALL"===i){l({resname:Wt});continue}if("NUCLEOPHILIC"===i){l({resname:qt});continue}if("HYDROPHOBIC"===i){l({resname:Xt});continue}if("AROMATIC"===i){l({resname:Yt});continue}if("AMIDE"===i){l({resname:Kt});continue}if("ACIDIC"===i){l({resname:Zt});continue}if("BASIC"===i){l({resname:Qt});continue}if("CHARGED"===i){l({resname:Jt});continue}if("POLAR"===i){l({resname:te});continue}if("NONPOLAR"===i){l({resname:ee});continue}if("CYCLIC"===i){l({resname:ie});continue}if("ALIPHATIC"===i){l({resname:re});continue}if("SIDECHAINATTACHED"===i){l({operator:"OR",rules:[{keyword:Vt.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:Vt.PROTEIN},{operator:"OR",negate:!1,rules:[{atomname:"CA"},{atomname:"BB"}]}]},{operator:"AND",negate:!1,rules:[{resname:"PRO"},{atomname:"N"}]},{operator:"AND",negate:!1,rules:[{keyword:Vt.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"HO3'"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"HO5'"},{atomname:"C5'"},{atomname:"C5*"},{atomname:"H5'"},{atomname:"H5''"}]}]}]});continue}if("APOLARH"===i){l({operator:"AND",negate:!1,rules:[{element:"H"},{negate:!0,operator:void 0,rules:[{keyword:Vt.POLARH}]}]});continue}if("LIGAND"===i){l({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:Vt.HETERO},{negate:!0,operator:void 0,rules:[{keyword:Vt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:Vt.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:Vt.WATER},{keyword:Vt.ION}]}]}]});continue}if(-1!==Gt.indexOf(i)){l({keyword:Vt.ALL});continue}if("@"===e.charAt(0)){const t=e.substr(1).split(",").map((t=>parseInt(t)));t.sort((function(t,e){return t-e})),l({atomindex:t});continue}if("#"===e.charAt(0)){console.error("# for element selection deprecated, use _"),l({element:i.substr(1)});continue}if("_"===e.charAt(0)){l({element:i.substr(1)});continue}if("["===e[0]&&"]"===e[e.length-1]){const t=i.substr(1,e.length-2).split(","),r=t.length>1?t:t[0];l({resname:r});continue}if(e.length>=1&&e.length<=4&&"^"!==e[0]&&":"!==e[0]&&"."!==e[0]&&"%"!==e[0]&&"/"!==e[0]&&isNaN(parseInt(e))){l({resname:i});continue}const r={operator:"AND",rules:[]},n=e.split("/");if(n.length>1&&n[1]){if(isNaN(parseInt(n[1])))throw new Error("model must be an integer");r.rules.push({model:parseInt(n[1])})}const d=n[0].split("%");d.length>1&&r.rules.push({altloc:d[1]});const u=d[0].split(".");if(u.length>1&&u[1]){if(u[1].length>4)throw new Error("atomname must be one to four characters");r.rules.push({atomname:u[1].substring(0,4).toUpperCase()})}const m=u[0].split(":");m.length>1&&m[1]&&r.rules.push({chainname:m[1]});const p=m[0].split("^");if(p.length>1&&r.rules.push({inscode:p[1]}),p[0]){let t,e;"-"===p[0][0]&&(p[0]=p[0].substr(1),t=!0),p[0].includes("--")&&(p[0]=p[0].replace("--","-"),e=!0);let i=p[0].split("-");if(1===i.length){let e=parseInt(i[0]);if(isNaN(e))throw new Error("resi must be an integer");t&&(e*=-1),r.rules.push({resno:e})}else{if(2!==i.length)throw new Error("resi range must contain one '-'");{const s=i.map((t=>parseInt(t)));t&&(s[0]*=-1),e&&(s[1]*=-1),r.rules.push({resno:[s[0],s[1]]})}}}if(1===r.rules.length)l(r.rules[0]);else{if(!(r.rules.length>1))throw new Error("empty selection chunk");l(r)}}return void 0===e.operator&&1===e.rules.length&&e.rules[0].hasOwnProperty("operator")&&(e=e.rules[0]),e}(t)}catch(t){this.selection={error:t.message}}const i=this.selection;this.string=t,this.test=he(i),this.residueTest=de(i),this.chainTest=ue(i),this.modelTest=me(i),this.atomOnlyTest=he(i,!0),this.residueOnlyTest=de(i,!0),this.chainOnlyTest=ue(i,!0),this.modelOnlyTest=me(i,!0),e||this.signals.stringChanged.dispatch(this.string)}isAllSelection(){return Gt.includes(this.string.toUpperCase())}isNoneSelection(){return Ut.includes(this.string.toUpperCase())}}class fe extends zt{constructor(t){super(t),this.colormakerList=[],this.selectionList=[];(t.dataList||[]).forEach((t=>{const[e,i,r={}]=t;Fe.hasScheme(e)?Object.assign(r,{scheme:e,structure:this.parameters.structure}):Object.assign(r,{scheme:"uniform",value:new s(e).getHex()}),this.colormakerList.push(Fe.getScheme(r)),this.selectionList.push(new pe(i))}))}atomColor(t){for(let e=0,i=this.selectionList.length;e{}),t)}catch(t){}const Se="undefined"!=typeof window&&void 0!==window.orientation;let Ce=!1;function Pe(t){Ce=t}let Ie=!1;function ke(t){Ie=t}const Me={log:Function.prototype.bind.call(console.log,console),info:Function.prototype.bind.call(console.info,console),warn:Function.prototype.bind.call(console.warn,console),error:Function.prototype.bind.call(console.error,console),time:Function.prototype.bind.call(console.time,console),timeEnd:Function.prototype.bind.call(console.timeEnd,console)};let Te={color:"green",labelColor:8421504,labelAttachment:"bottom-center",labelSize:.7,labelZOffset:.5,labelYOffset:.1,labelBorder:!0,labelBorderColor:13882323,labelBorderWidth:.25,lineOpacity:.8,linewidth:5,opacity:.6,labelUnit:"angstrom",arcVisible:!0,planeVisible:!1};function Be(t={}){Object.assign(Te,t)}let De=!!($e=rt("debug"))&&("string"!=typeof $e||/^1|true|t|yes|y$/i.test($e));var $e;function Oe(t){De=t}const Re=["ngl","js"],Ee=new class{constructor(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}}add(t,e,i){this._funcDict[t]=e,this._depsDict[t]=i}get(t){return this._blobDict[t]||(this._blobDict[t]=we(this._funcDict[t],this._depsDict[t])),this._blobDict[t]}},Fe=new class{constructor(){this.schemes={},this.userSchemes={}}getScheme(t){const e=((t||{}).scheme||"").toLowerCase();let i;return i=e in this.schemes?this.schemes[e]:e in this.userSchemes?this.userSchemes[e]:zt,new i(t)}getSchemes(){const t={};return Object.keys(this.schemes).forEach((function(e){t[e]=e})),Object.keys(this.userSchemes).forEach((function(e){t[e]=e.split("|")[1]})),t}getScales(){return ge}getModes(){return ye}add(t,e){t=t.toLowerCase(),this.schemes[t]=e}addScheme(t,e){return function(t){return t instanceof zt}(t)||(t=this._createScheme(t)),this._addUserScheme(t,e)}_addUserScheme(t,e){e=e||"";const i=`${Bt()}|${e}`.toLowerCase();return this.userSchemes[i]=t,i}removeScheme(t){t=t.toLowerCase(),delete this.userSchemes[t]}_createScheme(t){return class extends zt{constructor(e){super(e),t.call(this,e)}}}addSelectionScheme(t,e){return this._addUserScheme(class extends fe{constructor(e){super(Object.assign({dataList:t},e))}},e)}hasScheme(t){return(t=t.toLowerCase())in this.schemes||t in this.userSchemes}},Le=new It("datasource"),Ne=new It("representatation"),ze=new class extends It{constructor(){super("parser")}__hasObjName(t,e){const i=this.get(t);return i&&i.prototype.__objName===e}isTrajectory(t){return this.__hasObjName(t,"frames")}isStructure(t){return this.__hasObjName(t,"structure")}isVolume(t){return this.__hasObjName(t,"volume")}isSurface(t){return this.__hasObjName(t,"surface")}isBinary(t){const e=this.get(t);return e&&e.prototype.isBinary}isXml(t){const e=this.get(t);return e&&e.prototype.isXml}isJson(t){const e=this.get(t);return e&&e.prototype.isJson}getTrajectoryExtensions(){return this.names.filter((t=>this.isTrajectory(t)))}getStructureExtensions(){return this.names.filter((t=>this.isStructure(t)))}getVolumeExtensions(){return this.names.filter((t=>this.isVolume(t)))}getSurfaceExtensions(){return this.names.filter((t=>this.isSurface(t)))}},Ve=new It("shader"),Ge=new It("decompressor"),Ue=new It("component"),je=new It("buffer"),He=new It("picker");let We,qe;function Xe(t){We=t}function Ye(t){qe=t}class Ke{constructor(t,e={}){this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.compressed=st(e.compressed,!1),this.binary=st(e.binary,!1),this.json=st(e.json,!1),this.xml=st(e.xml,!1),this.src=t}isBinary(){return this.binary||this.compressed}read(){return this._read().then((t=>{const e=this.compressed?Ge.get(this.compressed):void 0;return this.compressed&&e?this.data=e(t):((this.binary||this.compressed)&&t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.data=t),this.data}))}_chunk(t,e){return e=Math.min(this.data.length,e),0===t&&this.data.length===e?this.data:this.isBinary()?this.data.subarray(t,e):this.data.substring(t,e)}chunk(t){const e=t+this.chunkSize;return this._chunk(t,e)}peekLines(t){const e=this.data,i=e.length,r=this.isBinary()?this.newline.charCodeAt(0):this.newline;let s,n=0;for(s=0;si).lines}chunkCount(){return Math.floor(this.data.length/this.chunkSize)+1}asText(){return this.isBinary()?yt(this.data):this.data}chunkToLines(t,e,i){const r=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(r),partialLine:""};let s=[];const n=this.isBinary()?yt(t):t,o=n.lastIndexOf(r);if(-1===o)e+=n;else{const t=e+n.substr(0,o);s=s.concat(t.split(r)),e=o===n.length-r.length?"":n.substr(o+r.length)}return i&&""!==e&&s.push(e),{lines:s,partialLine:e}}nextChunk(){const t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)}nextChunkOfLines(){const t=this.nextChunk();if(void 0===t)return;const e=this.__pointer>this.data.length,i=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=i.partialLine,i.lines}eachChunk(t){const e=this.chunkSize,i=this.data.length,r=this.chunkCount();for(let s=0;s{const s=i===r+1,n=this.chunkToLines(e,this.__partialLine,s);this.__partialLine=n.partialLine,t(n.lines,i,r)}))}dispose(){delete this.src}}class Ze extends Ke{_read(){return new Promise(((t,e)=>{const i=this.src,r=new FileReader;r.onload=e=>{e.target&&t(e.target.result)},r.onerror=t=>e(t),this.binary||this.compressed?r.readAsArrayBuffer(i):r.readAsText(i)}))}}class Qe extends Ke{_read(){return new Promise(((t,e)=>{const i=this.src,r=new XMLHttpRequest;r.open("GET",i,!0),r.addEventListener("load",(()=>{if(200===r.status||304===r.status||0===r.status)try{t(r.response)}catch(t){e(t)}else e(r.statusText)}),!1),r.addEventListener("error",(t=>e("network error")),!1),this.isBinary()?r.responseType="arraybuffer":this.json?r.responseType="json":this.xml?r.responseType="document":r.responseType="text",r.send()}))}}class Je{constructor(t,e={}){this.parameters=nt(e,{ext:"",compressed:!1,binary:ze.isBinary(e.ext||""),name:"",dir:"",path:"",protocol:""});const i={compressed:this.parameters.compressed,binary:this.parameters.binary,json:ze.isJson(this.parameters.ext),xml:ze.isXml(this.parameters.ext)};"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Blob&&t instanceof Blob?this.streamer=new Ze(t,i):this.streamer=new Qe(t,i)}}class ti extends Je{constructor(t,e={}){super(t,e),this.parserParams={voxelSize:e.voxelSize,firstModelOnly:e.firstModelOnly,asTrajectory:e.asTrajectory,cAlphaOnly:e.cAlphaOnly,delimiter:e.delimiter,comment:e.comment,columnNames:e.columnNames,inferBonds:e.inferBonds,name:this.parameters.name,path:this.parameters.path}}load(){return new(ze.get(this.parameters.ext))(this.streamer,this.parserParams).parse()}}class ei{constructor(t,e,i){this.name=e,this.path=i,this.signals={elementAdded:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],elementRemoved:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],nameChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.type="Script",this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","__name","__path","__dir",t)}catch(t){Me.error("Script compilation failed",t),this.fn=function(){}}}run(t){return new Promise(((e,i)=>{try{this.fn.apply(null,[t,this.name,this.path,this.dir]),e()}catch(t){Me.error("Script.fn",t),i(t)}}))}}class ii extends Je{load(){return this.streamer.read().then((()=>new ei(this.streamer.asText(),this.parameters.name,this.parameters.path)))}}function ri(t){const e=Ge.names;let i,r,s="";i=t instanceof File?t.name:t instanceof Blob?"":t;const n=i.lastIndexOf("?"),o=-1!==n?i.substring(n):"";i=i.substring(0,-1===n?i.length:n);const a=i.replace(/^.*[\\/]/,"");let c=a.substring(0,a.lastIndexOf("."));const l=a.split(".");let h=l.length>1?(l.pop()||"").toLowerCase():"";const d=i.match(/^(.+):\/\/(.+)$/);d&&(s=d[1].toLowerCase(),i=d[2]||"");const u=i.substring(0,i.lastIndexOf("/")+1);if(e.includes(h)){r=h;const t=i.length-h.length-1;h=(i.substr(0,t).split(".").pop()||"").toLowerCase();const e=c.length-h.length-1;c=c.substr(0,e)}else r=!1;return{path:i,name:a,ext:h,base:c,dir:u,compressed:r,protocol:s,query:o,src:t}}function si(t){let e=ri(t);const i=Le.get(e.protocol);return i&&(e=ri(i.getUrl(e.src)),!e.ext&&i.getExt&&(e.ext=i.getExt(t))),e}function ni(t,e={}){const i=Object.assign(si(t),e);let r;return ze.names.includes(i.ext)?r=new ti(i.src,i):Re.includes(i.ext)&&(r=new ii(i.src,i)),r?r.load():Promise.reject(new Error(`autoLoad: ext '${i.ext}' unknown`))}class oi{getBlob(){return new Blob([this.getData()],{type:this.mimeType})}download(t,e){t=st(t,this.defaultName),e=st(e,this.defaultExt),dt(this.getBlob(),`${t}.${e}`)}}class ai extends oi{constructor(t,e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},e);this.renumberSerial=st(i.renumberSerial,!0),this.remarks=function(t){return Array.isArray(t)?t:[t]}(st(i.remarks,[])),this.structure=t,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((t=>{this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("REMARK %-73s",t))})),this.structure.trajectory&&(this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let t=1,e=1,i=" ",r=" ";const s=this.structure.modelStore.count>1;this.structure.eachModel((n=>{s&&this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("MODEL %4d%-66s",e++,"")),n.eachAtom((e=>{const s=e.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",n=this.renumberSerial?t:e.serial;let o=e.atomname;(1===o.length||o.length<4&&1===e.element.length&&o[0]===e.element)&&(o=" "+o),e.formalCharge?(i=Math.abs(e.formalCharge).toPrecision(1),r=e.formalCharge>0?"+":"-"):(i=" ",r=" "),this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(s,n,o,e.resname,st(e.chainname," "),e.resno,e.x,e.y,e.z,st(e.occupancy,1),st(e.bfactor,0),"",st(e.element,""),i,r)),t+=1}),this.structure.getSelection()),s&&this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("%-80s","ENDMDL"))})),this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}}class ci extends oi{constructor(t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=t,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const t=[];this.structure.eachAtom((e=>{null!=e.formalCharge&&0!==e.formalCharge&&t.push([e.index,e.formalCharge])}));const e=[];for(let i=0;i{this._records.push(this.formatAtom(t))})),this.structure.eachBond((t=>{this._records.push(this.formatBond(t))})),this.chargeLines.forEach((t=>{this._records.push(t)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}}const li=[];class hi{constructor(t,e={}){this._mark=0,this._marks=[],this.offset=0,this.littleEndian=!0;let i=!1;void 0===t&&(t=8192),"number"==typeof t?t=new ArrayBuffer(t):i=!0;const r=e.offset?e.offset>>>0:0;let s=t.byteLength-r,n=r;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(n=t.byteOffset+r),t=t.buffer),this._lastWrittenByte=i?s:0,this.buffer=t,this.length=s,this.byteLength=s,this.byteOffset=n,this._data=new DataView(this.buffer,n,s)}available(t){return void 0===t&&(t=1),this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t){return void 0===t&&(t=1),this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t){if(void 0===t&&(t=1),!this.available(t)){const e=2*(this.offset+t),i=new Uint8Array(e);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=this.byteLength=e,this._data=new DataView(this.buffer)}return this}readBoolean(){return 0!==this.readUint8()}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t){void 0===t&&(t=1);for(var e=new Uint8Array(t),i=0;ithis._lastWrittenByte&&(this._lastWrittenByte=this.offset)}}class di extends oi{constructor(t){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=t}getData(){const t=this.surface.index.length/3,i=new hi(2*t+3*t*4*4+80+4);i.skip(80),i.writeUint32(t);const r=new e,s=new e,n=new e,o=new e;for(let e=0;e{0===this.count&&(this.signals.countChanged.remove(i,this),t.call(e))};this.signals.countChanged.add(i,this)}}dispose(){this.clear(),this.signals.countChanged.dispose()}}Ve.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),Ve.add("shader/BasicLine.frag","uniform vec3 uColor;\n#include common\n#include fog_pars_fragment\nvoid main(){\ngl_FragColor = vec4( uColor, 1.0 );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"),Ve.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),Ve.add("shader/Quad.frag","varying vec2 vUv;\nuniform sampler2D tForeground;\nuniform float scale;\nvoid main() {\nvec4 foreground = texture2D( tForeground, vUv );\ngl_FragColor = foreground * scale;\n}");class mi{constructor(){this.signals={updated:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.maxDuration=-1/0,this.minDuration=1/0,this.avgDuration=14,this.lastDuration=1/0,this.prevFpsTime=0,this.lastFps=1/0,this.lastFrames=1,this.frames=0,this.count=0,this.begin()}update(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()}begin(){this.startTime=window.performance.now(),this.lastFrames=this.frames}end(){const t=window.performance.now();return this.count+=1,this.frames+=1,this.lastDuration=t-this.startTime,this.minDuration=Math.min(this.minDuration,this.lastDuration),this.maxDuration=Math.max(this.maxDuration,this.lastDuration),this.avgDuration-=this.avgDuration/30,this.avgDuration+=this.lastDuration/30,t>this.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t}}Ve.add("shader/chunk/fog_fragment.glsl","#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"),Ve.add("shader/chunk/interior_fragment.glsl","if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"),Ve.add("shader/chunk/matrix_scale.glsl","float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"),Ve.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Ve.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),Ve.add("shader/chunk/opaque_back_fragment.glsl","#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"),Ve.add("shader/chunk/radiusclip_vertex.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),Ve.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),Ve.add("shader/chunk/unpack_color.glsl","vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}");const pi=/^(?!\/\/)\s*#include\s+(\S+)/gim,fi={};function gi(t,e={}){let i=t+"|";for(const t in e)i+=t+":"+e[t];if(!fi[i]){const r=function(t){if(void 0===t)return"";const e=[];for(const i in t){const r=t[i];r&&e.push(`#define ${i} ${r}`)}return e.join("\n")+"\n"}(e);let s=Ve.get(`shader/${t}`);if(!s)throw new Error(`empty shader, '${t}'`);s=s.replace(pi,(function(t,e){const i=`shader/chunk/${e}.glsl`,r=Ve.get(i)||__WEBPACK_IMPORTED_MODULE_0_three__["N" /* ShaderChunk */][e];if(!r)throw new Error(`empty chunk, '${e}'`);return r})),fi[i]=r+s}return fi[i]}if("undefined"!=typeof WebGLRenderingContext){const t=WebGLRenderingContext.prototype,e=t.getShaderParameter;t.getShaderParameter=function(){return!De||e.apply(this,arguments)};const i=t.getShaderInfoLog;t.getShaderInfoLog=function(){return De?i.apply(this,arguments):""};const r=t.getProgramParameter;t.getProgramParameter=function(e,i){return!De&&i===t.LINK_STATUS||r.apply(this,arguments)};const s=t.getProgramInfoLog;t.getProgramInfoLog=function(){return De?s.apply(this,arguments):""}}const yi=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];yi.forEach((t=>{t.forEach((t=>{t[0]*=.0625,t[1]*=.0625}))}));class bi{constructor(t,e,i,r){this.canvas=document.createElement("canvas"),this._viewer=i,this._factor=st(r.factor,2),this._antialias=st(r.antialias,!1),this._onProgress=r.onProgress,this._onFinish=r.onFinish,this._antialias&&(this._factor*=2),this._n=this._factor*this._factor,this._width=this._viewer.width,this._height=this._viewer.height,this._antialias?(this.canvas.width=this._width*this._factor/2,this.canvas.height=this._height*this._factor/2):(this.canvas.width=this._width*this._factor,this.canvas.height=this._height*this._factor),this._ctx=this.canvas.getContext("2d"),this._viewerSampleLevel=i.sampleLevel,this._viewer.setSampling(-1)}_renderTile(t){const e=this._viewer,i=this._width,r=this._height,s=this._factor,n=t%s*i,o=Math.floor(t/s)*r;if(e.camera.setViewOffset(i*s,r*s,n,o,i,r),e.render(),this._antialias){const t=Math.round((n+i)/2)-Math.round(n/2),s=Math.round((o+r)/2)-Math.round(o/2);this._ctx.drawImage(e.renderer.domElement,Math.round(n/2),Math.round(o/2),t,s)}else this._ctx.drawImage(e.renderer.domElement,Math.floor(n),Math.floor(o),Math.ceil(i),Math.ceil(r));"function"==typeof this._onProgress&&this._onProgress(t+1,this._n,!1)}_finalize(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)}render(){for(let t=0;t<=this._n;++t)t===this._n?this._finalize():this._renderTile(t)}renderAsync(){let t=0;const e=this._n,i=()=>{t===e?this._finalize():this._renderTile(t),t+=1};for(let t=0;t<=e;++t)setTimeout(i,0)}}const xi=2*Math.PI,vi=180/Math.PI;function wi(t,e,i=1,r=0,s){const n=s?s.length:t.length/i;let o=0,a=0;if(s)for(let c=0;ce&&(e=t[i]);return e}function Di(t){let e=1/0;for(let i=0,r=t.length;i=0;l--){for(c=o-1;c>=0;c--)if(d=4*(l*o+c),a[d]!==e||a[d+1]!==i||a[d+2]!==r||a[d+3]!==s){h=!0;break}if(h)break}const p=l;for(h=!1,c=o-1;c>=0;c--){for(l=n-1;l>=0;l--)if(d=4*(l*o+c),a[d]!==e||a[d+1]!==i||a[d+2]!==r||a[d+3]!==s){h=!0;break}if(h)break}const f=c,g=document.createElement("canvas");return g.width=f-m,g.height=p-u,g.getContext("2d").drawImage(t,m,u,g.width,g.height,0,0,g.width,g.height),g}(t,n?0:255*e.r,n?0:255*e.g,n?0:255*e.b,n?0:255)}return t}function u(t,i,r){"function"==typeof e.onProgress&&e.onProgress(t,i,r)}return new Promise((function(e,i){const l=new bi(o,a,t,{factor:r,antialias:s,onProgress:u,onFinish:function(r,s){d(l.canvas).toBlob((function(r){o.setClearAlpha(c),h(!0),t.requestRender(),u(s,s,!0),r?e(r):i("error creating image")}),"image/png")}});o.setClearAlpha(n?0:1),h(),l.renderAsync()}))}const Fi=new e,Li=new i,Ni=new i;const zi=new t,Vi=new i,Gi=new i;function Ui(t,e){Vi.getInverse(e.projectionMatrix),Gi.copy(e.projectionMatrix).transpose(),t.traverse((function(t){const e=t.material;if(!e)return;const i=e.uniforms;i&&(i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Vi),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(Gi))}))}function ji(t,e,i){const r=t.createShader(i);if(!r)return void console.log(`error creating WebGL shader ${i}`);t.shaderSource(r,e),t.compileShader(r);return t.getShaderParameter(r,t.COMPILE_STATUS)?r:(console.log(`error compiling shader ${r}: ${t.getShaderInfoLog(r)}`),t.deleteShader(r),null)}function Hi(t,e){const i=t.getExtension(e);return i||console.log(`extension '${e}' not available`),i}const Wi=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function qi(t){const e=document.createElement("canvas");e.width=16,e.height=16,e.style.width="16px",e.style.height="16px";const i=e.getContext("webgl")||e.getContext("experimental-webgl");if(!i)return console.log(`error creating webgl context for ${t}`),!1;if(!(i instanceof WebGLRenderingContext))return console.log("Got unexpected type for WebGL rendering context"),!1;Hi(i,"OES_texture_float"),Hi(i,"OES_texture_half_float"),Hi(i,"WEBGL_color_buffer_float");const r=ji(i,"\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}",i.VERTEX_SHADER),s=ji(i,"\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}",i.FRAGMENT_SHADER);if(!r||!s)return!1;const n=function(t,e,i,r){const s=t.createProgram();return s?(e.forEach((e=>t.attachShader(s,e))),i&&i.forEach(((e,i)=>{t.bindAttribLocation(s,r?r[i]:i,e)})),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)?s:(console.log(`error linking program: ${t.getProgramInfoLog(s)}`),t.deleteProgram(s),null)):void console.log("error creating WebGL program")}(i,[r,s]);if(!n)return console.log("error creating WebGL program"),!1;i.useProgram(n);const o=i.getAttribLocation(n,"a_position"),a=i.getUniformLocation(n,"u_color");if(!a)return console.log("error getting 'u_color' uniform location"),!1;const c=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,Wi,i.STATIC_DRAW),i.enableVertexAttribArray(o),i.vertexAttribPointer(o,2,i.FLOAT,!1,0,0);const l=i.createTexture(),h=new Uint8Array([255,255,255,255]);i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,h);const d=i.createTexture();i.bindTexture(i.TEXTURE_2D,d),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,t,null),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST);const u=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,u),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,d,0);if(i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return console.log(`error creating framebuffer for ${t}`),!1;i.bindTexture(i.TEXTURE_2D,l),i.uniform4fv(a,[0,10,20,1]),i.drawArrays(i.TRIANGLES,0,6),i.bindTexture(i.TEXTURE_2D,d),i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(1,0,0,1),i.clear(i.COLOR_BUFFER_BIT),i.uniform4fv(a,[0,.1,.05,1]),i.drawArrays(i.TRIANGLES,0,6);const m=new Uint8Array(4);if(i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,m),0!==m[0]||m[1]<248||m[2]<248||m[3]<254)return console.log(`not able to actually render to ${t} texture`),!1;if(t===i.FLOAT){i.bindFramebuffer(i.FRAMEBUFFER,u);const t=new Float32Array(4);i.readPixels(0,0,1,1,i.RGBA,i.FLOAT,t);const e=i.getError();if(e)return console.log(`error reading pixels as float: '${function(t,e){switch(e){case t.NO_ERROR:return"no error";case t.INVALID_ENUM:return"invalid enum";case t.INVALID_VALUE:return"invalid value";case t.INVALID_OPERATION:return"invalid operation";case t.INVALID_FRAMEBUFFER_OPERATION:return"invalid framebuffer operation";case t.OUT_OF_MEMORY:return"out of memory";case t.CONTEXT_LOST_WEBGL:return"context lost"}return"unknown error"}(i,e)}'`),!1}return!0}const Xi=new Float32Array(100),Yi=new Uint8Array(100),Ki=[12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20],Zi=new i;function Qi(t,e,i,r,s){const n=s.uniforms,o=[];if(n&&(n.objectId&&(n.objectId.value=Ce?this.id:this.id/255,o.push("objectId")),(n.modelViewMatrixInverse||n.modelViewMatrixInverseTranspose||n.modelViewProjectionMatrix||n.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),n.modelViewMatrixInverse&&(n.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),o.push("modelViewMatrixInverse")),n.modelViewMatrixInverseTranspose&&(n.modelViewMatrixInverse?n.modelViewMatrixInverseTranspose.value.copy(n.modelViewMatrixInverse.value).transpose():n.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),o.push("modelViewMatrixInverseTranspose")),n.modelViewProjectionMatrix&&(n.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.push("modelViewProjectionMatrix")),n.modelViewProjectionMatrixInverse&&(n.modelViewProjectionMatrix?(Zi.copy(n.modelViewProjectionMatrix.value),n.modelViewProjectionMatrixInverse.value.getInverse(Zi)):(Zi.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),n.modelViewProjectionMatrixInverse.value.getInverse(Zi)),o.push("modelViewProjectionMatrixInverse")),o.length)){const e=t.properties.get(s);if(e.program){const i=t.getContext(),r=e.program;i.useProgram(r.program);const s=r.getUniforms();o.forEach((function(t){s.setValue(i,t,n[t].value)}))}}}class Ji{constructor(t){if(this.boundingBox=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],this.boundingBoxSize=new e,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new e,this.signals={ticked:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],rendered:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},"string"==typeof t){const e=document.getElementById(t);this.container=null===e?document.createElement("div"):e}else t instanceof HTMLElement?this.container=t:this.container=document.createElement("div");if(this.container===document.body)this.width=window.innerWidth||1,this.height=window.innerHeight||1;else{const t=this.container.getBoundingClientRect();this.width=t.width||1,this.height=t.height||1,this.container.style.overflow="hidden"}this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.container.appendChild(this.wrapper),this._initParams(),this._initStats(),this._initCamera(),this._initScene(),!1!==this._initRenderer()?(this._initHelper(),this.setBackground(),this.setFog(),this.animate=this.animate.bind(this)):Me.error("Viewer: could not initialize renderer")}_initParams(){this.parameters={fogColor:new s(0),fogNear:50,fogFar:100,backgroundColor:new s(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new s(14540253),lightIntensity:1,ambientColor:new s(14540253),ambientIntensity:.2,sampleLevel:0,rendererEncoding:__WEBPACK_IMPORTED_MODULE_0_three__["w" /* LinearEncoding */]}}_initCamera(){const t=new e(0,0,0),{width:i,height:r}=this;this.perspectiveCamera=new __WEBPACK_IMPORTED_MODULE_0_three__["G" /* PerspectiveCamera */](this.parameters.cameraFov,i/r),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(t),this.orthographicCamera=new __WEBPACK_IMPORTED_MODULE_0_three__["F" /* OrthographicCamera */](i/-2,i/2,r/2,r/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(t),this.stereoCamera=new __WEBPACK_IMPORTED_MODULE_0_three__["Q" /* StereoCamera */],this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;const s=this.parameters.cameraType;if("orthographic"===s)this.camera=this.orthographicCamera;else{if("perspective"!==s&&"stereo"!==s)throw new Error(`Unknown cameraType '${s}'`);this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()}_initStats(){this.stats=new mi}_initScene(){this.scene||(this.scene=new __WEBPACK_IMPORTED_MODULE_0_three__["M" /* Scene */],this.scene.name="scene"),this.rotationGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new __WEBPACK_IMPORTED_MODULE_0_three__["q" /* Fog */](this.parameters.fogColor.getHex()),this.spotLight=new __WEBPACK_IMPORTED_MODULE_0_three__["P" /* SpotLight */](this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new __WEBPACK_IMPORTED_MODULE_0_three__["b" /* AmbientLight */](this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)}_initRenderer(){const t=window.devicePixelRatio,{width:e,height:i}=this;try{this.renderer=new __WEBPACK_IMPORTED_MODULE_0_three__["_0" /* WebGLRenderer */]({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return this.wrapper.innerHTML='

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

',!1}this.renderer.setPixelRatio(t),this.renderer.setSize(e,i),this.renderer.autoClear=!1,this.renderer.sortObjects=!0,this.renderer.outputEncoding=this.parameters.rendererEncoding;const r=this.renderer.getContext();this.renderer.capabilities.isWebGL2?(ke(!0),Pe(this.renderer.extensions.get("EXT_color_buffer_float")),this.supportsHalfFloat=!0):(ke(this.renderer.extensions.get("EXT_frag_depth")),this.renderer.extensions.get("OES_element_index_uint"),Pe(this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&qi(r.FLOAT)),this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&qi(36193)),this.wrapper.appendChild(this.renderer.domElement);const s=e*t,n=i*t;De&&console.log(JSON.stringify({Browser:Ae,OES_texture_float:!!this.renderer.extensions.get("OES_texture_float"),OES_texture_half_float:!!this.renderer.extensions.get("OES_texture_half_float"),WEBGL_color_buffer_float:!!this.renderer.extensions.get("WEBGL_color_buffer_float"),"testTextureSupport Float":qi(r.FLOAT),"testTextureSupport HalfFloat":qi(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:Ce},null,2)),this.pickingTarget=new __WEBPACK_IMPORTED_MODULE_0_three__["Z" /* WebGLRenderTarget */](s,n,{minFilter:__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],magFilter:__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],stencilBuffer:!1,format:__WEBPACK_IMPORTED_MODULE_0_three__["L" /* RGBAFormat */],type:Ce?__WEBPACK_IMPORTED_MODULE_0_three__["p" /* FloatType */]:__WEBPACK_IMPORTED_MODULE_0_three__["W" /* UnsignedByteType */]}),this.pickingTarget.texture.generateMipmaps=!1,this.pickingTarget.texture.encoding=this.parameters.rendererEncoding,this.renderer.setRenderTarget(this.pickingTarget),this.renderer.clear(),this.renderer.setRenderTarget(null),this.sampleTarget=new __WEBPACK_IMPORTED_MODULE_0_three__["Z" /* WebGLRenderTarget */](s,n,{minFilter:__WEBPACK_IMPORTED_MODULE_0_three__["x" /* LinearFilter */],magFilter:__WEBPACK_IMPORTED_MODULE_0_three__["x" /* LinearFilter */],format:__WEBPACK_IMPORTED_MODULE_0_three__["L" /* RGBAFormat */]}),this.sampleTarget.texture.encoding=this.parameters.rendererEncoding,this.holdTarget=new __WEBPACK_IMPORTED_MODULE_0_three__["Z" /* WebGLRenderTarget */](s,n,{minFilter:__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],magFilter:__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],format:__WEBPACK_IMPORTED_MODULE_0_three__["L" /* RGBAFormat */],type:__WEBPACK_IMPORTED_MODULE_0_three__["W" /* UnsignedByteType */]}),this.holdTarget.texture.encoding=this.parameters.rendererEncoding,this.compositeUniforms={tForeground:new __WEBPACK_IMPORTED_MODULE_0_three__["T" /* Uniform */](this.sampleTarget.texture),scale:new __WEBPACK_IMPORTED_MODULE_0_three__["T" /* Uniform */](1)},this.compositeMaterial=new __WEBPACK_IMPORTED_MODULE_0_three__["O" /* ShaderMaterial */]({uniforms:this.compositeUniforms,vertexShader:gi("Quad.vert"),fragmentShader:gi("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:__WEBPACK_IMPORTED_MODULE_0_three__["a" /* AdditiveBlending */],depthTest:!1,depthWrite:!1}),this.compositeCamera=new __WEBPACK_IMPORTED_MODULE_0_three__["F" /* OrthographicCamera */](-1,1,1,-1,0,1),this.compositeScene=new __WEBPACK_IMPORTED_MODULE_0_three__["M" /* Scene */],this.compositeScene.name="compositeScene",this.compositeScene.add(new __WEBPACK_IMPORTED_MODULE_0_three__["A" /* Mesh */](new __WEBPACK_IMPORTED_MODULE_0_three__["I" /* PlaneGeometry */](2,2),this.compositeMaterial))}_initHelper(){const t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),e=new Float32Array(24),i=new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */];i.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](t,1)),i.setAttribute("position",new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](e,3));const r=new __WEBPACK_IMPORTED_MODULE_0_three__["O" /* ShaderMaterial */]({uniforms:{uColor:{value:new s("skyblue")}},vertexShader:gi("BasicLine.vert"),fragmentShader:gi("BasicLine.frag")});this.boundingBoxMesh=new __WEBPACK_IMPORTED_MODULE_0_three__["v" /* LineSegments */](i,r),this.helperGroup.add(this.boundingBoxMesh)}updateHelper(){const t=this.boundingBoxMesh.geometry.attributes.position,e=t.array,{min:i,max:r}=this.boundingBox;e[0]=r.x,e[1]=r.y,e[2]=r.z,e[3]=i.x,e[4]=r.y,e[5]=r.z,e[6]=i.x,e[7]=i.y,e[8]=r.z,e[9]=r.x,e[10]=i.y,e[11]=r.z,e[12]=r.x,e[13]=r.y,e[14]=i.z,e[15]=i.x,e[16]=r.y,e[17]=i.z,e[18]=i.x,e[19]=i.y,e[20]=i.z,e[21]=r.x,e[22]=i.y,e[23]=i.z,t.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()}get cameraDistance(){return Math.abs(this.camera.position.z)}set cameraDistance(t){this.camera.position.z=-t}add(t,e){e?e.forEach((e=>this.addBuffer(t,e))):this.addBuffer(t),t.group.name="meshGroup",t.wireframeGroup.name="wireframeGroup",t.parameters.background?(this.backgroundGroup.add(t.group),this.backgroundGroup.add(t.wireframeGroup)):(this.modelGroup.add(t.group),this.modelGroup.add(t.wireframeGroup)),t.pickable&&this.pickingGroup.add(t.pickingGroup),De&&this.updateHelper()}addBuffer(t,e){function i(r){r instanceof __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]?r.children.forEach(i):(r.userData.buffer=t,r.userData.instance=e,r.onBeforeRender=Qi)}const r=t.getMesh();e&&r.applyMatrix4(e.matrix),i(r),t.group.add(r);const s=t.getWireframeMesh();if(e&&(s.matrix.copy(r.matrix),s.position.copy(r.position),s.quaternion.copy(r.quaternion),s.scale.copy(r.scale)),i(s),t.wireframeGroup.add(s),t.pickable){const s=t.getPickingMesh();e&&(s.matrix.copy(r.matrix),s.position.copy(r.position),s.quaternion.copy(r.quaternion),s.scale.copy(r.scale)),i(s),t.pickingGroup.add(s)}e?this._updateBoundingBox(t.geometry,t.matrix,e.matrix):this._updateBoundingBox(t.geometry,t.matrix)}remove(t){this.translationGroup.children.forEach((function(e){e.remove(t.group),e.remove(t.wireframeGroup)})),t.pickable&&this.pickingGroup.remove(t.pickingGroup),this.updateBoundingBox(),De&&this.updateHelper()}_updateBoundingBox(t,e,i){const r=this.boundingBox;function s(t,e,i){null==t.boundingBox&&t.computeBoundingBox();const s=t.boundingBox.clone();e&&s.applyMatrix4(e),i&&s.applyMatrix4(i),s.min.equals(s.max)&&s.expandByScalar(5),r.union(s)}function n(t){if(void 0!==t.geometry){let e,i;t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(i=t.userData.instance.matrix),s(t.geometry,e,i)}}t?s(t,e,i):(r.makeEmpty(),this.modelGroup.traverse(n),this.backgroundGroup.traverse(n)),r.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()}updateBoundingBox(){this._updateBoundingBox(),De&&this.updateHelper()}getPickingPixels(){const{width:t,height:e}=this,i=t*e*4,r=Ce?new Float32Array(i):new Uint8Array(i);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,t,e,r),r}getImage(t){return new Promise((e=>{if(t){const{width:t,height:i}=this,r=t*i*4;let s=this.getPickingPixels();if(Ce){const t=new Uint8Array(r);for(let e=0;e500&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){const t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,De&&Me.log("rendered still frame")}this.frameRequest=window.requestAnimationFrame(this.animate)}pick(t,e){if("stereo"===this.parameters.cameraType)return{pid:0,instance:void 0,picker:void 0};t*=window.devicePixelRatio,e*=window.devicePixelRatio,t=Math.max(t-2,0),e=Math.max(e-2,0);let i,r,s=0;const n=Ce?Xi:Yi;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,t,e,5,5,n);for(let t=0;t22&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame((()=>{this.render(),this.stats.update()})))}updateZoom(){const t=kt(this.perspectiveCamera.fov),e=2*Math.tan(t/2)*this.cameraDistance;this.orthographicCamera.zoom=this.height/e}absoluteToRelative(t){return 50*(1-t/this.bRadius)}relativeToAbsolute(t){return this.bRadius*(1-t/50)}__updateClipping(){const t=this.parameters;this.bRadius=Math.max(10,.5*this.boundingBoxLength),isFinite(this.bRadius)||(this.bRadius=50),this.camera.getWorldPosition(this.distVector),this.cDist=this.distVector.length(),this.cDist||(this.cameraDistance=Math.abs(t.cameraZ),this.cDist=Math.abs(t.cameraZ));const e=this.scene.fog;if(e.color.set(t.fogColor),"camera"===t.clipMode)this.camera.near=t.clipNear,this.camera.far=t.clipFar,e.near=t.fogNear,e.far=t.fogFar;else if("absolute"===t.clipScale)this.camera.near=this.cDist-t.clipNear,this.camera.far=this.cDist+t.clipFar,e.near=this.cDist-t.fogNear,e.far=this.cDist+t.fogFar;else{const i=(50-t.clipNear)/50,r=-(50-t.clipFar)/50;this.camera.near=this.cDist-this.bRadius*i,this.camera.far=this.cDist+this.bRadius*r;const s=(50-t.fogNear)/50,n=-(50-t.fogFar)/50;e.near=this.cDist-this.bRadius*s,e.far=this.cDist+this.bRadius*n}"camera"!==t.clipMode&&("PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,t.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),e.near=Math.max(.1,e.near),e.far=Math.max(1,e.far)):"OrthographicCamera"===this.camera.type&&t.clipDist>0&&(this.camera.near=Math.max(t.clipDist,this.camera.near)))}__updateCamera(){const e=this.camera;e.updateMatrix(),e.updateMatrixWorld(!0),e.updateProjectionMatrix(),function(e,i,r,s,n){let o=new t;r.getSize(o);const a=o.height,c=r.getPixelRatio(),l="OrthographicCamera"===i.type;zi.set(o.width,o.height),Vi.getInverse(i.projectionMatrix),Gi.copy(i.projectionMatrix).transpose(),e.traverse((function(t){const e=t.material;if(!e)return;const i=e.uniforms;if(i){if(e.clipNear){const t=(50-e.clipNear)/50,r=s-n*t;i.clipNear.value=r}i.canvasHeight&&(i.canvasHeight.value=a),i.resolution&&i.resolution.value.copy(zi),i.pixelRatio&&(i.pixelRatio.value=c),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Vi),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(Gi),i.ortho&&(i.ortho.value=l)}}))}(this.scene,e,this.renderer,this.cDist,this.bRadius),function(t,e){t.traverseVisible((function(t){if(!(t instanceof o&&t.userData.buffer.parameters.sortParticles))return;const i=t.geometry.attributes,r=i.position.count;if(0===r)return;let s,n,a,c,l,h,d,u;Li.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),Ni.multiplyMatrices(e.projectionMatrix,Li),t.userData.sortData?(s=t.userData.sortData,a=s.__zArray,n=s.__sortArray,c=s.__cmpFn):(a=new Float32Array(r),n=new Uint32Array(r),c=function(t,e){const i=a[t],r=a[e];return i>r?1:ie?1:t=l&&e(t[o],n)>0;)t[o+1]=t[o],--o;t[o+1]=n}if(-1===c)break;h=s[c--],l=s[c--]}else{for(o=l+1,a=h,d(l+h>>1,o),e(t[l],t[h])>0&&d(l,h),e(t[o],t[h])>0&&d(o,h),e(t[l],t[o])>0&&d(l,o),n=t[o];;){do{o++}while(e(t[o],n)<0);do{a--}while(e(t[a],n)>0);if(a=a-l?(s[++c]=o,s[++c]=h,h=a-1):(s[++c]=l,s[++c]=a-1,l=o)}}(n,c);for(let t in i){const e=i[t],o=e.array,a=e.itemSize;s[t]||(s[t]=new Float32Array(a*r)),u=s[t],s[t]=o;for(let t=0;t0&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(e,i):this.__renderModelGroup(e,i)}render(t=!1,e){if(this.rendering)Me.warn("'tried to call 'render' from within 'render'");else{this.rendering=!0;try{this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(t,e):this.__render(t,this.camera,e),this.lastRenderedPicking=t}finally{this.rendering=!1,this.renderPending=!1}this.signals.rendered.dispatch()}}clear(){Me.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()}dispose(){this.renderer.dispose(),window.cancelAnimationFrame(this.frameRequest)}}const tr=1,er=2,ir=3;function rr(t){const e=t.touches[0].pageX-t.touches[1].pageX,i=t.touches[0].pageY-t.touches[1].pageY;return Math.sqrt(e*e+i*i)}class sr{constructor(e,i={}){this.domElement=e,this.signals={moved:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],scrolled:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],dragged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],dropped:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],clicked:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],hovered:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],doubleClicked:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.position=new t,this.prevPosition=new t,this.down=new t,this.canvasPosition=new t,this.prevClickCP=new t,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=0,this.buttons=0,this.pressed=!1,this.altKey=!1,this.ctrlKey=!1,this.metaKey=!1,this.shiftKey=!1,this.domElement.style.touchAction="none",this.hoverTimeout=st(i.hoverTimeout,50),this.handleScroll=st(i.handleScroll,!0),this.doubleClickSpeed=st(i.doubleClickSpeed,500),this._listen=this._listen.bind(this),this._onMousewheel=this._onMousewheel.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMousedown=this._onMousedown.bind(this),this._onMouseup=this._onMouseup.bind(this),this._onContextmenu=this._onContextmenu.bind(this),this._onTouchstart=this._onTouchstart.bind(this),this._onTouchend=this._onTouchend.bind(this),this._onTouchmove=this._onTouchmove.bind(this),this._listen();const r={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,r),document.addEventListener("wheel",this._onMousewheel,r),document.addEventListener("MozMousePixelScroll",this._onMousewheel,r),document.addEventListener("mousemove",this._onMousemove,r),document.addEventListener("mousedown",this._onMousedown,r),document.addEventListener("mouseup",this._onMouseup,r),document.addEventListener("contextmenu",this._onContextmenu,r),document.addEventListener("touchstart",this._onTouchstart,r),document.addEventListener("touchend",this._onTouchend,r),document.addEventListener("touchmove",this._onTouchmove,r)}get key(){let t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t}setParameters(t={}){this.hoverTimeout=st(t.hoverTimeout,this.hoverTimeout)}_listen(){const t=window.performance.now(),e=this.canvasPosition;this.doubleClickPending&&t-this.lastClicked>this.doubleClickSpeed&&(this.doubleClickPending=!1),t-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement&&(this.hovering=!0,this.signals.hovered.dispatch(e.x,e.y))),this.frameRequest=window.requestAnimationFrame(this._listen)}_onMousewheel(t){if(t.target!==this.domElement||!this.handleScroll)return;t.preventDefault(),this._setKeys(t);let e=0;"deltaY"in t&&"deltaMode"in t&&void 0!==t.deltaY&&void 0!==t.deltaMode?e=t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?.025*-t.deltaY:t.deltaMode===WheelEvent.DOM_DELTA_LINE?-t.deltaY*(2.5/3):2.5*-t.deltaY:"deltaY"in t&&!("detail"in t)?e=.025*-t.deltaY:void 0!==t.wheelDelta?e=.025*-t.wheelDelta:void 0!==t.wheelDeltaY?e=.025*-t.wheelDeltaY:void 0!==t.detail&&(e=-t.detail/3),this.signals.scrolled.dispatch(e),setTimeout((()=>{this.scrolled=!0}),this.hoverTimeout)}_onMousemove(t){t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,this._setKeys(t),this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.clientX,t.clientY),this._setCanvasPosition(t);const e=this.prevPosition.x-this.position.x,i=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(e,i),this.pressed&&this.signals.dragged.dispatch(e,i)}_onMousedown(t){t.target===this.domElement&&(t.preventDefault(),this._setKeys(t),this.moving=!1,this.hovering=!1,this.down.set(t.clientX,t.clientY),this.position.set(t.clientX,t.clientY),this.which=t.which,this.buttons=function(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){const e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<2&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(i/2);else{this.which=3,this.buttons=2;const t=this.prevPosition.x-this.position.x,e=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(t,e),this.pressed&&this.signals.dragged.dispatch(t,e)}}}}_distance(){return this.position.distanceTo(this.down)}_setCanvasPosition(t){const e=this.domElement.getBoundingClientRect();let i,r;"clientX"in t&&"clientY"in t?(i=t.clientX-e.left,r=t.clientY-e.top):(i=t.offsetX,r=t.offsetY),this.canvasPosition.set(i,e.height-r)}_setKeys(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey}dispose(){document.removeEventListener("mousewheel",this._onMousewheel),document.removeEventListener("wheel",this._onMousewheel),document.removeEventListener("MozMousePixelScroll",this._onMousewheel),document.removeEventListener("mousemove",this._onMousemove),document.removeEventListener("mousedown",this._onMousedown),document.removeEventListener("mouseup",this._onMouseup),document.removeEventListener("contextmenu",this._onContextmenu),document.removeEventListener("touchstart",this._onTouchstart),document.removeEventListener("touchend",this._onTouchend),document.removeEventListener("touchmove",this._onTouchmove),window.cancelAnimationFrame(this.frameRequest)}}const nr=new i,or=new i,ar=new i,cr=new i,lr=new i,hr=new e,dr=new r,ur=new r,mr=new i,pr=new e,fr=new e;class gr{constructor(t,e={}){this.stage=t,this.rotateSpeed=st(e.rotateSpeed,2),this.zoomSpeed=st(e.zoomSpeed,1.2),this.panSpeed=st(e.panSpeed,1),this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls}get component(){return this.stage.transformComponent}get atom(){return this.stage.transformAtom}_setPanVector(t,e,i=0){const r=this.controls.getCanvasScaleFactor(i);pr.set(t,e,0),pr.multiplyScalar(this.panSpeed*r)}_getRotateXY(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]}_getCameraRotation(t){return t.extractRotation(this.viewer.camera.matrixWorld),t.multiply(or.makeRotationY(Math.PI)),t}_transformPanVector(){this.component&&(mr.extractRotation(this.component.transform),mr.premultiply(this.viewer.rotationGroup.matrix),mr.getInverse(mr),mr.multiply(this._getCameraRotation(cr)),pr.applyMatrix4(mr))}zoom(t){this.controls.zoom(this.zoomSpeed*t*.02)}pan(t,e){this._setPanVector(t,e),mr.getInverse(this.viewer.rotationGroup.matrix),mr.multiply(this._getCameraRotation(cr)),pr.applyMatrix4(mr),this.controls.translate(pr)}panComponent(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(pr),this.component.updateMatrix())}panAtom(t,e){this.atom&&this.component&&(this.atom.positionToVector3(fr),fr.add(this.viewer.translationGroup.position),fr.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,fr.z),this._transformPanVector(),this.atom.positionAdd(pr),this.component.updateRepresentations({position:!0}))}rotate(t,e){const[i,r]=this._getRotateXY(t,e);this._getCameraRotation(cr),hr.set(1,0,0),hr.applyMatrix4(cr),dr.setFromAxisAngle(hr,r),hr.set(0,1,0),hr.applyMatrix4(cr),ur.setFromAxisAngle(hr,i),dr.multiply(ur),cr.makeRotationFromQuaternion(dr),this.controls.applyMatrix(cr)}zRotate(t,e){const i=this.rotateSpeed*((-t+e)/-2)*.01;ar.makeRotationZ(i),this.controls.applyMatrix(ar)}rotateComponent(t,e){if(!this.component)return;const[i,r]=this._getRotateXY(t,e);this._getCameraRotation(lr),cr.extractRotation(this.component.transform),cr.premultiply(this.viewer.rotationGroup.matrix),cr.getInverse(cr),cr.premultiply(lr),hr.set(1,0,0),hr.applyMatrix4(cr),nr.makeRotationAxis(hr,r),hr.set(0,1,0),hr.applyMatrix4(cr),or.makeRotationAxis(hr,i),nr.multiply(or),dr.setFromRotationMatrix(nr),this.component.quaternion.premultiply(dr),this.component.quaternion.normalize(),this.component.updateMatrix()}}const yr=new e;class br{constructor(t,e){this.stage=e,this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver}get type(){return this.picker.type}get altKey(){return this.mouse.altKey}get ctrlKey(){return this.mouse.ctrlKey}get metaKey(){return this.mouse.metaKey}get shiftKey(){return this.mouse.shiftKey}get canvasPosition(){return this.mouse.canvasPosition}get component(){return this.stage.getComponentsByObject(this.picker.data).list[0]}get object(){return this.picker.getObject(this.pid)}get position(){return this.picker.getPosition(this.pid,this.instance,this.component)}get closestBondAtom(){if("bond"!==this.type||!this.bond)return;const t=this.bond,e=this.controls,i=this.canvasPosition,r=t.atom1.positionToVector3(),s=t.atom2.positionToVector3();r.applyMatrix4(this.component.matrix),s.applyMatrix4(this.component.matrix);const n=e.getPositionOnCanvas(r),o=e.getPositionOnCanvas(s);return c=n,l=o,(a=i).distanceTo(c)=t.length))return new br(i,this.stage);console.error("pid >= picker.array.length")}}}const vr=new r,wr=new e,Ar=new e,_r=new e,Sr=new e,Cr=new i,Pr=new e,Ir=new i;class kr{constructor(t){this.stage=t,this.signals={changed:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.viewer=t.viewer}get position(){return this.viewer.translationGroup.position}get rotation(){return this.viewer.rotationGroup.quaternion}changed(){this.viewer.requestRender(),this.signals.changed.dispatch()}getPositionOnCanvas(e,i){const r=wt(i,t);const s=this.viewer;return _r.copy(e).add(s.translationGroup.position).applyMatrix4(s.rotationGroup.matrix).project(s.camera),r.set((_r.x+1)*s.width/2,(_r.y+1)*s.height/2)}getCanvasScaleFactor(t=0){const e=this.viewer.camera;if(e instanceof __WEBPACK_IMPORTED_MODULE_0_three__["F" /* OrthographicCamera */])return 1/e.zoom;{t=Math.abs(t),t+=this.getCameraDistance();const i=kt(e.fov);return 2*t*Math.tan(i/2)/this.viewer.height}}getOrientation(t){const e=_t(t);e.copy(this.viewer.rotationGroup.matrix);const i=this.getCameraDistance();return e.scale(Sr.set(i,i,i)),e.setPosition(this.viewer.translationGroup.position),e}orient(t){_t(t).decompose(wr,vr,Ar);const e=this.viewer;e.rotationGroup.setRotationFromQuaternion(vr),e.translationGroup.position.copy(wr),e.cameraDistance=Ar.z,e.updateZoom(),this.changed()}translate(t){this.viewer.translationGroup.position.add(At(t)),this.changed()}center(t){this.viewer.translationGroup.position.copy(At(t)).negate(),this.changed()}zoom(t){this.distance(this.getCameraDistance()*(1-t))}getCameraDistance(){return this.viewer.cameraDistance}distance(t){this.viewer.cameraDistance=Math.max(Math.abs(t),.2),this.viewer.updateZoom(),this.changed()}spin(t,e){Cr.getInverse(this.viewer.rotationGroup.matrix),Pr.copy(At(t)).applyMatrix4(Cr),this.viewer.rotationGroup.rotateOnAxis(Pr,e),this.changed()}rotate(t){this.viewer.rotationGroup.setRotationFromQuaternion(St(t)),this.changed()}align(t){Ir.getInverse(_t(t)),this.viewer.rotationGroup.setRotationFromMatrix(Ir),this.changed()}applyMatrix(t){this.viewer.rotationGroup.applyMatrix4(_t(t)),this.changed()}}class Mr{constructor(t,e,...i){this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=st(t,1e3),this.controls=e,this.startTime=window.performance.now(),this._init(...i)}get done(){return 1===this.alpha}get paused(){return this._paused}tick(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Rt(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach((t=>t())),this.done}pause(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0}resume(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)}toggle(){this._paused?this.resume():this.pause()}then(t){let e;return e=this.done?Promise.resolve():new Promise((t=>this._resolveList.push(t))),e.then(t)}}class Tr extends Mr{constructor(t,e,...i){super(st(t,1/0),e,...i)}_init(t,i){Array.isArray(t)?this.axis=(new e).fromArray(t):this.axis=st(t,new e(0,1,0)),this.angle=st(i,.01)}_tick(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)}}class Br extends Mr{constructor(t,e,...i){super(st(t,1/0),e,...i),this.angleSum=0,this.direction=1}_init(t,i,r){Array.isArray(t)?this.axis=(new e).fromArray(t):this.axis=st(t,new e(0,1,0)),this.angleStep=st(i,.01),this.angleEnd=st(r,.2)}_tick(t){if(!this.axis||!this.angleStep||!this.angleEnd)return;const e=Rt(0,1,Math.abs(this.angleSum)/this.angleEnd),i=this.angleStep*this.direction*(1.1-e);this.controls.spin(this.axis,i*t.lastDuration/16),this.angleSum+=this.angleStep,this.angleSum>=this.angleEnd&&(this.direction*=-1,this.angleSum=-this.angleEnd)}}class Dr extends Mr{_init(t,i){this.moveFrom=At(st(t,new e)),this.moveTo=At(st(i,new e))}_tick(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()}}class $r extends Mr{_init(t,e){this.zoomFrom=t,this.zoomTo=e}_tick(){this.controls.distance($t(this.zoomFrom,this.zoomTo,this.alpha))}}class Or extends Mr{constructor(){super(...arguments),this._currentRotation=new r}_init(t,e){this.rotateFrom=St(t),this.rotateTo=St(e),this._currentRotation=new r}_tick(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)}}class Rr extends Mr{_init(t,e,i){this.valueFrom=t,this.valueTo=e,this.callback=i}_tick(){this.callback($t(this.valueFrom,this.valueTo,this.alpha))}}class Er extends Mr{_init(t){this.callback=t}_tick(){1===this.alpha&&this.callback()}}class Fr{constructor(t=[]){this._resolveList=[],this._list=t}get done(){return this._list.every((t=>t.done))}then(t){let e;return e=this.done?Promise.resolve():new Promise((t=>{this._resolveList.push(t),this._list.forEach((t=>{t.then((()=>{this._resolveList.forEach((t=>{t()})),this._resolveList.length=0}))}))})),e.then(t)}}class Lr{constructor(t){this.stage=t,this.animationList=[],this.finishedList=[],this.viewer=t.viewer,this.controls=t.viewerControls}get paused(){return this.animationList.every((t=>t.paused))}add(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t}remove(t){const e=this.animationList,i=e.indexOf(t);i>-1&&e.splice(i,1)}run(t){const e=this.finishedList,i=this.animationList,r=i.length;for(let s=0;st.pause()))}resume(){this.animationList.forEach((t=>t.resume()))}toggle(){this.paused?this.resume():this.pause()}clear(){this.animationList.length=0}dispose(){this.clear()}}class Nr{constructor(t,e){if(this.fn=t,this.queue=[],this.pending=!1,this.next=this.next.bind(this),e){for(let t=0,i=e.length;tthis.run(t)))):this.pending=!1}push(t){this.queue.push(t),this.pending||this.next()}kill(){this.queue.length=0}length(){return this.queue.length}}class zr{constructor(t,e,i){this.type="",this.parameters={lazy:{type:"boolean"},clipNear:{type:"range",step:1,max:100,min:0,buffer:!0},clipRadius:{type:"number",precision:1,max:1e3,min:0,buffer:!0},clipCenter:{type:"vector3",precision:1,buffer:!0},flatShaded:{type:"boolean",buffer:!0},opacity:{type:"range",step:.01,max:1,min:0,buffer:!0},depthWrite:{type:"boolean",buffer:!0},side:{type:"select",buffer:!0,options:{front:"front",back:"back",double:"double"}},wireframe:{type:"boolean",buffer:!0},colorData:{type:"hidden",update:"color"},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:Fe.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:Fe.getModes()},roughness:{type:"range",step:.01,max:1,min:0,buffer:!0},metalness:{type:"range",step:.01,max:1,min:0,buffer:!0},diffuse:{type:"color",buffer:!0},diffuseInterior:{type:"boolean",buffer:!0},useInteriorColor:{type:"boolean",buffer:!0},interiorColor:{type:"color",buffer:!0},interiorDarkening:{type:"range",step:.01,max:1,min:0,buffer:!0},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=e,this.tasks=new ui,this.queue=new Nr(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=Fe.getSchemes()),this.toBePrepared=!1}init(t){const r=t||{};this.clipNear=st(r.clipNear,0),this.clipRadius=st(r.clipRadius,0),this.clipCenter=st(r.clipCenter,new e),this.flatShaded=st(r.flatShaded,!1),this.side=st(r.side,"double"),this.opacity=st(r.opacity,1),this.depthWrite=st(r.depthWrite,!0),this.wireframe=st(r.wireframe,!1),this.setColor(r.color,r),this.colorData=st(r.colorData,void 0),this.colorScheme=st(r.colorScheme,"uniform"),this.colorScale=st(r.colorScale,""),this.colorReverse=st(r.colorReverse,!1),this.colorValue=st(r.colorValue,9474192),this.colorDomain=st(r.colorDomain,void 0),this.colorMode=st(r.colorMode,"hcl"),this.visible=st(r.visible,!0),this.quality=st(r.quality,void 0),this.roughness=st(r.roughness,.4),this.metalness=st(r.metalness,0),this.diffuse=st(r.diffuse,16777215),this.diffuseInterior=st(r.diffuseInterior,!1),this.useInteriorColor=st(r.useInteriorColor,!1),this.interiorColor=st(r.interiorColor,2236962),this.interiorDarkening=st(r.interiorDarkening,0),this.lazy=st(r.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=st(r.matrix,new i),this.disablePicking=st(r.disablePicking,!1);const s=this.parameters;!0===s.sphereDetail&&(s.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===s.radialSegments&&(s.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===s.openEnded&&(s.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===s.disableImpostor&&(s.disableImpostor={type:"boolean",rebuild:!0}),"low"===r.quality?(s.sphereDetail&&(this.sphereDetail=0),s.radialSegments&&(this.radialSegments=5)):"medium"===r.quality?(s.sphereDetail&&(this.sphereDetail=1),s.radialSegments&&(this.radialSegments=10)):"high"===r.quality?(s.sphereDetail&&(this.sphereDetail=2),s.radialSegments&&(this.radialSegments=20)):(s.sphereDetail&&(this.sphereDetail=st(r.sphereDetail,1)),s.radialSegments&&(this.radialSegments=st(r.radialSegments,10))),s.openEnded&&(this.openEnded=st(r.openEnded,!0)),s.disableImpostor&&(this.disableImpostor=st(r.disableImpostor,!1))}getColorParams(t){return Object.assign({data:this.colorData,scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode,colorSpace:this.colorSpace},t)}getBufferParams(t={}){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,depthWrite:this.depthWrite,side:this.side,wireframe:this.wireframe,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,diffuseInterior:this.diffuseInterior,useInteriorColor:this.useInteriorColor,interiorColor:this.interiorColor,interiorDarkening:this.interiorDarkening,matrix:this.matrix,disablePicking:this.disablePicking},t)}setColor(t,e){const i=Object.keys(Fe.getSchemes());if("string"==typeof t&&i.includes(t.toLowerCase()))e?e.colorScheme=t:this.setParameters({colorScheme:t});else if(void 0!==t){let i=new s(t).getHex();e?(e.colorScheme="uniform",e.colorValue=i):this.setParameters({colorScheme:"uniform",colorValue:i})}return this}prepare(t){}create(){}update(t){this.build()}build(t){if(!this.lazy||this.visible&&this.opacity){if(!this.toBePrepared)return this.tasks.increment(),void this.make();this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(t||!1)}else this.lazyProps.build=!0}make(t,e){De&&Me.time("Representation.make "+this.type);const i=()=>{t?(this.update(t),this.viewer.requestRender(),this.tasks.decrement(),e&&e()):(this.clear(),this.create(),this.manualAttach||this.disposed||(De&&Me.time("Representation.attach "+this.type),this.attach((()=>{De&&Me.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),e&&e()})))),De&&Me.timeEnd("Representation.make "+this.type)};this.toBePrepared?this.prepare(i):i()}attach(t){this.setVisibility(this.visible),t()}setVisibility(t,e){if(this.visible=t,this.visible&&this.opacity){const t=this.lazyProps,e=t.bufferParams,i=t.what;if(t.build)return t.build=!1,this.build(),this;(Object.keys(e).length||Object.keys(i).length)&&(t.bufferParams={},t.what={},this.updateParameters(e,i))}return this.bufferList.forEach((function(e){e.setVisibility(t)})),e||this.viewer.requestRender(),this}setParameters(t,e={},i=!1){const r=t||{},s=this.parameters,n={};this.opacity||void 0===r.opacity||(this.lazyProps.build?(this.lazyProps.build=!1,i=!0):(Object.assign(n,this.lazyProps.bufferParams),Object.assign(e,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(r.color,r);for(let t in r)if(void 0!==r[t]&&null!=s[t]&&(s[t].int&&(r[t]=parseInt(r[t])),s[t].float&&(r[t]=parseFloat(r[t])),r[t]!==this[t]||r[t].equals&&!r[t].equals(this[t]))){if(this[t]&&this[t].copy&&r[t].copy?this[t].copy(r[t]):this[t]&&this[t].set?this[t].set(r[t]):this[t]=r[t],s[t].buffer)if(!0===s[t].buffer)n[t]=r[t];else{n[s[t].buffer]=r[t]}s[t].update&&(e[s[t].update]=!0),!s[t].rebuild||"impostor"===s[t].rebuild&&Ie&&!this.disableImpostor||(i=!0)}return i?this.build():this.updateParameters(n,e),this}updateParameters(t={},e){if(this.lazy&&(!this.visible||!this.opacity)&&!1===t.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,t),void Object.assign(this.lazyProps.what,e);this.bufferList.forEach((function(e){e.setParameters(t)})),Object.keys(e).length&&this.update(e),this.viewer.requestRender()}getParameters(){const t={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach((e=>{null!==this.parameters[e]&&(t[e]=this[e])})),t}clear(){this.bufferList.forEach((t=>{this.viewer.remove(t),t.dispose()})),this.bufferList.length=0,this.viewer.requestRender()}dispose(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()}}class Vr{constructor(t){this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=t,this.blobUrl=window.URL.createObjectURL(Ee.get(t)),this.worker=new Worker(this.blobUrl),Ee.activeWorkerCount+=1,this.worker.onmessage=e=>{this.pending-=1;const i=e.data.__postId;De&&Me.timeEnd("Worker.postMessage "+t+" #"+i);const r=this.onmessageDict[i];r&&r.call(this.worker,e),delete this.onmessageDict[i],delete this.onerrorDict[i]},this.worker.onerror=e=>{if(this.pending-=1,e.data){const i=e.data.__postId,r=this.onerrorDict[i];r?r.call(this.worker,e):Me.error("Worker.onerror",i,t,e),delete this.onmessageDict[i],delete this.onerrorDict[i]}else Me.error("Worker.onerror",t,e)}}post(t={},e,i,r){this.onmessageDict[this.postCount]=i,this.onerrorDict[this.postCount]=r,t.__name=this.name,t.__postId=this.postCount,t.__debug=De,De&&Me.time(`Worker.postMessage ${this.name} #${this.postCount}`);try{this.worker.postMessage(t,e)}catch(e){Me.error("worker.post:",e),this.worker.postMessage(t)}return this.pending+=1,this.postCount+=1,this}terminate(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),Ee.activeWorkerCount-=1):Me.log("no worker to terminate")}}class Gr{constructor(t,e=2){this.pool=[],this.count=0,this.maxCount=Math.min(8,e),this.name=t}post(t={},e,i,r){const s=this.getNextWorker();return s?s.post(t,e,i,r):console.error("unable to get worker from pool"),this}terminate(){this.pool.forEach((function(t){t.terminate()}))}getNextWorker(){let t,e=1/0;for(let i=0;i=this.count){t=new Vr(this.name),this.pool.push(t),this.count+=1;break}const r=this.pool[i];if(0===r.pending){t=r;break}r.pendings&&(s=c),l>n&&(n=l),h>o&&(o=h)}return[Yr([e,i,r]),Yr([s,n,o])]}function Wr(t,e){for(let i=0,r=e.length;i0){const o=1/Math.sqrt(n);t[e]=i*o,t[e+1]=r*o,t[e+2]=s*o}}}function Yr(t){return new Float32Array(t||3)}function Kr(t,e,i){const r=e[0],s=e[1],n=e[2],o=i[0],a=i[1],c=i[2];t[0]=s*c-n*a,t[1]=n*o-r*c,t[2]=r*a-s*o}function Zr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Qr(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2]}function Jr(t,e,i){t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2]}function ts(t,e,i=0){t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2]}function es(t,e,i=0){e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2]}function is(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function rs(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function ss(t,e,i){ns(t,e,1/i)}function ns(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}function os(t,e){const i=is(e);0==i?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):ns(t,e,1/Math.sqrt(i))}function as(t,e,i){t[0]=e[0]-i,t[1]=e[1]-i,t[2]=e[2]-i}function cs(t,e,i){t[0]=e[0]+i,t[1]=e[1]+i,t[2]=e[2]+i}function ls(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function hs(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function ds(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}function us(t,e){const i=t[0],r=t[1],s=t[2],n=e[0],o=e[1],a=e[2],c=r*a-s*o,l=s*n-i*a,h=i*o-r*n,d=Math.sqrt(c*c+l*l+h*h),u=i*n+r*o+s*a;return Math.atan2(d,u)}function ms(t,i=9){const r=Math.floor(i/2),s=t.position1.length/3,n=3*(r*s),o=1/i,a=_i(t.position1,t.position2),c=new Float32Array(n),l=new Float32Array(n),h=new e;for(let e=0;e0){const e=3*p;n[e]=t.position2[3*d-3],n[e+1]=t.position2[3*d-2],n[e+1]=t.position2[3*d-1]}const y=new Float32Array(s),b=new Float32Array(n),x=Ai(y,b),v=new Float32Array(o),w={position:x,position1:y,position2:b,color:v,color2:v};return a&&(w.radius=new Float32Array(a)),c&&t.picking&&(t.picking.array=new Float32Array(c),w.picking=t.picking),l&&(w.primitiveId=new Float32Array(l)),w}Gr.prototype.constructor=Gr,Hr.__deps=[Yr],ss.__deps=[ns],os.__deps=[ns,is];const gs=new e;class ys{static get Picker(){return He.get(this.type)}static get Buffer(){return je.get(this.type)}static getShapeKey(t){return this.type+t[0].toUpperCase()+t.substr(1)}static expandBoundingBox(t,e){}static valueToShape(t,e,i){const r=t._primitiveData[this.getShapeKey(e)];switch(this.fields[e]){case"v3":case"c":n=r,void 0!==(s=i).toArray?s=s.toArray():void 0!==s.x?s=[s.x,s.y,s.z]:void 0!==s.r&&(s=[s.r,s.g,s.b]),n.push.apply(n,s);break;default:r.push(i)}var s,n}static objectToShape(t,e){Object.keys(this.fields).forEach((i=>{this.valueToShape(t,i,e[i])})),this.valueToShape(t,"name",e.name),this.expandBoundingBox(t.boundingBox,e)}static valueFromShape(t,i,r){const n=t._primitiveData[this.getShapeKey(r)];switch(this.fields[r]){case"v3":return(new e).fromArray(n,3*i);case"c":return(new s).fromArray(n,3*i);default:return n[i]}}static objectFromShape(t,e){let i=this.valueFromShape(t,e,"name");void 0===i&&(i=`${this.type}: ${e} (${t.name})`);const r={shape:t,name:i};return Object.keys(this.fields).forEach((i=>{r[i]=this.valueFromShape(t,e,i)})),r}static arrayFromShape(t,e){const i=t._primitiveData[this.getShapeKey(e)];return"s"===this.fields[e]?i:new Float32Array(i)}static dataFromShape(t){const e={};return this.Picker&&(e.picking=new this.Picker(t)),Object.keys(this.fields).forEach((i=>{e[i]=this.arrayFromShape(t,i)})),e}static bufferFromShape(t,e){return new this.Buffer(this.dataFromShape(t),e)}}ys.type="",ys.fields={};class bs extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}bs.type="sphere",bs.fields={position:"v3",color:"c",radius:"f"};class xs extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}xs.type="box",xs.fields={position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"};class vs extends xs{}vs.type="octahedron";class ws extends xs{}ws.type="tetrahedron";class As extends ys{static positionFromShape(t,e){const i=this.valueFromShape(t,e,"position1"),r=this.valueFromShape(t,e,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position1)),t.expandByPoint(gs.fromArray(e.position2))}static bufferFromShape(t,e={}){let i=this.dataFromShape(t);return"cylinder"===this.type&&e.dashedCylinder&&(i=ps(i)),new this.Buffer(i,e)}}As.type="cylinder",As.fields={position1:"v3",position2:"v3",color:"c",radius:"f"};class _s extends As{}_s.type="arrow";class Ss extends As{}Ss.type="cone";class Cs extends bs{}Cs.type="ellipsoid",Cs.fields={position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"};class Ps extends Cs{}Ps.type="torus";class Is extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}Is.type="text",Is.fields={position:"v3",color:"c",size:"f",text:"s"};class ks extends ys{static positionFromShape(t,e){return this.valueFromShape(t,e,"position")}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position))}}ks.type="point",ks.fields={position:"v3",color:"c"};class Ms extends ys{static positionFromShape(t,e){const i=this.valueFromShape(t,e,"position1"),r=this.valueFromShape(t,e,"position2");return i.add(r).multiplyScalar(.5)}static expandBoundingBox(t,e){t.expandByPoint(gs.fromArray(e.position1)),t.expandByPoint(gs.fromArray(e.position2))}}Ms.type="wideline",Ms.fields={position1:"v3",position2:"v3",color:"c"};class Ts{constructor(t,e){this.exp=3;const i=e||function(t){const{x:e,y:i,z:r}=t,s=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],n=e.length,{min:o,max:c}=s;for(let t=0;t>this.exp),this.boundY=1+(i.max.y-this.minY>>this.exp),this.boundZ=1+(i.max.z-this.minZ>>this.exp);const r=this.boundX*this.boundY*this.boundZ,s=void 0!==t.count?t.count:t.x.length,n=t.x,o=t.y,c=t.z;let l=0;const h=new Uint32Array(r),d=new Int32Array(s);for(let t=0;t>this.exp,i=o[t]-this.minY>>this.exp,r=c[t]-this.minZ>>this.exp,s=(e*this.boundY+i)*this.boundZ+r;1===(h[s]+=1)&&(l+=1),d[t]=s}const u=new Uint16Array(l);for(let t=0,e=0;t0&&(h[t]=e+1,u[e]=i,e+=1)}const m=new Uint32Array(l);for(let t=1;t0){const i=e-1;f[m[i]+p[i]]=t,p[i]+=1}}this.grid=h,this.bucketCount=u,this.bucketOffset=m,this.bucketArray=f,this.xArray=n,this.yArray=o,this.zArray=c}within(t,e,i,r){const s=[];return this.eachWithin(t,e,i,r,(t=>s.push(t))),s}eachWithin(t,e,i,r,s){const n=r*r,o=Math.max(0,t-r-this.minX>>this.exp),a=Math.max(0,e-r-this.minY>>this.exp),c=Math.max(0,i-r-this.minZ>>this.exp),l=Math.min(this.boundX,1+(t+r-this.minX>>this.exp)),h=Math.min(this.boundY,1+(e+r-this.minY>>this.exp)),d=Math.min(this.boundZ,1+(i+r-this.minZ>>this.exp));for(let r=o;r0){const r=l-1,o=this.bucketOffset[r],a=o+this.bucketCount[r];for(let r=o;rr?s.set(this[e].subarray(0,r)):s.set(this[e]),this[e]=s}}growIfFull(){if(this.count>=this.length){const t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}}copyFrom(t,e,i,r){for(let s=0,n=this._fields.length;s0;)h-=1;l<=h&&(l===c?c=h:h===c&&(c=l),(o=l)!==(a=h)&&(i.copyFrom(e,0,o,1),e.copyWithin(o,a,1),e.copyFrom(i,a,0,1)),l+=1,h-=1)}while(l<=h);r(s,h),r(l,n)}var o,a}(0,this.count-1),Me.timeEnd("Store.sort")}clear(){this.count=0}dispose(){for(let t=0,e=this._fields.length;t>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}class Os{constructor(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()}get(t){return 0!=(this._words[t>>>5]&1<>>5]|=1<>>5]&=~(1<>>5]^=1<>>5,o=e>>>5;for(let t=n+1;t>>5]|=1<>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]|=1<>>5]&=~(1<>>i,this}_isRangeValue(t,e,i){if(e>>5,o=e>>>5;for(let t=n+1;t>>5]&1<>>5]&1<>>5]&1<>>5]&1<>>5]&1<0){const{types:r,groups:s,centers:n,atomSets:o}=t;r.push(e.type),s.push(e.group),n.x.push(e.x/i),n.y.push(e.y/i),n.z.push(e.z/i),o.push(e.atomSet)}}const Ns=0,zs=["D-BETA-PEPTIDE, C-GAMMA LINKING","D-GAMMA-PEPTIDE, C-DELTA LINKING","D-PEPTIDE COOH CARBOXY TERMINUS","D-PEPTIDE NH3 AMINO TERMINUS","D-PEPTIDE LINKING","L-BETA-PEPTIDE, C-GAMMA LINKING","L-GAMMA-PEPTIDE, C-DELTA LINKING","L-PEPTIDE COOH CARBOXY TERMINUS","L-PEPTIDE NH3 AMINO TERMINUS","L-PEPTIDE LINKING","PEPTIDE LINKING","PEPTIDE-LIKE"],Vs=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],Gs=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],Us=["D-SACCHARIDE","D-SACCHARIDE 1,4 AND 1,4 LINKING","D-SACCHARIDE 1,4 AND 1,6 LINKING","L-SACCHARIDE","L-SACCHARIDE 1,4 AND 1,4 LINKING","L-SACCHARIDE 1,4 AND 1,6 LINKING","SACCHARIDE"],js=["NON-POLYMER"].concat(["OTHER"],Us),Hs=["h","g","i"],Ws=["e","b"],qs=["s","t","l",""],Xs={H:1,D:1,T:1,HE:2,LI:3,BE:4,B:5,C:6,N:7,O:8,F:9,NE:10,NA:11,MG:12,AL:13,SI:14,P:15,S:16,CL:17,AR:18,K:19,CA:20,SC:21,TI:22,V:23,CR:24,MN:25,FE:26,CO:27,NI:28,CU:29,ZN:30,GA:31,GE:32,AS:33,SE:34,BR:35,KR:36,RB:37,SR:38,Y:39,ZR:40,NB:41,MO:42,TC:43,RU:44,RH:45,PD:46,AG:47,CD:48,IN:49,SN:50,SB:51,TE:52,I:53,XE:54,CS:55,BA:56,LA:57,CE:58,PR:59,ND:60,PM:61,SM:62,EU:63,GD:64,TB:65,DY:66,HO:67,ER:68,TM:69,YB:70,LU:71,HF:72,TA:73,W:74,RE:75,OS:76,IR:77,PT:78,AU:79,HG:80,TL:81,PB:82,BI:83,PO:84,AT:85,RN:86,FR:87,RA:88,AC:89,TH:90,PA:91,U:92,NP:93,PU:94,AM:95,CM:96,BK:97,CF:98,ES:99,FM:100,MD:101,NO:102,LR:103,RF:104,DB:105,SG:106,BH:107,HS:108,MT:109,DS:110,RG:111,CN:112,NH:113,FL:114,MC:115,LV:116,TS:117,OG:118},Ys={1:1.1,2:1.4,3:1.81,4:1.53,5:1.92,6:1.7,7:1.55,8:1.52,9:1.47,10:1.54,11:2.27,12:1.73,13:1.84,14:2.1,15:1.8,16:1.8,17:1.75,18:1.88,19:2.75,20:2.31,21:2.3,22:2.15,23:2.05,24:2.05,25:2.05,26:2.05,27:2,28:2,29:2,30:2.1,31:1.87,32:2.11,33:1.85,34:1.9,35:1.83,36:2.02,37:3.03,38:2.49,39:2.4,40:2.3,41:2.15,42:2.1,43:2.05,44:2.05,45:2,46:2.05,47:2.1,48:2.2,49:2.2,50:1.93,51:2.17,52:2.06,53:1.98,54:2.16,55:3.43,56:2.68,57:2.5,58:2.48,59:2.47,60:2.45,61:2.43,62:2.42,63:2.4,64:2.38,65:2.37,66:2.35,67:2.33,68:2.32,69:2.3,70:2.28,71:2.27,72:2.25,73:2.2,74:2.1,75:2.05,76:2,77:2,78:2.05,79:2.1,80:2.05,81:1.96,82:2.02,83:2.07,84:1.97,85:2.02,86:2.2,87:3.48,88:2.83,89:2,90:2.4,91:2,92:2.3,93:2,94:2,95:2,96:2,97:2,98:2,99:2,100:2,101:2,102:2,103:2,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:2,114:2,115:2,116:2,117:2,118:2},Ks={1:.31,2:.28,3:1.28,4:.96,5:.84,6:.76,7:.71,8:.66,9:.57,10:.58,11:1.66,12:1.41,13:1.21,14:1.11,15:1.07,16:1.05,17:1.02,18:1.06,19:2.03,20:1.76,21:1.7,22:1.6,23:1.53,24:1.39,25:1.39,26:1.32,27:1.26,28:1.24,29:1.32,30:1.22,31:1.22,32:1.2,33:1.19,34:1.2,35:1.2,36:1.16,37:2.2,38:1.95,39:1.9,40:1.75,41:1.64,42:1.54,43:1.47,44:1.46,45:1.42,46:1.39,47:1.45,48:1.44,49:1.42,50:1.39,51:1.39,52:1.38,53:1.39,54:1.4,55:2.44,56:2.15,57:2.07,58:2.04,59:2.03,60:2.01,61:1.99,62:1.98,63:1.98,64:1.96,65:1.94,66:1.92,67:1.92,68:1.89,69:1.9,70:1.87,71:1.87,72:1.75,73:1.7,74:1.62,75:1.51,76:1.44,77:1.41,78:1.36,79:1.36,80:1.32,81:1.45,82:1.46,83:1.48,84:1.4,85:1.5,86:1.5,87:2.6,88:2.21,89:2.15,90:2.06,91:2,92:1.96,93:1.9,94:1.87,95:1.8,96:1.69,97:1.6,98:1.6,99:1.6,100:1.6,101:1.6,102:1.6,103:1.6,104:1.6,105:1.6,106:1.6,107:1.6,108:1.6,109:1.6,110:1.6,111:1.6,112:1.6,113:1.6,114:1.6,115:1.6,116:1.6,117:1.6,118:1.6},Zs={1:[1],2:[0],3:[1],4:[2],5:[3],6:[4],7:[3],8:[2],9:[1],10:[0],11:[1],12:[2],13:[6],14:[6],15:[3,5,7],16:[2,4,6],17:[1],18:[0],19:[1],20:[2],31:[3],32:[4],33:[3,5],34:[2,4,6],35:[1],36:[0],37:[1],38:[2],49:[3],50:[4],51:[3,5],52:[2],53:[1,2,5],54:[0,2],55:[1],56:[2],81:[3],82:[4],83:[3],84:[2],85:[1],86:[0],87:[1],88:[2]},Qs={1:1,2:2,3:1,4:2,5:3,6:4,7:5,8:6,9:7,10:8,11:1,12:2,13:3,14:4,15:5,16:6,17:7,18:8,19:1,20:2,21:3,22:4,23:5,24:6,25:7,26:8,27:9,28:10,29:11,30:2,31:3,32:4,33:5,34:6,35:7,36:8,37:1,38:2,39:3,40:4,41:5,42:6,43:7,44:8,45:9,46:10,47:11,48:2,49:3,50:4,51:5,52:6,53:7,54:8,55:1,56:2,57:3,58:4,59:3,60:4,61:5,62:6,63:7,64:8,65:9,66:10,67:11,68:12,69:13,70:14,71:15,72:4,73:5,74:6,75:7,76:8,77:9,78:10,79:11,80:2,81:3,82:4,83:5,84:6,85:7,86:8,87:1,88:2,89:3,90:4,91:3,92:4,93:5,94:6,95:7,96:8,97:9,98:10,99:11,100:12,101:13,102:14,103:15,104:2,105:2,106:2,107:2,108:2,109:2,110:2,111:2,112:2,113:3,114:4,115:5,116:6,117:7,118:8},Js={ALA:[.17,.5,.33],ARG:[.81,1.81,1],ASN:[.42,.85,.43],ASP:[1.23,3.64,2.41],ASH:[-.07,.43,.5],CYS:[-.24,-.02,.22],GLN:[.58,.77,.19],GLU:[2.02,3.63,1.61],GLH:[-.01,.11,.12],GLY:[.01,1.15,1.14],HIS:[.17,.11,-.06],ILE:[-.31,-1.12,-.81],LEU:[-.56,-1.25,-.69],LYS:[.99,2.8,1.81],MET:[-.23,-.67,-.44],PHE:[-1.13,-1.71,-.58],PRO:[.45,.14,-.31],SER:[.13,.46,.33],THR:[.14,.25,.11],TRP:[-1.85,-2.09,-.24],TYR:[-.94,-.71,.23],VAL:[.07,-.46,-.53]},tn=[0,0,0],en={HIS:"H",ARG:"R",LYS:"K",ILE:"I",PHE:"F",LEU:"L",TRP:"W",ALA:"A",MET:"M",PRO:"P",CYS:"C",ASN:"N",VAL:"V",GLY:"G",SER:"S",GLN:"Q",TYR:"Y",ASP:"D",GLU:"E",THR:"T",SEC:"U",PYL:"O"},rn=Object.keys(en),sn=["A","C","T","G","U","I"],nn=["DA","DC","DT","DG","DU","DI"],on=["A","G","I","DA","DG","DI"],an=sn.concat(nn),cn=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4","SPC"],ln=["118","119","1AL","1CU","2FK","2HP","2OF","3CO","3MT","3NI","3OF","3P8","4MO","4PU","543","6MO","ACT","AG","AL","ALF","AM","ATH","AU","AU3","AUC","AZI","BA","BCT","BEF","BF4","BO4","BR","BS3","BSY","CA","CAC","CD","CD1","CD3","CD5","CE","CHT","CL","CO","CO3","CO5","CON","CR","CS","CSB","CU","CU1","CU3","CUA","CUZ","CYN","DME","DMI","DSC","DTI","DY","E4N","EDR","EMC","ER3","EU","EU3","F","FE","FE2","FPO","GA","GD3","GEP","HAI","HG","HGC","IN","IOD","IR","IR3","IRI","IUM","K","KO4","LA","LCO","LCP","LI","LU","MAC","MG","MH2","MH3","MLI","MLT","MMC","MN","MN3","MN5","MN6","MO1","MO2","MO3","MO4","MO5","MO6","MOO","MOS","MOW","MW1","MW2","MW3","NA","NA2","NA5","NA6","NAO","NAW","NCO","NET","NH4","NI","NI1","NI2","NI3","NO2","NO3","NRU","O4M","OAA","OC1","OC2","OC3","OC4","OC5","OC6","OC7","OC8","OCL","OCM","OCN","OCO","OF1","OF2","OF3","OH","OS","OS4","OXL","PB","PBM","PD","PDV","PER","PI","PO3","PO4","PR","PT","PT4","PTN","RB","RH3","RHD","RU","SB","SCN","SE4","SEK","SM","SMO","SO3","SO4","SR","T1A","TB","TBA","TCN","TEA","TH","THE","TL","TMA","TRA","UNX","V","VN3","VO4","W","WO5","Y1","YB","YB2","YH","YT3","ZCM","ZN","ZN2","ZN3","ZNO","ZO3","OHX"],hn=["045","0AT","0BD","0MK","0NZ","0TS","0V4","0XY","0YT","10M","147","149","14T","15L","16G","18T","18Y","1AR","1BW","1GL","1GN","1JB","1LL","1NA","1S3","26M","26Q","26R","26V","26W","26Y","27C","289","291","293","2DG","2F8","2FG","2FL","2FP","2GL","2M4","2M5","32O","34V","3CM","3DO","3DY","3FM","3LR","3MF","3MG","3SA","3ZW","46D","46M","46Z","48Z","4CQ","4GC","4NN","50A","5DI","5GF","5MM","5RP","5SA","5SP","64K","6PG","6SA","7JZ","7SA","A1Q","A2G","AAB","AAL","AAO","ABC","ABD","ABE","ABF","ABL","ACG","ACI","ACR","ACX","ADA","ADG","ADR","AF1","AFD","AFL","AFO","AFP","AFR","AGC","AGH","AGL","AHR","AIG","ALL","ALX","AMU","AOG","AOS","ARA","ARB","ARE","ARI","ASG","ASO","AXP","AXR","B0D","B16","B2G","B4G","B6D","B8D","B9D","BBK","BCD","BDG","BDP","BDR","BEM","BFP","BGC","BGL","BGP","BGS","BHG","BMA","BMX","BNG","BNX","BOG","BRI","BXF","BXP","BXX","BXY","C3X","C4X","C5X","CAP","CBI","CBK","CBS","CDR","CEG","CGF","CHO","CR1","CR6","CRA","CT3","CTO","CTR","CTT","D6G","DAF","DAG","DDA","DDB","DDL","DEL","DFR","DFX","DG0","DGC","DGD","DGM","DGS","DIG","DLF","DLG","DMU","DNO","DOM","DP5","DQQ","DQR","DR2","DR3","DR4","DRI","DSR","DT6","DVC","E4P","E5G","EAG","EBG","EBQ","EGA","EJT","EPG","ERE","ERI","F1P","F1X","F6P","FBP","FCA","FCB","FCT","FDP","FDQ","FFC","FIX","FMO","FRU","FSI","FU4","FUB","FUC","FUD","FUL","FXP","G16","G1P","G2F","G3I","G4D","G4S","G6D","G6P","G6S","GAC","GAD","GAL","GC1","GC4","GCD","GCN","GCO","GCS","GCT","GCU","GCV","GCW","GCX","GE1","GFG","GFP","GIV","GL0","GL2","GL5","GL6","GL7","GL9","GLA","GLB","GLC","GLD","GLF","GLG","GLO","GLP","GLS","GLT","GLW","GMH","GN1","GNX","GP1","GP4","GPH","GPM","GQ1","GQ2","GQ4","GS1","GS4","GSA","GSD","GTE","GTH","GTK","GTR","GTZ","GU0","GU1","GU2","GU3","GU4","GU5","GU6","GU8","GU9","GUF","GUP","GUZ","GYP","GYV","H2P","HDL","HMS","HS2","HSD","HSG","HSH","HSJ","HSQ","HSR","HSU","HSX","HSY","HSZ","IAB","IDG","IDR","IDS","IDT","IDU","IDX","IDY","IMK","IN1","IPT","ISL","KBG","KD2","KDA","KDM","KDO","KFN","KO1","KO2","KTU","L6S","LAG","LAI","LAK","LAO","LAT","LB2","LBT","LCN","LDY","LGC","LGU","LM2","LMT","LMU","LOG","LOX","LPK","LSM","LTM","LVZ","LXB","LXZ","M1F","M3M","M6P","M8C","MA1","MA2","MA3","MAB","MAG","MAL","MAN","MAT","MAV","MAW","MBG","MCU","MDA","MDM","MDP","MFA","MFB","MFU","MG5","MGA","MGL","MLB","MMA","MMN","MN0","MRP","MTT","MUG","MVP","MXY","N1L","N9S","NAA","NAG","NBG","NDG","NED","NG1","NG6","NGA","NGB","NGC","NGE","NGF","NGL","NGS","NGY","NHF","NM6","NM9","NTF","NTO","NTP","NXD","NYT","OPG","OPM","ORP","OX2","P3M","P53","P6P","PA5","PNA","PNG","PNW","PRP","PSJ","PSV","PTQ","QDK","QPS","QV4","R1P","R1X","R2B","R5P","RAA","RAE","RAF","RAM","RAO","RAT","RB5","RBL","RCD","RDP","REL","RER","RF5","RG1","RGG","RHA","RIB","RIP","RNS","RNT","ROB","ROR","RPA","RST","RUB","RUU","RZM","S6P","S7P","SA0","SCR","SDD","SF6","SF9","SG4","SG5","SG6","SG7","SGA","SGC","SGD","SGN","SGS","SHB","SHG","SI3","SIO","SOE","SOL","SSG","SUC","SUP","SUS","T6P","T6T","TAG","TCB","TDG","TGK","TGY","TH1","TIA","TM5","TM6","TM9","TMR","TMX","TOA","TOC","TRE","TYV","UCD","UDC","VG1","X0X","X1X","X2F","X4S","X5S","X6X","XBP","XDN","XDP","XIF","XIM","XLF","XLS","XMM","XUL","XXR","XYP","XYS","YO5","Z3Q","Z6J","Z9M","ZDC","ZDM"],dn=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","OT1","OT2","H","H1","H2","H3","HA","HN","BB"],un=["P","OP1","OP2","HOP2","HOP3","O2'","O3'","O4'","O5'","C1'","C2'","C3'","C4'","C5'","H1'","H2'","H2''","HO2'","H3'","H4'","H5'","H5''","HO3'","HO5'","O2*","O3*","O4*","O5*","C1*","C2*","C3*","C4*","C5*"],mn={1:{trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT","OT1","OT2"],backboneStart:"N",backboneEnd:"C"},2:{trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},3:{trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},4:{trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},5:{trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},6:{trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]}};mn[Ns]={};const pn={HD:"H",HS:"H",A:"C",NA:"N",NS:"N",OA:"O",OS:"O",SA:"S",G0:"C",G1:"C",G2:"C",G3:"C",CG0:"C",CG1:"C",CG2:"C",CG3:"C",W:"O"};function fn(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;default:return 8}}const gn=new Map([[2,kt(180)],[3,kt(120)],[4,kt(109.4721)],[6,kt(90)]]);function yn(t,i){let r=[];const s=new e,n=new e;return s.subVectors(i,t),t.eachBondedAtom((e=>{1!==e.number&&(n.subVectors(e,t),r.push(s.angleTo(n)))})),r}function bn(t,i){const r=t.clone(),s=new e;s.subVectors(i,t);const n=[new e,new e];let o=0;if(t.eachBondedAtom((e=>{o>1||1!==e.number&&(r.index=e.index,n[o++].subVectors(e,t))})),1===o&&r.eachBondedAtom((e=>{o>1||1!==e.number&&e.index!==t.index&&n[o++].subVectors(e,t)})),2!==o)return;const a=n[0].cross(n[1]);return Math.abs(Math.PI/2-a.angleTo(s))}function xn(t,e){const i=t.structure,r=i.atomCount,s=new Int8Array(r),n=new Int8Array(r),o=new Int8Array(r),a=new Int8Array(r);return i.eachAtom((t=>{const i=t.index,[r,c,l,h]=function(t,e){const i=t.bondToElementCount(1);let r=t.formalCharge||0;const s="always"===e.assignCharge||"auto"===e.assignCharge&&0===r,n="always"===e.assignH||"auto"===e.assignH&&0===i,o=t.bondCount,a=function(t){let e=0;return t.eachBond((t=>e+=t.bondOrder)),e}(t),c=function(t){const e=t.structure.getBondProxy(),i=t.number,r=8===i||7===i;if(r&&4===t.bondCount)return!1;let s=!1;return t.eachBond((i=>{if(i.bondOrder>1)s=!0;else if(r){const r=i.getOtherAtom(t);r.eachBond((t=>{if(t.bondOrder>1){const e=r.number;if((15===e||16===e)&&8===t.getOtherAtom(r).number)return;s=!0}}),e)}})),s}(t),l=a-o>0;let h=0,d=8;switch(t.number){case 1:s&&(0===o?(r=1,d=0):1===o&&(r=0,d=1));break;case 6:s&&(r=0),n&&(h=Math.max(0,4-a-Math.abs(r))),d=fn(o+h+Math.max(0,-r));break;case 7:if(s)if(n)if(c&&a<4)r=o-i==1&&a-i==2?1:0;else{let e=!1;t.eachBondedAtom((t=>{(16===t.number||t.isMetal())&&(e=!0)})),r=e?0:1}else r=a-3;n&&(h=Math.max(0,3-a+r)),d=fn(c&&!l?o+h-r:o+h+1-r);break;case 8:s&&(n||(r=a-2),1===a&&t.eachBondedAtom((e=>{e.eachBond((i=>{const s=i.getOtherAtom(e);s.index!==t.index&&8===s.number&&2===i.bondOrder&&(r=-1)}))}))),n&&(h=Math.max(0,2-a+r)),d=fn(c&&!l?o+h-r+1:o+h-r+2);break;case 16:s&&(n||(r=a<=3&&!t.bondToElementCount(8)?a-2:0)),n&&a<2&&(h=Math.max(0,2-a+r)),a<=3&&(d=fn(o+h-r+2));break;case 9:case 17:case 35:case 53:case 85:s&&(r=a-1);break;case 3:case 11:case 19:case 37:case 55:case 87:s&&(r=1-a);break;case 4:case 12:case 20:case 38:case 56:case 88:s&&(r=2-a);break;default:console.warn("Requested charge, protonation for an unhandled element",t.element)}return[r,h,h+i,d]}(t,e);s[i]=r,n[i]=c,o[i]=l,a[i]=h})),{charge:s,implicitH:n,totalH:o,idealGeometry:a}}function vn(t){if(t["@valenceModel"])return t["@valenceModel"];const e=xn(t,{assignCharge:"auto",assignH:"auto"});return t["@valenceModel"]=e,e}function wn(t){return 15===t.number&&t.bondToElementCount(8)===t.bondCount}const An=["ARG","HIS","LYS"],_n=["GLU","ASP"];function Sn(t,e){return 2===t&&1===e||1===t&&2===e}function Cn(t,e){return 3===t&&3===e}function Pn(t,e){return 3===t&&1===e||1===t&&3===e}function In(t){return"HIS"===t.resname&&7==t.number&&t.isRing()}function kn(t,e){return 5===t&&4===e||4===t&&5===e}function Mn(t,e){return 9===t&&5===e||5===t&&9===e}const Tn=[3,11,19,37,55,12,20,38,56,13,31,49,81,21,50,82,83,51,80];function Bn(t,e){return 12===t?11===e||12===e:13===t?10===e:void 0}const Dn=[17,35,53,85];const $n=[7,8,16],On=[6,7,15,16];const Rn=kt(180),En=kt(120);function Fn(t,e,i){return!Nn(t,e,i)&&(t.modelIndex!==e.modelIndex||t.altloc&&e.altloc&&t.altloc!==e.altloc)}const Ln={maxHydrophobicDist:4,maxHbondDist:3.5,maxHbondSulfurDist:4.1,maxHbondAccAngle:45,maxHbondDonAngle:45,maxHbondAccPlaneAngle:90,maxHbondDonPlaneAngle:30,maxPiStackingDist:5.5,maxPiStackingOffset:2,maxPiStackingAngle:30,maxCationPiDist:6,maxCationPiOffset:2,maxIonicDist:5,maxHalogenBondDist:4,maxHalogenBondAngle:30,maxMetalDist:3,refineSaltBridges:!0,masterModelIndex:-1,lineOfSightDistFactor:1};function Nn(t,e,i){return t.modelIndex===i&&e.modelIndex!==i||e.modelIndex===i&&t.modelIndex!==i}function zn(t,e,i){return!Nn(t,e,i)&&(t.modelIndex!==e.modelIndex||t.residueIndex===e.residueIndex||t.altloc&&e.altloc&&t.altloc!==e.altloc)}function Vn(t){const e={types:[],groups:[],centers:{x:[],y:[],z:[]},atomSets:[]};return De&&Me.time("calculateFeatures"),function(t,e){const{charge:i}=vn(t.data),r={};t.eachResidue((t=>{if(An.includes(t.resname)){const i=Es(1);t.eachAtom((t=>{7===t.number&&t.isSidechain()&&Fs(i,t)})),Ls(e,i)}else rn.includes(t.resname)||t.isNucleic()||(t.eachAtom((t=>{let i=!1;const s=Es(1);!function(t){let e=0;return 6===t.number&&3===t.bondCount&&3===t.bondToElementCount(7)&&t.eachBondedAtom((t=>{t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)?function(t){let e=0;return 6===t.number&&3===t.bondCount&&2===t.bondToElementCount(7)&&1===t.bondToElementCount(6)&&t.eachBondedAtom((t=>{t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)&&(s.group=9,i=!0):(s.group=8,i=!0),i&&(t.eachBondedAtom((t=>{7===t.number&&(r[t.index]=!0,Fs(s,t))})),Ls(e,s))})),t.eachAtom((t=>{const s=Es(1);i[t.index]>0&&(r[t.index]||(Fs(s,t),Ls(e,s)))})))}))}(t,e),function(t,e){const{charge:i}=vn(t.data),r={};t.eachResidue((t=>{if(_n.includes(t.resname)){const i=Es(2);t.eachAtom((t=>{8===t.number&&t.isSidechain()&&Fs(i,t)})),Ls(e,i)}else if(an.includes(t.resname)){const i=Es(2);t.eachAtom((t=>{wn(t)&&(i.group=6,t.eachBondedAtom((t=>{8===t.number&&Fs(i,t)})),Ls(e,i))}))}else rn.includes(t.resname)||an.includes(t.resname)||(t.eachAtom((t=>{let i=!1;const s=Es(2);!function(t){return 16===t.number&&3===t.bondToElementCount(8)}(t)?wn(t)?(s.group=6,i=!0):function(t){return 16===t.number&&4===t.bondToElementCount(8)}(t)?(s.group=5,i=!0):function(t){let e=0;return 6===t.number&&2===t.bondToElementCount(8)&&1===t.bondToElementCount(6)&&t.eachBondedAtom((t=>{8===t.number&&t.bondCount-t.bondToElementCount(1)==1&&++e})),2===e}(t)&&(s.group=10,i=!0):(s.group=4,i=!0),i&&(t.eachBondedAtom((t=>{8===t.number&&(r[t.index]=!0,Fs(s,t))})),Ls(e,s))})),t.eachAtom((t=>{const s=Es(2);i[t.index]<0&&(r[t.index]||(Fs(s,t),Ls(e,s)))})))}))}(t,e),function(t,e){const i=t.getAtomProxy();t.eachResidue((t=>{const r=t.getAromaticRings();if(r){const s=t.atomOffset;r.forEach((t=>{const r=Es(3);t.forEach((t=>{i.index=t+s,Fs(r,i)})),Ls(e,r)}))}}))}(t,e),function(t,e){const{charge:i,implicitH:r,idealGeometry:s}=vn(t.data);t.eachAtom((t=>{const n=Es(5),o=t.number;if(8===o)Fs(n,t),Ls(e,n);else if(7===o){if(In(t))Fs(n,t),Ls(e,n);else if(i[t.index]<1){const i=t.bondCount+r[t.index],o=s[t.index];(4===o&&i<4||3===o&&i<3||2===o&&i<2)&&(Fs(n,t),Ls(e,n))}}else 16===o&&("CYS"!==t.resname&&"MET"!==t.resname&&-1!==t.formalCharge||(Fs(n,t),Ls(e,n)))}))}(t,e),function(t,e){const{totalH:i}=vn(t.data);t.eachAtom((t=>{const r=Es(4),s=t.number;(In(t)||i[t.index]>0&&(7===s||8===s||16===s))&&(Fs(r,t),Ls(e,r))}))}(t,e),function(t,e){const{totalH:i}=vn(t.data);t.eachAtom((t=>{if(6===t.number&&i[t.index]>0&&(t.bondToElementCount(7)>0||t.bondToElementCount(8)>0||function(t){if(!t.isAromatic())return!1;const e=t.residueType.getRings();if(!e)return!1;let i=!1;return e.rings.forEach((e=>{i||e.some((e=>t.index-t.residueAtomOffset===e))&&(i=e.some((e=>{const i=t.residueType.atomTypeIdList[e],r=t.atomMap.get(i).number;return 7===r||8===r})))})),i}(t))){const i=Es(9);Fs(i,t),Ls(e,i)}}))}(t,e),function(t,e){t.eachAtom((t=>{let i=!1,r=!1;const s=rn.includes(t.resname),n=an.includes(t.resname);if(s||n?s?8===t.number?(["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(t.resname)&&t.isSidechain()||t.isBackbone())&&(i=!0,r=!0):16===t.number&&"CYS"===t.resname?(i=!0,r=!0):7===t.number&&"HIS"===t.resname&&t.isSidechain()&&(i=!0):n&&(8===t.number&&t.isBackbone()?(i=!0,r=!0):["N3","N4","N7"].includes(t.atomname)?i=!0:["O2","O4","O6"].includes(t.atomname)&&(i=!0,r=!0)):t.isHalogen()||8===t.number||16===t.number?(i=!0,r=!0):7===t.number&&(i=!0),i){const i=Es(11);Fs(i,t),Ls(e,i)}if(r){const i=Es(10);Fs(i,t),Ls(e,i)}}))}(t,e),function(t,e){t.eachAtom((t=>{if(t.isTransitionMetal()||30===t.number||48===t.number){const i=Es(12);Fs(i,t),Ls(e,i)}else if(Tn.includes(t.number)){const i=Es(13);Fs(i,t),Ls(e,i)}}))}(t,e),function(t,e){t.eachAtom((t=>{const i=Es(8);let r=!1;6===t.number?(r=!0,t.eachBondedAtom((t=>{const e=t.number;6!==e&&1!==e&&(r=!1)}))):9===t.number&&(r=!0),r&&(Fs(i,t),Ls(e,i))}))}(t,e),function(t,e){t.eachAtom((t=>{if($n.includes(t.number)){let i=!1;if(t.eachBondedAtom((t=>{On.includes(t.number)&&(i=!0)})),i){const i=Es(7);Fs(i,t),Ls(e,i)}}}))}(t,e),function(t,e){t.eachAtom((t=>{if(Dn.includes(t.number)&&1===t.bondToElementCount(6)){const i=Es(6);Fs(i,t),Ls(e,i)}}))}(t,e),De&&Me.timeEnd("calculateFeatures"),e}function Gn(t,i=Ln){const r=function(t){const{types:e,centers:i}=t;return{features:t,spatialHash:new Ts(i),contactStore:new Ds,featureSet:new Os(e.length,!1)}}(Vn(t));De&&Me.time("calculateContacts"),function(t,i,r={}){const s=st(r.maxIonicDist,Ln.maxIonicDist),n=st(r.maxPiStackingDist,Ln.maxPiStackingDist),o=st(r.maxPiStackingOffset,Ln.maxPiStackingOffset),a=st(r.maxPiStackingAngle,Ln.maxPiStackingAngle),c=st(r.maxCationPiDist,Ln.maxCationPiDist),l=st(r.maxCationPiOffset,Ln.maxCationPiOffset),h=st(r.masterModelIndex,Ln.masterModelIndex),d=Math.max(s+2,n,c),u=n*n,m=c*c,{features:p,spatialHash:f,contactStore:g,featureSet:y}=i,{types:b,centers:x,atomSets:v}=p,{x:w,y:A,z:_}=x,S=b.length,C=t.atomStore.x,P=t.atomStore.y,I=t.atomStore.z,k=t.getAtomProxy(),M=t.getAtomProxy(),T=function(t,e,i){const r=t.length,s=e.length;for(let n=0;n{if(e<=t)return;if(k.index=v[t][0],M.index=v[e][0],zn(k,M,h))return;const r=b[t],n=b[e];if(Sn(r,n))T(v[t],v[e],s)&&z(t,e,1);else if(Cn(r,n)){if(i<=u){L(v[t],E),L(v[e],F);const i=57.29578*E.angleTo(F);Math.min(N(t,e,F),N(e,t,E))<=o&&(i<=a||i>=180-a||i<=a+90&&i>=90-a)&&z(t,e,3)}}else if(Pn(r,n)&&i<=m){const[i,s]=3===r?[t,e]:[e,t];L(v[i],E),N(s,i,E)<=l&&z(i,s,2)}}))}(t,r,i),function(t,e,i={}){const r=st(i.maxHbondDist,Ln.maxHbondDist),s=st(i.maxHbondSulfurDist,Ln.maxHbondSulfurDist),n=kt(st(i.maxHbondAccAngle,Ln.maxHbondAccAngle)),o=kt(st(i.maxHbondDonAngle,Ln.maxHbondDonAngle)),a=kt(st(i.maxHbondAccPlaneAngle,Ln.maxHbondAccPlaneAngle)),c=kt(st(i.maxHbondDonPlaneAngle,Ln.maxHbondDonPlaneAngle)),l=st(i.masterModelIndex,Ln.masterModelIndex),h=Math.max(r,s),d=r*r,{features:u,spatialHash:m,contactStore:p,featureSet:f}=e,{types:g,centers:y,atomSets:b}=u,{x:x,y:v,z:w}=y,A=g.length,{idealGeometry:_}=vn(t.data),S=t.getAtomProxy(),C=t.getAtomProxy();for(let t=0;t{if(e<=t)return;const r=g[t],s=g[e],h=Mn(r,s);if(!h&&!kn(r,s))return;const[u,m]=5===s?[t,e]:[e,t];if(S.index=b[u][0],C.index=b[m][0],C.index===S.index)return;if(zn(S,C,l))return;if(16!==S.number&&16!==C.number&&i>d)return;if(S.connectedTo(C))return;const y=yn(S,C),x=gn.get(_[S.index])||kt(120);if(y.some((t=>Math.abs(x-t)>o)))return;if(3===_[S.index]){const t=bn(S,C);if(void 0!==t&&t>c)return}const v=yn(C,S),w=gn.get(_[C.index])||kt(120);if(v.some((t=>w-t>n)))return;if(3===_[C.index]){const t=bn(C,S);if(void 0!==t&&t>a)return}f.setBits(u,m);const A=h?8:function(t,e){return t.isWater()&&e.isWater()}(P=S,I=C)?9:function(t,e){return t.isBackbone()&&e.isBackbone()}(P,I)?10:4;var P,I;p.addContact(u,m,A)}))}(t,r,i),function(t,e,i={}){const r=st(i.maxMetalDist,Ln.maxMetalDist),s=st(i.masterModelIndex,Ln.masterModelIndex),{features:n,spatialHash:o,contactStore:a,featureSet:c}=e,{types:l,centers:h,atomSets:d}=n,{x:u,y:m,z:p}=h,f=l.length,g=t.getAtomProxy(),y=t.getAtomProxy();for(let t=0;t{if(e<=t)return;if(g.index=d[t][0],y.index=d[e][0],zn(g,y,s))return;const r=g.isMetal(),n=y.isMetal();if(!r&&!n)return;const[o,h]=r?[l[t],l[e]]:[l[e],l[t]];Bn(o,h)&&(c.setBits(t,e),a.addContact(t,e,7))}))}(t,r,i),function(t,e,i={}){const r=st(i.maxHydrophobicDist,Ln.maxHydrophobicDist),s=st(i.masterModelIndex,Ln.masterModelIndex),{features:n,spatialHash:o,contactStore:a,featureSet:c}=e,{types:l,centers:h,atomSets:d}=n,{x:u,y:m,z:p}=h,f=l.length,g=t.getAtomProxy(),y=t.getAtomProxy();for(let t=0;t{var r,n;e<=t||(g.index=d[t][0],y.index=d[e][0],zn(g,y,s)||9===g.number&&9===y.number||g.connectedTo(y)||(r=l[t],n=l[e],8===r&&8===n&&(c.setBits(t,e),a.addContact(t,e,6))))}))}(t,r,i),function(t,e,i={}){const r=st(i.maxHalogenBondDist,Ln.maxHalogenBondDist),s=kt(st(i.maxHalogenBondAngle,Ln.maxHalogenBondAngle)),n=st(i.masterModelIndex,Ln.masterModelIndex),{features:o,spatialHash:a,contactStore:c,featureSet:l}=e,{types:h,centers:d,atomSets:u}=o,{x:m,y:p,z:f}=d,g=h.length,y=t.getAtomProxy(),b=t.getAtomProxy();for(let t=0;t{if(e<=t)return;if(y.index=u[t][0],b.index=u[e][0],zn(y,b,n))return;if(r=h[t],o=h[e],!(7===r&&6===o||6===r&&7===o))return;var r,o;const[a,d]=6===h[t]?[y,b]:[b,y],m=yn(a,d);if(1!==m.length)return;if(Rn-m[0]>s)return;const p=yn(d,a);0!==p.length&&(p.some((t=>En-t>s))||(l.setBits(t,e),c.addContact(t,e,5)))}))}(t,r,i);const s=function(t){const{index1:e,index2:i,count:r}=t.contactStore,s=Rs({nodeArray1:e,nodeArray2:i,edgeCount:r,nodeCount:t.featureSet.length}),n=new Os(t.contactStore.count,!0);return Object.assign({adjacencyList:s,contactSet:n},t)}(r);return function(t,i,r={}){De&&Me.time("refineLineOfSight");const s=st(r.lineOfSightDistFactor,Ln.lineOfSightDistFactor),n=st(r.masterModelIndex,Ln.masterModelIndex),o=t.spatialHash,{contactSet:a,contactStore:c,features:l}=i,{index1:h,index2:d}=c,{centers:u,atomSets:m}=l,{x:p,y:f,z:g}=u,y=t.getAtomProxy(),b=t.getAtomProxy(),x=t.getAtomProxy(),v=new e,w=new e,A=3*s,_=s*s;a.forEach((t=>{v.set(p[h[t]],f[h[t]],g[h[t]]),w.set(p[d[t]],f[d[t]],g[d[t]]);const e=(v.x+w.x)/2,i=(v.y+w.y)/2,r=(v.z+w.z)/2,s=m[h[t]],c=m[d[t]];y.index=s[0],b.index=c[0],o.eachWithin(e,i,r,A,((e,i)=>{x.index=e,1!==x.number&&x.vdw*x.vdw*_>i&&!Fn(y,x,n)&&!Fn(b,x,n)&&!s.includes(e)&&!c.includes(e)&&v.distanceToSquared(x)>1&&w.distanceToSquared(x)>1&&(a.clear(t),De&&Me.log("removing",y.qualifiedName(),b.qualifiedName(),"because",x.qualifiedName()))}))})),De&&Me.timeEnd("refineLineOfSight")}(t,s,i),function(t,e){const{contactSet:i,contactStore:r,features:s}=e,{type:n,index1:o,index2:a}=r,{atomSets:c}=s,l=t.getAtomProxy(),h=t.getAtomProxy(),d={},u=function(t,e,r){const[s,n]=d[r]||[1/0,-1];t{if(6!==n[t])return;l.index=c[o[t]][0],h.index=c[a[t]][0];const e=l.distanceTo(h);u(e,t,`${l.index}|${h.residueIndex}`),u(e,t,`${h.index}|${l.residueIndex}`)}))}(t,s),i.refineSaltBridges&&function(t,e){const{contactSet:i,contactStore:r,features:s}=e,{type:n,index1:o,index2:a}=r,{atomSets:c}=s,l={},h=function(t,e){l[t]||(l[t]=[]),l[t].push(e)};i.forEach((t=>{1===n[t]&&(c[o[t]].forEach((e=>h(e,t))),c[a[t]].forEach((e=>h(e,t))))})),i.forEach((t=>{if(!function(t){return 4===t||9===t||10===t}(n[t]))return;const e=l[c[o[t]][0]],r=l[c[a[t]][0]];if(!e||!r)return;const s=e.length;for(let n=0;n{3===n[t]&&(c[o[t]].forEach((e=>h(e,t))),c[a[t]].forEach((e=>h(e,t))))})),i.forEach((t=>{if(6!==n[t]&&2!==n[t])return;const e=l[c[o[t]][0]],r=l[c[a[t]][0]];if(!e||!r)return;const s=e.length;for(let n=0;n{1===n[t]&&(c[o[t]].forEach((e=>h(e,t))),c[a[t]].forEach((e=>h(e,t))))})),i.forEach((t=>{if(7!==n[t])return;const e=l[c[o[t]][0]],r=l[c[a[t]][0]];if(!e||!r)return;const s=e.length;for(let t=0;te.getAtomSet(new pe(t)))):e.getAtomSet(new pe(r.filterSele))),o.forEach((t=>{const e=f[t];if(!s.includes(e))return;if(w){const e=l[m[t]][0],i=l[p[t]][0];if(Array.isArray(w)){if(!(w[0].isSet(e)&&w[1].isSet(i)||w[1].isSet(e)&&w[0].isSet(i)))return}else if(!w.isSet(e)&&!w.isSet(i))return}const i=m[t],n=p[t];g.push(h[i],d[i],u[i]),y.push(h[n],d[n],u[n]),b.push(...function(t){switch(t){case 4:case 9:case 10:return Hn.setHex(2851770).toArray();case 6:return Hn.setHex(8421504).toArray();case 5:return Hn.setHex(4259775).toArray();case 1:return Hn.setHex(15779860).toArray();case 7:return Hn.setHex(9191577).toArray();case 2:return Hn.setHex(16744448).toArray();case 3:return Hn.setHex(9220966).toArray();case 8:return Hn.setHex(12967404).toArray();default:return Hn.setHex(13421772).toArray()}}(e)),x.push(r.radius),v.push(t)})),{position1:new Float32Array(g),position2:new Float32Array(y),color:new Float32Array(b),color2:new Float32Array(b),radius:new Float32Array(x),picking:new Qn(v,t,e)}}class qn{constructor(t){this.array=t}get type(){return""}get data(){return{}}getIndex(t){return this.array?this.array[t]:t}getObject(t){return{}}_applyTransformations(t,e,i){return e&&t.applyMatrix4(e.matrix),i&&t.applyMatrix4(i.matrix),t}_getPosition(t){return new e}getPosition(t,e,i){return this._applyTransformations(this._getPosition(t),e,i)}}class Xn extends qn{constructor(t){super(),this.shape=t}get primitive(){}get data(){return this.shape}get type(){return this.primitive.type}getObject(t){return this.primitive.objectFromShape(this.shape,this.getIndex(t))}_getPosition(t){return this.primitive.positionFromShape(this.shape,this.getIndex(t))}}class Yn extends qn{constructor(t,e){super(t),this.structure=e}get type(){return"atom"}get data(){return this.structure}getObject(t){return this.structure.getAtomProxy(this.getIndex(t))}_getPosition(t){return(new e).copy(this.getObject(t))}}class Kn extends qn{constructor(t){super(),this.axes=t}get type(){return"axes"}get data(){return this.axes}getObject(){return{axes:this.axes}}_getPosition(){return this.axes.center.clone()}}class Zn extends qn{constructor(t,e,i){super(t),this.structure=e,this.bondStore=i||e.bondStore}get type(){return"bond"}get data(){return this.structure}getObject(t){const e=this.structure.getBondProxy(this.getIndex(t));return e.bondStore=this.bondStore,e}_getPosition(t){const i=this.getObject(t);return(new e).copy(i.atom1).add(i.atom2).multiplyScalar(.5)}}class Qn extends qn{constructor(t,e,i){super(t),this.contacts=e,this.structure=i}get type(){return"contact"}get data(){return this.contacts}getObject(t){const i=this.getIndex(t),{features:r,contactStore:s}=this.contacts,{centers:n,atomSets:o}=r,{x:a,y:c,z:l}=n,{index1:h,index2:d,type:u}=s,m=h[i],p=d[i];return{center1:new e(a[m],c[m],l[m]),center2:new e(a[p],c[p],l[p]),atom1:this.structure.getAtomProxy(o[m][0]),atom2:this.structure.getAtomProxy(o[p][0]),type:Un(u[i])}}_getPosition(t){const{center1:i,center2:r}=this.getObject(t);return(new e).addVectors(i,r).multiplyScalar(.5)}}class Jn extends qn{constructor(t,e,i){super(t),this.validation=e,this.structure=i}get type(){return"clash"}get data(){return this.validation}getObject(t){const e=this.validation,i=this.getIndex(t);return{validation:e,index:i,clash:e.clashArray[i]}}_getAtomProxyFromSele(t){const e=new pe(t),i=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(i)}_getPosition(t){const i=this.getObject(t).clash,r=this._getAtomProxyFromSele(i.sele1),s=this._getAtomProxyFromSele(i.sele2);return(new e).copy(r).add(s).multiplyScalar(.5)}}class to extends Zn{get type(){return"distance"}}class eo extends qn{get type(){return"ignore"}}class io extends Xn{constructor(t,e){super(t),this.mesh=e}get type(){return"mesh"}getObject(){const t=this.mesh;return{shape:this.shape,name:t.name,serial:t.serial}}_getPosition(){return this.__position||(this.__position=Ur(this.mesh.position)),this.__position}}class ro extends qn{constructor(t,e){super(t),this.surface=e}get type(){return"surface"}get data(){return this.surface}getObject(t){return{surface:this.surface,index:this.getIndex(t)}}_getPosition(){return this.surface.center.clone()}}class so extends qn{constructor(t,e){super(),this.unitcell=t,this.structure=e}get type(){return"unitcell"}get data(){return this.unitcell}getObject(){return{unitcell:this.unitcell,structure:this.structure}}_getPosition(){return this.unitcell.getCenter(this.structure)}}class no extends qn{constructor(t,e){super(t),this.volume=e}get type(){return"volume"}get data(){return this.volume}getObject(t){const e=this.volume,i=this.getIndex(t);return{volume:e,index:i,value:e.data[i]}}_getPosition(t){const i=this.volume.position,r=this.getIndex(t);return new e(i[3*r],i[3*r+1],i[3*r+2])}}class oo extends no{get type(){return"slice"}}function ao(){return new Uint32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0])}function co(){return new Int32Array([-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])}function lo(t,e,i,r,s){var n,o,a,c,l,h,d,u=[[0,4,4,4,2,0,0,0,2,2,0,0],[4,0,4,4,0,8,0,0,0,8,8,0],[4,4,0,4,0,0,8,0,0,0,8,8],[4,4,4,0,0,0,0,1,1,0,0,1],[2,0,0,0,0,8,8,8,2,2,0,0],[0,8,0,0,8,0,8,8,0,8,8,0],[0,0,8,0,8,8,0,8,0,0,8,8],[0,0,0,1,8,8,8,0,1,0,0,1],[2,0,0,1,2,0,0,1,0,2,0,1],[2,8,0,0,2,8,0,0,2,0,8,0],[0,8,8,0,0,8,8,0,0,8,0,8],[0,0,8,1,0,0,8,1,1,0,8,0]],m=0,p=!1,f=!1,g=!1,y=!1,b=-1,x=e*i*r,v=e,w=e*i,A=new Int32Array(12),_=[],S=[],C=[],P=[],I=ao(),k=co();function M(t,e,i){return t+(e-t)*i}function T(t,s,n){return w*(n=(n+d)%r)+v*(s=(s+h)%i)+(t=(t+l)%e)}function B(t,e,i,r,c,l,h){var d=3*t;if(o[d]<0){var u=(m-l)/(h-l),f=n,g=3*a;if(_[g]=i+u,_[g+1]=r,_[g+2]=c,!p){var y=3*t;S[g]=b*M(f[y],f[y+3],u),S[g+1]=b*M(f[y+1],f[y+4],u),S[g+2]=b*M(f[y+2],f[y+5],u)}s&&(P[a]=s[t+Math.round(u)]),o[d]=a,A[e]=a,a+=1}else A[e]=o[d]}function D(t,e,i,r,c,l,h){var d=3*t+1;if(o[d]<0){var u=(m-l)/(h-l),f=n,g=3*a;if(_[g]=i,_[g+1]=r+u,_[g+2]=c,!p){var y=3*t,x=y+3*v;S[g]=b*M(f[y],f[x],u),S[g+1]=b*M(f[y+1],f[x+1],u),S[g+2]=b*M(f[y+2],f[x+2],u)}s&&(P[a]=s[t+Math.round(u)*v]),o[d]=a,A[e]=a,a+=1}else A[e]=o[d]}function $(t,e,i,r,c,l,h){var d=3*t+2;if(o[d]<0){var u=(m-l)/(h-l),f=n,g=3*a;if(_[g]=i,_[g+1]=r,_[g+2]=c+u,!p){var y=3*t,x=y+3*w;S[g]=b*M(f[y],f[x],u),S[g+1]=b*M(f[y+1],f[x+1],u),S[g+2]=b*M(f[y+2],f[x+2],u)}s&&(P[a]=s[t+Math.round(u)*w]),o[d]=a,A[e]=a,a+=1}else A[e]=o[d]}function O(e){var i=3*e;0===n[i]&&(n[i]=t[(e-1+x)%x]-t[(e+1)%x],n[i+1]=t[(e-v+x)%x]-t[(e+v)%x],n[i+2]=t[(e-w+x)%x]-t[(e+w)%x])}function R(e,i,r,s,n){var o,a,l,h,d,b,x;g?(s=T(e,i,r),o=T(e+1,i,r),a=T(e,i+1,r),l=T(e,i,r+1),h=T(e+1,i+1,r),d=T(e+1,i,r+1),b=T(e,i+1,r+1),x=T(e+1,i+1,r+1)):(o=s+1,h=(a=s+v)+1,d=(l=s+w)+1,x=(b=a+w)+1);var _=0,S=t[s],P=t[o],M=t[a],R=t[h],E=t[l],F=t[d],L=t[b],N=t[x];S=m){$=b,M=!0;break}if(M)break}if(M)break}for(M=!1,y=n;y=m){D=y,M=!0;break}if(M)break}if(M)break}for(M=!1,f=s;f=m){B=f,M=!0;break}if(M)break}if(M)break}for(M=!1,b=h;b>=a;--b){for(y=l;y>=n;--y){for(f=c;f>=s;--f)if(d=e*i*b+e*y+f,t[d]>=m){F=b,M=!0;break}if(M)break}if(M)break}for(M=!1,y=l;y>=n;--y){for(b=F;b>=a;--b){for(f=c;f>=s;--f)if(d=e*i*b+e*y+f,t[d]>=m){E=y,M=!0;break}if(M)break}if(M)break}for(M=!1,f=c;f>=s;--f){for(y=E;y>=n;--y){for(b=F;b>=a;--b)if(d=e*i*b+e*y+f,t[d]>=m){O=f,M=!0;break}if(M)break}if(M)break}p?(s=Math.max(0,B-1),n=Math.max(0,D-1),a=Math.max(0,$-1),c=Math.min(e-1,O+1),l=Math.min(i-1,E+1),h=Math.min(r-1,F+1)):(s=Math.max(1,B-1),n=Math.max(1,D-1),a=Math.max(1,$-1),c=Math.min(e-2,O+1),l=Math.min(i-2,E+1),h=Math.min(r-2,F+1))}var L=15;for(b=a;b0?-1:1,n||(n=new Float32Array(3*x)));var I=3*x;if(o&&o.length===I||(o=new Int32Array(I)),a=0,c=0,void 0!==v){var k=v[0].map(Math.round),M=v[1].map(Math.round);l=e*Math.ceil(Math.abs(k[0])/e),h=i*Math.ceil(Math.abs(k[1])/i),d=r*Math.ceil(Math.abs(k[2])/r),E(k[0],k[1],k[2],M[0],M[1],M[2])}else l=h=d=0,E();return _.length=3*a,p||(S.length=3*a),C.length=c,s&&(P.length=a),{position:new Float32Array(_),normal:p?void 0:new Float32Array(S),index:xt(C,_.length/3),atomindex:s?new Int32Array(P):void 0,contour:f}}}He.add("arrow",class extends Xn{get primitive(){return _s}}),He.add("box",class extends Xn{get primitive(){return xs}}),He.add("cone",class extends Xn{get primitive(){return Ss}}),He.add("cylinder",class extends Xn{get primitive(){return As}}),He.add("ellipsoid",class extends Xn{get primitive(){return Cs}}),He.add("octahedron",class extends Xn{get primitive(){return vs}}),He.add("sphere",class extends Xn{get primitive(){return bs}}),He.add("tetrahedron",class extends Xn{get primitive(){return ws}}),He.add("torus",class extends Xn{get primitive(){return Ps}}),He.add("point",class extends Xn{get primitive(){return ks}}),He.add("wideline",class extends Xn{get primitive(){return Ms}}),Object.assign(lo,{__deps:[ao,co,xt]});class ho{constructor(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}copyTo(t){t.data.set(this.data)}}function uo(t,e){let i=0,r=0;const s=e.rows,n=e.cols;let o=0,a=0,c=0;const l=e.data,h=t.data;for(;i(e=Math.abs(e))?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}const xo=1.192092896e-7,vo=1e-37;function wo(t,e,i,r){let s=0,n=0;const o=t.rows,a=t.cols;let c=o,l=a;c>16)?O:-O,t[h*e+u]=$;for(m=0;m<2;m++)for(d=0;d{const e=t.data.sd,i=t.data.p;o(this._makeSurface(e,i.isolevel,i.smooth))}),(a=>{console.warn("Volume.getSurfaceWorker error - trying without worker",a);const c=this.getSurface(t,e,i,r,s,n);o(c)}))}else{const a=this.getSurface(t,e,i,r,s,n);o(a)}}getValueForSigma(t){return this.mean+st(t,2)*this.rms}getSigmaForValue(t){return(st(t,0)-this.mean)/this.rms}get position(){if(!this._position){const t=this.nz,e=this.ny,i=this.nx,r=new Float32Array(i*e*t*3);let s=0;for(let n=0;ni){const t=e;e=i,i=t}const r=t[e];return void 0===r?(t[e]=[i],!0):!r.includes(i)&&(r.push(i),!0)}const i=this.geometry,r=i.index;if(this.parameters.wireframe)if(r){const s=r.array;let n,o=s.length;if(i.drawRange.count!==1/0&&(o=i.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*o)n=this.wireframeIndex;else{n=xt(2*o,i.attributes.position.count)}let a=0;t.length=0;for(let t=0;t2*t?this.wireframeIndex:xt(2*t,t);for(let i=0,r=0;ithis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](this.wireframeIndex,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0));else{const t=this.wireframeGeometry.getIndex();if(!t)return void Me.error("Index is null");t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}}getRenderOrder(){let t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t}_getMesh(t){this.material||this.makeMaterial();const e=this.geometry,i=this[t];let r;return r=this.isLine?new __WEBPACK_IMPORTED_MODULE_0_three__["v" /* LineSegments */](e,i):this.isPoint?new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Points */](e,i):new __WEBPACK_IMPORTED_MODULE_0_three__["A" /* Mesh */](e,i),r.frustumCulled=!1,r.renderOrder=this.getRenderOrder(),r}getMesh(){return this._getMesh("material")}getWireframeMesh(){let t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),t=new __WEBPACK_IMPORTED_MODULE_0_three__["v" /* LineSegments */](this.wireframeGeometry,this.wireframeMaterial),t.frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t}getPickingMesh(){return this._getMesh("pickingMaterial")}getShader(t,e){return gi(t,this.getDefines(e))}getVertexShader(t){return this.getShader(this.vertexShader,t)}getFragmentShader(t){return this.getShader(this.fragmentShader,t)}getDefines(t){const e={};return this.parameters.clipNear&&(e.NEAR_CLIP=1),this.parameters.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.parameters.background)&&(e.NOLIGHT=1),this.parameters.flatShaded&&(e.FLAT_SHADED=1),this.parameters.opaqueBack&&(e.OPAQUE_BACK=1),this.parameters.diffuseInterior&&(e.DIFFUSE_INTERIOR=1),this.parameters.useInteriorColor&&(e.USE_INTERIOR_COLOR=1)),e}getParameters(){return this.parameters}addUniforms(t){this.uniforms=__WEBPACK_IMPORTED_MODULE_0_three__["V" /* UniformsUtils */].merge([this.uniforms,t]),this.pickingUniforms=__WEBPACK_IMPORTED_MODULE_0_three__["V" /* UniformsUtils */].merge([this.pickingUniforms,t])}addAttributes(t){for(let e in t){let i;const r=t[e],s=this.attributeSize*Lo[r.type];r.value?(s!==r.value.length&&Me.error("attribute value has wrong length",e),i=r.value):i=bt("float32",s),this.geometry.setAttribute(e,new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](i,Lo[r.type]).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0))}}updateRenderOrder(){const t=this.getRenderOrder();function e(e){e.renderOrder=t}this.group.children.forEach(e),this.pickingGroup&&this.pickingGroup.children.forEach(e)}updateShader(){const t=this.material,e=this.wireframeMaterial,i=this.pickingMaterial;t.vertexShader=this.getVertexShader(),t.fragmentShader=this.getFragmentShader(),t.needsUpdate=!0,e.vertexShader=this.getShader("Line.vert"),e.fragmentShader=this.getShader("Line.frag"),e.needsUpdate=!0,i.vertexShader=this.getVertexShader("picking"),i.fragmentShader=this.getFragmentShader("picking"),i.needsUpdate=!0}setParameters(t){const e=t,i=this.parameterTypes,r=this.parameters,s={},n={};let o=!1,a=!1;for(const t in e){const c=e[t];void 0!==c&&(r[t]=c,void 0!==i[t]&&(i[t].property&&(!0!==i[t].property?s[i[t].property]=c:s[t]=c),i[t].uniform&&(!0!==i[t].uniform?n[i[t].uniform]=c:n[t]=c),i[t].updateShader&&(o=!0),i[t].updateVisibility&&(a=!0),this.dynamic&&"wireframe"===t&&!0===c&&this.updateWireframeIndex(),"forceTransparent"===t&&(s.transparent=this.transparent),"matrix"===t&&(this.matrix=c)))}this.setProperties(s),this.setUniforms(n),o&&this.updateShader(),a&&this.setVisibility(this.visible)}setAttributes(t){const e=this.geometry,i=e.attributes;for(const r in t){if("picking"===r)continue;const s=t[r],n=s.length;if("index"===r){const t=e.getIndex();if(!t){Me.error("Index is null");continue}e.setDrawRange(0,1/0),n>t.array.length?e.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](s,1).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(t.set(s),t.count=n,t.needsUpdate=n>0,t.updateRange.count=n,e.setDrawRange(0,n)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{const t=i[r];n>t.array.length?e.setAttribute(r,new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](s,t.itemSize).setUsage(this.dynamic?WebGLRenderingContext.DYNAMIC_DRAW:0)):(i[r].set(s),i[r].needsUpdate=n>0,i[r].updateRange.count=n)}}}setUniforms(t){if(!t)return;const e=this.material.uniforms,i=this.wireframeMaterial.uniforms,r=this.pickingMaterial.uniforms;for(let s in t)"opacity"===s&&this.setProperties({transparent:this.transparent}),void 0!==e[s]&&(e[s].value.isVector3?e[s].value.copy(t[s]):e[s].value.set?e[s].value.set(t[s]):e[s].value=t[s]),void 0!==i[s]&&(i[s].value.isVector3?i[s].value.copy(t[s]):i[s].value.set?i[s].value.set(t[s]):i[s].value=t[s]),void 0!==r[s]&&(r[s].value.isVector3?r[s].value.copy(t[s]):r[s].value.set?r[s].value.set(t[s]):r[s].value=t[s])}setProperties(t){if(!t)return;const e=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;for(const s in t){const n=s;let o=t[n];"transparent"===n?this.updateRenderOrder():"side"===n&&(o=Fo(o)),e[n]=o,i[n]=o,r[n]=o}e.needsUpdate=!0,i.needsUpdate=!0,r.needsUpdate=!0}setVisibility(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))}dispose(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()}toJSON(){var t={};for(var e in this)"group"!==e&&"wireframeGroup"!==e&&"pickingGroup"!=e&&"picking"!==e&&(t[e]=this[e]);return t}}class Uo extends Go{constructor(t,e={}){super(t,e),this.vertexShader="Mesh.vert",this.fragmentShader="Mesh.frag",this.addAttributes({normal:{type:"v3",value:t.normal}}),void 0===t.normal&&this.geometry.computeVertexNormals()}}class jo extends Uo{constructor(){super(...arguments),this.isSurface=!0}}function Ho(t){t.visible=!0}function Wo(t){t.visible=!1}class qo{constructor(t){this.group=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.wireframeGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.pickingGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.frontMeshes=[],this.backMeshes=[],this.size=t.size,this.side=t.parameters.side,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.group=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.wireframeGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.pickingGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.matrix=t.matrix;const e=t,i=new t.constructor({position:new Float32Array(0)});e.makeMaterial(),i.makeMaterial(),i.picking=t.picking,i.geometry=t.geometry,i.wireframeGeometry=t.wireframeGeometry,i.setParameters(t.getParameters()),i.updateShader(),e.setParameters({side:"front"}),i.setParameters({side:"back",opacity:i.parameters.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=i}set matrix(t){Go.prototype.setMatrix.call(this,t)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking&&!this.parameters.disablePicking}get parameters(){return this.buffer.parameters}getParameters(){const t=Object.assign({},this.buffer.parameters);return t.side=this.side,t}getMesh(t){let e,i;return t?(i=this.backBuffer.getPickingMesh(),e=this.frontBuffer.getPickingMesh()):(i=this.backBuffer.getMesh(),e=this.frontBuffer.getMesh()),this.frontMeshes.push(e),this.backMeshes.push(i),this.setParameters({side:this.side}),(new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]).add(i,e)}getWireframeMesh(){return this.buffer.getWireframeMesh()}getPickingMesh(){return this.getMesh(!0)}setAttributes(t){this.buffer.setAttributes(t)}setParameters(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(Ho),this.backMeshes.forEach(Wo)):"back"===t.side?(this.frontMeshes.forEach(Wo),this.backMeshes.forEach(Ho)):"double"===t.side&&(this.frontMeshes.forEach(Ho),this.backMeshes.forEach(Ho)),void 0!==t.side&&(this.side=t.side),delete t.side,void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)}setVisibility(t){this.visible=t,this.parameters.wireframe?(this.group.visible=!1,this.wireframeGroup.visible=t,this.pickable&&(this.pickingGroup.visible=!1)):(this.group.visible=t,this.wireframeGroup.visible=!1,this.pickable&&(this.pickingGroup.visible=t))}dispose(){this.frontBuffer.dispose(),this.backBuffer.dispose()}toJSON(){var t={};for(var e in this)["side","size","visible","matrix","parameters"].includes(e)&&(t[e]=this[e]);return t}}Ve.add("shader/Line.vert","uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/Line.frag","uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");class Xo extends Go{constructor(){super(...arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}}class Yo extends zr{constructor(t,r,s){super(t,r,s),this.type="surface",this.parameters=Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},negateIsolevel:{type:"boolean"},isolevelScroll:{type:"boolean"},smooth:{type:"integer",precision:1,max:10,min:0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},boxSize:{type:"integer",precision:1,max:100,min:0},colorVolume:{type:"hidden"},contour:{type:"boolean",rebuild:!0},useWorker:{type:"boolean",rebuild:!0},wrap:{type:"boolean",rebuild:!0}},this.parameters),t instanceof Eo?(this.surface=void 0,this.volume=t):(this.surface=t,this.volume=void 0),this.boxCenter=new e,this.__boxCenter=new e,this.box=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],this.__box=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],this._position=new e,this.inverseMatrix=new i,this.setBox=function(){this._position.copy(r.translationGroup.position).negate(),this._position.applyMatrix4(this.inverseMatrix),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(s)}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),this.isolevelType=st(e.isolevelType,"sigma"),this.isolevel=st(e.isolevel,2),this.negateIsolevel=st(e.negateIsolevel,!1),this.isolevelScroll=st(e.isolevelScroll,!1),this.smooth=st(e.smooth,0),this.background=st(e.background,!1),this.opaqueBack=st(e.opaqueBack,!0),this.boxSize=st(e.boxSize,0),this.colorVolume=st(e.colorVolume,void 0),this.contour=st(e.contour,!1),this.useWorker=st(e.useWorker,!0),this.wrap=st(e.wrap,!1),super.init(e),this.inverseMatrix.getInverse(this.matrix),this.build()}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t)})),this.setVisibility(this.visible),t()}prepare(t){if(this.volume){let e;if(e="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(e*=-1),!this.surface||this.__isolevel!==e||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=e,this.__smooth=this.smooth,this.__contour=this.contour,this.__wrap=this.wrap,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);const i=e=>{this.surface=e,t()};this.useWorker?this.volume.getSurfaceWorker(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,i):i(this.volume.getSurface(e,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t()}else t()}create(){const t={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};let e;if(this.contour)e=new Xo(t,this.getBufferParams({wireframe:!1}));else{Object.assign(t,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});const i=new jo(t,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));e=new qo(i)}this.bufferList.push(e)}update(t){if(0===this.bufferList.length)return;const e={};(t=t||{}).position&&(e.position=this.surface.getPosition()),t.color&&(e.color=this.surface.getColor(this.getColorParams())),t.index&&(e.index=this.surface.getIndex()),t.normal&&(e.normal=this.surface.getNormal()),this.bufferList.forEach((function(t){t.setAttributes(e)}))}setParameters(t,e,i){return t&&void 0!==t.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===t.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===t.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=t.isolevelType),t&&t.boxCenter&&(this.boxCenter.copy(t.boxCenter),delete t.boxCenter),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),super.setParameters(t,e,i),t.matrix&&this.inverseMatrix.getInverse(t.matrix),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),t&&void 0!==t.colorVolume&&e&&(e.color=!0),this.surface&&(void 0!==t.isolevel||void 0!==t.negateIsolevel||void 0!==t.smooth||void 0!==t.wrap||void 0!==t.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this}getColorParams(){const t=super.getColorParams();return t.volume=this.colorVolume,t}dispose(){this.viewer.signals.ticked.remove(this.setBox,this),super.dispose()}}class Ko{static zoomScroll(t,e){t.trackballControls.zoom(e)}static clipNearScroll(t,e){const i=t.getParameters();t.setParameters({clipNear:i.clipNear+e/10})}static focusScroll(t,e){const i=t.getFocus(),r=Math.sign(e)*function(t,e,i){if(t>e)return t;const r=t/e;return((2*i-e)*r+(2*e-3*i))*r*r+i}((100-i)/10,5,.2);t.setFocus(i+r)}static zoomFocusScroll(t,e){t.trackballControls.zoom(e);const i=t.viewer.camera.position.z;t.setFocus(100-Math.abs(i/8))}static isolevelScroll(t,e){const i=Math.sign(e)/10;t.eachRepresentation(((t,e)=>{if(t.repr instanceof Yo){const e=t.getParameters();e.isolevelScroll&&t.setParameters({isolevel:e.isolevel+i})}}))}static panDrag(t,e,i){t.trackballControls.pan(e,i)}static rotateDrag(t,e,i){t.trackballControls.rotate(e,i)}static zRotateDrag(t,e,i){t.trackballControls.zRotate(e,i)}static zoomDrag(t,e,i){t.trackballControls.zoom((e+i)/-2)}static zoomFocusDrag(t,e,i){t.trackballControls.zoom((e+i)/-2);const r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))}static panComponentDrag(t,e,i){t.trackballControls.panComponent(e,i)}static panAtomDrag(t,e,i){t.trackballControls.panAtom(e,i)}static rotateComponentDrag(t,e,i){t.trackballControls.rotateComponent(e,i)}static movePick(t,e){e&&t.animationControls.move(e.position.clone())}static tooltipPick(t,e){const i=t.tooltip;if(t.getParameters().tooltip&&e){const t=e.mouse.position;i.innerText=e.getLabel(),i.style.bottom=window.innerHeight-t.y+3+"px",i.style.left=t.x+3+"px",i.style.display="block"}else i.style.display="none"}static measurePick(t,e){if(e&&(e.atom||e.bond)){const t=e.atom||e.closestBondAtom;e.component.measurePick(t)}else t.measureClear()}}const Zo={default:[["scroll",Ko.zoomScroll],["scroll-shift",Ko.focusScroll],["scroll-ctrl",Ko.isolevelScroll],["scroll-shift-ctrl",Ko.zoomFocusScroll],["drag-left",Ko.rotateDrag],["drag-right",Ko.panDrag],["drag-ctrl-left",Ko.panDrag],["drag-ctrl-right",Ko.zRotateDrag],["drag-shift-left",Ko.zoomDrag],["drag-middle",Ko.zoomFocusDrag],["drag-ctrl-shift-right",Ko.panComponentDrag],["drag-ctrl-shift-left",Ko.rotateComponentDrag],["clickPick-right",Ko.measurePick],["clickPick-ctrl-left",Ko.measurePick],["clickPick-middle",Ko.movePick],["clickPick-left",Ko.movePick],["hoverPick",Ko.tooltipPick]],pymol:[["drag-left",Ko.rotateDrag],["drag-middle",Ko.panDrag],["drag-right",Ko.zoomDrag],["scroll",Ko.focusScroll],["drag-shift-right",Ko.focusScroll],["clickPick-ctrl+shift-middle",Ko.movePick],["hoverPick",Ko.tooltipPick]],coot:[["scroll",Ko.isolevelScroll],["drag-left",Ko.rotateDrag],["drag-middle",Ko.panDrag],["drag-ctrl-left",Ko.panDrag],["drag-right",Ko.zoomFocusDrag],["drag-ctrl-right",Ko.focusScroll],["clickPick-middle",Ko.movePick],["hoverPick",Ko.tooltipPick]],astexviewer:[["drag-left",Ko.rotateDrag],["drag-ctrl-left",Ko.panDrag],["drag-shift-left",Ko.zoomDrag],["scroll",Ko.focusScroll],["clickPick-middle",Ko.movePick],["hoverPick",Ko.tooltipPick]]};function Qo(t){const e=t.split(/[-+]/);let i="";e.includes("scroll")&&(i="scroll"),e.includes("drag")&&(i="drag"),e.includes("click")&&(i="click"),e.includes("doubleClick")&&(i="doubleClick"),e.includes("hover")&&(i="hover"),e.includes("clickPick")&&(i="clickPick"),e.includes("hoverPick")&&(i="hoverPick");let r=0;e.includes("alt")&&(r+=1),e.includes("ctrl")&&(r+=2),e.includes("meta")&&(r+=4),e.includes("shift")&&(r+=8);let s=0;return e.includes("left")&&(s+=1),e.includes("right")&&(s+=2),e.includes("middle")&&(s+=4),[i,r,s]}class Jo{constructor(t,e={}){this.stage=t,this.actionList=[],this.mouse=t.mouseObserver,this.disabled=e.disabled||!1,this.preset(e.preset||"default")}run(t,...e){if(this.disabled)return;const i=this.mouse.key||0,r=this.mouse.buttons||0;this.actionList.forEach((s=>{s.type===t&&s.key===i&&s.button===r&&s.callback(this.stage,...e)}))}add(t,e){const[i,r,s]=Qo(t);this.actionList.push({type:i,key:r,button:s,callback:e})}remove(t,e){const i=t.includes("*"),[r,s,n]=Qo(t),o=this.actionList.filter((function(t){return!((t.type===r||i&&""===r)&&(t.key===s||i&&0===s)&&(t.button===n||i&&0===n)&&(t.callback===e||void 0===e))}));this.actionList=o}preset(t){this.clear();(Zo[t]||[]).forEach((t=>this.add(t[0],t[1])))}clear(){this.actionList.length=0}}class ta{static autoView(t){t.autoView(1e3)}static toggleAnimations(t){t.animationControls.toggle()}static toggleRock(t){t.toggleRock()}static toggleSpin(t){t.toggleSpin()}static toggleAntialiasing(t){const e=t.getParameters();t.setParameters({sampleLevel:-1===e.sampleLevel?0:-1})}}const ea={default:[["i",ta.toggleSpin],["k",ta.toggleRock],["p",ta.toggleAnimations],["a",ta.toggleAntialiasing],["r",ta.autoView]]};class ia{constructor(t,e={}){this.stage=t,this.actionList=[],this.disabled=e.disabled||!1,this.preset(e.preset||"default")}run(t){this.disabled||this.actionList.forEach((e=>{e.key===t&&e.callback(this.stage)}))}add(t,e){this.actionList.push({key:t,callback:e})}remove(t,e){const i=this.actionList.filter((function(i){return!(i.key===t&&(i.callback===e||void 0===e))}));this.actionList=i}preset(t){this.clear();(ea[t]||[]).forEach((t=>this.add(t[0],t[1])))}clear(){this.actionList.length=0}}class ra{constructor(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this)}_onClick(t,e){const i=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)}_onHover(t,e){const i=this.stage.pickingControls.pick(t,e);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component,this.stage.transformAtom=i.atom),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)}dispose(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class sa{constructor(t){this.stage=t,this.stage=t,this.mouse=t.mouseObserver,this.controls=t.mouseControls,this.mouse.signals.moved.add(this._onMove,this),this.mouse.signals.scrolled.add(this._onScroll,this),this.mouse.signals.dragged.add(this._onDrag,this),this.mouse.signals.clicked.add(this._onClick,this),this.mouse.signals.hovered.add(this._onHover,this),this.mouse.signals.doubleClicked.add(this._onDblclick,this)}_onMove(){this.stage.tooltip.style.display="none"}_onScroll(t){this.controls.run("scroll",t)}_onDrag(t,e){this.controls.run("drag",t,e)}_onClick(t,e){this.controls.run("click",t,e)}_onDblclick(t,e){this.controls.run("doubleClick",t,e)}_onHover(t,e){this.controls.run("hover",t,e)}dispose(){this.mouse.signals.moved.remove(this._onMove,this),this.mouse.signals.scrolled.remove(this._onScroll,this),this.mouse.signals.dragged.remove(this._onDrag,this),this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)}}class na{constructor(t){this.stage=t,this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)}_onTick(t){this.animationControls.run(t)}dispose(){this.viewer.signals.ticked.remove(this._onTick,this)}}const oa=!!_e&&{passive:!0};class aa{constructor(t){this.stage=t,this.stage=t,this.controls=t.keyControls,this.domElement=t.viewer.renderer.domElement,this.domElement.setAttribute("tabIndex","-1"),this.domElement.style.outline="none",this._focusDomElement=this._focusDomElement.bind(this),this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),this.domElement.addEventListener("mousedown",this._focusDomElement),this.domElement.addEventListener("touchstart",this._focusDomElement,oa),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)}_onKeydown(){}_onKeyup(){}_onKeypress(t){let e;e="key"in KeyboardEvent.prototype?t.key:String.fromCharCode(t.which||t.keyCode),this.controls.run(e)}_focusDomElement(){this.domElement.focus()}dispose(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,oa),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)}}class ca{constructor(i,r,s,n={}){this.component=i,this.position=r,this.offsetX=st(n.offsetX,0),this.offsetY=st(n.offsetY,0),this.visible=st(n.visible,!0),this.stage=i.stage,this.viewer=i.stage.viewer,this._viewerPosition=new e,this._updateViewerPosition(),this._canvasPosition=new t,this._cameraPosition=new e,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"absolute",pointerEvents:"none",whiteSpace:"nowrap",left:"-10000px"}),this.viewer.wrapper.appendChild(this.element),this.setContent(s),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)}setContent(t){const e=this.element.style.display;if("none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof HTMLElement)this.element.appendChild(t);else{const e=document.createElement("div");e.innerText=t,Object.assign(e.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(e)}this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)}setVisibility(t){this.visible=t,this.updateVisibility()}getVisibility(){return this.visible&&this.component.parameters.visible}updateVisibility(){this.element.style.display=this.getVisibility()?"block":"none"}_updateViewerPosition(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)}_update(){if(!this.getVisibility())return;const t=this.element.style,e=this._canvasPosition,i=this._viewerPosition,r=this._clientRect;if(this._cameraPosition.copy(i).add(this.viewer.translationGroup.position).applyMatrix4(this.viewer.rotationGroup.matrix).sub(this.viewer.camera.position),this._cameraPosition.z<0)return void(t.display="none");t.display="block";const s=this._cameraPosition.length(),n=this.viewer.scene.fog;t.opacity=(1-Rt(n.near,n.far,s)).toString(),t.zIndex=Math.round(100*(n.far-s)).toString(),this.stage.viewerControls.getPositionOnCanvas(i,e),t.bottom=this.offsetX+e.y+r.height/2+"px",t.left=this.offsetY+e.x-r.width/2+"px"}dispose(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)}}const la=new i,ha=new e,da=new r;class ua{constructor(t){this.component=t,this.signals={changed:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.stage=t.stage,this.viewer=t.stage.viewer}get position(){return this.component.position}get rotation(){return this.component.quaternion}changed(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()}spin(t,e){la.getInverse(this.viewer.rotationGroup.matrix),ha.copy(At(t)).applyMatrix4(la),la.extractRotation(this.component.transform),la.premultiply(this.viewer.rotationGroup.matrix),la.getInverse(la),ha.copy(At(t)),ha.applyMatrix4(la),la.makeRotationAxis(ha,e),da.setFromRotationMatrix(la),this.component.quaternion.premultiply(da),this.changed()}}const ma={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"};class pa{constructor(t={}){this.max=10,this.type=st(t.type,"size"),this.scale=st(t.scale,1),this.size=st(t.size,1),this.data=st(t.data,{})}atomRadius(t){let e;switch(this.type){case"vdw":e=t.vdw;break;case"covalent":e=t.covalent;break;case"bfactor":e=t.bfactor||1;break;case"sstruc":const i=t.sstruc;e="h"===i||"g"===i||"i"===i||"e"===i||"b"===i?.25:un.includes(t.atomname)?.4:.1;break;case"data":e=st(this.data[t.index],1);break;case"explicit":e=t.radius,null===e&&(e=this.size);break;default:e=this.size}return Math.min(e*this.scale,this.max)}}pa.types=ma;const fa=new e(-1,-1,-1),ga=new i;class ya{constructor(t){const i=t.rows,r=i/3,s=new ho(i,3),n=new ho(3,3),o=new ho(1,3),a=new ho(3,3),c=new ho(3,3),l=fo(t);go(t,l),uo(s,t),mo(n,s,s),wo(n,o,a,c);const h=new e(l[0],l[1],l[2]),d=new e(a.data[0],a.data[3],a.data[6]),u=new e(a.data[1],a.data[4],a.data[7]),m=new e(a.data[2],a.data[5],a.data[8]),p=d.clone().multiplyScalar(Math.sqrt(o.data[0]/r)),f=u.clone().multiplyScalar(Math.sqrt(o.data[1]/r)),g=m.clone().multiplyScalar(Math.sqrt(o.data[2]/r));this.begA=h.clone().sub(p),this.endA=h.clone().add(p),this.begB=h.clone().sub(f),this.endB=h.clone().add(f),this.begC=h.clone().sub(g),this.endC=h.clone().add(g),this.center=h,this.vecA=p,this.vecB=f,this.vecC=g,this.normVecA=d,this.normVecB=u,this.normVecC=m}getBasisMatrix(t=new i){const e=t;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(fa),e}getRotationQuaternion(t=new r){const e=t;return e.setFromRotationMatrix(this.getBasisMatrix(ga)),e.inverse()}getProjectedScaleForAtoms(t){let i=-1/0,r=-1/0,s=-1/0,n=-1/0,o=-1/0,a=-1/0;const c=new e,l=new e,h=this.center,d=this.normVecA,u=this.normVecB,m=this.normVecC;return t.eachAtom((function(t){jr(c.copy(t),d,h);const e=l.subVectors(c,h).normalize().dot(d),p=c.distanceTo(h);e>0?p>i&&(i=p):p>r&&(r=p),jr(c.copy(t),u,h);const f=l.subVectors(c,h).normalize().dot(u),g=c.distanceTo(h);f>0?g>s&&(s=g):g>n&&(n=g),jr(c.copy(t),m,h);const y=l.subVectors(c,h).normalize().dot(m),b=c.distanceTo(h);y>0?b>o&&(o=b):b>a&&(a=b)})),{d1a:i,d2a:s,d3a:o,d1b:-r,d2b:-n,d3b:-a}}}class ba{constructor(t,e,i,r){this.volume=t,this.setFilter(e,i,r)}get header(){return this.volume.header}get matrix(){return this.volume.matrix}get normalMatrix(){return this.volume.normalMatrix}get inverseMatrix(){return this.volume.inverseMatrix}get center(){return this.volume.center}get boundingBox(){return this.volume.boundingBox}get min(){return this.volume.min}get max(){return this.volume.max}get mean(){return this.volume.mean}get rms(){return this.volume.rms}_getFilterHash(t,e,i){return JSON.stringify([t,e,i])}setFilter(t,e,i){isNaN(t)&&this.header&&(t=this.header.DMEAN+2*this.header.ARMS),t=void 0===t||isNaN(t)?-1/0:t,e=st(e,1/0),i=st(i,!1);const r=this.volume.data,s=this.volume.position,n=this.volume.atomindex,o=this._getFilterHash(t,e,i);if(o!==this._filterHash){if(t===-1/0&&e===1/0)this.data=r,this.position=s,this.atomindex=n;else{const o=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*o),this._positionBuffer=new ArrayBuffer(3*o*4),n&&(this._atomindexBuffer=new ArrayBuffer(4*o)));const a=new Float32Array(this._dataBuffer),c=new Float32Array(this._positionBuffer);let l;n&&(l=new Uint32Array(this._atomindexBuffer));let h=0;for(let d=0;d=t&&u<=e||i&&(ue)){const t=3*h;a[h]=u,c[t+0]=s[o+0],c[t+1]=s[o+1],c[t+2]=s[o+2],n&&l&&(l[h]=n[d]),h+=1}}this.data=new Float32Array(this._dataBuffer,0,h),this.position=new Float32Array(this._positionBuffer,0,3*h),n&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,h))}this._filterHash=o}}}ba.prototype.getValueForSigma=Eo.prototype.getValueForSigma,ba.prototype.getSigmaForValue=Eo.prototype.getSigmaForValue,ba.prototype.getDataAtomindex=Eo.prototype.getDataAtomindex,ba.prototype.getDataPosition=Eo.prototype.getDataPosition,ba.prototype.getDataColor=Eo.prototype.getDataColor,ba.prototype.getDataPicking=Eo.prototype.getDataPicking,ba.prototype.getDataSize=Eo.prototype.getDataSize;class xa{constructor(t,e){const i=Rs({nodeArray1:t.atomIndex1,nodeArray2:t.atomIndex2,edgeCount:t.count,nodeCount:e});this.countArray=i.countArray,this.offsetArray=i.offsetArray,this.indexArray=i.indexArray}}class va extends Bs{get _defaultFields(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]}addBond(t,e,i){this.growIfFull();const r=this.count,s=t.index,n=e.index;s0&&(a[e]=v.angleTo(w));const r=Math.cos(f.angleTo(g));h[e]=180/Math.PI*Math.acos(r);const s=f.length(),x=g.length();c[e]=Math.sqrt(x*s)/Math.max(2,2*(1-r)),l[e]=Math.abs(m.dot(v)),y.copy(f).multiplyScalar(c[e]/s),b.copy(g).multiplyScalar(c[e]/x),y.subVectors(P,y),b.subVectors(I,b),y.toArray(n,i+3),b.toArray(n,i+6),A.subVectors(C,_),A.toArray(d,i),w.copy(v),_.copy(y)}y.fromArray(n,3),b.fromArray(n,6),v.subVectors(y,b).normalize(),C.index=t.getAtomIndexByType(0,S),_.copy(C),x.copy(C),jr(x,v,y),x.toArray(n,0),A.subVectors(_,y),A.toArray(d,0),y.fromArray(n,3*r-6),b.fromArray(n,3*r-9),v.subVectors(y,b).normalize(),C.index=t.getAtomIndexByType(r-1,S),_.copy(C),x.copy(C),jr(x,v,y),x.toArray(n,3*r-3);for(let e=r-3;ei||h.bending[e]>t)&&(E=!0)),E){if(e-p<4){p=e,E=!1;continue}$.index=B.traceAtomIndex,I=h.axis.subarray(3*p+3,3*e),k=h.center.subarray(3*p,3*e+3),C=Ur(I).normalize(),P=Ur(k),M.fromArray(k),jr(M,C,P),T.fromArray(k,k.length-3),jr(T,C,P),C.subVectors(T,M),C.toArray(g,f),P.toArray(y,f),M.toArray(b,f),T.toArray(x,f),u.atomColorToArray($,v,f),w.push($.index),A.push(m.atomRadius($)),_.push(l+p),S.push(l+e+1-p),f+=3,p=e,E=!1}const F=new Float32Array(w);return{axis:new Float32Array(g),center:new Float32Array(y),begin:new Float32Array(b),end:new Float32Array(x),color:new Float32Array(v),picking:new Yn(F,a),size:new Float32Array(A),residueOffset:_,residueCount:S}}}class Ia{constructor(t){this.scoreFunction=t,this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}pop(){const t=this.content[0],e=this.content.pop();return e&&this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}peek(){return this.content[0]}remove(t){const e=this.content.length;for(let i=0;i0;){const i=Math.floor((t+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(e), 2016 + * @author Roman Bolzern , 2013 + * @author I4DS http://www.fhnw.ch/i4ds, 2013 + * @license MIT License + * @description + * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place + * provides fast nearest neighbour search + * + * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs + * + * Further information (including mathematical properties) + * http://en.wikipedia.org/wiki/Binary_tree + * http://en.wikipedia.org/wiki/K-d_tree + * + * @example + * points: [x, y, z, x, y, z, x, y, z, ...] + * metric: function(a, b){ + * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); + * } + * + * @param {Float32Array} points - points + * @param {Function} metric - metric + */class ka{constructor(t,e){this.points=t,this.metric=e,this.maxDepth=0,this.currentNode=0;const i=t.length/3,r=new Uint32Array(i);for(let t=0;tthis.maxDepth&&(this.maxDepth=t);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=e,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=t%3;let d,u,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],u=a[m],a[m]=a[y],a[y]=u,f=g,d=g;d-t[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const d=this.getNodeDepth(c)%3,u=3*o[s[c]],m=[n[u+0],n[u+1],n[u+2]],p=this.metric(t,m);function f(t,i){r.push([t,i]),r.size()>e&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[t]]+r])throw new Error("left child is > parent!");i+=this.verify(a,e+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const t=this.residueType.backboneIndexList;return t.length>0&&t.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const t=this.residueType.backboneType;return 4===t||5===t||6===t}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const t=this.residueType.moleculeType;return 4===t||5===t}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let t=!1;return 1!==this.number||(t=!this.hasBondToElement(6)),t}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index,n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index;if(e.altloc&&i.altloc){const t=e.altloc[r],n=i.altloc[s];if(0!==t&&0!==n&&32!==t&&32!==n&&t!==n)return!1}const n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+t.covalent,h=l+.3,d=l-.5;return cd*d}positionFromArray(t,e=0){return this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this}positionToArray(t=[],e=0){const i=this.index,r=this.atomStore;return t[e+0]=r.x[i],t[e+1]=r.y[i],t[e+2]=r.z[i],t}positionToVector3(t){return void 0===t&&(t=new e),t.x=this.x,t.y=this.y,t.z=this.z,t}positionFromVector3(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}positionAdd(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}positionSub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}getResidueBonds(t=!1){const e=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(t||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+e,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+e,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(t=!1){var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chainname&&(e+=":"+this.chainname),this.atomname&&(e+="."+this.atomname),this.altloc&&(e+="%"+this.altloc),this.structure.modelStore.count>1&&(e+="/"+this.modelIndex),e}clone(){return new Ma(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Ta(t,e){const i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return i*i+r*r+s*s}function Ba(t,e){return Math.sqrt(Ta(t,e))}const Da=new Float32Array(3);class $a{constructor(t,e=!1){De&&Me.time("Kdtree build");const i=e?Ta:Ba,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let n=0;t.eachAtom((function(t){r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z,s[n/3]=t.index,n+=3})),this.atomIndices=s,this.points=r,this.kdtree=new ka(r,i),De&&Me.timeEnd("Kdtree build")}nearest(t,i,r){t instanceof e?t.toArray(Da):t instanceof Ma&&t.positionToArray(Da);const s=this.kdtree.nearest(Da,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let t=0,e=s.length;t":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ra={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Ea=/^[1-9]$/;function Fa(t){let e="";return t.length>0&&(e=":"+gt(t).join(" OR :")),new pe(e)}class La{constructor(t=""){this.name=t,this.partList=[]}get type(){return"Assembly"}addPart(t,e){const i=new Na(t,e);return this.partList.push(i),i}getAtomCount(t){return this.partList.reduce(((e,i)=>e+i.getAtomCount(t)),0)}getResidueCount(t){return this.partList.reduce(((e,i)=>e+i.getResidueCount(t)),0)}getInstanceCount(){let t=0;return this.partList.forEach((function(e){t+=e.matrixList.length})),t}isIdentity(t){if(1!==this.partList.length)return!1;const e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new i).equals(e.matrixList[0]))return!1;let r=[];return t.eachChain((function(t){r.push(t.chainname)})),r=gt(r),e.chainList.length===r.length}getBoundingBox(t){const e=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */];return this.partList.forEach((function(i){const r=i.getBoundingBox(t);e.expandByPoint(r.min),e.expandByPoint(r.max)})),e}getCenter(t){return this.getBoundingBox(t).getCenter(new e)}getSelection(){let t=[];return this.partList.forEach((function(e){t=t.concat(e.chainList)})),Fa(t)}}class Na{constructor(t=[],e=[]){this.matrixList=t,this.chainList=e}get type(){return"AssemblyPart"}_getCount(t,e){let i=0;return t.eachChain((t=>{(0===this.chainList.length||this.chainList.includes(t.chainname))&&(i+=t[e])})),this.matrixList.length*i}getAtomCount(t){return this._getCount(t,"atomCount")}getResidueCount(t){return this._getCount(t,"residueCount")}getBoundingBox(t){const e=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],i=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],r=this.getSelection(),s=t.getBoundingBox(r);return this.matrixList.forEach((function(t){i.copy(s).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)})),e}getSelection(){return Fa(this.chainList)}getView(t){const e=this.getSelection();return e?t.getView(e):t}getInstanceList(){const t=[];for(let e=0,i=this.matrixList.length;e0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function Va(t,e){if(!e)return;De&&Me.time("assignSecondaryStructure");const i=[];t.eachModel((function(t){t.eachChain((function(t){i.push(t.chainname)}))}));const r=i.slice().sort(),s=[];r.forEach((function(t){s.push(i.indexOf(t))}));const n=e.helices.filter((function(t){return pt(r,t[0])>=0}));n.sort((function(t,e){const i=t[0],n=e[0],o=t[1],a=e[1];if(i===n)return o===a?0:o=0}));a.sort((function(t,e){const i=t[0],n=e[0];if(i===n)return 0;const o=pt(r,i),a=pt(r,n);return s[o]=t.residueCount)continue;o.index=n+s,a.index=n+s+e,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[e-2])>r)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},r=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){De&&Me.time("calculateSecondaryStructure"),t.eachPolymer((function(t){if(t.residueCount<4)return;if(t.isCg())!function(t){const i=t.residueStore,r=t.residueIndexStart,s=new Pa(t).position,n=new e,o=new e;for(let e=0,a=t.residueCount;e1&&s.bending[e]<20&&(i.sstruc[r+e]="h".charCodeAt(0),i.sstruc[r+e+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){const e=t.residueStore,s=t.residueIndexStart;for(let n=0,o=t.residueCount;n=e;)i=Math.floor(i/e),s+=Ua[i%e],r+=1;return r>=5&&Me.warn("chainname overflow"),s}function Ha(t,e=!1){De&&Me.time("calculateChainnames");let i=!0;if(t.eachChain((function(t){t.chainname&&(i=!1)})),i){const i=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,e,n,o){const a=r.count;for(let t=0;t{h.add(e),t.forEach((t=>{h.add(t)}))}))),t.eachResidue((function(t){if(!e&&l){const e=t.atomCount,s=t.atomOffset;if(e>500)return void Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());if("auto"===i&&t.hetero)for(let e=t.atomOffset;e{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(d);const m=new e,p=new La("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(t.biomolDict.NCS){const t=[];f.forEach((function(e){u.forEach((function(i){t.push(e.clone().multiply(i))}))})),p.addPart(t)}else p.addPart(f);t.biomolDict.UNITCELL=h,t.biomolDict.SUPERCELL=p,De&&Me.timeEnd("buildUnitcellAssembly")}const Qa=["H","C","O","N","S","P"],Ja=["NA","CL","FE"];function tc(t){let e=t.toUpperCase(),i=0,r=0;for(let t=0;t0)break;++i}else r=t+1;(i>0||r=3&&-1!==Qa.indexOf(e[0])?e[0]:""}function ec(t){const e=t.bondHash,i=e.countArray,r=e.offsetArray,s=e.indexArray,n=t.getBondProxy();t.eachResidue((function(t){const e=t.residueType;if(void 0!==e.bonds)return;var o=t.atomOffset,a=[],c=[],l=[],h={};const d=o+t.atomCount;t.eachAtom((function(t){const e=t.index,u=r[e];for(let t=0,r=i[e];t=d)continue;let i=n.atomIndex2;if(i=d)continue;if(e>i){const t=i;i=e,e=t}const r=e+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(e-o),c.push(i-o),l.push(n.bondOrder))}})),e.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}function ic(t,...e){De&&Me.time("concatStructures");const i=new Cc(t,""),r=new za(i),s=i.atomStore,n=i.atomMap;s.addField("formalCharge",1,"int8"),s.addField("partialCharge",1,"float32");const o={};let a=0,c=0,l=0;e.forEach((t=>{t.eachAtom((t=>{s.growIfFull(),s.atomTypeId[a]=n.add(t.atomname,t.element),s.x[a]=t.x,s.y[a]=t.y,s.z[a]=t.z,s.serial[a]=t.serial,s.formalCharge[a]=t.formalCharge,s.partialCharge[a]=t.partialCharge,s.altloc[a]=t.altloc,s.occupancy[a]=t.occupancy,s.bfactor[a]=t.bfactor,r.addAtom(t.modelIndex+l,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),o[t.index+c]=a,a+=1})),c+=t.atomStore.count,l+=t.modelStore.count}));const h=i.bondStore,d=i.getAtomProxy(),u=i.getAtomProxy();return c=0,e.forEach((t=>{t.eachBond((t=>{d.index=o[t.atomIndex1+c],u.index=o[t.atomIndex2+c],h.addBond(d,u,t.bondOrder)})),c+=t.atomStore.count})),r.finalize(),Ka(i,!0),Ya(i,!0),i.finalizeAtoms(),i.finalizeBonds(),ec(i),De&&Me.timeEnd("concatStructures"),i}const rc=[3,11,19,37,55,87],sc=[4,12,20,38,56,88],nc=[6,15,16,34],oc=[1,7,8,9,17,35,53],ac=[2,10,18,36,54,86],cc=[13,30,31,48,49,50,80,81,82,83,84,85,112],lc=[5,14,32,33,51,52,85],hc=[9,17,35,53,85];class dc{constructor(t,e,i){this.structure=t,this.atomname=e,i=i||tc(e),this.element=i,this.number=Xs[i]||0,this.vdw=Ys[this.number]||2,this.covalent=Ks[this.number]||1.6}getDefaultValence(){const t=Zs[this.number];return t?t[0]:-1}getValenceList(){return Zs[this.number]||[]}getOuterShellElectronCount(){return Qs[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return lc.includes(this.number)}isHalogen(){return hc.includes(this.number)}isDiatomicNonmetal(){return oc.includes(this.number)}isPolyatomicNonmetal(){return nc.includes(this.number)}isAlkaliMetal(){return rc.includes(this.number)}isAlkalineEarthMetal(){return sc.includes(this.number)}isNobleGas(){return ac.includes(this.number)}isTransitionMetal(){const t=this.number;return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}isPostTransitionMetal(){return cc.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class uc{constructor(t){this.structure=t,this.dict={},this.list=[],this.structure=t}add(t,e){const i=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():tc(t));let r=this.dict[i];if(void 0===r){const s=new dc(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(t){return this.list[t]}}class mc{constructor(t,e,i,r,s,n){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=mn[this.backboneType],a=mn[this.backboneStartType],c=mn[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=st(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=st(h,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=st(d,-1);const u=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=st(u,-1);const m=this.getAtomIndexByName(c.backboneEnd);let p;this.backboneEndAtomIndex=st(m,-1),p=on.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=st(p,-1)}getBackboneIndexList(){const t=[];let e;switch(this.moleculeType){case 3:e=dn;break;case 4:case 5:e=un;break;default:return t}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)De&&Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new $a(t,!0),s=t.isCg()?1.2:2.3;for(let t=n;t=0||yc(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}}isAromatic(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]}calculateAromatic(t){const e=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((e=>function(t){if(t.some((t=>!pc.includes(t.number))))return!1;let e=0;const i=new ho(3,t.length),r=i.data;t.forEach((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}));return new ya(i).vecC.length()this.structure.getAtomProxy(e+t.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((t,i)=>{r[i]&&(s.push(t),t.forEach((t=>e[t]=1)))}))}assignBondReferenceAtomIndices(){const t=this.getBondGraph(),e=this.getRings(),i=e.atomRings,r=e.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let e=0;e1)for(let i=0;i1)for(let i=0;i=0;t--)p[f++]=o[t];const g=t.rings.length;for(let e=0;e0?n[c]!==e&&n[e]!==c&&gc(t,e,c):(r[c]=1,s[a++]=c,n[c]=e)}}}const bc=4;class xc{constructor(t){this.structure=t,this.dict={},this.list=[]}add(t,e,i,r="",s){const n=function(t,e,i,r=""){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+r}(t=t.toUpperCase(),e,i,r);let o=this.dict[n];if(void 0===o){const a=new mc(this.structure,t,e,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(t){return this.list[t]}}class vc{constructor(t,i=0){this.structure=t,this.index=i,this.bondStore=t.bondStore,this._v12=new e,this._v13=new e,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(t){this.bondStore.atomIndex1[this.index]=t}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(t){this.bondStore.atomIndex2[this.index]=t}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(t){this.bondStore.bondOrder[this.index]=t}getOtherAtomIndex(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))}getReferenceAtomIndex(){const t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex!==e.residueIndex)return;const i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,s=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}calculateShiftDir(t=new e){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),t.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new vc(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class wc{constructor(t,e=0){this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(t){this.residueStore.chainIndex[this.index]=t}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(t){this.residueStore.atomOffset[this.index]=t}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(t){this.residueStore.atomCount[this.index]=t}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(t){this.residueStore.resno[this.index]=t}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(t){this.residueStore.setSstruc(this.index,t)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(t){this.residueStore.setInscode(this.index,t)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount}get y(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount}get z(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount}eachAtom(t,e){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(e&&e.atomOnlyTest){const i=e.atomOnlyTest;for(let e=r;e0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}getAtomType(t){return this.atomMap.get(this.atomStore.atomTypeId[t])}getResname1(){return en[this.resname.toUpperCase()]||"X"}getBackboneType(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(t){let e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e}hasAtomWithName(t){return this.residueType.hasAtomWithName(t)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const t=this.atomCount,e=this.atomOffset,i=new Array(t);for(let r=0;r=e){const e=st(t,this.structure.getResidueProxy());if(e.index=i,e.connectedTo(this))return e}else if(i===e-1){const i=this.chainStore.residueCount[this.chainIndex],r=st(t,this.structure.getResidueProxy());if(r.index=e+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(t=!1){let e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex,e}clone(){return new wc(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Ac{constructor(t,e,i){this.structure=t,this.residueIndexStart=e,this.residueIndexEnd=i,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueCount=i-e+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)}getAtomIndexByType(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+t,e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(e)}return r}eachAtom(t,e){this.eachResidue((function(i){i.eachAtom(t,e)}))}eachAtomN(t,e,i){const r=this.residueCount,s=new Array(t);for(let e=0;e1&&t(new Ac(n,i,l.index)),i=r)):(o!==Ns&&l.index-i>1&&t(new Ac(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&t(new Ac(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new _c(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Sc{constructor(t,e=0){this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(t){this.modelStore.chainOffset[this.index]=t}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(t){this.modelStore.chainCount[this.index]=t}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(t,e){this.eachChain((function(i){i.eachAtom(t,e)}),e)}eachResidue(t,e){this.eachChain((function(i){i.eachResidue(t,e)}),e)}eachPolymer(t,e){if(e&&e.chainOnlyTest){const i=e.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(t,e)}))}else this.eachChain((function(i){i.eachPolymer(t,e)}))}eachChain(t,e){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(e&&e.test){const i=e.chainOnlyTest;if(i)for(let e=r;e{const i=3*e;a.index=t,l&&a.positionToArray(l,i),h&&n.atomColorToArray(a,h,i),d&&(d.array[e]=t),u&&(u[e]=s.atomRadius(a)),m&&(m[e]=t)})),o}getBondData(t){const i=Object.assign({},t);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=st(i.bondSet,this.bondSet),n=st(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=st(i.bondScale,.4),l=st(i.bondSpacing,1);let h,d;const u={},m=this.getBondProxy();i.bondStore&&(m.bondStore=i.bondStore);const p=this.getAtomProxy(),f=this.getAtomProxy();let g;if(o){const t=m.bondStore.bondOrder;g=0,s.forEach((function(e){g+=t[e]}))}else g=s.getSize();r&&!r.position||(u.position1=new Float32Array(3*g),u.position2=new Float32Array(3*g)),r&&!r.color||!i.colorParams||(u.color=new Float32Array(3*g),u.color2=new Float32Array(3*g),d=Fe.getScheme(i.colorParams)),r&&!r.picking||(u.picking=new Zn(new Float32Array(g),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(h=new pa(i.radiusParams)),r&&!r.radius||(u.radius=new Float32Array(g),i.radius2&&(u.radius2=new Float32Array(g)));const{position1:y,position2:b,color:x,color2:v,picking:w,radius:A,radius2:_}=u;let S,C,P,I,k,M,T=0;const B=new e,D=new e,$=new e;return s.forEach((t=>{if(C=3*T,m.index=t,p.index=m.atomIndex1,f.index=m.atomIndex2,I=m.bondOrder,y)if(o&&I>1){const t=h.atomRadius(p);M=t*c/(.5*I),m.calculateShiftDir($),a?(k=2*l*t,$.multiplyScalar(k),$.negate(),D.subVectors(f,p).multiplyScalar(Math.max(.1,k/1.88)),p.positionToArray(y,C),f.positionToArray(b,C),I>=2&&(B.addVectors(p,$).add(D).toArray(y,C+3),B.addVectors(f,$).sub(D).toArray(b,C+3),I>=3&&(B.subVectors(p,$).add(D).toArray(y,C+6),B.subVectors(f,$).sub(D).toArray(b,C+6)))):(k=(l-c)*t,$.multiplyScalar(k),2===I?(B.addVectors(p,$).toArray(y,C),B.subVectors(p,$).toArray(y,C+3),B.addVectors(f,$).toArray(b,C),B.subVectors(f,$).toArray(b,C+3)):3===I?(p.positionToArray(y,C),B.addVectors(p,$).toArray(y,C+3),B.subVectors(p,$).toArray(y,C+6),f.positionToArray(b,C),B.addVectors(f,$).toArray(b,C+3),B.subVectors(f,$).toArray(b,C+6)):(p.positionToArray(y,C),f.positionToArray(b,C)))}else p.positionToArray(y,C),f.positionToArray(b,C);if(x&&v&&(d.bondColorToArray(m,1,x,C),d.bondColorToArray(m,0,v,C),o&&I>1))for(S=1;S1))for(S=1;S1))for(M=A[T]*c/(a?1:.5*I),S=a?1:0;S1))for(M=_[T]*c/(a?1:.5*I),S=a?1:0;S{const e=t.x,a=t.y,l=t.z;en&&(n=e),a>o&&(o=a),l>c&&(c=l)}),t),e.min.set(i,r,s),e.max.set(n,o,c),De&&Me.timeEnd("getBoundingBox"),e}getPrincipalAxes(t){De&&Me.time("getPrincipalAxes");let e=0;const i=new ho(3,this.atomCount),r=i.data;return this.eachAtom((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}),t),De&&Me.timeEnd("getPrincipalAxes"),new ya(i)}atomCenter(t){return t?this.getBoundingBox(t).getCenter(new e):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const t=this.atomStore;this._hasCoords=0!==Di(t.x)||0!==Bi(t.x)||0!==Di(t.y)||0!==Bi(t.y)||0!==Di(t.z)||0!==Bi(t.z)||t.count/this.modelStore.count==1}return this._hasCoords}getSequence(t){const e=[],i=this.getResidueProxy();return this.eachAtom((function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())}),t),e}getAtomIndices(t){if(t&&t.string){const e=[];return this.eachAtom((function(t){e.push(t.index)}),t),new Uint32Array(e)}{const t={what:{index:!0}};return this.getAtomData(t).index}}getChainnameCount(t){const e=new Set;return this.eachChain((function(t){t.residueCount&&e.add(t.chainname)}),t),e.size}updatePosition(t,e=!0){let i=0;this.eachAtom((function(e){e.positionFromArray(t,i),i+=3}),void 0),this._hasCoords=void 0,e&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Ts(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const Pc=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],Ic=[_s,xs,Ss,As,Cs,vs,bs,ws,Is,Ps,ks,Ms],kc={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Mc{constructor(t="shape",e={}){this.boundingBox=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=nt(e,kc),Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)]=[]})),this._primitiveData[t.getShapeKey("name")]=[]}))}addBuffer(t){this.bufferList.push(t);const e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this}addMesh(t,e,i,r,s){let n;t=Ct(t),e=Ct(e),Array.isArray(i)&&(i=xt(i,t.length)),r&&(r=Ct(r)),n=void 0===r||0==r.length?{position:t,color:e,index:i}:{position:t,color:e,index:i,normal:r};const o=new io(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Uo(Object.assign({picking:o},n));return this.bufferList.push(a),Pc.setFromArray(t),this.boundingBox.union(Pc),this.meshCount+=1,this}addSphere(t,e,i,r){return bs.objectToShape(this,{position:t,color:e,radius:i,name:r}),this}addEllipsoid(t,e,i,r,s,n){return Cs.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(t,e,i,r,s,n){return Ps.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(t,e,i,r,s){return As.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addCone(t,e,i,r,s){return Ss.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addArrow(t,e,i,r,s){return _s.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addBox(t,e,i,r,s,n){return xs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(t,e,i,r,s,n){return vs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(t,e,i,r,s,n){return ws.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(t,e,i,r){return Is.objectToShape(this,{position:t,color:e,size:i,text:r}),this}addPoint(t,e,i){return ks.objectToShape(this,{position:t,color:e,name:i}),this}addWideline(t,e,i,r,s){return this.parameters.linewidth=r,Ms.objectToShape(this,{position1:t,position2:e,color:i,name:s}),this}addLabel(t,e,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,i,r)}getBufferList(){const t=[];return Ic.forEach((e=>{this._primitiveData[e.getShapeKey("color")].length&&t.push(e.bufferFromShape(this,this.parameters))})),this.bufferList.concat(t)}dispose(){this.bufferList.forEach((function(t){t.dispose()})),this.bufferList.length=0,Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)].length=0})),this._primitiveData[t.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new e)),this._center}get type(){return"Shape"}}class Tc extends zr{constructor(t,e,i){Array.isArray(t)||(t=[t]),super(t,e,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=t,this.init(i)}init(t){super.init(t),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t),t.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),t()}}const Bc=new i,Dc=new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix3 */];class $c extends Uo{constructor(t,e={},i){super(function(t,e){const i=e.attributes.position.array,r=e.index?e.index.array:void 0,s=t.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=xt(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:t.primitiveId||Ii(s,n),picking:t.picking}}(t,i),e),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=t.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(t),n){const t=this.geometry.getIndex();if(!t)return void Me.error("Index is null");this.meshIndex=t.array,this.makeIndex()}}setAttributes(t={},e=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d;const u=this.updateNormals;t.position&&(r=t.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(u||e)&&(o=this.geoNormal,d=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),t.color&&(s=t.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let t=0;t 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Fc extends Go{constructor(t,e,i={}){super(e,i),this.index=xt(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:t,value:null}}),this.setAttributes({primitiveId:Pi(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(t){const e={};for(const i in t){const r=t[i];e[i]={type:r.type,value:null}}super.addAttributes(e)}getAttributeIndex(t){return 3*t*this.mappingSize}setAttributes(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Ai(t.position1,t.position2));const e=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const d in t)if("index"!==d&&"picking"!==d){n=t[d],s=r[d],o=s.itemSize,a=s.array;for(let t=0;t0&&this.parameters.alphaTest<=1&&(e.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),e}setUniforms(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),super.setUniforms(t)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",Wc);class qc extends zr{constructor(t,e,i){super(t,e,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),t instanceof Eo?(this.surface=void 0,this.volume=new ba(t)):(this.surface=t,this.volume=void 0),this.init(i)}init(t){var e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),this.thresholdType=st(e.thresholdType,"sigma"),this.thresholdMin=st(e.thresholdMin,2),this.thresholdMax=st(e.thresholdMax,1/0),this.thresholdOut=st(e.thresholdOut,!1),this.dotType=st(e.dotType,"point"),this.radius=st(e.radius,.1),this.scale=st(e.scale,1),this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e),this.build()}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){var t={};if(this.volume){var e,i,r=this.volume;"sigma"===this.thresholdType?(e=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,i=this.thresholdMax),r.setFilter(e,i,this.thresholdOut),Object.assign(t,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(t,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Gc(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Wc(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(t={}){if(0===this.bufferList.length)return;const e={};t.color&&(this.volume?Object.assign(e,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(e,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?Object.assign(e,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(e,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(e)}setParameters(t,e={},i){return t&&void 0!==t.thresholdType&&this.volume instanceof Eo&&("value"===this.thresholdType&&"sigma"===t.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===t.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=t.thresholdType),t&&void 0!==t.radiusType&&("radius"===t.radiusType?this.radius=.1:this.radius=parseFloat(t.radiusType),e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.scale=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),super.setParameters(t,e,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Xc=new Uint16Array([0,1,2,1,3,2]),Yc=new Float32Array([0,1,0,0,1,1,1,0]),Kc=Object.assign({filter:"nearest",forceTransparent:!0},zo),Zc=Object.assign({filter:{updateShader:!0,uniform:!0}},Vo);class Qc extends Go{constructor(e,i){super({position:e.position,index:Xc,picking:e.picking},i),this.parameterTypes=Zc,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new __WEBPACK_IMPORTED_MODULE_0_three__["l" /* DataTexture */](r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let t=0;t>16&255,c[t+1]=e>>8&255,c[t+2]=255&e}const l=new __WEBPACK_IMPORTED_MODULE_0_three__["l" /* DataTexture */](c,s,n);l.flipY=!0,l.minFilter=__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],l.magFilter=__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t(s,n)}}),this.geometry.setAttribute("uv",new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](Yc,2))}get defaultParameters(){return Kc}getDefines(t){const e=super.getDefines(t),i=this.parameters.filter;return i.startsWith("cubic")&&(e.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?e.BSPLINE_FILTER=1:i.endsWith("catmulrom")?e.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(e.MITCHELL_FILTER=1)),e}updateTexture(){const t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],t.magFilter=__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */]):"linear"===e?(t.minFilter=__WEBPACK_IMPORTED_MODULE_0_three__["x" /* LinearFilter */],t.magFilter=__WEBPACK_IMPORTED_MODULE_0_three__["x" /* LinearFilter */]):(t.minFilter=__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */],t.magFilter=__WEBPACK_IMPORTED_MODULE_0_three__["B" /* NearestFilter */]),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const t=this.material;t.uniforms.map.value=this.tex,t.blending=__WEBPACK_IMPORTED_MODULE_0_three__["D" /* NormalBlending */],t.needsUpdate=!0;const e=this.wireframeMaterial;e.uniforms.map.value=this.tex,e.blending=__WEBPACK_IMPORTED_MODULE_0_three__["D" /* NormalBlending */],e.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=__WEBPACK_IMPORTED_MODULE_0_three__["D" /* NormalBlending */],i.needsUpdate=!0}setUniforms(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),super.setUniforms(t)}}class Jc{constructor(t,e){const i=e||{};this.dimension=st(i.dimension,"x"),this.positionType=st(i.positionType,"percent"),this.position=st(i.position,30),this.thresholdType=st(i.thresholdType,"sigma"),this.thresholdMin=st(i.thresholdMin,-1/0),this.thresholdMax=st(i.thresholdMax,1/0),this.normalize=st(i.normalize,!1),this.volume=t}getPositionFromCoordinate(t){const i=this.dimension,r=this.volume,s=r.matrix,n=(new e).setFromMatrixPosition(s)[i],o=(new e).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-n)/(a/100)+1)/o)}getData(t){t=t||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(t){return Math.round(t/100*(n-1))}function a(t,e,r,s){return 3*(r*i.ny*i.nx+e*i.nx+t)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new e;let h,d,u,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(t,e,i,r){l.set(t,e,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(u=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,d=i.ny,f=u,b=f+1,w(u,0,0,0),w(u,m,0,3),w(u,0,p,6),w(u,m,p,9)):"y"===this.dimension?(u=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,d=i.nx,g=m,x=g+1,w(0,m,0,0),w(u,m,0,3),w(0,m,p,6),w(u,m,p,9)):"z"===this.dimension&&(u=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,d=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(u,0,p,6),w(u,m,p,9));let A=0,_=0;const S=new Uint8Array(h*d*4),C=new Float32Array(h*d);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},t.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Fe.getScheme(k),T=new Float32Array(3),B=M.getScale();let D,$=0,O=0;if(this.normalize){$=1/0,D=-1/0;for(let t=g;tD&&(D=s)}O=D-$}for(let t=g;tP&&n{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){const t=new Jc(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),e=new Qc(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)}}function el(t){Me.error(`makeRepresentation: representation type ${t} unknown`)}const il={name:"some element",status:""};class rl{constructor(t,e={}){this.stage=t,this.signals={statusChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],nameChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],disposed:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.parameters=nt(e,this.defaultParameters),this.uuid=Bt()}get defaultParameters(){return il}get name(){return this.parameters.name}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}dispose(){this.signals.disposed.dispatch()}}const sl=Object.assign({visible:!0},il);class nl extends rl{constructor(t,e,i={},r){super(t,Object.assign({name:e.type},i)),this.parent=r,this.signals=Object.assign({visibilityChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],parametersChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.signals),this.setRepresentation(e)}get defaultParameters(){return sl}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(t){this._disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(t){return this.parameters.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(t){return this.repr.update(t),this}build(t){return this.repr.build(t),this}setSelection(t){const e=this.repr;return e.setSelection&&e.setSelection(t),this}setParameters(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(t){return this.repr.setColor(t),this}}const ol=new i,al=new e,cl={name:"",status:"",visible:!0};class ll{constructor(t,s,n={}){this.stage=t,this.object=s,this.signals={representationAdded:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],representationRemoved:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],visibilityChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],matrixChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],statusChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],nameChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],disposed:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.reprList=[],this.annotationList=[],this.matrix=new i,this.position=new e,this.quaternion=new r,this.scale=new e(1,1,1),this.transform=new i,this.parameters=nt(n,this.defaultParameters),this.uuid=Bt(),this.viewer=t.viewer,this.controls=new ua(this)}get defaultParameters(){return cl}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this}setRotation(t){if(Array.isArray(t))if(3===t.length){const e=(new __WEBPACK_IMPORTED_MODULE_0_three__["n" /* Euler */]).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof __WEBPACK_IMPORTED_MODULE_0_three__["n" /* Euler */]?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this}setScale(t){return this.scale.set(t,t,t),this.updateMatrix(),this}setTransform(t){return this.transform.copy(t),this.updateMatrix(),this}updateMatrix(){const t=this.getCenterUntransformed(al);this.matrix.makeTranslation(-t.x,-t.y,-t.z),ol.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(ol),ol.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(ol);const e=this.position;ol.makeTranslation(e.x+t.x,e.y+t.y,e.z+t.z),this.matrix.premultiply(ol),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((t=>{t.setParameters({matrix:this.matrix})}))}addAnnotation(t,e,i){const r=new ca(this,t,e,i);return this.annotationList.push(r),r}eachAnnotation(t){this.annotationList.slice().forEach(t)}removeAnnotation(t){const e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())}removeAllAnnotations(){this.eachAnnotation((t=>t.dispose())),this.annotationList.length=0}_addRepresentation(t,e,i,r=!1){const s=i||{},n=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||n.quality,s.disableImpostor=st(s.disableImpostor,!n.impostor),s.useWorker=st(s.useWorker,n.workerDefault),s.visible=st(s.visible,!0);const o=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),a=function(t,e,i,r){var s;if(De&&Me.time("makeRepresentation "+t),e instanceof Cc){if(!(s=Ne.get(t)))return void el(t)}else if(e instanceof Oo)if("surface"===t)s=Yo;else{if("dot"!==t)return void el(t);s=qc}else if(e instanceof Eo)if("surface"===t)s=Yo;else if("dot"===t)s=qc;else{if("slice"!==t)return void el(t);s=tl}else if(e instanceof Mc)s=Tc,e=e.getBufferList();else{if("buffer"!==t)return void Me.error("makeRepresentation: object "+e+" unknown");s=Tc}const n=new s(e,i,r);return De&&Me.timeEnd("makeRepresentation "+t),n}(t,e,this.viewer,o),c=new nl(this.stage,a,s,this);return r||(this.reprList.push(c),this.signals.representationAdded.dispatch(c)),c}addBufferRepresentation(t,e){return this._addRepresentation.call(this,"buffer",t,e)}hasRepresentation(t){return-1!==this.reprList.indexOf(t)}eachRepresentation(t){this.reprList.slice().forEach(t)}removeRepresentation(t){const e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))}updateRepresentations(t){this.reprList.forEach((e=>e.update(t))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((t=>t.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(t){return this.parameters.visible=t,this.eachRepresentation((t=>t.updateVisibility())),this.eachAnnotation((t=>t.updateVisibility())),this.signals.visibilityChanged.dispatch(t),this}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}getBox(...t){return this.getBoxUntransformed(...t).clone().applyMatrix4(this.matrix)}getCenter(...t){return this.getCenterUntransformed(...t).clone().applyMatrix4(this.matrix)}getZoom(...t){return this.stage.getZoomForBox(this.getBox(...t))}getBoxUntransformed(...t){return new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */]}getCenterUntransformed(...t){return this.getBoxUntransformed().getCenter(new e)}autoView(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),st(t,0))}}class hl{constructor(t=[]){this.list=t;const e=t.length;for(let i=0;i0?this.list[0]:void 0}forEach(t){return this.list.forEach(t),this}dispose(){return this.forEach((t=>t.dispose()))}}class dl extends hl{setParameters(t){return this.forEach((e=>e.setParameters(t)))}setVisibility(t){return this.forEach((e=>e.setVisibility(t)))}setSelection(t){return this.forEach((e=>e.setSelection(t)))}setColor(t){return this.forEach((e=>e.setColor(t)))}update(t){return this.forEach((e=>e.update(t)))}build(t){return this.forEach((e=>e.build(t)))}dispose(t){return this.forEach((t=>t.dispose()))}}const ul=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},il);class ml extends rl{constructor(t,e,i={}){super(t,Object.assign({name:e.name},i)),this.trajectory=e,this.signals=Object.assign(this.signals,{frameChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],playerChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],countChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],parametersChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]}),e.signals.frameChanged.add((t=>{this.signals.frameChanged.dispatch(t)})),e.signals.playerChanged.add((t=>{this.signals.playerChanged.dispatch(t)})),e.signals.countChanged.add((t=>{this.signals.countChanged.dispatch(t)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return ul}get type(){return"trajectory"}setFrame(t){this.trajectory.setFrame(t)}setParameters(t={}){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)}dispose(){this.trajectory.dispose(),super.dispose()}}class pl{constructor(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class fl{constructor(t,e){let r,s;if(this.A=new ho(3,3),this.W=new ho(1,3),this.U=new ho(3,3),this.V=new ho(3,3),this.VH=new ho(3,3),this.R=new ho(3,3),this.tmp=new ho(3,3),this.c=new ho(3,3),t instanceof Cc)r=t.atomCount;else{if(!(t instanceof Float32Array))return;r=t.length/3}if(e instanceof Cc)s=e.atomCount;else{if(!(e instanceof Float32Array))return;s=e.length/3}const n=Math.min(r,s),o=new ho(3,n),a=new ho(3,n);this.coords1t=new ho(n,3),this.coords2t=new ho(n,3),this.transformationMatrix=new i,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,o,n,!1),this.prepCoords(e,a,n,!1),this._superpose(o,a)}_superpose(t,e){this.mean1=fo(t),this.mean2=fo(e),go(t,this.mean1),go(e,this.mean2),uo(this.coords1t,t),uo(this.coords2t,e),mo(this.A,this.coords2t,this.coords1t),wo(this.A,this.W,this.U,this.V),function(t,e){const i=t.data,r=e.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,d=i[3],u=i[1],m=d*u,p=i[2],f=d*p,g=i[6],y=g*u,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(u*n-p*a)*x,r[2]=-(-u*o+p*s)*x,r[3]=-(d*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-d*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),po(this.R,this.U,this.VH),function(t){const e=t.data;return e[0]*e[4]*e[8]-e[0]*e[5]*e[7]-e[3]*e[1]*e[8]+e[3]*e[2]*e[7]+e[6]*e[1]*e[5]-e[6]*e[2]*e[4]}(this.R)<0&&(De&&Me.log("R not a right handed system"),po(this.tmp,this.c,this.VH),po(this.R,this.U,this.tmp));const i=new ho(4,4),r=new ho(4,4),s=new ho(4,4),n=new ho(4,4),o=new ho(4,4),a=new ho(4,4),c=this.R.data,l=this.mean1,h=this.mean2;n.data.set([1,0,0,-l[0],0,1,0,-l[1],0,0,1,-l[2],0,0,0,1]),o.data.set([c[0],c[1],c[2],0,c[3],c[4],c[5],0,c[6],c[7],c[8],0,0,0,0,1]),a.data.set([1,0,0,h[0],0,1,0,h[1],0,0,1,h[2],0,0,0,1]),uo(r,n),mo(i,o,r),uo(s,i),mo(r,a,s),uo(i,r),this.transformationMatrix.elements=i.data}prepCoords(t,e,i,r){let s=0;const n=e.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),t instanceof Cc)t.eachAtom((function(t){s{t!==this&&this.pause()}),this);const i=st(t.frameCount,1);this.traj=t,this.parameters=nt(e,gl),this.parameters.end=Math.min(st(e.end,i-1),i-1),this.parameters.step=st(e.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,t.signals.countChanged.add((t=>{this.parameters.end=Math.min(st(this.parameters.end,t-1),t-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(t={}){ot(this.parameters,t),void 0!==t.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const t=this._currentTime-this._previousTime,e=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/e,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&t>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const t=this._currentStep/(this.parameters.interpolateStep+1),[e,i,s,n]=this._currentFrame;r.setFrameInterpolated(e,i,s,n,t,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const t=this._next();r.hasFrame(t)?(r.setFrame(t),this._previousTime=this._currentTime):r.loadFrame(t)}window.requestAnimationFrame(this._animate)}_next(){const t=this.parameters;let e;return e="forward"===this._direction?this.traj.currentFrame+t.step:this.traj.currentFrame-t.step,(e>t.end||e=t.end?i=t.start:"backward"===t.direction&&e<=t.start&&(i=t.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class bl{constructor(t,e,i={}){this.signals={countChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],frameChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],playerChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=st(i.deltaTime,0),this.timeOffset=st(i.timeOffset,0),this.centerPbc=st(i.centerPbc,!1),this.removePbc=st(i.removePbc,!1),this.removePeriodicity=st(i.removePeriodicity,!1),this.superpose=st(i.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new pe(st(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new yl(this))}_loadFrameCount(){}setStructure(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new pe("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(t){return this.selection.setString(t),this}_getIndices(t){let e=0;const i=t.test,r=[];return i&&this.structure.eachAtom((t=>{i(t)&&r.push(e),e+=1})),r}_makeSuperposeCoords(){const t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);const e=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[t])):!!this.frameCache[t]}setFrame(t,e){return void 0===t||(this.inProgress=!0,-1===t||this.frameCache[t]?(this._updateStructure(t),e&&e()):this.loadFrame(t,(()=>{this._updateStructure(t),e&&e()}))),this}_interpolate(t,e,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(t,e,i,r,s){const n=t.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(t,e,i,r,s,n),o&&o()})):(this._interpolate(t,e,i,r,s,n),o&&o()),this}loadFrame(t,e){Array.isArray(t)?t.forEach((t=>{this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t]})))})):this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t],e&&e()})))}_loadFrame(t,e){Me.error("Trajectory._loadFrame not implemented",t,e)}_updateStructure(t){this._disposed?console.error("updateStructure: traj disposed"):(-1===t?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[t]),this.structure.trajectory={name:this.trajPath,frame:t},this._currentFrame=t,this.inProgress=!1,this.signals.frameChanged.dispatch(t))}_doSuperpose(t){const e=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const t=[e[0],e[4],e[8]],r=function(t,e,i){return[wi(e,i[0],3,0,t),wi(e,i[1],3,1,t),wi(e,i[2],3,2,t)]}(this.backboneIndices,i,t);!function(t,e,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=t.length,s=i[0],n=i[1],o=i[2],a=-e[0]+s+s/2,c=-e[1]+n+n/2,l=-e[2]+o+o/2;for(let e=0;e.5&&(t[s+r]-=e[3*r+r]*Math.round(n))}}(i,e,t)}this.removePbc&&function(t,e){if(0===e[0]||0===e[8]||0===e[4])return;const i=t.length;for(let r=3;r.9*e[3*i+i])if(s>0)for(let s=0;s<3;++s)t[r+s]-=e[3*i+s];else for(let s=0;s<3;++s)t[r+s]+=e[3*i+s]}}(i,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1}_setFrameCount(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(t){this.player=t,this.signals.playerChanged.dispatch(t)}getFrameTime(t){return this.timeOffset+t*this.deltaTime}}class xl extends bl{constructor(t,e,i){const r=i||{};r.timeOffset=st(r.timeOffset,t.timeOffset),r.deltaTime=st(r.deltaTime,t.deltaTime),super("",e,r),this.name=t.name,this.path=t.path,this.frames=t.coordinates,this.boxes=t.boxes,this._init(e)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(t,e){let i;const r=this.frames[t];if(this.atomIndices){const t=this.atomIndices,e=t.length;i=new Float32Array(3*e);for(let s=0;s{const s=i.response;if(!s)return void Me.error(`empty arrayBuffer for '${r}'`);const n=new Int32Array(s,0,1)[0],o=new Float32Array(s,8,9),a=new Float32Array(s,44);this._process(t,o,a,n),"function"==typeof e&&e()}),!1),i.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,e=qe.getCountUrl(this.trajPath);t.open("GET",e,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Al extends bl{constructor(t,e,i){super("",e,i),this.requestCallback=t,this._init(e)}get type(){return"callback"}_makeAtomIndices(){const t=[];if("StructureView"===this.structure.type){const e=this.structure.getAtomIndices(),i=e.length;let r=e[0],s=e[0];for(let n=1;n{this._process(t,i,r,s),"function"==typeof e&&e()}),t,this.atomIndices)}_loadFrameCount(){this.requestCallback((t=>this._setFrameCount(t)))}}Cc.prototype.getView=function(t){return new _l(this,t)};class _l extends Cc{constructor(t,i){super(),this.structure=t,this.selection=i,this.center=new e,this.boundingBox=new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */],this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(t){this.structure._hasCoords=t}refresh(){De&&Me.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Os(t.atomCount),this.bondSet=new Os(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Os(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new e)}De&&Me.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(t){this.selection=t,this.refresh()}getSelection(t){const e=[];t&&t.string&&e.push(t.string);const i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);let r="";return e.length>0&&(r=`( ${e.join(" ) AND ( ")} )`),new pe(r)}getStructure(){return this.structure.getStructure()}eachBond(t,e){this.structure.eachBond(t,this.getSelection(e))}eachAtom(t,e){const i=this.getAtomProxy(),r=this.getAtomSet(e),s=this.atomStore.count;if(r.getSize()=this.V[i][r]?(e="S",this.score=this.S[i][r]):this.V[i][r]>=this.H[i][r]?(e="V",this.score=this.V[i][r]):(e="H",this.score=this.H[i][r]),De&&Me.log("Alignment: SCORE",this.score),De&&Me.log("Alignment: S, V, H",this.S[i][r],this.V[i][r],this.H[i][r]);i>0&&r>0;)"S"===e?this.S[i][r]===this.S[i-1][r-1]+t(i-1,r-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--i,--r,e="S"):this.S[i][r]===this.V[i][r]?e="V":this.S[i][r]===this.H[i][r]?e="H":(--i,--r):"V"===e?this.V[i][r]===this.V[i-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="V"):this.V[i][r]===this.S[i-1][r]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="S"):--i:"H"===e?this.H[i][r]===this.H[i][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="H"):this.H[i][r]===this.S[i][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="S"):--r:Me.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;De&&Me.timeEnd("Alignment.trace"),De&&Me.log([this.ali1,this.ali2])}}function kl(t,e,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=t,h=e;r&&s&&(i=t.getView(new pe(r)),h=e.getView(new pe(s)));const d=i.getSequence(),u=h.getSequence(),m=new Il(d.join(""),u.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let t=0;tt[e]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Te.opacity,color:Te.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Te,!0),this.angleRepresentation=this.addRepresentation("angle",Te,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Te,!0),this.measureRepresentations=new dl([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Ml}get type(){return"structure"}initSelection(t){this.selection=new pe(t),this.structureView=new _l(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(t){return this.parameters.sele=t,this.selection.setString(t),this}setDefaultAssembly(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){const e={defaultAssembly:t};this.reprList.forEach((t=>t.setParameters(e))),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this}rebuildRepresentations(){this.reprList.forEach((t=>{t.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((t=>{t.trajectory.setStructure(this.structureView)}))}updateRepresentations(t){super.updateRepresentations(t),this.measureRepresentations.update(t)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(t,e={},i=!1){e.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(t,this.structureView,e,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(t="",e={}){const i=function(t,e,i){let r;return r=t&&t instanceof pl?new xl(t,e,i):!t&&e.frames?new vl(t,e,i):t&&"function"==typeof t?new Al(t,e,i):new wl(t,e,i),r}(t,this.structureView,e),r=new ml(this.stage,i,e);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(t){const e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)}dispose(){this.trajList.slice().forEach((t=>t.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),st(e,0))}getBoxUntransformed(t){let e;return e=t?this.structureView.getBoundingBox(new pe(t)):this.structureView.boundingBox,e}getCenterUntransformed(t){return t&&"string"==typeof t?this.structure.atomCenter(new pe(t)):this.structure.center}superpose(t,e,i,r){return kl(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(t){let e=0;const i=this.structure.getAtomProxy(t);return this.eachRepresentation((t=>{if(t.getVisibility()){const r=t.repr;e=Math.max(r.getAtomRadius(i),e)}})),e}measurePick(t){const e=this.pickBuffer.count;if(this.lastPick===t.index&&e>=1){if(e>1){const t=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,t),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((t=>2===t.length))}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((t=>3===t.length))}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((t=>4===t.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(t.index)||this.pickBuffer.push(t.index),this.lastPick=t.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})}measureUpdate(){const t=this.pickBuffer.data,e={};t.forEach((t=>{const i=Math.max(.1,this.getMaxRepresentationRadius(t));e[t]=i*(2.3-Rt(.1,2,i))})),this.spacefillRepresentation.setSelection(t.length?"@"+t.join(","):"none"),t.length&&this.spacefillRepresentation.setParameters({radiusData:e})}measureData(){const t=this.pickDict.values;return{distance:t.filter((t=>2===t.length)),angle:t.filter((t=>3===t.length)),dihedral:t.filter((t=>4===t.length))}}removeAllMeasurements(t){const e=this.pickDict,i=e.values,r=function(t){i.filter((e=>e.length===t)).forEach((t=>e.del(t.slice().sort())))};(!t||1&t)&&r(2),(!t||2&t)&&r(3),(!t||4&t)&&r(4),this.measureBuild()}removeMeasurement(t){this.pickDict.del(t.slice().sort()),this.measureBuild()}addMeasurement(t){if(t.length<2||t.length>4)return;const e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}}Ue.add("structure",Tl),Ue.add("structureview",Tl);class Bl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.surface=e}get type(){return"surface"}addRepresentation(t,e={}){return this._addRepresentation(t,this.surface,e)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",Bl);class Dl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.volume=e}get type(){return"volume"}addRepresentation(t,e={}){return this._addRepresentation(t,this.volume,e)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",Dl);class $l extends hl{addRepresentation(t,e){return this.forEach((i=>i.addRepresentation(t,e)))}autoView(t){return this.forEach((e=>e.autoView(t)))}}function Ol(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}const Rl=new e,El={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Fl{constructor(t,e={}){this.signals={parametersChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],fullscreenChanged:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],componentAdded:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],componentRemoved:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],clicked:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"],hovered:new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]},this.tasks=new ui,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Ji(t),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new sr(this.viewer.renderer.domElement),this.viewerControls=new kr(this),this.trackballControls=new gr(this),this.pickingControls=new xr(this),this.animationControls=new Lr(this),this.mouseControls=new Jo(this),this.keyControls=new ia(this),this.pickingBehavior=new ra(this),this.mouseBehavior=new sa(this),this.animationBehavior=new na(this),this.keyBehavior=new aa(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=nt(e,El),this.setParameters(this.parameters),this.viewer.animate())}setParameters(t={}){ot(this.parameters,t);const e=t,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==e.quality&&this.setQuality(i.quality),void 0!==e.impostor&&this.setImpostor(i.impostor),void 0!==e.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==e.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==e.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(t){console.log("STAGE LOG",t),this.logList.push(t)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Tl){let e,i,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const n=s.biomolDict.BU1;e=n.getAtomCount(s),i=n.getResidueCount(s),r=n.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=s.getModelProxy(0).atomCount,i=s.getModelProxy(0).residueCount,r=1;let n=e;Se&&(n*=4);const o=s.atomStore.count/s.residueStore.count<2;o&&(n*=10);let a="chainname",c="RdYlBu",l=!1;if(1===s.getChainnameCount(new pe("polymer and /0"))&&(a="residueindex",c="Spectral",l=!0),De&&console.log(n,e,r,o),i/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&n>15e3||n>7e5){let e=Math.min(2,Math.max(.1,6e3/(n/r)));o&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:a,colorScale:c,colorReverse:l,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else n>25e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,lineOnly:!0}):n>1e5?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,quality:"low",disableImpostor:!0,radiusScale:2}):n>8e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:.7,aspectRatio:5,quality:"auto"}),n<5e4&&t.addRepresentation("base",{colorScheme:a,colorScale:c,colorReverse:l,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Bl||t instanceof Dl)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(t,e={}){const i=Object.assign({},this.defaultFileParams,e),r=ri(t).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=st(i.ext,ri(t).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):ni(t,i),n.then((t=>{this.log(`loaded '${r}'`);const e=this.addComponentFromObject(t,i);return i.defaultRepresentation&&this.defaultFileRepresentation(e),this.tasks.decrement(),e}),(t=>{this.tasks.decrement();const e=`error loading file: '${t}'`;throw this.log(e),e}))}loadScript(t){const e=ri(t).name;return this.log(`loading script '${e}'`),ni(t).then((t=>{this.tasks.increment(),this.log(`running script '${e}'`),t.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${e}'`)})),this.log(`called script '${e}'`)}),(t=>{this.tasks.decrement();const i=`errored script '${e}' "${t}"`;throw this.log(i),i}))}addComponent(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):Me.warn("Stage.addComponent: no component given")}addComponentFromObject(t,e={}){const i=Ue.get(t.type);if(i){const r=new i(this,t,e);return this.addComponent(r),r}Me.warn("no component for object type",t.type)}removeComponent(t){const e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))}removeAllComponents(){this.compList.slice().forEach((t=>this.removeComponent(t)))}handleResize(){this.viewer.handleResize()}setSize(t,e){const i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())}toggleFullscreen(t){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Me.log("fullscreen mode (currently) not possible");const e=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&e.lastFullscreenElement){const t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth||"",t.style.height=t.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}t=t||this.viewer.container,this.lastFullscreenElement=t,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width||"",t.dataset.normalHeight=t.style.height||"",t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){e.handleResize()}),100))}setSpin(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const t=this.parameters;if("scene"!==t.clipMode)return 0;let e=t.clipNear;return"absolute"===t.clipScale&&(e=this.viewer.absoluteToRelative(e)),2*e}setFocus(t){if("scene"!==this.parameters.clipMode)return;let e,i,r,s;"relative"===this.parameters.clipScale?(e=Dt(t/2,0,49.9),i=100-e,r=50,s=function(t){return Dt(t,0,100)}(2*i-50)):(e=this.viewer.relativeToAbsolute(t/2),i=e,r=0,s=2*i),this.setParameters({clipNear:e,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(t){const e=t.getSize(Rl),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z);let s=i+Math.sqrt(r);const n=kt(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(t).then((t=>{this.tasks.decrement(),e(t)})).catch((t=>{this.tasks.decrement(),i(t)}))}))}))}setImpostor(t){this.parameters.impostor=t;const e=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!e.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!t,i.build(r)}))}setQuality(t){this.parameters.quality=t;const e=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!e.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=t)}s.quality=t,r.build(s)}))}eachComponent(t,e){this.compList.slice().forEach((i=>{void 0!==e&&e!==i.type||t(i)}))}eachRepresentation(t,e){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==e&&e!==r.getType()||t(r,i)}))}))}getComponentsByName(t){const e=[];return this.eachComponent((i=>{(void 0===t||Ol(t,i))&&e.push(i)})),new $l(e)}getComponentsByObject(t){const e=[];return this.eachComponent((i=>{i.object===t&&e.push(i)})),new $l(e)}getRepresentationsByName(t){const e=[];return this.eachRepresentation(((i,r)=>{(void 0===t||Ol(t,i))&&e.push(i)})),new dl(e)}measureClear(){this.eachComponent((t=>t.measureClear()),"structure")}measureUpdate(){this.eachComponent((t=>t.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}}class Ll extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.shape=e}get type(){return"shape"}addRepresentation(t,e={}){return this._addRepresentation(t,this.shape,e)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Nl(t,e,i,r){var s,n=arguments.length,o=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,i,o):s(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o}Ue.add("shape",Ll);class zl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),this.scalePerModel={},t.structure.eachModel((t=>{this.parameters.domain=[t.atomOffset,t.atomEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.index)}}Nl([Nt],zl.prototype,"atomColor",null),Fe.add("atomindex",zl);class Vl extends zt{constructor(t){if(super(t),t.scale||(this.parameters.scale="OrRd"),!t.domain){let e,i=1/0,r=-1/0;t.sele&&(e=new pe(t.sele)),t.structure.eachAtom((function(t){const e=t.bfactor;i=Math.min(i,e),r=Math.max(r,e)}),e),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(t){return this.bfactorScale(t.bfactor)}}Nl([Nt],Vl.prototype,"atomColor",null),Fe.add("bfactor",Vl);class Gl extends zt{constructor(t){super(t),this.chainidDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainidDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])}}Nl([Nt],Gl.prototype,"atomColor",null),Fe.add("chainid",Gl);class Ul extends zt{constructor(t){super(t),this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{this.parameters.domain=[t.chainOffset,t.chainEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.chainIndex)}}Nl([Nt],Ul.prototype,"atomColor",null),Fe.add("chainindex",Ul);class jl extends zt{constructor(t){super(t),this.chainnameDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainnameDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])}}Nl([Nt],jl.prototype,"atomColor",null),Fe.add("chainname",jl);class Hl extends zt{constructor(t){super(t),this.rsrzDict={},this.rsccDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const e=t.structure.validation;e&&(this.rsrzDict=e.rsrzDict,this.rsccDict=e.rsccDict)}atomColor(t){let e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;const i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192}}Nl([Nt],Hl.prototype,"atomColor",null),Fe.add("densityfit",Hl);const Wl={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class ql extends zt{constructor(t){super(t),this.delta=new e,this.hCharges=[],t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(t.structure.atomCount);const i=[];t.structure.eachAtom((t=>{var r;if(this.charges[t.index]=(null!==(r=t).partialCharge?r.partialCharge:r.isProtein()&&(Wl[r.resname]&&Wl[r.resname][r.atomname]||Wl.backbone[r.atomname])||0)*t.occupancy,"N"===t.atomname){if(t.bondCount>=3)return;if(t.bondToElementCount(1))return;const r=function(t,i=new e){let r=!1,s=!1,n=!1;return i.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom((function(t){if(!r)return"H"===t.atomname?(i.set(t.x,t.y,t.z),void(r=!0)):void(s||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,i.sub(t)):(i.sub(t),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(t),i):void 0}(t);void 0!==r&&(i.push(r),this.hCharges.push(.25*t.occupancy))}}));const r=t.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(t){const e=t.length,i=new Float32Array(e),r=new Float32Array(e),s=new Float32Array(e);for(let e=0;e{const s=e[t];0!==s&&(r+=s/i)})),this.hHash.eachWithin(t.x,t.y,t.z,12,((t,e)=>{const s=i[t];0!==s&&(r+=s/e)})),this.scale(332*r)}}Nl([Nt],ql.prototype,"positionColor",null),Fe.add("electrostatic",ql);const Xl={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Yl extends zt{constructor(t){t.value=st(t.value,Xl.C),super(t)}atomColor(t){const e=t.element;return"C"===e?this.parameters.value:Xl[e]||16777215}}Nl([Nt],Yl.prototype,"atomColor",null),Fe.add("element",Yl);class Kl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="Spectral"),t.domain||(this.parameters.domain=[0,t.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(t){return this.entityindexScale(t.entityIndex)}}Nl([Nt],Kl.prototype,"atomColor",null),Fe.add("entityindex",Kl);class Zl extends zt{atomColor(t){const e=t.entity;switch(e?e.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Nl([Nt],Zl.prototype,"atomColor",null),Fe.add("entitytype",Zl);class Ql extends zt{constructor(t){super(t),this.geoAtomDict={},this.geoDict={};const e=t.structure.validation;e&&(this.geoAtomDict=e.geoAtomDict,this.geoDict=e.geoDict)}atomColor(t){let e,i=t.resno+"";t.inscode&&(i+="^"+t.inscode),t.chainname&&(i+=":"+t.chainname),i+="/"+t.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[t.atomname]||0;s=i,e=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else e=this.geoDict[i]||0;var s;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192}}Nl([Nt],Ql.prototype,"atomColor",null),Fe.add("geoquality",Ql);class Jl extends zt{constructor(t){super(t),this.resHF={},t.scale||(this.parameters.scale="RdYlGn");for(const t in Js)this.resHF[t]=Js[t][0];if(this.defaultResidueHydrophobicity=tn[0],!t.domain){let t=1/0,e=-1/0;for(const i in this.resHF){const r=this.resHF[i];t=Math.min(t,r),e=Math.max(e,r)}this.parameters.domain=[t,0,e]}this.hfScale=this.getScale()}atomColor(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)}}Nl([Nt],Jl.prototype,"atomColor",null),Fe.add("hydrophobicity",Jl);class th extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow"),t.domain||(this.parameters.domain=[0,t.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(t){return this.modelindexScale(t.modelIndex)}}Nl([Nt],th.prototype,"atomColor",null),Fe.add("modelindex",th);class eh extends zt{atomColor(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Nl([Nt],eh.prototype,"atomColor",null),Fe.add("moleculetype",eh);class ih extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="PuBu"),t.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(t){return this.occupancyScale(t.occupancy)}}Nl([Nt],ih.prototype,"atomColor",null),Fe.add("occupancy",ih);class rh extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(t){return this.partialchargeScale(t.partialCharge||0)}}function sh(){return 16777215*Math.random()}Nl([Nt],rh.prototype,"atomColor",null),Fe.add("partialcharge",rh);class nh extends zt{atomColor(){return sh()}volumeColor(){return sh()}positionColor(){return sh()}}Nl([Nt],nh.prototype,"atomColor",null),Nl([Nt],nh.prototype,"volumeColor",null),Nl([Nt],nh.prototype,"positionColor",null),Fe.add("random",nh);class oh extends zt{constructor(t){super(t),this.rciDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const e=t.structure.validation;e&&(this.rciDict=e.rciDict)}atomColor(t){let e=`[${t.resname}]${t.resno}`;t.chainname&&(e+=":"+t.chainname);const i=this.rciDict[e];return void 0!==i?this.rciScale(i):9474192}}Nl([Nt],oh.prototype,"atomColor",null),Fe.add("randomcoilindex",oh);class ah extends zt{constructor(t){super(t),this.scalePerChain={},t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),t.structure.eachChain((t=>{this.parameters.domain=[t.residueOffset,t.residueEnd],this.scalePerChain[t.index]=this.getScale()}))}atomColor(t){return this.scalePerChain[t.chainIndex](t.residueIndex)}}Nl([Nt],ah.prototype,"atomColor",null),Fe.add("residueindex",ah);const ch={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class lh extends zt{atomColor(t){return ch[t.resname]||16711935}}Nl([Nt],lh.prototype,"atomColor",null),Fe.add("resname",lh);const hh=16711808,dh=10485888,uh=6291584,mh=16762880,ph=6324479,fh=16777215,gh=11403518,yh=16580962,bh=10921722;class xh extends zt{constructor(t){super(t),this.residueProxy=t.structure.getResidueProxy()}atomColor(t){const e=t.sstruc,i=this.residueProxy;return"h"===e?hh:"g"===e?dh:"i"===e?uh:"e"===e||"b"===e?mh:"t"===e?ph:(i.index=t.residueIndex,i.isDna()?gh:i.isRna()?yh:i.isSaccharide()?bh:i.isProtein()||"s"===e||"l"===e?fh:8421504)}}Nl([Nt],xh.prototype,"atomColor",null),Fe.add("sstruc",xh);class vh extends zt{constructor(t){var e,i;super(t),t.scale||(this.parameters.scale="rwb"),this.atomData=null===(e=this.parameters.data)||void 0===e?void 0:e.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(t){var e;const i=null===(e=this.atomData)||void 0===e?void 0:e[t.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(t,e){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[t.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Nl([Nt],vh.prototype,"atomColor",null),Nl([Nt],vh.prototype,"bondColor",null),Fe.add("structuredata",vh);class wh extends zt{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Nl([Nt],wh.prototype,"atomColor",null),Nl([Nt],wh.prototype,"bondColor",null),Nl([Nt],wh.prototype,"valueColor",null),Nl([Nt],wh.prototype,"volumeColor",null),Fe.add("uniform",wh);class Ah extends zt{constructor(t){super(t),this.valueScale=this.getScale()}volumeColor(t){return this.valueScale(this.parameters.volume.data[t])}}Nl([Nt],Ah.prototype,"volumeColor",null),Fe.add("value",Ah);class _h extends zt{constructor(t){super(t),this.vec=new e,this.valueScale=this.getScale()}positionColor(t){const e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;const i=this.vec,r=e.data,s=e.nx,n=e.ny,o=s*n;i.copy(t),i.applyMatrix4(e.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,d=h+1,u=h+s,m=h+o,p=u+1,f=m+1,g=u+o,y=g+1,b=r[h],x=r[d],v=r[u],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=$t(b,x,P),T=$t(w,_,P),B=$t(v,A,P),D=$t(S,C,P),$=$t(M,B,I),O=$t(T,D,I),R=$t($,O,k);return this.valueScale(R)}}Nl([Nt],_h.prototype,"positionColor",null),Fe.add("volume",_h);class Sh extends zr{constructor(t,e,i){const r=i||{};if(super(t,e,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:pa.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new pe(r.sele),this.dataList=[],this.structure=t,this.structureView=this.structure.getView(this.selection),t.biomolDict){const e={default:"default","":t.unitcell?"AU":"FULL"};Object.keys(t.biomolDict).forEach((function(t){e[t]=t})),this.parameters.assembly={type:"select",options:e,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"element"),this.setRadius(e.radius,e),this.radiusType=st(e.radiusType,"vdw"),this.radiusData=st(e.radiusData,{}),this.radiusSize=st(e.radiusSize,1),this.radiusScale=st(e.radiusScale,1),this.assembly=st(e.assembly,"default"),this.defaultAssembly=st(e.defaultAssembly,""),"auto"===e.quality&&(e.quality=this.getQuality()),super.init(e),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(t,e){const i=Object.keys(ma);return"string"==typeof t&&i.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this}getAssembly(){const t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]}getQuality(){let t;const e=this.structureView,i=this.getAssembly();t=i?i.getAtomCount(e):e.atomCount,Se&&(t*=4);return e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const t=this.getAssembly();if(t)t.partList.forEach(((t,e)=>{const i=t.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),this.dataList.push(r))}));else{const t=this.createData(this.structureView,0);t&&(t.sview=this.structureView,this.dataList.push(t))}}update(t){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((e=>{e.bufferList.length>0&&this.updateData(t,e)}),this):Object.assign(this.lazyProps.what,t)}updateData(t,e){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getBondParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getAtomRadius(t){if(this.structureView.atomSet.isSet(t.index)){return new pa(this.getRadiusParams()).atomRadius(t)}return 0}setSelection(t,e){return this.selection.setString(t,e),this}setParameters(t,e={},i=!1){const r=t||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(e.radius=!0,Ie&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,e,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(t){const e=this.viewer,i=this.bufferList;this.dataList.forEach((function(t){t.bufferList.forEach((function(r){i.push(r),e.add(r,t.instanceList)}))})),this.setVisibility(this.visible),t()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Ch extends Sh{constructor(t,e,i){super(t,e,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(t){const e=t||{};this.labelVisible=st(e.labelVisible,!0),this.labelSize=st(e.labelSize,2),this.labelColor=st(e.labelColor,16777215),this.labelFontFamily=st(e.labelFontFamily,"sans-serif"),this.labelFontStyle=st(e.labelFontstyle,"normal"),this.labelFontWeight=st(e.labelFontWeight,"bold"),this.labelsdf=st(e.labelsdf,"Chrome"===Ae),this.labelXOffset=st(e.labelXOffset,0),this.labelYOffset=st(e.labelYOffset,0),this.labelZOffset=st(e.labelZOffset,.5),this.labelAttachment=st(e.labelAttachment,"bottom-left"),this.labelBorder=st(e.labelBorder,!1),this.labelBorderColor=st(e.labelBorderColor,"lightgrey"),this.labelBorderWidth=st(e.labelBorderWidth,.15),this.labelBackground=st(e.labelBackground,!1),this.labelBackgroundColor=st(e.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=st(e.labelBackgroundMargin,.5),this.labelBackgroundOpacity=st(e.labelBackgroundOpacity,1),this.labelFixedSize=st(e.labelFixedSize,!1),this.lineOpacity=st(e.lineOpacity,1),this.linewidth=st(e.linewidth,2),super.init(e)}update(t){t.position?this.build():super.update(t)}updateData(t,e){const i={};if(t&&!t.labelSize||Object.assign(i,{size:Si(this.n,this.labelSize)}),!t||t.labelColor){const t=new s(this.labelColor);Object.assign(i,{color:Ci(this.n,t.r,t.g,t.b)})}this.textBuffer.setAttributes(i)}setParameters(t,e={},i=!1){return t&&t.labelSize&&(e.labelSize=!0),t&&(t.labelColor||0===t.labelColor)&&(e.labelColor=!0,i=!0),super.setParameters(t,e,i),t&&void 0!==t.opacity&&this.textBuffer.setParameters({opacity:1}),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),e||this.viewer.requestRender(),this}getLabelBufferParams(t={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},t,{opacity:1}))}getAtomRadius(){return 0}}function Ph(t,e){const i=t.getAtomProxy(),r=new pe,s=e.length;if(0===s)return new Float32Array(0);const n=e[0].length,o=t.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return e.forEach((function(e){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Th={};const Bh={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Dh{constructor(t={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=nt(t,Bh);const e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;const i=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),r=this.maxWidth=e.width/4,s=this.canvas=document.createElement("canvas");s.width=r,s.height=i;const n=this.context=this.canvas.getContext("2d");n.font=`${e.style} ${e.variant} ${e.weight} ${e.size}px ${e.font}`,n.fillStyle="black",n.textAlign="left",n.textBaseline="bottom",n.lineJoin="round",this.gridOuter=new Float64Array(i*r),this.gridInner=new Float64Array(i*r),this.f=new Float64Array(Math.max(i,r)),this.d=new Float64Array(Math.max(i,r)),this.z=new Float64Array(Math.max(i,r)+1),this.v=new Int16Array(Math.max(i,r)),this.data=new Uint8Array(e.width*e.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=e.width,this.canvas2.height=e.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let t=32;t<=126;++t)this.map(String.fromCharCode(t));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new __WEBPACK_IMPORTED_MODULE_0_three__["h" /* CanvasTexture */](this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(t){const e=this.parameters;return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>e.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>e.height&&console.warn("canvas to small"),this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[t]}get(t){return this.mapped[t]||this.placeholder}draw(t){const e=this.parameters,i=this.lineHeight,r=e.outline,s=this.context,n=this.maxWidth,o=r,a=i-e.outline,c=s.measureText(t),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(t,o,a);const d=s.getImageData(0,0,l,i),u=d.data;for(let t=0;t= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fh=Object.assign({linewidth:2},zo),Lh=Object.assign({linewidth:{uniform:!0}},Vo);class Nh extends zc{constructor(e,r={}){super(e,r),this.parameterTypes=Lh,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t},projectionMatrixInverse:{value:new i}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Fh}setParameters(t){super.setParameters(t)}}je.add("wideline",Nh);class zh extends Ch{constructor(t,e,i){super(t,e,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(t){const e=t||{};e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),this.atomTriple=st(e.atomTriple,[]),this.arcVisible=st(e.arcVisible,!0),this.sectorVisible=st(e.sectorVisible,!0),this.vectorVisible=st(e.vectorVisible,!0),super.init(e)}createData(t){if(!t.atomCount||!this.atomTriple.length)return;const e=function(t,e){return function(t){const e=[],i=t.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Xh=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Yh=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Kh extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Xh}get mappingIndices(){return Yh}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Zh=Object.assign({openEnded:!1},zo),Qh=Object.assign({openEnded:{updateShader:!0}},Vo);class Jh extends Kh{constructor(t,e={}){super(t,e),this.parameterTypes=Qh,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new i},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Zh}getDefines(t){const e=Kh.prototype.getDefines.call(this,t);return this.parameters.openEnded||(e.CAP=1),e}}Object.assign({disableImpostor:!1},Hh,Zh);const td=class{constructor(t,e={}){return!t.color2&&t.color&&(t.color2=t.color),!Ie||e&&e.disableImpostor?new qh(t,e):new Jh(t,e)}};je.add("cylinder",td);class ed extends Sh{constructor(t,e,i){super(t,e,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(t){const e=t||{};e.radiusSize=st(e.radiusSize,.5),e.colorValue=st(e.colorValue,"lightgreen"),e.useInteriorColor=st(e.useInteriorColor,!0),this.showAxes=st(e.showAxes,!0),this.showBox=st(e.showBox,!1),super.init(e)}getPrincipalAxes(){let t;const e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)}getAxesData(t){const i=this.getPrincipalAxes(),r=new s(this.colorValue);let n=0,o=0;this.showAxes&&(n+=6,o+=3),this.showBox&&(n+=8,o+=12);const a=new Float32Array(3*n),c=Ci(n,r.r,r.g,r.b),l=Si(n,this.radiusSize),h=new Float32Array(3*o),d=new Float32Array(3*o),u=Ci(o,r.r,r.g,r.b),m=Si(o,this.radiusSize);let p=0;if(this.showAxes){const t=function(t,e){t.toArray(a,2*p),e.toArray(a,2*p+3),t.toArray(h,p),e.toArray(d,p),p+=3};t(i.begA,i.endA),t(i.begB,i.endB),t(i.begC,i.endC)}if(this.showBox){const r=new e,{d1a:s,d2a:n,d3a:o,d1b:c,d2b:l,d3b:u}=i.getProjectedScaleForAtoms(t);let m=2*p;const f=function(t,e,s){r.copy(i.center).addScaledVector(i.normVecA,t).addScaledVector(i.normVecB,e).addScaledVector(i.normVecC,s),r.toArray(a,m),m+=3};f(s,n,o),f(s,n,u),f(s,l,u),f(s,l,o),f(c,l,u),f(c,l,o),f(c,n,o),f(c,n,u);let g=p;const y=function(t,e){r.fromArray(a,2*p+3*t).toArray(h,g),r.fromArray(a,2*p+3*e).toArray(d,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const f=new Kn(i);return{vertex:{position:a,color:c,radius:l,picking:f},edge:{position1:h,position2:d,color:u,color2:u,radius:m,picking:f}}}create(){const t=this.getAxesData(this.structureView);this.sphereBuffer=new Gc(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new td(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(t){}updateData(t,e){const i=this.getAxesData(e.sview),r={},s={};t&&!t.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),t&&!t.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),t&&!t.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",ed);class id extends Sh{constructor(t,e,i){super(t,e,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(t){var e=t||{};e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),e.useInteriorColor=st(e.useInteriorColor,!0),this.aspectRatio=st(e.aspectRatio,2),this.lineOnly=st(e.lineOnly,!1),this.cylinderOnly=st(e.cylinderOnly,!1),this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.bondScale=st(e.bondScale,.4),this.linewidth=st(e.linewidth,2),super.init(e)}getAtomRadius(t){return this.aspectRatio*super.getAtomRadius(t)}getAtomParams(t,e){var i=super.getAtomParams(t,e);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(t,e,i){return t.getAtomData(this.getAtomParams(e,i))}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},e),super.getBondParams(t,e)}getBondData(t,e,i){return t.getBondData(this.getBondParams(e,i))}createData(t){const e=[];if(this.lineOnly)this.lineBuffer=new Nh(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{const i=new td(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(i),!this.cylinderOnly){const i=new Gc(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}}updateData(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);const i=this.getBondData(e.sview,t);if(this.lineOnly){const r={};t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),e.bufferList[0].setAttributes(r)}else{var r={};if(t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(e.sview,t),n={};t&&!t.position||Object.assign(n,{position:s.position}),t&&!t.color||Object.assign(n,{color:s.color}),t&&!t.radius||Object.assign(n,{radius:s.radius}),e.bufferList[1].setAttributes(n)}}}setParameters(t={}){let e=!1;const i={};return(t.aspectRatio||t.bondSpacing||t.bondScale)&&(Object.assign(i,{radius:!0}),Ie&&!this.disableImpostor||(e=!0)),super.setParameters(t,i,e),this}}Ne.add("ball+stick",id);class rd extends id{constructor(t,e,i){super(t,e,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(t){var e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.25),super.init(e)}getAtomRadius(t){return t.isTrace()?super.getAtomRadius(t):0}getAtomData(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))}}Ne.add("backbone",rd);class sd extends id{constructor(t,e,i){super(t,e,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(t){let e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.3),super.init(e)}getAtomData(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){let r=this.getBondParams(e,i);return Object.assign(r.colorParams,{rung:!0}),t.getRungBondData(r)}}Ne.add("base",sd);class nd{constructor(t,i){this.m=t,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new e,this.vec2=new e,this.vDir=new e,this.vTan=new e,this.vNorm=new e,this.vBin=new e,this.m2=Math.ceil(this.m/2)}interpolateToArr(t,e,i,r,s,n,o){n[o+0]=Ot(t.x,e.x,i.x,r.x,s,this.tension),n[o+1]=Ot(t.y,e.y,i.y,r.y,s,this.tension),n[o+2]=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolateToVec(t,e,i,r,s,n){n.x=Ot(t.x,e.x,i.x,r.x,s,this.tension),n.y=Ot(t.y,e.y,i.y,r.y,s,this.tension),n.z=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolatePosition(t,e,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(t,e,i,r,c,this.vec1),this.interpolateToVec(t,e,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(t,e,i,r,s){let n,o=e.next(),a=e.next(),c=e.next();const l=e.size,h=l-1;let d=r||0;for(let r=0;r0&&e{if(t.residueCount<4)return;i.push(t);const r=this.getSpline(t),s=this.getAspectRatio(t),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());e.push(new hd(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i0;Qr(A,b,_);const s=Zr(A,v)<0;if(ns(A,v,Zr(v,x)),Qr(S,x,A),ns(A,v,Zr(v,w)),Qr(C,w,A),0===rs(S)||0===rs(C))continue;os(S,S),os(C,C);const D=n[T]=us(S,C);a[T]=(vi*D).toFixed(1)+String.fromCharCode(176),Kr(k,S,v),os(k,k),Zr(k,C)<0&&ds(k,k),Ih(A,_,S,k,D/2),es(A,o,3*T);const $=Math.ceil(D/i),O=$+(e.extendLine?4:2),R=e.extendLine?36:0,E=new Float32Array(3*O),F=new Float32Array(3*O),L=new Float32Array(9*$),N=new Float32Array(R);c[T]=E,l[T]=F,h[T]=L,d[T]=N,e.extendLine&&(r?(Qr(A,f,y),os(A,A),ns(P,A,1/Zr(S,A)),Jr(P,P,y)):(ns(P,x,1/Zr(S,x)),Jr(P,P,g)),s?(Qr(A,b,g),os(A,A),ns(I,A,1/Zr(C,A)),Jr(I,I,g)):(ns(I,w,1/Zr(C,w)),Jr(I,I,y))),Jr(M,_,S);let z=0;e.extendLine?(es(f,E,z),es(P,F,z),z+=3,es(P,E,z),es(M,F,z),z+=3,es(P,N,0),es(M,N,3),es(r?y:g,N,6),es(r?y:g,N,9),es(M,N,12),es(_,N,15)):(es(_,E,z),es(M,F,z),z+=3);const V=function(t,e){const i=9*e;es(_,L,i),es(M,L,i+3),es(M,E,z),Ih(M,_,S,k,t),es(M,L,i+6),es(M,F,z),z+=3};let G=0;for(let t=i;t{const e=pd(i,t);Object.assign(t,e)})),e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),super.init(e)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(t){if(!t.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((e=>e.atomPositions=Ph(t,[e.atomQuad])));const e=this.scaleBinToSectorArea?function(t){return Math.sqrt(t)}:function(t){return t};function i(t){const e=t.map((t=>t.length)),i=new Float32Array($i(e));let r=0;for(let e=0;et.startPoints))),position2:i(t.map((t=>t.endPoints))),color:i(t.map((t=>t.startColors))),color2:i(t.map((t=>t.endColors)))},e)}function s(t,e){return new Uo({position:i(t.map((t=>t.triangles))),color:i(t.map((t=>t.triangleColors)))},e)}this.histogramsData.forEach((t=>t.histogram360Scaled=t.histogram360.map(e)));const n=[];for(let t=0;t=3&&(e=yd(i)),void 0!==e&&n.push(e)}return this.frontHistogramBinBordersBuffer=r(n.map((t=>t.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((t=>t.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((t=>t.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((t=>t.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((t=>t.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((t=>t.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((t=>t.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(t){return super.setParameters(t,{},!1),t&&void 0!==t.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),e||this.viewer.requestRender(),this}}function yd(t){const e=t.atomPositions,i=t.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:fd(t.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.adjacentBondArrowColor,i.length),endColors:fd(t.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.distantBondArrowColor,i.length),endColors:fd(t.distantBondArrowColor,i.length)},d=Yr(),u=Yr(),m=Yr(),p=Yr(),f=Yr(),g=Yr(),y=Yr(),b=Yr(),x=Yr(),v=Yr(),w=Yr(),A=Yr(),_=Yr(),S=Yr(),C=Yr(),P=Yr(),I=[d,u,m,p];for(let t=0;t{let u=e[0],m=e[1];if("number"==typeof u&&Number.isInteger(u)&&"number"==typeof m&&Number.isInteger(m)){if(!d.get(u)||!d.get(m))return void(h+=1);c.index=u,l.index=m}else{n.setString(u),o.setString(m);var p=t.getAtomIndices(n),f=t.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var u=new Os(a.count,!0);return{text:r,position:s,bondSet:u,bondStore:a}}getBondData(t,e,i){const r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new to(r.picking.array,r.picking.structure,i.bondStore)),r}createData(t){if(!t.atomCount||!this.atomPair.length)return;const e=this.atomPair.length,i=new s(this.labelColor),r=this.getDistanceData(t,this.atomPair);this.textBuffer=new Eh({position:r.position,size:Si(e,this.labelSize),color:Ci(e,i.r,i.g,i.b),text:r.text},this.getLabelBufferParams());const n={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(t,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new td(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Nh(ps(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:r.bondSet,bondStore:r.bondStore,position:r.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(t,e){super.updateData(t,e);const i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),s={};t&&!t.color||Object.assign(s,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(t){return super.setParameters(t,{},!1),this.useCylinder||(t&&t.lineOpacity&&this.distanceBuffer.setParameters({opacity:t.lineOpacity}),t&&void 0!==t.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),t&&t.linewidth&&this.distanceBuffer.setParameters({linewidth:t.linewidth})),this}}function xd(t){return 2*(t.position.length/3)*3}Ne.add("distance",bd);const vd=Object.assign({scale:1,color:"grey"},zo);class wd extends Go{constructor(t,e={}){super({position:new Float32Array(xd(t)),color:new Float32Array(xd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new s(this.parameters.color),r=this.geometry.attributes;Ci(xd(t)/3,i.r,i.g,i.b,r.color.array),this.setAttributes(t)}get defaultParameters(){return vd}setAttributes(t={}){const e=this.geometry.attributes;let i,r,s;t.position&&t.vector&&(i=t.position,r=t.vector,s=e.position.array,e.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let t=0;t{if(t.residueCount<4)return;i.push(t);const r=new Ca(t),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();e.push(new Gc({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new wd({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new wd({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(let i=0,r=e.polymerList.length;i radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Sd=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Cd=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Pd extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Sd}get mappingIndices(){return Cd}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const Id=Object.assign({shrink:.14},zo),kd=Object.assign({shrink:{uniform:!0}},Vo);class Md extends Pd{constructor(t,e={}){super(t,e),this.parameterTypes=kd,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new i},modelViewProjectionMatrixInverse:{value:new i},modelViewMatrixInverseTranspose:{value:new i},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Id}}Object.assign({disableImpostor:!1},Hh,Id);const Td=class{constructor(t,e={}){return!Ie||e&&e.disableImpostor?(t.radius=function(t,e){const i=t.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(t)))))}else if("residue"===this.labelGrouping){e&&!e.position||(c=[]),e&&!e.color||(h=[]),e&&!e.radius||(l=[]),e&&!e.text||(a=[]),i.colorParams&&(i.colorParams.structure=t.getStructure());const d=Fe.getScheme(i.colorParams),u=new pa(i.radiusParams),m=t.getAtomProxy();let p=0;t.eachResidue((t=>{const i=3*p;t.isProtein()||t.isNucleic()?(m.index=t.traceAtomIndex,e&&!e.position||m.positionToArray(c,i)):(m.index=t.atomOffset,e&&!e.position||t.positionToArray(c,i)),e&&!e.color||d.atomColorToArray(m,h,i),e&&!e.radius||(l[p]=u.atomRadius(m)),e&&!e.text||a.push(r.atomLabel(m)),++p})),e&&!e.position||(s=new Float32Array(c)),e&&!e.color||(o=new Float32Array(h)),e&&!e.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(t){return{bufferList:[new Eh(this.getTextData(t,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(t,e){e.bufferList[0].setAttributes(this.getTextData(e.sview,t))}getAtomRadius(){return 0}}function Od(t){const e=t.getAtomSet(),i=t.getBondSet(),r=t.getBondProxy();return i.forEach((function(t){r.index=t,e.clear(r.atomIndex1),e.clear(r.atomIndex2)})),e}Ne.add("label",$d);class Rd extends Sh{constructor(t,e,i){super(t,e,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.linewidth=st(e.linewidth,2),this.lines=st(e.lines,!0),this.crosses=st(e.crosses,"lone"),this.crossSize=st(e.crossSize,.4),super.init(e)}getAtomRadius(t){return.1}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},e),super.getBondParams(t,e)}_crossData(t,e){if(t&&!t.position&&!t.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Od(e)});const r=e.getAtomData(this.getAtomParams(t,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),d=new Float32Array(0),u=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);t&&!t.position||(h=s.position1=new Float32Array(l),d=s.position2=new Float32Array(l),p=this.crossSize/2),t&&!t.color||(u=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),t&&!t.picking||(f=new Float32Array(3*r.picking.array.length));for(let e=0;el?u[f]=-1:(c=Math.sqrt(l-a),u[f]=Math.floor(c)),++f;p[g]=d,m[g]=u}}function k(i){var r,s,n,a,d,f,b,v,w,A,S,C,P,I,k,M,T,B,D=3*i,$=i;r=Math.floor(.5+o*(t[D]+u[0])),s=Math.floor(.5+o*(t[D+1]+u[1])),n=Math.floor(.5+o*(t[D+2]+u[2]));var O,R=e[$],E=m[R],F=0,L=l*h,N=p[R];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==D&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(t[V]+u[0])))*a+(d=s+v-Math.floor(.5+o*(t[V+1]+u[1])))*d+(f=n+w-Math.floor(.5+o*(t[V+2]+u[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}F++}}function M(e){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*F+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(t[N]+u[0])))*a+(d=Math.floor(.5+o*(t[N+1]+u[1])))*d+(f=Math.floor(.5+o*(t[N+2]+u[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}R++}}function B(){var t,e,i,r;console.time("EDTSurface fastdistancemap");var s,n=Ed(c,l,h,Uint16Array,3),o=l*h,d=f*f,u=0;for(t=0;t0);var A,P=a*a,I=new Uint16Array(3);for(t=0;t=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(t,e,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function D(t,e,i,r){var s,n,o,a,d,u,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,T=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&o-1&&d-1&&aT&&(T=O)}return{neighbourListLength:27*T+1,withinRadii:function(s,n,o,a,d){for(var u=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),T=y;Tu&&(u=h[t]);!function(){const t=$o(c,l,u,p,0);p=t.scaleFactor,y=t.dim,b=t.matrix,$=Math.max(5,2+Math.floor(m*p)),x=Si(y[0]*y[1]*y[2],-1001),v=new Int32Array(x.length),w=new Float32Array(y[0]),A=new Float32Array(y[1]),_=new Float32Array(y[2]),R(w,c[0],1/p),R(A,c[1],1/p),R(_,c[2],1/p)}(),function(){var t=0,e=2*Math.PI/g;C=new Float32Array(g),S=new Float32Array(g);for(var i=0;i=0;){if(n!==r&&n!==s&&F(n,t,e,i))return k=n,n;n=I[++o]}return k=-1,-1}function F(e,i,r,s){var n=3*e,o=d[e],a=t[n]-i,c=t[n+1]-r,l=t[n+2]-s;return a*a+c*c+l*l0&&u=0;)t{e(this._makeSurface(t.data.sd,i))}),(t=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);e(r)}))}else{const t=this.getSurface(i);e(t)}}dispose(){this.worker&&this.worker.terminate()}}class Vd extends Sh{constructor(t,e,i){super(t,e,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),e.disablePicking=st(e.disablePicking,!0),this.surfaceType=st(e.surfaceType,"ms"),this.probeRadius=st(e.probeRadius,1.4),this.smooth=st(e.smooth,2),this.scaleFactor=st(e.scaleFactor,2),this.cutoff=st(e.cutoff,0),this.contour=st(e.contour,!1),this.background=st(e.background,!1),this.opaqueBack=st(e.opaqueBack,!0),this.filterSele=st(e.filterSele,""),this.colorVolume=st(e.colorVolume,void 0),this.useWorker=st(e.useWorker,!0),super.init(t)}prepareData(t,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===t.selection.string)r(i);else{if(this.filterSele){const s=t.structure.getView(new pe(this.filterSele)),n=s.boundingBox.getSize(new e),o=Math.max(n.x,n.y,n.z),a=t.getAtomSetWithinPoint(s.center,o/2+6);if(0===(t=t.getView(new pe(t.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=t.selection.string,s.molsurf=new zd(t);const n=this.getSurfaceParams(),o=t=>{s.surface=t,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(t){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void t();const e=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((t,i)=>{const s=t.getView(this.structureView);this.prepareData(s,i,(t=>{t===r.partList.length-1&&e()}))})):this.prepareData(this.structureView,0,e)}createData(t,e){const i=this.__infoList[e],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},n=[];if(r.contour){const t=new Xo(s,this.getBufferParams({wireframe:!1}));n.push(t)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(t.getStructure())});const e=new jo(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const t=new qo(e);n.push(t)}else n.push(e)}return{bufferList:n,info:i}}updateData(t,e){const i={};if(t.position||t.radius)return this.__forceNewMolsurf=!0,void this.build();t.color&&(i.color=e.info.surface.getColor(this.getColorParams())),t.index&&(i.index=e.info.surface.getFilteredIndex(this.filterSele,e.sview)),e.bufferList[0].setAttributes(i)}setParameters(t,e={},i){return t&&t.filterSele&&(e.index=!0),t&&void 0!==t.colorVolume&&(e.color=!0),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),super.setParameters(t,e,i),this}getSurfaceParams(t={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},t)}getColorParams(){const t=super.getColorParams();return t.volume=this.colorVolume,t}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Vd);class Gd extends Sh{constructor(t,e,i){super(t,e,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e)}createData(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Wc(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),e.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Gd),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Ud=new Uint16Array([0,1,2,1,3,2]);function jd(t){return 3*(4*(t.position.length/3-1))}class Hd extends Uo{constructor(t,e={}){super({position:new Float32Array(jd(t)),color:new Float32Array(jd(t)),index:xt(jd(t),jd(t)/3),normal:new Float32Array(jd(t)),picking:t.picking},e),this.vertexShader="Ribbon.vert";const i=t.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),t.primitiveId=Pi(i),this.setAttributes(t),this.makeIndex()}setAttributes(t={}){const e=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w;t.position&&(r=t.position,l=i.position.array,i.position.needsUpdate=!0),t.normal&&(s=t.normal,h=i.normal.array,i.normal.needsUpdate=!0),t.size&&(n=t.size,d=i.size.array,i.size.needsUpdate=!0),t.dir&&(o=t.dir,u=i.dir.array,i.dir.needsUpdate=!0),t.color&&(a=t.color,m=i.color.array,i.color.needsUpdate=!0),t.primitiveId&&(c=t.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());e.push(new Hd({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{if(t.residueCount<4||t.isNucleic())return;const s=new Pa(t),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e+=n.size.length,i.push(n),r.push(s)}),t.getSelection());const s={begin:new Float32Array(3*e),end:new Float32Array(3*e),size:new Float32Array(e),color:new Float32Array(3*e),picking:{}};let n=new Float32Array(e),o=0;i.forEach((function(t){s.begin.set(t.begin,3*o),s.end.set(t.end,3*o),s.size.set(t.size,o),s.color.set(t.color,3*o),n.set(t.picking.array,o),o+=t.size.length})),e&&(s.picking=new Yn(n,t.getStructure()));return{bufferList:[new td({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(t,e){if((t=t||{}).position)this.build();else{var i={};if(t.color||t.radius){var r=0;e.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t.color&&e.axisData.color.set(s.color,3*r),(t.radius||t.scale)&&e.axisData.size.set(s.size,r),r+=s.size.length})),t.color&&Object.assign(i,{color:e.axisData.color,color2:e.axisData.color}),(t.radius||t.scale)&&Object.assign(i,{radius:e.axisData.size})}e.bufferList[0].setAttributes(i)}}}Ne.add("rocket",qd);class Xd extends dd{constructor(t,e,i){super(t,e,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(t){var e=t||{};e.aspectRatio=1,e.tension=st(e.tension,.5),e.radiusScale=st(e.radiusScale,5),e.smoothSheet=!1,this.smooth=st(e.smooth,2),super.init(e)}getSpline(t){var e=new Ca(t);return new od(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))}}Ne.add("rope",Xd);class Yd extends Sh{constructor(t,e,i){super(t,e,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(t){var e=t||{};e.useInteriorColor=st(e.useInteriorColor,!0),super.init(e)}createData(t){return{bufferList:[new Gc(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r)}}function Kd(t){return 3*(t.position.length/3-1)*2}Ne.add("spacefill",Yd);class Zd extends Go{constructor(t,e={}){super({position:new Float32Array(Kd(t)),color:new Float32Array(Kd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(t)}setAttributes(t){let e,i,r,s;const n=this.geometry.attributes;if(t.position&&(e=t.position,r=n.position.array,n.position.needsUpdate=!0),t.color&&(i=t.color,s=n.color.array,n.color.needsUpdate=!0),!e&&!i)return void Me.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let t=0;t{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());e.push(new Zd(Object.assign({},s,n),this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox)}))}}const lu=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},zo);class hu{constructor(t,e={}){this.group=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.wireframeGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.pickingGroup=new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */],this.visible=!0,this.parameters=nt(e,this.defaultParameters),this.splitPosition=new Float32Array(t.position1.length),this.cylinderRadius=new Float32Array(t.radius.length);const r=this.makeAttributes(t),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new td(r.cylinder,s),this.coneBuffer=new au(r.cone,s),this.geometry=new cu([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=st(e.matrix,new i),this.picking=t.picking}get defaultParameters(){return lu}set matrix(t){Go.prototype.setMatrix.call(this,t)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(t={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(t.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){De&&Me.log(this[this.__objName])}}class Nu extends Lu{constructor(t,e){var i=e||{};super(t,i),this.firstModelOnly=st(i.firstModelOnly,!1),this.asTrajectory=st(i.asTrajectory,!1),this.cAlphaOnly=st(i.cAlphaOnly,!1),this.structure=new Cc(this.name,this.path),this.structureBuilder=new za(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class zu{constructor(t,e,i="",r,s=[]){this.structure=t,this.index=e,this.description=i,this.entityType=function(t){switch(t=t.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){t.chainStore.entityIndex[i]=e}))}get type(){return function(t){switch(t){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(t){const e=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){e.index=i,t(e)}))}}const Vu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Gu{constructor(t=Vu){this.cartToFrac=new i,this.fracToCart=new i,this.a=t.a,this.b=t.b,this.c=t.c,this.alpha=t.alpha,this.beta=t.beta,this.gamma=t.gamma,this.spacegroup=t.spacegroup;const e=kt(this.alpha),r=kt(this.beta),s=kt(this.gamma),n=Math.cos(e),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===t.cartToFrac){const t=this.a*this.b*l/this.volume,e=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*e,1/t,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(t.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(t){const i=new Float32Array(24);if(t.unitcell){const r=t.unitcell,s=t.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new e;let o=0;const a=function(t,e,a){n.set(t,e,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(t){return function(t,i=new e){const r=t.length;for(let e=0;e0)continue;let e,i,r,s,a,g=0;if(n){if(s=S.split(Wu),g=10===s.length?1:0,D=s[2],p&&"CA"!==D)continue;e=parseFloat(s[6-g]),i=parseFloat(s[7-g]),r=parseFloat(s[8-g])}else{if(D=S.substr(12,4).trim(),p&&"CA"!==D)continue;e=parseFloat(S.substr(30,8)),i=parseFloat(S.substr(38,8)),r=parseFloat(S.substr(46,8))}if(m){const t=3*b;if(y[t+0]=e,y[t+1]=i,y[t+2]=r,b+=1,x)continue}n?(P=parseInt(s[1]),a="",$="H"===S[0],I=g?"":s[4],k=parseInt(s[5-g]),B="",M=s[3],R="",T=1):(P=parseInt(S.substr(6,5),h),l&&99999===P&&(h=16),$="H"===S[0],I=S[21].trim(),k=parseInt(S.substr(22,4),d),l&&9999===k&&(d=16),B=S[26].trim(),M=S.substr(17,4).trim()||"MOL",O=parseFloat(S.substr(60,6)),R=S[16].trim(),T=parseFloat(S.substr(54,6)),t||(o?(a=S.substr(76,3).trim(),a in pn&&(a=pn[a])):(a=S.substr(76,2).trim(),I||(I=S.substr(72,4).trim())),E=parseInt((S.substr(79,1)+S.substr(78,1)).trim()))),dt.growIfFull(),dt.atomTypeId[pt]=ht.add(D,a),dt.x[pt]=e,dt.y[pt]=i,dt.z[pt]=r,dt.serial[pt]=P,dt.altloc[pt]=R.charCodeAt(0),dt.occupancy[pt]=isNaN(T)?0:T,n?(dt.partialCharge[pt]=parseFloat(s[9-g]),dt.radius[pt]=parseFloat(s[10-g])):(dt.bfactor[pt]=isNaN(O)?0:O,o&&(dt.partialCharge[pt]=parseFloat(S.substr(70,6))),isFinite(E)&&(dt.formalCharge||dt.addField("formalCharge",1,"int8"),dt.formalCharge[pt]=E));const v=qu(k,I,B);!$||K[v]||ju.includes(M)?tt||et===I||(Q+=1,J=Q.toString()):et===I&&rt===M&&(cn.includes(M)||it===k&&st===B)||(Q+=1,J=Q.toString(),it=k,rt=M,st=B),c.addAtom(ft,I,J,M,k,$,void 0,B),U[P]=pt,pt+=1,tt=!1,et=I}else if("CONECT"===C){const t=U[parseInt(S.substr(6,5))],e=[11,16,21,26],i={};if(void 0===t)continue;for(let r=0;r<4;++r){let s=parseInt(S.substr(e[r],5));if(!Number.isNaN(s)&&(s=U[s],void 0!==s))if(t0)continue;const s=e[l].replace(Zu,"");if(k&&"CA"!==s)continue;const T=parseFloat(e[x]),$=parseFloat(e[v]),O=parseFloat(e[w]);if(I){const e=3*r;if(t[e+0]=T,t[e+1]=$,t[e+2]=O,r+=1,X>0)continue}const R=e[h],E=parseInt(e[-1!==a?a:c]);let F=e[b];F="?"===F?"":F;const L=e[o],N=e[d],z="H"===e[p][0],V=e[g],Y=parseFloat(e[A]),K=parseFloat(e[_]);let Z=e[m];if(Z="."===Z?"":Z,H.growIfFull(),H.atomTypeId[q]=j.add(s,V),H.x[q]=T,H.y[q]=$,H.z[q]=O,H.serial[q]=parseInt(e[f]),H.bfactor[q]=isNaN(Y)?0:Y,H.occupancy[q]=isNaN(K)?0:K,H.altloc[q]=Z.charCodeAt(0),C.addAtom(X,L,N,R,E,z,void 0,F),De){const t=B[N];void 0!==t&&t!==L&&De&&Me.warn(t,L)}B[N]=L;const Q=e[u];D[Q]||(D[Q]=new Set),D[Q].add(S.chainStore.count-1),q+=1}else{const t=n.match(Ku),e=t.length;N===L.length&&(N=0);for(let i=0;ic*c)return o.growIfFull(),o.atomTypeId[f]=o.atomTypeId[t],o.x[f]=u.x,o.y[f]=u.y,o.z[f]=u.z,o.occupancy[f]=o.occupancy[t],o.serial[f]=f,o.altloc[f]="A".charCodeAt(0),s.addAtom(0,"","","HET",1,!0),void(f+=1)}}}))}}(T,S,C),C.finalize(),S.finalizeAtoms(),Wa(S),S.finalizeBonds();else{var Y=function(t,e,i){var r,s,n,o,a=[],c=[],l=t.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(em(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(t){Object.keys(h).forEach((function(e){var r=new i;r.multiplyMatrices(l[t],h[e]),s[t+"x"+e]=r}))}))}else s=c(o);var d=[];for(var u in s)d.push(s[u]);var m=t;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[e].split(","),f=0,g=p.length;fA){var _=w;w=A,A=_;var S=p;p=x,x=S}if(0!==w&&0!==A)for(var C=0;Cb)continue}d=I.substr(5,5).trim(),u=parseInt(I.substr(0,5)),m=parseInt(I.substr(15,5)),v.growIfFull(),v.atomTypeId[w]=x.add(h),v.x[w]=T,v.y[w]=B,v.z[w]=D,v.serial[w]=m,r.addAtom(A,"","",d,u,!1,"l"),w+=1}}}(0,i.length,i)})),r.finalize(),i.finalizeAtoms(),Ha(i),Wa(i),i.finalizeBonds(),Ga(i),De&&Me.timeEnd("GroParser._parse "+this.name)}});var om=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function am(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function cm(t){return am(DataView,t)}function lm(t){return am(Int8Array,t)}function hm(t){return am(Int32Array,t,4)}function dm(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,s=0;rn&&++a;e=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(o.biomolDict[t]=e)}const O=a.unitCell;O&&Array.isArray(O)&&O[0]?o.unitcell=new Gu({a:O[0],b:O[1],c:O[2],alpha:O[3],beta:O[4],gamma:O[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,Ka(o,!0),Ya(o,!0),o.finalizeAtoms(),o.finalizeBonds(),Za(o),De&&Me.timeEnd("MmtfParser._parse "+this.name)}});const _m=/\s+/,Sm={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Nu{get type(){return"mol2"}_parse(){De&&Me.time("Mol2Parser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let n,o,a=!1;const c=t.atomMap,l=t.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");let h=0,d=0,u=0,m=-1,p=0,f=0;const g=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(b){!function(b,x,v){for(let w=b;wMOLECULE"===b?(f=1,d=0,++m):"@ATOM"===b?(f=2,u=l.count,r&&(o=0,n=new Float32Array(3*p),s.push(n),m>0&&(a=!0))):f="@BOND"===b?3:0;else if(1===f){if(0===d)t.title=b,t.id=b;else if(1===d){const t=b.split(_m);p=parseInt(t[0])}++d}else if(2===f){const t=b.split(_m);if(i&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),u=parseFloat(t[4]);if(r){const t=3*o;if(n[t+0]=s,n[t+1]=d,n[t+2]=u,o+=1,a)continue}const p=t[0],f=t[1],g=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;l.growIfFull(),l.atomTypeId[h]=c.add(f,g),l.x[h]=s,l.y[h]=d,l.z[h]=u,l.serial[h]=p,l.partialCharge[h]=v,e.addAtom(m,"","",x,y,!0),h+=1}else if(3===f){if(i&&m>0)continue;if(r&&m>0)continue;const e=b.split(_m);g.index=parseInt(e[1])-1+u,y.index=parseInt(e[2])-1+u;const s=Sm[e[3]];t.bondStore.addBond(g,y,s)}}}(0,b.length,b)})),e.finalize(),t.finalizeAtoms(),Ha(t),Ya(t,!0),Ka(t,!0),t.finalizeBonds(),ec(t),Ga(t),De&&Me.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Xu{get type(){return"pdbqt"}});ze.add("pqr",class extends Xu{get type(){return"pqr"}});const Cm=/> +<(.+)>/;class Pm extends Nu{get type(){return"sdf"}_parse(){De&&Me.time("SdfParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),u=t.getAtomProxy();let m=0,p=0,f=0,g=0;const y=[];let b,x,v,w,A,_,S,C,P,I,k,M,T,B,D=!1,$={};t.extraData.sdf=y;let O=!1,R=!1,E=!1,F=[],L=[];const N=new Map;this.streamer.eachChunkOfLines((function(s){!function(s,z,V){for(let G=s;G-1,O?N.clear():(x=parseInt(s.substr(0,3)),v=parseInt(s.substr(3,3)),w=4,A=w+x,_=A,S=_+v,r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0)));else if(O&&"COUNTS"===F[0])x=parseInt(F[1]),r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?R=!0:"END"===F[0]&&(R=!1):"BOND"===F[1]&&("BEGIN"===F[0]?E=!0:"END"===F[0]&&(E=!1));else if(R||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),I=parseFloat(F[4]),M=F[1],T=parseInt(F[0]),N.set(T,m),k=M+T,F.length>6){let e=F.slice(6).find((t=>0===t.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(s.substr(0,10)),P=parseFloat(s.substr(10,10)),I=parseFloat(s.substr(20,10)),M=s.substr(31,3).trim(),k=M+(m-g+1);if(r){const t=3*a;if(o[t+0]=C,o[t+1]=P,o[t+2]=I,a+=1,c)continue}h.growIfFull(),h.atomTypeId[m]=l.add(k,M),h.x[m]=C,h.y[m]=P,h.z[m]=I,h.serial[m]=O?T:m,h.formalCharge[m]=t,e.addAtom(f,"","","HET",1,!0),m+=1}else if(E||!O&&p>=_&&p0)continue;if(r&&f>0)continue;O?(d.index=N.get(parseInt(F[2])),u.index=N.get(parseInt(F[3])),B=parseInt(F[1])):(d.index=parseInt(s.substr(0,3))-1+g,u.index=parseInt(s.substr(3,3))-1+g,B=parseInt(s.substr(6,3))),t.bondStore.addBond(d,u,B)}else if("M CHG"===s.substr(0,6)){const t=parseInt(s.substr(6,3));for(let e=0,i=10;e"===s.charAt(0)&&(b=s.match(Cm))?(D=b[1],$[D]=[]):!1!==D&&s&&$[D].push(s);++p}}}(0,s.length,s)})),e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),ec(t),De&&Me.timeEnd("SdfParser._parse "+this.name)}_postProcess(){ec(this.structure)}}ze.add("sdf",Pm),ze.add("sd",Pm),ze.add("mol",Pm);function Im(t,e,i){return parseInt(t.substr(e,i).trim())}class km extends Nu{get type(){return"prmtop"}_parse(){De&&Me.time("PrmtopParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],n={},o=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let a,c,l,h,d;o.forEach((t=>{n[t]=0}));let u,m,p,f,g,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let b=t;b0)return void Me.error("dcd format with fixed atoms unsupported, aborting");const p=n.NATOM,f=4*p;for(let i=0,a=n.NSET;i=1&&(i.timeOffset=(n.ISTART-1)*i.deltaTime),De&&Me.timeEnd("DcdParser._parse "+this.name)}});const Fm={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Lm(t){switch(Number(t)){case Fm.BYTE:return"byte";case Fm.CHAR:return"char";case Fm.SHORT:return"short";case Fm.INT:return"int";case Fm.FLOAT:return"float";case Fm.DOUBLE:return"double";default:return"undefined"}}function Nm(t){switch(Number(t)){case Fm.BYTE:case Fm.CHAR:return 1;case Fm.SHORT:return 2;case Fm.INT:case Fm.FLOAT:return 4;case Fm.DOUBLE:return 8;default:return-1}}function zm(t){switch(String(t)){case"byte":return Fm.BYTE;case"char":return Fm.CHAR;case"short":return Fm.SHORT;case"int":return Fm.INT;case"float":return Fm.FLOAT;case"double":return Fm.DOUBLE;default:return-1}}function Vm(t,e){if(1!==t){const i=new Array(t);for(let r=0;r6,"non valid type "+h);const d=t.readUint32();let u=t.readUint32();2===i&&(Om(u>0,"offsets larger than 4GB not supported"),u=t.readUint32()),c[0]===e&&(n+=d),s[r]={name:o,dimensions:c,attributes:l,type:Lm(h),size:d,offset:u,record:c[0]===e}}}return{variables:s,recordStep:n}}(t,r.recordId,e);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function Xm(t){let e;const i=t.readUint32();if(i===Um)return Om(t.readUint32()!==Um,"wrong empty tag for list of attributes"),[];{Om(i!==Wm,"wrong tag for list of attributes");const r=t.readUint32();e=new Array(r);for(let i=0;i6,"non valid type "+s);const n=t.readUint32(),o=Gm(t,s,n);Rm(t),e[i]={name:r,type:Lm(s),value:o}}}return e}class Ym{constructor(t){const e=new hi(t);e.setBigEndian(),Om("CDF"!==e.readChars(3),"should start with CDF");const i=e.readByte();Om(i>2,"unknown version"),this.header=qm(e,i),this.buffer=e}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(t){return-1!==this.header.variables.findIndex((function(e){return e.name===t}))}getDataVariable(t){let e;return e="string"==typeof t?this.header.variables.find((function(e){return e.name===t})):t,Om(void 0===e,"variable not found"),this.buffer.seek(e.offset),e.record?function(t,e,i){const r=zm(e.type),s=e.size?e.size/Nm(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let e=0;e=1&&(e.timeOffset=s[0]),s.length>=2&&(e.deltaTime=s[1]-s[0]),De&&Me.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Km),ze.add("ncdf",Km),ze.add("nc",Km);ze.add("trr",class extends $m{get type(){return"trr"}get isBinary(){return!0}_parse(){De&&Me.time("TrrParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times;let o=0;for(;;){o+=8;const i=e.getInt32(o);o+=4,o+=i;const a=e.getInt32(o+8),c=e.getInt32(o+12),l=e.getInt32(o+16),h=e.getInt32(o+28),d=e.getInt32(o+32),u=e.getInt32(o+36),m=e.getInt32(o+40);o+=52;const p=a/9,f=3*m;if(8===p?n.push(e.getFloat64(o)):n.push(e.getFloat32(o)),o+=2*p,a){const t=new Float32Array(9);if(8===p)for(let i=0;i<9;++i)t[i]=10*e.getFloat64(o),o+=8;else for(let i=0;i<9;++i)t[i]=10*e.getFloat32(o),o+=4;s.push(t)}if(o+=c,o+=l,h){let i;if(8===p){i=new Float32Array(f);for(let t=0;t>8&65280|i>>24&255}i=new Float32Array(t,o,f);for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("TrrParser._parse "+this.name)}});const Zm=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function Qm(t){let e=1,i=0;for(;t>=e&&i<32;)i++,e<<=1;return i}const Jm=new Uint8Array(32);function tp(t,e){let i=1,r=0;Jm[0]=1;for(let r=0;r>=8;for(;0!==s;)Jm[t++]=255&s,s>>=8;i=t}let s=1;for(i--;Jm[i]>=s;)r++,s*=2;return r+8*i}function ep(t,e,i,r){const s=(1<=8;)o=o<<8|e[a++],c|=o>>n<0&&(n>n&(1<8;)ip[a++]=ep(t,e,8,o),r-=8;r>0&&(ip[a++]=ep(t,e,r,o));for(let t=i-1;t>0;t--){let e=0;for(let i=a-1;i>=0;i--){e=e<<8|ip[i];const r=e/s[t]|0;ip[i]=r,e-=r*s[t]}n[t]=e}n[0]=ip[0]|ip[1]<<8|ip[2]<<16|ip[3]<<24}ze.add("xtc",class extends $m{get type(){return"xtc"}get isBinary(){return!0}_parse(){De&&Me.time("XtcParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times,o=new Int32Array(6),a=new Int32Array(3),c=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),d=new Float32Array(3);let u=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let i;const f=e.getInt32(u+4);u+=12;const g=3*f;n.push(e.getFloat32(u)),u+=4;const y=new Float32Array(9);for(let t=0;t<9;++t)y[t]=10*e.getFloat32(u),u+=4;if(s.push(y),f<=9){i=new Float32Array(f);for(let t=0;t16777215?(c[0]=Qm(a[0]),c[1]=Qm(a[1]),c[2]=Qm(a[2]),f=0):f=tp(3,a);let y=e.getInt32(u);u+=4;let b=y-1;b=9>b?9:b;let x=Zm[b]/2|0,v=Zm[y]/2|0;l[0]=l[1]=l[2]=Zm[y];let w=4*Math.ceil(e.getInt32(u)/4);u+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,u);for(h[0]=h[1]=h[2]=0;S0){h[0]=h[1]=h[2]=0;for(let t=0;t<_;t+=3){if(rp(m,C,3,y,l,h,p),S++,h[0]+=d[0]-v,h[1]+=d[1]-v,h[2]+=d[2]-v,0===t){let t=h[0];h[0]=d[0],d[0]=t,t=h[1],h[1]=d[1],d[1]=t,t=h[2],h[2]=d[2],d[2]=t,i[r++]=d[0]*A,i[r++]=d[1]*A,i[r++]=d[2]*A}else d[0]=h[0],d[1]=h[1],d[2]=h[2];i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A}}else i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A;if(y+=t,t<0?(v=x,x=y>9?Zm[y-1]/2|0:0):t>0&&(x=v,v=Zm[y]/2|0),l[0]=l[1]=l[2]=Zm[y],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}u+=w}for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("XtcParser._parse "+this.name)}});class sp extends Lu{constructor(t,e){const i=e||{};super(t,i),this.volume=new Eo(this.name,this.path),this.voxelSize=st(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new i}}const np=/\s+/,op=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,ap=.529177210859;class cp extends sp{get type(){return"cube"}_parse(){De&&Me.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),r={},s=ap*this.voxelSize;function n(t,e){var r=i[t].trim().split(np)[e];return parseFloat(r)}r.atomCount=Math.abs(n(2,0)),r.originX=n(2,1)*ap,r.originY=n(2,2)*ap,r.originZ=n(2,3)*ap,r.NVX=n(3,0),r.NVY=n(4,0),r.NVZ=n(5,0),r.basisX=new e(n(3,1),n(3,2),n(3,3)).multiplyScalar(s),r.basisY=new e(n(4,1),n(4,2),n(4,3)).multiplyScalar(s),r.basisZ=new e(n(5,1),n(5,2),n(5,3)).multiplyScalar(s);const o=new Float32Array(r.NVX*r.NVY*r.NVZ);let a=0,c=0;const l=n(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let s=t;s=r.atomCount+6+l){const e=t.match(op);for(let t=0,i=e.length;t>8&255}e.xStart=n[0],e.yStart=n[1],e.zStart=n[2],e.xExtent=n[3],e.yExtent=n[4],e.zExtent=n[5],e.xRate=n[6],e.yRate=n[7],e.zRate=n[8];const t=1/n[17],s=t*this.voxelSize;e.xlen=n[9]*s,e.ylen=n[10]*s,e.zlen=n[11]*s,e.alpha=n[12]*t,e.beta=n[13]*t,e.gamma=n[14]*t,i=n[15]/100,r=n[16],e.gamma=n[14]*t}t.header=e,De&&Me.log(e,i,r);const c=new Float32Array(e.xExtent*e.yExtent*e.zExtent);let l=512;const h=Math.ceil(e.xExtent/8),d=Math.ceil(e.yExtent/8),u=Math.ceil(e.zExtent/8);for(var m=0;ms){const t=i[r].trim();if(""!==t){const e=t.split(hp);for(let t=0,i=e.length;t=s&&(p-s)%u!=0&&m=0?i-1:i+e/3)},parseNormalIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},addVertex:function(t,e,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(t){var e=this.vertices,i=this.object.geometry.vertices;i.push(e[t+0]),i.push(e[t+1]),i.push(e[t+2])},addNormal:function(t,e,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(t,e,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(t,l),d=this.parseVertexIndex(e,l),u=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,d,u):(c=this.parseVertexIndex(r,l),this.addVertex(h,d,c),this.addVertex(d,u,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),d=s===n?h:this.parseNormalIndex(n,m),u=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,d,u):(c=this.parseNormalIndex(a,m),this.addNormal(h,d,c),this.addNormal(d,u,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,r=t.length;i0?x.setAttribute("normal",new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};ze.add("obj",class extends kp{get type(){return"obj"}getLoader(){return new Mp}});const Tp=function(){this.propertyNameMapping={}};Tp.prototype={constructor:Tp,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r=r.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(r.elements[o].properties,l);this.handleElement(i,r.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e{const s=r.length;for(let n=0;n/g,""),{declaration:e(),root:i()};function e(){if(!s(/^<\?xml\s*/))return;const t={attributes:{}};for(;!n()&&!o("?>");){const e=r();if(!e)return t;t.attributes[e.name]=e.value}return s(/\?>\s*/),t}function i(){const t=s($p);if(!t)return;const e={name:t[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const t=r();if(!t)return e;e.attributes[t.name]=t.value}if(s(/^\s*\/>\s*/))return e;let a;for(s(/\??>\s*/),e.content=function(){const t=s(Op);return t?t[1]:""}();a=i();)e.children.push(a);return s(/^<\/[\w-:.]+>\s*/),e}function r(){const t=s(Rp);var e;if(t)return{name:t[1],value:(e=t[2],e.replace(Dp,""))}}function s(e){const i=t.match(e);if(i)return t=t.slice(i[0].length),i}function n(){return 0===t.length}function o(e){return 0===t.indexOf(e)}}class Fp extends Lu{constructor(t,e){const i=e||{};super(t,i),this.useDomParser=st(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(t){return Ep(t)}__domParser(t){return(new window.DOMParser).parseFromString(t,"text/xml")}_parse(){De&&Me.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),De&&Me.timeEnd("XmlParser._parse "+this.name)}}function Lp(t,e){const i=t.getNamedItem(e);return null!==i?i.value:""}function Np(t,e,i=!1){const r=Lp(t,"icode").trim(),s=Lp(t,"chain").trim(),n=Lp(t,"altcode");let o=Lp(t,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),e&&(o+="."+e),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Lp(t,"model"))-1),o}function zp(t){const e=Lp(t,"chain").trim();let i=`[${Lp(t,"rescode")}]${Lp(t,"resnum")}`;return e&&(i+=`:${e}`),i}function Vp(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function Gp(t,e){return null!==t&&t.value===e}function Up(t,e,i){let r=0;const s=e.getElementsByTagName("clash");for(let e=0,i=s.length;e0&&(r+=1);e.getElementsByTagName("bond-outlier").length>0&&(r+=1);return e.getElementsByTagName("plane-outlier").length>0&&(r+=1),Gp(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Gp(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Gp(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Fp);class jp{constructor(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){De&&Me.time("Validation.fromXml");const e=this.rsrzDict,i=this.rsccDict,r=this.rciDict,s=this.clashDict,n=this.clashArray,o=this.geoDict,a=this.geoAtomDict,c=this.atomDict,l=t.getElementsByTagName("Entry");if(1===l.length){const t=l[0].getElementsByTagName("chemical_shift_list");if(1===t.length){const e=t[0].getElementsByTagName("random_coil_index");for(let t=0,i=e.length;t0&&(o[r]=t)}else{const t=e.getElementsByTagName("clash"),i=e.getElementsByTagName("mog-bond-outlier"),n=e.getElementsByTagName("mog-angle-outlier");if(i.length>0||n.length>0||t.length>0){const e={};a[r]=e;for(let i=0,r=t.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+e[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Fp{constructor(t,e){super(t,e||{}),this.useDomParser=!0,this.validation=new jp(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),De&&Me.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),De&&Me.timeEnd("ValidationParser._parse "+this.name)}});var Xp=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();function Yp(t,e,i,r){var s=Xp,n=r+i;t^=-1;for(var o=r;o>>8^s[255&(t^e[o])];return-1^t}var Kp=30,Zp=12;function Qp(t,e){var i,r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=t.state,r=t.next_in,C=t.input,s=r+(t.avail_in-5),n=t.next_out,P=t.output,o=n-(e-t.avail_out),a=n+(t.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){t.msg="invalid distance too far back",i.mode=Kp;break t}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){t.msg="invalid distance too far back",i.mode=Kp;break t}if(_=0,S=u,0===d){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,t.next_in=r,t.next_out=n,t.avail_in=r=1&&0===T[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(t===rf||1!==w))return-1;for(B[1]=0,b=1;btf||t===nf&&P>ef)return 1;for(;;){p=b-S,o[x]m?(f=D[$+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--T[b]){if(b===w)break;b=e[i+o[x]]}if(b>A&&(I&d)!==h){for(0===S&&(S=A),u+=v,C=1<<(_=b-S);_+Stf||t===nf&&P>ef)return 1;s[h=I&d]=A<<24|_<<16|u-n|0}}return 0!==I&&(s[u+I]=b-S<<24|64<<16|0),a.bits=A,0}var df=1,uf=2,mf=0,pf=-2,ff=1,gf=12,yf=30,bf=852,xf=592;function vf(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function wf(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Af(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=ff,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(bf),e.distcode=e.distdyn=new Int32Array(xf),e.sane=1,e.back=-1,mf):pf}(t)):pf}function _f(t,e){var i,r;return t?(r=new wf,t.state=r,r.window=null,i=function(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?pf:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,Af(t))):pf}(t,e),i!==mf&&(t.state=null),i):pf}var Sf,Cf,Pf=!0;function If(t){if(Pf){var e;for(Sf=new Int32Array(512),Cf=new Int32Array(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(hf(df,t.lens,0,288,Sf,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;hf(uf,t.lens,0,32,Cf,0,t.work,{bits:5}),Pf=!1}t.lencode=Sf,t.lenbits=9,t.distcode=Cf,t.distbits=5}function kf(t,e,i,r){var s,n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(Wp(n.window,e,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Wp(n.window,e,i-r,s,n.wnext),(r-=s)?(Wp(n.window,e,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Yp(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=yf;break}if(8!=(15&l)){t.msg="unknown compression method",i.mode=yf;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){t.msg="invalid window size",i.mode=yf;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Yp(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Yp(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Yp(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>>8&255,i.check=Yp(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Wp(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Yp(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break t;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=gf;break;case 10:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break t;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(If(i),i.mode=20,6===e){l>>>=2,h-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=yf}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,l+=r[n++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=yf;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break t;Wp(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=gf;break;case 17:for(;h<14;){if(0===a)break t;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=yf;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=hf(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid code lengths set",i.mode=yf;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=yf;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=yf;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===yf)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=yf;break}if(i.lenbits=9,S={bits:i.lenbits},_=hf(df,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid literal/lengths set",i.mode=yf;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=hf(uf,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){t.msg="invalid distances set",i.mode=yf;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=n,t.avail_in=a,i.hold=l,i.bits=h,Qp(t,u),o=t.next_out,s=t.output,c=t.avail_out,n=t.next_in,r=t.input,a=t.avail_in,l=i.hold,h=i.bits,i.mode===gf&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=gf;break}if(64&y){t.msg="invalid literal/length code",i.mode=yf;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){t.msg="invalid distance code",i.mode=yf;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=yf;break}i.mode=25;case 25:if(0===c)break t;if(m=u-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=yf;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break t;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break t;a--,l|=r[n++]<=252?6:Of>=248?5:Of>=240?4:Of>=224?3:Of>=192?2:1;function Rf(t){var e,i,r,s,n,o=t.length,a=0;for(s=0;s>>6,e[n++]=128|63&i):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|63&i):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|63&i);return e}function Ef(t,e){var i,r,s,n,o=e||t.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(t,e){if(e<65537&&(t.subarray&&Df||!t.subarray&&Bf))return String.fromCharCode.apply(null,Hp(t,e));for(var i="",r=0;rt.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+$f[t[i]]>e?i:e}$f[254]=$f[254]=1;var Lf=0,Nf={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function zf(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Vf(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Gf=Object.prototype.toString;function Uf(t){if(!(this instanceof Uf))return new Uf(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zf,this.strm.avail_out=0;var i,r,s,n=_f(this.strm,e.windowBits);if(n!==Lf)throw new Error(Nf[n]);this.header=new Vf,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Uf.prototype.push=function(t,e){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,d=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(t){if(!t||!t.state)return pf;var e=t.state;return e.window&&(e.window=null),t.state=null,mf}(this.strm),this.onEnd(i),this.ended=!0,i===Lf):2!==r||(this.onEnd(Lf),c.avail_out=0,!0)},Uf.prototype.onData=function(t){this.chunks.push(t)},Uf.prototype.onEnd=function(t){t===Lf&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,r,s,n,o;for(r=0,e=0,i=t.length;e({path:t,data:e.data})))}getUrl(t){const e=ri(t);return`${this.baseUrl}file/${e.path}${e.query}`}getCountUrl(t){const e=ri(t);return`${this.baseUrl}traj/numframes/${e.path}${e.query}`}getFrameUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/frame/${e}/${i.path}${i.query}`}getFrameParams(t,e){return`atomIndices=${e.join(";")}`}getPathUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/path/${e}/${i.path}${i.query}`}getExt(t){return ri(t).ext}}function ig(t,e){return{type:"integer",max:t,min:e}}function rg(t,e,i){return{type:"number",precision:t,max:e,min:i}}function sg(t,e,i){return{type:"range",step:t,max:e,min:i}}function ng(...t){return{type:"select",options:t.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:e})),{})}}const og={backgroundColor:{type:"color"},quality:ng("auto","low","medium","high"),sampleLevel:sg(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:rg(1,10,0),zoomSpeed:rg(1,10,0),panSpeed:rg(1,10,0),clipNear:sg(1,100,0),clipFar:sg(1,100,0),clipDist:ig(200,0),clipMode:ng("scene","camera"),clipScale:ng("relative","absolute"),fogNear:sg(1,100,0),fogFar:sg(1,100,0),cameraType:ng("perspective","orthographic","stereo"),cameraEyeSep:rg(3,1,.01),cameraFov:sg(1,120,15),lightColor:{type:"color"},lightIntensity:rg(2,10,0),ambientColor:{type:"color"},ambientIntensity:rg(2,10,0),hoverTimeout:ig(1e4,-1),tooltip:{type:"boolean"},mousePreset:ng(...Object.keys(Zo))};const ag="2.2.2"; +//# sourceMappingURL=ngl.esm.js.map +/***/ }), +/* 19 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = values; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__keys_js__ = __webpack_require__(4); +// Retrieve the values of an object's properties. +function values(obj) { + var _keys = Object(__WEBPACK_IMPORTED_MODULE_0__keys_js__["a" /* default */])(obj); + var length = _keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[_keys[i]]; + } + return values; +} +/***/ }), +/* 20 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -/** - * @file shims - * @private - * @author Alexander Rose - */ +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = flatten; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__getLength_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isArray_js__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__isArguments_js__ = __webpack_require__(38); -/// /////////// -// Polyfills -if (typeof window !== 'undefined') { - (function () { - // Console-polyfill. MIT license. - // https://github.com/paulmillr/console-polyfill - // Make it safe to do console.log() always. - - window.console = window.console || {}; - var con = window.console; - var prop, method; - var empty = {}; - var dummy = function () {}; - var properties = 'memory'.split(','); - var methods = ( - 'assert,clear,count,debug,dir,dirxml,error,exception,group,' + - 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' + - 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn' - ).split(','); - - while ((prop = properties.pop())) { if (!con[prop]) { con[prop] = empty; } } - while ((method = methods.pop())) { if (!con[method]) { con[method] = dummy; } } - })(); -} -if (typeof window !== 'undefined' && typeof window.HTMLCanvasElement !== 'undefined' && !window.HTMLCanvasElement.prototype.toBlob) { - // http://code.google.com/p/chromium/issues/detail?id=67587#57 - Object.defineProperty(window.HTMLCanvasElement.prototype, 'toBlob', { - - value: function (callback, type, quality) { - var bin = window.atob(this.toDataURL(type, quality).split(',')[ 1 ]); - var len = bin.length; - var len32 = len >> 2; - var a8 = new Uint8Array(len); - var a32 = new Uint32Array(a8.buffer, 0, len32); - - for (var i = 0, j = 0; i < len32; i++) { - a32[i] = ( - bin.charCodeAt(j++) | - bin.charCodeAt(j++) << 8 | - bin.charCodeAt(j++) << 16 | - bin.charCodeAt(j++) << 24 - ); - } - var tailLength = len & 3; - while (tailLength--) { - a8[ j ] = bin.charCodeAt(j++); +// Internal implementation of a recursive `flatten` function. +function flatten(input, depth, strict, output) { + output = output || []; + if (!depth && depth !== 0) { + depth = Infinity; + } else if (depth <= 0) { + return output.concat(input); + } + var idx = output.length; + for (var i = 0, length = Object(__WEBPACK_IMPORTED_MODULE_0__getLength_js__["a" /* default */])(input); i < length; i++) { + var value = input[i]; + if (Object(__WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__["a" /* default */])(value) && (Object(__WEBPACK_IMPORTED_MODULE_2__isArray_js__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_3__isArguments_js__["a" /* default */])(value))) { + // Flatten current level of array or arguments object. + if (depth > 1) { + flatten(value, depth - 1, strict, output); + idx = output.length; + } else { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; } - - callback(new window.Blob([ a8 ], { 'type': type || 'image/png' })); + } else if (!strict) { + output[idx++] = value; } - - }); + } + return output; } -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt -Math.cbrt = Math.cbrt || function (x) { - var y = Math.pow(Math.abs(x), 1 / 3); - return x < 0 ? -y : y -}; -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign -if (!Math.sign) { - Math.sign = function (x) { - // If x is NaN, the result is NaN. - // If x is -0, the result is -0. - // If x is +0, the result is +0. - // If x is negative and not -0, the result is -1. - // If x is positive and not +0, the result is +1. - x = +x; // convert to a number - if (x === 0 || isNaN(x)) { - return Number(x) - } - return x > 0 ? 1 : -1 - }; -} +/***/ }), +/* 21 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -if (!Number.isInteger) { - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger - Number.isInteger = function isInteger (nVal) { - return typeof nVal === 'number' && isFinite(nVal) && nVal > -9007199254740992 && nVal < 9007199254740992 && Math.floor(nVal) === nVal - }; -} +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = map; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cb_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__keys_js__ = __webpack_require__(4); -if (!Number.isNaN) { - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN - Number.isNaN = function isNaN (value) { - return value !== value // eslint-disable-line no-self-compare - }; -} -if (!Object.assign) { - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign - Object.defineProperty(Object, 'assign', { - enumerable: false, - configurable: true, - writable: true, - value: function (target/*, firstSource */) { - var arguments$1 = arguments; +// Return the results of applying the iteratee to each element. +function map(obj, iteratee, context) { + iteratee = Object(__WEBPACK_IMPORTED_MODULE_0__cb_js__["a" /* default */])(iteratee, context); + var _keys = !Object(__WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__["a" /* default */])(obj) && Object(__WEBPACK_IMPORTED_MODULE_2__keys_js__["a" /* default */])(obj), + length = (_keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; +} - if (target === undefined || target === null) { throw new TypeError('Cannot convert first argument to object') } - var to = Object(target); +/***/ }), +/* 22 */ +/***/ (function(module, exports) { - var hasPendingException = false; - var pendingException; +module.exports = __WEBPACK_EXTERNAL_MODULE_22__; - for (var i = 1; i < arguments.length; i++) { - var nextSource = arguments$1[i]; - if (nextSource === undefined || nextSource === null) { continue } +/***/ }), +/* 23 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var keysArray = Object.keys(Object(nextSource)); - for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { - var nextKey = keysArray[nextIndex]; - try { - var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); - if (desc !== undefined && desc.enumerable) { to[nextKey] = nextSource[nextKey]; } - } catch (e) { - if (!hasPendingException) { - hasPendingException = true; - pendingException = e; - } - } - } +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return hasStringTagBug; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isIE11; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__setup_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__hasObjectTag_js__ = __webpack_require__(121); - if (hasPendingException) { throw pendingException } - } - return to - } - }); -} +// In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. +// In IE 11, the most common among them, this problem also applies to +// `Map`, `WeakMap` and `Set`. +var hasStringTagBug = ( + __WEBPACK_IMPORTED_MODULE_0__setup_js__["s" /* supportsDataView */] && Object(__WEBPACK_IMPORTED_MODULE_1__hasObjectTag_js__["a" /* default */])(new DataView(new ArrayBuffer(8))) + ), + isIE11 = (typeof Map !== 'undefined' && Object(__WEBPACK_IMPORTED_MODULE_1__hasObjectTag_js__["a" /* default */])(new Map)); -if (!String.prototype.startsWith) { - /*! https://mths.be/startswith v0.2.0 by @mathias */ - - (function () { - var defineProperty = (function () { - // IE 8 only supports `Object.defineProperty` on DOM elements - var result; - try { - var object = {}; - var $defineProperty = Object.defineProperty; - result = $defineProperty(object, object, object) && $defineProperty; - } catch (error) {} // eslint-disable-line no-empty - return result - }()); - var toString = {}.toString; - var startsWith = function (search) { - if (this === null) { - throw TypeError() - } - var string = String(this); - if (search && toString.call(search) === '[object RegExp]') { - throw TypeError() - } - var stringLength = string.length; - var searchString = String(search); - var searchLength = searchString.length; - var position = arguments.length > 1 ? arguments[1] : undefined; - // `ToInteger` - var pos = position ? Number(position) : 0; - if (Number.isNaN(pos)) { - pos = 0; - } - var start = Math.min(Math.max(pos, 0), stringLength); - // Avoid the `indexOf` call if no match is possible - if (searchLength + start > stringLength) { - return false - } - var index = -1; - while (++index < searchLength) { - if (string.charCodeAt(start + index) !== searchString.charCodeAt(index)) { - return false - } - } - return true - }; - if (defineProperty) { - defineProperty(String.prototype, 'startsWith', { - 'value': startsWith, - 'configurable': true, - 'writable': true - }); - } else { - // eslint-disable-next-line no-extend-native - String.prototype.startsWith = startsWith; - } - }()); -} -if (!String.prototype.endsWith) { - // eslint-disable-next-line no-extend-native - String.prototype.endsWith = function (searchString, position) { - var subjectString = this.toString(); - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position - }; -} +/***/ }), +/* 24 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -if (!String.prototype.repeat) { - // eslint-disable-next-line no-extend-native - String.prototype.repeat = function (count) { - if (this === null) { - throw new TypeError('can\'t convert ' + this + ' to object') - } - var str = '' + this; - count = +count; - if (Number.isNaN(count)) { - count = 0; - } - if (count < 0) { - throw new RangeError('repeat count must be non-negative') - } - if (count === Infinity) { - throw new RangeError('repeat count must be less than infinity') - } - count = Math.floor(count); - if (str.length === 0 || count === 0) { - return '' - } - // Ensuring count is a 31-bit integer allows us to heavily optimize the - // main part. But anyway, most current (August 2014) browsers can't handle - // strings 1 << 28 chars or longer, so: - if (str.length * count >= 1 << 28) { - throw new RangeError('repeat count must not overflow maximum string size') - } - var rpt = ''; - for (;;) { - if ((count & 1) === 1) { - rpt += str; - } - count >>>= 1; - if (count === 0) { - break - } - str += str; - } - // Could we try: - // return Array(count + 1).join(this); - return rpt - }; -} +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = allKeys; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isObject_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__setup_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__collectNonEnumProps_js__ = __webpack_require__(63); -if (!String.prototype.includes) { - // eslint-disable-next-line no-extend-native - String.prototype.includes = function (search, start) { - if (typeof start !== 'number') { - start = 0; - } - if (start + search.length > this.length) { - return false - } else { - return this.indexOf(search, start) !== -1 - } - }; -} -if (!Array.prototype.includes) { - // eslint-disable-next-line no-extend-native - Array.prototype.includes = function (searchElement /*, fromIndex */) { - if (this == null) { - throw new TypeError('Array.prototype.includes called on null or undefined') - } - var O = Object(this); - var len = parseInt(O.length, 10) || 0; - if (len === 0) { - return false - } - var n = parseInt(arguments[1], 10) || 0; - var k; - if (n >= 0) { - k = n; - } else { - k = len + n; - if (k < 0) { k = 0; } - } - var currentElement; - while (k < len) { - currentElement = O[k]; - if (searchElement === currentElement || - (Number.isNaN(searchElement) && Number.isNaN(currentElement)) - ) { - return true - } - k++; - } - return false - }; +// Retrieve all the enumerable property names of an object. +function allKeys(obj) { + if (!Object(__WEBPACK_IMPORTED_MODULE_0__isObject_js__["a" /* default */])(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + // Ahem, IE < 9. + if (__WEBPACK_IMPORTED_MODULE_1__setup_js__["h" /* hasEnumBug */]) Object(__WEBPACK_IMPORTED_MODULE_2__collectNonEnumProps_js__["a" /* default */])(obj, keys); + return keys; } -// Production steps of ECMA-262, Edition 6, 22.1.2.1 -// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from -if (!Array.from) { - Array.from = (function () { - var toStr = Object.prototype.toString; - var isCallable = function (fn) { - return typeof fn === 'function' || toStr.call(fn) === '[object Function]' - }; - var toInteger = function (value) { - var number = Number(value); - if (isNaN(number)) { return 0 } - if (number === 0 || !isFinite(number)) { return number } - return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)) - }; - var maxSafeInteger = Math.pow(2, 53) - 1; - var toLength = function (value) { - var len = toInteger(value); - return Math.min(Math.max(len, 0), maxSafeInteger) - }; - - // The length property of the from method is 1. - return function from (arrayLike/*, mapFn, thisArg */) { - // 1. Let C be the this value. - var C = this; - // 2. Let items be ToObject(arrayLike). - var items = Object(arrayLike); +/***/ }), +/* 25 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - // 3. ReturnIfAbrupt(items). - if (arrayLike == null) { - throw new TypeError('Array.from requires an array-like object - not null or undefined') - } +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = toPath; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__underscore_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__toPath_js__ = __webpack_require__(71); - // 4. If mapfn is undefined, then let mapping be false. - var mapFn = arguments.length > 1 ? arguments[1] : void undefined; - var T; - if (typeof mapFn !== 'undefined') { - // 5. else - // 5. a If IsCallable(mapfn) is false, throw a TypeError exception. - if (!isCallable(mapFn)) { - throw new TypeError('Array.from: when provided, the second argument must be a function') - } - // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined. - if (arguments.length > 2) { - T = arguments[2]; - } - } - // 10. Let lenValue be Get(items, "length"). - // 11. Let len be ToLength(lenValue). - var len = toLength(items.length); - - // 13. If IsConstructor(C) is true, then - // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len. - // 14. a. Else, Let A be ArrayCreate(len). - var A = isCallable(C) ? Object(new C(len)) : new Array(len); - - // 16. Let k be 0. - var k = 0; - // 17. Repeat, while k < len… (also steps a - h) - var kValue; - while (k < len) { - kValue = items[k]; - if (mapFn) { - A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); - } else { - A[k] = kValue; - } - k += 1; - } - // 18. Let putStatus be Put(A, "length", len, true). - A.length = len; - // 20. Return A. - return A - } - }()); +// Internal wrapper for `_.toPath` to enable minification. +// Similar to `cb` for `_.iteratee`. +function toPath(path) { + return __WEBPACK_IMPORTED_MODULE_0__underscore_js__["a" /* default */].toPath(path); } -if (typeof window !== 'undefined') { - (function () { - // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating - - // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel - // MIT license - - var lastTime = 0; - var vendors = [ 'ms', 'moz', 'webkit', 'o' ]; +/***/ }), +/* 26 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = ( - window[ vendors[ x ] + 'RequestAnimationFrame' ] - ); +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = optimizeCb; +// Internal function that returns an efficient (for current engines) version +// of the passed-in callback, to be repeatedly applied in other Underscore +// functions. +function optimizeCb(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + // The 2-argument case is omitted because we’re not using it. + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; +} - window.cancelAnimationFrame = ( - window[ vendors[ x ] + 'CancelAnimationFrame' ] || - window[ vendors[ x ] + 'CancelRequestAnimationFrame' ] - ); - } - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = function (callback/*, element */) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); +/***/ }), +/* 27 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var id = window.setTimeout(function () { - var time = currTime + timeToCall; - callback(time); - }, timeToCall); +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = filter; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cb_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each_js__ = __webpack_require__(16); - lastTime = currTime + timeToCall; - return id - }; - } - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = function (id) { - clearTimeout(id); - }; - } - }()); +// Return all the elements that pass a truth test. +function filter(obj, predicate, context) { + var results = []; + predicate = Object(__WEBPACK_IMPORTED_MODULE_0__cb_js__["a" /* default */])(predicate, context); + Object(__WEBPACK_IMPORTED_MODULE_1__each_js__["a" /* default */])(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; } -if (Function.prototype.name === undefined && Object.defineProperty !== undefined) { - // Missing in IE9-11. - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name - // eslint-disable-next-line no-extend-native - Object.defineProperty(Function.prototype, 'name', { +/***/ }), +/* 28 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - get: function () { - return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[ 1 ] - } +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = contains; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isArrayLike_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__values_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__indexOf_js__ = __webpack_require__(87); - }); -} -if (typeof window !== 'undefined') { - if (window.performance === undefined) { - /* global self */ - self.performance = {}; - } - if (window.performance.now === undefined) { - (function () { - var start = Date.now(); - window.performance.now = function () { - return Date.now() - start - }; - })(); - } +// Determine if the array or object contains a given item (using `===`). +function contains(obj, item, fromIndex, guard) { + if (!Object(__WEBPACK_IMPORTED_MODULE_0__isArrayLike_js__["a" /* default */])(obj)) obj = Object(__WEBPACK_IMPORTED_MODULE_1__values_js__["a" /* default */])(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return Object(__WEBPACK_IMPORTED_MODULE_2__indexOf_js__["a" /* default */])(obj, item, fromIndex) >= 0; } -if (Object.defineProperty !== undefined) { - // Missing in IE < 13 - // MIT license - // Copyright (c) 2016 Financial Times - // https://github.com/Financial-Times/polyfill-service - if (Number.MAX_SAFE_INTEGER === undefined) { - Object.defineProperty(Number, 'MAX_SAFE_INTEGER', { - enumerable: false, - configurable: false, - writable: false, - value: Math.pow(2, 53) - 1 - }); - } - if (Number.MIN_SAFE_INTEGER === undefined) { - Object.defineProperty(Number, 'MIN_SAFE_INTEGER', { - enumerable: false, - configurable: false, - writable: false, - value: -(Math.pow(2, 53) - 1) - }); - } -} -/** - * @file Utils - * @author Alexander Rose - * @private - */ -function getQuery(id) { - if (typeof window === 'undefined') - { return undefined; } - var a = new RegExp((id + "=([^&#=]*)")); - var m = a.exec(window.location.search); - if (m) { - return decodeURIComponent(m[1]); - } - else { - return undefined; - } -} -function boolean(value) { - if (!value) { - return false; - } - if (typeof value === 'string') { - return /^1|true|t|yes|y$/i.test(value); - } - return true; -} -function defaults(value, defaultValue) { - return value !== undefined ? value : defaultValue; -} -function createParams(params, defaultParams) { - var o = Object.assign({}, params); - for (var k in defaultParams) { - var value = params[k]; - if (value === undefined) - { o[k] = defaultParams[k]; } - } - return o; -} -function updateParams(params, newParams) { - for (var k in newParams) { - var value = newParams[k]; - if (value !== undefined) - { params[k] = value; } - } - return params; -} -function flatten(array, ret) { - ret = defaults(ret, []); - for (var i = 0; i < array.length; i++) { - if (Array.isArray(array[i])) { - flatten(array[i], ret); - } - else { - ret.push(array[i]); - } - } - return ret; -} -function getProtocol() { - var protocol = window.location.protocol; - return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol; -} -function getBrowser() { - if (typeof window === 'undefined') - { return false; } - var ua = window.navigator.userAgent; - if (/Opera|OPR/.test(ua)) { - return 'Opera'; - } - else if (/Chrome/i.test(ua)) { - return 'Chrome'; - } - else if (/Firefox/i.test(ua)) { - return 'Firefox'; - } - else if (/Mobile(\/.*)? Safari/i.test(ua)) { - return 'Mobile Safari'; - } - else if (/MSIE/i.test(ua)) { - return 'Internet Explorer'; - } - else if (/Safari/i.test(ua)) { - return 'Safari'; - } - return false; -} -function getAbsolutePath(relativePath) { - var loc = window.location; - var pn = loc.pathname; - var basePath = pn.substring(0, pn.lastIndexOf('/') + 1); - return loc.origin + basePath + relativePath; -} -function openUrl(url) { - var opened = window.open(url, '_blank'); - if (!opened) { - window.location.href = url; - } -} -function download(data, downloadName) { - if ( downloadName === void 0 ) downloadName = 'download'; - - // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js - if (!data) - { return; } - var isSafari = getBrowser() === 'Safari'; - var isChromeIos = /CriOS\/[\d]+/.test(window.navigator.userAgent); - var a = document.createElement('a'); - function open(str) { - openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;')); - } - if (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob) { - // native saveAs in IE 10+ - navigator.msSaveOrOpenBlob(data, downloadName); - } - else if ((isSafari || isChromeIos) && FileReader) { - if (data instanceof Blob) { - // no downloading of blob urls in Safari - var reader = new FileReader(); - reader.onloadend = function () { - open(reader.result); - }; - reader.readAsDataURL(data); - } - else { - open(data); - } - } - else { - var objectUrlCreated = false; - if (data instanceof Blob) { - data = URL.createObjectURL(data); - objectUrlCreated = true; - } - if ('download' in a) { - // download link available - a.style.display = 'hidden'; - document.body.appendChild(a); - a.href = data; - a.download = downloadName; - a.target = '_blank'; - a.click(); - document.body.removeChild(a); - } - else { - openUrl(data); - } - if (objectUrlCreated) { - window.URL.revokeObjectURL(data); - } - } -} -function throttle(func, wait, options) { - // from http://underscorejs.org/docs/underscore.html - var context; - var args; - var result; - var timeout = null; - var previous = 0; - if (!options) - { options = {}; } - function later() { - previous = options.leading === false ? 0 : Date.now(); - timeout = null; - result = func.apply(context, args); - if (!timeout) - { context = args = null; } - } - return function throttle() { - var now = Date.now(); - if (!previous && options.leading === false) - { previous = now; } - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0 || remaining > wait) { - if (timeout) { - clearTimeout(timeout); - timeout = null; - } - previous = now; - result = func.apply(context, args); - if (!timeout) - { context = args = null; } - } - else if (!timeout && options.trailing !== false) { - timeout = setTimeout(later, remaining); - } - return result; - }; -} -function lexicographicCompare(elm1, elm2) { - if (elm1 < elm2) - { return -1; } - if (elm1 > elm2) - { return 1; } - return 0; -} -/** - * Does a binary search to get the index of an element in the input array - * @function - * @example - * var array = [ 1, 2, 3, 4, 5, 6 ]; - * var element = 4; - * binarySearchIndexOf( array, element ); // returns 3 - * - * @param {Array} array - sorted array - * @param {Anything} element - element to search for in the array - * @param {Function} [compareFunction] - compare function - * @return {Number} the index of the element or -1 if not in the array - */ -function binarySearchIndexOf(array, element, compareFunction) { - if ( compareFunction === void 0 ) compareFunction = lexicographicCompare; - - var low = 0; - var high = array.length - 1; - while (low <= high) { - var mid = (low + high) >> 1; - var cmp = compareFunction(element, array[mid]); - if (cmp > 0) { - low = mid + 1; - } - else if (cmp < 0) { - high = mid - 1; - } - else { - return mid; - } - } - return -low - 1; -} -function binarySearchForLeftRange(array, leftRange) { - var high = array.length - 1; - if (array[high] < leftRange) - { return -1; } - var low = 0; - while (low <= high) { - var mid = (low + high) >> 1; - if (array[mid] >= leftRange) { - high = mid - 1; - } - else { - low = mid + 1; - } - } - return high + 1; -} -function binarySearchForRightRange(array, rightRange) { - if (array[0] > rightRange) - { return -1; } - var low = 0; - var high = array.length - 1; - while (low <= high) { - var mid = (low + high) >> 1; - if (array[mid] > rightRange) { - high = mid - 1; - } - else { - low = mid + 1; +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BaseView = void 0; +const widgets = __webpack_require__(22); +var NGL = __webpack_require__(18); // not sure why I can not import it +class BaseView extends widgets.DOMWidgetView { + render() { + if (this.isEmbeded()) { + // embed mode: let NGLView call the handleEmbed directly + return; } + this.handleMessage(); + this.displayed.then(() => { + this.model.set("_ready", true); + this.touch(); + }); } - return low - 1; -} -function rangeInSortedArray(array, min, max) { - var indexLeft = binarySearchForLeftRange(array, min); - var indexRight = binarySearchForRightRange(array, max); - if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) { - return 0; - } - else { - return indexRight - indexLeft + 1; - } -} -function uniqueArray(array) { - return array.sort().filter(function (value, index, sorted) { - return (index === 0) || (value !== sorted[index - 1]); - }); -} -// String/arraybuffer conversion -function uint8ToString(u8a) { - var chunkSize = 0x7000; - if (u8a.length > chunkSize) { - var c = []; - for (var i = 0; i < u8a.length; i += chunkSize) { - c.push(String.fromCharCode.apply(null, u8a.subarray(i, i + chunkSize))); - } - return c.join(''); + executeCode(code) { + eval(code); } - else { - return String.fromCharCode.apply(null, u8a); + handleMessage() { + this.model.on("msg:custom", function (msg) { + this.on_msg(msg); + }.bind(this)); } -} -function uint8ToLines(u8a, chunkSize, newline) { - if ( chunkSize === void 0 ) chunkSize = 1024 * 1024 * 10; - if ( newline === void 0 ) newline = '\n'; - - var partialLine = ''; - var lines = []; - for (var i = 0; i < u8a.length; i += chunkSize) { - var str = uint8ToString(u8a.subarray(i, i + chunkSize)); - var idx = str.lastIndexOf(newline); - if (idx === -1) { - partialLine += str; - } - else { - var str2 = partialLine + str.substr(0, idx); - lines = lines.concat(str2.split(newline)); - if (idx === str.length - newline.length) { - partialLine = ''; - } - else { - partialLine = str.substr(idx + newline.length); - } + on_msg(msg) { + if (msg.type == 'callMethod') { + console.log("from BaseView", msg); + this[msg.methodName].apply(this, msg.args, msg.kwargs); } } - if (partialLine !== '') { - lines.push(partialLine); - } - return lines; -} -function getTypedArray(arrayType, arraySize) { - switch (arrayType) { - case 'int8': - return new Int8Array(arraySize); - case 'int16': - return new Int16Array(arraySize); - case 'int32': - return new Int32Array(arraySize); - case 'uint8': - return new Uint8Array(arraySize); - case 'uint16': - return new Uint16Array(arraySize); - case 'uint32': - return new Uint32Array(arraySize); - case 'float32': - return new Float32Array(arraySize); - default: - throw new Error('arrayType unknown: ' + arrayType); - } -} -function getUintArray(sizeOrArray, maxUint) { - var TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array; - return new TypedArray(sizeOrArray); -} -function ensureArray(value) { - return Array.isArray(value) ? value : [value]; -} -function ensureBuffer(a) { - return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a; -} -function _ensureClassFromArg(arg, constructor) { - return arg instanceof constructor ? arg : new constructor(arg); -} -function _ensureClassFromArray(array, constructor) { - if (array === undefined) { - array = new constructor(); - } - else if (Array.isArray(array)) { - array = new constructor().fromArray(array); + isEmbeded() { + return (this.model.comm == undefined); } - return array; -} -function ensureVector2(v) { - return _ensureClassFromArray(v, __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */]); -} -function ensureVector3(v) { - return _ensureClassFromArray(v, __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]); -} -function ensureMatrix4(m) { - return _ensureClassFromArray(m, __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]); -} -function ensureQuaternion(q) { - return _ensureClassFromArray(q, __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */]); -} -function ensureFloat32Array(a) { - return _ensureClassFromArg(a, Float32Array); -} -function createRingBuffer(length) { - var pointer = 0; - var count = 0; - var buffer = []; - return { - has: function (value) { return buffer.indexOf(value) !== -1; }, - get: function (idx) { return buffer[idx]; }, - push: function (item) { - buffer[pointer] = item; - pointer = (length + pointer + 1) % length; - ++count; - }, - get count() { return count; }, - get data() { return buffer.slice(0, Math.min(count, length)); }, - clear: function () { - count = 0; - pointer = 0; - buffer.length = 0; - } - }; -} -function createSimpleDict() { - var set = {}; - return { - has: function (k) { return set[JSON.stringify(k)] !== undefined; }, - add: function (k, v) { set[JSON.stringify(k)] = v; }, - del: function (k) { delete set[JSON.stringify(k)]; }, - get values() { return Object.keys(set).map(function (k) { return set[k]; }); } - }; } +exports.BaseView = BaseView; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9iYXNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlEQUFnRDtBQUNoRCxJQUFJLEdBQUcsR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUEsQ0FBQyxtQ0FBbUM7QUFHNUQsTUFDTSxRQUFTLFNBQVEsT0FBTyxDQUFDLGFBQWE7SUFFeEMsTUFBTTtRQUNOLElBQUksSUFBSSxDQUFDLFNBQVMsRUFBRSxFQUFDO1lBQ2Isd0RBQXdEO1lBQ3hELE9BQU07U0FDVDtRQUNELElBQUksQ0FBQyxhQUFhLEVBQUUsQ0FBQztRQUNyQixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUU7WUFDckIsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFBO1lBQzlCLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNoQixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUM7SUFFRCxXQUFXLENBQUMsSUFBSTtRQUNaLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNmLENBQUM7SUFFRCxhQUFhO1FBQ1QsSUFBSSxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsWUFBWSxFQUFFLFVBQVMsR0FBRztZQUNwQyxJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ3BCLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQTtJQUNqQixDQUFDO0lBRUQsTUFBTSxDQUFDLEdBQUc7UUFDTixJQUFJLEdBQUcsQ0FBQyxJQUFJLElBQUksWUFBWSxFQUFDO1lBQ3pCLE9BQU8sQ0FBQyxHQUFHLENBQUMsZUFBZSxFQUFFLEdBQUcsQ0FBQyxDQUFBO1lBQ2pDLElBQUksQ0FBQyxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUMsS0FBSyxDQUFDLElBQUksRUFBRSxHQUFHLENBQUMsSUFBSSxFQUFFLEdBQUcsQ0FBQyxNQUFNLENBQUMsQ0FBQTtTQUN6RDtJQUNMLENBQUM7SUFFRCxTQUFTO1FBQ0wsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxJQUFJLFNBQVMsQ0FBQyxDQUFBO0lBQ3pDLENBQUM7Q0FDSjtBQW5DRCw0QkFtQ0MifQ== -/** - * @file Registry - * @author Alexander Rose - * @private - */ -function toLowerCaseString(value) { - return defaults(value, '').toString().toLowerCase(); -} -var Registry = function Registry(name) { - this.name = name; - this._dict = {}; -}; +/***/ }), +/* 30 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -var prototypeAccessors = { names: { configurable: true } }; -Registry.prototype.add = function add (key, value) { - this._dict[toLowerCaseString(key)] = value; -}; -Registry.prototype.get = function get (key) { - return this._dict[toLowerCaseString(key)]; -}; -prototypeAccessors.names.get = function () { - return Object.keys(this._dict); -}; +"use strict"; +/* harmony export (immutable) */ __webpack_exports__["a"] = matcher; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extendOwn_js__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isMatch_js__ = __webpack_require__(64); -Object.defineProperties( Registry.prototype, prototypeAccessors ); -/** - * @file Math Utils - * @author Alexander Rose - * @private - */ -function degToRad(deg) { - return deg * 0.01745; // deg * Math.PI / 180 -} -function radToDeg(rad) { - return rad * 57.29578; // rad * 180 / Math.PI -} -// http://www.broofa.com/Tools/Math.uuid.htm -var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); -var uuid = new Array(36); -function generateUUID() { - var rnd = 0; - var r; - for (var i = 0; i < 36; i++) { - if (i === 8 || i === 13 || i === 18 || i === 23) { - uuid[i] = '-'; - } - else if (i === 14) { - uuid[i] = '4'; - } - else { - if (rnd <= 0x02) - { rnd = 0x2000000 + (Math.random() * 0x1000000) | 0; } - r = rnd & 0xf; - rnd = rnd >> 4; - uuid[i] = chars[(i === 19) ? (r & 0x3) | 0x8 : r]; - } - } - return uuid.join(''); -} -function countSetBits(i) { - i = i - ((i >> 1) & 0x55555555); - i = (i & 0x33333333) + ((i >> 2) & 0x33333333); - return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24; -} -function normalize(value, min, max) { - return (value - min) / (max - min); -} -function clamp(value, min, max) { - return Math.max(min, Math.min(max, value)); -} -function pclamp(value) { - return clamp(value, 0, 100); -} -function saturate(value) { - return clamp(value, 0, 1); -} -function lerp(start, stop, alpha) { - return start + (stop - start) * alpha; -} -function spline(p0, p1, p2, p3, t, tension) { - var v0 = (p2 - p0) * tension; - var v1 = (p3 - p1) * tension; - var t2 = t * t; - var t3 = t * t2; - return (2 * p1 - 2 * p2 + v0 + v1) * t3 + - (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + - v0 * t + p1; -} -function smoothstep(min, max, x) { - x = saturate(normalize(x, min, max)); - return x * x * (3 - 2 * x); -} -function almostIdentity(value, start, stop) { - if (value > start) - { return value; } - var a = 2 * stop - start; - var b = 2 * start - 3 * stop; - var t = value / start; - return (a * t + b) * t * t + stop; + +// Returns a predicate for checking whether an object has a given set of +// `key:value` pairs. +function matcher(attrs) { + attrs = Object(__WEBPACK_IMPORTED_MODULE_0__extendOwn_js__["a" /* default */])({}, attrs); + return function(obj) { + return Object(__WEBPACK_IMPORTED_MODULE_1__isMatch_js__["a" /* default */])(obj, attrs); + }; } -/** - * @file Colormaker - * @author Alexander Rose - * @private - */ -var ScaleDefaultParameters = { - scale: 'uniform', - mode: 'hcl', - domain: [0, 1], - value: 0xFFFFFF, - reverse: false -}; -var tmpColor = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](); -/** - * Class for making colors. - * @interface - */ -var Colormaker = function Colormaker(params) { - if ( params === void 0 ) params = {}; - this.parameters = createParams(params, ScaleDefaultParameters); - if (typeof this.parameters.value === 'string') { - this.parameters.value = tmpColor.set(this.parameters.value).getHex(); - } - if (this.parameters.structure) { - this.atomProxy = this.parameters.structure.getAtomProxy(); - } -}; -Colormaker.prototype.getScale = function getScale (params) { - if ( params === void 0 ) params = {}; +/***/ }), +/* 31 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - var p = createParams(params, this.parameters); - if (p.scale === 'rainbow') { - p.scale = ['red', 'orange', 'yellow', 'green', 'blue']; - } - else if (p.scale === 'rwb') { - p.scale = ['red', 'white', 'blue']; - } - if (p.reverse) { - p.domain.reverse(); - } - return Object(__WEBPACK_IMPORTED_MODULE_1_chroma_js__["scale"])(p.scale) // TODO - .mode(p.mode) - .domain(p.domain) - .out('num'); // TODO -}; -/** - * safe a color to an array - * @param {Integer} color - hex color value - * @param {Array|TypedArray} array - destination - * @param {Integer} offset - index into the array - * @return {Array} the destination array - */ -Colormaker.prototype.colorToArray = function colorToArray (color, array, offset) { - if ( array === void 0 ) array = []; - if ( offset === void 0 ) offset = 0; - - array[offset] = (color >> 16 & 255) / 255; - array[offset + 1] = (color >> 8 & 255) / 255; - array[offset + 2] = (color & 255) / 255; - return array; -}; -/** - * safe a atom color to an array - * @param {AtomProxy} atom - atom to get color for - * @param {Array|TypedArray} array - destination - * @param {Integer} offset - index into the array - * @return {Array} the destination array - */ -Colormaker.prototype.atomColorToArray = function atomColorToArray (atom, array, offset) { - return this.colorToArray(this.atomColor ? this.atomColor(atom) : 0x000000, array, offset); -}; -/** - * return the color for an bond - * @param {BondProxy} bond - bond to get color for - * @param {Boolean} fromTo - whether to use the first or second atom of the bond - * @return {Integer} hex bond color - */ -Colormaker.prototype.bondColor = function bondColor (bond, fromTo) { - if (this.atomProxy && this.atomColor) { - this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2; - return this.atomColor(this.atomProxy); - } - else { - return 0x000000; - } -}; -/** - * safe a bond color to an array - * @param {BondProxy} bond - bond to get color for - * @param {Boolean} fromTo - whether to use the first or second atom of the bond - * @param {Array|TypedArray} array - destination - * @param {Integer} offset - index into the array - * @return {Array} the destination array - */ -Colormaker.prototype.bondColorToArray = function bondColorToArray (bond, fromTo, array, offset) { - return this.colorToArray(this.bondColor(bond, fromTo), array, offset); -}; -/** - * safe a volume cell color to an array - * @param {Integer} index - volume cell index - * @param {Array|TypedArray} array - destination - * @param {Integer} offset - index into the array - * @return {Array} the destination array - */ -Colormaker.prototype.volumeColorToArray = function volumeColorToArray (index, array, offset) { - return this.colorToArray(this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset); -}; -/** - * safe a color for coordinates in space to an array - * @param {Vector3} coords - xyz coordinates - * @param {Array|TypedArray} array - destination - * @param {Integer} offset - index into the array - * @return {Array} the destination array - */ -Colormaker.prototype.positionColorToArray = function positionColorToArray (coords, array, offset) { - return this.colorToArray(this.positionColor ? this.positionColor(coords) : 0x000000, array, offset); -}; - -/** - * @file Selection Constants - * @author Alexander Rose - * @private - */ -var kwd; -(function (kwd) { - kwd[kwd["PROTEIN"] = 1] = "PROTEIN"; - kwd[kwd["NUCLEIC"] = 2] = "NUCLEIC"; - kwd[kwd["RNA"] = 3] = "RNA"; - kwd[kwd["DNA"] = 4] = "DNA"; - kwd[kwd["POLYMER"] = 5] = "POLYMER"; - kwd[kwd["WATER"] = 6] = "WATER"; - kwd[kwd["HELIX"] = 7] = "HELIX"; - kwd[kwd["SHEET"] = 8] = "SHEET"; - kwd[kwd["TURN"] = 9] = "TURN"; - kwd[kwd["BACKBONE"] = 10] = "BACKBONE"; - kwd[kwd["SIDECHAIN"] = 11] = "SIDECHAIN"; - kwd[kwd["ALL"] = 12] = "ALL"; - kwd[kwd["HETERO"] = 13] = "HETERO"; - kwd[kwd["ION"] = 14] = "ION"; - kwd[kwd["SACCHARIDE"] = 15] = "SACCHARIDE"; - kwd[kwd["SUGAR"] = 15] = "SUGAR"; - kwd[kwd["BONDED"] = 16] = "BONDED"; - kwd[kwd["RING"] = 17] = "RING"; - kwd[kwd["AROMATICRING"] = 18] = "AROMATICRING"; - kwd[kwd["METAL"] = 19] = "METAL"; - kwd[kwd["POLARH"] = 20] = "POLARH"; - kwd[kwd["NONE"] = 21] = "NONE"; -})(kwd || (kwd = {})); -var SelectAllKeyword = ['*', '', 'ALL']; -var SelectNoneKeyword = ['NONE']; -var AtomOnlyKeywords = [ - kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH -]; -var ChainKeywords = [ - kwd.POLYMER, kwd.WATER -]; -var SmallResname = ['ALA', 'GLY', 'SER']; -var NucleophilicResname = ['CYS', 'SER', 'THR']; -var HydrophobicResname = ['ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL']; -var AromaticResname = ['PHE', 'TRP', 'TYR', 'HIS']; -var AmideResname = ['ASN', 'GLN']; -var AcidicResname = ['ASP', 'GLU']; -var BasicResname = ['ARG', 'HIS', 'LYS']; -var ChargedResname = ['ARG', 'ASP', 'GLU', 'HIS', 'LYS']; -var PolarResname = ['ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR']; -var NonpolarResname = ['ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL']; -var CyclicResname = ['HIS', 'PHE', 'PRO', 'TRP', 'TYR']; -var AliphaticResname = ['ALA', 'GLY', 'ILE', 'LEU', 'VAL']; - -/** - * @file Selection Parser - * @author Alexander Rose - * @private - */ -function parseSele(string) { - var retSelection = { - operator: undefined, - rules: [] - }; - if (!string) { - return retSelection; - } - var selection = retSelection; - var newSelection; - var oldSelection; - var selectionStack = []; - string = string.replace(/\(/g, ' ( ').replace(/\)/g, ' ) ').trim(); - if (string.charAt(0) === '(' && string.substr(-1) === ')') { - string = string.slice(1, -1).trim(); - } - var chunks = string.split(/\s+/); - // Log.log( string, chunks ) - var createNewContext = function (operator) { - newSelection = { - operator: operator, - rules: [] - }; - if (selection === undefined) { - selection = newSelection; - retSelection = newSelection; - } - else { - selection.rules.push(newSelection); - selectionStack.push(selection); - selection = newSelection; - } - }; - var getPrevContext = function (operator) { - oldSelection = selection; - selection = selectionStack.pop(); - if (selection === undefined) { - createNewContext(operator); - pushRule(oldSelection); - } - }; - var pushRule = function (rule) { - selection.rules.push(rule); - }; - var not = false; - for (var i = 0; i < chunks.length; ++i) { - var c = chunks[i]; - var cu = c.toUpperCase(); - // handle parens - if (c === '(') { - // Log.log( "(" ); - not = false; - createNewContext(); - continue; - } - else if (c === ')') { - // Log.log( ")" ); - getPrevContext(); - if (selection.negate) { - getPrevContext(); - } - continue; - } - // leave 'not' context - if (not > 0) { - if (cu === 'NOT') { - not = 1; - } - else if (not === 1) { - not = 2; - } - else if (not === 2) { - not = false; - getPrevContext(); - } - else { - throw new Error("something went wrong with 'not'"); - } - } - // handle logic operators - if (cu === 'AND') { - // Log.log( "AND" ); - if (selection.operator === 'OR') { - var lastRule = selection.rules.pop(); - createNewContext('AND'); - pushRule(lastRule); - } - else { - selection.operator = 'AND'; - } - continue; - } - else if (cu === 'OR') { - // Log.log( "OR" ); - if (selection.operator === 'AND') { - getPrevContext('OR'); - } - else { - selection.operator = 'OR'; - } - continue; - } - else if (c.toUpperCase() === 'NOT') { - // Log.log( "NOT", j ); - not = 1; - createNewContext(); - selection.negate = true; - continue; - } - // handle keyword attributes - // ensure `cu` is not a number before testing if it is in the - // kwd enum dictionary which includes the enum numbers as well... - if (+cu !== +cu) { - var keyword = kwd[cu]; - if (keyword !== undefined) { - pushRule({ keyword: keyword }); - continue; - } - } - if (cu === 'HYDROGEN') { - pushRule({ - operator: 'OR', - rules: [ - { element: 'H' }, - { element: 'D' } - ] - }); - continue; - } - if (cu === 'SMALL') { - pushRule({ resname: SmallResname }); - continue; - } - if (cu === 'NUCLEOPHILIC') { - pushRule({ resname: NucleophilicResname }); - continue; - } - if (cu === 'HYDROPHOBIC') { - pushRule({ resname: HydrophobicResname }); - continue; - } - if (cu === 'AROMATIC') { - pushRule({ resname: AromaticResname }); - continue; - } - if (cu === 'AMIDE') { - pushRule({ resname: AmideResname }); - continue; - } - if (cu === 'ACIDIC') { - pushRule({ resname: AcidicResname }); - continue; - } - if (cu === 'BASIC') { - pushRule({ resname: BasicResname }); - continue; - } - if (cu === 'CHARGED') { - pushRule({ resname: ChargedResname }); - continue; - } - if (cu === 'POLAR') { - pushRule({ resname: PolarResname }); - continue; - } - if (cu === 'NONPOLAR') { - pushRule({ resname: NonpolarResname }); - continue; - } - if (cu === 'CYCLIC') { - pushRule({ resname: CyclicResname }); - continue; - } - if (cu === 'ALIPHATIC') { - pushRule({ resname: AliphaticResname }); - continue; - } - if (cu === 'SIDECHAINATTACHED') { - pushRule({ - operator: 'OR', - rules: [ - { keyword: kwd.SIDECHAIN }, - { - operator: 'AND', - negate: false, - rules: [ - { keyword: kwd.PROTEIN }, - { - operator: 'OR', - negate: false, - rules: [ - { atomname: 'CA' }, - { atomname: 'BB' } - ] - } - ] - }, - { - operator: 'AND', - negate: false, - rules: [ - { resname: 'PRO' }, - { atomname: 'N' } - ] - }, - { - operator: 'AND', - negate: false, - rules: [ - { keyword: kwd.NUCLEIC }, - { - operator: 'OR', - negate: true, - rules: [ - { atomname: 'P' }, - { atomname: 'OP1' }, - { atomname: 'OP2' }, - { atomname: "O3'" }, - { atomname: 'O3*' }, - { atomname: "O5'" }, - { atomname: 'O5*' }, - { atomname: "C5'" }, - { atomname: 'C5*' } - ] - } - ] - } - ] - }); - continue; - } - if (cu === 'APOLARH') { - pushRule({ - operator: 'AND', - negate: false, - rules: [ - { element: 'H' }, - { - negate: true, - operator: undefined, - rules: [ - { keyword: kwd.POLARH } - ] - } - ] - }); - continue; - } - if (cu === 'LIGAND') { - pushRule({ - operator: 'AND', - rules: [ - { - operator: 'OR', - rules: [ - { - operator: 'AND', - rules: [ - { keyword: kwd.HETERO }, - { - negate: true, - operator: undefined, - rules: [ - { keyword: kwd.POLYMER } - ] - } - ] - }, - { - negate: true, - operator: undefined, - rules: [ - { keyword: kwd.POLYMER } - ] - } - ] - }, - { - negate: true, - operator: undefined, - rules: [ - { - operator: 'OR', - rules: [ - { keyword: kwd.WATER }, - { keyword: kwd.ION } - ] - } - ] - } - ] - }); - continue; - } - if (SelectAllKeyword.indexOf(cu) !== -1) { - pushRule({ keyword: kwd.ALL }); - continue; - } - // handle atom expressions - if (c.charAt(0) === '@') { - var indexList = c.substr(1).split(',').map(function (x) { return parseInt(x); }); - indexList.sort(function (a, b) { return a - b; }); - pushRule({ atomindex: indexList }); - continue; - } - if (c.charAt(0) === '#') { - console.error('# for element selection deprecated, use _'); - pushRule({ element: cu.substr(1) }); - continue; - } - if (c.charAt(0) === '_') { - pushRule({ element: cu.substr(1) }); - continue; - } - if (c[0] === '[' && c[c.length - 1] === ']') { - var resnameList = cu.substr(1, c.length - 2).split(','); - var resname = resnameList.length > 1 ? resnameList : resnameList[0]; - pushRule({ resname: resname }); - continue; - } - else if ((c.length >= 1 && c.length <= 4) && - c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' && - isNaN(parseInt(c))) { - pushRule({ resname: cu }); - continue; - } - // there must be only one constraint per rule - // otherwise a test quickly becomes not applicable - // e.g. chainTest for chainname when resno is present too - var sele = { - operator: 'AND', - rules: [] - }; - var model = c.split('/'); - if (model.length > 1 && model[1]) { - if (isNaN(parseInt(model[1]))) { - throw new Error('model must be an integer'); - } - sele.rules.push({ - model: parseInt(model[1]) - }); - } - var altloc = model[0].split('%'); - if (altloc.length > 1) { - sele.rules.push({ - altloc: altloc[1] - }); - } - var atomname = altloc[0].split('.'); - if (atomname.length > 1 && atomname[1]) { - if (atomname[1].length > 4) { - throw new Error('atomname must be one to four characters'); - } - sele.rules.push({ - atomname: atomname[1].substring(0, 4).toUpperCase() - }); - } - var chain = atomname[0].split(':'); - if (chain.length > 1 && chain[1]) { - sele.rules.push({ - chainname: chain[1] - }); - } - var inscode = chain[0].split('^'); - if (inscode.length > 1) { - sele.rules.push({ - inscode: inscode[1] - }); - } - if (inscode[0]) { - var negate = (void 0), negate2 = (void 0); - if (inscode[0][0] === '-') { - inscode[0] = inscode[0].substr(1); - negate = true; - } - if (inscode[0].includes('--')) { - inscode[0] = inscode[0].replace('--', '-'); - negate2 = true; - } - var resi = inscode[0].split('-'); - if (resi.length === 1) { - var resiSingle = parseInt(resi[0]); - if (isNaN(resiSingle)) { - throw new Error('resi must be an integer'); - } - if (negate) - { resiSingle *= -1; } - sele.rules.push({ - resno: resiSingle - }); - } - else if (resi.length === 2) { - var resiRange = resi.map(function (x) { return parseInt(x); }); - if (negate) - { resiRange[0] *= -1; } - if (negate2) - { resiRange[1] *= -1; } - sele.rules.push({ - resno: [resiRange[0], resiRange[1]] - }); - } - else { - throw new Error("resi range must contain one '-'"); - } - } - // round up - if (sele.rules.length === 1) { - pushRule(sele.rules[0]); - } - else if (sele.rules.length > 1) { - pushRule(sele); - } - else { - throw new Error('empty selection chunk'); - } - } - // cleanup - if (retSelection.operator === undefined && - retSelection.rules.length === 1 && - retSelection.rules[0].hasOwnProperty('operator')) { - retSelection = retSelection.rules[0]; - } - return retSelection; -} - -/** - * @file Selection Test - * @author Alexander Rose - * @private - */ -function atomTestFn(a, s) { - // returning -1 means the rule is not applicable - if (s.atomname === undefined && s.element === undefined && - s.altloc === undefined && s.atomindex === undefined && - s.keyword === undefined && s.inscode === undefined && - s.resname === undefined && s.sstruc === undefined && - s.resno === undefined && s.chainname === undefined && - s.model === undefined) - { return -1; } - if (s.keyword !== undefined) { - if (s.keyword === kwd.BACKBONE && !a.isBackbone()) - { return false; } - if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) - { return false; } - if (s.keyword === kwd.BONDED && !a.isBonded()) - { return false; } - if (s.keyword === kwd.RING && !a.isRing()) - { return false; } - if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) - { return false; } - if (s.keyword === kwd.HETERO && !a.isHetero()) - { return false; } - if (s.keyword === kwd.PROTEIN && !a.isProtein()) - { return false; } - if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) - { return false; } - if (s.keyword === kwd.RNA && !a.isRna()) - { return false; } - if (s.keyword === kwd.DNA && !a.isDna()) - { return false; } - if (s.keyword === kwd.POLYMER && !a.isPolymer()) - { return false; } - if (s.keyword === kwd.WATER && !a.isWater()) - { return false; } - if (s.keyword === kwd.HELIX && !a.isHelix()) - { return false; } - if (s.keyword === kwd.SHEET && !a.isSheet()) - { return false; } - if (s.keyword === kwd.TURN && !a.isTurn()) - { return false; } - if (s.keyword === kwd.ION && !a.isIon()) - { return false; } - if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) - { return false; } - if (s.keyword === kwd.METAL && !a.isMetal()) - { return false; } - if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) - { return false; } - } - if (s.atomname !== undefined && s.atomname !== a.atomname) - { return false; } - if (s.element !== undefined && s.element !== a.element) - { return false; } - if (s.altloc !== undefined && s.altloc !== a.altloc) - { return false; } - if (s.atomindex !== undefined && - binarySearchIndexOf(s.atomindex, a.index) < 0) - { return false; } - if (s.resname !== undefined) { - if (Array.isArray(s.resname)) { - if (!s.resname.includes(a.resname)) - { return false; } - } - else { - if (s.resname !== a.resname) - { return false; } - } - } - if (s.sstruc !== undefined && s.sstruc !== a.sstruc) - { return false; } - if (s.resno !== undefined) { - if (Array.isArray(s.resno) && s.resno.length === 2) { - if (s.resno[0] > a.resno || s.resno[1] < a.resno) - { return false; } - } - else { - if (s.resno !== a.resno) - { return false; } - } - } - if (s.inscode !== undefined && s.inscode !== a.inscode) - { return false; } - if (s.chainname !== undefined && s.chainname !== a.chainname) - { return false; } - if (s.model !== undefined && s.model !== a.modelIndex) - { return false; } - return true; -} -function residueTestFn(r, s) { - // returning -1 means the rule is not applicable - if (s.resname === undefined && s.resno === undefined && s.inscode === undefined && - s.sstruc === undefined && s.model === undefined && s.chainname === undefined && - s.atomindex === undefined && - (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))) - { return -1; } - if (s.keyword !== undefined) { - if (s.keyword === kwd.HETERO && !r.isHetero()) - { return false; } - if (s.keyword === kwd.PROTEIN && !r.isProtein()) - { return false; } - if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) - { return false; } - if (s.keyword === kwd.RNA && !r.isRna()) - { return false; } - if (s.keyword === kwd.DNA && !r.isDna()) - { return false; } - if (s.keyword === kwd.POLYMER && !r.isPolymer()) - { return false; } - if (s.keyword === kwd.WATER && !r.isWater()) - { return false; } - if (s.keyword === kwd.HELIX && !r.isHelix()) - { return false; } - if (s.keyword === kwd.SHEET && !r.isSheet()) - { return false; } - if (s.keyword === kwd.TURN && !r.isTurn()) - { return false; } - if (s.keyword === kwd.ION && !r.isIon()) - { return false; } - if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) - { return false; } - } - if (s.atomindex !== undefined && - rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0) - { return false; } - if (s.resname !== undefined) { - if (Array.isArray(s.resname)) { - if (!s.resname.includes(r.resname)) - { return false; } - } - else { - if (s.resname !== r.resname) - { return false; } - } - } - if (s.sstruc !== undefined && s.sstruc !== r.sstruc) - { return false; } - if (s.resno !== undefined) { - if (Array.isArray(s.resno) && s.resno.length === 2) { - if (s.resno[0] > r.resno || s.resno[1] < r.resno) - { return false; } - } - else { - if (s.resno !== r.resno) - { return false; } - } - } - if (s.inscode !== undefined && s.inscode !== r.inscode) - { return false; } - if (s.chainname !== undefined && s.chainname !== r.chainname) - { return false; } - if (s.model !== undefined && s.model !== r.modelIndex) - { return false; } - return true; -} -function chainTestFn(c, s) { - // returning -1 means the rule is not applicable - if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined && - (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)) - { return -1; } - if (s.keyword !== undefined) { - if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) - { return false; } - if (s.keyword === kwd.WATER && !c.entity.isWater()) - { return false; } - } - if (s.atomindex !== undefined && - rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0) - { return false; } - if (s.chainname !== undefined && s.chainname !== c.chainname) - { return false; } - if (s.model !== undefined && s.model !== c.modelIndex) - { return false; } - return true; -} -function modelTestFn(m, s) { - // returning -1 means the rule is not applicable - if (s.model === undefined && s.atomindex === undefined) - { return -1; } - if (s.atomindex !== undefined && - rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0) - { return false; } - if (s.model !== undefined && s.model !== m.index) - { return false; } - return true; -} -function makeTest(selection, fn) { - if (selection === null) - { return false; } - if (selection.error) - { return false; } - if (!selection.rules || selection.rules.length === 0) - { return false; } - var n = selection.rules.length; - var t = !selection.negate; - var f = !!selection.negate; - var subTests = []; - for (var i = 0; i < n; ++i) { - var s = selection.rules[i]; - if (s.hasOwnProperty('operator')) { - subTests[i] = makeTest(s, fn); // TODO - } - } - // ( x and y ) can short circuit on false - // ( x or y ) can short circuit on true - // not ( x and y ) - return function test(entity) { - var and = selection.operator === 'AND'; - var na = false; - for (var i = 0; i < n; ++i) { - var s = selection.rules[i]; // TODO - var ret = (void 0); - if (s.hasOwnProperty('operator')) { - var test$1 = subTests[i]; - if (test$1 !== false) { - ret = test$1(entity); - } - else { - ret = -1; - } - if (ret === -1) { - na = true; - continue; - } - else if (ret === true) { - if (and) { - continue; - } - else { - return t; - } - } - else { - if (and) { - return f; - } - else { - continue; - } - } - } - else { - if (s.keyword === kwd.ALL) { - if (and) { - continue; - } - else { - return t; - } - } - else if (s.keyword === kwd.NONE) { - if (and) { - continue; - } - else { - return f; - } - } - ret = fn(entity, s); - // console.log( entity.qualifiedName(), ret, s, selection.negate, "t", t, "f", f ) - if (ret === -1) { - na = true; - continue; - } - else if (ret === true) { - if (and) { - continue; - } - else { - return t; - } - } - else { - if (and) { - return f; - } - else { - continue; - } - } - } - } - if (na) { - return -1; - } - else { - if (and) { - return t; - } - else { - return f; - } - } - }; -} -function filter(selection, fn) { - if (selection.error) - { return selection; } - if (!selection.rules || selection.rules.length === 0) - { return selection; } - var n = selection.rules.length; - var filtered = { - operator: selection.operator, - rules: [] - }; - if (selection.hasOwnProperty('negate')) { - filtered.negate = selection.negate; - } - for (var i = 0; i < n; ++i) { - var s = selection.rules[i]; - if (s.hasOwnProperty('operator')) { - var fs = filter(s, fn); - if (fs !== null) - { filtered.rules.push(fs); } // TODO - } - else if (!fn(s)) { - filtered.rules.push(s); // TODO - } - } - if (filtered.rules.length > 0) { // TODO - // TODO maybe the filtered rules could be returned - // in some case, but the way how tests are applied - // e.g. when traversing a structure would also need - // to change - return selection; - // return filtered; - } - else { - return null; - } -} -function makeAtomTest(selection, atomOnly) { - if ( atomOnly === void 0 ) atomOnly = false; - - var filteredSelection = selection; - if (atomOnly) { - filteredSelection = filter(selection, function (s) { - if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) - { return true; } - if (s.model !== undefined) - { return true; } - if (s.chainname !== undefined) - { return true; } - if (s.resname !== undefined) - { return true; } - if (s.resno !== undefined) - { return true; } - if (s.sstruc !== undefined) - { return true; } - return false; - }); - } - return makeTest(filteredSelection, atomTestFn); -} -function makeResidueTest(selection, residueOnly) { - if ( residueOnly === void 0 ) residueOnly = false; - - var filteredSelection = selection; - if (residueOnly) { - filteredSelection = filter(selection, function (s) { - if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) - { return true; } - if (s.model !== undefined) - { return true; } - if (s.chainname !== undefined) - { return true; } - if (s.atomname !== undefined) - { return true; } - if (s.element !== undefined) - { return true; } - if (s.altloc !== undefined) - { return true; } - return false; - }); - } - return makeTest(filteredSelection, residueTestFn); -} -function makeChainTest(selection, chainOnly) { - if ( chainOnly === void 0 ) chainOnly = false; - - var filteredSelection = selection; - if (chainOnly) { - filteredSelection = filter(selection, function (s) { - if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) - { return true; } - // if( s.model!==undefined ) return true; - if (s.resname !== undefined) - { return true; } - if (s.resno !== undefined) - { return true; } - if (s.atomname !== undefined) - { return true; } - if (s.element !== undefined) - { return true; } - if (s.altloc !== undefined) - { return true; } - if (s.sstruc !== undefined) - { return true; } - if (s.inscode !== undefined) - { return true; } - return false; - }); - } - return makeTest(filteredSelection, chainTestFn); -} -function makeModelTest(selection, modelOnly) { - if ( modelOnly === void 0 ) modelOnly = false; - - var filteredSelection = selection; - if (modelOnly) { - filteredSelection = filter(selection, function (s) { - if (s.keyword !== undefined) - { return true; } - if (s.chainname !== undefined) - { return true; } - if (s.resname !== undefined) - { return true; } - if (s.resno !== undefined) - { return true; } - if (s.atomname !== undefined) - { return true; } - if (s.element !== undefined) - { return true; } - if (s.altloc !== undefined) - { return true; } - if (s.sstruc !== undefined) - { return true; } - if (s.inscode !== undefined) - { return true; } - return false; - }); - } - return makeTest(filteredSelection, modelTestFn); -} - -/** - * @file Selection - * @author Alexander Rose - * @private - */ -/** - * Selection - */ -var Selection = function Selection(string) { - this.signals = { - stringChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.setString(string); -}; - -var prototypeAccessors$1 = { type: { configurable: true } }; -prototypeAccessors$1.type.get = function () { return 'selection'; }; -Selection.prototype.setString = function setString (string, silent) { - if (string === undefined) - { string = this.string || ''; } - if (string === this.string) - { return; } - try { - this.selection = parseSele(string); - } - catch (e) { - // Log.error( e.stack ); - this.selection = { 'error': e.message }; - } - var selection = this.selection; - this.string = string; - this.test = makeAtomTest(selection); - this.residueTest = makeResidueTest(selection); - this.chainTest = makeChainTest(selection); - this.modelTest = makeModelTest(selection); - this.atomOnlyTest = makeAtomTest(selection, true); - this.residueOnlyTest = makeResidueTest(selection, true); - this.chainOnlyTest = makeChainTest(selection, true); - this.modelOnlyTest = makeModelTest(selection, true); - if (!silent) { - this.signals.stringChanged.dispatch(this.string); - } -}; -Selection.prototype.isAllSelection = function isAllSelection () { - return SelectAllKeyword.includes(this.string.toUpperCase()); -}; -Selection.prototype.isNoneSelection = function isNoneSelection () { - return SelectNoneKeyword.includes(this.string.toUpperCase()); -}; - -Object.defineProperties( Selection.prototype, prototypeAccessors$1 ); - -/** - * @file Selection Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color based on {@link Selection} - */ -var SelectionColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function SelectionColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - this.colormakerList = []; // TODO - this.selectionList = []; - var dataList = params.dataList || []; - dataList.forEach(function (data) { - var scheme = data[0]; - var sele = data[1]; - var params = data[2]; if ( params === void 0 ) params = {}; - if (ColormakerRegistry$1.hasScheme(scheme)) { - Object.assign(params, { - scheme: scheme, - structure: this$1.parameters.structure - }); - } - else { - Object.assign(params, { - scheme: 'uniform', - value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](scheme).getHex() - }); - } - this$1.colormakerList.push(ColormakerRegistry$1.getScheme(params)); - this$1.selectionList.push(new Selection(sele)); - }); - } - - if ( Colormaker$$1 ) SelectionColormaker.__proto__ = Colormaker$$1; - SelectionColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - SelectionColormaker.prototype.constructor = SelectionColormaker; - SelectionColormaker.prototype.atomColor = function atomColor (a) { - for (var i = 0, n = this.selectionList.length; i < n; ++i) { - var test = this.selectionList[i].test; - if (test && test(a)) { - return this.colormakerList[i].atomColor(a); - } - } - return 0xFFFFFF; - }; - - return SelectionColormaker; -}(Colormaker)); - -/** - * @file Colormaker Registry - * @author Alexander Rose - * @private - */ -var ColormakerScales = { - '': '', - // Sequential - OrRd: '[S] Orange-Red', - PuBu: '[S] Purple-Blue', - BuPu: '[S] Blue-Purple', - Oranges: '[S] Oranges', - BuGn: '[S] Blue-Green', - YlOrBr: '[S] Yellow-Orange-Brown', - YlGn: '[S] Yellow-Green', - Reds: '[S] Reds', - RdPu: '[S] Red-Purple', - Greens: '[S] Greens', - YlGnBu: '[S] Yellow-Green-Blue', - Purples: '[S] Purples', - GnBu: '[S] Green-Blue', - Greys: '[S] Greys', - YlOrRd: '[S] Yellow-Orange-Red', - PuRd: '[S] Purple-Red', - Blues: '[S] Blues', - PuBuGn: '[S] Purple-Blue-Green', - // Diverging - Viridis: '[D] Viridis', - Spectral: '[D] Spectral', - RdYlGn: '[D] Red-Yellow-Green', - RdBu: '[D] Red-Blue', - PiYG: '[D] Pink-Yellowgreen', - PRGn: '[D] Purplered-Green', - RdYlBu: '[D] Red-Yellow-Blue', - BrBG: '[D] Brown-Bluegreen', - RdGy: '[D] Red-Grey', - PuOr: '[D] Purple-Orange', - // Qualitative - Set1: '[Q] Set1', - Set2: '[Q] Set2', - Set3: '[Q] Set3', - Dark2: '[Q] Dark2', - Paired: '[Q] Paired', - Pastel1: '[Q] Pastel1', - Pastel2: '[Q] Pastel2', - Accent: '[Q] Accent', - // Other - rainbow: '[?] Rainbow', - rwb: '[?] Red-White-Blue' -}; -var ColormakerModes = { - '': '', - rgb: 'Red Green Blue', - hsv: 'Hue Saturation Value', - hsl: 'Hue Saturation Lightness', - hsi: 'Hue Saturation Intensity', - lab: 'CIE L*a*b*', - hcl: 'Hue Chroma Lightness' -}; -/** - * Class for registering {@link Colormaker}s. Generally use the - * global {@link src/globals.js~ColormakerRegistry} instance. - */ -var ColormakerRegistry = function ColormakerRegistry() { - this.schemes = {}; - this.userSchemes = {}; -}; -ColormakerRegistry.prototype.getScheme = function getScheme (params) { - var p = params || {}; - var id = (p.scheme || '').toLowerCase(); - var SchemeClass; - if (id in this.schemes) { - SchemeClass = this.schemes[id]; - } - else if (id in this.userSchemes) { - SchemeClass = this.userSchemes[id]; - } - else { - SchemeClass = Colormaker; - } - return new SchemeClass(params); -}; -/** - * Get an description of available schemes as an - * object with id-label as key-value pairs - * @return {Object} available schemes - */ -ColormakerRegistry.prototype.getSchemes = function getSchemes () { - var types = {}; - Object.keys(this.schemes).forEach(function (k) { - types[k] = k; - }); - Object.keys(this.userSchemes).forEach(function (k) { - types[k] = k.split('|')[1]; - }); - return types; -}; -/** - * Get an description of available scales as an - * object with id-label as key-value pairs - * @return {Object} available scales - */ -ColormakerRegistry.prototype.getScales = function getScales () { - return ColormakerScales; -}; -ColormakerRegistry.prototype.getModes = function getModes () { - return ColormakerModes; -}; -/** - * Add a scheme with a hardcoded id - * @param {String} id - the id - * @param {Colormaker} scheme - the colormaker - * @return {undefined} - */ -ColormakerRegistry.prototype.add = function add (id, scheme) { - id = id.toLowerCase(); - this.schemes[id] = scheme; -}; -/** - * Register a custom scheme - * - * @example - * // Create a class with a `atomColor` method that returns a hex color. - * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){ - * this.atomColor = function( atom ){ - * if( atom.serial < 1000 ){ - * return 0x0000FF; // blue - * }else if( atom.serial > 2000 ){ - * return 0xFF0000; // red - * }else{ - * return 0x00FF00; // green - * } - * }; - * } ); - * - * stage.loadFile( "rcsb://3dqb.pdb" ).then( function( o ){ - * o.addRepresentation( "cartoon", { color: schemeId } ); // pass schemeId here - * o.autoView(); - * } ); - * - * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance - * @param {String} label - scheme label - * @return {String} id to refer to the registered scheme - */ -ColormakerRegistry.prototype.addScheme = function addScheme (scheme, label) { - if (!(scheme instanceof Colormaker)) { - scheme = this._createScheme(scheme); - } - return this._addUserScheme(scheme, label); -}; -/** - * Add a user-defined scheme - * @param {Colormaker} scheme - the user-defined scheme - * @param {String} [label] - scheme label - * @return {String} id to refer to the registered scheme - */ -ColormakerRegistry.prototype._addUserScheme = function _addUserScheme (scheme, label) { - label = label || ''; - var id = ((generateUUID()) + "|" + label).toLowerCase(); - this.userSchemes[id] = scheme; - return id; -}; -/** - * Remove the scheme with the given id - * @param {String} id - scheme to remove - * @return {undefined} - */ -ColormakerRegistry.prototype.removeScheme = function removeScheme (id) { - id = id.toLowerCase(); - delete this.userSchemes[id]; -}; -ColormakerRegistry.prototype._createScheme = function _createScheme (constructor) { - var _Colormaker = function (params) { - Colormaker.call(this, params); - constructor.call(this, params); - }; - _Colormaker.prototype = Colormaker.prototype; - _Colormaker.prototype.constructor = Colormaker; - return _Colormaker; -}; -/** - * Create and a selection-based coloring scheme. Supply a list with pairs - * of colorname and selection for coloring by selections. Use the last - * entry as a default (catch all) coloring definition. - * - * @example - * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [ - * [ "red", "64-74 or 134-154 or 222-254 or 310-310 or 322-326" ], - * [ "green", "311-322" ], - * [ "yellow", "40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309" ], - * [ "blue", "1-39 or 96-112 or 174-201 or 278-288" ], - * [ "white", "*" ] - * ], "Transmembrane 3dqb" ); - * - * stage.loadFile( "rcsb://3dqb.pdb" ).then( function( o ){ - * o.addRepresentation( "cartoon", { color: schemeId } ); // pass schemeId here - * o.autoView(); - * } ); - * - * @param {Array} dataList - cloror-selection pairs - * @param {String} label - scheme name - * @return {String} id to refer to the registered scheme - */ -ColormakerRegistry.prototype.addSelectionScheme = function addSelectionScheme (dataList, label) { - var MySelectionColormaker = /*@__PURE__*/(function (SelectionColormaker$$1) { - function MySelectionColormaker(params) { - SelectionColormaker$$1.call(this, Object.assign({ dataList: dataList }, params)); - } - - if ( SelectionColormaker$$1 ) MySelectionColormaker.__proto__ = SelectionColormaker$$1; - MySelectionColormaker.prototype = Object.create( SelectionColormaker$$1 && SelectionColormaker$$1.prototype ); - MySelectionColormaker.prototype.constructor = MySelectionColormaker; - - return MySelectionColormaker; - }(SelectionColormaker)); - return this._addUserScheme(MySelectionColormaker, label); -}; -/** - * Check if a scheme with the given id exists - * @param {String} id - the id to check - * @return {Boolean} flag indicating if the scheme exists - */ -ColormakerRegistry.prototype.hasScheme = function hasScheme (id) { - id = id.toLowerCase(); - return id in this.schemes || id in this.userSchemes; -}; - -/** - * @file Parser Registry - * @author Alexander Rose - * @private - */ -var ParserRegistry = /*@__PURE__*/(function (Registry$$1) { - function ParserRegistry() { - Registry$$1.call(this, 'parser'); - } - - if ( Registry$$1 ) ParserRegistry.__proto__ = Registry$$1; - ParserRegistry.prototype = Object.create( Registry$$1 && Registry$$1.prototype ); - ParserRegistry.prototype.constructor = ParserRegistry; - ParserRegistry.prototype.__hasObjName = function __hasObjName (key, objName) { - var parser = this.get(key); - return parser && parser.prototype.__objName === objName; - }; - ParserRegistry.prototype.isTrajectory = function isTrajectory (key) { - return this.__hasObjName(key, 'frames'); - }; - ParserRegistry.prototype.isStructure = function isStructure (key) { - return this.__hasObjName(key, 'structure'); - }; - ParserRegistry.prototype.isVolume = function isVolume (key) { - return this.__hasObjName(key, 'volume'); - }; - ParserRegistry.prototype.isSurface = function isSurface (key) { - return this.__hasObjName(key, 'surface'); - }; - ParserRegistry.prototype.isBinary = function isBinary (key) { - var parser = this.get(key); - return parser && parser.prototype.isBinary; - }; - ParserRegistry.prototype.isXml = function isXml (key) { - var parser = this.get(key); - return parser && parser.prototype.isXml; - }; - ParserRegistry.prototype.isJson = function isJson (key) { - var parser = this.get(key); - return parser && parser.prototype.isJson; - }; - ParserRegistry.prototype.getTrajectoryExtensions = function getTrajectoryExtensions () { - var this$1 = this; - - return this.names.filter(function (name) { return this$1.isTrajectory(name); }); - }; - ParserRegistry.prototype.getStructureExtensions = function getStructureExtensions () { - var this$1 = this; - - return this.names.filter(function (name) { return this$1.isStructure(name); }); - }; - ParserRegistry.prototype.getVolumeExtensions = function getVolumeExtensions () { - var this$1 = this; - - return this.names.filter(function (name) { return this$1.isVolume(name); }); - }; - ParserRegistry.prototype.getSurfaceExtensions = function getSurfaceExtensions () { - var this$1 = this; - - return this.names.filter(function (name) { return this$1.isSurface(name); }); - }; - - return ParserRegistry; -}(Registry)); - -/** - * @file Worker Utils - * @author Alexander Rose - * @private - */ -function getWorkerDeps(vars) { - var deps = vars; - vars.forEach(function (sym) { - if (sym.__deps) { - Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps)); - } - }); - return deps; -} -function makeWorkerString(vars) { - var deps = uniqueArray(getWorkerDeps(vars)); - return deps.map(function (sym) { - return sym.toString(); - }).join('\n\n\n'); -} -function onmessage(e) { - var name = e.data.__name; - var postId = e.data.__postId; - /* global self */ - if (name === undefined) { - console.error('message __name undefined'); - } - else if (self.func === undefined) { - console.error('worker func undefined', name); - } - else { - var callback = function (aMessage, transferList) { - aMessage = aMessage || {}; - if (postId !== undefined) - { aMessage.__postId = postId; } - try { - self.postMessage(aMessage, transferList); - } - catch (error) { - console.error('self.postMessage:', error); - self.postMessage(aMessage); - } - }; - self.func(e, callback); - } -} -function makeWorkerBlob(func, deps) { - var str = "'use strict';\n\n" + makeWorkerString(deps); - str += '\n\n\nself.func = ' + func.toString() + ';'; - str += '\n\n\nself.onmessage = ' + onmessage.toString() + ';'; - // console.log(str); - return new Blob([str], { type: 'application/javascript' }); -} - -/** - * @file Worker Registry - * @author Alexander Rose - * @private - */ -var WorkerRegistry = function WorkerRegistry() { - this.activeWorkerCount = 0; - this._funcDict = {}; - this._depsDict = {}; - this._blobDict = {}; -}; -WorkerRegistry.prototype.add = function add (name, func, deps) { - this._funcDict[name] = func; - this._depsDict[name] = deps; -}; -WorkerRegistry.prototype.get = function get (name) { - if (!this._blobDict[name]) { - this._blobDict[name] = makeWorkerBlob(this._funcDict[name], this._depsDict[name]); - } - return this._blobDict[name]; -}; - -/** - * @file Globals - * @author Alexander Rose - * @private - */ -/** - * The browser name: "Opera", "Chrome", "Firefox", "Mobile Safari", - * "Internet Explorer", "Safari" or false. - */ -var Browser = getBrowser(); -/** - * Flag indicating support for the 'passive' option for event handler - */ -var SupportsPassiveEventHandler = false; -try { - // Test via a getter in the options object to see if the passive property is accessed - var opts = Object.defineProperty({}, 'passive', { - get: function () { - SupportsPassiveEventHandler = true; - } - }); - window.addEventListener('test', function (e) { }, opts); -} -catch (e) { } -/** - * Flag indicating a mobile browser - */ -var Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false; -var SupportsReadPixelsFloat = false; -function setSupportsReadPixelsFloat(value) { - SupportsReadPixelsFloat = value; -} -/** - * Flag indicating support for the `EXT_frag_depth` WebGL extension - * (Always present in WebGL2) - */ -var ExtensionFragDepth = false; -function setExtensionFragDepth(value) { - ExtensionFragDepth = value; -} -var Log = { - log: Function.prototype.bind.call(console.log, console), - info: Function.prototype.bind.call(console.info, console), - warn: Function.prototype.bind.call(console.warn, console), - error: Function.prototype.bind.call(console.error, console), - time: Function.prototype.bind.call(console.time, console), - timeEnd: Function.prototype.bind.call(console.timeEnd, console) -}; -var MeasurementDefaultParams = { - color: 'green', - labelColor: 0x808080, - labelAttachment: 'bottom-center', - labelSize: 0.7, - labelZOffset: 0.5, - labelYOffset: 0.1, - labelBorder: true, - labelBorderColor: 0xd3d3d3, - labelBorderWidth: 0.25, - lineOpacity: 0.8, - linewidth: 5.0, - opacity: 0.6, - labelUnit: 'angstrom', - arcVisible: true, - planeVisible: false -}; -function setMeasurementDefaultParams(params) { - if ( params === void 0 ) params = {}; - - Object.assign(MeasurementDefaultParams, params); -} -var Debug = boolean(getQuery('debug')); -function setDebug(value) { - Debug = value; -} -var WebglErrorMessage = '

Your browser/graphics card does not seem to support WebGL.

Find out how to get it here.

'; -/** - * List of file extensions to be recognized as scripts - */ -var ScriptExtensions = ['ngl', 'js']; -var WorkerRegistry$1 = new WorkerRegistry(); -var ColormakerRegistry$1 = new ColormakerRegistry(); -var DatasourceRegistry = new Registry('datasource'); -var RepresentationRegistry = new Registry('representatation'); -var ParserRegistry$1 = new ParserRegistry(); -var ShaderRegistry = new Registry('shader'); -var DecompressorRegistry = new Registry('decompressor'); -var ComponentRegistry = new Registry('component'); -var BufferRegistry = new Registry('buffer'); -var PickerRegistry = new Registry('picker'); -var ListingDatasource; -function setListingDatasource(value) { - ListingDatasource = value; -} -var TrajectoryDatasource; -function setTrajectoryDatasource(value) { - TrajectoryDatasource = value; -} - -/** - * @file Streamer - * @author Alexander Rose - * @private - */ -var Streamer = function Streamer(src, params) { - if ( params === void 0 ) params = {}; - - this.chunkSize = 1024 * 1024 * 10; - this.newline = '\n'; - this.__pointer = 0; - this.__partialLine = ''; - this.compressed = defaults(params.compressed, false); - this.binary = defaults(params.binary, false); - this.json = defaults(params.json, false); - this.xml = defaults(params.xml, false); - this.src = src; -}; -Streamer.prototype.isBinary = function isBinary () { - return this.binary || this.compressed; -}; -Streamer.prototype.read = function read () { - var this$1 = this; - - return this._read().then(function (data) { - var decompressFn = this$1.compressed ? DecompressorRegistry.get(this$1.compressed) : undefined; - if (this$1.compressed && decompressFn) { - this$1.data = decompressFn(data); - } - else { - if ((this$1.binary || this$1.compressed) && data instanceof ArrayBuffer) { - data = new Uint8Array(data); - } - this$1.data = data; - } - return this$1.data; - }); -}; -Streamer.prototype._chunk = function _chunk (start, end) { - end = Math.min(this.data.length, end); - if (start === 0 && this.data.length === end) { - return this.data; - } - else { - if (this.isBinary()) { - return this.data.subarray(start, end); - } - else { - return this.data.substring(start, end); - } - } -}; -Streamer.prototype.chunk = function chunk (start) { - var end = start + this.chunkSize; - return this._chunk(start, end); -}; -Streamer.prototype.peekLines = function peekLines (m) { - var data = this.data; - var n = data.length; - // FIXME does not work for multi-char newline - var newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline; - var i; - var count = 0; - for (i = 0; i < n; ++i) { - if (data[i] === newline) - { ++count; } - if (count === m) - { break; } - } - var chunk = this._chunk(0, i + 1); - var d = this.chunkToLines(chunk, '', i > n); - return d.lines; -}; -Streamer.prototype.chunkCount = function chunkCount () { - return Math.floor(this.data.length / this.chunkSize) + 1; -}; -Streamer.prototype.asText = function asText () { - return this.isBinary() ? uint8ToString(this.data) : this.data; -}; -Streamer.prototype.chunkToLines = function chunkToLines (chunk, partialLine, isLast) { - var newline = this.newline; - if (!this.isBinary() && chunk.length === this.data.length) { - return { - lines: chunk.split(newline), - partialLine: '' - }; - } - var lines = []; - var str = this.isBinary() ? uint8ToString(chunk) : chunk; - var idx = str.lastIndexOf(newline); - if (idx === -1) { - partialLine += str; - } - else { - var str2 = partialLine + str.substr(0, idx); - lines = lines.concat(str2.split(newline)); - if (idx === str.length - newline.length) { - partialLine = ''; - } - else { - partialLine = str.substr(idx + newline.length); - } - } - if (isLast && partialLine !== '') { - lines.push(partialLine); - } - return { - lines: lines, - partialLine: partialLine - }; -}; -Streamer.prototype.nextChunk = function nextChunk () { - var start = this.__pointer; - if (start > this.data.length) { - return undefined; - } - this.__pointer += this.chunkSize; - return this.chunk(start); -}; -Streamer.prototype.nextChunkOfLines = function nextChunkOfLines () { - var chunk = this.nextChunk(); - if (chunk === undefined) { - return undefined; - } - var isLast = this.__pointer > this.data.length; - var d = this.chunkToLines(chunk, this.__partialLine, isLast); - this.__partialLine = d.partialLine; - return d.lines; -}; -Streamer.prototype.eachChunk = function eachChunk (callback) { - var chunkSize = this.chunkSize; - var n = this.data.length; - var chunkCount = this.chunkCount(); - for (var i = 0; i < n; i += chunkSize) { - var chunk = this.chunk(i); - var chunkNo = Math.round(i / chunkSize); - callback(chunk, chunkNo, chunkCount); - } -}; -Streamer.prototype.eachChunkOfLines = function eachChunkOfLines (callback) { - var this$1 = this; - - this.eachChunk(function (chunk, chunkNo, chunkCount) { - var isLast = chunkNo === chunkCount + 1; - var d = this$1.chunkToLines(chunk, this$1.__partialLine, isLast); - this$1.__partialLine = d.partialLine; - callback(d.lines, chunkNo, chunkCount); - }); -}; -Streamer.prototype.dispose = function dispose () { - delete this.src; -}; - -/** - * @file File Streamer - * @author Alexander Rose - * @private - */ -var FileStreamer = /*@__PURE__*/(function (Streamer$$1) { - function FileStreamer () { - Streamer$$1.apply(this, arguments); - } - - if ( Streamer$$1 ) FileStreamer.__proto__ = Streamer$$1; - FileStreamer.prototype = Object.create( Streamer$$1 && Streamer$$1.prototype ); - FileStreamer.prototype.constructor = FileStreamer; - - FileStreamer.prototype._read = function _read () { - var this$1 = this; - - return new Promise(function (resolve, reject) { - var file = this$1.src; - var reader = new FileReader(); - reader.onload = function (event) { - if (event.target) - { resolve(event.target.result); } - }; - // if (typeof this.onprogress === 'function') { - // reader.onprogress = event => this.onprogress(event) - // } - reader.onerror = function (event) { return reject(event); }; - if (this$1.binary || this$1.compressed) { - reader.readAsArrayBuffer(file); - } - else { - reader.readAsText(file); - } - }); - }; - - return FileStreamer; -}(Streamer)); - -/** - * @file Network Streamer - * @author Alexander Rose - * @private - */ -var NetworkStreamer = /*@__PURE__*/(function (Streamer$$1) { - function NetworkStreamer () { - Streamer$$1.apply(this, arguments); - } - - if ( Streamer$$1 ) NetworkStreamer.__proto__ = Streamer$$1; - NetworkStreamer.prototype = Object.create( Streamer$$1 && Streamer$$1.prototype ); - NetworkStreamer.prototype.constructor = NetworkStreamer; - - NetworkStreamer.prototype._read = function _read () { - var this$1 = this; - - return new Promise(function (resolve, reject) { - var url = this$1.src; - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.addEventListener('load', function () { - if (xhr.status === 200 || xhr.status === 304 || - // when requesting from local file system - // the status in Google Chrome/Chromium is 0 - xhr.status === 0) { - try { - resolve(xhr.response); - } - catch (e) { - reject(e); - } - } - else { - reject(xhr.statusText); - } - }, false); - // if (typeof this.onprogress === 'function') { - // xhr.addEventListener('progress', event => this.onprogress(event), false); - // } - xhr.addEventListener('error', function (event) { return reject('network error'); }, false); - if (this$1.isBinary()) { - xhr.responseType = 'arraybuffer'; - } - else if (this$1.json) { - xhr.responseType = 'json'; - } - else if (this$1.xml) { - xhr.responseType = 'document'; - } - else { - xhr.responseType = 'text'; - } - // xhr.crossOrigin = true; - xhr.send(); - }); - }; - - return NetworkStreamer; -}(Streamer)); - -/** - * @file Loader - * @author Alexander Rose - * @private - */ -/** - * Loader parameter object. - * @typedef {Object} LoaderParameters - loader parameters - * @property {String} ext - file extension, determines file type - * @property {Boolean} compressed - flag data as compressed - * @property {Boolean} binary - flag data as binary - * @property {String} name - set data name - */ -/** - * Loader base class - */ -var Loader = function Loader(src, params) { - if ( params === void 0 ) params = {}; - - this.parameters = createParams(params, { - ext: '', - compressed: false, - binary: ParserRegistry$1.isBinary(params.ext || ''), - name: '', - dir: '', - path: '', - protocol: '' - }); - var streamerParams = { - compressed: this.parameters.compressed, - binary: this.parameters.binary, - json: ParserRegistry$1.isJson(this.parameters.ext), - xml: ParserRegistry$1.isXml(this.parameters.ext) - }; - if ((typeof File !== 'undefined' && src instanceof File) || - (typeof Blob !== 'undefined' && src instanceof Blob)) { - this.streamer = new FileStreamer(src, streamerParams); - } - else { - this.streamer = new NetworkStreamer(src, streamerParams); - } -}; - -/** - * @file Parser Loader - * @author Alexander Rose - * @private - */ -/** - * Parser loader class - * @extends Loader - */ -var ParserLoader = /*@__PURE__*/(function (Loader$$1) { - function ParserLoader(src, params) { - if ( params === void 0 ) params = {}; - - Loader$$1.call(this, src, params); - this.parserParams = { - voxelSize: params.voxelSize, - firstModelOnly: params.firstModelOnly, - asTrajectory: params.asTrajectory, - cAlphaOnly: params.cAlphaOnly, - delimiter: params.delimiter, - comment: params.comment, - columnNames: params.columnNames, - name: this.parameters.name, - path: this.parameters.path - }; - } - - if ( Loader$$1 ) ParserLoader.__proto__ = Loader$$1; - ParserLoader.prototype = Object.create( Loader$$1 && Loader$$1.prototype ); - ParserLoader.prototype.constructor = ParserLoader; - /** - * Load parsed object - * @return {Promise} resolves to the loaded & parsed {@link Structure}, - * {@link Volume}, {@link Surface} or data object - */ - ParserLoader.prototype.load = function load () { - var ParserClass = ParserRegistry$1.get(this.parameters.ext); - var parser = new ParserClass(this.streamer, this.parserParams); - return parser.parse(); - }; - - return ParserLoader; -}(Loader)); - -/** - * @file Script - * @author Alexander Rose - * @private - */ -/** - * Script class - */ -var Script = function Script(functionBody, name, path) { - this.name = name; - this.path = path; - this.signals = { - elementAdded: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - elementRemoved: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - nameChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.type = 'Script'; - this.dir = path.substring(0, path.lastIndexOf('/') + 1); - try { - /* eslint-disable no-new-func */ - this.fn = new Function('stage', '__name', '__path', '__dir', functionBody); - } - catch (e) { - Log.error('Script compilation failed', e); - this.fn = function () { }; - } -}; -/** - * Execute the script - * @param {Stage} stage - the stage context - * @return {Promise} - resolve when script finished running - */ -Script.prototype.run = function run (stage) { - var this$1 = this; - - return new Promise(function (resolve, reject) { - try { - this$1.fn.apply(null, [stage, this$1.name, this$1.path, this$1.dir]); - resolve(); - } - catch (e) { - Log.error('Script.fn', e); - reject(e); - } - }); -}; - -/** - * @file Script Loader - * @author Alexander Rose - * @private - */ -/** - * Script loader class - * @extends Loader - */ -var ScriptLoader = /*@__PURE__*/(function (Loader$$1) { - function ScriptLoader () { - Loader$$1.apply(this, arguments); - } - - if ( Loader$$1 ) ScriptLoader.__proto__ = Loader$$1; - ScriptLoader.prototype = Object.create( Loader$$1 && Loader$$1.prototype ); - ScriptLoader.prototype.constructor = ScriptLoader; - - ScriptLoader.prototype.load = function load () { - var this$1 = this; - - return this.streamer.read().then(function () { - return new Script(this$1.streamer.asText(), this$1.parameters.name, this$1.parameters.path); - }); - }; - - return ScriptLoader; -}(Loader)); - -/** - * @file Loader Utils - * @author Alexander Rose - * @private - */ -function getFileInfo(file) { - var compressedExtList = DecompressorRegistry.names; - var path; - var compressed; - var protocol = ''; - if (file instanceof File) { - path = file.name; - } - else if (file instanceof Blob) { - path = ''; - } - else { - path = file; - } - var queryIndex = path.lastIndexOf('?'); - var query = queryIndex !== -1 ? path.substring(queryIndex) : ''; - path = path.substring(0, queryIndex === -1 ? path.length : queryIndex); - var name = path.replace(/^.*[\\/]/, ''); - var base = name.substring(0, name.lastIndexOf('.')); - var nameSplit = name.split('.'); - var ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''; - var protocolMatch = path.match(/^(.+):\/\/(.+)$/); - if (protocolMatch) { - protocol = protocolMatch[1].toLowerCase(); - path = protocolMatch[2] || ''; - } - var dir = path.substring(0, path.lastIndexOf('/') + 1); - if (compressedExtList.includes(ext)) { - compressed = ext; - var n = path.length - ext.length - 1; - ext = (path.substr(0, n).split('.').pop() || '').toLowerCase(); - var m = base.length - ext.length - 1; - base = base.substr(0, m); - } - else { - compressed = false; - } - return { path: path, name: name, ext: ext, base: base, dir: dir, compressed: compressed, protocol: protocol, query: query, 'src': file }; -} -function getDataInfo(src) { - var info = getFileInfo(src); - var datasource = DatasourceRegistry.get(info.protocol); - if (datasource) { - info = getFileInfo(datasource.getUrl(info.src)); - if (!info.ext && datasource.getExt) { - info.ext = datasource.getExt(src); - } - } - return info; -} -/** - * Load a file - * - * @example - * // load from URL - * NGL.autoLoad( "http://files.rcsb.org/download/5IOS.cif" ); - * - * @example - * // load binary data in CCP4 format via a Blob - * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} ); - * NGL.autoLoad( binaryBlob, { ext: "ccp4" } ); - * - * @example - * // load string data in PDB format via a Blob - * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} ); - * NGL.autoLoad( stringBlob, { ext: "pdb" } ); - * - * @example - * // load a File object - * NGL.autoLoad( file ); - * - * @param {String|File|Blob} file - either a URL or an object containing the file data - * @param {LoaderParameters} params - loading parameters - * @return {Promise} Promise resolves to the loaded data - */ -function autoLoad(file, params) { - if ( params === void 0 ) params = {}; - - var p = Object.assign(getDataInfo(file), params); - var loader; - if (ParserRegistry$1.names.includes(p.ext)) { - loader = new ParserLoader(p.src, p); - } - else if (ScriptExtensions.includes(p.ext)) { - loader = new ScriptLoader(p.src, p); - } - if (loader) { - return loader.load(); - } - else { - return Promise.reject(new Error(("autoLoad: ext '" + (p.ext) + "' unknown"))); - } -} - -/** - * @file Writer - * @author Alexander Rose - * @private - */ -/** - * Base class for writers - * @interface - */ -var Writer = function Writer () {}; - -Writer.prototype.getBlob = function getBlob () { - return new Blob([this.getData()], { type: this.mimeType }); -}; -/** - * Trigger a download of the - * @param {[type]} name [description] - * @param {[type]} ext [description] - * @return {[type]} [description] - */ -Writer.prototype.download = function download$1 (name, ext) { - name = defaults(name, this.defaultName); - ext = defaults(ext, this.defaultExt); - download(this.getBlob(), (name + "." + ext)); -}; - -/** - * @file Pdb Writer - * @author Alexander Rose - * @private - */ -// http://www.wwpdb.org/documentation/file-format -// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line. -// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108 -var AtomFormat = 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s'; -var HetatmFormat = 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s'; -/** - * Create a PDB file from a Structure object - */ -var PdbWriter = /*@__PURE__*/(function (Writer$$1) { - function PdbWriter(structure, params) { - Writer$$1.call(this); - this.mimeType = 'text/plain'; - this.defaultName = 'structure'; - this.defaultExt = 'pdb'; - var p = Object.assign({}, params); - this.renumberSerial = defaults(p.renumberSerial, true); - this.remarks = ensureArray(defaults(p.remarks, [])); - this.structure = structure; - this._records = []; - } - - if ( Writer$$1 ) PdbWriter.__proto__ = Writer$$1; - PdbWriter.prototype = Object.create( Writer$$1 && Writer$$1.prototype ); - PdbWriter.prototype.constructor = PdbWriter; - PdbWriter.prototype._writeRecords = function _writeRecords () { - this._records.length = 0; - this._writeTitle(); - this._writeRemarks(); - this._writeAtoms(); - }; - PdbWriter.prototype._writeTitle = function _writeTitle () { - // FIXME multiline if title line longer than 80 chars - this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('TITLE %-74s', this.structure.name)); - }; - PdbWriter.prototype._writeRemarks = function _writeRemarks () { - var this$1 = this; - - this.remarks.forEach(function (str) { - this$1._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('REMARK %-73s', str)); - }); - if (this.structure.trajectory) { - this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('REMARK %-73s', "Trajectory '" + this.structure.trajectory.name + "'")); - this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('REMARK %-73s', ("Frame " + (this.structure.trajectory.frame)) // TODO - )); - } - }; - PdbWriter.prototype._writeAtoms = function _writeAtoms () { - var this$1 = this; - - var ia = 1; - var im = 1; - this.structure.eachModel(function (m) { - this$1._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('MODEL %-74d', im++)); - m.eachAtom(function (a) { - var formatString = a.hetero ? HetatmFormat : AtomFormat; - var serial = this$1.renumberSerial ? ia : a.serial; - // Alignment of one-letter atom name such as C starts at column 14, - // while two-letter atom name such as FE starts at column 13. - var atomname = a.atomname; - if (atomname.length === 1) - { atomname = ' ' + atomname; } - this$1._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(formatString, serial, atomname, a.resname, defaults(a.chainname, ' '), a.resno, a.x, a.y, a.z, defaults(a.occupancy, 1.0), defaults(a.bfactor, 0.0), '', // segid - defaults(a.element, ''))); - ia += 1; - }, this$1.structure.getSelection()); - this$1._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('%-80s', 'ENDMDL')); - im += 1; - }); - this._records.push(Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('%-80s', 'END')); - }; - PdbWriter.prototype.getString = function getString () { - console.warn('PdbWriter.getString() is deprecated, use .getData instead'); - return this.getData(); - }; - /** - * Get string containing the PDB file data - * @return {String} PDB file - */ - PdbWriter.prototype.getData = function getData () { - this._writeRecords(); - return this._records.join('\n'); - }; - - return PdbWriter; -}(Writer)); - -/** - * Writer class for sdf/mol files. - */ -// Hard-coded chiral as false as we don't specify it any atoms -var CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'; -var AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'; -var BondFormat = '%3i%3i%3i 0 0 0'; -var SdfWriter = /*@__PURE__*/(function (Writer$$1) { - function SdfWriter(structure) { - Writer$$1.call(this); - this.mimeType = 'text/plain'; - this.defaultName = 'structure'; - this.defaultExt = 'sdf'; - this.structure = structure; - // Follow the pdb-writer example: - this._records = []; - } - - if ( Writer$$1 ) SdfWriter.__proto__ = Writer$$1; - SdfWriter.prototype = Object.create( Writer$$1 && Writer$$1.prototype ); - SdfWriter.prototype.constructor = SdfWriter; - - var prototypeAccessors = { idString: { configurable: true },titleString: { configurable: true },countsString: { configurable: true },chargeLines: { configurable: true } }; - prototypeAccessors.idString.get = function () { - return this.structure.id; - }; - prototypeAccessors.titleString.get = function () { - return ' ' + this.structure.title; - }; - prototypeAccessors.countsString.get = function () { - return Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(CountFormat, this.structure.atomCount, this.structure.bondCount); - }; - prototypeAccessors.chargeLines.get = function () { - var pairs = []; - this.structure.eachAtom(function (ap) { - if (ap.formalCharge != null && ap.formalCharge !== 0) { - pairs.push([ap.index, ap.formalCharge]); - } - }); - var lines = []; - for (var i = 0; i < pairs.length; i += 8) { - var nCharges = Math.min(8, pairs.length - i); - var s = Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])('M CHG%3i', nCharges); - for (var j = i; j < i + nCharges; j++) { - s += Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(' %3i %3i', pairs[j][0] + 1, pairs[j][1]); - } - lines.push(s); - } - return lines; - }; - SdfWriter.prototype.formatAtom = function formatAtom (ap) { - var charge = 0; - if (ap.formalCharge != null && ap.formalCharge !== 0) { - charge = 4 - ap.formalCharge; - } - var line = Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(AtomLine, ap.x, ap.y, ap.z, ap.element, charge); - if (line.length !== 48) { - throw new Error('Incompatible atom for sdf format'); - } - return line; - }; - SdfWriter.prototype.formatBond = function formatBond (bp) { - return Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(BondFormat, bp.atomIndex1 + 1, bp.atomIndex2 + 1, bp.bondOrder); - }; - SdfWriter.prototype._writeRecords = function _writeRecords () { - this._records.length = 0; - this._writeHeader(); - this._writeCTab(); - this._writeFooter(); - }; - SdfWriter.prototype._writeHeader = function _writeHeader () { - this._records.push(this.idString, this.titleString, ''); - }; - SdfWriter.prototype._writeCTab = function _writeCTab () { - var this$1 = this; - - this._records.push(this.countsString); - this.structure.eachAtom(function (ap) { - this$1._records.push(this$1.formatAtom(ap)); - }); - this.structure.eachBond(function (bp) { - this$1._records.push(this$1.formatBond(bp)); - }); - this.chargeLines.forEach(function (line) { - this$1._records.push(line); - }); - this._records.push('M END'); - }; - SdfWriter.prototype._writeFooter = function _writeFooter () { - this._records.push('$$$$'); - }; - SdfWriter.prototype.getData = function getData () { - this._writeRecords(); - return this._records.join('\n'); - }; - - Object.defineProperties( SdfWriter.prototype, prototypeAccessors ); - - return SdfWriter; -}(Writer)); - -/** - * @file IO Buffer - * @author Alexander Rose - * @private - * - * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer - * MIT License, Copyright (c) 2015 Michaël Zasso - */ -var defaultByteLength = 1024 * 8; -var charArray = []; -/** - * Class for writing and reading binary data - */ -var IOBuffer = function IOBuffer(data, params) { - if ( params === void 0 ) params = {}; - - this._mark = 0; - this._marks = []; - this.offset = 0; // The current offset of the buffer's pointer - this.littleEndian = true; - var dataIsGiven = false; - if (data === undefined) { - data = defaultByteLength; - } - if (typeof data === 'number') { - data = new ArrayBuffer(data); - } - else { - dataIsGiven = true; - } - var offset = params.offset ? params.offset >>> 0 : 0; - var byteLength = data.byteLength - offset; - var dvOffset = offset; - if (!(data instanceof ArrayBuffer)) { - if (data.byteLength !== data.buffer.byteLength) { - dvOffset = data.byteOffset + offset; - } - data = data.buffer; - } - if (dataIsGiven) { - this._lastWrittenByte = byteLength; - } - else { - this._lastWrittenByte = 0; - } - this.buffer = data; - this.length = byteLength; - this.byteLength = byteLength; - this.byteOffset = dvOffset; - this._data = new DataView(this.buffer, dvOffset, byteLength); -}; -/** - * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset - * @param {number} [byteLength=1] The needed memory in bytes - * @return {boolean} Returns true if there is sufficient space and false otherwise - */ -IOBuffer.prototype.available = function available (byteLength) { - if (byteLength === undefined) - { byteLength = 1; } - return (this.offset + byteLength) <= this.length; -}; -/** - * Check if little-endian mode is used for reading and writing multi-byte values - * @return {boolean} Returns true if little-endian mode is used, false otherwise - */ -IOBuffer.prototype.isLittleEndian = function isLittleEndian () { - return this.littleEndian; -}; -/** - * Set little-endian mode for reading and writing multi-byte values - * @return {IOBuffer} - */ -IOBuffer.prototype.setLittleEndian = function setLittleEndian () { - this.littleEndian = true; - return this; -}; -/** - * Check if big-endian mode is used for reading and writing multi-byte values - * @return {boolean} Returns true if big-endian mode is used, false otherwise - */ -IOBuffer.prototype.isBigEndian = function isBigEndian () { - return !this.littleEndian; -}; -/** - * Switches to big-endian mode for reading and writing multi-byte values - * @return {IOBuffer} - */ -IOBuffer.prototype.setBigEndian = function setBigEndian () { - this.littleEndian = false; - return this; -}; -/** - * Move the pointer n bytes forward - * @param {number} n - * @return {IOBuffer} - */ -IOBuffer.prototype.skip = function skip (n) { - if (n === undefined) - { n = 1; } - this.offset += n; - return this; -}; -/** - * Move the pointer to the given offset - * @param {number} offset - * @return {IOBuffer} - */ -IOBuffer.prototype.seek = function seek (offset) { - this.offset = offset; - return this; -}; -/** - * Store the current pointer offset. - * @see {@link IOBuffer#reset} - * @return {IOBuffer} - */ -IOBuffer.prototype.mark = function mark () { - this._mark = this.offset; - return this; -}; -/** - * Move the pointer back to the last pointer offset set by mark - * @see {@link IOBuffer#mark} - * @return {IOBuffer} - */ -IOBuffer.prototype.reset = function reset () { - this.offset = this._mark; - return this; -}; -/** - * Push the current pointer offset to the mark stack - * @see {@link IOBuffer#popMark} - * @return {IOBuffer} - */ -IOBuffer.prototype.pushMark = function pushMark () { - this._marks.push(this.offset); - return this; -}; -/** - * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value - * @see {@link IOBuffer#pushMark} - * @return {IOBuffer} - */ -IOBuffer.prototype.popMark = function popMark () { - var offset = this._marks.pop(); - if (offset === undefined) - { throw new Error('Mark stack empty'); } - this.seek(offset); - return this; -}; -/** - * Move the pointer offset back to 0 - * @return {IOBuffer} - */ -IOBuffer.prototype.rewind = function rewind () { - this.offset = 0; - return this; -}; -/** - * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset - * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length - * that is twice (byteLength + current offset) - * @param {number} [byteLength = 1] - * @return {IOBuffer} - */ -IOBuffer.prototype.ensureAvailable = function ensureAvailable (byteLength) { - if (byteLength === undefined) - { byteLength = 1; } - if (!this.available(byteLength)) { - var lengthNeeded = this.offset + byteLength; - var newLength = lengthNeeded * 2; - var newArray = new Uint8Array(newLength); - newArray.set(new Uint8Array(this.buffer)); - this.buffer = newArray.buffer; - this.length = this.byteLength = newLength; - this._data = new DataView(this.buffer); - } - return this; -}; -/** - * Read a byte and return false if the byte's value is 0, or true otherwise - * Moves pointer forward - * @return {boolean} - */ -IOBuffer.prototype.readBoolean = function readBoolean () { - return this.readUint8() !== 0; -}; -/** - * Read a signed 8-bit integer and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readInt8 = function readInt8 () { - return this._data.getInt8(this.offset++); -}; -/** - * Read an unsigned 8-bit integer and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readUint8 = function readUint8 () { - return this._data.getUint8(this.offset++); -}; -/** - * Alias for {@link IOBuffer#readUint8} - * @return {number} - */ -IOBuffer.prototype.readByte = function readByte () { - return this.readUint8(); -}; -/** - * Read n bytes and move pointer forward. - * @param {number} n - * @return {Uint8Array} - */ -IOBuffer.prototype.readBytes = function readBytes (n) { - if (n === undefined) - { n = 1; } - var bytes = new Uint8Array(n); - for (var i = 0; i < n; i++) { - bytes[i] = this.readByte(); - } - return bytes; -}; -/** - * Read a 16-bit signed integer and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readInt16 = function readInt16 () { - var value = this._data.getInt16(this.offset, this.littleEndian); - this.offset += 2; - return value; -}; -/** - * Read a 16-bit unsigned integer and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readUint16 = function readUint16 () { - var value = this._data.getUint16(this.offset, this.littleEndian); - this.offset += 2; - return value; -}; -/** - * Read a 32-bit signed integer and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readInt32 = function readInt32 () { - var value = this._data.getInt32(this.offset, this.littleEndian); - this.offset += 4; - return value; -}; -/** - * Read a 32-bit unsigned integer and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readUint32 = function readUint32 () { - var value = this._data.getUint32(this.offset, this.littleEndian); - this.offset += 4; - return value; -}; -/** - * Read a 32-bit floating number and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readFloat32 = function readFloat32 () { - var value = this._data.getFloat32(this.offset, this.littleEndian); - this.offset += 4; - return value; -}; -/** - * Read a 64-bit floating number and move pointer forward - * @return {number} - */ -IOBuffer.prototype.readFloat64 = function readFloat64 () { - var value = this._data.getFloat64(this.offset, this.littleEndian); - this.offset += 8; - return value; -}; -/** - * Read 1-byte ascii character and move pointer forward - * @return {string} - */ -IOBuffer.prototype.readChar = function readChar () { - return String.fromCharCode(this.readInt8()); -}; -/** - * Read n 1-byte ascii characters and move pointer forward - * @param {number} n - * @return {string} - */ -IOBuffer.prototype.readChars = function readChars (n) { - if ( n === void 0 ) n = 1; - - charArray.length = n; - for (var i = 0; i < n; i++) { - charArray[i] = this.readChar(); - } - return charArray.join(''); -}; -/** - * Write 0xff if the passed value is truthy, 0x00 otherwise - * @param {any} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeBoolean = function writeBoolean (value) { - if ( value === void 0 ) value = false; - - this.writeUint8(value ? 0xff : 0x00); - return this; -}; -/** - * Write value as an 8-bit signed integer - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeInt8 = function writeInt8 (value) { - this.ensureAvailable(1); - this._data.setInt8(this.offset++, value); - this._updateLastWrittenByte(); - return this; -}; -/** - * Write value as a 8-bit unsigned integer - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeUint8 = function writeUint8 (value) { - this.ensureAvailable(1); - this._data.setUint8(this.offset++, value); - this._updateLastWrittenByte(); - return this; -}; -/** - * An alias for {@link IOBuffer#writeUint8} - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeByte = function writeByte (value) { - return this.writeUint8(value); -}; -/** - * Write bytes - * @param {Array|Uint8Array} bytes - * @return {IOBuffer} - */ -IOBuffer.prototype.writeBytes = function writeBytes (bytes) { - this.ensureAvailable(bytes.length); - for (var i = 0; i < bytes.length; i++) { - this._data.setUint8(this.offset++, bytes[i]); - } - this._updateLastWrittenByte(); - return this; -}; -/** - * Write value as an 16-bit signed integer - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeInt16 = function writeInt16 (value) { - this.ensureAvailable(2); - this._data.setInt16(this.offset, value, this.littleEndian); - this.offset += 2; - this._updateLastWrittenByte(); - return this; -}; -/** - * Write value as a 16-bit unsigned integer - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeUint16 = function writeUint16 (value) { - this.ensureAvailable(2); - this._data.setUint16(this.offset, value, this.littleEndian); - this.offset += 2; - this._updateLastWrittenByte(); - return this; -}; -/** - * Write a 32-bit signed integer at the current pointer offset - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeInt32 = function writeInt32 (value) { - this.ensureAvailable(4); - this._data.setInt32(this.offset, value, this.littleEndian); - this.offset += 4; - this._updateLastWrittenByte(); - return this; -}; -/** - * Write a 32-bit unsigned integer at the current pointer offset - * @param {number} value - The value to set - * @return {IOBuffer} - */ -IOBuffer.prototype.writeUint32 = function writeUint32 (value) { - this.ensureAvailable(4); - this._data.setUint32(this.offset, value, this.littleEndian); - this.offset += 4; - this._updateLastWrittenByte(); - return this; -}; -/** - * Write a 32-bit floating number at the current pointer offset - * @param {number} value - The value to set - * @return {IOBuffer} - */ -IOBuffer.prototype.writeFloat32 = function writeFloat32 (value) { - this.ensureAvailable(4); - this._data.setFloat32(this.offset, value, this.littleEndian); - this.offset += 4; - this._updateLastWrittenByte(); - return this; -}; -/** - * Write a 64-bit floating number at the current pointer offset - * @param {number} value - * @return {IOBuffer} - */ -IOBuffer.prototype.writeFloat64 = function writeFloat64 (value) { - this.ensureAvailable(8); - this._data.setFloat64(this.offset, value, this.littleEndian); - this.offset += 8; - this._updateLastWrittenByte(); - return this; -}; -/** - * Write the charCode of the passed string's first character to the current pointer offset - * @param {string} str - The character to set - * @return {IOBuffer} - */ -IOBuffer.prototype.writeChar = function writeChar (str) { - return this.writeUint8(str.charCodeAt(0)); -}; -/** - * Write the charCodes of the passed string's characters to the current pointer offset - * @param {string} str - * @return {IOBuffer} - */ -IOBuffer.prototype.writeChars = function writeChars (str) { - for (var i = 0; i < str.length; i++) { - this.writeUint8(str.charCodeAt(i)); - } - return this; -}; -/** - * Export a Uint8Array view of the internal buffer. - * The view starts at the byte offset and its length - * is calculated to stop at the last written byte or the original length. - * @return {Uint8Array} - */ -IOBuffer.prototype.toArray = function toArray () { - return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte); -}; -/** - * Update the last written byte offset - * @private - */ -IOBuffer.prototype._updateLastWrittenByte = function _updateLastWrittenByte () { - if (this.offset > this._lastWrittenByte) { - this._lastWrittenByte = this.offset; - } -}; - -/** - * @file STL Writer - * @author Paul Pillot - * @private - */ -// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL -/** - * Create an STL File from a surface Object (e.g. for 3D printing) - * - * @example - * molsurf = new MolecularSurface(structure) - * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4}) - * stl = new StlWriter(surf) - * stl.download('myFileName') - */ -var StlWriter = /*@__PURE__*/(function (Writer$$1) { - function StlWriter(surface) { - Writer$$1.call(this); - this.mimeType = 'application/vnd.ms-pki.stl'; - this.defaultName = 'surface'; - this.defaultExt = 'stl'; - this.surface = surface; - } - - if ( Writer$$1 ) StlWriter.__proto__ = Writer$$1; - StlWriter.prototype = Object.create( Writer$$1 && Writer$$1.prototype ); - StlWriter.prototype.constructor = StlWriter; - /* - * Get STL Binary data - * - * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js - * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description - * - * @return {DataView} the data - */ - StlWriter.prototype.getData = function getData () { - var triangles = this.surface.index.length / 3; - var bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4; - var output = new IOBuffer(bufferLength); - output.skip(80); // skip header - output.writeUint32(triangles); - var vector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vectorNorm1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vectorNorm2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vectorNorm3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - // traversing vertices - for (var i = 0; i < triangles; i++) { - var indices = [ - this.surface.index[i * 3], - this.surface.index[i * 3 + 1], - this.surface.index[i * 3 + 2] - ]; - vectorNorm1.fromArray(this.surface.normal, indices[0] * 3); - vectorNorm2.fromArray(this.surface.normal, indices[1] * 3); - vectorNorm3.fromArray(this.surface.normal, indices[2] * 3); - vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize(); - output.writeFloat32(vector.x); - output.writeFloat32(vector.y); - output.writeFloat32(vector.z); - for (var j = 0; j < 3; j++) { - vector.fromArray(this.surface.position, indices[j] * 3); - output.writeFloat32(vector.x); // vertices - output.writeFloat32(vector.y); - output.writeFloat32(vector.z); - } - output.writeUint16(0); // attribute byte count - } - return new DataView(output.buffer); - }; - - return StlWriter; -}(Writer)); - -/** - * @file Counter - * @author Alexander Rose - * @private - */ -/** - * Counter class for keeping track of counts - */ -var Counter = function Counter() { - this.count = 0; - this.signals = { - countChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; -}; -/** - * Set the `count` to zero - * @return {undefined} - */ -Counter.prototype.clear = function clear () { - this.change(-this.count); -}; -/** - * Change the `count` - * @fires Counter#countChanged - * @param {Integer} delta - count change - * @return {undefined} - */ -Counter.prototype.change = function change (delta) { - this.count += delta; - this.signals.countChanged.dispatch(delta, this.count); - if (this.count < 0) { - Log.warn('Counter.count below zero', this.count); - } -}; -/** - * Increments the `count` by one. - * @return {undefined} - */ -Counter.prototype.increment = function increment () { - this.change(1); -}; -/** - * Decrements the `count` by one. - * @return {undefined} - */ -Counter.prototype.decrement = function decrement () { - this.change(-1); -}; -/** - * Listen to another counter object and change this `count` by the - * same amount - * @param {Counter} counter - the counter object to listen to - * @return {undefined} - */ -Counter.prototype.listen = function listen (counter) { - this.change(counter.count); - counter.signals.countChanged.add(this.change, this); -}; -/** - * Stop listening to the other counter object - * @param {Counter} counter - the counter object to stop listening to - * @return {undefined} - */ -Counter.prototype.unlisten = function unlisten (counter) { - var countChanged = counter.signals.countChanged; - if (countChanged.has(this.change, this)) { - countChanged.remove(this.change, this); - } -}; -/** - * Invole the callback function once, when the `count` becomes zero - * @param {Function} callback - the callback function - * @param {Object} context - the context for the callback function - * @return {undefined} - */ -Counter.prototype.onZeroOnce = function onZeroOnce (callback, context) { - var this$1 = this; - - if (this.count === 0) { - callback.call(context); - } - else { - var fn = function () { - if (this$1.count === 0) { - this$1.signals.countChanged.remove(fn, this$1); - callback.call(context); - } - }; - this.signals.countChanged.add(fn, this); - } -}; -Counter.prototype.dispose = function dispose () { - this.clear(); - this.signals.countChanged.dispose(); -}; - -ShaderRegistry.add('shader/BasicLine.vert', "void main(){\n#include begin_vertex\n#include project_vertex\n}"); - -ShaderRegistry.add('shader/BasicLine.frag', "uniform vec3 uColor;\n#include common\n#include fog_pars_fragment\nvoid main(){\ngl_FragColor = vec4( uColor, 1.0 );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"); - -ShaderRegistry.add('shader/Quad.vert', "varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"); - -ShaderRegistry.add('shader/Quad.frag', "varying vec2 vUv;\nuniform sampler2D tForeground;\nuniform float scale;\nvoid main() {\nvec4 foreground = texture2D( tForeground, vUv );\ngl_FragColor = foreground * scale;\n}"); - -/** - * @file Stats - * @author Alexander Rose - * @private - */ -var Stats = function Stats() { - this.signals = { - updated: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.maxDuration = -Infinity; - this.minDuration = Infinity; - this.avgDuration = 14; - this.lastDuration = Infinity; - this.prevFpsTime = 0; - this.lastFps = Infinity; - this.lastFrames = 1; - this.frames = 0; - this.count = 0; - this.begin(); -}; -Stats.prototype.update = function update () { - this.startTime = this.end(); - this.currentTime = this.startTime; - this.signals.updated.dispatch(); -}; -Stats.prototype.begin = function begin () { - this.startTime = window.performance.now(); - this.lastFrames = this.frames; -}; -Stats.prototype.end = function end () { - var time = window.performance.now(); - this.count += 1; - this.frames += 1; - this.lastDuration = time - this.startTime; - this.minDuration = Math.min(this.minDuration, this.lastDuration); - this.maxDuration = Math.max(this.maxDuration, this.lastDuration); - this.avgDuration -= this.avgDuration / 30; - this.avgDuration += this.lastDuration / 30; - if (time > this.prevFpsTime + 1000) { - this.lastFps = this.frames; - this.prevFpsTime = time; - this.frames = 0; - } - return time; -}; - -ShaderRegistry.add('shader/chunk/fog_fragment.glsl', "#ifdef USE_FOG\nfloat depth = length( vViewPosition );\n#ifdef FOG_EXP2\nfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"); - -ShaderRegistry.add('shader/chunk/interior_fragment.glsl', "if( gl_FrontFacing == false ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}"); - -ShaderRegistry.add('shader/chunk/matrix_scale.glsl', "float matrixScale( in mat4 m ){\nvec4 r = m[ 0 ];\nreturn sqrt( r[ 0 ] * r[ 0 ] + r[ 1 ] * r[ 1 ] + r[ 2 ] * r[ 2 ] );\n}"); - -ShaderRegistry.add('shader/chunk/nearclip_vertex.glsl', "#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"); - -ShaderRegistry.add('shader/chunk/nearclip_fragment.glsl', "#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"); - -ShaderRegistry.add('shader/chunk/opaque_back_fragment.glsl', "#ifdef OPAQUE_BACK\n#ifdef FLIP_SIDED\nif( gl_FrontFacing == true ){\ngl_FragColor.a = 1.0;\n}\n#else\nif( gl_FrontFacing == false ){\ngl_FragColor.a = 1.0;\n}\n#endif\n#endif"); - -ShaderRegistry.add('shader/chunk/radiusclip_vertex.glsl', "#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius + 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"); - -ShaderRegistry.add('shader/chunk/radiusclip_fragment.glsl', "#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"); - -ShaderRegistry.add('shader/chunk/unpack_color.glsl', "vec3 unpackColor(float f) {\nvec3 color;\ncolor.r = floor(f / 256.0 / 256.0);\ncolor.g = floor((f - color.r * 256.0 * 256.0) / 256.0);\ncolor.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);\nreturn color / 255.0;\n}"); - -/** - * @file Shader Utils - * @author Alexander Rose - * @private - */ -function getDefines(defines) { - if (defines === undefined) - { return ''; } - var lines = []; - for (var name in defines) { - var value = defines[name]; - if (!value) - { continue; } - lines.push(("#define " + name + " " + value)); - } - return lines.join('\n') + '\n'; -} -var reInclude = /^(?!\/\/)\s*#include\s+(\S+)/gmi; -var shaderCache = {}; -function getShader(name, defines) { - if ( defines === void 0 ) defines = {}; - - var hash = name + '|'; - for (var key in defines) { - hash += key + ':' + defines[key]; - } - if (!shaderCache[hash]) { - var definesText = getDefines(defines); - var shaderText = ShaderRegistry.get(("shader/" + name)); - if (!shaderText) { - throw new Error(("empty shader, '" + name + "'")); - } - shaderText = shaderText.replace(reInclude, function (match, p1) { - var path = "shader/chunk/" + p1 + ".glsl"; - var chunk = ShaderRegistry.get(path) || __WEBPACK_IMPORTED_MODULE_0_three__["M" /* ShaderChunk */][p1]; - if (!chunk) { - throw new Error(("empty chunk, '" + p1 + "'")); - } - return chunk; - }); - shaderCache[hash] = definesText + shaderText; - } - return shaderCache[hash]; -} - -/** - * @file Viewer Constants - * @author Alexander Rose - * @private - */ -if (typeof WebGLRenderingContext !== 'undefined') { - var wrcp = WebGLRenderingContext.prototype; - // wrap WebGL debug function used by three.js and - // ignore calls to them when the debug flag is not set - var _getShaderParameter = wrcp.getShaderParameter; - wrcp.getShaderParameter = function getShaderParameter() { - if (Debug) { - return _getShaderParameter.apply(this, arguments); - } - else { - return true; - } - }; - var _getShaderInfoLog = wrcp.getShaderInfoLog; - wrcp.getShaderInfoLog = function getShaderInfoLog() { - if (Debug) { - return _getShaderInfoLog.apply(this, arguments); - } - else { - return ''; - } - }; - var _getProgramParameter = wrcp.getProgramParameter; - wrcp.getProgramParameter = function getProgramParameter(program, pname) { - if (Debug || pname !== wrcp.LINK_STATUS) { - return _getProgramParameter.apply(this, arguments); - } - else { - return true; - } - }; - var _getProgramInfoLog = wrcp.getProgramInfoLog; - wrcp.getProgramInfoLog = function getProgramInfoLog() { - if (Debug) { - return _getProgramInfoLog.apply(this, arguments); - } - else { - return ''; - } - }; -} -var JitterVectors = [ - [ - [0, 0] - ], - [ - [4, 4], [-4, -4] - ], - [ - [-2, -6], [6, -2], [-6, 2], [2, 6] - ], - [ - [1, -3], [-1, 3], [5, 1], [-3, -5], - [-5, 5], [-7, -1], [3, 7], [7, -7] - ], - [ - [1, 1], [-1, -3], [-3, 2], [4, -1], - [-5, -2], [2, 5], [5, 3], [3, -5], - [-2, 6], [0, -7], [-4, -6], [-6, 4], - [-8, 0], [7, -4], [6, 7], [-7, -8] - ], - [ - [-4, -7], [-7, -5], [-3, -5], [-5, -4], - [-1, -4], [-2, -2], [-6, -1], [-4, 0], - [-7, 1], [-1, 2], [-6, 3], [-3, 3], - [-7, 6], [-3, 6], [-5, 7], [-1, 7], - [5, -7], [1, -6], [6, -5], [4, -4], - [2, -3], [7, -2], [1, -1], [4, -1], - [2, 1], [6, 2], [0, 4], [4, 4], - [2, 5], [7, 5], [5, 6], [3, 7] - ] -]; -JitterVectors.forEach(function (offsetList) { - offsetList.forEach(function (offset) { - // 0.0625 = 1 / 16 - offset[0] *= 0.0625; - offset[1] *= 0.0625; - }); -}); - -/** - * @file Tiled Renderer - * @author Alexander Rose - * @private - */ -var TiledRenderer = function TiledRenderer(renderer, camera, viewer, params) { - this.canvas = document.createElement('canvas'); - this._viewer = viewer; - this._factor = defaults(params.factor, 2); - this._antialias = defaults(params.antialias, false); - this._onProgress = params.onProgress; - this._onFinish = params.onFinish; - if (this._antialias) - { this._factor *= 2; } - this._n = this._factor * this._factor; - // canvas - this._width = this._viewer.width; - this._height = this._viewer.height; - if (this._antialias) { - this.canvas.width = this._width * this._factor / 2; - this.canvas.height = this._height * this._factor / 2; - } - else { - this.canvas.width = this._width * this._factor; - this.canvas.height = this._height * this._factor; - } - this._ctx = this.canvas.getContext('2d'); - this._viewerSampleLevel = viewer.sampleLevel; - this._viewer.setSampling(-1); -}; -TiledRenderer.prototype._renderTile = function _renderTile (i) { - var viewer = this._viewer; - var width = this._width; - var height = this._height; - var factor = this._factor; - var x = i % factor; - var y = Math.floor(i / factor); - var offsetX = x * width; - var offsetY = y * height; - viewer.camera.setViewOffset(width * factor, height * factor, offsetX, offsetY, width, height); - viewer.render(); - if (this._antialias) { - var w = Math.round((offsetX + width) / 2) - Math.round(offsetX / 2); - var h = Math.round((offsetY + height) / 2) - Math.round(offsetY / 2); - this._ctx.drawImage(viewer.renderer.domElement, Math.round(offsetX / 2), Math.round(offsetY / 2), w, h); - } - else { - this._ctx.drawImage(viewer.renderer.domElement, Math.floor(offsetX), Math.floor(offsetY), Math.ceil(width), Math.ceil(height)); - } - if (typeof this._onProgress === 'function') { - this._onProgress(i + 1, this._n, false); - } -}; -TiledRenderer.prototype._finalize = function _finalize () { - this._viewer.setSampling(this._viewerSampleLevel); - this._viewer.camera.view = null; // TODO - if (typeof this._onFinish === 'function') { - this._onFinish(this._n + 1, this._n, false); - } -}; -TiledRenderer.prototype.render = function render () { - for (var i = 0; i <= this._n; ++i) { - if (i === this._n) { - this._finalize(); - } - else { - this._renderTile(i); - } - } -}; -TiledRenderer.prototype.renderAsync = function renderAsync () { - var this$1 = this; - - var count = 0; - var n = this._n; - var fn = function () { - if (count === n) { - this$1._finalize(); - } - else { - this$1._renderTile(count); - } - count += 1; - }; - for (var i = 0; i <= n; ++i) { - setTimeout(fn, 0); - } -}; - -/** - * @file Math Constants - * @author Alexander Rose - * @private - */ -var TwoPI = 2 * Math.PI; -var DEG2RAD = Math.PI / 180; -var RAD2DEG = 180 / Math.PI; - -/** - * @file Array Utils - * @author Alexander Rose - * @private - */ -function circularMean(array, max, stride, offset, indices) { - if ( stride === void 0 ) stride = 1; - if ( offset === void 0 ) offset = 0; - - // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions - // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60. - // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions - var n = indices ? indices.length : array.length / stride; - var cosMean = 0; - var sinMean = 0; - if (indices) { - for (var i = 0; i < n; ++i) { - var c = (array[indices[i] * stride + offset] + max) % max; - var angle = (c / max) * TwoPI - Math.PI; - cosMean += Math.cos(angle); - sinMean += Math.sin(angle); - } - } - else { - for (var i$1 = offset; i$1 < n; i$1 += stride) { - var c$1 = (array[i$1] + max) % max; - var angle$1 = (c$1 / max) * TwoPI - Math.PI; - cosMean += Math.cos(angle$1); - sinMean += Math.sin(angle$1); - } - } - cosMean /= n; - sinMean /= n; - var meanAngle = Math.atan2(sinMean, cosMean); - var mean = (meanAngle + Math.PI) / TwoPI * max; - return mean; -} -function calculateCenterArray(array1, array2, center, offset) { - if ( offset === void 0 ) offset = 0; - - var n = array1.length; - var c = center || new Float32Array(n); - for (var i = 0; i < n; i += 3) { - c[offset + i + 0] = (array1[i + 0] + array2[i + 0]) / 2.0; - c[offset + i + 1] = (array1[i + 1] + array2[i + 1]) / 2.0; - c[offset + i + 2] = (array1[i + 2] + array2[i + 2]) / 2.0; - } - return c; -} -function calculateDirectionArray(array1, array2) { - var n = array1.length; - var direction = new Float32Array(n); - for (var i = 0; i < n; i += 3) { - direction[i + 0] = array2[i + 0] - array1[i + 0]; - direction[i + 1] = array2[i + 1] - array1[i + 1]; - direction[i + 2] = array2[i + 2] - array1[i + 2]; - } - return direction; -} -function uniformArray(n, a, optionalTarget) { - var array = optionalTarget || new Float32Array(n); - for (var i = 0; i < n; ++i) { - array[i] = a; - } - return array; -} -function uniformArray3(n, a, b, c, optionalTarget) { - var array = optionalTarget || new Float32Array(n * 3); - for (var i = 0; i < n; ++i) { - var j = i * 3; - array[j + 0] = a; - array[j + 1] = b; - array[j + 2] = c; - } - return array; -} -function centerArray3(array, center) { - if ( center === void 0 ) center = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - - var n = array.length; - for (var i = 0; i < n; i += 3) { - center.x += array[i]; - center.y += array[i + 1]; - center.z += array[i + 2]; - } - center.divideScalar(n / 3); - return center; -} -function serialArray(n) { - var array = new Float32Array(n); - for (var i = 0; i < n; ++i) { - array[i] = i; - } - return array; -} -function serialBlockArray(n, b, offset, optionalTarget) { - if ( offset === void 0 ) offset = 0; - - var array = optionalTarget || new Float32Array(n * b); - for (var i = 0; i < n; ++i) { - var k = offset + i * b; - for (var j = 0; j < b; ++j) { - array[k + j] = i; - } - } - return array; -} -function replicateArrayEntries(array, m) { - var n = array.length; - var repArr = new Float32Array(n * m); - for (var i = 0; i < n; ++i) { - var k = i * m; - var a = array[i]; - for (var j = 0; j < m; ++j) { - repArr[k + j] = a; - } - } - return repArr; -} -function replicateArray3Entries(array, m) { - var n = array.length / 3; - var repArr = new Float32Array(n * m * 3); - for (var i = 0; i < n; ++i) { - var v = i * 3; - var k = i * m * 3; - var a = array[v + 0]; - var b = array[v + 1]; - var c = array[v + 2]; - for (var j = 0; j < m; ++j) { - var l = k + j * 3; - repArr[l + 0] = a; - repArr[l + 1] = b; - repArr[l + 2] = c; - } - } - return repArr; -} -function calculateMinArray(array1, array2) { - var n = array1.length; - var min = new Float32Array(n); - for (var i = 0; i < n; i++) { - min[i] = Math.min(array1[i], array2[i]); - } - return min; -} -function copyArray(src, dst, srcOffset, dstOffset, length) { - for (var i = 0; i < length; ++i) { - dst[dstOffset + i] = src[srcOffset + i]; - } -} -function copyWithin(array, srcOffset, dstOffset, length) { - copyArray(array, array, srcOffset, dstOffset, length); -} -function quicksortCmp(arr, cmp, begin, end) { - if ( begin === void 0 ) begin = 0; - - cmp = cmp || function cmp(a, b) { - if (a > b) - { return 1; } - if (a < b) - { return -1; } - return 0; - }; - end = (end || arr.length) - 1; - var stack = []; - var sp = -1; - var left = begin; - var right = end; - var tmp; - function swap(a, b) { - var tmp2 = arr[a]; - arr[a] = arr[b]; - arr[b] = tmp2; - } - var i, j; - while (true) { - if (right - left <= 25) { - for (var k = left + 1; k <= right; ++k) { - tmp = arr[k]; - i = k - 1; - while (i >= left && cmp(arr[i], tmp) > 0) { - arr[i + 1] = arr[i]; - --i; - } - arr[i + 1] = tmp; - } - if (sp === -1) - { break; } - right = stack[sp--]; // ? - left = stack[sp--]; - } - else { - var median = (left + right) >> 1; - i = left + 1; - j = right; - swap(median, i); - if (cmp(arr[left], arr[right]) > 0) { - swap(left, right); - } - if (cmp(arr[i], arr[right]) > 0) { - swap(i, right); - } - if (cmp(arr[left], arr[i]) > 0) { - swap(left, i); - } - tmp = arr[i]; - while (true) { - do - { i++; } - while (cmp(arr[i], tmp) < 0); - do - { j--; } - while (cmp(arr[j], tmp) > 0); - if (j < i) - { break; } - swap(i, j); - } - arr[left + 1] = arr[j]; - arr[j] = tmp; - if (right - i + 1 >= j - left) { - stack[++sp] = i; - stack[++sp] = right; - right = j - 1; - } - else { - stack[++sp] = left; - stack[++sp] = j - 1; - left = i; - } - } - } - return arr; -} -function arrayMax(array) { - var max = -Infinity; - for (var i = 0, il = array.length; i < il; ++i) { - if (array[i] > max) - { max = array[i]; } - } - return max; -} -function arrayMin(array) { - var min = Infinity; - for (var i = 0, il = array.length; i < il; ++i) { - if (array[i] < min) - { min = array[i]; } - } - return min; -} -function arraySum(array, stride, offset) { - if ( stride === void 0 ) stride = 1; - if ( offset === void 0 ) offset = 0; - - var n = array.length; - var sum = 0; - for (var i = offset; i < n; i += stride) { - sum += array[i]; - } - return sum; -} -function arrayMean(array, stride, offset) { - if ( stride === void 0 ) stride = 1; - if ( offset === void 0 ) offset = 0; - - return arraySum(array, stride, offset) / (array.length / stride); -} -function arrayRms(array) { - var n = array.length; - var sumSq = 0; - for (var i = 0; i < n; ++i) { - var di = array[i]; - sumSq += di * di; - } - return Math.sqrt(sumSq / n); -} - -/** - * @file Viewer Utils - * @author Alexander Rose - * @private - */ -function _trimCanvas(canvas, r, g, b, a) { - var canvasHeight = canvas.height; - var canvasWidth = canvas.width; - var ctx = canvas.getContext('2d'); - var pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data; - var x, y, doBreak, off; - doBreak = false; - for (y = 0; y < canvasHeight; y++) { - for (x = 0; x < canvasWidth; x++) { - off = (y * canvasWidth + x) * 4; - if (pixels[off] !== r || pixels[off + 1] !== g || - pixels[off + 2] !== b || pixels[off + 3] !== a) { - doBreak = true; - break; - } - } - if (doBreak) { - break; - } - } - var topY = y; - doBreak = false; - for (x = 0; x < canvasWidth; x++) { - for (y = 0; y < canvasHeight; y++) { - off = (y * canvasWidth + x) * 4; - if (pixels[off] !== r || pixels[off + 1] !== g || - pixels[off + 2] !== b || pixels[off + 3] !== a) { - doBreak = true; - break; - } - } - if (doBreak) { - break; - } - } - var topX = x; - doBreak = false; - for (y = canvasHeight - 1; y >= 0; y--) { - for (x = canvasWidth - 1; x >= 0; x--) { - off = (y * canvasWidth + x) * 4; - if (pixels[off] !== r || pixels[off + 1] !== g || - pixels[off + 2] !== b || pixels[off + 3] !== a) { - doBreak = true; - break; - } - } - if (doBreak) { - break; - } - } - var bottomY = y; - doBreak = false; - for (x = canvasWidth - 1; x >= 0; x--) { - for (y = canvasHeight - 1; y >= 0; y--) { - off = (y * canvasWidth + x) * 4; - if (pixels[off] !== r || pixels[off + 1] !== g || - pixels[off + 2] !== b || pixels[off + 3] !== a) { - doBreak = true; - break; - } - } - if (doBreak) { - break; - } - } - var bottomX = x; - var trimedCanvas = document.createElement('canvas'); - trimedCanvas.width = bottomX - topX; - trimedCanvas.height = bottomY - topY; - var trimedCtx = trimedCanvas.getContext('2d'); - trimedCtx.drawImage(canvas, topX, topY, trimedCanvas.width, trimedCanvas.height, 0, 0, trimedCanvas.width, trimedCanvas.height); - return trimedCanvas; -} -/** - * Image parameter object. - * @typedef {Object} ImageParameters - image generation parameters - * @property {Boolean} trim - trim the image - * @property {Integer} factor - scaling factor to apply to the viewer canvas - * @property {Boolean} antialias - antialias the image - * @property {Boolean} transparent - transparent image background - */ -var ImageDefaultParameters = { - trim: false, - factor: 1, - antialias: false, - transparent: false, - onProgress: undefined -}; -/** - * Make image from what is shown in a viewer canvas - * @param {Viewer} viewer - the viewer - * @param {ImageParameters} params - parameters object - * @return {Promise} A Promise object that resolves to an image {@link Blob}. - */ -function makeImage(viewer, params) { - if ( params === void 0 ) params = {}; - - var ref = createParams(params, ImageDefaultParameters); - var trim = ref.trim; - var factor = ref.factor; - var antialias = ref.antialias; - var transparent = ref.transparent; - var renderer = viewer.renderer; - var camera = viewer.camera; - var originalClearAlpha = renderer.getClearAlpha(); - var backgroundColor = renderer.getClearColor(); - function setLineWidthAndPixelSize(invert) { - if ( invert === void 0 ) invert = false; - - var _factor = factor; - if (antialias) - { _factor *= 2; } - if (invert) - { _factor = 1 / _factor; } - viewer.scene.traverse(function (o) { - var m = o.material; - if (m && m.linewidth) { - m.linewidth *= _factor; - } - if (m && m.uniforms && m.uniforms.size) { - if (m.uniforms.size.__seen === undefined) { - m.uniforms.size.value *= _factor; - m.uniforms.size.__seen = true; - } - } - if (m && m.uniforms && m.uniforms.linewidth) { - if (m.uniforms.linewidth.__seen === undefined) { - m.uniforms.linewidth.value *= _factor; - m.uniforms.linewidth.__seen = true; - } - } - }); - viewer.scene.traverse(function (o) { - var m = o.material; - if (m && m.uniforms && m.uniforms.size) { - delete m.uniforms.size.__seen; - } - if (m && m.uniforms && m.uniforms.linewidth) { - delete m.uniforms.linewidth.__seen; - } - }); - } - function trimCanvas(canvas) { - if (trim) { - var bg = backgroundColor; - var r = transparent ? 0 : bg.r * 255; - var g = transparent ? 0 : bg.g * 255; - var b = transparent ? 0 : bg.b * 255; - var a = transparent ? 0 : 255; - return _trimCanvas(canvas, r, g, b, a); - } - else { - return canvas; - } - } - function onProgress(i, n, finished) { - if (typeof params.onProgress === 'function') { - params.onProgress(i, n, finished); - } - } - return new Promise(function (resolve, reject) { - var tiledRenderer = new TiledRenderer(renderer, camera, viewer, { factor: factor, antialias: antialias, onProgress: onProgress, onFinish: onFinish }); - renderer.setClearAlpha(transparent ? 0 : 1); - setLineWidthAndPixelSize(); - tiledRenderer.renderAsync(); - function onFinish(i, n) { - var canvas = trimCanvas(tiledRenderer.canvas); - canvas.toBlob(function (blob) { - renderer.setClearAlpha(originalClearAlpha); - setLineWidthAndPixelSize(true); - viewer.requestRender(); - onProgress(n, n, true); - if (blob) { - resolve(blob); - } - else { - reject('error creating image'); - } - }, 'image/png'); - } - }); -} -var vertex = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var modelViewProjectionMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -function sortProjectedPosition(scene, camera) { - // console.time( "sort" ); - scene.traverseVisible(function (o) { - if (!(o instanceof __WEBPACK_IMPORTED_MODULE_0_three__["I" /* Points */]) || !o.userData.buffer.parameters.sortParticles) { - return; - } - var attributes = o.geometry.attributes; // TODO - var n = attributes.position.count; - if (n === 0) - { return; } - matrix.multiplyMatrices(camera.matrixWorldInverse, o.matrixWorld); - modelViewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, matrix); - var sortData, sortArray, zArray, cmpFn; - if (!o.userData.sortData) { - zArray = new Float32Array(n); - sortArray = new Uint32Array(n); - cmpFn = function (ai, bi) { - var a = zArray[ai]; - var b = zArray[bi]; - if (a > b) - { return 1; } - if (a < b) - { return -1; } - return 0; - }; - sortData = { - __zArray: zArray, - __sortArray: sortArray, - __cmpFn: cmpFn - }; - o.userData.sortData = sortData; - } - else { - sortData = o.userData.sortData; - zArray = sortData.__zArray; - sortArray = sortData.__sortArray; - cmpFn = sortData.__cmpFn; - } - for (var i = 0; i < n; ++i) { - vertex.fromArray(attributes.position.array, i * 3); - vertex.applyMatrix4(modelViewProjectionMatrix); - // negate, so that sorting order is reversed - zArray[i] = -vertex.z; - sortArray[i] = i; - } - quicksortCmp(sortArray, cmpFn); - var index, indexSrc, indexDst, tmpTab; - for (var name in attributes) { - var attr = attributes[name]; - var array = attr.array; - var itemSize = attr.itemSize; - if (!sortData[name]) { - sortData[name] = new Float32Array(itemSize * n); - } - tmpTab = sortData[name]; - sortData[name] = array; - for (var i$1 = 0; i$1 < n; ++i$1) { - index = sortArray[i$1]; - for (var j = 0; j < itemSize; ++j) { - indexSrc = index * itemSize + j; - indexDst = i$1 * itemSize + j; - tmpTab[indexDst] = array[indexSrc]; - } - } - attributes[name].array = tmpTab; - attributes[name].needsUpdate = true; - } - }); - // console.timeEnd( "sort" ); -} -var resolution = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); -var projectionMatrixInverse = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var projectionMatrixTranspose = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -function updateMaterialUniforms(group, camera, renderer, cDist, bRadius) { - var size = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); - renderer.getSize(size); - var canvasHeight = size.height; - var pixelRatio = renderer.getPixelRatio(); - var ortho = camera.type === 'OrthographicCamera'; - resolution.set(size.width, size.height); - projectionMatrixInverse.getInverse(camera.projectionMatrix); - projectionMatrixTranspose.copy(camera.projectionMatrix).transpose(); - group.traverse(function (o) { - var m = o.material; - if (!m) - { return; } - var u = m.uniforms; - if (!u) - { return; } - if (m.clipNear) { - var nearFactor = (50 - m.clipNear) / 50; - var nearClip = cDist - (bRadius * nearFactor); - u.clipNear.value = nearClip; - } - if (u.canvasHeight) { - u.canvasHeight.value = canvasHeight; - } - if (u.resolution) { - u.resolution.value.copy(resolution); - } - if (u.pixelRatio) { - u.pixelRatio.value = pixelRatio; - } - if (u.projectionMatrixInverse) { - u.projectionMatrixInverse.value.copy(projectionMatrixInverse); - } - if (u.projectionMatrixTranspose) { - u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose); - } - if (u.ortho) { - u.ortho.value = ortho; - } - }); -} -function updateCameraUniforms(group, camera) { - projectionMatrixInverse.getInverse(camera.projectionMatrix); - projectionMatrixTranspose.copy(camera.projectionMatrix).transpose(); - group.traverse(function (o) { - var m = o.material; - if (!m) - { return; } - var u = m.uniforms; - if (!u) - { return; } - if (u.projectionMatrixInverse) { - u.projectionMatrixInverse.value.copy(projectionMatrixInverse); - } - if (u.projectionMatrixTranspose) { - u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose); - } - }); -} - -/** - * @file Viewer - * @author Alexander Rose - * @private - */ -// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js -// Copyright 2012, Gregg Tavares. Modified BSD License -function createProgram(gl, shaders, attribs, locations) { - var program = gl.createProgram(); - if (!program) { - console.log("error creating WebGL program"); - return; - } - shaders.forEach(function (shader) { return gl.attachShader(program, shader); }); - if (attribs) { - attribs.forEach(function (attrib, i) { - gl.bindAttribLocation(program, locations ? locations[i] : i, attrib); - }); - } - gl.linkProgram(program); - // Check the link status - var linked = gl.getProgramParameter(program, gl.LINK_STATUS); - if (!linked) { - console.log(("error linking program: " + (gl.getProgramInfoLog(program)))); - gl.deleteProgram(program); - return null; - } - return program; -} -function loadShader(gl, shaderSource, shaderType) { - var shader = gl.createShader(shaderType); - if (!shader) { - console.log(("error creating WebGL shader " + shaderType)); - return; // can't create shader - } - gl.shaderSource(shader, shaderSource); - gl.compileShader(shader); - // Check the compile status - var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); - if (!compiled) { - console.log(("error compiling shader " + shader + ": " + (gl.getShaderInfoLog(shader)))); - gl.deleteShader(shader); - return null; - } - return shader; -} -// -function getErrorDescription(gl, error) { - switch (error) { - case gl.NO_ERROR: return 'no error'; - case gl.INVALID_ENUM: return 'invalid enum'; - case gl.INVALID_VALUE: return 'invalid value'; - case gl.INVALID_OPERATION: return 'invalid operation'; - case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'; - case gl.OUT_OF_MEMORY: return 'out of memory'; - case gl.CONTEXT_LOST_WEBGL: return 'context lost'; - } - return 'unknown error'; -} -function getExtension(gl, name) { - var ext = gl.getExtension(name); - if (!ext) - { console.log(("extension '" + name + "' not available")); } - return ext; -} -var TextureTestVertShader = "\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}"; -var TextureTestFragShader = "\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}"; -var TextureTestTexCoords = new Float32Array([ - -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0 -]); -function testTextureSupport(type) { - // adapted from - // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture - // Get A WebGL context - var canvas = document.createElement('canvas'); - canvas.width = 16; - canvas.height = 16; - canvas.style.width = 16 + 'px'; - canvas.style.height = 16 + 'px'; - var gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); - if (!gl) { - console.log(("error creating webgl context for " + type)); - return false; - } - if (!(gl instanceof WebGLRenderingContext)) { - console.log("Got unexpected type for WebGL rendering context"); - return false; - } - getExtension(gl, 'OES_texture_float'); - getExtension(gl, 'OES_texture_half_float'); - getExtension(gl, 'WEBGL_color_buffer_float'); - // setup shaders - var vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER); - var fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER); - if (!vertShader || !fragShader) - { return false; } - // setup program - var program = createProgram(gl, [vertShader, fragShader]); - if (!program) { - console.log("error creating WebGL program"); - return false; - } - gl.useProgram(program); - // look up where the vertex data needs to go. - var positionLocation = gl.getAttribLocation(program, "a_position"); - var colorLoc = gl.getUniformLocation(program, "u_color"); - if (!colorLoc) { - console.log("error getting 'u_color' uniform location"); - return false; - } - // provide texture coordinates for the rectangle. - var positionBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); - gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW); - gl.enableVertexAttribArray(positionLocation); - gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0); - var whiteTex = gl.createTexture(); - var whiteData = new Uint8Array([255, 255, 255, 255]); - gl.bindTexture(gl.TEXTURE_2D, whiteTex); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData); - var tex = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - var fb = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, fb); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0); - var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - if (status !== gl.FRAMEBUFFER_COMPLETE) { - console.log(("error creating framebuffer for " + type)); - return false; - } - // Draw the rectangle. - gl.bindTexture(gl.TEXTURE_2D, whiteTex); - gl.uniform4fv(colorLoc, [0, 10, 20, 1]); - gl.drawArrays(gl.TRIANGLES, 0, 6); - gl.bindTexture(gl.TEXTURE_2D, tex); - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - gl.clearColor(1, 0, 0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - gl.uniform4fv(colorLoc, [0, 1 / 10, 1 / 20, 1]); - gl.drawArrays(gl.TRIANGLES, 0, 6); - // Check if rendered correctly - var pixel = new Uint8Array(4); - gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel); - if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) { - console.log(("not able to actually render to " + type + " texture")); - return false; - } - // Check reading from float texture - if (type === gl.FLOAT) { - gl.bindFramebuffer(gl.FRAMEBUFFER, fb); - var floatPixel = new Float32Array(4); - gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel); - var error = gl.getError(); - if (error) { - console.log(("error reading pixels as float: '" + (getErrorDescription(gl, error)) + "'")); - return false; - } - } - return true; -} - -/** - * @file Viewer - * @author Alexander Rose - * @private - */ -var pixelBufferFloat = new Float32Array(4 * 25); -var pixelBufferUint = new Uint8Array(4 * 25); -// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels) -// We read the pixels in the order below to find what was picked. -// This starts at the center and tries successively further points. -// (Many points will be at equal distance to the center, their order -// is arbitrary). -var pixelOrder = [12, 7, 13, 17, 11, 6, 8, 18, 16, 2, 14, 22, 10, 1, 3, 9, 19, 23, 21, 15, 5, 0, 4, 24, 20]; -var tmpMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -function onBeforeRender(renderer, scene, camera, geometry, material /*, group */) { - var u = material.uniforms; - var updateList = []; - if (u.objectId) { - u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255; - updateList.push('objectId'); - } - if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose || - u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse) { - this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld); - } - if (u.modelViewMatrixInverse) { - u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix); - updateList.push('modelViewMatrixInverse'); - } - if (u.modelViewMatrixInverseTranspose) { - if (u.modelViewMatrixInverse) { - u.modelViewMatrixInverseTranspose.value.copy(u.modelViewMatrixInverse.value).transpose(); - } - else { - u.modelViewMatrixInverseTranspose.value - .getInverse(this.modelViewMatrix) - .transpose(); - } - updateList.push('modelViewMatrixInverseTranspose'); - } - if (u.modelViewProjectionMatrix) { - u.modelViewProjectionMatrix.value.multiplyMatrices(camera.projectionMatrix, this.modelViewMatrix); - updateList.push('modelViewProjectionMatrix'); - } - if (u.modelViewProjectionMatrixInverse) { - if (u.modelViewProjectionMatrix) { - tmpMatrix.copy(u.modelViewProjectionMatrix.value); - u.modelViewProjectionMatrixInverse.value.getInverse(tmpMatrix); - } - else { - tmpMatrix.multiplyMatrices(camera.projectionMatrix, this.modelViewMatrix); - u.modelViewProjectionMatrixInverse.value.getInverse(tmpMatrix); - } - updateList.push('modelViewProjectionMatrixInverse'); - } - if (updateList.length) { - var materialProperties = renderer.properties.get(material); - if (materialProperties.program) { - var gl = renderer.getContext(); - var p = materialProperties.program; - gl.useProgram(p.program); - var pu = p.getUniforms(); - updateList.forEach(function (name) { - pu.setValue(gl, name, u[name].value); - }); - } - } -} -/** - * Viewer class - * @class - * @param {String|Element} [idOrElement] - dom id or element - */ -var Viewer = function Viewer(idOrElement) { - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this.boundingBoxSize = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.boundingBoxLength = 0; - this.info = { - memory: { - programs: 0, - geometries: 0, - textures: 0 - }, - render: { - calls: 0, - vertices: 0, - faces: 0, - points: 0 - } - }; - this.distVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.signals = { - ticked: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - rendered: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - if (typeof idOrElement === 'string') { - var elm = document.getElementById(idOrElement); - if (elm === null) { - this.container = document.createElement('div'); - } - else { - this.container = elm; - } - } - else if (idOrElement instanceof HTMLElement) { - this.container = idOrElement; - } - else { - this.container = document.createElement('div'); - } - if (this.container === document.body) { - this.width = window.innerWidth || 1; - this.height = window.innerHeight || 1; - } - else { - var box = this.container.getBoundingClientRect(); - this.width = box.width || 1; - this.height = box.height || 1; - this.container.style.overflow = 'hidden'; - } - this.wrapper = document.createElement('div'); - this.wrapper.style.position = 'relative'; - this.container.appendChild(this.wrapper); - this._initParams(); - this._initStats(); - this._initCamera(); - this._initScene(); - if (this._initRenderer() === false) { - Log.error('Viewer: could not initialize renderer'); - return; - } - this._initHelper(); - // fog & background - this.setBackground(); - this.setFog(); - this.animate = this.animate.bind(this); -}; - -var prototypeAccessors$2 = { cameraDistance: { configurable: true } }; -Viewer.prototype._initParams = function _initParams () { - this.parameters = { - fogColor: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](0x000000), - fogNear: 50, - fogFar: 100, - backgroundColor: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](0x000000), - cameraType: 'perspective', - cameraFov: 40, - cameraEyeSep: 0.3, - cameraZ: -80, - clipNear: 0, - clipFar: 100, - clipDist: 10, - clipMode: 'scene', - clipScale: 'relative', - lightColor: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](0xdddddd), - lightIntensity: 1.0, - ambientColor: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](0xdddddd), - ambientIntensity: 0.2, - sampleLevel: 0 - }; -}; -Viewer.prototype._initCamera = function _initCamera () { - var lookAt = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); - var ref = this; - var width = ref.width; - var height = ref.height; - this.perspectiveCamera = new __WEBPACK_IMPORTED_MODULE_0_three__["F" /* PerspectiveCamera */](this.parameters.cameraFov, width / height); - this.perspectiveCamera.position.z = this.parameters.cameraZ; - this.perspectiveCamera.lookAt(lookAt); - this.orthographicCamera = new __WEBPACK_IMPORTED_MODULE_0_three__["E" /* OrthographicCamera */](width / -2, width / 2, height / 2, height / -2); - this.orthographicCamera.position.z = this.parameters.cameraZ; - this.orthographicCamera.lookAt(lookAt); - this.stereoCamera = new __WEBPACK_IMPORTED_MODULE_0_three__["P" /* StereoCamera */](); - this.stereoCamera.aspect = 0.5; - this.stereoCamera.eyeSep = this.parameters.cameraEyeSep; - var cameraType = this.parameters.cameraType; - if (cameraType === 'orthographic') { - this.camera = this.orthographicCamera; - } - else if (cameraType === 'perspective' || cameraType === 'stereo') { - this.camera = this.perspectiveCamera; - } - else { - throw new Error(("Unknown cameraType '" + cameraType + "'")); - } - this.camera.updateProjectionMatrix(); -}; -Viewer.prototype._initStats = function _initStats () { - this.stats = new Stats(); -}; -Viewer.prototype._initScene = function _initScene () { - if (!this.scene) { - this.scene = new __WEBPACK_IMPORTED_MODULE_0_three__["L" /* Scene */](); - this.scene.name = 'scene'; - } - this.rotationGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.rotationGroup.name = 'rotationGroup'; - this.scene.add(this.rotationGroup); - this.translationGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.translationGroup.name = 'translationGroup'; - this.rotationGroup.add(this.translationGroup); - this.modelGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.modelGroup.name = 'modelGroup'; - this.translationGroup.add(this.modelGroup); - this.pickingGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.pickingGroup.name = 'pickingGroup'; - this.translationGroup.add(this.pickingGroup); - this.backgroundGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.backgroundGroup.name = 'backgroundGroup'; - this.translationGroup.add(this.backgroundGroup); - this.helperGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.helperGroup.name = 'helperGroup'; - this.translationGroup.add(this.helperGroup); - // fog - this.scene.fog = new __WEBPACK_IMPORTED_MODULE_0_three__["q" /* Fog */](this.parameters.fogColor.getHex()); - // light - this.spotLight = new __WEBPACK_IMPORTED_MODULE_0_three__["O" /* SpotLight */](this.parameters.lightColor.getHex(), this.parameters.lightIntensity); - this.scene.add(this.spotLight); - this.ambientLight = new __WEBPACK_IMPORTED_MODULE_0_three__["b" /* AmbientLight */](this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity); - this.scene.add(this.ambientLight); -}; -Viewer.prototype._initRenderer = function _initRenderer () { - var dpr = window.devicePixelRatio; - var ref = this; - var width = ref.width; - var height = ref.height; - try { - this.renderer = new __WEBPACK_IMPORTED_MODULE_0_three__["Z" /* WebGLRenderer */]({ - preserveDrawingBuffer: true, - alpha: true, - antialias: true - }); - } - catch (e) { - this.wrapper.innerHTML = WebglErrorMessage; - return false; - } - this.renderer.setPixelRatio(dpr); - this.renderer.setSize(width, height); - this.renderer.autoClear = false; - this.renderer.sortObjects = true; - var gl = this.renderer.getContext(); - // console.log(gl.getContextAttributes().antialias) - // console.log(gl.getParameter(gl.SAMPLES)) - // For WebGL1, extensions must be explicitly enabled. - // The following are builtin to WebGL2 (and don't appear as - // extensions) - // EXT_frag_depth, OES_element_index_uint, OES_texture_float - // OES_texture_half_float - // The WEBGL_color_buffer_float extension is replaced by - // EXT_color_buffer_float - // If not webgl2 context, explicitly check for these - if (!this.renderer.capabilities.isWebGL2) { - setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth')); - this.renderer.extensions.get('OES_element_index_uint'); - setSupportsReadPixelsFloat((this.renderer.extensions.get('OES_texture_float') && - this.renderer.extensions.get('WEBGL_color_buffer_float')) || - (this.renderer.extensions.get('OES_texture_float') && - testTextureSupport(gl.FLOAT))); - // picking texture - this.renderer.extensions.get('OES_texture_float'); - this.supportsHalfFloat = (this.renderer.extensions.get('OES_texture_half_float') && - testTextureSupport(0x8D61)); - } - else { - setExtensionFragDepth(true); - setSupportsReadPixelsFloat(this.renderer.extensions.get('EXT_color_buffer_float')); - this.supportsHalfFloat = true; - } - this.wrapper.appendChild(this.renderer.domElement); - var dprWidth = width * dpr; - var dprHeight = height * dpr; - if (Debug) { - console.log(JSON.stringify({ - 'Browser': Browser, - 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'), - 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'), - 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'), - 'testTextureSupport Float': testTextureSupport(gl.FLOAT), - 'testTextureSupport HalfFloat': testTextureSupport(0x8D61), - 'this.supportsHalfFloat': this.supportsHalfFloat, - 'SupportsReadPixelsFloat': SupportsReadPixelsFloat - }, null, 2)); - } - this.pickingTarget = new __WEBPACK_IMPORTED_MODULE_0_three__["Y" /* WebGLRenderTarget */](dprWidth, dprHeight, { - minFilter: __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */], - magFilter: __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */], - stencilBuffer: false, - format: __WEBPACK_IMPORTED_MODULE_0_three__["K" /* RGBAFormat */], - type: SupportsReadPixelsFloat ? __WEBPACK_IMPORTED_MODULE_0_three__["p" /* FloatType */] : __WEBPACK_IMPORTED_MODULE_0_three__["V" /* UnsignedByteType */] - }); - this.pickingTarget.texture.generateMipmaps = false; - // workaround to reset the gl state after using testTextureSupport - // fixes some bug where nothing is rendered to the canvas - // when animations are started on page load - this.renderer.setRenderTarget(this.pickingTarget); - this.renderer.clear(); - this.renderer.setRenderTarget(null); - // ssaa textures - this.sampleTarget = new __WEBPACK_IMPORTED_MODULE_0_three__["Y" /* WebGLRenderTarget */](dprWidth, dprHeight, { - minFilter: __WEBPACK_IMPORTED_MODULE_0_three__["w" /* LinearFilter */], - magFilter: __WEBPACK_IMPORTED_MODULE_0_three__["w" /* LinearFilter */], - format: __WEBPACK_IMPORTED_MODULE_0_three__["K" /* RGBAFormat */] - }); - this.holdTarget = new __WEBPACK_IMPORTED_MODULE_0_three__["Y" /* WebGLRenderTarget */](dprWidth, dprHeight, { - minFilter: __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */], - magFilter: __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */], - format: __WEBPACK_IMPORTED_MODULE_0_three__["K" /* RGBAFormat */], - type: __WEBPACK_IMPORTED_MODULE_0_three__["V" /* UnsignedByteType */] - // using HalfFloatType or FloatType does not work on some Chrome 61 installations - // type: this.supportsHalfFloat ? HalfFloatType : ( - // SupportsReadPixelsFloat ? FloatType : UnsignedByteType - // ) - }); - this.compositeUniforms = { - 'tForeground': new __WEBPACK_IMPORTED_MODULE_0_three__["S" /* Uniform */](this.sampleTarget.texture), - 'scale': new __WEBPACK_IMPORTED_MODULE_0_three__["S" /* Uniform */](1.0) - }; - this.compositeMaterial = new __WEBPACK_IMPORTED_MODULE_0_three__["N" /* ShaderMaterial */]({ - uniforms: this.compositeUniforms, - vertexShader: getShader('Quad.vert'), - fragmentShader: getShader('Quad.frag'), - premultipliedAlpha: true, - transparent: true, - blending: __WEBPACK_IMPORTED_MODULE_0_three__["a" /* AdditiveBlending */], - depthTest: false, - depthWrite: false - }); - this.compositeCamera = new __WEBPACK_IMPORTED_MODULE_0_three__["E" /* OrthographicCamera */](-1, 1, 1, -1, 0, 1); - this.compositeScene = new __WEBPACK_IMPORTED_MODULE_0_three__["L" /* Scene */](); - this.compositeScene.name = 'compositeScene'; - this.compositeScene.add(new __WEBPACK_IMPORTED_MODULE_0_three__["z" /* Mesh */](new __WEBPACK_IMPORTED_MODULE_0_three__["H" /* PlaneGeometry */](2, 2), this.compositeMaterial)); -}; -Viewer.prototype._initHelper = function _initHelper () { - var indices = new Uint16Array([ - 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, - 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 - ]); - var positions = new Float32Array(8 * 3); - var bbGeometry = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */](); - bbGeometry.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](indices, 1)); - bbGeometry.setAttribute('position', new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](positions, 3)); - var bbMaterial = new __WEBPACK_IMPORTED_MODULE_0_three__["N" /* ShaderMaterial */]({ - uniforms: { 'uColor': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */]('skyblue') } }, - vertexShader: getShader('BasicLine.vert'), - fragmentShader: getShader('BasicLine.frag') - }); - this.boundingBoxMesh = new __WEBPACK_IMPORTED_MODULE_0_three__["v" /* LineSegments */](bbGeometry, bbMaterial); - this.helperGroup.add(this.boundingBoxMesh); -}; -Viewer.prototype.updateHelper = function updateHelper () { - var position = this.boundingBoxMesh.geometry.attributes.position; // TODO - var array = position.array; - var ref = this.boundingBox; - var min = ref.min; - var max = ref.max; - array[0] = max.x; - array[1] = max.y; - array[2] = max.z; - array[3] = min.x; - array[4] = max.y; - array[5] = max.z; - array[6] = min.x; - array[7] = min.y; - array[8] = max.z; - array[9] = max.x; - array[10] = min.y; - array[11] = max.z; - array[12] = max.x; - array[13] = max.y; - array[14] = min.z; - array[15] = min.x; - array[16] = max.y; - array[17] = min.z; - array[18] = min.x; - array[19] = min.y; - array[20] = min.z; - array[21] = max.x; - array[22] = min.y; - array[23] = min.z; - position.needsUpdate = true; - if (!this.boundingBox.isEmpty()) { - this.boundingBoxMesh.geometry.computeBoundingSphere(); - } -}; -/** Distance from origin (lookAt point) */ -prototypeAccessors$2.cameraDistance.get = function () { - return Math.abs(this.camera.position.z); -}; -/** Set distance from origin (lookAt point); along the -z axis */ -prototypeAccessors$2.cameraDistance.set = function (d) { - this.camera.position.z = -d; -}; -Viewer.prototype.add = function add (buffer, instanceList) { - var this$1 = this; - - // Log.time( "Viewer.add" ); - if (instanceList) { - instanceList.forEach(function (instance) { return this$1.addBuffer(buffer, instance); }); - } - else { - this.addBuffer(buffer); - } - buffer.group.name = 'meshGroup'; - buffer.wireframeGroup.name = 'wireframeGroup'; - if (buffer.parameters.background) { - this.backgroundGroup.add(buffer.group); - this.backgroundGroup.add(buffer.wireframeGroup); - } - else { - this.modelGroup.add(buffer.group); - this.modelGroup.add(buffer.wireframeGroup); - } - if (buffer.pickable) { - this.pickingGroup.add(buffer.pickingGroup); - } - if (Debug) - { this.updateHelper(); } - // Log.timeEnd( "Viewer.add" ); -}; -Viewer.prototype.addBuffer = function addBuffer (buffer, instance) { - // Log.time( "Viewer.addBuffer" ); - function setUserData(object) { - if (object instanceof __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]) { - object.children.forEach(setUserData); - } - else { - object.userData.buffer = buffer; - object.userData.instance = instance; - object.onBeforeRender = onBeforeRender; - } - } - var mesh = buffer.getMesh(); - if (instance) { - mesh.applyMatrix4(instance.matrix); - } - setUserData(mesh); - buffer.group.add(mesh); - var wireframeMesh = buffer.getWireframeMesh(); - if (instance) { - // wireframeMesh.applyMatrix( instance.matrix ); - wireframeMesh.matrix.copy(mesh.matrix); - wireframeMesh.position.copy(mesh.position); - wireframeMesh.quaternion.copy(mesh.quaternion); - wireframeMesh.scale.copy(mesh.scale); - } - setUserData(wireframeMesh); - buffer.wireframeGroup.add(wireframeMesh); - if (buffer.pickable) { - var pickingMesh = buffer.getPickingMesh(); - if (instance) { - // pickingMesh.applyMatrix( instance.matrix ); - pickingMesh.matrix.copy(mesh.matrix); - pickingMesh.position.copy(mesh.position); - pickingMesh.quaternion.copy(mesh.quaternion); - pickingMesh.scale.copy(mesh.scale); - } - setUserData(pickingMesh); - buffer.pickingGroup.add(pickingMesh); - } - if (instance) { - this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix); - } - else { - this._updateBoundingBox(buffer.geometry, buffer.matrix); - } - // Log.timeEnd( "Viewer.addBuffer" ); -}; -Viewer.prototype.remove = function remove (buffer) { - this.translationGroup.children.forEach(function (group) { - group.remove(buffer.group); - group.remove(buffer.wireframeGroup); - }); - if (buffer.pickable) { - this.pickingGroup.remove(buffer.pickingGroup); - } - this.updateBoundingBox(); - if (Debug) - { this.updateHelper(); } - // this.requestRender(); -}; -Viewer.prototype._updateBoundingBox = function _updateBoundingBox (geometry, matrix, instanceMatrix) { - var boundingBox = this.boundingBox; - function updateGeometry(geometry, matrix, instanceMatrix) { - if (geometry.boundingBox == null) { - geometry.computeBoundingBox(); - } - var geoBoundingBox = geometry.boundingBox.clone(); - if (matrix) { - geoBoundingBox.applyMatrix4(matrix); - } - if (instanceMatrix) { - geoBoundingBox.applyMatrix4(instanceMatrix); - } - if (geoBoundingBox.min.equals(geoBoundingBox.max)) { - // mainly to give a single impostor geometry some volume - // as it is only expanded in the shader on the GPU - geoBoundingBox.expandByScalar(5); - } - boundingBox.union(geoBoundingBox); - } - function updateNode(node) { - if (node.geometry !== undefined) { - var matrix, instanceMatrix; - if (node.userData.buffer) { - matrix = node.userData.buffer.matrix; - } - if (node.userData.instance) { - instanceMatrix = node.userData.instance.matrix; - } - updateGeometry(node.geometry, matrix, instanceMatrix); // TODO - } - } - if (geometry) { - updateGeometry(geometry, matrix, instanceMatrix); - } - else { - boundingBox.makeEmpty(); - this.modelGroup.traverse(updateNode); - this.backgroundGroup.traverse(updateNode); - } - boundingBox.getSize(this.boundingBoxSize); - this.boundingBoxLength = this.boundingBoxSize.length(); -}; -Viewer.prototype.updateBoundingBox = function updateBoundingBox () { - this._updateBoundingBox(); - if (Debug) - { this.updateHelper(); } -}; -Viewer.prototype.getPickingPixels = function getPickingPixels () { - var ref = this; - var width = ref.width; - var height = ref.height; - var n = width * height * 4; - var imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n); - this.render(true); - this.renderer.readRenderTargetPixels(this.pickingTarget, 0, 0, width, height, imgBuffer); - return imgBuffer; -}; -Viewer.prototype.getImage = function getImage (picking) { - var this$1 = this; - - return new Promise(function (resolve) { - if (picking) { - var ref = this$1; - var width = ref.width; - var height = ref.height; - var n = width * height * 4; - var imgBuffer = this$1.getPickingPixels(); - if (SupportsReadPixelsFloat) { - var imgBuffer2 = new Uint8Array(n); - for (var i = 0; i < n; ++i) { - imgBuffer2[i] = Math.round(imgBuffer[i] * 255); - } - imgBuffer = imgBuffer2; - } - var canvas = document.createElement('canvas'); - canvas.width = width; - canvas.height = height; - var ctx = canvas.getContext('2d'); // TODO - var imgData = ctx.getImageData(0, 0, width, height); - imgData.data.set(imgBuffer); // TODO - ctx.putImageData(imgData, 0, 0); - canvas.toBlob(resolve, 'image/png'); // TODO - } - else { - this$1.renderer.domElement.toBlob(resolve, 'image/png'); // TODO - } - }); -}; -Viewer.prototype.makeImage = function makeImage$1 (params) { - if ( params === void 0 ) params = {}; - - return makeImage(this, params); -}; -Viewer.prototype.setLight = function setLight (color, intensity, ambientColor, ambientIntensity) { - var p = this.parameters; - if (color !== undefined) - { p.lightColor.set(color); } // TODO - if (intensity !== undefined) - { p.lightIntensity = intensity; } - if (ambientColor !== undefined) - { p.ambientColor.set(ambientColor); } // TODO - if (ambientIntensity !== undefined) - { p.ambientIntensity = ambientIntensity; } - this.requestRender(); -}; -Viewer.prototype.setFog = function setFog (color, near, far) { - var p = this.parameters; - if (color !== undefined) - { p.fogColor.set(color); } // TODO - if (near !== undefined) - { p.fogNear = near; } - if (far !== undefined) - { p.fogFar = far; } - this.requestRender(); -}; -Viewer.prototype.setBackground = function setBackground (color) { - var p = this.parameters; - if (color) - { p.backgroundColor.set(color); } // TODO - this.setFog(p.backgroundColor); - this.renderer.setClearColor(p.backgroundColor, 0); - this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle(); - this.requestRender(); -}; -Viewer.prototype.setSampling = function setSampling (level) { - if (level !== undefined) { - this.parameters.sampleLevel = level; - this.sampleLevel = level; - } - this.requestRender(); -}; -Viewer.prototype.setCamera = function setCamera (type, fov, eyeSep) { - var p = this.parameters; - if (type) - { p.cameraType = type; } - if (fov) - { p.cameraFov = fov; } - if (eyeSep) - { p.cameraEyeSep = eyeSep; } - if (p.cameraType === 'orthographic') { - if (this.camera !== this.orthographicCamera) { - this.camera = this.orthographicCamera; - this.camera.position.copy(this.perspectiveCamera.position); - this.camera.up.copy(this.perspectiveCamera.up); - this.updateZoom(); - } - } - else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') { - if (this.camera !== this.perspectiveCamera) { - this.camera = this.perspectiveCamera; - this.camera.position.copy(this.orthographicCamera.position); - this.camera.up.copy(this.orthographicCamera.up); - } - } - else { - throw new Error(("Unknown cameraType '" + (p.cameraType) + "'")); - } - this.perspectiveCamera.fov = p.cameraFov; - this.stereoCamera.eyeSep = p.cameraEyeSep; - this.camera.updateProjectionMatrix(); - this.requestRender(); -}; -Viewer.prototype.setClip = function setClip (near, far, dist, clipMode, clipScale) { - var p = this.parameters; - if (near !== undefined) - { p.clipNear = near; } - if (far !== undefined) - { p.clipFar = far; } - if (dist !== undefined) - { p.clipDist = dist; } - if (clipMode !== undefined) - { p.clipMode = clipMode; } - if (clipScale !== undefined) - { p.clipScale = clipScale; } - this.requestRender(); -}; -Viewer.prototype.setSize = function setSize (width, height) { - this.width = width || 1; - this.height = height || 1; - this.perspectiveCamera.aspect = this.width / this.height; - this.orthographicCamera.left = -this.width / 2; - this.orthographicCamera.right = this.width / 2; - this.orthographicCamera.top = this.height / 2; - this.orthographicCamera.bottom = -this.height / 2; - this.camera.updateProjectionMatrix(); - var dpr = window.devicePixelRatio; - this.renderer.setPixelRatio(dpr); - this.renderer.setSize(width, height); - var dprWidth = this.width * dpr; - var dprHeight = this.height * dpr; - this.pickingTarget.setSize(dprWidth, dprHeight); - this.sampleTarget.setSize(dprWidth, dprHeight); - this.holdTarget.setSize(dprWidth, dprHeight); - this.requestRender(); -}; -Viewer.prototype.handleResize = function handleResize () { - if (this.container === document.body) { - this.setSize(window.innerWidth, window.innerHeight); - } - else { - var box = this.container.getBoundingClientRect(); - this.setSize(box.width, box.height); - } -}; -Viewer.prototype.updateInfo = function updateInfo (reset) { - var ref = this.info; - var memory = ref.memory; - var render = ref.render; - if (reset) { - memory.programs = 0; - memory.geometries = 0; - memory.textures = 0; - render.calls = 0; - render.vertices = 0; - render.points = 0; - } - else { - var rInfo = this.renderer.info; - var rMemory = rInfo.memory; - var rRender = rInfo.render; - memory.geometries = rMemory.geometries; - memory.textures = rMemory.textures; - render.calls += rRender.calls; - render.faces += rRender.triangles; - render.points += rRender.points; - } -}; -Viewer.prototype.animate = function animate () { - this.signals.ticked.dispatch(this.stats); - var delta = window.performance.now() - this.stats.startTime; - if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) { - var currentSampleLevel = this.sampleLevel; - this.sampleLevel = 3; - this.renderPending = true; - this.render(); - this.isStill = true; - this.sampleLevel = currentSampleLevel; - if (Debug) - { Log.log('rendered still frame'); } - } - window.requestAnimationFrame(this.animate); -}; -Viewer.prototype.pick = function pick (x, y) { - if (this.parameters.cameraType === 'stereo') { - // TODO picking broken for stereo camera - return { - 'pid': 0, - 'instance': undefined, - 'picker': undefined - }; - } - x *= window.devicePixelRatio; - y *= window.devicePixelRatio; - x = Math.max(x - 2, 0); - y = Math.max(y - 2, 0); - var pid = 0, instance, picker; - var pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint; - this.render(true); - this.renderer.readRenderTargetPixels(this.pickingTarget, x, y, 5, 5, pixelBuffer); - for (var i = 0; i < pixelOrder.length; i++) { - var offset = pixelOrder[i] * 4; - var oid = Math.round(pixelBuffer[offset + 3]); - var object = this.pickingGroup.getObjectById(oid); - if (object) { - instance = object.userData.instance; - picker = object.userData.buffer.picking; - } - else { - continue; - } - if (SupportsReadPixelsFloat) { - pid = - ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) | - ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) | - ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF); - } - else { - pid = - (pixelBuffer[offset] << 16) | - (pixelBuffer[offset + 1] << 8) | - (pixelBuffer[offset + 2]); - } - } - // if( Debug ){ - // const rgba = Array.apply( [], pixelBuffer ); - // Log.log( pixelBuffer ); - // Log.log( - // "picked color", - // rgba.map( c => { return c.toPrecision( 2 ) } ) - // ); - // Log.log( "picked pid", pid ); - // Log.log( "picked oid", oid ); - // Log.log( "picked object", object ); - // Log.log( "picked instance", instance ); - // Log.log( "picked position", x, y ); - // Log.log( "devicePixelRatio", window.devicePixelRatio ); - // } - return { pid: pid, instance: instance, picker: picker }; -}; -Viewer.prototype.requestRender = function requestRender () { - var this$1 = this; - - if (this.renderPending) { - // Log.info("there is still a 'render' call pending") - return; - } - // start gathering stats anew after inactivity - if (window.performance.now() - this.stats.startTime > 22) { - this.stats.begin(); - this.isStill = false; - } - this.renderPending = true; - window.requestAnimationFrame(function () { - this$1.render(); - this$1.stats.update(); - }); -}; -Viewer.prototype.updateZoom = function updateZoom () { - var fov = degToRad(this.perspectiveCamera.fov); - var height = 2 * Math.tan(fov / 2) * this.cameraDistance; - this.orthographicCamera.zoom = this.height / height; -}; -/** - * Convert an absolute clip value to a relative one using bRadius. - * - * 0.0 -> 50.0 - * bRadius -> 0.0 - */ -Viewer.prototype.absoluteToRelative = function absoluteToRelative (d) { - return 50 * (1 - d / this.bRadius); -}; -/** - * Convert a relative clip value to an absolute one using bRadius - * - * 0.0 -> bRadius - * 50.0 -> 0.0 - */ -Viewer.prototype.relativeToAbsolute = function relativeToAbsolute (d) { - return this.bRadius * (1 - d / 50); -}; -/** - * Intepret clipMode, clipScale and set the camera and fog clipping. - * Also ensures bRadius and cDist are valid - */ -Viewer.prototype.__updateClipping = function __updateClipping () { - var p = this.parameters; - // bRadius must always be updated for material-based clipping - // and for focus calculations - this.bRadius = Math.max(10, this.boundingBoxLength * 0.5); - // FL: Removed below, but leaving commented as I don't understand intention - // this.bRadius += this.boundingBox.getCenter(this.distVector).length() - if (!isFinite(this.bRadius)) { - this.bRadius = 50; - } - this.camera.getWorldPosition(this.distVector); - this.cDist = this.distVector.length(); - if (!this.cDist) { - // recover from a broken (NaN) camera position - this.cameraDistance = Math.abs(p.cameraZ); - this.cDist = Math.abs(p.cameraZ); - } - // fog - var fog = this.scene.fog; - fog.color.set(p.fogColor); - if (p.clipMode === 'camera') { - // Always interpret clipScale as absolute for clipMode camera - this.camera.near = p.clipNear; - this.camera.far = p.clipFar; - fog.near = p.fogNear; - fog.far = p.fogFar; - } - else { - // scene mode - if (p.clipScale === 'absolute') { - // absolute scene mode; offset clip planes from scene center - // (note: positive values move near plane towards camera and rear plane away) - this.camera.near = this.cDist - p.clipNear; - this.camera.far = this.cDist + p.clipFar; - fog.near = this.cDist - p.fogNear; - fog.far = this.cDist + p.fogFar; - } - else { - // relative scene mode (default): convert pecentages to Angstroms - var nearFactor = (50 - p.clipNear) / 50; - var farFactor = -(50 - p.clipFar) / 50; - this.camera.near = this.cDist - (this.bRadius * nearFactor); - this.camera.far = this.cDist + (this.bRadius * farFactor); - var fogNearFactor = (50 - p.fogNear) / 50; - var fogFarFactor = -(50 - p.fogFar) / 50; - fog.near = this.cDist - (this.bRadius * fogNearFactor); - fog.far = this.cDist + (this.bRadius * fogFarFactor); - } - } - if (p.clipMode !== 'camera') { - if (this.camera.type === 'PerspectiveCamera') { - this.camera.near = Math.max(0.1, p.clipDist, this.camera.near); - this.camera.far = Math.max(1, this.camera.far); - fog.near = Math.max(0.1, fog.near); - fog.far = Math.max(1, fog.far); - } - else if (this.camera.type === 'OrthographicCamera') { - if (p.clipDist > 0) { - this.camera.near = Math.max(p.clipDist, this.camera.near); - } - } - } -}; -Viewer.prototype.__updateCamera = function __updateCamera () { - var camera = this.camera; - camera.updateMatrix(); - camera.updateMatrixWorld(true); - camera.updateProjectionMatrix(); - updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius); - sortProjectedPosition(this.scene, camera); -}; -Viewer.prototype.__setVisibility = function __setVisibility (model, picking, background, helper) { - this.modelGroup.visible = model; - this.pickingGroup.visible = picking; - this.backgroundGroup.visible = background; - this.helperGroup.visible = helper; -}; -Viewer.prototype.__updateLights = function __updateLights () { - this.spotLight.color.set(this.parameters.lightColor); - this.spotLight.intensity = this.parameters.lightIntensity; - this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100); - this.spotLight.position.copy(this.camera.position).add(this.distVector); - this.ambientLight.color.set(this.parameters.ambientColor); - this.ambientLight.intensity = this.parameters.ambientIntensity; -}; -Viewer.prototype.__renderPickingGroup = function __renderPickingGroup (camera) { - this.renderer.setRenderTarget(this.pickingTarget || null); - this.renderer.clear(); - this.__setVisibility(false, true, false, false); - this.renderer.render(this.scene, camera); - this.renderer.setRenderTarget(null); - this.updateInfo(); - // back to standard render target - this.renderer.setRenderTarget(null); // TODO - // if (Debug) { - // this.__setVisibility(false, true, false, true); - // this.renderer.clear(); - // this.renderer.render(this.scene, camera); - // } -}; -Viewer.prototype.__renderModelGroup = function __renderModelGroup (camera, renderTarget) { - this.renderer.setRenderTarget(renderTarget || null); - this.renderer.clear(); - this.__setVisibility(false, false, true, false); - this.renderer.render(this.scene, camera); - this.renderer.clear(false, true, true); - this.updateInfo(); - this.__setVisibility(true, false, false, Debug); - this.renderer.render(this.scene, camera); - this.renderer.setRenderTarget(null); // set back to default canvas - this.updateInfo(); -}; -Viewer.prototype.__renderSuperSample = function __renderSuperSample (camera) { - // based on the Supersample Anti-Aliasing Render Pass - // contributed to three.js by bhouston / http://clara.io/ - // - // This manual approach to SSAA re-renders the scene ones for - // each sample with camera jitter and accumulates the results. - // References: https://en.wikipedia.org/wiki/Supersampling - var offsetList = JitterVectors[Math.max(0, Math.min(this.sampleLevel, 5))]; - var baseSampleWeight = 1.0 / offsetList.length; - var roundingRange = 1 / 32; - this.compositeUniforms.tForeground.value = this.sampleTarget.texture; - var width = this.sampleTarget.width; - var height = this.sampleTarget.height; - if (this.parameters.cameraType === 'stereo') { - width /= 2; - } - // render the scene multiple times, each slightly jitter offset - // from the last and accumulate the results. - for (var i = 0; i < offsetList.length; ++i) { - var offset = offsetList[i]; - camera.setViewOffset(width, height, offset[0], offset[1], width, height); - camera.updateProjectionMatrix(); - updateCameraUniforms(this.scene, camera); - var sampleWeight = baseSampleWeight; - // the theory is that equal weights for each sample lead to an - // accumulation of rounding errors. - // The following equation varies the sampleWeight per sample - // so that it is uniformly distributed across a range of values - // whose rounding errors cancel each other out. - var uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length; - sampleWeight += roundingRange * uniformCenteredDistribution; - this.compositeUniforms.scale.value = sampleWeight; - this.__renderModelGroup(camera, this.sampleTarget); - this.renderer.setRenderTarget(this.holdTarget); - if (i === 0) { - this.renderer.clear(); - } - this.renderer.render(this.compositeScene, this.compositeCamera); - } - this.compositeUniforms.scale.value = 1.0; - this.compositeUniforms.tForeground.value = this.holdTarget.texture; - camera.clearViewOffset(); - this.renderer.setRenderTarget(null); - this.renderer.clear(); - this.renderer.render(this.compositeScene, this.compositeCamera); -}; -Viewer.prototype.__renderStereo = function __renderStereo (picking) { - if ( picking === void 0 ) picking = false; - - var stereoCamera = this.stereoCamera; - stereoCamera.update(this.perspectiveCamera); - var renderer = this.renderer; - var size = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); - renderer.getSize(size); - renderer.setScissorTest(true); - renderer.setScissor(0, 0, size.width / 2, size.height); - renderer.setViewport(0, 0, size.width / 2, size.height); - updateCameraUniforms(this.scene, stereoCamera.cameraL); - this.__render(picking, stereoCamera.cameraL); - renderer.setScissor(size.width / 2, 0, size.width / 2, size.height); - renderer.setViewport(size.width / 2, 0, size.width / 2, size.height); - updateCameraUniforms(this.scene, stereoCamera.cameraR); - this.__render(picking, stereoCamera.cameraR); - renderer.setScissorTest(false); - renderer.setViewport(0, 0, size.width, size.height); -}; -Viewer.prototype.__render = function __render (picking, camera) { - if ( picking === void 0 ) picking = false; - - if (picking) { - if (!this.lastRenderedPicking) - { this.__renderPickingGroup(camera); } - } - else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') { - // TODO super sample broken for stereo camera - this.__renderSuperSample(camera); - } - else { - this.__renderModelGroup(camera); - } -}; -Viewer.prototype.render = function render (picking) { - if ( picking === void 0 ) picking = false; - - if (this.rendering) { - Log.warn("'tried to call 'render' from within 'render'"); - return; - } - // Log.time('Viewer.render') - this.rendering = true; - try { - this.__updateClipping(); - this.__updateCamera(); - this.__updateLights(); - this.updateInfo(true); - // render - if (this.parameters.cameraType === 'stereo') { - this.__renderStereo(picking); - } - else { - this.__render(picking, this.camera); - } - this.lastRenderedPicking = picking; - } - finally { - this.rendering = false; - this.renderPending = false; - } - this.signals.rendered.dispatch(); - // Log.timeEnd('Viewer.render') - // Log.log(this.info.memory, this.info.render) -}; -Viewer.prototype.clear = function clear () { - Log.log('scene cleared'); - this.scene.remove(this.rotationGroup); - this._initScene(); - this.renderer.clear(); -}; -Viewer.prototype.dispose = function dispose () { - this.renderer.dispose(); -}; - -Object.defineProperties( Viewer.prototype, prototypeAccessors$2 ); - -/** - * @file Constants - * @author Alexander Rose - * @private - */ -var LeftMouseButton = 1; -var MiddleMouseButton = 2; -var RightMouseButton = 3; - -/** - * @file Mouse Observer - * @author Alexander Rose - * @private - */ -/** - * @example - * mouseObserver.signals.scrolled.add( function( delta ){ ... } ); - * - * @typedef {Object} MouseSignals - * @property {Signal} moved - on move: deltaX, deltaY - * @property {Signal} scrolled - on scroll: delta - * @property {Signal} dragged - on drag: deltaX, deltaY - * @property {Signal} dropped - on drop - * @property {Signal} clicked - on click - * @property {Signal} hovered - on hover - */ -function getTouchDistance(event) { - var dx = event.touches[0].pageX - event.touches[1].pageX; - var dy = event.touches[0].pageY - event.touches[1].pageY; - return Math.sqrt(dx * dx + dy * dy); -} -function getMouseButtons(event) { - if (typeof event === 'object') { - if ('buttons' in event) { - return event.buttons; - } - else if ('which' in event) { - var b = event.which; - if (b === 2) { - return 4; - } - else if (b === 3) { - return 2; - } - else if (b > 0) { - return 1 << (b - 1); - } - } - else if ('button' in event) { - var b$1 = event.button; - if (b$1 === 1) { - return 4; - } - else if (b$1 === 2) { - return 2; - } - else if (b$1 >= 0) { - return 1 << b$1; - } - } - } - return 0; -} -/** - * Mouse observer - * - * @example - * // listen to mouse moving (and touch-moving) events - * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } ); - * - * @example - * // listen to scrolling (and pinching) events - * mouseObserver.signals.scrolled.add( function( delta ){ ... } ); - * - * @example - * // listen to dragging (and touch-dragging) events - * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } ); - * - * @example - * // listen to clicking (and tapping) events - * mouseObserver.signals.clicked.add( function(){ ... } ); - * - * @example - * // listen to double clicking (and double tapping) events - * mouseObserver.signals.doubleClicked.add( function(){ ... } ); - * - * @example - * // listen to hovering events - * mouseObserver.signals.hovered.add( function(){ ... } ); - */ -var MouseObserver = function MouseObserver(domElement, params) { - if ( params === void 0 ) params = {}; - - this.domElement = domElement; - this.signals = { - moved: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - scrolled: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - dragged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - dropped: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - clicked: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - hovered: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - doubleClicked: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.position = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); // Position on page - this.prevPosition = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); // Previous position on page - this.down = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); // Position on page when clicked - this.canvasPosition = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); // Position on dom element - this.prevClickCP = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); - this.moving = false; // Flag indicating if the mouse is moving - this.hovering = true; // Flag indicating if the mouse is hovering - this.scrolled = false; // Flag indicating if there was a scolling event since the last mouse move - this.lastMoved = Infinity; // Timestamp of last mouse move - this.which = 0; // 0: No button; 1: Left button; 2: Middle button; 3: Right button - this.buttons = 0; // 0: No button; 1: Left button; 2: Right button; 4: Middle button - this.pressed = false; // Flag indicating if the mouse is pressed down - this.altKey = false; // Flag indicating if the alt key is pressed - this.ctrlKey = false; // Flag indicating if the ctrl key is pressed - this.metaKey = false; // Flag indicating if the meta key is pressed - this.shiftKey = false; // Flag indicating if the shift key is pressed - this.domElement.style.touchAction = 'none'; - this.hoverTimeout = defaults(params.hoverTimeout, 50); - this.handleScroll = defaults(params.handleScroll, true); - this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500); - this._listen = this._listen.bind(this); - this._onMousewheel = this._onMousewheel.bind(this); - this._onMousemove = this._onMousemove.bind(this); - this._onMousedown = this._onMousedown.bind(this); - this._onMouseup = this._onMouseup.bind(this); - this._onContextmenu = this._onContextmenu.bind(this); - this._onTouchstart = this._onTouchstart.bind(this); - this._onTouchend = this._onTouchend.bind(this); - this._onTouchmove = this._onTouchmove.bind(this); - this._listen(); - var opt = { passive: false }; // treat as 'passive' so preventDefault can be called - document.addEventListener('mousewheel', this._onMousewheel, opt); - document.addEventListener('wheel', this._onMousewheel, opt); - document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt); - document.addEventListener('mousemove', this._onMousemove, opt); - document.addEventListener('mousedown', this._onMousedown, opt); - document.addEventListener('mouseup', this._onMouseup, opt); - document.addEventListener('contextmenu', this._onContextmenu, opt); - document.addEventListener('touchstart', this._onTouchstart, opt); - document.addEventListener('touchend', this._onTouchend, opt); - document.addEventListener('touchmove', this._onTouchmove, opt); -}; - -var prototypeAccessors$3 = { key: { configurable: true } }; -prototypeAccessors$3.key.get = function () { - var key = 0; - if (this.altKey) - { key += 1; } - if (this.ctrlKey) - { key += 2; } - if (this.metaKey) - { key += 4; } - if (this.shiftKey) - { key += 8; } - return key; -}; -MouseObserver.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout); -}; -/** - * listen to mouse actions - * @emits {MouseSignals.clicked} when clicked - * @emits {MouseSignals.hovered} when hovered - * @return {undefined} - */ -MouseObserver.prototype._listen = function _listen () { - var now = window.performance.now(); - var cp = this.canvasPosition; - if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) { - this.doubleClickPending = false; - } - if (now - this.lastMoved > this.hoverTimeout) { - this.moving = false; - } - if (this.scrolled || (!this.moving && !this.hovering)) { - this.scrolled = false; - if (this.hoverTimeout !== -1 && this.overElement) { - this.hovering = true; - this.signals.hovered.dispatch(cp.x, cp.y); - } - } - window.requestAnimationFrame(this._listen); -}; -/** - * handle mouse scroll - * @emits {MouseSignals.scrolled} when scrolled - * @param {Event} event - mouse event - * @return {undefined} - */ -MouseObserver.prototype._onMousewheel = function _onMousewheel (event) { - var this$1 = this; - - if (event.target !== this.domElement || !this.handleScroll) { - return; - } - event.preventDefault(); - this._setKeys(event); - var delta = 0; - if ('deltaY' in event && 'deltaMode' in event) { - // all modern browsers, using WheelEvent; deltaY + down (toward user) - if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL) - // everything except Firefox: normally 100 per wheel click - { delta = -event.deltaY * (2.5 / 100.0); } - else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE) - // Firefox in line mode, normally 3 per wheel click - { delta = -event.deltaY * (2.5 / 3.0); } - else // page mode: 1 per wheel click - { delta = -event.deltaY * 2.5; } - } - else if ('deltaY' in event && !('detail' in event)) { - // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels - delta = -event.deltaY * (2.5 / 100.0); - } - else if (event.wheelDelta !== undefined) { - delta = -event.wheelDelta * (2.5 / 100); - } - else if (event.wheelDeltaY !== undefined) { - delta = -event.wheelDeltaY * (2.5 / 100); - } - else { - // Old Firefox, MouseWheelEvent - delta = -event.detail / 3; - } - this.signals.scrolled.dispatch(delta); - setTimeout(function () { - this$1.scrolled = true; - }, this.hoverTimeout); -}; -/** - * handle mouse move - * @emits {MouseSignals.moved} when moved - * @emits {MouseSignals.dragged} when dragged - * @param {Event} event - mouse event - * @return {undefined} - */ -MouseObserver.prototype._onMousemove = function _onMousemove (event) { - if (event.target === this.domElement) { - event.preventDefault(); - this.overElement = true; - } - else { - this.overElement = false; - } - this._setKeys(event); - this.moving = true; - this.hovering = false; - this.lastMoved = window.performance.now(); - this.prevPosition.copy(this.position); - this.position.set(event.clientX, event.clientY); - this._setCanvasPosition(event); - var dx = this.prevPosition.x - this.position.x; - var dy = this.prevPosition.y - this.position.y; - this.signals.moved.dispatch(dx, dy); - if (this.pressed) { - this.signals.dragged.dispatch(dx, dy); - } -}; -MouseObserver.prototype._onMousedown = function _onMousedown (event) { - if (event.target !== this.domElement) { - return; - } - event.preventDefault(); - this._setKeys(event); - this.moving = false; - this.hovering = false; - this.down.set(event.clientX, event.clientY); - this.position.set(event.clientX, event.clientY); - this.which = event.which; - this.buttons = getMouseButtons(event); - this.pressed = true; - this._setCanvasPosition(event); -}; -/** - * handle mouse up - * @emits {MouseSignals.doubleClicked} when double clicked - * @emits {MouseSignals.dropped} when dropped - * @param {Event} event - mouse event - * @return {undefined} - */ -MouseObserver.prototype._onMouseup = function _onMouseup (event) { - if (event.target === this.domElement) { - event.preventDefault(); - } - this._setKeys(event); - var cp = this.canvasPosition; - if (this._distance() < 4) { - this.lastClicked = window.performance.now(); - if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) { - this.signals.doubleClicked.dispatch(cp.x, cp.y); - this.doubleClickPending = false; - } - this.signals.clicked.dispatch(cp.x, cp.y); - this.doubleClickPending = true; - this.prevClickCP.copy(cp); - } - this.which = undefined; - this.buttons = undefined; - this.pressed = undefined; - // if (this._distance() > 3 || event.which === RightMouseButton) { - // this.signals.dropped.dispatch(); - // } -}; -MouseObserver.prototype._onContextmenu = function _onContextmenu (event) { - if (event.target === this.domElement) { - event.preventDefault(); - } -}; -MouseObserver.prototype._onTouchstart = function _onTouchstart (event) { - if (event.target !== this.domElement) { - return; - } - event.preventDefault(); - this.pressed = true; - switch (event.touches.length) { - case 1: { - this.moving = false; - this.hovering = false; - this.down.set(event.touches[0].pageX, event.touches[0].pageY); - this.position.set(event.touches[0].pageX, event.touches[0].pageY); - this._setCanvasPosition(event.touches[0]); - break; - } - case 2: { - this.down.set((event.touches[0].pageX + event.touches[1].pageX) / 2, (event.touches[0].pageY + event.touches[1].pageY) / 2); - this.position.set((event.touches[0].pageX + event.touches[1].pageX) / 2, (event.touches[0].pageY + event.touches[1].pageY) / 2); - this.lastTouchDistance = getTouchDistance(event); - } - } -}; -MouseObserver.prototype._onTouchend = function _onTouchend (event) { - if (event.target === this.domElement) { - event.preventDefault(); - } - this.which = undefined; - this.buttons = undefined; - this.pressed = undefined; -}; -MouseObserver.prototype._onTouchmove = function _onTouchmove (event) { - if (event.target === this.domElement) { - event.preventDefault(); - this.overElement = true; - } - else { - this.overElement = false; - } - switch (event.touches.length) { - case 1: { - this._setKeys(event); - this.which = LeftMouseButton; - this.buttons = 1; - this.moving = true; - this.hovering = false; - this.lastMoved = window.performance.now(); - this.prevPosition.copy(this.position); - this.position.set(event.touches[0].pageX, event.touches[0].pageY); - this._setCanvasPosition(event.touches[0]); - var dx = this.prevPosition.x - this.position.x; - var dy = this.prevPosition.y - this.position.y; - this.signals.moved.dispatch(dx, dy); - if (this.pressed) { - this.signals.dragged.dispatch(dx, dy); - } - break; - } - case 2: { - var touchDistance = getTouchDistance(event); - var delta = touchDistance - this.lastTouchDistance; - this.lastTouchDistance = touchDistance; - this.prevPosition.copy(this.position); - this.position.set((event.touches[0].pageX + event.touches[1].pageX) / 2, (event.touches[0].pageY + event.touches[1].pageY) / 2); - if (Math.abs(delta) > 2 && this.handleScroll && - this.position.distanceTo(this.prevPosition) < 2) { - this.which = 0; - this.buttons = 0; - this.signals.scrolled.dispatch(delta / 2); - } - else { - this.which = RightMouseButton; - this.buttons = 2; - var dx$1 = this.prevPosition.x - this.position.x; - var dy$1 = this.prevPosition.y - this.position.y; - this.signals.moved.dispatch(dx$1, dy$1); - if (this.pressed) { - this.signals.dragged.dispatch(dx$1, dy$1); - } - } - } - } -}; -MouseObserver.prototype._distance = function _distance () { - return this.position.distanceTo(this.down); -}; -MouseObserver.prototype._setCanvasPosition = function _setCanvasPosition (event) { - var box = this.domElement.getBoundingClientRect(); - var offsetX, offsetY; - if ('offsetX' in event && 'offsetY' in event) { - offsetX = event.offsetX; - offsetY = event.offsetY; - } - else { - offsetX = event.clientX - box.left; - offsetY = event.clientY - box.top; - } - this.canvasPosition.set(offsetX, box.height - offsetY); -}; -MouseObserver.prototype._setKeys = function _setKeys (event) { - this.altKey = event.altKey; - this.ctrlKey = event.ctrlKey; - this.metaKey = event.metaKey; - this.shiftKey = event.shiftKey; -}; -MouseObserver.prototype.dispose = function dispose () { - document.removeEventListener('mousewheel', this._onMousewheel); - document.removeEventListener('wheel', this._onMousewheel); - document.removeEventListener('MozMousePixelScroll', this._onMousewheel); - document.removeEventListener('mousemove', this._onMousemove); - document.removeEventListener('mousedown', this._onMousedown); - document.removeEventListener('mouseup', this._onMouseup); - document.removeEventListener('contextmenu', this._onContextmenu); - document.removeEventListener('touchstart', this._onTouchstart); - document.removeEventListener('touchend', this._onTouchend); - document.removeEventListener('touchmove', this._onTouchmove); -}; - -Object.defineProperties( MouseObserver.prototype, prototypeAccessors$3 ); - -/** - * @file Trackball Controls - * @author Alexander Rose - * @private - */ -var tmpRotateXMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateYMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateZMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateCameraMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpRotateQuaternion = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); -var tmpRotateQuaternion2 = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); -var tmpPanMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpPanVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpAtomVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -/** - * Trackball controls - */ -var TrackballControls = function TrackballControls(stage, params) { - if ( params === void 0 ) params = {}; - - this.stage = stage; - this.rotateSpeed = defaults(params.rotateSpeed, 2.0); - this.zoomSpeed = defaults(params.zoomSpeed, 1.2); - this.panSpeed = defaults(params.panSpeed, 1.0); - this.viewer = stage.viewer; - this.mouse = stage.mouseObserver; - this.controls = stage.viewerControls; -}; - -var prototypeAccessors$4 = { component: { configurable: true },atom: { configurable: true } }; -prototypeAccessors$4.component.get = function () { - return this.stage.transformComponent; -}; -prototypeAccessors$4.atom.get = function () { - return this.stage.transformAtom; -}; -TrackballControls.prototype._setPanVector = function _setPanVector (x, y, z) { - if ( z === void 0 ) z = 0; - - var scaleFactor = this.controls.getCanvasScaleFactor(z); - tmpPanVector.set(x, y, 0); - tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor); -}; -TrackballControls.prototype._getRotateXY = function _getRotateXY (x, y) { - return [ - this.rotateSpeed * -x * 0.01, - this.rotateSpeed * y * 0.01 - ]; -}; -TrackballControls.prototype._getCameraRotation = function _getCameraRotation (m) { - m.extractRotation(this.viewer.camera.matrixWorld); - m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI)); - return m; -}; -TrackballControls.prototype._transformPanVector = function _transformPanVector () { - if (!this.component) - { return; } - // Adjust for component and scene rotation - tmpPanMatrix.extractRotation(this.component.transform); - tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix); - tmpPanMatrix.getInverse(tmpPanMatrix); - // Adjust for camera rotation - tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix)); - tmpPanVector.applyMatrix4(tmpPanMatrix); -}; -TrackballControls.prototype.zoom = function zoom (delta) { - this.controls.zoom(this.zoomSpeed * delta * 0.02); -}; -TrackballControls.prototype.pan = function pan (x, y) { - this._setPanVector(x, y); - // Adjust for scene rotation - tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix); - // Adjust for camera rotation - tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix)); - tmpPanVector.applyMatrix4(tmpPanMatrix); - this.controls.translate(tmpPanVector); -}; -TrackballControls.prototype.panComponent = function panComponent (x, y) { - if (!this.component) - { return; } - this._setPanVector(x, y); - this._transformPanVector(); - this.component.position.add(tmpPanVector); - this.component.updateMatrix(); -}; -TrackballControls.prototype.panAtom = function panAtom (x, y) { - if (!this.atom || !this.component) - { return; } - this.atom.positionToVector3(tmpAtomVector); - tmpAtomVector.add(this.viewer.translationGroup.position); - tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix); - this._setPanVector(x, y, tmpAtomVector.z); - this._transformPanVector(); - this.atom.positionAdd(tmpPanVector); - this.component.updateRepresentations({ 'position': true }); -}; -TrackballControls.prototype.rotate = function rotate (x, y) { - var ref = this._getRotateXY(x, y); - var dx = ref[0]; - var dy = ref[1]; - // rotate around screen X then screen Y - this._getCameraRotation(tmpRotateMatrix); - tmpRotateVector.set(1, 0, 0); // X axis - tmpRotateVector.applyMatrix4(tmpRotateMatrix); // screen X - tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy); - tmpRotateVector.set(0, 1, 0); // Y axis - tmpRotateVector.applyMatrix4(tmpRotateMatrix); // screen Y - tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx); - tmpRotateQuaternion.multiply(tmpRotateQuaternion2); - tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion); - this.controls.applyMatrix(tmpRotateMatrix); -}; -TrackballControls.prototype.zRotate = function zRotate (x, y) { - var dz = this.rotateSpeed * ((-x + y) / -2) * 0.01; - tmpRotateZMatrix.makeRotationZ(dz); - this.controls.applyMatrix(tmpRotateZMatrix); -}; -TrackballControls.prototype.rotateComponent = function rotateComponent (x, y) { - if (!this.component) - { return; } - var ref = this._getRotateXY(x, y); - var dx = ref[0]; - var dy = ref[1]; - this._getCameraRotation(tmpRotateCameraMatrix); - tmpRotateMatrix.extractRotation(this.component.transform); - tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix); - tmpRotateMatrix.getInverse(tmpRotateMatrix); - tmpRotateMatrix.premultiply(tmpRotateCameraMatrix); - tmpRotateVector.set(1, 0, 0); - tmpRotateVector.applyMatrix4(tmpRotateMatrix); - tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy); - tmpRotateVector.set(0, 1, 0); - tmpRotateVector.applyMatrix4(tmpRotateMatrix); - tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx); - tmpRotateXMatrix.multiply(tmpRotateYMatrix); - tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix); - this.component.quaternion.premultiply(tmpRotateQuaternion); - this.component.quaternion.normalize(); - this.component.updateMatrix(); -}; - -Object.defineProperties( TrackballControls.prototype, prototypeAccessors$4 ); - -/** - * @file Picking Proxy - * @author Alexander Rose - * @private - */ -var tmpVec = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -function closer(x, a, b) { - return x.distanceTo(a) < x.distanceTo(b); -} -/** - * Picking proxy class. - */ -var PickingProxy = function PickingProxy(pickingData, stage) { - this.stage = stage; - this.pid = pickingData.pid; - this.picker = pickingData.picker; - /** - * @type {Object} - */ - this.instance = pickingData.instance; - /** - * @type {Stage} - */ - this.stage = stage; - /** - * @type {ViewerControls} - */ - this.controls = stage.viewerControls; - /** - * @type {MouseObserver} - */ - this.mouse = stage.mouseObserver; -}; - -var prototypeAccessors$5 = { type: { configurable: true },altKey: { configurable: true },ctrlKey: { configurable: true },metaKey: { configurable: true },shiftKey: { configurable: true },canvasPosition: { configurable: true },component: { configurable: true },object: { configurable: true },position: { configurable: true },closestBondAtom: { configurable: true },closeAtom: { configurable: true },arrow: { configurable: true },atom: { configurable: true },axes: { configurable: true },bond: { configurable: true },box: { configurable: true },cone: { configurable: true },clash: { configurable: true },contact: { configurable: true },cylinder: { configurable: true },distance: { configurable: true },ellipsoid: { configurable: true },octahedron: { configurable: true },point: { configurable: true },mesh: { configurable: true },slice: { configurable: true },sphere: { configurable: true },tetrahedron: { configurable: true },torus: { configurable: true },surface: { configurable: true },unitcell: { configurable: true },unknown: { configurable: true },volume: { configurable: true },wideline: { configurable: true } }; -/** - * Kind of the picked data - * @type {String} - */ -prototypeAccessors$5.type.get = function () { return this.picker.type; }; -/** - * If the `alt` key was pressed - * @type {Boolean} - */ -prototypeAccessors$5.altKey.get = function () { return this.mouse.altKey; }; -/** - * If the `ctrl` key was pressed - * @type {Boolean} - */ -prototypeAccessors$5.ctrlKey.get = function () { return this.mouse.ctrlKey; }; -/** - * If the `meta` key was pressed - * @type {Boolean} - */ -prototypeAccessors$5.metaKey.get = function () { return this.mouse.metaKey; }; -/** - * If the `shift` key was pressed - * @type {Boolean} - */ -prototypeAccessors$5.shiftKey.get = function () { return this.mouse.shiftKey; }; -/** - * Position of the mouse on the canvas - * @type {Vector2} - */ -prototypeAccessors$5.canvasPosition.get = function () { return this.mouse.canvasPosition; }; -/** - * The component the picked data is part of - * @type {Component} - */ -prototypeAccessors$5.component.get = function () { - return this.stage.getComponentsByObject(this.picker.data).list[0]; // TODO -}; -/** - * The picked object data - * @type {Object} - */ -prototypeAccessors$5.object.get = function () { - return this.picker.getObject(this.pid); -}; -/** - * The 3d position in the scene of the picked object - * @type {Vector3} - */ -prototypeAccessors$5.position.get = function () { - return this.picker.getPosition(this.pid, this.instance, this.component); -}; -/** - * The atom of a picked bond that is closest to the mouse - * @type {AtomProxy} - */ -prototypeAccessors$5.closestBondAtom.get = function () { - if (this.type !== 'bond' || !this.bond) - { return undefined; } - var bond = this.bond; - var controls = this.controls; - var cp = this.canvasPosition; - var v1 = bond.atom1.positionToVector3(); - var v2 = bond.atom2.positionToVector3(); - v1.applyMatrix4(this.component.matrix); - v2.applyMatrix4(this.component.matrix); - var acp1 = controls.getPositionOnCanvas(v1); - var acp2 = controls.getPositionOnCanvas(v2); - return closer(cp, acp1, acp2) ? bond.atom1 : bond.atom2; -}; -/** - * Close-by atom - * @type {AtomProxy} - */ -prototypeAccessors$5.closeAtom.get = function () { - var cp = this.canvasPosition; - var ca = this.closestBondAtom; - if (!ca) - { return undefined; } - var v = ca.positionToVector3().applyMatrix4(this.component.matrix); - var acp = this.controls.getPositionOnCanvas(v); - ca.positionToVector3(tmpVec); - if (this.instance) - { tmpVec.applyMatrix4(this.instance.matrix); } - tmpVec.applyMatrix4(this.component.matrix); - var viewer = this.controls.viewer; - tmpVec.add(viewer.translationGroup.position); - tmpVec.applyMatrix4(viewer.rotationGroup.matrix); - var scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z); - var sc = this.component; - var radius = sc.getMaxRepresentationRadius(ca.index); - //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius) - if (cp.distanceTo(acp) <= radius / scaleFactor) { - return ca; - } - else { - return undefined; - } -}; -/** - * @type {Object} - */ -prototypeAccessors$5.arrow.get = function () { return this._objectIfType('arrow'); }; -/** - * @type {AtomProxy} - */ -prototypeAccessors$5.atom.get = function () { return this._objectIfType('atom'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.axes.get = function () { return this._objectIfType('axes'); }; -/** - * @type {BondProxy} - */ -prototypeAccessors$5.bond.get = function () { return this._objectIfType('bond'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.box.get = function () { return this._objectIfType('box'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.cone.get = function () { return this._objectIfType('cone'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.clash.get = function () { return this._objectIfType('clash'); }; -/** - * @type {BondProxy} - */ -prototypeAccessors$5.contact.get = function () { return this._objectIfType('contact'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.cylinder.get = function () { return this._objectIfType('cylinder'); }; -/** - * @type {BondProxy} - */ -prototypeAccessors$5.distance.get = function () { return this._objectIfType('distance'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.ellipsoid.get = function () { return this._objectIfType('ellipsoid'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.octahedron.get = function () { return this._objectIfType('octahedron'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.point.get = function () { return this._objectIfType('point'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.mesh.get = function () { return this._objectIfType('mesh'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.slice.get = function () { return this._objectIfType('slice'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.sphere.get = function () { return this._objectIfType('sphere'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.tetrahedron.get = function () { return this._objectIfType('tetrahedron'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.torus.get = function () { return this._objectIfType('torus'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.surface.get = function () { return this._objectIfType('surface'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.unitcell.get = function () { return this._objectIfType('unitcell'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.unknown.get = function () { return this._objectIfType('unknown'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.volume.get = function () { return this._objectIfType('volume'); }; -/** - * @type {Object} - */ -prototypeAccessors$5.wideline.get = function () { return this._objectIfType('wideline'); }; -PickingProxy.prototype._objectIfType = function _objectIfType (type) { - return this.type === type ? this.object : undefined; -}; -PickingProxy.prototype.getLabel = function getLabel () { - var atom = this.atom || this.closeAtom; - var msg = 'nothing'; - if (this.arrow) { - msg = this.arrow.name; - } - else if (atom) { - msg = "atom: " + (atom.qualifiedName()) + " (" + (atom.structure.name) + ")"; - } - else if (this.axes) { - msg = 'axes'; - } - else if (this.bond) { - msg = "bond: " + (this.bond.atom1.qualifiedName()) + " - " + (this.bond.atom2.qualifiedName()) + " (" + (this.bond.structure.name) + ")"; - } - else if (this.box) { - msg = this.box.name; - } - else if (this.cone) { - msg = this.cone.name; - } - else if (this.clash) { - msg = "clash: " + (this.clash.clash.sele1) + " - " + (this.clash.clash.sele2); - } - else if (this.contact) { - msg = (this.contact.type) + ": " + (this.contact.atom1.qualifiedName()) + " - " + (this.contact.atom2.qualifiedName()) + " (" + (this.contact.atom1.structure.name) + ")"; - } - else if (this.cylinder) { - msg = this.cylinder.name; - } - else if (this.distance) { - msg = "distance: " + (this.distance.atom1.qualifiedName()) + " - " + (this.distance.atom2.qualifiedName()) + " (" + (this.distance.structure.name) + ")"; - } - else if (this.ellipsoid) { - msg = this.ellipsoid.name; - } - else if (this.octahedron) { - msg = this.octahedron.name; - } - else if (this.point) { - msg = this.point.name; - } - else if (this.mesh) { - msg = "mesh: " + (this.mesh.name || this.mesh.serial) + " (" + (this.mesh.shape.name) + ")"; - } - else if (this.slice) { - msg = "slice: " + (this.slice.value.toPrecision(3)) + " (" + (this.slice.volume.name) + ")"; - } - else if (this.sphere) { - msg = this.sphere.name; - } - else if (this.surface) { - msg = "surface: " + (this.surface.surface.name); - } - else if (this.tetrahedron) { - msg = this.tetrahedron.name; - } - else if (this.torus) { - msg = this.torus.name; - } - else if (this.unitcell) { - msg = "unitcell: " + (this.unitcell.unitcell.spacegroup) + " (" + (this.unitcell.structure.name) + ")"; - } - else if (this.unknown) { - msg = 'unknown'; - } - else if (this.volume) { - msg = "volume: " + (this.volume.value.toPrecision(3)) + " (" + (this.volume.volume.name) + ")"; - } - else if (this.wideline) { - msg = this.wideline.name; - } - return msg; -}; - -Object.defineProperties( PickingProxy.prototype, prototypeAccessors$5 ); - -/** - * @file Picking Controls - * @author Alexander Rose - * @private - */ -/** - * Picking controls - */ -var PickingControls = function PickingControls(stage) { - this.stage = stage; - this.viewer = stage.viewer; -}; -/** - * get picking data - * @param {Number} x - canvas x coordinate - * @param {Number} y - canvas y coordinate - * @return {PickingProxy|undefined} picking proxy - */ -PickingControls.prototype.pick = function pick (x, y) { - var pickingData = this.viewer.pick(x, y); - if (pickingData.picker && - pickingData.picker.type !== 'ignore' && - pickingData.pid !== undefined) { - var pickerArray = pickingData.picker.array; - if (pickerArray && pickingData.pid >= pickerArray.length) { - console.error('pid >= picker.array.length'); - } - else { - return new PickingProxy(pickingData, this.stage); - } - } -}; - -/** - * @file Viewer Controls - * @author Alexander Rose - * @private - */ -/** - * Orientation matrix, a 4x4 transformation matrix with rotation part - * used for scene rotation, scale part for scene camera distance and - * position part for scene translation - * @typedef {Matrix4} OrientationMatrix - orientation matrix - */ -var tmpQ = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); -var tmpP = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpS = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpCanvasVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpScaleVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpRotateMatrix$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateVector$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpAlignMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -/** - * Viewer controls - */ -var ViewerControls = function ViewerControls(stage) { - this.stage = stage; - this.signals = { - changed: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.viewer = stage.viewer; -}; - -var prototypeAccessors$6 = { position: { configurable: true },rotation: { configurable: true } }; -/** - * scene center position - * @type {Vector3} - */ -prototypeAccessors$6.position.get = function () { - return this.viewer.translationGroup.position; -}; -/** - * scene rotation - * @type {Quaternion} - */ -prototypeAccessors$6.rotation.get = function () { - return this.viewer.rotationGroup.quaternion; -}; -/** - * Trigger render and emit changed event - * @emits {ViewerControls.signals.changed} - * @return {undefined} - */ -ViewerControls.prototype.changed = function changed () { - this.viewer.requestRender(); - this.signals.changed.dispatch(); -}; -ViewerControls.prototype.getPositionOnCanvas = function getPositionOnCanvas (position, optionalTarget) { - var canvasPosition = ensureVector2(optionalTarget); - var viewer = this.viewer; - tmpCanvasVector.copy(position) - .add(viewer.translationGroup.position) - .applyMatrix4(viewer.rotationGroup.matrix) - .project(viewer.camera); - return canvasPosition.set((tmpCanvasVector.x + 1) * viewer.width / 2, (tmpCanvasVector.y + 1) * viewer.height / 2); -}; -ViewerControls.prototype.getCanvasScaleFactor = function getCanvasScaleFactor (z) { - if ( z === void 0 ) z = 0; - - var camera = this.viewer.camera; - if (camera instanceof __WEBPACK_IMPORTED_MODULE_0_three__["E" /* OrthographicCamera */]) { - return 1 / camera.zoom; - } - else { - z = Math.abs(z); - z += this.getCameraDistance(); - var fov = degToRad(camera.fov); - var unitHeight = 2.0 * z * Math.tan(fov / 2); - return unitHeight / this.viewer.height; - } -}; -/** - * get scene orientation - * @param {Matrix4} optionalTarget - pre-allocated target matrix - * @return {OrientationMatrix} scene orientation - */ -ViewerControls.prototype.getOrientation = function getOrientation (optionalTarget) { - var m = ensureMatrix4(optionalTarget); - m.copy(this.viewer.rotationGroup.matrix); - var z = this.getCameraDistance(); - m.scale(tmpScaleVector.set(z, z, z)); - m.setPosition(this.viewer.translationGroup.position); - return m; -}; -/** - * set scene orientation - * @param {OrientationMatrix|Array} orientation - scene orientation - * @return {undefined} - */ -ViewerControls.prototype.orient = function orient (orientation) { - ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS); - var v = this.viewer; - v.rotationGroup.setRotationFromQuaternion(tmpQ); - v.translationGroup.position.copy(tmpP); - v.cameraDistance = tmpS.z; - v.updateZoom(); - this.changed(); -}; -/** - * translate scene - * @param {Vector3|Array} vector - translation vector - * @return {undefined} - */ -ViewerControls.prototype.translate = function translate (vector) { - this.viewer.translationGroup.position - .add(ensureVector3(vector)); - this.changed(); -}; -/** - * center scene - * @param {Vector3|Array} position - center position - * @return {undefined} - */ -ViewerControls.prototype.center = function center (position) { - this.viewer.translationGroup.position - .copy(ensureVector3(position)).negate(); - this.changed(); -}; -/** - * "zoom" scene by moving camera closer to origin - * @param {Number} delta - zoom change - * @return {undefined} - */ -ViewerControls.prototype.zoom = function zoom (delta) { - this.distance(this.getCameraDistance() * (1 - delta)); -}; -/** - * get camera distance - */ -ViewerControls.prototype.getCameraDistance = function getCameraDistance () { - return this.viewer.cameraDistance; -}; -/** - * camera distance - * @param {Number} z - distance - * @return {undefined} - */ -ViewerControls.prototype.distance = function distance (distance$1) { - // Math.abs because distance used to be "z", normally negative. - // Math.max to prevent us from getting _too_ close. - this.viewer.cameraDistance = Math.max(Math.abs(distance$1), 0.2); - this.viewer.updateZoom(); - this.changed(); -}; -/** - * spin scene on axis - * @param {Vector3|Array} axis - rotation axis - * @param {Number} angle - amount to spin - * @return {undefined} - */ -ViewerControls.prototype.spin = function spin (axis, angle) { - tmpRotateMatrix$1.getInverse(this.viewer.rotationGroup.matrix); - tmpRotateVector$1 - .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix$1); - this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector$1, angle); - this.changed(); -}; -/** - * rotate scene - * @param {Quaternion|Array} quaternion - rotation quaternion - * @return {undefined} - */ -ViewerControls.prototype.rotate = function rotate (quaternion) { - this.viewer.rotationGroup - .setRotationFromQuaternion(ensureQuaternion(quaternion)); - this.changed(); -}; -/** - * align scene to basis matrix - * @param {Matrix4|Array} basis - basis matrix - * @return {undefined} - */ -ViewerControls.prototype.align = function align (basis) { - tmpAlignMatrix.getInverse(ensureMatrix4(basis)); - this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix); - this.changed(); -}; -/** - * apply rotation matrix to scene - * @param {Matrix4|Array} matrix - rotation matrix - * @return {undefined} - */ -ViewerControls.prototype.applyMatrix = function applyMatrix (matrix) { - this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix)); - this.changed(); -}; - -Object.defineProperties( ViewerControls.prototype, prototypeAccessors$6 ); - -/** - * @file Animation - * @author Alexander Rose - * @private - */ -/** - * Animation. Base animation class. - * @interface - */ -var Animation = function Animation(duration, controls) { - var ref; - - var args = [], len = arguments.length - 2; - while ( len-- > 0 ) args[ len ] = arguments[ len + 2 ]; - this.pausedTime = -1; - this.elapsedDuration = 0; - this.pausedDuration = 0; - this.ignoreGlobalToggle = false; - this._paused = false; - this._resolveList = []; - this.duration = defaults(duration, 1000); - this.controls = controls; - this.startTime = window.performance.now(); - (ref = this)._init.apply(ref, args); -}; - -var prototypeAccessors$7 = { done: { configurable: true },paused: { configurable: true } }; -/** - * True when animation has finished - */ -prototypeAccessors$7.done.get = function () { - return this.alpha === 1; -}; -/** - * True when animation is paused - */ -prototypeAccessors$7.paused.get = function () { - return this._paused; -}; -Animation.prototype.tick = function tick (stats) { - if (this._paused) - { return; } - this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration; - if (this.duration === 0) { - this.alpha = 1; - } - else { - this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration); - } - this._tick(stats); - if (this.done) { - this._resolveList.forEach(function (resolve) { return resolve(); }); - } - return this.done; -}; -/** - * Pause animation - * @param {boolean} [hold] - put animation on a hold which - * must be release before it can be resumed - */ -Animation.prototype.pause = function pause (hold) { - if (hold) - { this._hold = true; } - if (this.pausedTime === -1) { - this.pausedTime = window.performance.now(); - } - this._paused = true; -}; -/** - * Resume animation - * @param {Boolean} [releaseHold] - release a hold on the animation - */ -Animation.prototype.resume = function resume (releaseHold) { - if (!releaseHold && this._hold) - { return; } - this.pausedDuration += window.performance.now() - this.pausedTime; - this._paused = false; - this._hold = false; - this.pausedTime = -1; -}; -/** - * Toggle animation - */ -Animation.prototype.toggle = function toggle () { - if (this._paused) { - this.resume(); - } - else { - this.pause(); - } -}; -/** - * Promise-like interface - */ -Animation.prototype.then = function then (callback) { - var this$1 = this; - - var p; - if (this.done) { - p = Promise.resolve(); - } - else { - p = new Promise(function (resolve) { return this$1._resolveList.push(resolve); }); - } - return p.then(callback); -}; - -Object.defineProperties( Animation.prototype, prototypeAccessors$7 ); -/** - * Spin animation. Spin around an axis. - */ -var SpinAnimation = /*@__PURE__*/(function (Animation) { - function SpinAnimation(duration, controls) { - var args = [], len = arguments.length - 2; - while ( len-- > 0 ) args[ len ] = arguments[ len + 2 ]; - - Animation.apply(this, [ defaults(duration, Infinity), controls ].concat( args )); - } - - if ( Animation ) SpinAnimation.__proto__ = Animation; - SpinAnimation.prototype = Object.create( Animation && Animation.prototype ); - SpinAnimation.prototype.constructor = SpinAnimation; - SpinAnimation.prototype._init = function _init (axis, angle) { - if (Array.isArray(axis)) { - this.axis = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().fromArray(axis); - } - else { - this.axis = defaults(axis, new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 1, 0)); - } - this.angle = defaults(angle, 0.01); - }; - SpinAnimation.prototype._tick = function _tick (stats) { - if (!this.axis || !this.angle) - { return; } - this.controls.spin(this.axis, this.angle * stats.lastDuration / 16); - }; - - return SpinAnimation; -}(Animation)); -/** - * Rock animation. Rock around an axis. - */ -var RockAnimation = /*@__PURE__*/(function (Animation) { - function RockAnimation(duration, controls) { - var args = [], len = arguments.length - 2; - while ( len-- > 0 ) args[ len ] = arguments[ len + 2 ]; - - Animation.apply(this, [ defaults(duration, Infinity), controls ].concat( args )); - this.angleSum = 0; - this.direction = 1; - } - - if ( Animation ) RockAnimation.__proto__ = Animation; - RockAnimation.prototype = Object.create( Animation && Animation.prototype ); - RockAnimation.prototype.constructor = RockAnimation; - RockAnimation.prototype._init = function _init (axis, angleStep, angleEnd) { - if (Array.isArray(axis)) { - this.axis = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().fromArray(axis); - } - else { - this.axis = defaults(axis, new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 1, 0)); - } - this.angleStep = defaults(angleStep, 0.01); - this.angleEnd = defaults(angleEnd, 0.2); - }; - RockAnimation.prototype._tick = function _tick (stats) { - if (!this.axis || !this.angleStep || !this.angleEnd) - { return; } - var alpha = smoothstep(0, 1, Math.abs(this.angleSum) / this.angleEnd); - var angle = this.angleStep * this.direction * (1.1 - alpha); - this.controls.spin(this.axis, angle * stats.lastDuration / 16); - this.angleSum += this.angleStep; - if (this.angleSum >= this.angleEnd) { - this.direction *= -1; - this.angleSum = -this.angleEnd; - } - }; - - return RockAnimation; -}(Animation)); -/** - * Move animation. Move from one position to another. - */ -var MoveAnimation = /*@__PURE__*/(function (Animation) { - function MoveAnimation () { - Animation.apply(this, arguments); - } - - if ( Animation ) MoveAnimation.__proto__ = Animation; - MoveAnimation.prototype = Object.create( Animation && Animation.prototype ); - MoveAnimation.prototype.constructor = MoveAnimation; - - MoveAnimation.prototype._init = function _init (moveFrom, moveTo) { - this.moveFrom = ensureVector3(defaults(moveFrom, new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]())); - this.moveTo = ensureVector3(defaults(moveTo, new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]())); - }; - MoveAnimation.prototype._tick = function _tick ( /* stats */) { - this.controls.position.lerpVectors(this.moveFrom, this.moveTo, this.alpha).negate(); - this.controls.changed(); - }; - - return MoveAnimation; -}(Animation)); -/** - * Zoom animation. Gradually change the zoom level. - */ -var ZoomAnimation = /*@__PURE__*/(function (Animation) { - function ZoomAnimation () { - Animation.apply(this, arguments); - } - - if ( Animation ) ZoomAnimation.__proto__ = Animation; - ZoomAnimation.prototype = Object.create( Animation && Animation.prototype ); - ZoomAnimation.prototype.constructor = ZoomAnimation; - - ZoomAnimation.prototype._init = function _init (zoomFrom, zoomTo) { - this.zoomFrom = zoomFrom; - this.zoomTo = zoomTo; - }; - ZoomAnimation.prototype._tick = function _tick () { - this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha)); - }; - - return ZoomAnimation; -}(Animation)); -/** - * Rotate animation. Rotate from one orientation to another. - */ -var RotateAnimation = /*@__PURE__*/(function (Animation) { - function RotateAnimation() { - Animation.apply(this, arguments); - this._currentRotation = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); - } - - if ( Animation ) RotateAnimation.__proto__ = Animation; - RotateAnimation.prototype = Object.create( Animation && Animation.prototype ); - RotateAnimation.prototype.constructor = RotateAnimation; - RotateAnimation.prototype._init = function _init (rotateFrom, rotateTo) { - this.rotateFrom = ensureQuaternion(rotateFrom); - this.rotateTo = ensureQuaternion(rotateTo); - this._currentRotation = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); - }; - RotateAnimation.prototype._tick = function _tick () { - this._currentRotation - .copy(this.rotateFrom) - .slerp(this.rotateTo, this.alpha); - this.controls.rotate(this._currentRotation); - }; - - return RotateAnimation; -}(Animation)); -/** - * Value animation. Call callback with interpolated value. - */ -var ValueAnimation = /*@__PURE__*/(function (Animation) { - function ValueAnimation () { - Animation.apply(this, arguments); - } - - if ( Animation ) ValueAnimation.__proto__ = Animation; - ValueAnimation.prototype = Object.create( Animation && Animation.prototype ); - ValueAnimation.prototype.constructor = ValueAnimation; - - ValueAnimation.prototype._init = function _init (valueFrom, valueTo, callback) { - this.valueFrom = valueFrom; - this.valueTo = valueTo; - this.callback = callback; - }; - ValueAnimation.prototype._tick = function _tick ( /* stats */) { - this.callback(lerp(this.valueFrom, this.valueTo, this.alpha)); - }; - - return ValueAnimation; -}(Animation)); -/** - * Timeout animation. Call callback after duration. - */ -var TimeoutAnimation = /*@__PURE__*/(function (Animation) { - function TimeoutAnimation () { - Animation.apply(this, arguments); - } - - if ( Animation ) TimeoutAnimation.__proto__ = Animation; - TimeoutAnimation.prototype = Object.create( Animation && Animation.prototype ); - TimeoutAnimation.prototype.constructor = TimeoutAnimation; - - TimeoutAnimation.prototype._init = function _init (callback) { - this.callback = callback; - }; - TimeoutAnimation.prototype._tick = function _tick () { - if (this.alpha === 1) - { this.callback(); } - }; - - return TimeoutAnimation; -}(Animation)); -/** - * Animation list. - */ -var AnimationList = function AnimationList(list) { - if ( list === void 0 ) list = []; - - this._resolveList = []; - this._list = list; -}; - -var prototypeAccessors$1$1 = { done: { configurable: true } }; -/** - * True when all animations have finished - */ -prototypeAccessors$1$1.done.get = function () { - return this._list.every(function (animation) { - return animation.done; - }); -}; -/** - * Promise-like interface - */ -AnimationList.prototype.then = function then (callback) { - var this$1 = this; - - var p; - if (this.done) { - p = Promise.resolve(); - } - else { - p = new Promise(function (resolve) { - this$1._resolveList.push(resolve); - this$1._list.forEach(function (animation) { - animation.then(function () { - this$1._resolveList.forEach(function (callback) { - callback(); - }); - this$1._resolveList.length = 0; - }); - }); - }); - } - return p.then(callback); -}; - -Object.defineProperties( AnimationList.prototype, prototypeAccessors$1$1 ); - -/** - * @file Animation Controls - * @author Alexander Rose - * @private - */ -/** - * Animation controls - */ -var AnimationControls = function AnimationControls(stage) { - this.stage = stage; - this.animationList = []; - this.finishedList = []; - this.viewer = stage.viewer; - this.controls = stage.viewerControls; -}; - -var prototypeAccessors$8 = { paused: { configurable: true } }; -/** - * True when all animations are paused - * @type {Boolean} - */ -prototypeAccessors$8.paused.get = function () { - return this.animationList.every(function (animation) { return animation.paused; }); -}; -/** - * Add an animation - */ -AnimationControls.prototype.add = function add (animation) { - if (animation.duration === 0) { - animation.tick(this.viewer.stats); - } - else { - this.animationList.push(animation); - } - return animation; -}; -/** - * Remove an animation - */ -AnimationControls.prototype.remove = function remove (animation) { - var list = this.animationList; - var index = list.indexOf(animation); - if (index > -1) { - list.splice(index, 1); - } -}; -/** - * Run all animations - */ -AnimationControls.prototype.run = function run (stats) { - var finishedList = this.finishedList; - var animationList = this.animationList; - var n = animationList.length; - for (var i = 0; i < n; ++i) { - var animation = animationList[i]; - // tick returns true when finished - if (animation.tick(stats)) { - finishedList.push(animation); - } - } - var m = finishedList.length; - if (m) { - for (var j = 0; j < m; ++j) { - this.remove(finishedList[j]); - } - finishedList.length = 0; - } -}; -/** - * Add a spin animation - * @param {Vector3} axis - axis to spin around - * @param {Number} angle - amount to spin per frame, radians - * @param {Number} duration - animation time in milliseconds - * @return {SpinAnimation} the animation - */ -AnimationControls.prototype.spin = function spin (axis, angle, duration) { - return this.add(new SpinAnimation(duration, this.controls, axis, angle)); -}; -/** - * Add a rock animation - * @param {Vector3} axis - axis to rock around - * @param {Number} angle - amount to spin per frame, radians - * @param {Number} end - maximum extend of motion, radians - * @param {Number} duration - animation time in milliseconds - * @return {SpinAnimation} the animation - */ -AnimationControls.prototype.rock = function rock (axis, angle, end, duration) { - return this.add(new RockAnimation(duration, this.controls, axis, angle, end)); -}; -/** - * Add a rotate animation - * @param {Quaternion} rotateTo - target rotation - * @param {Number} duration - animation time in milliseconds - * @return {RotateAnimation} the animation - */ -AnimationControls.prototype.rotate = function rotate (rotateTo, duration) { - var rotateFrom = this.viewer.rotationGroup.quaternion.clone(); - return this.add(new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)); -}; -/** - * Add a move animation - * @param {Vector3} moveTo - target position - * @param {Number} duration - animation time in milliseconds - * @return {MoveAnimation} the animation - */ -AnimationControls.prototype.move = function move (moveTo, duration) { - var moveFrom = this.controls.position.clone().negate(); - return this.add(new MoveAnimation(duration, this.controls, moveFrom, moveTo)); -}; -/** - * Add a zoom animation - * @param {Number} zoomTo - target distance - * @param {Number} duration - animation time in milliseconds - * @return {ZoomAnimation} the animation - */ -AnimationControls.prototype.zoom = function zoom (zoomTo, duration) { - var zoomFrom = this.viewer.camera.position.z; - return this.add(new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)); -}; -/** - * Add a zoom and a move animation - * @param {Vector3} moveTo - target position - * @param {Number} zoomTo - target distance - * @param {Number} duration - animation time in milliseconds - * @return {Array} the animations - */ -AnimationControls.prototype.zoomMove = function zoomMove (moveTo, zoomTo, duration) { - return new AnimationList([ - this.move(moveTo, duration), - this.zoom(zoomTo, duration) - ]); -}; -/** - * Add an orient animation - * @param {OrientationMatrix|Array} orientTo - target orientation - * @param {Number} duration - animation time in milliseconds - * @return {Array} the animations - */ -AnimationControls.prototype.orient = function orient (orientTo, duration) { - var p = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var q = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); - var s = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - ensureMatrix4(orientTo).decompose(p, q, s); - return new AnimationList([ - this.move(p.negate(), duration), - this.rotate(q, duration), - this.zoom(-s.x, duration) - ]); -}; -/** - * Add a value animation - * @param {Number} valueFrom - start value - * @param {Number} valueTo - target value - * @param {Function} callback - called on every tick - * @param {Number} duration - animation time in milliseconds - * @return {ValueAnimation} the animation - */ -AnimationControls.prototype.value = function value (valueFrom, valueTo, callback, duration) { - return this.add(new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)); -}; -/** - * Add a timeout animation - * @param {Function} callback - called after duration - * @param {Number} duration - timeout in milliseconds - * @return {TimeoutAnimation} the animation - */ -AnimationControls.prototype.timeout = function timeout (callback, duration) { - return this.add(new TimeoutAnimation(duration, this.controls, callback)); -}; -/** - * Add a component spin animation - * @param {Component} component - object to move - * @param {Vector3} axis - axis to spin around - * @param {Number} angle - amount to spin per frame, radians - * @param {Number} duration - animation time in milliseconds - * @return {SpinAnimation} the animation - */ -AnimationControls.prototype.spinComponent = function spinComponent (component, axis, angle, duration) { - return this.add( - // TODO - new SpinAnimation(duration, component.controls, axis, angle)); -}; -/** - * Add a component rock animation - * @param {Component} component - object to move - * @param {Vector3} axis - axis to rock around - * @param {Number} angle - amount to spin per frame, radians - * @param {Number} end - maximum extend of motion, radians - * @param {Number} duration - animation time in milliseconds - * @return {SpinAnimation} the animation - */ -AnimationControls.prototype.rockComponent = function rockComponent (component, axis, angle, end, duration) { - return this.add( - // TODO - new RockAnimation(duration, component.controls, axis, angle, end)); -}; -/** - * Add a component move animation - * @param {Component} component - object to move - * @param {Vector3} moveTo - target position - * @param {Number} duration - animation time in milliseconds - * @return {MoveAnimation} the animation - */ -AnimationControls.prototype.moveComponent = function moveComponent (component, moveTo, duration) { - var moveFrom = component.controls.position.clone().negate(); - return this.add( - // TODO - new MoveAnimation(duration, component.controls, moveFrom, moveTo)); -}; -/** - * Pause all animations - * @return {undefined} - */ -AnimationControls.prototype.pause = function pause () { - this.animationList.forEach(function (animation) { return animation.pause(); }); -}; -/** - * Resume all animations - * @return {undefined} - */ -AnimationControls.prototype.resume = function resume () { - this.animationList.forEach(function (animation) { return animation.resume(); }); -}; -/** - * Toggle all animations - * @return {undefined} - */ -AnimationControls.prototype.toggle = function toggle () { - if (this.paused) { - this.resume(); - } - else { - this.pause(); - } -}; -/** - * Clear all animations - * @return {undefined} - */ -AnimationControls.prototype.clear = function clear () { - this.animationList.length = 0; -}; -AnimationControls.prototype.dispose = function dispose () { - this.clear(); -}; - -Object.defineProperties( AnimationControls.prototype, prototypeAccessors$8 ); - -/** - * @file Queue - * @author Alexander Rose - * @private - */ -var Queue = function Queue(fn, argList) { - this.fn = fn; - this.queue = []; - this.pending = false; - this.next = this.next.bind(this); - if (argList) { - for (var i = 0, il = argList.length; i < il; ++i) { - this.queue.push(argList[i]); - } - this.next(); - } -}; -Queue.prototype.run = function run (arg) { - this.fn(arg, this.next); -}; -Queue.prototype.next = function next () { - var this$1 = this; - - var arg = this.queue.shift(); - if (arg !== undefined) { - this.pending = true; - setTimeout(function () { return this$1.run(arg); }); - } - else { - this.pending = false; - } -}; -Queue.prototype.push = function push (arg) { - this.queue.push(arg); - if (!this.pending) - { this.next(); } -}; -Queue.prototype.kill = function kill () { - this.queue.length = 0; -}; -Queue.prototype.length = function length () { - return this.queue.length; -}; - -/** - * @file Representation - * @author Alexander Rose - * @private - */ -/** - * Representation parameter object. - * @typedef {Object} RepresentationParameters - representation parameters - * @property {Boolean} [lazy] - only build & update the representation when visible - * otherwise defer changes until set visible again - * @property {Integer} [clipNear] - position of camera near/front clipping plane - * in percent of scene bounding box - * @property {Integer} [clipRadius] - radius of clipping sphere - * @property {Vector3} [clipCenter] - position of for spherical clipping - * @property {Boolean} [flatShaded] - render flat shaded - * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent - * @property {Boolean} [depthWrite] - depth write - * @property {String} [side] - which triangle sides to render, "front" front-side, - * "back" back-side, "double" front- and back-side - * @property {Boolean} [wireframe] - render as wireframe - * @property {String} [colorScheme] - color scheme - * @property {String} [colorScale] - color scale, either a string for a - * predefined scale or an array of - * colors to be used as the scale - * @property {Boolean} [colorReverse] - reverse color scale - * @property {Color} [colorValue] - color value - * @property {Integer[]} [colorDomain] - scale value range - * @property {Integer} colorDomain.0 - min value - * @property {Integer} colorDomain.1 - max value - * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl - * @property {Float} [roughness] - how rough the material is, between 0 and 1 - * @property {Float} [metalness] - how metallic the material is, between 0 and 1 - * @property {Color} [diffuse] - diffuse color for lighting - * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal - * @property {Boolean} [useInteriorColor] - use interior color - * @property {Color} [interiorColor] - interior color - * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened - * @property {Boolean} [disablePicking] - disable picking - */ -/** - * Representation object - * @interface - * @param {Object} object - the object to be represented - * @param {Viewer} viewer - a viewer object - * @param {RepresentationParameters} [params] - representation parameters - */ -var Representation = function Representation(object, viewer, params) { - // eslint-disable-next-line no-unused-vars - // const p = params || {} - this.type = ''; - this.parameters = { - lazy: { - type: 'boolean' - }, - clipNear: { - type: 'range', step: 1, max: 100, min: 0, buffer: true - }, - clipRadius: { - type: 'number', precision: 1, max: 1000, min: 0, buffer: true - }, - clipCenter: { - type: 'vector3', precision: 1, buffer: true - }, - flatShaded: { - type: 'boolean', buffer: true - }, - opacity: { - type: 'range', step: 0.01, max: 1, min: 0, buffer: true - }, - depthWrite: { - type: 'boolean', buffer: true - }, - side: { - type: 'select', - buffer: true, - options: { front: 'front', back: 'back', double: 'double' } - }, - wireframe: { - type: 'boolean', buffer: true - }, - colorScheme: { - type: 'select', - update: 'color', - options: {} - }, - colorScale: { - type: 'select', - update: 'color', - options: ColormakerRegistry$1.getScales() - }, - colorReverse: { - type: 'boolean', update: 'color' - }, - colorValue: { - type: 'color', update: 'color' - }, - colorDomain: { - type: 'hidden', update: 'color' - }, - colorMode: { - type: 'select', - update: 'color', - options: ColormakerRegistry$1.getModes() - }, - roughness: { - type: 'range', step: 0.01, max: 1, min: 0, buffer: true - }, - metalness: { - type: 'range', step: 0.01, max: 1, min: 0, buffer: true - }, - diffuse: { - type: 'color', buffer: true - }, - diffuseInterior: { - type: 'boolean', buffer: true - }, - useInteriorColor: { - type: 'boolean', buffer: true - }, - interiorColor: { - type: 'color', buffer: true - }, - interiorDarkening: { - type: 'range', step: 0.01, max: 1, min: 0, buffer: true - }, - matrix: { - type: 'hidden', buffer: true - }, - disablePicking: { - type: 'boolean', rebuild: true - } - }; - /** - * @type {Viewer} - */ - this.viewer = viewer; - /** - * Counter that keeps track of tasks related to the creation of - * the representation, including surface calculations. - * @type {Counter} - */ - this.tasks = new Counter(); - /** - * @type {Queue} - * @private - */ - this.queue = new Queue(this.make.bind(this)); - /** - * @type {Array} - * @private - */ - this.bufferList = []; - if (this.parameters.colorScheme) { - this.parameters.colorScheme.options = ColormakerRegistry$1.getSchemes(); - } - this.toBePrepared = false; -}; -Representation.prototype.init = function init (params) { - var p = params || {}; - this.clipNear = defaults(p.clipNear, 0); - this.clipRadius = defaults(p.clipRadius, 0); - this.clipCenter = defaults(p.clipCenter, new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); - this.flatShaded = defaults(p.flatShaded, false); - this.side = defaults(p.side, 'double'); - this.opacity = defaults(p.opacity, 1.0); - this.depthWrite = defaults(p.depthWrite, true); - this.wireframe = defaults(p.wireframe, false); - this.setColor(p.color, p); - this.colorScheme = defaults(p.colorScheme, 'uniform'); - this.colorScale = defaults(p.colorScale, ''); - this.colorReverse = defaults(p.colorReverse, false); - this.colorValue = defaults(p.colorValue, 0x909090); - this.colorDomain = defaults(p.colorDomain, undefined); - this.colorMode = defaults(p.colorMode, 'hcl'); - this.visible = defaults(p.visible, true); - this.quality = defaults(p.quality, undefined); - this.roughness = defaults(p.roughness, 0.4); - this.metalness = defaults(p.metalness, 0.0); - this.diffuse = defaults(p.diffuse, 0xffffff); - this.diffuseInterior = defaults(p.diffuseInterior, false); - this.useInteriorColor = defaults(p.useInteriorColor, false); - this.interiorColor = defaults(p.interiorColor, 0x222222); - this.interiorDarkening = defaults(p.interiorDarkening, 0); - this.lazy = defaults(p.lazy, false); - this.lazyProps = { - build: false, - bufferParams: {}, - what: {} - }; - this.matrix = defaults(p.matrix, new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]()); - this.disablePicking = defaults(p.disablePicking, false); - // handle common parameters when applicable - var tp = this.parameters; - if (tp.sphereDetail === true) { - tp.sphereDetail = { - type: 'integer', max: 3, min: 0, rebuild: 'impostor' - }; - } - if (tp.radialSegments === true) { - tp.radialSegments = { - type: 'integer', max: 25, min: 5, rebuild: 'impostor' - }; - } - if (tp.openEnded === true) { - tp.openEnded = { - type: 'boolean', rebuild: 'impostor', buffer: true - }; - } - if (tp.disableImpostor === true) { - tp.disableImpostor = { - type: 'boolean', rebuild: true - }; - } - if (p.quality === 'low') { - if (tp.sphereDetail) - { this.sphereDetail = 0; } - if (tp.radialSegments) - { this.radialSegments = 5; } - } - else if (p.quality === 'medium') { - if (tp.sphereDetail) - { this.sphereDetail = 1; } - if (tp.radialSegments) - { this.radialSegments = 10; } - } - else if (p.quality === 'high') { - if (tp.sphereDetail) - { this.sphereDetail = 2; } - if (tp.radialSegments) - { this.radialSegments = 20; } - } - else { - if (tp.sphereDetail) { - this.sphereDetail = defaults(p.sphereDetail, 1); - } - if (tp.radialSegments) { - this.radialSegments = defaults(p.radialSegments, 10); - } - } - if (tp.openEnded) { - this.openEnded = defaults(p.openEnded, true); - } - if (tp.disableImpostor) { - this.disableImpostor = defaults(p.disableImpostor, false); - } -}; -Representation.prototype.getColorParams = function getColorParams (p) { - return Object.assign({ - scheme: this.colorScheme, - scale: this.colorScale, - reverse: this.colorReverse, - value: this.colorValue, - domain: this.colorDomain, - mode: this.colorMode - }, p); -}; -Representation.prototype.getBufferParams = function getBufferParams (p) { - if ( p === void 0 ) p = {}; - - return Object.assign({ - clipNear: this.clipNear, - clipRadius: this.clipRadius, - clipCenter: this.clipCenter, - flatShaded: this.flatShaded, - opacity: this.opacity, - depthWrite: this.depthWrite, - side: this.side, - wireframe: this.wireframe, - roughness: this.roughness, - metalness: this.metalness, - diffuse: this.diffuse, - diffuseInterior: this.diffuseInterior, - useInteriorColor: this.useInteriorColor, - interiorColor: this.interiorColor, - interiorDarkening: this.interiorDarkening, - matrix: this.matrix, - disablePicking: this.disablePicking - }, p); -}; -Representation.prototype.setColor = function setColor (value, p) { - var types = Object.keys(ColormakerRegistry$1.getSchemes()); - if (typeof value === 'string' && types.includes(value.toLowerCase())) { - if (p) { - p.colorScheme = value; - } - else { - this.setParameters({ colorScheme: value }); - } - } - else if (value !== undefined) { - var val = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](value).getHex(); //TODO - if (p) { - p.colorScheme = 'uniform'; - p.colorValue = val; - } - else { - this.setParameters({ - colorScheme: 'uniform', colorValue: val - }); - } - } - return this; -}; -// TODO -Representation.prototype.prepare = function prepare (cb) { -}; -Representation.prototype.create = function create () { - // this.bufferList.length = 0; -}; -Representation.prototype.update = function update (what) { - this.build(); -}; -Representation.prototype.build = function build (updateWhat) { - if (this.lazy && (!this.visible || !this.opacity)) { - this.lazyProps.build = true; - return; - } - if (!this.toBePrepared) { - this.tasks.increment(); - this.make(); - return; - } - // don't let tasks accumulate - if (this.queue.length() > 0) { - this.tasks.change(1 - this.queue.length()); - this.queue.kill(); - } - else { - this.tasks.increment(); - } - this.queue.push(updateWhat || false); -}; -Representation.prototype.make = function make (updateWhat, callback) { - var this$1 = this; - - if (Debug) - { Log.time('Representation.make ' + this.type); } - var _make = function () { - if (updateWhat) { - this$1.update(updateWhat); - this$1.viewer.requestRender(); - this$1.tasks.decrement(); - if (callback) - { callback(); } - } - else { - this$1.clear(); - this$1.create(); - if (!this$1.manualAttach && !this$1.disposed) { - if (Debug) - { Log.time('Representation.attach ' + this$1.type); } - this$1.attach(function () { - if (Debug) - { Log.timeEnd('Representation.attach ' + this$1.type); } - this$1.tasks.decrement(); - if (callback) - { callback(); } - }); - } - } - if (Debug) - { Log.timeEnd('Representation.make ' + this$1.type); } - }; - if (this.toBePrepared) { - this.prepare(_make); - } - else { - _make(); - } -}; -Representation.prototype.attach = function attach (callback) { - this.setVisibility(this.visible); - callback(); -}; -/** - * Set the visibility of the representation - * @param {Boolean} value - visibility flag - * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer - * @return {Representation} this object - */ -Representation.prototype.setVisibility = function setVisibility (value, noRenderRequest) { - this.visible = value; - if (this.visible && this.opacity) { - var lazyProps = this.lazyProps; - var bufferParams = lazyProps.bufferParams; - var what = lazyProps.what; - if (lazyProps.build) { - lazyProps.build = false; - this.build(); - return this; - } - else if (Object.keys(bufferParams).length || Object.keys(what).length) { - lazyProps.bufferParams = {}; - lazyProps.what = {}; - this.updateParameters(bufferParams, what); - } - } - this.bufferList.forEach(function (buffer) { - buffer.setVisibility(value); - }); - if (!noRenderRequest) - { this.viewer.requestRender(); } - return this; -}; -/** - * Set the visibility of the representation - * @param {RepresentationParameters} params - parameters object - * @param {Object} [what] - buffer data attributes to be updated, - * note that this needs to be implemented in the - * derived classes. Generally it allows more - * fine-grained control over updating than - * forcing a rebuild. - * @param {Boolean} what.position - update position data - * @param {Boolean} what.color - update color data - * @param {Boolean} [rebuild] - whether or not to rebuild the representation - * @return {Representation} this object - */ -Representation.prototype.setParameters = function setParameters (params, what, rebuild) { - if ( what === void 0 ) what = {}; - if ( rebuild === void 0 ) rebuild = false; - - var p = params || {}; - var tp = this.parameters; - var bufferParams = {}; - if (!this.opacity && p.opacity !== undefined) { - if (this.lazyProps.build) { - this.lazyProps.build = false; - rebuild = true; - } - else { - Object.assign(bufferParams, this.lazyProps.bufferParams); - Object.assign(what, this.lazyProps.what); - this.lazyProps.bufferParams = {}; - this.lazyProps.what = {}; - } - } - this.setColor(p.color, p); - for (var name in p) { - if (p[name] === undefined) - { continue; } - if (tp[name] === undefined) - { continue; } - if (tp[name].int) - { p[name] = parseInt(p[name]); } - if (tp[name].float) - { p[name] = parseFloat(p[name]); } - // no value change - if (p[name] === this[name] && (!p[name].equals || p[name].equals(this[name]))) - { continue; } - if (this[name] && this[name].copy && p[name].copy) { - this[name].copy(p[name]); - } - else if (this[name] && this[name].set) { - this[name].set(p[name]); - } - else { - this[name] = p[name]; - } - // buffer param - if (tp[name].buffer) { - if (tp[name].buffer === true) { - bufferParams[name] = p[name]; - } - else { - var key = tp[name].buffer; - bufferParams[key] = p[name]; - } - } - // mark for update - if (tp[name].update) { - what[tp[name].update] = true; - } - // mark for rebuild - if (tp[name].rebuild && - !(tp[name].rebuild === 'impostor' && - ExtensionFragDepth && !this.disableImpostor)) { - rebuild = true; - } - } - // - if (rebuild) { - this.build(); - } - else { - this.updateParameters(bufferParams, what); - } - return this; -}; -Representation.prototype.updateParameters = function updateParameters (bufferParams, what) { - if ( bufferParams === void 0 ) bufferParams = {}; - - if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) { - Object.assign(this.lazyProps.bufferParams, bufferParams); - Object.assign(this.lazyProps.what, what); - return; - } - this.bufferList.forEach(function (buffer) { - buffer.setParameters(bufferParams); - }); - if (Object.keys(what).length) { - this.update(what); // update buffer attribute - } - this.viewer.requestRender(); -}; -Representation.prototype.getParameters = function getParameters () { - var this$1 = this; - - var params = { - lazy: this.lazy, - visible: this.visible, - quality: this.quality - }; - Object.keys(this.parameters).forEach(function (name) { - if (this$1.parameters[name] !== null) { - params[name] = this$1[name]; - } - }); - return params; -}; -Representation.prototype.clear = function clear () { - var this$1 = this; - - this.bufferList.forEach(function (buffer) { - this$1.viewer.remove(buffer); - buffer.dispose(); - }); - this.bufferList.length = 0; - this.viewer.requestRender(); -}; -Representation.prototype.dispose = function dispose () { - this.disposed = true; - this.queue.kill(); - this.tasks.dispose(); - this.clear(); -}; - -/** - * @file Worker - * @author Alexander Rose - * @private - */ -var _Worker = function _Worker(name) { - var this$1 = this; - - this.pending = 0; - this.postCount = 0; - this.onmessageDict = {}; - this.onerrorDict = {}; - this.name = name; - this.blobUrl = window.URL.createObjectURL(WorkerRegistry$1.get(name)); - this.worker = new Worker(this.blobUrl); - WorkerRegistry$1.activeWorkerCount += 1; - this.worker.onmessage = function (event) { - this$1.pending -= 1; - var postId = event.data.__postId; - if (Debug) - { Log.timeEnd('Worker.postMessage ' + name + ' #' + postId); } - var onmessage = this$1.onmessageDict[postId]; - if (onmessage) { - onmessage.call(this$1.worker, event); - } - delete this$1.onmessageDict[postId]; - delete this$1.onerrorDict[postId]; - }; - this.worker.onerror = function (event) { - this$1.pending -= 1; - if (event.data) { - var postId = event.data.__postId; - var onerror = this$1.onerrorDict[postId]; - if (onerror) { - onerror.call(this$1.worker, event); - } - else { - Log.error('Worker.onerror', postId, name, event); - } - delete this$1.onmessageDict[postId]; - delete this$1.onerrorDict[postId]; - } - else { - Log.error('Worker.onerror', name, event); - } - }; -}; -_Worker.prototype.post = function post (aMessage, transferList, onmessage, onerror) { - if ( aMessage === void 0 ) aMessage = {}; - - this.onmessageDict[this.postCount] = onmessage; - this.onerrorDict[this.postCount] = onerror; - aMessage.__name = this.name; - aMessage.__postId = this.postCount; - aMessage.__debug = Debug; - if (Debug) - { Log.time(("Worker.postMessage " + (this.name) + " #" + (this.postCount))); } - try { - this.worker.postMessage(aMessage, transferList); - } - catch (error) { - Log.error('worker.post:', error); - this.worker.postMessage(aMessage); - } - this.pending += 1; - this.postCount += 1; - return this; -}; -_Worker.prototype.terminate = function terminate () { - if (this.worker) { - this.worker.terminate(); - window.URL.revokeObjectURL(this.blobUrl); - WorkerRegistry$1.activeWorkerCount -= 1; - } - else { - Log.log('no worker to terminate'); - } -}; - -/** - * @file Worker Pool - * @author Alexander Rose - * @private - */ -var WorkerPool = function WorkerPool(name, maxCount) { - if ( maxCount === void 0 ) maxCount = 2; - - this.pool = []; - this.count = 0; - this.maxCount = Math.min(8, maxCount); - this.name = name; -}; -WorkerPool.prototype.post = function post (aMessage, transferList, onmessage, onerror) { - if ( aMessage === void 0 ) aMessage = {}; - - var worker = this.getNextWorker(); - if (worker) { - worker.post(aMessage, transferList, onmessage, onerror); - } - else { - console.error('unable to get worker from pool'); - } - return this; -}; -WorkerPool.prototype.terminate = function terminate () { - this.pool.forEach(function (worker) { - worker.terminate(); - }); -}; -WorkerPool.prototype.getNextWorker = function getNextWorker () { - var nextWorker; - var minPending = Infinity; - for (var i = 0; i < this.maxCount; ++i) { - if (i >= this.count) { - nextWorker = new _Worker(this.name); - this.pool.push(nextWorker); - this.count += 1; - break; - } - var worker = this.pool[i]; - if (worker.pending === 0) { - nextWorker = worker; - break; - } - else if (worker.pending < minPending) { - minPending = worker.pending; - nextWorker = worker; - } - } - return nextWorker; -}; -WorkerPool.prototype.constructor = WorkerPool; - -/** - * @file Vector Utils - * @author Alexander Rose - * @private - */ -function calculateMeanVector3(array) { - var n = array.length; - var m = n / 3; - var x = 0; - var y = 0; - var z = 0; - for (var i = 0; i < n; i += 3) { - x += array[i + 0]; - y += array[i + 1]; - z += array[i + 2]; - } - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](x / m, y / m, z / m); -} -function projectPointOnVector(point, vector, origin) { - if (origin) { - point.sub(origin).projectOnVector(vector).add(origin); - } - else { - point.projectOnVector(vector); - } - return point; -} -function computeBoundingBox(array) { - var minX = +Infinity; - var minY = +Infinity; - var minZ = +Infinity; - var maxX = -Infinity; - var maxY = -Infinity; - var maxZ = -Infinity; - for (var i = 0, l = array.length; i < l; i += 3) { - var x = array[i]; - var y = array[i + 1]; - var z = array[i + 2]; - if (x < minX) - { minX = x; } - if (y < minY) - { minY = y; } - if (z < minZ) - { minZ = z; } - if (x > maxX) - { maxX = x; } - if (y > maxY) - { maxY = y; } - if (z > maxZ) - { maxZ = z; } - } - return [ - v3new([minX, minY, minZ]), - v3new([maxX, maxY, maxZ]) - ]; -} -computeBoundingBox.__deps = [v3new]; -function applyMatrix4toVector3array(m, a) { - for (var i = 0, il = a.length; i < il; i += 3) { - var x = a[i]; - var y = a[i + 1]; - var z = a[i + 2]; - a[i] = m[0] * x + m[4] * y + m[8] * z + m[12]; - a[i + 1] = m[1] * x + m[5] * y + m[9] * z + m[13]; - a[i + 2] = m[2] * x + m[6] * y + m[10] * z + m[14]; - } -} -function applyMatrix3toVector3array(m, a) { - for (var i = 0, il = a.length; i < il; i += 3) { - var x = a[i]; - var y = a[i + 1]; - var z = a[i + 2]; - a[i] = m[0] * x + m[3] * y + m[6] * z; - a[i + 1] = m[1] * x + m[4] * y + m[7] * z; - a[i + 2] = m[2] * x + m[5] * y + m[8] * z; - } -} -function normalizeVector3array(a) { - for (var i = 0, il = a.length; i < il; i += 3) { - var x = a[i]; - var y = a[i + 1]; - var z = a[i + 2]; - var len2 = x * x + y * y + z * z; - if (len2 > 0) { // avoid divide by zero - var s = 1 / Math.sqrt(len2); - a[i] = x * s; - a[i + 1] = y * s; - a[i + 2] = z * s; - } - // else leave as all zeros - } -} -function v3new(array) { - return new Float32Array(array || 3); // TODO -} -function v3cross(out, a, b) { - var ax = a[0]; - var ay = a[1]; - var az = a[2]; - var bx = b[0]; - var by = b[1]; - var bz = b[2]; - out[0] = ay * bz - az * by; - out[1] = az * bx - ax * bz; - out[2] = ax * by - ay * bx; -} -function v3dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -} -function v3sub(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; -} -function v3add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; -} -function v3fromArray(out, array, offset) { - if ( offset === void 0 ) offset = 0; - - out[0] = array[offset]; - out[1] = array[offset + 1]; - out[2] = array[offset + 2]; -} -function v3toArray(input, array, offset) { - if ( offset === void 0 ) offset = 0; - - array[offset] = input[0]; - array[offset + 1] = input[1]; - array[offset + 2] = input[2]; -} -function v3length2(a) { - return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; -} -function v3length(a) { - return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); -} -function v3divideScalar(out, a, s) { - v3multiplyScalar(out, a, 1 / s); -} -v3divideScalar.__deps = [v3multiplyScalar]; -function v3multiplyScalar(out, a, s) { - out[0] = a[0] * s; - out[1] = a[1] * s; - out[2] = a[2] * s; -} -function v3normalize(out, a) { - var length2 = v3length2(a); - if (length2 == 0) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - } - else { - v3multiplyScalar(out, a, 1 / Math.sqrt(length2)); - } -} -v3normalize.__deps = [v3multiplyScalar, v3length2]; -function v3subScalar(out, a, s) { - out[0] = a[0] - s; - out[1] = a[1] - s; - out[2] = a[2] - s; -} -function v3addScalar(out, a, s) { - out[0] = a[0] + s; - out[1] = a[1] + s; - out[2] = a[2] + s; -} -function v3floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); -} -function v3ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); -} -function v3negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; -} - -/** - * @file Dash - * @author Alexander Rose - * @private - */ -function getFixedCountDashData(data, segmentCount) { - if ( segmentCount === void 0 ) segmentCount = 9; - - var s = Math.floor(segmentCount / 2); - var n = data.position1.length / 3; - var sn = s * n; - var sn3 = sn * 3; - var step = 1 / segmentCount; - var direction = calculateDirectionArray(data.position1, data.position2); - var position1 = new Float32Array(sn3); - var position2 = new Float32Array(sn3); - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - for (var i = 0; i < n; ++i) { - var i3 = i * 3; - v.set(direction[i3], direction[i3 + 1], direction[i3 + 2]); - var x = data.position1[i3]; - var y = data.position1[i3 + 1]; - var z = data.position1[i3 + 2]; - for (var j = 0; j < s; ++j) { - var j3 = s * i3 + j * 3; - var f1 = step * (j * 2 + 1); - var f2 = step * (j * 2 + 2); - position1[j3] = x + v.x * f1; - position1[j3 + 1] = y + v.y * f1; - position1[j3 + 2] = z + v.z * f1; - position2[j3] = x + v.x * f2; - position2[j3 + 1] = y + v.y * f2; - position2[j3 + 2] = z + v.z * f2; - } - } - var position = calculateCenterArray(position1, position2); - var color = replicateArray3Entries(data.color, s); // TODO - var color2 = color; - var d = { position: position, position1: position1, position2: position2, color: color, color2: color2 }; - if (data.radius) { // TODO - d.radius = replicateArrayEntries(data.radius, s); // TODO - } - if (data.picking && data.picking.array) { - data.picking.array = replicateArrayEntries(data.picking.array, s); - d.picking = data.picking; - } - if (data.primitiveId) { - d.primitiveId = replicateArrayEntries(data.primitiveId, s); - } - return d; -} -function getFixedLengthDashData(data, segmentLength) { - if ( segmentLength === void 0 ) segmentLength = 0.1; - - var direction = calculateDirectionArray(data.position1, data.position2); - var pos1 = []; - var pos2 = []; - var col = []; - var rad = data.radius ? [] : undefined; - var pick = data.picking ? [] : undefined; - var id = data.primitiveId ? [] : undefined; - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var n = data.position1.length / 3; - var k = 0; - for (var i = 0; i < n; ++i) { - var i3 = i * 3; - v.set(direction[i3], direction[i3 + 1], direction[i3 + 2]); - var vl = v.length(); - var segmentCount = vl / segmentLength; - var s = Math.floor(segmentCount / 2); - var step = 1 / segmentCount; - var x = data.position1[i3]; - var y = data.position1[i3 + 1]; - var z = data.position1[i3 + 2]; - for (var j = 0; j < s; ++j) { - var j3 = k * 3 + j * 3; - var f1 = step * (j * 2 + 1); - var f2 = step * (j * 2 + 2); - pos1[j3] = x + v.x * f1; - pos1[j3 + 1] = y + v.y * f1; - pos1[j3 + 2] = z + v.z * f1; - pos2[j3] = x + v.x * f2; - pos2[j3 + 1] = y + v.y * f2; - pos2[j3 + 2] = z + v.z * f2; - if (data.color) { - col[j3] = data.color[i3]; - col[j3 + 1] = data.color[i3 + 1]; - col[j3 + 2] = data.color[i3 + 2]; - } - if (rad) - { rad[k + j] = data.radius[i]; } - if (pick) { - if (data.picking.array) { - pick[k + j] = data.picking.array[i]; - } - else { - pick[k + j] = i; - } - } - if (id) - { id[k + j] = data.primitiveId[i]; } - } - k += s; - } - var position1 = new Float32Array(pos1); - var position2 = new Float32Array(pos2); - var position = calculateCenterArray(position1, position2); - var color = new Float32Array(col); - var color2 = color; - var d = { position: position, position1: position1, position2: position2, color: color, color2: color2 }; - if (rad) - { d.radius = new Float32Array(rad); } - if (pick && data.picking) { - data.picking.array = new Float32Array(pick); - d.picking = data.picking; - } - if (id) - { d.primitiveId = new Float32Array(id); } - return d; -} -function getFixedLengthWrappedDashData(data, segmentLength) { - if ( segmentLength === void 0 ) segmentLength = 0.1; - - var direction = calculateDirectionArray(data.position1, data.position2); - var pos1 = []; - var pos2 = []; - var col = []; - var rad = data.radius ? [] : undefined; - var pick = data.picking ? [] : undefined; - var id = data.primitiveId ? [] : undefined; - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var n = data.position1.length / 3; - var remaining = segmentLength; - var drawing = true; - var k = 0; - var k3 = 0; - var kprev = 0; - for (var i = 0; i < n; ++i) { - var i3 = i * 3; - var x = data.position1[i3]; - var y = data.position1[i3 + 1]; - var z = data.position1[i3 + 2]; - v.set(direction[i3], direction[i3 + 1], direction[i3 + 2]); - var vl = v.length(); - if (drawing) { - pos1[k3] = x; - pos1[k3 + 1] = y; - pos1[k3 + 2] = z; - } - var dist = remaining; - var inv = 1 / vl; - while (dist < vl) { - var a = drawing ? pos2 : pos1; - a[k3] = x + v.x * dist * inv; - a[k3 + 1] = y + v.y * dist * inv; - a[k3 + 2] = z + v.z * dist * inv; - if (drawing) { - k++; - k3 = k * 3; - } - drawing = !drawing; - remaining = segmentLength; - dist += segmentLength; - } - if (drawing) { - pos2[k3] = data.position2[i3]; - pos2[k3 + 1] = data.position2[i3 + 1]; - pos2[k3 + 2] = data.position2[i3 + 2]; - k++; - k3 = k * 3; - } - remaining = dist - vl; - for (var j = kprev; j < k; j++) { - if (data.color) { - var j3 = j * 3; - col[j3] = data.color[i3]; - col[j3 + 1] = data.color[i3 + 1]; - col[j3 + 2] = data.color[i3 + 2]; - } - if (rad) - { rad[j] = data.radius[i]; } - if (pick) { - if (data.picking.array) { - pick[j] = data.picking.array[i]; - } - else { - pick[j] = i; - } - } - if (id) - { id[j] = data.primitiveId[i]; } - } - kprev = k; - } - if (!drawing && n > 0) { - var k3$1 = k * 3; - pos2[k3$1] = data.position2[3 * n - 3]; - pos2[k3$1 + 1] = data.position2[3 * n - 2]; - pos2[k3$1 + 1] = data.position2[3 * n - 1]; - } - var position1 = new Float32Array(pos1); - var position2 = new Float32Array(pos2); - var position = calculateCenterArray(position1, position2); - var color = new Float32Array(col); - var color2 = color; - var d = { position: position, position1: position1, position2: position2, color: color, color2: color2 }; - if (rad) - { d.radius = new Float32Array(rad); } - if (pick && data.picking) { - data.picking.array = new Float32Array(pick); - d.picking = data.picking; - } - if (id) - { d.primitiveId = new Float32Array(id); } - return d; -} - -/** - * @file Primitive - * @author Alexander Rose - * @private - */ -function addElement(elm, array) { - if (elm.toArray !== undefined) { - elm = elm.toArray(); - } - else if (elm.x !== undefined) { - elm = [elm.x, elm.y, elm.z]; - } - else if (elm.r !== undefined) { - elm = [elm.r, elm.g, elm.b]; - } - array.push.apply(array, elm); -} -var tmpVec$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -/** - * Base class for geometry primitives - * @interface - */ -var Primitive = function Primitive () {}; - -var staticAccessors = { Picker: { configurable: true },Buffer: { configurable: true } }; - -staticAccessors.Picker.get = function () { return PickerRegistry.get(this.type); }; -staticAccessors.Buffer.get = function () { return BufferRegistry.get(this.type); }; -Primitive.getShapeKey = function getShapeKey (name) { - return this.type + name[0].toUpperCase() + name.substr(1); -}; -Primitive.expandBoundingBox = function expandBoundingBox (box, data) { }; -Primitive.valueToShape = function valueToShape (shape, name, value) { - var data = shape._primitiveData[this.getShapeKey(name)]; - var type = this.fields[name]; - switch (type) { - case 'v3': - case 'c': - addElement(value, data); - break; - default: - data.push(value); - } -}; -Primitive.objectToShape = function objectToShape (shape, data) { - var this$1 = this; - - Object.keys(this.fields).forEach(function (name) { - this$1.valueToShape(shape, name, data[name]); - }); - this.valueToShape(shape, 'name', data.name); - this.expandBoundingBox(shape.boundingBox, data); -}; -Primitive.valueFromShape = function valueFromShape (shape, pid, name) { - var data = shape._primitiveData[this.getShapeKey(name)]; - var type = this.fields[name]; - switch (type) { - case 'v3': - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().fromArray(data, 3 * pid); - case 'c': - return new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */]().fromArray(data, 3 * pid); - default: - return data[pid]; - } -}; -Primitive.objectFromShape = function objectFromShape (shape, pid) { - var this$1 = this; - - var name = this.valueFromShape(shape, pid, 'name'); - if (name === undefined) { - name = (this.type) + ": " + pid + " (" + (shape.name) + ")"; - } - var o = { shape: shape, name: name }; - Object.keys(this.fields).forEach(function (name) { - o[name] = this$1.valueFromShape(shape, pid, name); - }); - return o; -}; -Primitive.arrayFromShape = function arrayFromShape (shape, name) { - var data = shape._primitiveData[this.getShapeKey(name)]; - var type = this.fields[name]; - switch (type) { - case 's': - return data; - default: - return new Float32Array(data); - } -}; -Primitive.dataFromShape = function dataFromShape (shape) { - var this$1 = this; - - var data = {}; - if (this.Picker) { - data.picking = new this.Picker(shape); - } - Object.keys(this.fields).forEach(function (name) { - data[name] = this$1.arrayFromShape(shape, name); - }); - return data; -}; -Primitive.bufferFromShape = function bufferFromShape (shape, params) { - return new this.Buffer(this.dataFromShape(shape), params); -}; - -Object.defineProperties( Primitive, staticAccessors ); -Primitive.type = ''; -Primitive.fields = {}; -/** - * Sphere geometry primitive - */ -var SpherePrimitive = /*@__PURE__*/(function (Primitive) { - function SpherePrimitive () { - Primitive.apply(this, arguments); - } - - if ( Primitive ) SpherePrimitive.__proto__ = Primitive; - SpherePrimitive.prototype = Object.create( Primitive && Primitive.prototype ); - SpherePrimitive.prototype.constructor = SpherePrimitive; - - SpherePrimitive.positionFromShape = function positionFromShape (shape, pid) { - return this.valueFromShape(shape, pid, 'position'); - }; - SpherePrimitive.expandBoundingBox = function expandBoundingBox (box, data) { - box.expandByPoint(tmpVec$1.fromArray(data.position)); - }; - - return SpherePrimitive; -}(Primitive)); -SpherePrimitive.type = 'sphere'; -SpherePrimitive.fields = { - position: 'v3', - color: 'c', - radius: 'f' -}; -/** - * Box geometry primitive - */ -var BoxPrimitive = /*@__PURE__*/(function (Primitive) { - function BoxPrimitive () { - Primitive.apply(this, arguments); - } - - if ( Primitive ) BoxPrimitive.__proto__ = Primitive; - BoxPrimitive.prototype = Object.create( Primitive && Primitive.prototype ); - BoxPrimitive.prototype.constructor = BoxPrimitive; - - BoxPrimitive.positionFromShape = function positionFromShape (shape, pid) { - return this.valueFromShape(shape, pid, 'position'); - }; - BoxPrimitive.expandBoundingBox = function expandBoundingBox (box, data) { - box.expandByPoint(tmpVec$1.fromArray(data.position)); - }; - - return BoxPrimitive; -}(Primitive)); -BoxPrimitive.type = 'box'; -BoxPrimitive.fields = { - position: 'v3', - color: 'c', - size: 'f', - heightAxis: 'v3', - depthAxis: 'v3' -}; -/** - * Octahedron geometry primitive - */ -var OctahedronPrimitive = /*@__PURE__*/(function (BoxPrimitive) { - function OctahedronPrimitive () { - BoxPrimitive.apply(this, arguments); - }if ( BoxPrimitive ) OctahedronPrimitive.__proto__ = BoxPrimitive; - OctahedronPrimitive.prototype = Object.create( BoxPrimitive && BoxPrimitive.prototype ); - OctahedronPrimitive.prototype.constructor = OctahedronPrimitive; - - - - return OctahedronPrimitive; -}(BoxPrimitive)); -OctahedronPrimitive.type = 'octahedron'; -/** - * Tetrahedron geometry primitive - */ -var TetrahedronPrimitive = /*@__PURE__*/(function (BoxPrimitive) { - function TetrahedronPrimitive () { - BoxPrimitive.apply(this, arguments); - }if ( BoxPrimitive ) TetrahedronPrimitive.__proto__ = BoxPrimitive; - TetrahedronPrimitive.prototype = Object.create( BoxPrimitive && BoxPrimitive.prototype ); - TetrahedronPrimitive.prototype.constructor = TetrahedronPrimitive; - - - - return TetrahedronPrimitive; -}(BoxPrimitive)); -TetrahedronPrimitive.type = 'tetrahedron'; -/** - * Cylinder geometry primitive - */ -var CylinderPrimitive = /*@__PURE__*/(function (Primitive) { - function CylinderPrimitive () { - Primitive.apply(this, arguments); - } - - if ( Primitive ) CylinderPrimitive.__proto__ = Primitive; - CylinderPrimitive.prototype = Object.create( Primitive && Primitive.prototype ); - CylinderPrimitive.prototype.constructor = CylinderPrimitive; - - CylinderPrimitive.positionFromShape = function positionFromShape (shape, pid) { - var p1 = this.valueFromShape(shape, pid, 'position1'); - var p2 = this.valueFromShape(shape, pid, 'position2'); - return p1.add(p2).multiplyScalar(0.5); - }; - CylinderPrimitive.expandBoundingBox = function expandBoundingBox (box, data) { - box.expandByPoint(tmpVec$1.fromArray(data.position1)); - box.expandByPoint(tmpVec$1.fromArray(data.position2)); - }; - CylinderPrimitive.bufferFromShape = function bufferFromShape (shape, params) { - if ( params === void 0 ) params = {}; - - var data = this.dataFromShape(shape); - if (this.type === 'cylinder' && params.dashedCylinder) { - data = getFixedLengthDashData(data); - } - return new this.Buffer(data, params); - }; - - return CylinderPrimitive; -}(Primitive)); -CylinderPrimitive.type = 'cylinder'; -CylinderPrimitive.fields = { - position1: 'v3', - position2: 'v3', - color: 'c', - radius: 'f' -}; -/** - * Arrow geometry primitive - */ -var ArrowPrimitive = /*@__PURE__*/(function (CylinderPrimitive) { - function ArrowPrimitive () { - CylinderPrimitive.apply(this, arguments); - }if ( CylinderPrimitive ) ArrowPrimitive.__proto__ = CylinderPrimitive; - ArrowPrimitive.prototype = Object.create( CylinderPrimitive && CylinderPrimitive.prototype ); - ArrowPrimitive.prototype.constructor = ArrowPrimitive; - - - - return ArrowPrimitive; -}(CylinderPrimitive)); -ArrowPrimitive.type = 'arrow'; -/** - * Cone geometry primitive - */ -var ConePrimitive = /*@__PURE__*/(function (CylinderPrimitive) { - function ConePrimitive () { - CylinderPrimitive.apply(this, arguments); - }if ( CylinderPrimitive ) ConePrimitive.__proto__ = CylinderPrimitive; - ConePrimitive.prototype = Object.create( CylinderPrimitive && CylinderPrimitive.prototype ); - ConePrimitive.prototype.constructor = ConePrimitive; - - - - return ConePrimitive; -}(CylinderPrimitive)); -ConePrimitive.type = 'cone'; -/** - * Ellipsoid geometry primitive - */ -var EllipsoidPrimitive = /*@__PURE__*/(function (SpherePrimitive) { - function EllipsoidPrimitive () { - SpherePrimitive.apply(this, arguments); - }if ( SpherePrimitive ) EllipsoidPrimitive.__proto__ = SpherePrimitive; - EllipsoidPrimitive.prototype = Object.create( SpherePrimitive && SpherePrimitive.prototype ); - EllipsoidPrimitive.prototype.constructor = EllipsoidPrimitive; - - - - return EllipsoidPrimitive; -}(SpherePrimitive)); -EllipsoidPrimitive.type = 'ellipsoid'; -EllipsoidPrimitive.fields = { - position: 'v3', - color: 'c', - radius: 'f', - majorAxis: 'v3', - minorAxis: 'v3' -}; -/** - * Torus geometry primitive - */ -var TorusPrimitive = /*@__PURE__*/(function (EllipsoidPrimitive) { - function TorusPrimitive () { - EllipsoidPrimitive.apply(this, arguments); - }if ( EllipsoidPrimitive ) TorusPrimitive.__proto__ = EllipsoidPrimitive; - TorusPrimitive.prototype = Object.create( EllipsoidPrimitive && EllipsoidPrimitive.prototype ); - TorusPrimitive.prototype.constructor = TorusPrimitive; - - - - return TorusPrimitive; -}(EllipsoidPrimitive)); -TorusPrimitive.type = 'torus'; -/** - * Text geometry primitive - */ -var TextPrimitive = /*@__PURE__*/(function (Primitive) { - function TextPrimitive () { - Primitive.apply(this, arguments); - } - - if ( Primitive ) TextPrimitive.__proto__ = Primitive; - TextPrimitive.prototype = Object.create( Primitive && Primitive.prototype ); - TextPrimitive.prototype.constructor = TextPrimitive; - - TextPrimitive.positionFromShape = function positionFromShape (shape, pid) { - return this.valueFromShape(shape, pid, 'position'); - }; - TextPrimitive.expandBoundingBox = function expandBoundingBox (box, data) { - box.expandByPoint(tmpVec$1.fromArray(data.position)); - }; - - return TextPrimitive; -}(Primitive)); -TextPrimitive.type = 'text'; -TextPrimitive.fields = { - position: 'v3', - color: 'c', - size: 'f', - text: 's' -}; -/** - * Point primitive - */ -var PointPrimitive = /*@__PURE__*/(function (Primitive) { - function PointPrimitive () { - Primitive.apply(this, arguments); - } - - if ( Primitive ) PointPrimitive.__proto__ = Primitive; - PointPrimitive.prototype = Object.create( Primitive && Primitive.prototype ); - PointPrimitive.prototype.constructor = PointPrimitive; - - PointPrimitive.positionFromShape = function positionFromShape (shape, pid) { - return this.valueFromShape(shape, pid, 'position'); - }; - PointPrimitive.expandBoundingBox = function expandBoundingBox (box, data) { - box.expandByPoint(tmpVec$1.fromArray(data.position)); - }; - - return PointPrimitive; -}(Primitive)); -PointPrimitive.type = 'point'; -PointPrimitive.fields = { - position: 'v3', - color: 'c', -}; -/** - * Wideline geometry primitive - */ -var WidelinePrimitive = /*@__PURE__*/(function (Primitive) { - function WidelinePrimitive () { - Primitive.apply(this, arguments); - } - - if ( Primitive ) WidelinePrimitive.__proto__ = Primitive; - WidelinePrimitive.prototype = Object.create( Primitive && Primitive.prototype ); - WidelinePrimitive.prototype.constructor = WidelinePrimitive; - - WidelinePrimitive.positionFromShape = function positionFromShape (shape, pid) { - var p1 = this.valueFromShape(shape, pid, 'position1'); - var p2 = this.valueFromShape(shape, pid, 'position2'); - return p1.add(p2).multiplyScalar(0.5); - }; - WidelinePrimitive.expandBoundingBox = function expandBoundingBox (box, data) { - box.expandByPoint(tmpVec$1.fromArray(data.position1)); - box.expandByPoint(tmpVec$1.fromArray(data.position2)); - }; - - return WidelinePrimitive; -}(Primitive)); -WidelinePrimitive.type = 'wideline'; -WidelinePrimitive.fields = { - position1: 'v3', - position2: 'v3', - color: 'c' -}; - -/** - * @file Spatial Hash - * @author Alexander Rose - * @private - */ -function createBoundingBox(positions) { - var x = positions.x; - var y = positions.y; - var z = positions.z; - var boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - var count = x.length; - var min = boundingBox.min; - var max = boundingBox.max; - for (var i = 0; i < count; i++) { - min.x = Math.min(x[i], min.x); - min.y = Math.min(y[i], min.y); - min.z = Math.min(z[i], min.z); - max.x = Math.max(x[i], max.x); - max.y = Math.max(y[i], max.y); - max.z = Math.max(z[i], max.z); - } - return boundingBox; -} -var SpatialHash = function SpatialHash(positions, boundingBox) { - this.exp = 3; - var bb = boundingBox || createBoundingBox(positions); - this.minX = bb.min.x; - this.minY = bb.min.y; - this.minZ = bb.min.z; - this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1; - this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1; - this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1; - var n = this.boundX * this.boundY * this.boundZ; - var an = (positions.count !== undefined) ? positions.count : positions.x.length; - var xArray = positions.x; - var yArray = positions.y; - var zArray = positions.z; - var count = 0; - var grid = new Uint32Array(n); - var bucketIndex = new Int32Array(an); - for (var i = 0; i < an; ++i) { - var x = (xArray[i] - this.minX) >> this.exp; - var y = (yArray[i] - this.minY) >> this.exp; - var z = (zArray[i] - this.minZ) >> this.exp; - var idx = (((x * this.boundY) + y) * this.boundZ) + z; - if ((grid[idx] += 1) === 1) { - count += 1; - } - bucketIndex[i] = idx; - } - var bucketCount = new Uint16Array(count); - for (var i$1 = 0, j = 0; i$1 < n; ++i$1) { - var c = grid[i$1]; - if (c > 0) { - grid[i$1] = j + 1; - bucketCount[j] = c; - j += 1; - } - } - var bucketOffset = new Uint32Array(count); - for (var i$2 = 1; i$2 < count; ++i$2) { - bucketOffset[i$2] += bucketOffset[i$2 - 1] + bucketCount[i$2 - 1]; - } - var bucketFill = new Uint16Array(count); - var bucketArray = new Int32Array(an); - for (var i$3 = 0; i$3 < an; ++i$3) { - var bucketIdx = grid[bucketIndex[i$3]]; - if (bucketIdx > 0) { - var k = bucketIdx - 1; - bucketArray[bucketOffset[k] + bucketFill[k]] = i$3; - bucketFill[k] += 1; - } - } - this.grid = grid; - this.bucketCount = bucketCount; - this.bucketOffset = bucketOffset; - this.bucketArray = bucketArray; - this.xArray = xArray; - this.yArray = yArray; - this.zArray = zArray; -}; -SpatialHash.prototype.within = function within (x, y, z, r) { - var result = []; - this.eachWithin(x, y, z, r, function (atomIndex) { return result.push(atomIndex); }); - return result; -}; -SpatialHash.prototype.eachWithin = function eachWithin (x, y, z, r, callback) { - var rSq = r * r; - var loX = Math.max(0, (x - r - this.minX) >> this.exp); - var loY = Math.max(0, (y - r - this.minY) >> this.exp); - var loZ = Math.max(0, (z - r - this.minZ) >> this.exp); - var hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1); - var hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1); - var hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1); - for (var ix = loX; ix < hiX; ++ix) { - for (var iy = loY; iy < hiY; ++iy) { - for (var iz = loZ; iz < hiZ; ++iz) { - var idx = (((ix * this.boundY) + iy) * this.boundZ) + iz; - var bucketIdx = this.grid[idx]; - if (bucketIdx > 0) { - var k = bucketIdx - 1; - var offset = this.bucketOffset[k]; - var count = this.bucketCount[k]; - var end = offset + count; - for (var i = offset; i < end; ++i) { - var atomIndex = this.bucketArray[i]; - var dx = this.xArray[atomIndex] - x; - var dy = this.yArray[atomIndex] - y; - var dz = this.zArray[atomIndex] - z; - var dSq = dx * dx + dy * dy + dz * dz; - if (dSq <= rSq) - { callback(atomIndex, dSq); } - } - } - } - } - } -}; - -/** - * @file Store - * @author Alexander Rose - * @private - */ -/** - * Store base class - * @interface - */ -var Store = function Store(size) { - if ( size === void 0 ) size = 0; - - this._fields = this._defaultFields; - this._init(0); -}; -/** - * Initialize the store - * @param {Integer} size - size to initialize - * @return {undefined} - */ -Store.prototype._init = function _init (size) { - this.length = size; - this.count = 0; - for (var i = 0, il = this._fields.length; i < il; ++i) { - var ref = this._fields[i]; - var name = ref[0]; - var size$1 = ref[1]; - var type = ref[2]; - this._initField(name, size$1, type); - } -}; -/** - * Initialize a field - * @param {String} name - field name - * @param {Integer} size - element size - * @param {String} type - data type, one of int8, int16, int32, - * uint8, uint16, uint32, float32 - * @return {undefined} - */ -Store.prototype._initField = function _initField (name, size, type) { - this[name] = getTypedArray(type, this.length * size); -}; -/** - * Add a field - * @param {String} name - field name - * @param {Integer} size - element size - * @param {String} type - data type, one of int8, int16, int32, - * uint8, uint16, uint32, float32 - * @return {undefined} - */ -Store.prototype.addField = function addField (name, size, type) { - this._fields.push([name, size, type]); - this._initField(name, size, type); -}; -/** - * Resize the store to the new size - * @param {Integer} size - new size - * @return {undefined} - */ -Store.prototype.resize = function resize (size) { - // Log.time( "Store.resize" ); - this.length = Math.round(size || 0); - this.count = Math.min(this.count, this.length); - for (var i = 0, il = this._fields.length; i < il; ++i) { - var name = this._fields[i][0]; - var itemSize = this._fields[i][1]; - var arraySize = this.length * itemSize; - var tmpArray = new this[name].constructor(arraySize); - if (this[name].length > arraySize) { - tmpArray.set(this[name].subarray(0, arraySize)); - } - else { - tmpArray.set(this[name]); - } - this[name] = tmpArray; - } - // Log.timeEnd( "Store.resize" ); -}; -/** - * Resize the store to 1.5 times its current size if full - * @return {undefined} - */ -Store.prototype.growIfFull = function growIfFull () { - if (this.count >= this.length) { - var size = Math.round(this.length * 1.5); - this.resize(Math.max(256, size)); - } -}; -/** - * Copy data from one store to another - * @param {Store} other - store to copy from - * @param {Integer} thisOffset - offset to start copying to - * @param {Integer} otherOffset - offset to start copying from - * @param {Integer} length - number of entries to copy - * @return {undefined} - */ -Store.prototype.copyFrom = function copyFrom (other, thisOffset, otherOffset, length) { - for (var i = 0, il = this._fields.length; i < il; ++i) { - var name = this._fields[i][0]; - var itemSize = this._fields[i][1]; - var thisField = this[name]; - var otherField = other[name]; - for (var j = 0; j < length; ++j) { - var thisIndex = itemSize * (thisOffset + j); - var otherIndex = itemSize * (otherOffset + j); - for (var k = 0; k < itemSize; ++k) { - thisField[thisIndex + k] = otherField[otherIndex + k]; - } - } - } -}; -/** - * Copy data within this store - * @param {Integer} thisOffset - offset to start copying to - * @param {Integer} otherOffset - offset to start copying from - * @param {Integer} length - number of entries to copy - * @return {undefined} - */ -Store.prototype.copyWithin = function copyWithin (offsetTarget, offsetSource, length) { - for (var i = 0, il = this._fields.length; i < il; ++i) { - var name = this._fields[i][0]; - var itemSize = this._fields[i][1]; - var thisField = this[name]; - for (var j = 0; j < length; ++j) { - var targetIndex = itemSize * (offsetTarget + j); - var sourceIndex = itemSize * (offsetSource + j); - for (var k = 0; k < itemSize; ++k) { - thisField[targetIndex + k] = thisField[sourceIndex + k]; - } - } - } -}; -/** - * Sort entries in the store given the compare function - * @param {[type]} compareFunction - function to sort by - * @return {undefined} - */ -Store.prototype.sort = function sort (compareFunction) { - Log.time('Store.sort'); - var thisStore = this; - var tmpStore = new this.constructor(1); - function swap(index1, index2) { - if (index1 === index2) - { return; } - tmpStore.copyFrom(thisStore, 0, index1, 1); - thisStore.copyWithin(index1, index2, 1); - thisStore.copyFrom(tmpStore, index2, 0, 1); - } - function quicksort(left, right) { - if (left < right) { - var pivot = Math.floor((left + right) / 2); - var leftNew = left; - var rightNew = right; - do { - while (compareFunction(leftNew, pivot) < 0) { - leftNew += 1; - } - while (compareFunction(rightNew, pivot) > 0) { - rightNew -= 1; - } - if (leftNew <= rightNew) { - if (leftNew === pivot) { - pivot = rightNew; - } - else if (rightNew === pivot) { - pivot = leftNew; - } - swap(leftNew, rightNew); - leftNew += 1; - rightNew -= 1; - } - } while (leftNew <= rightNew); - quicksort(left, rightNew); - quicksort(leftNew, right); - } - } - quicksort(0, this.count - 1); - Log.timeEnd('Store.sort'); -}; -/** - * Empty the store - * @return {undefined} - */ -Store.prototype.clear = function clear () { - this.count = 0; -}; -/** - * Dispose of the store entries and fields - * @return {undefined} - */ -Store.prototype.dispose = function dispose () { - delete this.length; - delete this.count; - for (var i = 0, il = this._fields.length; i < il; ++i) { - var name = this._fields[i][0]; - delete this[name]; - } -}; - -/** - * @file Contact Store - * @author Alexander Rose - * @private - */ -/** - * Bond store - */ -var ContactStore = /*@__PURE__*/(function (Store$$1) { - function ContactStore () { - Store$$1.apply(this, arguments); - } - - if ( Store$$1 ) ContactStore.__proto__ = Store$$1; - ContactStore.prototype = Object.create( Store$$1 && Store$$1.prototype ); - ContactStore.prototype.constructor = ContactStore; - - var prototypeAccessors = { _defaultFields: { configurable: true } }; - - prototypeAccessors._defaultFields.get = function () { - return [ - ['index1', 1, 'int32'], - ['index2', 1, 'int32'], - ['type', 1, 'int8'] - ]; - }; - ContactStore.prototype.addContact = function addContact (index1, index2, type) { - this.growIfFull(); - var i = this.count; - if (index1 < index2) { - this.index1[i] = index1; - this.index2[i] = index2; - } - else { - this.index2[i] = index1; - this.index1[i] = index2; - } - if (type) - { this.type[i] = type; } - this.count += 1; - }; - - Object.defineProperties( ContactStore.prototype, prototypeAccessors ); - - return ContactStore; -}(Store)); - -/** - * @file Bit array - * @author Alexander Rose - * @author Paul Pillot - * @private - */ -/** - * Compute the Hamming weight of a 32-bit unsigned integer - * @param {Integer} v - a 32-bit unsigned integer - * @return {Integer} the Hamming weight - */ -function hammingWeight(v) { - // works with signed or unsigned shifts - v -= ((v >>> 1) & 0x55555555); - v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); - return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; -} -/** - * Bit array - * - * Based heavily on https://github.com/lemire/FastBitSet.js - * which is licensed under the Apache License, Version 2.0. - */ -var BitArray = function BitArray(length, setAll) { - this.length = length; - this._words = new Uint32Array((length + 32) >>> 5); - if (setAll === true) { - this.setAll(); - } -}; -/** - * Get value at index - * @param {Integer} index - the index - * @return {Boolean} value - */ -BitArray.prototype.get = function get (index) { - return (this._words[index >>> 5] & (1 << index)) !== 0; -}; -/** - * Set value at index to true - * @param {Integer} index - the index - * @return {undefined} - */ -BitArray.prototype.set = function set (index) { - this._words[index >>> 5] |= 1 << index; -}; -/** - * Set value at index to false - * @param {Integer} index - the index - * @return {undefined} - */ -BitArray.prototype.clear = function clear (index) { - this._words[index >>> 5] &= ~(1 << index); -}; -/** - * Flip value at index - * @param {Integer} index - the index - * @return {undefined} - */ -BitArray.prototype.flip = function flip (index) { - this._words[index >>> 5] ^= 1 << index; -}; -BitArray.prototype._assignRange = function _assignRange (start, end, value) { - if (end < start) - { return; } - var words = this._words; - var wordValue = value === true ? 0xFFFFFFFF : 0; - var wordStart = start >>> 5; - var wordEnd = end >>> 5; - // set complete words when applicable - for (var k = wordStart; k < wordEnd; ++k) { - words[k] = wordValue; - } - // set parts of the range not spanning complete words - var startWord = wordStart << 5; - var endWord = wordEnd << 5; - if (value === true) { - if (end - start < 32) { - for (var i = start, n = end + 1; i < n; ++i) { - words[i >>> 5] |= 1 << i; - } - } - else { - for (var i$1 = start, n$1 = startWord; i$1 < n$1; ++i$1) { - words[i$1 >>> 5] |= 1 << i$1; - } - for (var i$2 = endWord, n$2 = end + 1; i$2 < n$2; ++i$2) { - words[i$2 >>> 5] |= 1 << i$2; - } - } - } - else { - if (end - start < 32) { - for (var i$3 = start, n$3 = end + 1; i$3 < n$3; ++i$3) { - words[i$3 >>> 5] &= ~(1 << i$3); - } - } - else { - for (var i$4 = start, n$4 = startWord; i$4 < n$4; ++i$4) { - words[i$4 >>> 5] &= ~(1 << i$4); - } - for (var i$5 = endWord, n$5 = end + 1; i$5 < n$5; ++i$5) { - words[i$5 >>> 5] &= ~(1 << i$5); - } - } - } - return this; -}; -/** - * Set bits of the given range - * @param {Integer} start - start index - * @param {Integer} end - end index - * @return {BitArray} this object - */ -BitArray.prototype.setRange = function setRange (start, end) { - return this._assignRange(start, end, true); -}; -/** - * Clear bits of the given range - * @param {Integer} start - start index - * @param {Integer} end - end index - * @return {BitArray} this object - */ -BitArray.prototype.clearRange = function clearRange (start, end) { - return this._assignRange(start, end, false); -}; -/** - * Set bits at all given indices - * @param {...Integer} arguments - indices - * @return {Boolean} this object - */ -BitArray.prototype.setBits = function setBits () { - var indices = [], len = arguments.length; - while ( len-- ) indices[ len ] = arguments[ len ]; - - var words = this._words; - var n = indices.length; - for (var i = 0; i < n; ++i) { - var index = indices[i]; - words[index >>> 5] |= 1 << index; - } - return this; -}; -/** - * Clear bits at all given indices - * @param {...Integer} arguments - indices - * @return {Boolean} this object - */ -BitArray.prototype.clearBits = function clearBits () { - var indices = [], len = arguments.length; - while ( len-- ) indices[ len ] = arguments[ len ]; - - var words = this._words; - var n = indices.length; - for (var i = 0; i < n; ++i) { - var index = indices[i]; - words[index >>> 5] &= ~(1 << index); - } - return this; -}; -/** - * Set all bits of the array - * @return {BitArray} this object - */ -BitArray.prototype.setAll = function setAll () { - return this._assignRange(0, this.length - 1, true); -}; -/** - * Clear all bits of the array - * @return {BitArray} this object - */ -BitArray.prototype.clearAll = function clearAll () { - return this._assignRange(0, this.length - 1, false); -}; -/** - * Flip all the values in the array - * @return {BitArray} this object - */ -BitArray.prototype.flipAll = function flipAll () { - var count = this._words.length; - var words = this._words; - var bs = 32 - this.length % 32; - for (var k = 0; k < count - 1; ++k) { - words[k] = ~words[k]; - } - words[count - 1] = (~(words[count - 1] << bs)) >>> bs; - return this; -}; -BitArray.prototype._isRangeValue = function _isRangeValue (start, end, value) { - if (end < start) - { return; } - var words = this._words; - var wordValue = value === true ? 0xFFFFFFFF : 0; - var wordStart = start >>> 5; - var wordEnd = end >>> 5; - // set complete words when applicable - for (var k = wordStart; k < wordEnd; ++k) { - if (words[k] !== wordValue) - { return false; } - } - // set parts of the range not spanning complete words - if (end - start < 32) { - for (var i = start, n = end + 1; i < n; ++i) { - if (!!(words[i >>> 5] & (1 << i)) !== value) - { return false; } - } - } - else { - var startWord = wordStart << 5; - var endWord = wordEnd << 5; - for (var i$1 = start, n$1 = startWord << 5; i$1 < n$1; ++i$1) { - if (!!(words[i$1 >>> 5] & (1 << i$1)) !== value) - { return false; } - } - for (var i$2 = endWord, n$2 = end + 1; i$2 < n$2; ++i$2) { - if (!!(words[i$2 >>> 5] & (1 << i$2)) !== value) - { return false; } - } - } - return true; -}; -/** - * Test if bits in given range are set - * @param {Integer} start - start index - * @param {Integer} end - end index - * @return {BitArray} this object - */ -BitArray.prototype.isRangeSet = function isRangeSet (start, end) { - return this._isRangeValue(start, end, true); -}; -/** - * Test if bits in given range are clear - * @param {Integer} start - start index - * @param {Integer} end - end index - * @return {BitArray} this object - */ -BitArray.prototype.isRangeClear = function isRangeClear (start, end) { - return this._isRangeValue(start, end, false); -}; -/** - * Test if all bits in the array are set - * @return {Boolean} test result - */ -BitArray.prototype.isAllSet = function isAllSet () { - return this._isRangeValue(0, this.length - 1, true); -}; -/** - * Test if all bits in the array are clear - * @return {Boolean} test result - */ -BitArray.prototype.isAllClear = function isAllClear () { - return this._isRangeValue(0, this.length - 1, false); -}; -/** - * Test if bits at all given indices are set - * @param {...Integer} arguments - indices - * @return {Boolean} test result - */ -BitArray.prototype.isSet = function isSet () { - var indices = [], len = arguments.length; - while ( len-- ) indices[ len ] = arguments[ len ]; - - var words = this._words; - var n = indices.length; - for (var i = 0; i < n; ++i) { - var index = indices[i]; - if ((words[index >>> 5] & (1 << index)) === 0) - { return false; } - } - return true; -}; -/** - * Test if bits at all given indices are clear - * @param {...Integer} arguments - indices - * @return {Boolean} test result - */ -BitArray.prototype.isClear = function isClear () { - var indices = [], len = arguments.length; - while ( len-- ) indices[ len ] = arguments[ len ]; - - var words = this._words; - var n = indices.length; - for (var i = 0; i < n; ++i) { - var index = indices[i]; - if ((words[index >>> 5] & (1 << index)) !== 0) - { return false; } - } - return true; -}; -/** - * Test if two BitArrays are identical in all their values - * @param {BitArray} otherBitarray - the other BitArray - * @return {Boolean} test result - */ -BitArray.prototype.isEqualTo = function isEqualTo (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - for (var k = 0; k < count; ++k) { - if (words1[k] !== words2[k]) { - return false; - } - } - return true; -}; -/** - * How many set bits? - * @return {Integer} number of set bits - */ -BitArray.prototype.getSize = function getSize () { - var count = this._words.length; - var words = this._words; - var size = 0; - for (var i = 0; i < count; ++i) { - size += hammingWeight(words[i]); - } - return size; -}; -/** - * Calculate difference betwen this and another bit array. - * Store result in this object. - * @param {BitArray} otherBitarray - the other bit array - * @return {BitArray} this object - */ -BitArray.prototype.difference = function difference (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - for (var k = 0; k < count; ++k) { - words1[k] = words1[k] & ~words2[k]; - } - for (var k$1 = words1.length; k$1 < count; ++k$1) { - words1[k$1] = 0; - } - return this; -}; -/** - * Calculate union betwen this and another bit array. - * Store result in this object. - * @param {BitArray} otherBitarray - the other bit array - * @return {BitArray} this object - */ -BitArray.prototype.union = function union (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - for (var k = 0; k < count; ++k) { - words1[k] |= words2[k]; - } - for (var k$1 = words1.length; k$1 < count; ++k$1) { - words1[k$1] = 0; - } - return this; -}; -/** - * Calculate intersection betwen this and another bit array. - * Store result in this object. - * @param {BitArray} otherBitarray - the other bit array - * @return {BitArray} this object - */ -BitArray.prototype.intersection = function intersection (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - for (var k = 0; k < count; ++k) { - words1[k] &= words2[k]; - } - for (var k$1 = words1.length; k$1 < count; ++k$1) { - words1[k$1] = 0; - } - return this; -}; -/** - * Test if there is any intersection betwen this and another bit array. - * @param {BitArray} otherBitarray - the other bit array - * @return {Boolean} test result - */ -BitArray.prototype.intersects = function intersects (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - for (var k = 0; k < count; ++k) { - if ((words1[k] & words2[k]) !== 0) { - return true; - } - } - return false; -}; -/** - * Calculate the number of bits in common betwen this and another bit array. - * @param {BitArray} otherBitarray - the other bit array - * @return {Integer} size - */ -BitArray.prototype.getIntersectionSize = function getIntersectionSize (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - var size = 0; - for (var k = 0; k < count; ++k) { - size += hammingWeight(words1[k] & words2[k]); - } - return size; -}; -/** - * Calculate intersection betwen this and another bit array. - * Store result in a new bit array. - * @param {BitArray} otherBitarray - the other bit array - * @return {BitArray} the new bit array - */ -BitArray.prototype.makeIntersection = function makeIntersection (otherBitarray) { - var words1 = this._words; - var words2 = otherBitarray._words; - var count = Math.min(words1.length, words2.length); - var wordsA = new Uint32Array(count); - var intersection = Object.create(BitArray.prototype); - intersection._words = wordsA; - intersection.length = Math.min(this.length, otherBitarray.length); - for (var k = 0; k < count; ++k) { - wordsA[k] = words1[k] & words2[k]; - } - return intersection; -}; -/** - * Iterate over all set bits in the array - * @param {function( index: Integer, i: Integer )} callback - the callback - * @return {undefined} - */ -BitArray.prototype.forEach = function forEach (callback) { - var count = this._words.length; - var words = this._words; - var i = 0; - for (var k = 0; k < count; ++k) { - var w = words[k]; - while (w !== 0) { - var t = w & -w; - var index = (k << 5) + hammingWeight(t - 1); - callback(index, i); - w ^= t; - ++i; - } - } -}; -/** - * Get an array with the set bits - * @return {Array} bit indices - */ -BitArray.prototype.toArray = function toArray () { - var words = this._words; - var answer = new Array(this.getSize()); - var count = this._words.length; - var pos = 0; - for (var k = 0; k < count; ++k) { - var w = words[k]; - while (w !== 0) { - var t = w & -w; - answer[pos++] = (k << 5) + hammingWeight(t - 1); - w ^= t; - } - } - return answer; -}; -BitArray.prototype.toString = function toString () { - return '{' + this.toArray().join(',') + '}'; -}; -BitArray.prototype.toSeleString = function toSeleString () { - var sele = this.toArray().join(','); - return sele ? '@' + sele : 'NONE'; -}; -/** - * Clone this object - * @return {BitArray} the cloned object - */ -BitArray.prototype.clone = function clone () { - var clone = Object.create(BitArray.prototype); - clone.length = this.length; - clone._words = new Uint32Array(this._words); - return clone; -}; - -/** - * @file Adjacency List - * @author Alexander Rose - * @private - */ -function createAdjacencyList(edges) { - var edgeCount = edges.edgeCount; - var nodeCount = edges.nodeCount; - var nodeArray1 = edges.nodeArray1; - var nodeArray2 = edges.nodeArray2; - var countArray = new Uint8Array(nodeCount); - var offsetArray = new Int32Array(nodeCount); - // count edges per node - for (var i = 0; i < edgeCount; ++i) { - countArray[nodeArray1[i]] += 1; - countArray[nodeArray2[i]] += 1; - } - // get offsets to node edges - for (var i$1 = 1; i$1 < nodeCount; ++i$1) { - offsetArray[i$1] += offsetArray[i$1 - 1] + countArray[i$1 - 1]; - } - // prepare index array - var bondCount2 = edgeCount * 2; - var indexArray = new Int32Array(bondCount2); - for (var j = 0; j < bondCount2; ++j) { - indexArray[j] = -1; - } - // build index array - for (var i$2 = 0; i$2 < edgeCount; ++i$2) { - var idx1 = nodeArray1[i$2]; - var idx2 = nodeArray2[i$2]; - var j1 = offsetArray[idx1]; - while (indexArray[j1] !== -1 && j1 < bondCount2) { - j1 += 1; - } - indexArray[j1] = i$2; - var j2 = offsetArray[idx2]; - while (indexArray[j2] !== -1 && j2 < bondCount2) { - j2 += 1; - } - indexArray[j2] = i$2; - } - return { countArray: countArray, offsetArray: offsetArray, indexArray: indexArray }; -} - -/** - * @file Features - * @author Alexander Rose - */ -function createFeatures() { - return { - types: [], - groups: [], - centers: { x: [], y: [], z: [] }, - atomSets: [] - }; -} -function createFeatureState(type /* Unknown */, group /* Unknown */) { - if ( type === void 0 ) type = 0; - if ( group === void 0 ) group = 0; - - return { type: type, group: group, x: 0, y: 0, z: 0, atomSet: [] }; -} -function addAtom(state, atom) { - state.x += atom.x; - state.y += atom.y; - state.z += atom.z; - state.atomSet.push(atom.index); -} -function addFeature(features, state) { - var n = state.atomSet.length; - if (n > 0) { - var types = features.types; - var groups = features.groups; - var centers = features.centers; - var atomSets = features.atomSets; - types.push(state.type); - groups.push(state.group); - centers.x.push(state.x / n); - centers.y.push(state.y / n); - centers.z.push(state.z / n); - atomSets.push(state.atomSet); - } -} - -/** - * @file Structure Constants - * @author Alexander Rose - * @private - */ -// entity types -var UnknownEntity = 0; -var PolymerEntity = 1; -var NonPolymerEntity = 2; -var MacrolideEntity = 3; -var WaterEntity = 4; -// molecule types -var UnknownType = 0; -var WaterType = 1; -var IonType = 2; -var ProteinType = 3; -var RnaType = 4; -var DnaType = 5; -var SaccharideType = 6; -// backbone types -var UnknownBackboneType = 0; -var ProteinBackboneType = 1; -var RnaBackboneType = 2; -var DnaBackboneType = 3; -var CgProteinBackboneType = 4; -var CgRnaBackboneType = 5; -var CgDnaBackboneType = 6; -// chemical component types -var ChemCompProtein = [ - 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING', - 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING', - 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING', - 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING', - 'PEPTIDE LINKING', 'PEPTIDE-LIKE' -]; -var ChemCompRna = [ - 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING' -]; -var ChemCompDna = [ - 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING', - 'L-DNA LINKING', 'L-RNA LINKING' -]; -var ChemCompSaccharide = [ - 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING', - 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING', - 'SACCHARIDE' -]; -var ChemCompOther = [ - 'OTHER' -]; -var ChemCompNonPolymer = [ - 'NON-POLYMER' -]; -var ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide); -// secondary structure -var SecStrucHelix = ['h', 'g', 'i']; -var SecStrucSheet = ['e', 'b']; -var SecStrucTurn = ['s', 't', 'l', '']; -var AtomicNumbers = { - 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118 -}; -var DefaultAtomicNumber = 0; -// http://dx.doi.org/10.1021/jp8111556 (or 2.0) -var VdwRadii = { - 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0 -}; -var DefaultVdwRadius = 2.0; // C -// http://dx.doi.org/10.1039/b801115j (or 1.6) -var CovalentRadii = { - 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6 -}; -var DefaultCovalentRadius = 1.6; -var Valences = { - 1: [1], - 2: [0], - 3: [1], - 4: [2], - 5: [3], - 6: [4], - 7: [3], - 8: [2], - 9: [1], - 10: [0], - 11: [1], - 12: [2], - 13: [6], - 14: [6], - 15: [3, 5, 7], - 16: [2, 4, 6], - 17: [1], - 18: [0], - 19: [1], - 20: [2], - 31: [3], - 32: [4], - 33: [3, 5], - 34: [2, 4, 6], - 35: [1], - 36: [0], - 37: [1], - 38: [2], - 49: [3], - 50: [4], - 51: [3, 5], - 52: [2], - 53: [1, 2, 5], - 54: [0, 2], - 55: [1], - 56: [2], - 81: [3], - 82: [4], - 83: [3], - 84: [2], - 85: [1], - 86: [0], - 87: [1], - 88: [2] -}; -var DefaultValence = -1; -var OuterShellElectronCounts = { - 1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8 -}; -var DefaultOuterShellElectronCount = 2; -// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt -// https://www.nature.com/articles/nsb1096-842 -var ResidueHydrophobicity = { - // AA DGwif DGwoct Oct-IF - 'ALA': [0.17, 0.50, 0.33], - 'ARG': [0.81, 1.81, 1.00], - 'ASN': [0.42, 0.85, 0.43], - 'ASP': [1.23, 3.64, 2.41], - 'ASH': [-0.07, 0.43, 0.50], - 'CYS': [-0.24, -0.02, 0.22], - 'GLN': [0.58, 0.77, 0.19], - 'GLU': [2.02, 3.63, 1.61], - 'GLH': [-0.01, 0.11, 0.12], - 'GLY': [0.01, 1.15, 1.14], - // "His+": [ 0.96, 2.33, 1.37 ], - 'HIS': [0.17, 0.11, -0.06], - 'ILE': [-0.31, -1.12, -0.81], - 'LEU': [-0.56, -1.25, -0.69], - 'LYS': [0.99, 2.80, 1.81], - 'MET': [-0.23, -0.67, -0.44], - 'PHE': [-1.13, -1.71, -0.58], - 'PRO': [0.45, 0.14, -0.31], - 'SER': [0.13, 0.46, 0.33], - 'THR': [0.14, 0.25, 0.11], - 'TRP': [-1.85, -2.09, -0.24], - 'TYR': [-0.94, -0.71, 0.23], - 'VAL': [0.07, -0.46, -0.53] -}; -var DefaultResidueHydrophobicity = [0.00, 0.00, 0.00]; -var AA1 = { - 'HIS': 'H', - 'ARG': 'R', - 'LYS': 'K', - 'ILE': 'I', - 'PHE': 'F', - 'LEU': 'L', - 'TRP': 'W', - 'ALA': 'A', - 'MET': 'M', - 'PRO': 'P', - 'CYS': 'C', - 'ASN': 'N', - 'VAL': 'V', - 'GLY': 'G', - 'SER': 'S', - 'GLN': 'Q', - 'TYR': 'Y', - 'ASP': 'D', - 'GLU': 'E', - 'THR': 'T', - 'SEC': 'U', - 'PYL': 'O', -}; -var AA3 = Object.keys(AA1); -var RnaBases = ['A', 'C', 'T', 'G', 'U', 'I']; -var DnaBases = ['DA', 'DC', 'DT', 'DG', 'DU', 'DI']; -var PurinBases = ['A', 'G', 'I', 'DA', 'DG', 'DI']; -var Bases = RnaBases.concat(DnaBases); -var WaterNames = [ - 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC' -]; -// all chemical components with the word "ion" in their name, Sep 2016 -// -// SET SESSION group_concat_max_len = 1000000; -// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '", "') from -// ( -// SELECT count(obj_id) as c, id_ -// FROM pdb.chem_comp WHERE name LIKE "% ION%" -// GROUP BY id_ -// ) AS t1; -var IonNames = [ - '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO', - '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL', - 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4', - 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL', - 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ', - 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU', - 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN', - 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU', - 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6', - 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2', - 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI', - 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3', - 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2', - 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3', - 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4', - 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH', - 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB', - 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3', - // additional ion names - 'OHX' -]; -// all chemical components with the word "%saccharide%" in their type, Sep 2016 -// -// SET SESSION group_concat_max_len = 1000000; -// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '", "') from -// ( -// SELECT count(obj_id), id_ -// FROM pdb.chem_comp WHERE type like "%SACCHARIDE%" -// GROUP BY id_ -// ) AS t1; -var SaccharideNames = [ - '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M', - '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN', - '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C', - '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5', - '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW', - '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM', - '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB', - 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX', - 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH', - 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE', - 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D', - 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP', - 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX', - 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF', - 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG', - 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS', - 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3', - 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA', - 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT', - 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD', - 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S', - 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU', - 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6', - 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS', - 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2', - 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0', - 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ', - 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ', - 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU', - 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO', - 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2', - 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK', - 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2', - 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA', - 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN', - 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG', - 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS', - 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM', - 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ', - 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE', - 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5', - 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST', - 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4', - 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3', - 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB', - 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA', - 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S', - 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR', - 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM' -]; -var ProteinBackboneAtoms = [ - 'CA', 'C', 'N', 'O', - 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2', - 'H', 'H1', 'H2', 'H3', 'HA', 'HN', - 'BB' -]; -var NucleicBackboneAtoms = [ - 'P', 'OP1', 'OP2', 'HOP2', 'HOP3', - "O2'", "O3'", "O4'", "O5'", "C1'", "C2'", "C3'", "C4'", "C5'", - "H1'", "H2'", "H2''", "HO2'", "H3'", "H4'", "H5'", "H5''", "HO3'", "HO5'", - 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*' -]; -var ResidueTypeAtoms = {}; -ResidueTypeAtoms[ProteinBackboneType] = { - trace: 'CA', - direction1: 'C', - direction2: ['O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2'], - backboneStart: 'N', - backboneEnd: 'C' -}; -ResidueTypeAtoms[RnaBackboneType] = { - trace: ["C4'", 'C4*'], - direction1: ["C1'", 'C1*'], - direction2: ["C3'", 'C3*'], - backboneStart: 'P', - backboneEnd: ["O3'", 'O3*'] -}; -ResidueTypeAtoms[DnaBackboneType] = { - trace: ["C3'", 'C3*'], - direction1: ["C2'", 'C2*'], - direction2: ["O4'", 'O4*'], - backboneStart: 'P', - backboneEnd: ["O3'", 'O3*'] -}; -ResidueTypeAtoms[CgProteinBackboneType] = { - trace: ['CA', 'BB'], - backboneStart: ['CA', 'BB'], - backboneEnd: ['CA', 'BB'] -}; -ResidueTypeAtoms[CgRnaBackboneType] = { - trace: ["C4'", 'C4*', 'P'], - backboneStart: ["C4'", 'C4*', 'P'], - backboneEnd: ["C4'", 'C4*', 'P'] -}; -ResidueTypeAtoms[CgDnaBackboneType] = { - trace: ["C3'", 'C3*', "C2'", 'P'], - backboneStart: ["C3'", 'C3*', "C2'", 'P'], - backboneEnd: ["C3'", 'C3*', "C2'", 'P'] -}; -ResidueTypeAtoms[UnknownBackboneType] = {}; - -/** - * @file Geometry - * @author Fred Ludlow - * @author Alexander Rose - */ -function assignGeometry(totalCoordination) { - switch (totalCoordination) { - case 0: - return 0 /* Spherical */; - case 1: - return 1 /* Terminal */; - case 2: - return 2 /* Linear */; - case 3: - return 3 /* Trigonal */; - case 4: - return 4 /* Tetrahedral */; - default: - return 8 /* Unknown */; - } -} -var Angles = new Map([ - [2 /* Linear */, degToRad(180)], - [3 /* Trigonal */, degToRad(120)], - [4 /* Tetrahedral */, degToRad(109.4721)], - [6 /* Octahedral */, degToRad(90)] -]); -/** - * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1. - * @param {AtomProxy} ap1 First atom (angle centre) - * @param {AtomProxy} ap2 Second atom - * @return {number[]} Angles in radians - */ -function calcAngles(ap1, ap2) { - var angles = []; - var d1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var d2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - d1.subVectors(ap2, ap1); - ap1.eachBondedAtom(function (x) { - if (x.number !== 1 /* H */) { - d2.subVectors(x, ap1); - angles.push(d1.angleTo(d2)); - } - }); - return angles; -} -/** - * Find two neighbours of ap1 to define a plane (if possible) and - * measure angle out of plane to ap2 - * @param {AtomProxy} ap1 First atom (angle centre) - * @param {AtomProxy} ap2 Second atom (out-of-plane) - * @return {number} Angle from plane to second atom - */ -function calcPlaneAngle(ap1, ap2) { - var x1 = ap1.clone(); - var v12 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - v12.subVectors(ap2, ap1); - var neighbours = [new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()]; - var ni = 0; - ap1.eachBondedAtom(function (x) { - if (ni > 1) { - return; - } - if (x.number !== 1 /* H */) { - x1.index = x.index; - neighbours[ni++].subVectors(x, ap1); - } - }); - if (ni === 1) { - x1.eachBondedAtom(function (x) { - if (ni > 1) { - return; - } - if (x.number !== 1 /* H */ && x.index !== ap1.index) { - neighbours[ni++].subVectors(x, ap1); - } - }); - } - if (ni !== 2) { - return; - } - var cp = neighbours[0].cross(neighbours[1]); - return Math.abs((Math.PI / 2) - cp.angleTo(v12)); -} - -/** - * @file Valence Model - * @author Fred Ludlow - * @author Alexander Rose - */ -/** - * Are we involved in some kind of pi system. Either explicitly forming - * double bond or N, O next to a double bond, except: - * - * N,O with degree 4 cannot be conjugated. - * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom) - */ -function isConjugated(a) { - var _bp = a.structure.getBondProxy(); - var atomicNumber = a.number; - var hetero = atomicNumber === 8 /* O */ || atomicNumber === 7 /* N */; - if (hetero && a.bondCount === 4) { - return false; - } - var flag = false; - a.eachBond(function (b) { - if (b.bondOrder > 1) { - flag = true; - return; - } - if (hetero) { - var a2 = b.getOtherAtom(a); - a2.eachBond(function (b2) { - if (b2.bondOrder > 1) { - var atomicNumber2 = a2.number; - if ((atomicNumber2 === 15 /* P */ || atomicNumber2 === 16 /* S */) && - b2.getOtherAtom(a2).number === 8 /* O */) { - return; - } - flag = true; - } - }, _bp); // Avoid reuse of structure._bp - } - }); - return flag; -} -/* function hasExplicitCharge(r: ResidueProxy) { - let flag = false - r.eachAtom(a => { - if (a.formalCharge != null && a.formalCharge !== 0) flag = true - }) - return flag -} - -function hasExplicitHydrogen(r: ResidueProxy) { - let flag = false - r.eachAtom(a => { - if (a.number === Elements.H) flag = true - }) - return flag -} */ -function explicitValence(a) { - var v = 0; - a.eachBond(function (b) { return v += b.bondOrder; }); - return v; -} -/** - * Attempts to produce a consistent charge and implicit - * H-count for an atom. - * - * If both params.assignCharge and params.assignH, this - * approximately followsthe rules described in - * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model - * - * If only charge or hydrogens are to be assigned it takes - * a much simpler view and deduces one from the other - * - * @param {AtomProxy} a Atom to analyze - * @param {assignChargeHParams} params What to assign - */ -function calculateHydrogensCharge(a, params) { - var hydrogenCount = a.bondToElementCount(1 /* H */); - var charge = a.formalCharge || 0; - var assignCharge = (params.assignCharge === 'always' || - (params.assignCharge === 'auto' && charge === 0)); - var assignH = (params.assignH === 'always' || - (params.assignH === 'auto' && hydrogenCount === 0)); - var degree = a.bondCount; - var valence = explicitValence(a); - var conjugated = isConjugated(a); - var multiBond = (valence - degree > 0); - var implicitHCount = 0; - var geom = 8 /* Unknown */; - switch (a.number) { - case 1 /* H */: - if (assignCharge) { - if (degree === 0) { - charge = 1; - geom = 0 /* Spherical */; - } - else if (degree === 1) { - charge = 0; - geom = 1 /* Terminal */; - } - } - break; - case 6 /* C */: - // TODO: Isocyanide? - if (assignCharge) { - charge = 0; // Assume carbon always neutral - } - if (assignH) { - // Carbocation/carbanion are 3-valent - implicitHCount = Math.max(0, 4 - valence - Math.abs(charge)); - } - // Carbocation is planar, carbanion is tetrahedral - geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge)); - break; - case 7 /* N */: - if (assignCharge) { - if (!assignH) { // Trust input H explicitly: - charge = valence - 3; - } - else if (conjugated && valence < 4) { - // Neutral unless amidine/guanidine double-bonded N: - if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) { - charge = 1; - } - else { - charge = 0; - } - } - else { - // Sulfonamide nitrogen and classed as sp3 in conjugation model but - // they won't be charged - // Don't assign charge to nitrogens bound to metals - var flag = false; - a.eachBondedAtom(function (ba) { - if (ba.number === 16 /* S */ || ba.isMetal()) - { flag = true; } - }); - if (flag) - { charge = 0; } - else - { charge = 1; } - // TODO: Planarity sanity check? - } - } - if (assignH) { - // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0 - implicitHCount = Math.max(0, 3 - valence + charge); - } - if (conjugated && !multiBond) { - // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes - // Anilinic N geometry is depenent on ring electronics, for our purposes we - // assume it's trigonal! - geom = assignGeometry(degree + implicitHCount - charge); - } - else { - // Everything else, pyridine, amine, nitrile, lp plays normal role: - geom = assignGeometry(degree + implicitHCount + 1 - charge); - } - break; - case 8 /* O */: - if (assignCharge) { - if (!assignH) { - charge = valence - 2; // - } - if (valence === 1) { - a.eachBondedAtom(function (ba) { - ba.eachBond(function (b) { - var oa = b.getOtherAtom(ba); - if (oa.index !== a.index && oa.number === 8 /* O */ && b.bondOrder === 2) { - charge = -1; - } - }); - }); - } - } - if (assignH) { - // ethanol -> 1, carboxylate -> -1 - implicitHCount = Math.max(0, 2 - valence + charge); - } - if (conjugated && !multiBond) { - // carboxylate OH, phenol OH, one lone-pair taken up with conjugation - geom = assignGeometry(degree + implicitHCount - charge + 1); - } - else { - // Carbonyl (trigonal) - geom = assignGeometry(degree + implicitHCount - charge + 2); - } - break; - // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher - // oxidiation states are assumed neutral S (charge carried on O if required) - case 16 /* S */: - if (assignCharge) { - if (!assignH) { - if (valence <= 3 && !a.bondToElementCount(8 /* O */)) { - charge = valence - 2; // e.g. explicitly deprotonated thiol - } - else { - charge = 0; - } - } - } - if (assignH) { - if (valence < 2) { - implicitHCount = Math.max(0, 2 - valence + charge); - } - } - if (valence <= 3) { - // Thiol, thiolate, tioether -> tetrahedral - geom = assignGeometry(degree + implicitHCount - charge + 2); - } - break; - case 9 /* F */: - case 17 /* CL */: - case 35 /* BR */: - case 53 /* I */: - case 85 /* AT */: - // Never implicitly protonate halides - if (assignCharge) { - charge = valence - 1; - } - break; - case 3 /* LI */: - case 11 /* NA */: - case 19 /* K */: - case 37 /* RB */: - case 55 /* CS */: - case 87 /* FR */: - if (assignCharge) { - charge = 1 - valence; - } - break; - case 4 /* BE */: - case 12 /* MG */: - case 20 /* CA */: - case 38 /* SR */: - case 56 /* BA */: - case 88 /* RA */: - if (assignCharge) { - charge = 2 - valence; - } - break; - default: - console.warn('Requested charge, protonation for an unhandled element', a.element); - } - return [charge, implicitHCount, implicitHCount + hydrogenCount, geom]; -} -function ValenceModel(data, params) { - var structure = data.structure; - var n = structure.atomCount; - var charge = new Int8Array(n); - var implicitH = new Int8Array(n); - var totalH = new Int8Array(n); - var idealGeometry = new Int8Array(n); - structure.eachAtom(function (a) { - var i = a.index; - var ref = calculateHydrogensCharge(a, params); - var chg = ref[0]; - var implH = ref[1]; - var totH = ref[2]; - var geom = ref[3]; - charge[i] = chg; - implicitH[i] = implH; - totalH[i] = totH; - idealGeometry[i] = geom; - }); - return { charge: charge, implicitH: implicitH, totalH: totalH, idealGeometry: idealGeometry }; -} - -function createData(structure) { - return { - structure: structure, - '@spatialLookup': undefined, - '@valenceModel': undefined - }; -} -function valenceModel(data) { - if (data['@valenceModel']) - { return data['@valenceModel']; } - var valenceModel = ValenceModel(data, { assignCharge: 'auto', assignH: 'auto' }); - data['@valenceModel'] = valenceModel; - return valenceModel; -} - -/** - * @file Functional Groups - * @author Alexander Rose - */ -/** - * Sulfur in a sulfonic acid or sulfonate group - */ -function isSulfonicAcid(a) { - return (a.number === 16 && - a.bondToElementCount(8 /* O */) === 3); -} -/** - * Sulfur in a sulfate group - */ -function isSulfate(a) { - return (a.number === 16 && - a.bondToElementCount(8 /* O */) === 4); -} -/** - * Phosphor in a phosphate group - */ -function isPhosphate(a) { - return (a.number === 15 && - a.bondToElementCount(8 /* O */) === a.bondCount); -} -/** - * Carbon in a carboxylate group - */ -function isCarboxylate(a) { - var terminalOxygenCount = 0; - if (a.number === 6 && - a.bondToElementCount(8 /* O */) === 2 && - a.bondToElementCount(6 /* C */) === 1) { - a.eachBondedAtom(function (ba) { - if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(1 /* H */) === 1) { - ++terminalOxygenCount; - } - }); - } - return terminalOxygenCount === 2; -} -/** - * Carbon in a guanidine group - */ -function isGuanidine(a) { - var terminalNitrogenCount = 0; - if (a.number === 6 && - a.bondCount === 3 && - a.bondToElementCount(7 /* N */) === 3) { - a.eachBondedAtom(function (ba) { - if (ba.bondCount - ba.bondToElementCount(1 /* H */) === 1) { - ++terminalNitrogenCount; - } - }); - } - return terminalNitrogenCount === 2; -} -/** - * Carbon in a acetamidine group - */ -function isAcetamidine(a) { - var terminalNitrogenCount = 0; - if (a.number === 6 && - a.bondCount === 3 && - a.bondToElementCount(7 /* N */) === 2 && - a.bondToElementCount(6 /* C */) === 1) { - a.eachBondedAtom(function (ba) { - if (ba.bondCount - ba.bondToElementCount(1 /* H */) === 1) { - ++terminalNitrogenCount; - } - }); - } - return terminalNitrogenCount === 2; -} - -/** - * @file Charged - * @author Alexander Rose - * @author Fred Ludlow - */ -var PositvelyCharged = ['ARG', 'HIS', 'LYS']; -var NegativelyCharged = ['GLU', 'ASP']; -function addPositiveCharges(structure, features) { - var ref = valenceModel(structure.data); - var charge = ref.charge; - var atomInGroupDict = {}; - structure.eachResidue(function (r) { - if (PositvelyCharged.includes(r.resname)) { - var state = createFeatureState(1 /* PositiveCharge */); - r.eachAtom(function (a) { - if (a.number === 7 /* N */ && a.isSidechain()) { - addAtom(state, a); - } - }); - addFeature(features, state); - } - else if (!AA3.includes(r.resname) && !r.isNucleic()) { - r.eachAtom(function (a) { - var addGroup = false; - var state = createFeatureState(1 /* PositiveCharge */); - if (isGuanidine(a)) { - state.group = 8 /* Guanidine */; - addGroup = true; - } - else if (isAcetamidine(a)) { - state.group = 9 /* Acetamidine */; - addGroup = true; - } - if (addGroup) { - a.eachBondedAtom(function (a) { - if (a.number === 7 /* N */) { - atomInGroupDict[a.index] = true; - addAtom(state, a); - } - }); - addFeature(features, state); - } - }); - r.eachAtom(function (a) { - var state = createFeatureState(1 /* PositiveCharge */); - if (charge[a.index] > 0) { - if (!atomInGroupDict[a.index]) { - addAtom(state, a); - addFeature(features, state); - } - } - }); - } - }); -} -function addNegativeCharges(structure, features) { - var ref = valenceModel(structure.data); - var charge = ref.charge; - var atomInGroupDict = {}; - structure.eachResidue(function (r) { - if (NegativelyCharged.includes(r.resname)) { - var state = createFeatureState(2 /* NegativeCharge */); - r.eachAtom(function (a) { - if (a.number === 8 /* O */ && a.isSidechain()) { - addAtom(state, a); - } - }); - addFeature(features, state); - } - else if (Bases.includes(r.resname)) { - var state$1 = createFeatureState(2 /* NegativeCharge */); - r.eachAtom(function (a) { - if (isPhosphate(a)) { - state$1.group = 6 /* Phosphate */; - a.eachBondedAtom(function (a) { - if (a.number === 8 /* O */) - { addAtom(state$1, a); } - }); - addFeature(features, state$1); - } - }); - } - else if (!AA3.includes(r.resname) && !Bases.includes(r.resname)) { - r.eachAtom(function (a) { - var addGroup = false; - var state = createFeatureState(2 /* NegativeCharge */); - if (isSulfonicAcid(a)) { - state.group = 4 /* SulfonicAcid */; - addGroup = true; - } - else if (isPhosphate(a)) { - state.group = 6 /* Phosphate */; - addGroup = true; - } - else if (isSulfate(a)) { - state.group = 5 /* Sulfate */; - addGroup = true; - } - else if (isCarboxylate(a)) { - state.group = 10 /* Carboxylate */; - addGroup = true; - } - if (addGroup) { - a.eachBondedAtom(function (a) { - if (a.number === 8 /* O */) { - atomInGroupDict[a.index] = true; - addAtom(state, a); - } - }); - addFeature(features, state); - } - }); - r.eachAtom(function (a) { - var state = createFeatureState(2 /* NegativeCharge */); - if (charge[a.index] < 0) { - if (!atomInGroupDict[a.index]) { - addAtom(state, a); - addFeature(features, state); - } - } - }); - } - }); -} -function addAromaticRings(structure, features) { - var a = structure.getAtomProxy(); - structure.eachResidue(function (r) { - var rings = r.getAromaticRings(); - if (rings) { - var offset = r.atomOffset; - rings.forEach(function (ring) { - var state = createFeatureState(3 /* AromaticRing */); - ring.forEach(function (i) { - a.index = i + offset; - addAtom(state, a); - }); - addFeature(features, state); - }); - } - }); -} -function isIonicInteraction(ti, tj) { - return ((ti === 2 /* NegativeCharge */ && tj === 1 /* PositiveCharge */) || - (ti === 1 /* PositiveCharge */ && tj === 2 /* NegativeCharge */)); -} -function isPiStacking(ti, tj) { - return ti === 3 /* AromaticRing */ && tj === 3 /* AromaticRing */; -} -function isCationPi(ti, tj) { - return ((ti === 3 /* AromaticRing */ && tj === 1 /* PositiveCharge */) || - (ti === 1 /* PositiveCharge */ && tj === 3 /* AromaticRing */)); -} -function addChargedContacts(structure, contacts, params) { - if ( params === void 0 ) params = {}; - - var maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist); - var maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist); - var maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset); - var maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle); - var maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist); - var maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset); - var masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex); - var maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist); - // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist - var maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist; - var maxCationPiDistSq = maxCationPiDist * maxCationPiDist; - var features = contacts.features; - var spatialHash = contacts.spatialHash; - var contactStore = contacts.contactStore; - var featureSet = contacts.featureSet; - var types = features.types; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var n = types.length; - var ax = structure.atomStore.x; - var ay = structure.atomStore.y; - var az = structure.atomStore.z; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var areAtomSetsWithinDist = function (atomSet1, atomSet2, maxDist) { - var sn = atomSet1.length; - var sm = atomSet2.length; - for (var si = 0; si < sn; ++si) { - ap1.index = atomSet1[si]; - for (var sj = 0; sj < sm; ++sj) { - ap2.index = atomSet2[sj]; - if (ap1.distanceTo(ap2) <= maxDist) { - return true; - } - } - } - return false; - }; - var v1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var v2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var v3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var d1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var d2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var n1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var n2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var getNormal = function (atoms, normal) { - v1.set(ax[atoms[0]], ay[atoms[0]], az[atoms[0]]); - v2.set(ax[atoms[1]], ay[atoms[1]], az[atoms[1]]); - v3.set(ax[atoms[2]], ay[atoms[2]], az[atoms[2]]); - d1.subVectors(v1, v2); - d2.subVectors(v1, v3); - normal.crossVectors(d1, d2); - }; - var getOffset = function (i, j, normal) { - v1.set(x[i], y[i], z[i]); - v2.set(x[j], y[j], z[j]); - return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2); - }; - var add = function (i, j, ct) { - featureSet.setBits(i, j); - contactStore.addContact(i, j, ct); - }; - var loop = function ( i ) { - spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, function (j, dSq) { - if (j <= i) - { return; } - ap1.index = atomSets[i][0]; - ap2.index = atomSets[j][0]; - if (invalidAtomContact$1(ap1, ap2, masterIdx)) - { return; } - var ti = types[i]; - var tj = types[j]; - if (isIonicInteraction(ti, tj)) { - if (areAtomSetsWithinDist(atomSets[i], atomSets[j], maxIonicDist)) { - add(i, j, 1 /* IonicInteraction */); - } - } - else if (isPiStacking(ti, tj)) { - if (dSq <= maxPiStackingDistSq) { - getNormal(atomSets[i], n1); - getNormal(atomSets[j], n2); - var angle = radToDeg(n1.angleTo(n2)); - var offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1)); - if (offset <= maxPiStackingOffset) { - if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) { - add(i, j, 3 /* PiStacking */); // parallel - } - else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) { - add(i, j, 3 /* PiStacking */); // t-shaped - } - } - } - } - else if (isCationPi(ti, tj)) { - if (dSq <= maxCationPiDistSq) { - var ref = ti === 3 /* AromaticRing */ ? [i, j] : [j, i]; - var l = ref[0]; - var k = ref[1]; - getNormal(atomSets[l], n1); - var offset$1 = getOffset(k, l, n1); - if (offset$1 <= maxCationPiOffset) { - add(l, k, 2 /* CationPi */); - } - } - } - }); - }; - - for (var i = 0; i < n; ++i) loop( i ); -} - -/** - * @file Hydrogen Bonds - * @author Alexander Rose - * @author Fred Ludlow - */ -// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins -// https://doi.org/10.1002/prot.22327 -// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS) -// https://doi.org/10.1006/jmbi.1994.1334 -// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html -/** - * Potential hydrogen donor - */ -function addHydrogenDonors(structure, features) { - var ref = valenceModel(structure.data); - var totalH = ref.totalH; - structure.eachAtom(function (a) { - var state = createFeatureState(4 /* HydrogenDonor */); - var an = a.number; - if (isHistidineNitrogen(a)) { - // include both nitrogen atoms in histidine due to - // their often ambiguous protonation assignment - addAtom(state, a); - addFeature(features, state); - } - else if (totalH[a.index] > 0 && - (an === 7 /* N */ || an === 8 /* O */ || an === 16 /* S */)) { - addAtom(state, a); - addFeature(features, state); - } - }); -} -/** - * Weak hydrogen donor. - */ -function addWeakHydrogenDonors(structure, features) { - var ref = valenceModel(structure.data); - var totalH = ref.totalH; - structure.eachAtom(function (a) { - if (a.number === 6 /* C */ && - totalH[a.index] > 0 && - (a.bondToElementCount(7 /* N */) > 0 || - a.bondToElementCount(8 /* O */) > 0 || - inAromaticRingWithElectronNegativeElement(a))) { - var state = createFeatureState(9 /* WeakHydrogenDonor */); - addAtom(state, a); - addFeature(features, state); - } - }); -} -function inAromaticRingWithElectronNegativeElement(a) { - if (!a.isAromatic()) - { return false; } - var ringData = a.residueType.getRings(); - if (!ringData) - { return false; } - var hasElement = false; - var rings = ringData.rings; - rings.forEach(function (ring) { - if (hasElement) - { return; } // already found one - if (ring.some(function (idx) { return (a.index - a.residueAtomOffset) === idx; })) { // in ring - hasElement = ring.some(function (idx) { - var atomTypeId = a.residueType.atomTypeIdList[idx]; - var number = a.atomMap.get(atomTypeId).number; - return number === 7 /* N */ || number === 8 /* O */; - }); - } - }); - return hasElement; -} -/** - * Potential hydrogen acceptor - */ -function addHydrogenAcceptors(structure, features) { - var ref = valenceModel(structure.data); - var charge = ref.charge; - var implicitH = ref.implicitH; - var idealGeometry = ref.idealGeometry; - structure.eachAtom(function (a) { - var state = createFeatureState(5 /* HydrogenAcceptor */); - var an = a.number; - if (an === 8 /* O */) { - // Basically assume all oxygen atoms are acceptors! - addAtom(state, a); - addFeature(features, state); - } - else if (an === 7 /* N */) { - if (isHistidineNitrogen(a)) { - // include both nitrogen atoms in histidine due to - // their often ambiguous protonation assignment - addAtom(state, a); - addFeature(features, state); - } - else if (charge[a.index] < 1) { - // Neutral nitrogen might be an acceptor - // It must have at least one lone pair not conjugated - var totalBonds = a.bondCount + implicitH[a.index]; - var ig = idealGeometry[a.index]; - if ((ig === 4 /* Tetrahedral */ && totalBonds < 4) || - (ig === 3 /* Trigonal */ && totalBonds < 3) || - (ig === 2 /* Linear */ && totalBonds < 2)) { - addAtom(state, a); - addFeature(features, state); - } - } - } - else if (an === 16) { // S - if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) { - addAtom(state, a); - addFeature(features, state); - } - } - }); -} -/** - * Atom that is only bound to carbon or hydrogen - */ -// function isHydrocarbon (atom: AtomProxy) { -// let flag = true -// atom.eachBondedAtom(ap => { -// const e = ap.element -// if (e !== 'C' && e !== 'H') flag = false -// }) -// return flag -// } -function isHistidineNitrogen(ap) { - return ap.resname === 'HIS' && ap.number == 7 /* N */ && ap.isRing(); -} -function isBackboneHydrogenBond(ap1, ap2) { - return ap1.isBackbone() && ap2.isBackbone(); -} -function isWaterHydrogenBond(ap1, ap2) { - return ap1.isWater() && ap2.isWater(); -} -function isHydrogenBond(ti, tj) { - return ((ti === 5 /* HydrogenAcceptor */ && tj === 4 /* HydrogenDonor */) || - (ti === 4 /* HydrogenDonor */ && tj === 5 /* HydrogenAcceptor */)); -} -function isWeakHydrogenBond(ti, tj) { - return ((ti === 9 /* WeakHydrogenDonor */ && tj === 5 /* HydrogenAcceptor */) || - (ti === 5 /* HydrogenAcceptor */ && tj === 9 /* WeakHydrogenDonor */)); -} -function getHydrogenBondType(ap1, ap2) { - if (isWaterHydrogenBond(ap1, ap2)) { - return 9 /* WaterHydrogenBond */; - } - else if (isBackboneHydrogenBond(ap1, ap2)) { - return 10 /* BackboneHydrogenBond */; - } - else { - return 4 /* HydrogenBond */; - } -} -/** - * All pairs of hydrogen donor and acceptor atoms - */ -function addHydrogenBonds(structure, contacts, params) { - if ( params === void 0 ) params = {}; - - var maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist); - var maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist); - var maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle)); - var maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle)); - var maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle)); - var maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle)); - var masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex); - var maxDist = Math.max(maxHbondDist, maxHbondSulfurDist); - var maxHbondDistSq = maxHbondDist * maxHbondDist; - var features = contacts.features; - var spatialHash = contacts.spatialHash; - var contactStore = contacts.contactStore; - var featureSet = contacts.featureSet; - var types = features.types; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var n = types.length; - var ref = valenceModel(structure.data); - var idealGeometry = ref.idealGeometry; - var donor = structure.getAtomProxy(); - var acceptor = structure.getAtomProxy(); - var loop = function ( i ) { - spatialHash.eachWithin(x[i], y[i], z[i], maxDist, function (j, dSq) { - if (j <= i) - { return; } - var ti = types[i]; - var tj = types[j]; - var isWeak = isWeakHydrogenBond(ti, tj); - if (!isWeak && !isHydrogenBond(ti, tj)) - { return; } - var ref = tj === 5 /* HydrogenAcceptor */ ? [i, j] : [j, i]; - var l = ref[0]; - var k = ref[1]; - donor.index = atomSets[l][0]; - acceptor.index = atomSets[k][0]; - if (acceptor.index === donor.index) - { return; } // DA to self - if (invalidAtomContact$1(donor, acceptor, masterIdx)) - { return; } - if (donor.number !== 16 /* S */ && acceptor.number !== 16 /* S */ && dSq > maxHbondDistSq) - { return; } - if (donor.connectedTo(acceptor)) - { return; } - var donorAngles = calcAngles(donor, acceptor); - var idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120); - if (donorAngles.some(function (donorAngle) { - return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle; - })) - { return; } - if (idealGeometry[donor.index] === 3 /* Trigonal */) { - var outOfPlane = calcPlaneAngle(donor, acceptor); - if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) - { return; } - } - var acceptorAngles = calcAngles(acceptor, donor); - var idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120); - if (acceptorAngles.some(function (acceptorAngle) { - // Do not limit large acceptor angles - return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle; - })) - { return; } - if (idealGeometry[acceptor.index] === 3 /* Trigonal */) { - var outOfPlane$1 = calcPlaneAngle(acceptor, donor); - if (outOfPlane$1 !== undefined && outOfPlane$1 > maxHbondAccPlaneAngle) - { return; } - } - featureSet.setBits(l, k); - var bondType = isWeak ? 8 /* WeakHydrogenBond */ : getHydrogenBondType(donor, acceptor); - contactStore.addContact(l, k, bondType); - }); - }; - - for (var i = 0; i < n; ++i) loop( i ); -} - -/** - * @file Metal Binding - * @author Alexander Rose - */ -var IonicTypeMetals = [ - 3 /* LI */, 11 /* NA */, 19 /* K */, 37 /* RB */, 55 /* CS */, - 12 /* MG */, 20 /* CA */, 38 /* SR */, 56 /* BA */, 13 /* AL */, - 31 /* GA */, 49 /* IN */, 81 /* TL */, 21 /* SC */, 50 /* SN */, - 82 /* PB */, 83 /* BI */, 51 /* SB */, 80 /* HG */ -]; -/** - * Metal binding partners (dative bond or ionic-type interaction) - */ -function addMetalBinding(structure, features) { - structure.eachAtom(function (a) { - var dative = false; - var ionic = false; - var isStandardAminoacid = AA3.includes(a.resname); - var isStandardBase = Bases.includes(a.resname); - if (!isStandardAminoacid && !isStandardBase) { - if (a.isHalogen() || a.number === 8 /* O */ || a.number === 16 /* S */) { - dative = true; - ionic = true; - } - else if (a.number === 7 /* N */) { - dative = true; - } - } - else if (isStandardAminoacid) { - // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids - if (a.number === 8 /* O */) { - if (['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) { - dative = true; - ionic = true; - } - else if (a.isBackbone()) { - dative = true; - ionic = true; - } - } - else if (a.number === 16 /* S */ && 'CYS' === a.resname) { - dative = true; - ionic = true; - } - else if (a.number === 7 /* N */) { - if (a.resname === 'HIS' && a.isSidechain()) { - dative = true; - } - } - } - else if (isStandardBase) { - // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253 - // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full - if (a.number === 8 /* O */ && a.isBackbone()) { - dative = true; - ionic = true; - } - else if (['N3', 'N4', 'N7'].includes(a.atomname)) { - dative = true; - } - else if (['O2', 'O4', 'O6'].includes(a.atomname)) { - dative = true; - ionic = true; - } - } - if (dative) { - var state = createFeatureState(11 /* DativeBondPartner */); - addAtom(state, a); - addFeature(features, state); - } - if (ionic) { - var state$1 = createFeatureState(10 /* IonicTypePartner */); - addAtom(state$1, a); - addFeature(features, state$1); - } - }); -} -/** - * Metal Pi complexation partner - */ -// export function addMetalPiPartners (structure: Structure, features: Features) { -// const { charge } = valenceModel(structure.data) -// structure.eachAtom(a => { -// const state = createFeatureState(FeatureType.MetalPiPartner) -// const resname = a.resname -// const element = a.element -// const atomname = a.atomname -// if (!a.isPolymer()) { -// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol; -// // nitrogen from imidazole; sulfur from thiolate -// if (element === 'O') { -// // Water oxygen -// if (a.bondCount === 0 || a.isWater()) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// // Oxygen in alcohol (R-[O]-H) -// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// // Phenolate oxygen -// if (hasAromaticNeighbour(a) && !a.aromatic) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// // Carboxylic acid oxygen -// if (a.bondToElementCount('C') === 1) { -// let flag = false -// a.eachBondedAtom(ba => { -// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) { -// flag = true -// } -// }) -// if (flag) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// } -// // Phosphoryl oxygen -// if (a.bondToElementCount('P') === 1) { -// let flag = false -// a.eachBondedAtom(ba => { -// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) { -// flag = true -// } -// }) -// if (flag) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// } -// } else if (element === 'N') { -// // Imidazole/pyrrole or similar -// if (a.bondToElementCount('C') === 2) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// } else if (element === 'S') { -// // Thiolate -// if (hasAromaticNeighbour(a) && !a.aromatic) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// // Sulfur in Iron sulfur cluster -// const ironCount = a.bondToElementCount('FE') -// if (ironCount > 0 && ironCount === a.bondCount) { -// addAtom(state, a) -// addFeature(features, state) -// return -// } -// } -// } -// }) -// } -function addMetals(structure, features) { - structure.eachAtom(function (a) { - if (a.isTransitionMetal() || a.number === 30 /* ZN */ || a.number === 48 /* CD */) { - var state = createFeatureState(12 /* TransitionMetal */); - addAtom(state, a); - addFeature(features, state); - } - else if (IonicTypeMetals.includes(a.number)) { - var state$1 = createFeatureState(13 /* IonicTypeMetal */); - addAtom(state$1, a); - addFeature(features, state$1); - } - }); -} -function isMetalComplex(ti, tj) { - if (ti === 12 /* TransitionMetal */) { - return (tj === 11 /* DativeBondPartner */ || - tj === 12 /* TransitionMetal */); - } - else if (ti === 13 /* IonicTypeMetal */) { - return (tj === 10 /* IonicTypePartner */); - } -} -/** - * Metal complexes of metals and appropriate groups in protein and ligand, including water - */ -function addMetalComplexation(structure, contacts, params) { - if ( params === void 0 ) params = {}; - - var maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist); - var masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex); - var features = contacts.features; - var spatialHash = contacts.spatialHash; - var contactStore = contacts.contactStore; - var featureSet = contacts.featureSet; - var types = features.types; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var n = types.length; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var loop = function ( i ) { - spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, function (j, dSq) { - if (j <= i) - { return; } - ap1.index = atomSets[i][0]; - ap2.index = atomSets[j][0]; - if (invalidAtomContact$1(ap1, ap2, masterIdx)) - { return; } - var m1 = ap1.isMetal(); - var m2 = ap2.isMetal(); - if (!m1 && !m2) - { return; } - var ref = m1 ? [types[i], types[j]] : [types[j], types[i]]; - var ti = ref[0]; - var tj = ref[1]; - if (isMetalComplex(ti, tj)) { - featureSet.setBits(i, j); - contactStore.addContact(i, j, 7 /* MetalCoordination */); - } - }); - }; - - for (var i = 0; i < n; ++i) loop( i ); -} - -/** - * @file Hydrophobic - * @author Alexander Rose - */ -/** - * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine - */ -function addHydrophobic(structure, features) { - structure.eachAtom(function (a) { - var state = createFeatureState(8 /* Hydrophobic */); - var flag = false; - if (a.number === 6 /* C */) { - flag = true; - a.eachBondedAtom(function (ap) { - var an = ap.number; - if (an !== 6 /* C */ && an !== 1 /* H */) - { flag = false; } - }); - } - else if (a.number === 9 /* F */) { - flag = true; - } - if (flag) { - addAtom(state, a); - addFeature(features, state); - } - }); -} -function isHydrophobicContact(ti, tj) { - return ti === 8 /* Hydrophobic */ && tj === 8 /* Hydrophobic */; -} -/** - * All hydrophobic contacts - */ -function addHydrophobicContacts(structure, contacts, params) { - if ( params === void 0 ) params = {}; - - var maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist); - var masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex); - var features = contacts.features; - var spatialHash = contacts.spatialHash; - var contactStore = contacts.contactStore; - var featureSet = contacts.featureSet; - var types = features.types; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var n = types.length; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var loop = function ( i ) { - spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, function (j, dSq) { - if (j <= i) - { return; } - ap1.index = atomSets[i][0]; - ap2.index = atomSets[j][0]; - if (invalidAtomContact$1(ap1, ap2, masterIdx)) - { return; } - if (ap1.number === 9 /* F */ && ap2.number === 9 /* F */) - { return; } - if (ap1.connectedTo(ap2)) - { return; } - if (isHydrophobicContact(types[i], types[j])) { - featureSet.setBits(i, j); - contactStore.addContact(i, j, 6 /* Hydrophobic */); - } - }); - }; - - for (var i = 0; i < n; ++i) loop( i ); -} - -/** - * @file Halogen Bonds - * @author Alexander Rose - * @author Fred Ludlow - */ -var halBondElements = [17, 35, 53, 85]; -/** - * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F! - */ -function addHalogenDonors(structure, features) { - structure.eachAtom(function (a) { - if (halBondElements.includes(a.number) && a.bondToElementCount(6 /* C */) === 1) { - var state = createFeatureState(6 /* HalogenDonor */); - addAtom(state, a); - addFeature(features, state); - } - }); -} -var X = [7 /* N */, 8 /* O */, 16 /* S */]; -var Y = [6 /* C */, 7 /* N */, 15 /* P */, 16 /* S */]; -/** - * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S) - */ -function addHalogenAcceptors(structure, features) { - structure.eachAtom(function (a) { - if (X.includes(a.number)) { - var flag = false; - a.eachBondedAtom(function (ba) { - if (Y.includes(ba.number)) { - flag = true; - } - }); - if (flag) { - var state = createFeatureState(7 /* HalogenAcceptor */); - addAtom(state, a); - addFeature(features, state); - } - } - }); -} -function isHalogenBond(ti, tj) { - return ((ti === 7 /* HalogenAcceptor */ && tj === 6 /* HalogenDonor */) || - (ti === 6 /* HalogenDonor */ && tj === 7 /* HalogenAcceptor */)); -} -// http://www.pnas.org/content/101/48/16789.full -var OptimalHalogenAngle = degToRad(180); // adjusted from 165 to account for spherical statistics -var OptimalAcceptorAngle = degToRad(120); -/** - * All pairs of halogen donor and acceptor atoms - */ -function addHalogenBonds(structure, contacts, params) { - if ( params === void 0 ) params = {}; - - var maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist); - var maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle)); - var masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex); - var features = contacts.features; - var spatialHash = contacts.spatialHash; - var contactStore = contacts.contactStore; - var featureSet = contacts.featureSet; - var types = features.types; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var n = types.length; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var loop = function ( i ) { - spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, function (j, dSq) { - if (j <= i) - { return; } - ap1.index = atomSets[i][0]; - ap2.index = atomSets[j][0]; - if (invalidAtomContact$1(ap1, ap2, masterIdx)) - { return; } - if (!isHalogenBond(types[i], types[j])) - { return; } - var ref = types[i] === 6 /* HalogenDonor */ ? [ap1, ap2] : [ap2, ap1]; - var halogen = ref[0]; - var acceptor = ref[1]; - var halogenAngles = calcAngles(halogen, acceptor); - // Singly bonded halogen only (not bromide ion for example) - if (halogenAngles.length !== 1) - { return; } - if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) - { return; } - var acceptorAngles = calcAngles(acceptor, halogen); - // Angle must be defined. Excludes water as acceptor. Debatable - if (acceptorAngles.length === 0) - { return; } - if (acceptorAngles.some(function (acceptorAngle) { - return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle); - })) - { return; } - featureSet.setBits(i, j); - contactStore.addContact(i, j, 5 /* HalogenBond */); - }); - }; - - for (var i = 0; i < n; ++i) loop( i ); -} - -/** - * @file Refine Contacts - * @author Alexander Rose - * @private - */ -// also allows intra-residue contacts -function invalidAtomContact(ap1, ap2, masterIdx) { - return !isMasterContact(ap1, ap2, masterIdx) && (ap1.modelIndex !== ap2.modelIndex || - (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)); -} -function refineLineOfSight(structure, contacts, params) { - if ( params === void 0 ) params = {}; - - if (Debug) - { Log.time('refineLineOfSight'); } - var lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor); - var masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex); - var spatialHash = structure.spatialHash; - var contactSet = contacts.contactSet; - var contactStore = contacts.contactStore; - var features = contacts.features; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var ac1 = structure.getAtomProxy(); - var ac2 = structure.getAtomProxy(); - var aw = structure.getAtomProxy(); - var c1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var c2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var lineOfSightDist = 3 * lineOfSightDistFactor; - var lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor; - contactSet.forEach(function (i) { - c1.set(x[index1[i]], y[index1[i]], z[index1[i]]); - c2.set(x[index2[i]], y[index2[i]], z[index2[i]]); - var cx = (c1.x + c2.x) / 2; - var cy = (c1.y + c2.y) / 2; - var cz = (c1.z + c2.z) / 2; - var as1 = atomSets[index1[i]]; - var as2 = atomSets[index2[i]]; - ac1.index = as1[0]; - ac2.index = as2[0]; - spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, function (j, dSq) { - aw.index = j; - if (aw.number !== 1 /* H */ && - (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq && - !invalidAtomContact(ac1, aw, masterIdx) && - !invalidAtomContact(ac2, aw, masterIdx) && - !as1.includes(j) && - !as2.includes(j) && - // to ignore atoms in the center of functional groups - c1.distanceToSquared(aw) > 1 && - c2.distanceToSquared(aw) > 1) { - contactSet.clear(i); - if (Debug) - { Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName()); } - } - }); - }); - if (Debug) - { Log.timeEnd('refineLineOfSight'); } -} -/** - * For atoms interacting with several atoms in the same residue - * only the one with the closest distance is kept. - */ -function refineHydrophobicContacts(structure, contacts) { - var contactSet = contacts.contactSet; - var contactStore = contacts.contactStore; - var features = contacts.features; - var type = contactStore.type; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var atomSets = features.atomSets; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var residueContactDict = {}; - /* keep only closest contact between residues */ - var handleResidueContact = function (dist, i, key) { - var ref = residueContactDict[key] || [Infinity, -1]; - var minDist = ref[0]; - var minIndex = ref[1]; - if (dist < minDist) { - if (minIndex !== -1) - { contactSet.clear(minIndex); } - residueContactDict[key] = [dist, i]; - } - else { - contactSet.clear(i); - } - }; - contactSet.forEach(function (i) { - if (type[i] !== 6 /* Hydrophobic */) - { return; } - ap1.index = atomSets[index1[i]][0]; - ap2.index = atomSets[index2[i]][0]; - var dist = ap1.distanceTo(ap2); - handleResidueContact(dist, i, ((ap1.index) + "|" + (ap2.residueIndex))); - handleResidueContact(dist, i, ((ap2.index) + "|" + (ap1.residueIndex))); - }); -} -function isHydrogenBondType(type) { - return (type === 4 /* HydrogenBond */ || - type === 9 /* WaterHydrogenBond */ || - type === 10 /* BackboneHydrogenBond */); -} -/** - * Remove hydrogen bonds between groups that also form - * a salt bridge between each other - */ -function refineSaltBridges(structure, contacts) { - var contactSet = contacts.contactSet; - var contactStore = contacts.contactStore; - var features = contacts.features; - var type = contactStore.type; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var atomSets = features.atomSets; - var ionicInteractionDict = {}; - var add = function (idx, i) { - if (!ionicInteractionDict[idx]) - { ionicInteractionDict[idx] = []; } - ionicInteractionDict[idx].push(i); - }; - contactSet.forEach(function (i) { - if (type[i] !== 1 /* IonicInteraction */) - { return; } - atomSets[index1[i]].forEach(function (idx) { return add(idx, i); }); - atomSets[index2[i]].forEach(function (idx) { return add(idx, i); }); - }); - contactSet.forEach(function (i) { - if (!isHydrogenBondType(type[i])) - { return; } - var iil1 = ionicInteractionDict[atomSets[index1[i]][0]]; - var iil2 = ionicInteractionDict[atomSets[index2[i]][0]]; - if (!iil1 || !iil2) - { return; } - var n = iil1.length; - for (var j = 0; j < n; ++j) { - if (iil2.includes(iil1[j])) { - contactSet.clear(i); - return; - } - } - }); -} -/** - * Remove hydrophobic and cation-pi interactions between groups that also form - * a pi-stacking interaction between each other - */ -function refinePiStacking(structure, contacts) { - var contactSet = contacts.contactSet; - var contactStore = contacts.contactStore; - var features = contacts.features; - var type = contactStore.type; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var atomSets = features.atomSets; - var piStackingDict = {}; - var add = function (idx, i) { - if (!piStackingDict[idx]) - { piStackingDict[idx] = []; } - piStackingDict[idx].push(i); - }; - contactSet.forEach(function (i) { - if (type[i] !== 3 /* PiStacking */) - { return; } - atomSets[index1[i]].forEach(function (idx) { return add(idx, i); }); - atomSets[index2[i]].forEach(function (idx) { return add(idx, i); }); - }); - contactSet.forEach(function (i) { - if (type[i] !== 6 /* Hydrophobic */ && - type[i] !== 2 /* CationPi */) - { return; } - var pil1 = piStackingDict[atomSets[index1[i]][0]]; - var pil2 = piStackingDict[atomSets[index2[i]][0]]; - if (!pil1 || !pil2) - { return; } - var n = pil1.length; - for (var j = 0; j < n; ++j) { - if (pil2.includes(pil1[j])) { - contactSet.clear(i); - return; - } - } - }); -} -/** - * Remove ionic interactions between groups that also form - * a metal coordination between each other - */ -function refineMetalCoordination(structure, contacts) { - var contactSet = contacts.contactSet; - var contactStore = contacts.contactStore; - var features = contacts.features; - var type = contactStore.type; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var atomSets = features.atomSets; - var ionicInteractionDict = {}; - var add = function (idx, i) { - if (!ionicInteractionDict[idx]) - { ionicInteractionDict[idx] = []; } - ionicInteractionDict[idx].push(i); - }; - contactSet.forEach(function (i) { - if (type[i] !== 1 /* IonicInteraction */) - { return; } - atomSets[index1[i]].forEach(function (idx) { return add(idx, i); }); - atomSets[index2[i]].forEach(function (idx) { return add(idx, i); }); - }); - contactSet.forEach(function (i) { - if (type[i] !== 7 /* MetalCoordination */) - { return; } - var iil1 = ionicInteractionDict[atomSets[index1[i]][0]]; - var iil2 = ionicInteractionDict[atomSets[index2[i]][0]]; - if (!iil1 || !iil2) - { return; } - var n = iil1.length; - for (var j = 0; j < n; ++j) { - if (iil2.includes(iil1[j])) { - contactSet.clear(iil1[j]); - return; - } - } - }); -} -// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY - -/** - * @file Contact - * @author Alexander Rose - */ -var ContactDefaultParams = { - maxHydrophobicDist: 4.0, - maxHbondDist: 3.5, - maxHbondSulfurDist: 4.1, - maxHbondAccAngle: 45, - maxHbondDonAngle: 45, - maxHbondAccPlaneAngle: 90, - maxHbondDonPlaneAngle: 30, - maxPiStackingDist: 5.5, - maxPiStackingOffset: 2.0, - maxPiStackingAngle: 30, - maxCationPiDist: 6.0, - maxCationPiOffset: 2.0, - maxIonicDist: 5.0, - maxHalogenBondDist: 4.0, - maxHalogenBondAngle: 30, - maxMetalDist: 3.0, - refineSaltBridges: true, - masterModelIndex: -1, - lineOfSightDistFactor: 1.0 -}; -function isMasterContact(ap1, ap2, masterIdx) { - return ((ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) || - (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)); -} -function invalidAtomContact$1(ap1, ap2, masterIdx) { - return !isMasterContact(ap1, ap2, masterIdx) && (ap1.modelIndex !== ap2.modelIndex || - ap1.residueIndex === ap2.residueIndex || - (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)); -} -function createContacts(features) { - var types = features.types; - var centers = features.centers; - var spatialHash = new SpatialHash(centers); - var contactStore = new ContactStore(); - var featureSet = new BitArray(types.length, false); - return { features: features, spatialHash: spatialHash, contactStore: contactStore, featureSet: featureSet }; -} -function createFrozenContacts(contacts) { - var ref = contacts.contactStore; - var index1 = ref.index1; - var index2 = ref.index2; - var count = ref.count; - var adjacencyList = createAdjacencyList({ - nodeArray1: index1, - nodeArray2: index2, - edgeCount: count, - nodeCount: contacts.featureSet.length - }); - var contactSet = new BitArray(contacts.contactStore.count, true); - return Object.assign({ adjacencyList: adjacencyList, contactSet: contactSet }, contacts); -} -function calculateFeatures(structure) { - var features = createFeatures(); - if (Debug) - { Log.time('calculateFeatures'); } - addPositiveCharges(structure, features); - addNegativeCharges(structure, features); - addAromaticRings(structure, features); - addHydrogenAcceptors(structure, features); - addHydrogenDonors(structure, features); - addWeakHydrogenDonors(structure, features); - addMetalBinding(structure, features); - addMetals(structure, features); - addHydrophobic(structure, features); - addHalogenAcceptors(structure, features); - addHalogenDonors(structure, features); - if (Debug) - { Log.timeEnd('calculateFeatures'); } - return features; -} -function calculateContacts(structure, params) { - if ( params === void 0 ) params = ContactDefaultParams; - - var features = calculateFeatures(structure); - var contacts = createContacts(features); - if (Debug) - { Log.time('calculateContacts'); } - addChargedContacts(structure, contacts, params); - addHydrogenBonds(structure, contacts, params); - addMetalComplexation(structure, contacts, params); - addHydrophobicContacts(structure, contacts, params); - addHalogenBonds(structure, contacts, params); - var frozenContacts = createFrozenContacts(contacts); - refineLineOfSight(structure, frozenContacts, params); - refineHydrophobicContacts(structure, frozenContacts); - if (params.refineSaltBridges) - { refineSaltBridges(structure, frozenContacts); } - refinePiStacking(structure, frozenContacts); - refineMetalCoordination(structure, frozenContacts); - if (Debug) - { Log.timeEnd('calculateContacts'); } - return frozenContacts; -} -function contactTypeName(type) { - switch (type) { - case 4 /* HydrogenBond */: - case 9 /* WaterHydrogenBond */: - case 10 /* BackboneHydrogenBond */: - return 'hydrogen bond'; - case 6 /* Hydrophobic */: - return 'hydrophobic contact'; - case 5 /* HalogenBond */: - return 'halogen bond'; - case 1 /* IonicInteraction */: - return 'ionic interaction'; - case 7 /* MetalCoordination */: - return 'metal coordination'; - case 2 /* CationPi */: - return 'cation-pi interaction'; - case 3 /* PiStacking */: - return 'pi-pi stacking'; - case 8 /* WeakHydrogenBond */: - return 'weak hydrogen bond'; - default: - return 'unknown contact'; - } -} -var ContactDataDefaultParams = { - hydrogenBond: true, - hydrophobic: true, - halogenBond: true, - ionicInteraction: true, - metalCoordination: true, - cationPi: true, - piStacking: true, - weakHydrogenBond: true, - waterHydrogenBond: true, - backboneHydrogenBond: true, - radius: 1, - filterSele: '' -}; -var tmpColor$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](); -function contactColor(type) { - switch (type) { - case 4 /* HydrogenBond */: - case 9 /* WaterHydrogenBond */: - case 10 /* BackboneHydrogenBond */: - return tmpColor$1.setHex(0x2B83BA).toArray(); - case 6 /* Hydrophobic */: - return tmpColor$1.setHex(0x808080).toArray(); - case 5 /* HalogenBond */: - return tmpColor$1.setHex(0x40FFBF).toArray(); - case 1 /* IonicInteraction */: - return tmpColor$1.setHex(0xF0C814).toArray(); - case 7 /* MetalCoordination */: - return tmpColor$1.setHex(0x8C4099).toArray(); - case 2 /* CationPi */: - return tmpColor$1.setHex(0xFF8000).toArray(); - case 3 /* PiStacking */: - return tmpColor$1.setHex(0x8CB366).toArray(); - case 8 /* WeakHydrogenBond */: - return tmpColor$1.setHex(0xC5DDEC).toArray(); - default: - return tmpColor$1.setHex(0xCCCCCC).toArray(); - } -} -function getContactData(contacts, structure, params) { - var p = createParams(params, ContactDataDefaultParams); - var types = []; - if (p.hydrogenBond) - { types.push(4 /* HydrogenBond */); } - if (p.hydrophobic) - { types.push(6 /* Hydrophobic */); } - if (p.halogenBond) - { types.push(5 /* HalogenBond */); } - if (p.ionicInteraction) - { types.push(1 /* IonicInteraction */); } - if (p.metalCoordination) - { types.push(7 /* MetalCoordination */); } - if (p.cationPi) - { types.push(2 /* CationPi */); } - if (p.piStacking) - { types.push(3 /* PiStacking */); } - if (p.weakHydrogenBond) - { types.push(8 /* WeakHydrogenBond */); } - if (p.waterHydrogenBond) - { types.push(9 /* WaterHydrogenBond */); } - if (p.backboneHydrogenBond) - { types.push(10 /* BackboneHydrogenBond */); } - var features = contacts.features; - var contactSet = contacts.contactSet; - var contactStore = contacts.contactStore; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var type = contactStore.type; - var position1 = []; - var position2 = []; - var color = []; - var radius = []; - var picking = []; - var filterSet; - if (p.filterSele) { - if (Array.isArray(p.filterSele)) { - filterSet = p.filterSele.map(function (sele) { - return structure.getAtomSet(new Selection(sele)); - }); - } - else { - filterSet = structure.getAtomSet(new Selection(p.filterSele)); - } - } - contactSet.forEach(function (i) { - var ti = type[i]; - if (!types.includes(ti)) - { return; } - if (filterSet) { - var idx1 = atomSets[index1[i]][0]; - var idx2 = atomSets[index2[i]][0]; - if (Array.isArray(filterSet)) { - if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) - { return; } - } - else { - if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) - { return; } - } - } - var k = index1[i]; - var l = index2[i]; - position1.push(x[k], y[k], z[k]); - position2.push(x[l], y[l], z[l]); - color.push.apply(color, contactColor(ti)); - radius.push(p.radius); - picking.push(i); - }); - return { - position1: new Float32Array(position1), - position2: new Float32Array(position2), - color: new Float32Array(color), - color2: new Float32Array(color), - radius: new Float32Array(radius), - picking: new ContactPicker(picking, contacts, structure) - }; -} -function getLabelData(contactData, params) { - var position = calculateCenterArray(contactData.position1, contactData.position2); - var text = []; - var direction = calculateDirectionArray(contactData.position1, contactData.position2); - var n = direction.length / 3; - for (var i = 0; i < n; i++) { - var j = 3 * i; - var d = Math.sqrt(Math.pow(direction[j], 2) + Math.pow(direction[j + 1], 2) + Math.pow(direction[j + 2], 2)); - switch (params.unit) { - case 'angstrom': - text[i] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B); - break; - case 'nm': - text[i] = (d / 10).toFixed(2) + ' nm'; - break; - default: - text[i] = d.toFixed(2); - break; - } - } - return { - position: position, - size: uniformArray(position.length / 3, params.size), - color: contactData.color, - text: text - }; -} - -/** - * @file Picker - * @author Alexander Rose - * @private - */ -/** - * Picker class - * @interface - */ -var Picker = function Picker(array) { - this.array = array; -}; - -var prototypeAccessors$9 = { type: { configurable: true },data: { configurable: true } }; -prototypeAccessors$9.type.get = function () { return ''; }; -prototypeAccessors$9.data.get = function () { return {}; }; -/** - * Get the index for the given picking id - * @param {Integer} pid - the picking id - * @return {Integer} the index - */ -Picker.prototype.getIndex = function getIndex (pid) { - return this.array ? this.array[pid] : pid; -}; -/** - * Get object data - * @abstract - * @param {Integer} pid - the picking id - * @return {Object} the object data - */ -Picker.prototype.getObject = function getObject (pid) { - return {}; -}; -Picker.prototype._applyTransformations = function _applyTransformations (vector, instance, component) { - if (instance) { - vector.applyMatrix4(instance.matrix); - } - if (component) { - vector.applyMatrix4(component.matrix); - } - return vector; -}; -/** - * Get object position - * @abstract - * @param {Integer} pid - the picking id - * @return {Vector3} the object position - */ -Picker.prototype._getPosition = function _getPosition (pid) { - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -}; -/** - * Get position for the given picking id - * @param {Integer} pid - the picking id - * @param {Object} instance - the instance that should be applied - * @param {Component} component - the component of the picked object - * @return {Vector3} the position - */ -Picker.prototype.getPosition = function getPosition (pid, instance, component) { - return this._applyTransformations(this._getPosition(pid), instance, component); -}; - -Object.defineProperties( Picker.prototype, prototypeAccessors$9 ); -/** - * Shape picker class - * @interface - */ -var ShapePicker = /*@__PURE__*/(function (Picker) { - function ShapePicker(shape) { - Picker.call(this); - this.shape = shape; - } - - if ( Picker ) ShapePicker.__proto__ = Picker; - ShapePicker.prototype = Object.create( Picker && Picker.prototype ); - ShapePicker.prototype.constructor = ShapePicker; - - var prototypeAccessors$1 = { primitive: { configurable: true },data: { configurable: true },type: { configurable: true } }; - prototypeAccessors$1.primitive.get = function () { return; }; - prototypeAccessors$1.data.get = function () { return this.shape; }; - prototypeAccessors$1.type.get = function () { return this.primitive.type; }; - ShapePicker.prototype.getObject = function getObject (pid) { - return this.primitive.objectFromShape(this.shape, this.getIndex(pid)); - }; - ShapePicker.prototype._getPosition = function _getPosition (pid) { - return this.primitive.positionFromShape(this.shape, this.getIndex(pid)); - }; - - Object.defineProperties( ShapePicker.prototype, prototypeAccessors$1 ); - - return ShapePicker; -}(Picker)); -// -var CylinderPicker = /*@__PURE__*/(function (ShapePicker) { - function CylinderPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) CylinderPicker.__proto__ = ShapePicker; - CylinderPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - CylinderPicker.prototype.constructor = CylinderPicker; - - var prototypeAccessors$2 = { primitive: { configurable: true } }; - - prototypeAccessors$2.primitive.get = function () { return CylinderPrimitive; }; - - Object.defineProperties( CylinderPicker.prototype, prototypeAccessors$2 ); - - return CylinderPicker; -}(ShapePicker)); -var ArrowPicker = /*@__PURE__*/(function (ShapePicker) { - function ArrowPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) ArrowPicker.__proto__ = ShapePicker; - ArrowPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - ArrowPicker.prototype.constructor = ArrowPicker; - - var prototypeAccessors$3 = { primitive: { configurable: true } }; - - prototypeAccessors$3.primitive.get = function () { return ArrowPrimitive; }; - - Object.defineProperties( ArrowPicker.prototype, prototypeAccessors$3 ); - - return ArrowPicker; -}(ShapePicker)); -var AtomPicker = /*@__PURE__*/(function (Picker) { - function AtomPicker(array, structure) { - Picker.call(this, array); - this.structure = structure; - } - - if ( Picker ) AtomPicker.__proto__ = Picker; - AtomPicker.prototype = Object.create( Picker && Picker.prototype ); - AtomPicker.prototype.constructor = AtomPicker; - - var prototypeAccessors$4 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$4.type.get = function () { return 'atom'; }; - prototypeAccessors$4.data.get = function () { return this.structure; }; - AtomPicker.prototype.getObject = function getObject (pid) { - return this.structure.getAtomProxy(this.getIndex(pid)); - }; - AtomPicker.prototype._getPosition = function _getPosition (pid) { - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(this.getObject(pid)); - }; - - Object.defineProperties( AtomPicker.prototype, prototypeAccessors$4 ); - - return AtomPicker; -}(Picker)); -var AxesPicker = /*@__PURE__*/(function (Picker) { - function AxesPicker(axes) { - Picker.call(this); - this.axes = axes; - } - - if ( Picker ) AxesPicker.__proto__ = Picker; - AxesPicker.prototype = Object.create( Picker && Picker.prototype ); - AxesPicker.prototype.constructor = AxesPicker; - - var prototypeAccessors$5 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$5.type.get = function () { return 'axes'; }; - prototypeAccessors$5.data.get = function () { return this.axes; }; - AxesPicker.prototype.getObject = function getObject ( /* pid */) { - return { - axes: this.axes - }; - }; - AxesPicker.prototype._getPosition = function _getPosition ( /* pid */) { - return this.axes.center.clone(); - }; - - Object.defineProperties( AxesPicker.prototype, prototypeAccessors$5 ); - - return AxesPicker; -}(Picker)); -var BondPicker = /*@__PURE__*/(function (Picker) { - function BondPicker(array, structure, bondStore) { - Picker.call(this, array); - this.structure = structure; - this.bondStore = bondStore || structure.bondStore; - } - - if ( Picker ) BondPicker.__proto__ = Picker; - BondPicker.prototype = Object.create( Picker && Picker.prototype ); - BondPicker.prototype.constructor = BondPicker; - - var prototypeAccessors$6 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$6.type.get = function () { return 'bond'; }; - prototypeAccessors$6.data.get = function () { return this.structure; }; - BondPicker.prototype.getObject = function getObject (pid) { - var bp = this.structure.getBondProxy(this.getIndex(pid)); - bp.bondStore = this.bondStore; - return bp; - }; - BondPicker.prototype._getPosition = function _getPosition (pid) { - var b = this.getObject(pid); - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]() - .copy(b.atom1) - .add(b.atom2) - .multiplyScalar(0.5); - }; - - Object.defineProperties( BondPicker.prototype, prototypeAccessors$6 ); - - return BondPicker; -}(Picker)); -var ContactPicker = /*@__PURE__*/(function (Picker) { - function ContactPicker(array, contacts, structure) { - Picker.call(this, array); - this.contacts = contacts; - this.structure = structure; - } - - if ( Picker ) ContactPicker.__proto__ = Picker; - ContactPicker.prototype = Object.create( Picker && Picker.prototype ); - ContactPicker.prototype.constructor = ContactPicker; - - var prototypeAccessors$7 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$7.type.get = function () { return 'contact'; }; - prototypeAccessors$7.data.get = function () { return this.contacts; }; - ContactPicker.prototype.getObject = function getObject (pid) { - var idx = this.getIndex(pid); - var ref = this.contacts; - var features = ref.features; - var contactStore = ref.contactStore; - var centers = features.centers; - var atomSets = features.atomSets; - var x = centers.x; - var y = centers.y; - var z = centers.z; - var index1 = contactStore.index1; - var index2 = contactStore.index2; - var type = contactStore.type; - var k = index1[idx]; - var l = index2[idx]; - return { - center1: new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](x[k], y[k], z[k]), - center2: new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](x[l], y[l], z[l]), - atom1: this.structure.getAtomProxy(atomSets[k][0]), - atom2: this.structure.getAtomProxy(atomSets[l][0]), - type: contactTypeName(type[idx]) - }; - }; - ContactPicker.prototype._getPosition = function _getPosition (pid) { - var ref = this.getObject(pid); - var center1 = ref.center1; - var center2 = ref.center2; - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().addVectors(center1, center2).multiplyScalar(0.5); - }; - - Object.defineProperties( ContactPicker.prototype, prototypeAccessors$7 ); - - return ContactPicker; -}(Picker)); -var ConePicker = /*@__PURE__*/(function (ShapePicker) { - function ConePicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) ConePicker.__proto__ = ShapePicker; - ConePicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - ConePicker.prototype.constructor = ConePicker; - - var prototypeAccessors$8 = { primitive: { configurable: true } }; - - prototypeAccessors$8.primitive.get = function () { return ConePrimitive; }; - - Object.defineProperties( ConePicker.prototype, prototypeAccessors$8 ); - - return ConePicker; -}(ShapePicker)); -var ClashPicker = /*@__PURE__*/(function (Picker) { - function ClashPicker(array, validation, structure) { - Picker.call(this, array); - this.validation = validation; - this.structure = structure; - } - - if ( Picker ) ClashPicker.__proto__ = Picker; - ClashPicker.prototype = Object.create( Picker && Picker.prototype ); - ClashPicker.prototype.constructor = ClashPicker; - - var prototypeAccessors$9 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$9.type.get = function () { return 'clash'; }; - prototypeAccessors$9.data.get = function () { return this.validation; }; - ClashPicker.prototype.getObject = function getObject (pid) { - var val = this.validation; - var idx = this.getIndex(pid); - return { - validation: val, - index: idx, - clash: val.clashArray[idx] - }; - }; - ClashPicker.prototype._getAtomProxyFromSele = function _getAtomProxyFromSele (sele) { - var selection = new Selection(sele); - var idx = this.structure.getAtomIndices(selection)[0]; - return this.structure.getAtomProxy(idx); - }; - ClashPicker.prototype._getPosition = function _getPosition (pid) { - var clash = this.getObject(pid).clash; - var ap1 = this._getAtomProxyFromSele(clash.sele1); - var ap2 = this._getAtomProxyFromSele(clash.sele2); - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(ap1).add(ap2).multiplyScalar(0.5); - }; - - Object.defineProperties( ClashPicker.prototype, prototypeAccessors$9 ); - - return ClashPicker; -}(Picker)); -var DistancePicker = /*@__PURE__*/(function (BondPicker) { - function DistancePicker () { - BondPicker.apply(this, arguments); - } - - if ( BondPicker ) DistancePicker.__proto__ = BondPicker; - DistancePicker.prototype = Object.create( BondPicker && BondPicker.prototype ); - DistancePicker.prototype.constructor = DistancePicker; - - var prototypeAccessors$10 = { type: { configurable: true } }; - - prototypeAccessors$10.type.get = function () { return 'distance'; }; - - Object.defineProperties( DistancePicker.prototype, prototypeAccessors$10 ); - - return DistancePicker; -}(BondPicker)); -var EllipsoidPicker = /*@__PURE__*/(function (ShapePicker) { - function EllipsoidPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) EllipsoidPicker.__proto__ = ShapePicker; - EllipsoidPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - EllipsoidPicker.prototype.constructor = EllipsoidPicker; - - var prototypeAccessors$11 = { primitive: { configurable: true } }; - - prototypeAccessors$11.primitive.get = function () { return EllipsoidPrimitive; }; - - Object.defineProperties( EllipsoidPicker.prototype, prototypeAccessors$11 ); - - return EllipsoidPicker; -}(ShapePicker)); -var OctahedronPicker = /*@__PURE__*/(function (ShapePicker) { - function OctahedronPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) OctahedronPicker.__proto__ = ShapePicker; - OctahedronPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - OctahedronPicker.prototype.constructor = OctahedronPicker; - - var prototypeAccessors$12 = { primitive: { configurable: true } }; - - prototypeAccessors$12.primitive.get = function () { return OctahedronPrimitive; }; - - Object.defineProperties( OctahedronPicker.prototype, prototypeAccessors$12 ); - - return OctahedronPicker; -}(ShapePicker)); -var BoxPicker = /*@__PURE__*/(function (ShapePicker) { - function BoxPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) BoxPicker.__proto__ = ShapePicker; - BoxPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - BoxPicker.prototype.constructor = BoxPicker; - - var prototypeAccessors$13 = { primitive: { configurable: true } }; - - prototypeAccessors$13.primitive.get = function () { return BoxPrimitive; }; - - Object.defineProperties( BoxPicker.prototype, prototypeAccessors$13 ); - - return BoxPicker; -}(ShapePicker)); -var IgnorePicker = /*@__PURE__*/(function (Picker) { - function IgnorePicker () { - Picker.apply(this, arguments); - } - - if ( Picker ) IgnorePicker.__proto__ = Picker; - IgnorePicker.prototype = Object.create( Picker && Picker.prototype ); - IgnorePicker.prototype.constructor = IgnorePicker; - - var prototypeAccessors$14 = { type: { configurable: true } }; - - prototypeAccessors$14.type.get = function () { return 'ignore'; }; - - Object.defineProperties( IgnorePicker.prototype, prototypeAccessors$14 ); - - return IgnorePicker; -}(Picker)); -var MeshPicker = /*@__PURE__*/(function (ShapePicker) { - function MeshPicker(shape, mesh) { - ShapePicker.call(this, shape); - this.mesh = mesh; - } - - if ( ShapePicker ) MeshPicker.__proto__ = ShapePicker; - MeshPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - MeshPicker.prototype.constructor = MeshPicker; - - var prototypeAccessors$15 = { type: { configurable: true } }; - prototypeAccessors$15.type.get = function () { return 'mesh'; }; - MeshPicker.prototype.getObject = function getObject ( /* pid */) { - var m = this.mesh; - return { - shape: this.shape, - name: m.name, - serial: m.serial - }; - }; - MeshPicker.prototype._getPosition = function _getPosition ( /* pid */) { - if (!this.__position) { - this.__position = calculateMeanVector3(this.mesh.position); - } - return this.__position; - }; - - Object.defineProperties( MeshPicker.prototype, prototypeAccessors$15 ); - - return MeshPicker; -}(ShapePicker)); -var SpherePicker = /*@__PURE__*/(function (ShapePicker) { - function SpherePicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) SpherePicker.__proto__ = ShapePicker; - SpherePicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - SpherePicker.prototype.constructor = SpherePicker; - - var prototypeAccessors$16 = { primitive: { configurable: true } }; - - prototypeAccessors$16.primitive.get = function () { return SpherePrimitive; }; - - Object.defineProperties( SpherePicker.prototype, prototypeAccessors$16 ); - - return SpherePicker; -}(ShapePicker)); -var SurfacePicker = /*@__PURE__*/(function (Picker) { - function SurfacePicker(array, surface) { - Picker.call(this, array); - this.surface = surface; - } - - if ( Picker ) SurfacePicker.__proto__ = Picker; - SurfacePicker.prototype = Object.create( Picker && Picker.prototype ); - SurfacePicker.prototype.constructor = SurfacePicker; - - var prototypeAccessors$17 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$17.type.get = function () { return 'surface'; }; - prototypeAccessors$17.data.get = function () { return this.surface; }; - SurfacePicker.prototype.getObject = function getObject (pid) { - return { - surface: this.surface, - index: this.getIndex(pid) - }; - }; - SurfacePicker.prototype._getPosition = function _getPosition ( /* pid */) { - return this.surface.center.clone(); - }; - - Object.defineProperties( SurfacePicker.prototype, prototypeAccessors$17 ); - - return SurfacePicker; -}(Picker)); -var TetrahedronPicker = /*@__PURE__*/(function (ShapePicker) { - function TetrahedronPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) TetrahedronPicker.__proto__ = ShapePicker; - TetrahedronPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - TetrahedronPicker.prototype.constructor = TetrahedronPicker; - - var prototypeAccessors$18 = { primitive: { configurable: true } }; - - prototypeAccessors$18.primitive.get = function () { return TetrahedronPrimitive; }; - - Object.defineProperties( TetrahedronPicker.prototype, prototypeAccessors$18 ); - - return TetrahedronPicker; -}(ShapePicker)); -var TorusPicker = /*@__PURE__*/(function (ShapePicker) { - function TorusPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) TorusPicker.__proto__ = ShapePicker; - TorusPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - TorusPicker.prototype.constructor = TorusPicker; - - var prototypeAccessors$19 = { primitive: { configurable: true } }; - - prototypeAccessors$19.primitive.get = function () { return TorusPrimitive; }; - - Object.defineProperties( TorusPicker.prototype, prototypeAccessors$19 ); - - return TorusPicker; -}(ShapePicker)); -var UnitcellPicker = /*@__PURE__*/(function (Picker) { - function UnitcellPicker(unitcell, structure) { - Picker.call(this); - this.unitcell = unitcell; - this.structure = structure; - } - - if ( Picker ) UnitcellPicker.__proto__ = Picker; - UnitcellPicker.prototype = Object.create( Picker && Picker.prototype ); - UnitcellPicker.prototype.constructor = UnitcellPicker; - - var prototypeAccessors$20 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$20.type.get = function () { return 'unitcell'; }; - prototypeAccessors$20.data.get = function () { return this.unitcell; }; - UnitcellPicker.prototype.getObject = function getObject ( /* pid */) { - return { - unitcell: this.unitcell, - structure: this.structure - }; - }; - UnitcellPicker.prototype._getPosition = function _getPosition ( /* pid */) { - return this.unitcell.getCenter(this.structure); - }; - - Object.defineProperties( UnitcellPicker.prototype, prototypeAccessors$20 ); - - return UnitcellPicker; -}(Picker)); -var UnknownPicker = /*@__PURE__*/(function (Picker) { - function UnknownPicker () { - Picker.apply(this, arguments); - } - - if ( Picker ) UnknownPicker.__proto__ = Picker; - UnknownPicker.prototype = Object.create( Picker && Picker.prototype ); - UnknownPicker.prototype.constructor = UnknownPicker; - - var prototypeAccessors$21 = { type: { configurable: true } }; - - prototypeAccessors$21.type.get = function () { return 'unknown'; }; - - Object.defineProperties( UnknownPicker.prototype, prototypeAccessors$21 ); - - return UnknownPicker; -}(Picker)); -var VolumePicker = /*@__PURE__*/(function (Picker) { - function VolumePicker(array, volume) { - Picker.call(this, array); - this.volume = volume; - } - - if ( Picker ) VolumePicker.__proto__ = Picker; - VolumePicker.prototype = Object.create( Picker && Picker.prototype ); - VolumePicker.prototype.constructor = VolumePicker; - - var prototypeAccessors$22 = { type: { configurable: true },data: { configurable: true } }; - prototypeAccessors$22.type.get = function () { return 'volume'; }; - prototypeAccessors$22.data.get = function () { return this.volume; }; - VolumePicker.prototype.getObject = function getObject (pid) { - var vol = this.volume; - var idx = this.getIndex(pid); - return { - volume: vol, - index: idx, - value: vol.data[idx] - }; - }; - VolumePicker.prototype._getPosition = function _getPosition (pid) { - var dp = this.volume.position; - var idx = this.getIndex(pid); - return new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](dp[idx * 3], dp[idx * 3 + 1], dp[idx * 3 + 2]); - }; - - Object.defineProperties( VolumePicker.prototype, prototypeAccessors$22 ); - - return VolumePicker; -}(Picker)); -var SlicePicker = /*@__PURE__*/(function (VolumePicker) { - function SlicePicker () { - VolumePicker.apply(this, arguments); - } - - if ( VolumePicker ) SlicePicker.__proto__ = VolumePicker; - SlicePicker.prototype = Object.create( VolumePicker && VolumePicker.prototype ); - SlicePicker.prototype.constructor = SlicePicker; - - var prototypeAccessors$23 = { type: { configurable: true } }; - - prototypeAccessors$23.type.get = function () { return 'slice'; }; - - Object.defineProperties( SlicePicker.prototype, prototypeAccessors$23 ); - - return SlicePicker; -}(VolumePicker)); -var PointPicker = /*@__PURE__*/(function (ShapePicker) { - function PointPicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) PointPicker.__proto__ = ShapePicker; - PointPicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - PointPicker.prototype.constructor = PointPicker; - - var prototypeAccessors$24 = { primitive: { configurable: true } }; - - prototypeAccessors$24.primitive.get = function () { return PointPrimitive; }; - - Object.defineProperties( PointPicker.prototype, prototypeAccessors$24 ); - - return PointPicker; -}(ShapePicker)); -var WidelinePicker = /*@__PURE__*/(function (ShapePicker) { - function WidelinePicker () { - ShapePicker.apply(this, arguments); - } - - if ( ShapePicker ) WidelinePicker.__proto__ = ShapePicker; - WidelinePicker.prototype = Object.create( ShapePicker && ShapePicker.prototype ); - WidelinePicker.prototype.constructor = WidelinePicker; - - var prototypeAccessors$25 = { primitive: { configurable: true } }; - - prototypeAccessors$25.primitive.get = function () { return WidelinePrimitive; }; - - Object.defineProperties( WidelinePicker.prototype, prototypeAccessors$25 ); - - return WidelinePicker; -}(ShapePicker)); -PickerRegistry.add('arrow', ArrowPicker); -PickerRegistry.add('box', BoxPicker); -PickerRegistry.add('cone', ConePicker); -PickerRegistry.add('cylinder', CylinderPicker); -PickerRegistry.add('ellipsoid', EllipsoidPicker); -PickerRegistry.add('octahedron', OctahedronPicker); -PickerRegistry.add('sphere', SpherePicker); -PickerRegistry.add('tetrahedron', TetrahedronPicker); -PickerRegistry.add('torus', TorusPicker); -PickerRegistry.add('point', PointPicker); -PickerRegistry.add('wideline', WidelinePicker); - -/** - * @file Marching Cubes - * @author Alexander Rose - * @private - */ -function getEdgeTable() { - return new Uint32Array([ - 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, - 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, - 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, - 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, - 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, - 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, - 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, - 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, - 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, - 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, - 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, - 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, - 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, - 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, - 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, - 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, - 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, - 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, - 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, - 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, - 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, - 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, - 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, - 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, - 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, - 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, - 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, - 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, - 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, - 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, - 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, - 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 - ]); -} -function getTriTable() { - return new Int32Array([ - -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 - ]); -} -// Triangles are constructed between points on cube edges. -// allowedContours[edge1][edge1] indicates which lines from a given -// triangle should be shown in line mode. -// Values are bitmasks: -// In loop over cubes we keep another bitmask indicating whether our current -// cell is the first x-value (1), -// first y-value (2) or first z-value (4) of the current loop. -// We draw all lines on leading faces but only draw trailing face lines the first -// time through the loop -// A value of 8 below means the edge is always drawn (leading face) -// E.g. the first row, lines between edge0 and other edges in the bottom -// x-y plane are only drawn for the first value of z, edges in the -// x-z plane are only drawn for the first value of y. No other lines -// are drawn as they're redundant -// The line between edge 1 and 5 is always drawn as it's on the leading edge -function getAllowedContours() { - return [ - [0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0], - [4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0], - [4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8], - [4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1], - [2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0], - [0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0], - [0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8], - [0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1], - [2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1], - [2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0], - [0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8], - [0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0] - ]; -} -function MarchingCubes(field, nx, ny, nz, atomindex) { - // Based on alteredq / http://alteredqualia.com/ - // port of greggman's ThreeD version of marching cubes to Three.js - // http://webglsamples.googlecode.com/hg/blob/blob.html - // - // Adapted for NGL by Alexander Rose - var isolevel = 0; - var noNormals = false; - var contour = false; - var wrap = false; - var isNegativeIso = false; - var normalFactor = -1; - var n = nx * ny * nz; - // deltas - var yd = nx; - var zd = nx * ny; - var normalCache, vertexIndex; - var count, icount; - var ilist = new Int32Array(12); - var positionArray = []; - var normalArray = []; - var indexArray = []; - var atomindexArray = []; - var edgeTable = getEdgeTable(); - var triTable = getTriTable(); - var allowedContours = getAllowedContours(); - var mx, my, mz; - // - this.triangulate = function (_isolevel, _noNormals, _box, _contour, _wrap) { - isolevel = _isolevel; - isNegativeIso = isolevel < 0.0; - contour = _contour; - wrap = _wrap; - // Normals currently disabled in contour mode for performance (unused) - noNormals = _noNormals || contour; - if (!noNormals) { - normalFactor = isolevel > 0 ? -1.0 : 1.0; - if (!normalCache) { - normalCache = new Float32Array(n * 3); - } - } - var vIndexLength = n * 3; - if (!vertexIndex || vertexIndex.length !== vIndexLength) { - vertexIndex = new Int32Array(vIndexLength); - } - count = 0; - icount = 0; - if (_box !== undefined) { - var min = _box[0].map(Math.round); - var max = _box[1].map(Math.round); - mx = nx * Math.ceil(Math.abs(min[0]) / nx); - my = ny * Math.ceil(Math.abs(min[1]) / ny); - mz = nz * Math.ceil(Math.abs(min[2]) / nz); - triangulate(min[0], min[1], min[2], max[0], max[1], max[2]); - } - else { - mx = my = mz = 0; - triangulate(); - } - positionArray.length = count * 3; - if (!noNormals) - { normalArray.length = count * 3; } - indexArray.length = icount; - if (atomindex) - { atomindexArray.length = count; } - return { - position: new Float32Array(positionArray), - normal: noNormals ? undefined : new Float32Array(normalArray), - index: getUintArray(indexArray, positionArray.length / 3), - atomindex: atomindex ? new Int32Array(atomindexArray) : undefined, - contour: contour - }; - }; - // polygonization - function lerp(a, b, t) { return a + (b - a) * t; } - function index(x, y, z) { - x = (x + mx) % nx; - y = (y + my) % ny; - z = (z + mz) % nz; - return ((zd * z) + yd * y) + x; - } - function VIntX(q, offset, x, y, z, valp1, valp2) { - var _q = 3 * q; - if (vertexIndex[_q] < 0) { - var mu = (isolevel - valp1) / (valp2 - valp1); - var nc = normalCache; - var c = count * 3; - positionArray[c + 0] = x + mu; - positionArray[c + 1] = y; - positionArray[c + 2] = z; - if (!noNormals) { - var q3 = q * 3; - normalArray[c] = normalFactor * lerp(nc[q3], nc[q3 + 3], mu); - normalArray[c + 1] = normalFactor * lerp(nc[q3 + 1], nc[q3 + 4], mu); - normalArray[c + 2] = normalFactor * lerp(nc[q3 + 2], nc[q3 + 5], mu); - } - if (atomindex) - { atomindexArray[count] = atomindex[q + Math.round(mu)]; } - vertexIndex[_q] = count; - ilist[offset] = count; - count += 1; - } - else { - ilist[offset] = vertexIndex[_q]; - } - } - function VIntY(q, offset, x, y, z, valp1, valp2) { - var _q = 3 * q + 1; - if (vertexIndex[_q] < 0) { - var mu = (isolevel - valp1) / (valp2 - valp1); - var nc = normalCache; - var c = count * 3; - positionArray[c] = x; - positionArray[c + 1] = y + mu; - positionArray[c + 2] = z; - if (!noNormals) { - var q3 = q * 3; - var q6 = q3 + yd * 3; - normalArray[c] = normalFactor * lerp(nc[q3], nc[q6], mu); - normalArray[c + 1] = normalFactor * lerp(nc[q3 + 1], nc[q6 + 1], mu); - normalArray[c + 2] = normalFactor * lerp(nc[q3 + 2], nc[q6 + 2], mu); - } - if (atomindex) - { atomindexArray[count] = atomindex[q + Math.round(mu) * yd]; } - vertexIndex[_q] = count; - ilist[offset] = count; - count += 1; - } - else { - ilist[offset] = vertexIndex[_q]; - } - } - function VIntZ(q, offset, x, y, z, valp1, valp2) { - var _q = 3 * q + 2; - if (vertexIndex[_q] < 0) { - var mu = (isolevel - valp1) / (valp2 - valp1); - var nc = normalCache; - var c = count * 3; - positionArray[c] = x; - positionArray[c + 1] = y; - positionArray[c + 2] = z + mu; - if (!noNormals) { - var q3 = q * 3; - var q6 = q3 + zd * 3; - normalArray[c] = normalFactor * lerp(nc[q3], nc[q6], mu); - normalArray[c + 1] = normalFactor * lerp(nc[q3 + 1], nc[q6 + 1], mu); - normalArray[c + 2] = normalFactor * lerp(nc[q3 + 2], nc[q6 + 2], mu); - } - if (atomindex) - { atomindexArray[count] = atomindex[q + Math.round(mu) * zd]; } - vertexIndex[_q] = count; - ilist[offset] = count; - count += 1; - } - else { - ilist[offset] = vertexIndex[_q]; - } - } - function compNorm(q) { - var q3 = q * 3; - if (normalCache[q3] === 0.0) { - normalCache[q3] = field[(q - 1 + n) % n] - field[(q + 1) % n]; - normalCache[q3 + 1] = field[(q - yd + n) % n] - field[(q + yd) % n]; - normalCache[q3 + 2] = field[(q - zd + n) % n] - field[(q + zd) % n]; - } - } - function polygonize(fx, fy, fz, q, edgeFilter) { - // cache indices - var q1; - var qy; - var qz; - var q1y; - var q1z; - var qyz; - var q1yz; - if (wrap) { - q = index(fx, fy, fz); - q1 = index(fx + 1, fy, fz); - qy = index(fx, fy + 1, fz); - qz = index(fx, fy, fz + 1); - q1y = index(fx + 1, fy + 1, fz); - q1z = index(fx + 1, fy, fz + 1); - qyz = index(fx, fy + 1, fz + 1); - q1yz = index(fx + 1, fy + 1, fz + 1); - } - else { - q1 = q + 1; - qy = q + yd; - qz = q + zd; - q1y = qy + 1; - q1z = qz + 1; - qyz = qy + zd; - q1yz = qyz + 1; - } - var cubeindex = 0; - var field0 = field[q]; - var field1 = field[q1]; - var field2 = field[qy]; - var field3 = field[q1y]; - var field4 = field[qz]; - var field5 = field[q1z]; - var field6 = field[qyz]; - var field7 = field[q1yz]; - if (field0 < isolevel) - { cubeindex |= 1; } - if (field1 < isolevel) - { cubeindex |= 2; } - if (field2 < isolevel) - { cubeindex |= 8; } - if (field3 < isolevel) - { cubeindex |= 4; } - if (field4 < isolevel) - { cubeindex |= 16; } - if (field5 < isolevel) - { cubeindex |= 32; } - if (field6 < isolevel) - { cubeindex |= 128; } - if (field7 < isolevel) - { cubeindex |= 64; } - // if cube is entirely in/out of the surface - bail, nothing to draw - var bits = edgeTable[cubeindex]; - if (bits === 0) - { return 0; } - var fx2 = fx + 1; - var fy2 = fy + 1; - var fz2 = fz + 1; - // top of the cube - if (bits & 1) { - if (!noNormals) { - compNorm(q); - compNorm(q1); - } - VIntX(q, 0, fx, fy, fz, field0, field1); - } - if (bits & 2) { - if (!noNormals) { - compNorm(q1); - compNorm(q1y); - } - VIntY(q1, 1, fx2, fy, fz, field1, field3); - } - if (bits & 4) { - if (!noNormals) { - compNorm(qy); - compNorm(q1y); - } - VIntX(qy, 2, fx, fy2, fz, field2, field3); - } - if (bits & 8) { - if (!noNormals) { - compNorm(q); - compNorm(qy); - } - VIntY(q, 3, fx, fy, fz, field0, field2); - } - // bottom of the cube - if (bits & 16) { - if (!noNormals) { - compNorm(qz); - compNorm(q1z); - } - VIntX(qz, 4, fx, fy, fz2, field4, field5); - } - if (bits & 32) { - if (!noNormals) { - compNorm(q1z); - compNorm(q1yz); - } - VIntY(q1z, 5, fx2, fy, fz2, field5, field7); - } - if (bits & 64) { - if (!noNormals) { - compNorm(qyz); - compNorm(q1yz); - } - VIntX(qyz, 6, fx, fy2, fz2, field6, field7); - } - if (bits & 128) { - if (!noNormals) { - compNorm(qz); - compNorm(qyz); - } - VIntY(qz, 7, fx, fy, fz2, field4, field6); - } - // vertical lines of the cube - if (bits & 256) { - if (!noNormals) { - compNorm(q); - compNorm(qz); - } - VIntZ(q, 8, fx, fy, fz, field0, field4); - } - if (bits & 512) { - if (!noNormals) { - compNorm(q1); - compNorm(q1z); - } - VIntZ(q1, 9, fx2, fy, fz, field1, field5); - } - if (bits & 1024) { - if (!noNormals) { - compNorm(q1y); - compNorm(q1yz); - } - VIntZ(q1y, 10, fx2, fy2, fz, field3, field7); - } - if (bits & 2048) { - if (!noNormals) { - compNorm(qy); - compNorm(qyz); - } - VIntZ(qy, 11, fx, fy2, fz, field2, field6); - } - var triIndex = cubeindex << 4; // re-purpose cubeindex into an offset into triTable - var e1; - var e2; - var e3; - var i = 0; - // here is where triangles are created - while (triTable[triIndex + i] !== -1) { - e1 = triTable[triIndex + i]; - e2 = triTable[triIndex + i + 1]; - e3 = triTable[triIndex + i + 2]; - if (contour) { - if (allowedContours[e1][e2] & edgeFilter) { - indexArray[icount++] = ilist[e1]; - indexArray[icount++] = ilist[e2]; - } - if (allowedContours[e2][e3] & edgeFilter) { - indexArray[icount++] = ilist[e2]; - indexArray[icount++] = ilist[e3]; - } - if (allowedContours[e1][e3] & edgeFilter) { - indexArray[icount++] = ilist[e1]; - indexArray[icount++] = ilist[e3]; - } - } - else { - indexArray[icount++] = ilist[isNegativeIso ? e1 : e2]; - indexArray[icount++] = ilist[isNegativeIso ? e2 : e1]; - indexArray[icount++] = ilist[e3]; - } - i += 3; - } - } - function triangulate(xBeg, yBeg, zBeg, xEnd, yEnd, zEnd) { - var q; - var q3; - var x; - var y; - var z; - var yOffset; - var zOffset; - xBeg = xBeg !== undefined ? xBeg : 0; - yBeg = yBeg !== undefined ? yBeg : 0; - zBeg = zBeg !== undefined ? zBeg : 0; - xEnd = xEnd !== undefined ? xEnd : nx - 1; - yEnd = yEnd !== undefined ? yEnd : ny - 1; - zEnd = zEnd !== undefined ? zEnd : nz - 1; - if (!wrap) { - if (noNormals) { - xBeg = Math.max(0, xBeg); - yBeg = Math.max(0, yBeg); - zBeg = Math.max(0, zBeg); - xEnd = Math.min(nx - 1, xEnd); - yEnd = Math.min(ny - 1, yEnd); - zEnd = Math.min(nz - 1, zEnd); - } - else { - xBeg = Math.max(1, xBeg); - yBeg = Math.max(1, yBeg); - zBeg = Math.max(1, zBeg); - xEnd = Math.min(nx - 2, xEnd); - yEnd = Math.min(ny - 2, yEnd); - zEnd = Math.min(nz - 2, zEnd); - } - } - var xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2; - if (!wrap) { - // init part of the vertexIndex - // (takes a significant amount of time to do for all) - xBeg2 = Math.max(0, xBeg - 2); - yBeg2 = Math.max(0, yBeg - 2); - zBeg2 = Math.max(0, zBeg - 2); - xEnd2 = Math.min(nx, xEnd + 2); - yEnd2 = Math.min(ny, yEnd + 2); - zEnd2 = Math.min(nz, zEnd + 2); - for (z = zBeg2; z < zEnd2; ++z) { - zOffset = zd * z; - for (y = yBeg2; y < yEnd2; ++y) { - yOffset = zOffset + yd * y; - for (x = xBeg2; x < xEnd2; ++x) { - q = 3 * (yOffset + x); - vertexIndex[q] = -1; - vertexIndex[q + 1] = -1; - vertexIndex[q + 2] = -1; - } - } - } - } - else { - xBeg2 = xBeg - 2; - yBeg2 = yBeg - 2; - zBeg2 = zBeg - 2; - xEnd2 = xEnd + 2; - yEnd2 = yEnd + 2; - zEnd2 = zEnd + 2; - for (z = zBeg2; z < zEnd2; ++z) { - for (y = yBeg2; y < yEnd2; ++y) { - for (x = xBeg2; x < xEnd2; ++x) { - q3 = index(x, y, z) * 3; - vertexIndex[q3] = -1; - vertexIndex[q3 + 1] = -1; - vertexIndex[q3 + 2] = -1; - } - } - } - } - if (!wrap) { - // clip space where the isovalue is too low - var __break; - var __xBeg = xBeg; - var __yBeg = yBeg; - var __zBeg = zBeg; - var __xEnd = xEnd; - var __yEnd = yEnd; - var __zEnd = zEnd; - __break = false; - for (z = zBeg; z < zEnd; ++z) { - for (y = yBeg; y < yEnd; ++y) { - for (x = xBeg; x < xEnd; ++x) { - q = ((nx * ny) * z) + (nx * y) + x; - if (field[q] >= isolevel) { - __zBeg = z; - __break = true; - break; - } - } - if (__break) - { break; } - } - if (__break) - { break; } - } - __break = false; - for (y = yBeg; y < yEnd; ++y) { - for (z = __zBeg; z < zEnd; ++z) { - for (x = xBeg; x < xEnd; ++x) { - q = ((nx * ny) * z) + (nx * y) + x; - if (field[q] >= isolevel) { - __yBeg = y; - __break = true; - break; - } - } - if (__break) - { break; } - } - if (__break) - { break; } - } - __break = false; - for (x = xBeg; x < xEnd; ++x) { - for (y = __yBeg; y < yEnd; ++y) { - for (z = __zBeg; z < zEnd; ++z) { - q = ((nx * ny) * z) + (nx * y) + x; - if (field[q] >= isolevel) { - __xBeg = x; - __break = true; - break; - } - } - if (__break) - { break; } - } - if (__break) - { break; } - } - __break = false; - for (z = zEnd; z >= zBeg; --z) { - for (y = yEnd; y >= yBeg; --y) { - for (x = xEnd; x >= xBeg; --x) { - q = ((nx * ny) * z) + (nx * y) + x; - if (field[q] >= isolevel) { - __zEnd = z; - __break = true; - break; - } - } - if (__break) - { break; } - } - if (__break) - { break; } - } - __break = false; - for (y = yEnd; y >= yBeg; --y) { - for (z = __zEnd; z >= zBeg; --z) { - for (x = xEnd; x >= xBeg; --x) { - q = ((nx * ny) * z) + (nx * y) + x; - if (field[q] >= isolevel) { - __yEnd = y; - __break = true; - break; - } - } - if (__break) - { break; } - } - if (__break) - { break; } - } - __break = false; - for (x = xEnd; x >= xBeg; --x) { - for (y = __yEnd; y >= yBeg; --y) { - for (z = __zEnd; z >= zBeg; --z) { - q = ((nx * ny) * z) + (nx * y) + x; - if (field[q] >= isolevel) { - __xEnd = x; - __break = true; - break; - } - } - if (__break) - { break; } - } - if (__break) - { break; } - } - // - if (noNormals) { - xBeg = Math.max(0, __xBeg - 1); - yBeg = Math.max(0, __yBeg - 1); - zBeg = Math.max(0, __zBeg - 1); - xEnd = Math.min(nx - 1, __xEnd + 1); - yEnd = Math.min(ny - 1, __yEnd + 1); - zEnd = Math.min(nz - 1, __zEnd + 1); - } - else { - xBeg = Math.max(1, __xBeg - 1); - yBeg = Math.max(1, __yBeg - 1); - zBeg = Math.max(1, __zBeg - 1); - xEnd = Math.min(nx - 2, __xEnd + 1); - yEnd = Math.min(ny - 2, __yEnd + 1); - zEnd = Math.min(nz - 2, __zEnd + 1); - } - } - // polygonize part of the grid - var edgeFilter = 15; - for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) { - zOffset = zd * z; - edgeFilter |= 2; - for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) { - yOffset = zOffset + yd * y; - edgeFilter |= 1; - for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) { - q = yOffset + x; - polygonize(x, y, z, q, edgeFilter); - } - } - } - } -} -Object.assign(MarchingCubes, { __deps: [getEdgeTable, getTriTable, getAllowedContours, getUintArray] }); - -/** - * @file Matrix Utils - * @private - * @author Alexander Rose - * - * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/ - */ -var Matrix = function Matrix(cols, rows) { - this.cols = cols; - this.rows = rows; - this.size = this.cols * this.rows; - this.data = new Float32Array(this.size); -}; -Matrix.prototype.copyTo = function copyTo (matrix) { - matrix.data.set(this.data); -}; -function transpose(At, A) { - var i = 0; - var j = 0; - var nrows = A.rows; - var ncols = A.cols; - var Ai = 0; - var Ati = 0; - var pAt = 0; - var ad = A.data; - var atd = At.data; - for (; i < nrows; Ati += 1, Ai += ncols, i++) { - pAt = Ati; - for (j = 0; j < ncols; pAt += nrows, j++) - { atd[pAt] = ad[Ai + j]; } - } -} -// C = A * B -function multiply(C, A, B) { - var i = 0; - var j = 0; - var k = 0; - var Ap = 0; - var pA = 0; - var pB = 0; - var _pB = 0; - var Cp = 0; - var ncols = A.cols; - var nrows = A.rows; - var mcols = B.cols; - var ad = A.data; - var bd = B.data; - var cd = C.data; - var sum = 0.0; - for (; i < nrows; Ap += ncols, i++) { - for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) { - pB = _pB; - pA = Ap; - sum = 0.0; - for (k = 0; k < ncols; pA++, pB += mcols, k++) { - sum += ad[pA] * bd[pB]; - } - cd[Cp] = sum; - } - } -} -// C = A * B' -function multiplyABt(C, A, B) { - var i = 0; - var j = 0; - var k = 0; - var Ap = 0; - var pA = 0; - var pB = 0; - var Cp = 0; - var ncols = A.cols; - var nrows = A.rows; - var mrows = B.rows; - var ad = A.data; - var bd = B.data; - var cd = C.data; - var sum = 0.0; - for (; i < nrows; Ap += ncols, i++) { - for (pB = 0, j = 0; j < mrows; Cp++, j++) { - pA = Ap; - sum = 0.0; - for (k = 0; k < ncols; pA++, pB++, k++) { - sum += ad[pA] * bd[pB]; - } - cd[Cp] = sum; - } - } -} -function invert3x3(from, to) { - var A = from.data; - var invA = to.data; - var t1 = A[4]; - var t2 = A[8]; - var t4 = A[5]; - var t5 = A[7]; - var t8 = A[0]; - var t9 = t8 * t1; - var t11 = t8 * t4; - var t13 = A[3]; - var t14 = A[1]; - var t15 = t13 * t14; - var t17 = A[2]; - var t18 = t13 * t17; - var t20 = A[6]; - var t21 = t20 * t14; - var t23 = t20 * t17; - var t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1); - invA[0] = (t1 * t2 - t4 * t5) * t26; - invA[1] = -(t14 * t2 - t17 * t5) * t26; - invA[2] = -(-t14 * t4 + t17 * t1) * t26; - invA[3] = -(t13 * t2 - t4 * t20) * t26; - invA[4] = (t8 * t2 - t23) * t26; - invA[5] = -(t11 - t18) * t26; - invA[6] = -(-t13 * t5 + t1 * t20) * t26; - invA[7] = -(t8 * t5 - t21) * t26; - invA[8] = (t9 - t15) * t26; -} -function mat3x3determinant(M) { - var md = M.data; - return md[0] * md[4] * md[8] - - md[0] * md[5] * md[7] - - md[3] * md[1] * md[8] + - md[3] * md[2] * md[7] + - md[6] * md[1] * md[5] - - md[6] * md[2] * md[4]; -} -// C = A * B -function multiply3x3(C, A, B) { - var Cd = C.data; - var Ad = A.data; - var Bd = B.data; - var m10 = Ad[0]; - var m11 = Ad[1]; - var m12 = Ad[2]; - var m13 = Ad[3]; - var m14 = Ad[4]; - var m15 = Ad[5]; - var m16 = Ad[6]; - var m17 = Ad[7]; - var m18 = Ad[8]; - var m20 = Bd[0]; - var m21 = Bd[1]; - var m22 = Bd[2]; - var m23 = Bd[3]; - var m24 = Bd[4]; - var m25 = Bd[5]; - var m26 = Bd[6]; - var m27 = Bd[7]; - var m28 = Bd[8]; - Cd[0] = m10 * m20 + m11 * m23 + m12 * m26; - Cd[1] = m10 * m21 + m11 * m24 + m12 * m27; - Cd[2] = m10 * m22 + m11 * m25 + m12 * m28; - Cd[3] = m13 * m20 + m14 * m23 + m15 * m26; - Cd[4] = m13 * m21 + m14 * m24 + m15 * m27; - Cd[5] = m13 * m22 + m14 * m25 + m15 * m28; - Cd[6] = m16 * m20 + m17 * m23 + m18 * m26; - Cd[7] = m16 * m21 + m17 * m24 + m18 * m27; - Cd[8] = m16 * m22 + m17 * m25 + m18 * m28; -} -function meanRows(A) { - var nrows = A.rows; - var ncols = A.cols; - var Ad = A.data; - var mean = new Array(ncols); - for (var j = 0; j < ncols; ++j) { - mean[j] = 0.0; - } - for (var i = 0, p = 0; i < nrows; ++i) { - for (var j$1 = 0; j$1 < ncols; ++j$1, ++p) { - mean[j$1] += Ad[p]; - } - } - for (var j$2 = 0; j$2 < ncols; ++j$2) { - mean[j$2] /= nrows; - } - return mean; -} -function subRows(A, row) { - var nrows = A.rows; - var ncols = A.cols; - var Ad = A.data; - for (var i = 0, p = 0; i < nrows; ++i) { - for (var j = 0; j < ncols; ++j, ++p) { - Ad[p] -= row[j]; - } - } -} -function swap$1(A, i0, i1, t) { - t = A[i0]; - A[i0] = A[i1]; - A[i1] = t; -} -function hypot(a, b) { - a = Math.abs(a); - b = Math.abs(b); - if (a > b) { - b /= a; - return a * Math.sqrt(1.0 + b * b); - } - if (b > 0) { - a /= b; - return b * Math.sqrt(1.0 + a * a); - } - return 0.0; -} -var EPSILON = 0.0000001192092896; -var FLT_MIN = 1E-37; -function JacobiSVDImpl(At, astep, _W, Vt, vstep, m, n, n1) { - var eps = EPSILON * 2.0; - var minval = FLT_MIN; - var i = 0; - var j = 0; - var k = 0; - var iter = 0; - var maxIter = Math.max(m, 30); - var Ai = 0; - var Aj = 0; - var Vi = 0; - var Vj = 0; - var changed = 0; - var c = 0.0; - var s = 0.0; - var t = 0.0; - var t0 = 0.0; - var t1 = 0.0; - var sd = 0.0; - var beta = 0.0; - var gamma = 0.0; - var delta = 0.0; - var a = 0.0; - var p = 0.0; - var b = 0.0; - var seed = 0x1234; - var val = 0.0; - var val0 = 0.0; - var asum = 0.0; - var W = new Float64Array(n << 3); - for (; i < n; i++) { - for (k = 0, sd = 0; k < m; k++) { - t = At[i * astep + k]; - sd += t * t; - } - W[i] = sd; - if (Vt) { - for (k = 0; k < n; k++) { - Vt[i * vstep + k] = 0; - } - Vt[i * vstep + i] = 1; - } - } - for (; iter < maxIter; iter++) { - changed = 0; - for (i = 0; i < n - 1; i++) { - for (j = i + 1; j < n; j++) { - Ai = (i * astep) | 0; - Aj = (j * astep) | 0; - a = W[i]; - p = 0; - b = W[j]; - k = 2; - p += At[Ai] * At[Aj]; - p += At[Ai + 1] * At[Aj + 1]; - for (; k < m; k++) { - p += At[Ai + k] * At[Aj + k]; - } - if (Math.abs(p) <= eps * Math.sqrt(a * b)) - { continue; } - p *= 2.0; - beta = a - b; - gamma = hypot(p, beta); - if (beta < 0) { - delta = (gamma - beta) * 0.5; - s = Math.sqrt(delta / gamma); - c = (p / (gamma * s * 2.0)); - } - else { - c = Math.sqrt((gamma + beta) / (gamma * 2.0)); - s = (p / (gamma * c * 2.0)); - } - a = 0.0; - b = 0.0; - k = 2; // unroll - t0 = c * At[Ai] + s * At[Aj]; - t1 = -s * At[Ai] + c * At[Aj]; - At[Ai] = t0; - At[Aj] = t1; - a += t0 * t0; - b += t1 * t1; - t0 = c * At[Ai + 1] + s * At[Aj + 1]; - t1 = -s * At[Ai + 1] + c * At[Aj + 1]; - At[Ai + 1] = t0; - At[Aj + 1] = t1; - a += t0 * t0; - b += t1 * t1; - for (; k < m; k++) { - t0 = c * At[Ai + k] + s * At[Aj + k]; - t1 = -s * At[Ai + k] + c * At[Aj + k]; - At[Ai + k] = t0; - At[Aj + k] = t1; - a += t0 * t0; - b += t1 * t1; - } - W[i] = a; - W[j] = b; - changed = 1; - if (Vt) { - Vi = (i * vstep) | 0; - Vj = (j * vstep) | 0; - k = 2; - t0 = c * Vt[Vi] + s * Vt[Vj]; - t1 = -s * Vt[Vi] + c * Vt[Vj]; - Vt[Vi] = t0; - Vt[Vj] = t1; - t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]; - t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]; - Vt[Vi + 1] = t0; - Vt[Vj + 1] = t1; - for (; k < n; k++) { - t0 = c * Vt[Vi + k] + s * Vt[Vj + k]; - t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]; - Vt[Vi + k] = t0; - Vt[Vj + k] = t1; - } - } - } - } - if (changed === 0) - { break; } - } - for (i = 0; i < n; i++) { - for (k = 0, sd = 0; k < m; k++) { - t = At[i * astep + k]; - sd += t * t; - } - W[i] = Math.sqrt(sd); - } - for (i = 0; i < n - 1; i++) { - j = i; - for (k = i + 1; k < n; k++) { - if (W[j] < W[k]) { - j = k; - } - } - if (i !== j) { - swap$1(W, i, j, sd); - if (Vt) { - for (k = 0; k < m; k++) { - swap$1(At, i * astep + k, j * astep + k, t); - } - for (k = 0; k < n; k++) { - swap$1(Vt, i * vstep + k, j * vstep + k, t); - } - } - } - } - for (i = 0; i < n; i++) { - _W[i] = W[i]; - } - if (!Vt) { - return; - } - for (i = 0; i < n1; i++) { - sd = i < n ? W[i] : 0; - while (sd <= minval) { - // if we got a zero singular value, then in order to get the corresponding left singular vector - // we generate a random vector, project it to the previously computed left singular vectors, - // subtract the projection and normalize the difference. - val0 = (1.0 / m); - for (k = 0; k < m; k++) { - seed = (seed * 214013 + 2531011); - val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0; - At[i * astep + k] = val; - } - for (iter = 0; iter < 2; iter++) { - for (j = 0; j < i; j++) { - sd = 0; - for (k = 0; k < m; k++) { - sd += At[i * astep + k] * At[j * astep + k]; - } - asum = 0.0; - for (k = 0; k < m; k++) { - t = (At[i * astep + k] - sd * At[j * astep + k]); - At[i * astep + k] = t; - asum += Math.abs(t); - } - asum = asum ? 1.0 / asum : 0; - for (k = 0; k < m; k++) { - At[i * astep + k] *= asum; - } - } - } - sd = 0; - for (k = 0; k < m; k++) { - t = At[i * astep + k]; - sd += t * t; - } - sd = Math.sqrt(sd); - } - s = (1.0 / sd); - for (k = 0; k < m; k++) { - At[i * astep + k] *= s; - } - } -} -function svd(A, W, U, V) { - var at = 0; - var i = 0; - var _m = A.rows; - var _n = A.cols; - var m = _m; - var n = _n; - if (m < n) { - at = 1; - i = m; - m = n; - n = i; - } - var amt = new Matrix(m, m); - var wmt = new Matrix(1, n); - var vmt = new Matrix(n, n); - if (at === 0) { - transpose(amt, A); - } - else { - for (i = 0; i < _n * _m; i++) { - amt.data[i] = A.data[i]; - } - for (; i < n * m; i++) { - amt.data[i] = 0; - } - } - JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m); - if (W) { - for (i = 0; i < n; i++) { - W.data[i] = wmt.data[i]; - } - for (; i < _n; i++) { - W.data[i] = 0; - } - } - if (at === 0) { - if (U) - { transpose(U, amt); } - if (V) - { transpose(V, vmt); } - } - else { - if (U) - { transpose(U, vmt); } - if (V) - { transpose(V, amt); } - } -} -// -function m4new() { - return new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); -} -function m4set(out, n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) { - out[0] = n11; - out[4] = n12; - out[8] = n13; - out[12] = n14; - out[1] = n21; - out[5] = n22; - out[9] = n23; - out[13] = n24; - out[2] = n31; - out[6] = n32; - out[10] = n33; - out[14] = n34; - out[3] = n41; - out[7] = n42; - out[11] = n43; - out[15] = n44; -} -function m4multiply(out, a, b) { - var a11 = a[0]; - var a12 = a[4]; - var a13 = a[8]; - var a14 = a[12]; - var a21 = a[1]; - var a22 = a[5]; - var a23 = a[9]; - var a24 = a[13]; - var a31 = a[2]; - var a32 = a[6]; - var a33 = a[10]; - var a34 = a[14]; - var a41 = a[3]; - var a42 = a[7]; - var a43 = a[11]; - var a44 = a[15]; - var b11 = b[0]; - var b12 = b[4]; - var b13 = b[8]; - var b14 = b[12]; - var b21 = b[1]; - var b22 = b[5]; - var b23 = b[9]; - var b24 = b[13]; - var b31 = b[2]; - var b32 = b[6]; - var b33 = b[10]; - var b34 = b[14]; - var b41 = b[3]; - var b42 = b[7]; - var b43 = b[11]; - var b44 = b[15]; - out[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; - out[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; - out[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; - out[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; - out[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; - out[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; - out[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; - out[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; - out[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; - out[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; - out[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; - out[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; - out[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; - out[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; - out[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; - out[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; -} -function m4makeScale(out, x, y, z) { - m4set(out, x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1); -} -m4makeScale.__deps = [m4set]; -function m4makeTranslation(out, x, y, z) { - m4set(out, 1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1); -} -m4makeTranslation.__deps = [m4set]; -function m4makeRotationY(out, theta) { - var c = Math.cos(theta); - var s = Math.sin(theta); - m4set(out, c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1); -} -m4makeRotationY.__deps = [m4set]; -// -function m3new() { - return new Float32Array([ - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 - ]); -} -function m3makeNormal(out, m4) { - var r0 = v3new([m4[0], m4[1], m4[2]]); - var r1 = v3new([m4[4], m4[5], m4[6]]); - var r2 = v3new([m4[8], m4[9], m4[10]]); - var cp = v3new(); - // [ r0 ] [ r1 x r2 ] - // M3x3 = [ r1 ] N = [ r2 x r0 ] - // [ r2 ] [ r0 x r1 ] - v3cross(cp, r1, r2); - out[0] = cp[0]; - out[1] = cp[1]; - out[2] = cp[2]; - v3cross(cp, r2, r0); - out[3] = cp[0]; - out[4] = cp[1]; - out[5] = cp[2]; - v3cross(cp, r0, r1); - out[6] = cp[0]; - out[7] = cp[1]; - out[8] = cp[2]; -} -m3makeNormal.__deps = [v3new, v3cross]; - -/** - * @file Surface Utils - * @author Alexander Rose - * @private - */ -function laplacianSmooth(verts, faces, numiter, inflate) { - // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular - // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140. - // - // Permission to use, copy, modify, and distribute this program for - // any purpose, with or without fee, is hereby granted, provided that - // the notices on the head, the reference information, and this - // copyright notice appear in all copies or substantial portions of - // the Software. It is provided "as is" without express or implied - // warranty. - // - // ported to JavaScript and adapted to NGL by Alexander Rose - numiter = numiter || 1; - inflate = inflate || true; - var nv = verts.length / 3; - var nf = faces.length / 3; - var norms = undefined; - if (inflate) { - norms = new Float32Array(nv * 3); - } - var tps = new Float32Array(nv * 3); - var i; - var ndeg = 20; - var vertdeg = new Array(ndeg); - for (i = 0; i < ndeg; ++i) { - vertdeg[i] = new Uint32Array(nv); - } - for (i = 0; i < nv; ++i) { - vertdeg[0][i] = 0; - } - var j, jl; - var flagvert; - // for each face - for (i = 0; i < nf; ++i) { - var ao = i * 3; - var bo = i * 3 + 1; - var co = i * 3 + 2; - // vertex a - flagvert = true; - for (j = 0, jl = vertdeg[0][faces[ao]]; j < jl; ++j) { - if (faces[bo] === vertdeg[j + 1][faces[ao]]) { - flagvert = false; - break; - } - } - if (flagvert) { - vertdeg[0][faces[ao]]++; - vertdeg[vertdeg[0][faces[ao]]][faces[ao]] = faces[bo]; - } - flagvert = true; - for (j = 0, jl = vertdeg[0][faces[ao]]; j < jl; ++j) { - if (faces[co] === vertdeg[j + 1][faces[ao]]) { - flagvert = false; - break; - } - } - if (flagvert) { - vertdeg[0][faces[ao]]++; - vertdeg[vertdeg[0][faces[ao]]][faces[ao]] = faces[co]; - } - // vertex b - flagvert = true; - for (j = 0, jl = vertdeg[0][faces[bo]]; j < jl; ++j) { - if (faces[ao] === vertdeg[j + 1][faces[bo]]) { - flagvert = false; - break; - } - } - if (flagvert) { - vertdeg[0][faces[bo]]++; - vertdeg[vertdeg[0][faces[bo]]][faces[bo]] = faces[ao]; - } - flagvert = true; - for (j = 0, jl = vertdeg[0][faces[bo]]; j < jl; ++j) { - if (faces[co] === vertdeg[j + 1][faces[bo]]) { - flagvert = false; - break; - } - } - if (flagvert) { - vertdeg[0][faces[bo]]++; - vertdeg[vertdeg[0][faces[bo]]][faces[bo]] = faces[co]; - } - // vertex c - flagvert = true; - for (j = 0; j < vertdeg[0][faces[co]]; ++j) { - if (faces[ao] === vertdeg[j + 1][faces[co]]) { - flagvert = false; - break; - } - } - if (flagvert) { - vertdeg[0][faces[co]]++; - vertdeg[vertdeg[0][faces[co]]][faces[co]] = faces[ao]; - } - flagvert = true; - for (j = 0, jl = vertdeg[0][faces[co]]; j < jl; ++j) { - if (faces[bo] === vertdeg[j + 1][faces[co]]) { - flagvert = false; - break; - } - } - if (flagvert) { - vertdeg[0][faces[co]]++; - vertdeg[vertdeg[0][faces[co]]][faces[co]] = faces[bo]; - } - } - var wt = 1.0; - var wt2 = 0.5; - var i3, vi3, vdi, wtvi, wt2vi; - var ssign = -1; - var scaleFactor = 1; - var outwt = 0.75 / (scaleFactor + 3.5); // area-preserving - // smoothing iterations - for (var k = 0; k < numiter; ++k) { - // for each vertex - for (i = 0; i < nv; ++i) { - i3 = i * 3; - vdi = vertdeg[0][i]; - if (vdi < 3) { - tps[i3] = verts[i3]; - tps[i3 + 1] = verts[i3 + 1]; - tps[i3 + 2] = verts[i3 + 2]; - } - else if (vdi === 3 || vdi === 4) { - tps[i3] = 0; - tps[i3 + 1] = 0; - tps[i3 + 2] = 0; - for (j = 0; j < vdi; ++j) { - vi3 = vertdeg[j + 1][i] * 3; - tps[i3] += verts[vi3]; - tps[i3 + 1] += verts[vi3 + 1]; - tps[i3 + 2] += verts[vi3 + 2]; - } - tps[i3] += wt2 * verts[i3]; - tps[i3 + 1] += wt2 * verts[i3 + 1]; - tps[i3 + 2] += wt2 * verts[i3 + 2]; - wt2vi = wt2 + vdi; - tps[i3] /= wt2vi; - tps[i3 + 1] /= wt2vi; - tps[i3 + 2] /= wt2vi; - } - else { - tps[i3] = 0; - tps[i3 + 1] = 0; - tps[i3 + 2] = 0; - for (j = 0; j < vdi; ++j) { - vi3 = vertdeg[j + 1][i] * 3; - tps[i3] += verts[vi3]; - tps[i3 + 1] += verts[vi3 + 1]; - tps[i3 + 2] += verts[vi3 + 2]; - } - tps[i3] += wt * verts[i3]; - tps[i3 + 1] += wt * verts[i3 + 1]; - tps[i3 + 2] += wt * verts[i3 + 2]; - wtvi = wt + vdi; - tps[i3] /= wtvi; - tps[i3 + 1] /= wtvi; - tps[i3 + 2] /= wtvi; - } - } - verts.set(tps); // copy smoothed positions - if (inflate) { - computeVertexNormals(verts, faces, norms); - var nv3 = nv * 3; - for (i3 = 0; i3 < nv3; i3 += 3) { - // if(verts[i].inout) ssign=1; - // else ssign=-1; - verts[i3] += ssign * outwt * norms[i3]; - verts[i3 + 1] += ssign * outwt * norms[i3 + 1]; - verts[i3 + 2] += ssign * outwt * norms[i3 + 2]; - } - } - } -} -Object.assign(laplacianSmooth, { __deps: [computeVertexNormals] }); -function computeVertexNormals(position, index, normal) { - var i, il; - if (normal === undefined) { - normal = new Float32Array(position.length); - } - else { - // reset existing normals to zero - for (i = 0, il = normal.length; i < il; i++) { - normal[i] = 0; - } - } - var a = new Float32Array(3); - var b = new Float32Array(3); - var c = new Float32Array(3); - var cb = new Float32Array(3); - var ab = new Float32Array(3); - if (index) { - // indexed elements - for (i = 0, il = index.length; i < il; i += 3) { - var ai = index[i] * 3; - var bi = index[i + 1] * 3; - var ci = index[i + 2] * 3; - v3fromArray(a, position, ai); - v3fromArray(b, position, bi); - v3fromArray(c, position, ci); - v3sub(cb, c, b); - v3sub(ab, a, b); - v3cross(cb, cb, ab); - normal[ai] += cb[0]; - normal[ai + 1] += cb[1]; - normal[ai + 2] += cb[2]; - normal[bi] += cb[0]; - normal[bi + 1] += cb[1]; - normal[bi + 2] += cb[2]; - normal[ci] += cb[0]; - normal[ci + 1] += cb[1]; - normal[ci + 2] += cb[2]; - } - } - else { - // non-indexed elements (unconnected triangle soup) - for (i = 0, il = position.length; i < il; i += 9) { - v3fromArray(a, position, i); - v3fromArray(b, position, i + 3); - v3fromArray(c, position, i + 6); - v3sub(cb, c, b); - v3sub(ab, a, b); - v3cross(cb, cb, ab); - normal[i] = cb[0]; - normal[i + 1] = cb[1]; - normal[i + 2] = cb[2]; - normal[i + 3] = cb[0]; - normal[i + 4] = cb[1]; - normal[i + 5] = cb[2]; - normal[i + 6] = cb[0]; - normal[i + 7] = cb[1]; - normal[i + 8] = cb[2]; - } - } - normalizeVector3array(normal); - return normal; -} -Object.assign(computeVertexNormals, { __deps: [ - v3sub, v3cross, v3fromArray, normalizeVector3array - ] }); -function getRadiusDict(radiusList) { - var radiusDict = {}; - for (var i = 0, il = radiusList.length; i < il; ++i) { - radiusDict[radiusList[i]] = true; - } - return radiusDict; -} -function getSurfaceGrid(min, max, maxRadius, scaleFactor, extraMargin) { - // need margin to avoid boundary/round off effects - var margin = (1 / scaleFactor) * 3; - margin += maxRadius; - v3subScalar(min, min, extraMargin + margin); - v3addScalar(max, max, extraMargin + margin); - v3multiplyScalar(min, min, scaleFactor); - v3floor(min, min); - v3divideScalar(min, min, scaleFactor); - v3multiplyScalar(max, max, scaleFactor); - v3ceil(max, max); - v3divideScalar(max, max, scaleFactor); - var dim = new Float32Array(3); - v3sub(dim, max, min); - v3multiplyScalar(dim, dim, scaleFactor); - v3ceil(dim, dim); - v3addScalar(dim, dim, 1); - var maxSize = Math.pow(10, 6) * 256; - var tmpSize = dim[0] * dim[1] * dim[2] * 3; - if (maxSize <= tmpSize) { - scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3); - v3multiplyScalar(min, min, scaleFactor); - v3floor(min, min); - v3divideScalar(min, min, scaleFactor); - v3multiplyScalar(max, max, scaleFactor); - v3ceil(max, max); - v3divideScalar(max, max, scaleFactor); - v3sub(dim, max, min); - v3multiplyScalar(dim, dim, scaleFactor); - v3ceil(dim, dim); - v3addScalar(dim, dim, 1); - } - var tran = new Float32Array(min); - v3negate(tran, tran); - // coordinate transformation matrix - var matrix = m4new(); - var mroty = m4new(); - m4makeRotationY(mroty, degToRad(90)); - m4multiply(matrix, matrix, mroty); - var mscale = m4new(); - m4makeScale(mscale, -1 / scaleFactor, 1 / scaleFactor, 1 / scaleFactor); - m4multiply(matrix, matrix, mscale); - var mtrans = m4new(); - m4makeTranslation(mtrans, -scaleFactor * tran[2], -scaleFactor * tran[1], -scaleFactor * tran[0]); - m4multiply(matrix, matrix, mtrans); - return { - dim: dim, - tran: tran, - matrix: matrix, - scaleFactor: scaleFactor - }; -} -Object.assign(getSurfaceGrid, { '__deps': [ - degToRad, - v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar, - v3floor, v3ceil, v3sub, v3negate, - m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY - ] }); - -/** - * @file Surface - * @author Alexander Rose - * @private - */ -/** - * Surface - */ -var Surface = function Surface(name, path, data) { - this.name = name || ''; - this.path = path || ''; - this.info = {}; - this.center = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - if (data instanceof __WEBPACK_IMPORTED_MODULE_0_three__["s" /* Geometry */] || - data instanceof __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */] || - data instanceof __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]) { - // to be removed - this.fromGeometry(data); - } - else if (data) { - this.set(data.position, data.index, data.normal, data.color, data.atomindex, data.contour); - this.boundingBox.setFromArray(data.position); - this.boundingBox.getCenter(this.center); - } -}; - -var prototypeAccessors$a = { type: { configurable: true } }; -prototypeAccessors$a.type.get = function () { return 'Surface'; }; -/** - * set surface data - * @param {Float32Array} position - surface positions - * @param {Int32Array} index - surface indices - * @param {Float32Array} normal - surface normals - * @param {Float32Array} color - surface colors - * @param {Int32Array} atomindex - atom indices - * @param {boolean} contour - contour mode flag - * @return {undefined} - */ -Surface.prototype.set = function set (position, index, normal, color, atomindex, contour) { - if ( contour === void 0 ) contour = false; - - /** - * @type {Float32Array} - */ - this.position = position; - /** - * @type {Uint32Array|Uint16Array|undefined} - */ - this.index = index; - /** - * @type {Float32Array|undefined} - */ - this.normal = normal; - /** - * @type {Float32Array|undefined} - */ - this.color = color; - /** - * @type {Int32Array|undefined} - */ - this.atomindex = atomindex; - this.size = position.length / 3; - this.contour = contour; -}; -Surface.prototype.fromGeometry = function fromGeometry (geometry) { - if (Debug) - { Log.time('GeometrySurface.fromGeometry'); } - var geo; - if (geometry instanceof __WEBPACK_IMPORTED_MODULE_0_three__["s" /* Geometry */]) { - geometry.computeVertexNormals(true); - geo = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */]().fromGeometry(geometry); - } - else if (geometry instanceof __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */]) { - geo = geometry; - } - else { - geo = geometry[0]; - } - if (!geo.boundingBox) - { geo.computeBoundingBox(); } - this.boundingBox.copy(geo.boundingBox); - this.boundingBox.getCenter(this.center); - var position, color, index, normal; - if (geo instanceof __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */]) { - var attr = geo.attributes; - var an = attr.normal ? attr.normal.array : false; - // assume there are no normals if the first is zero - if (!an || (an[0] === 0 && an[1] === 0 && an[2] === 0)) { - geo.computeVertexNormals(); - } - position = attr.position.array; - index = attr.index ? attr.index.array : null; - normal = attr.normal.array; - } - this.set(position, index, normal, color, undefined); - if (Debug) - { Log.timeEnd('GeometrySurface.setGeometry'); } -}; -Surface.prototype.getPosition = function getPosition () { - return this.position; -}; -Surface.prototype.getColor = function getColor (params) { - var p = params || {}; - p.surface = this; - var n = this.size; - var array = new Float32Array(n * 3); - var colormaker = ColormakerRegistry$1.getScheme(p); - if (colormaker.volumeColor || p.scheme === 'random') { - for (var i = 0; i < n; ++i) { - colormaker.volumeColorToArray(i, array, i * 3); - } - } - else if (colormaker.positionColor) { - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var pos = this.position; - for (var i$1 = 0; i$1 < n; ++i$1) { - var i3 = i$1 * 3; - v.set(pos[i3], pos[i3 + 1], pos[i3 + 2]); - colormaker.positionColorToArray(v, array, i3); - } - } - else if (colormaker.atomColor && this.atomindex) { - var atomProxy = p.structure.getAtomProxy(); - var atomindex = this.atomindex; - for (var i$2 = 0; i$2 < n; ++i$2) { - atomProxy.index = atomindex[i$2]; - colormaker.atomColorToArray(atomProxy, array, i$2 * 3); - } - } - else { - var tc = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](p.value); - uniformArray3(n, tc.r, tc.g, tc.b, array); - } - return array; -}; -Surface.prototype.getPicking = function getPicking (structure) { - if (this.atomindex && structure) { - return new AtomPicker(this.atomindex, structure); - } - else { - return new SurfacePicker(serialArray(this.size), this); - } -}; -Surface.prototype.getNormal = function getNormal () { - return this.normal; -}; -Surface.prototype.getSize = function getSize (size, scale$$1) { - return uniformArray(this.size, size * scale$$1); -}; -Surface.prototype.getIndex = function getIndex () { - return this.index; -}; -Surface.prototype.getFilteredIndex = function getFilteredIndex (sele, structure) { - if (sele && this.atomindex) { - var selection = new Selection(sele); - var atomSet = structure.getAtomSet(selection); - var filteredIndex = []; - var atomindex = this.atomindex; - var index = this.index; - var n = index.length; - var elementSize = this.contour ? 2 : 3; - var j = 0; - for (var i = 0; i < n; i += elementSize) { - var include = true; - for (var a = 0; a < elementSize; a++) { - var idx = index[i + a]; - var ai = atomindex[idx]; - if (!atomSet.get(ai)) { - include = false; - break; - } - } - if (!include) { - continue; - } - for (var a$1 = 0; a$1 < elementSize; a$1++, j++) { - filteredIndex[j] = index[i + a$1]; - } - } - return getUintArray(filteredIndex, this.position.length / 3); - } - else { - return this.index; - } -}; -Surface.prototype.getAtomindex = function getAtomindex () { - return this.atomindex; -}; -Surface.prototype.dispose = function dispose () { - // -}; - -Object.defineProperties( Surface.prototype, prototypeAccessors$a ); - -/** - * @file Volume - * @author Alexander Rose - * @private - */ -function VolumeSurface(data, nx, ny, nz, atomindex) { - var mc = new MarchingCubes(data, nx, ny, nz, atomindex); - function getSurface(isolevel, smooth, box, matrix, contour, wrap) { - if ( wrap === void 0 ) wrap = false; - - var sd = mc.triangulate(isolevel, smooth, box, contour, wrap); - if (smooth && !contour) { - laplacianSmooth(sd.position, sd.index, smooth, true); - sd.normal = computeVertexNormals(sd.position, sd.index); - } - if (matrix) { - applyMatrix4toVector3array(matrix, sd.position); - if (sd.normal) { - var normalMatrix = m3new(); - m3makeNormal(normalMatrix, matrix); - applyMatrix3toVector3array(normalMatrix, sd.normal); - } - } - return sd; - } - this.getSurface = getSurface; -} -Object.assign(VolumeSurface, { __deps: [ - laplacianSmooth, computeVertexNormals, MarchingCubes, - applyMatrix4toVector3array, applyMatrix3toVector3array, - m3new, m3makeNormal - ] }); -WorkerRegistry$1.add('surf', function func(e, callback) { - var a = e.data.args; - var p = e.data.params; - if (a) { - /* global self */ - self.volsurf = new VolumeSurface(a[0], a[1], a[2], a[3], a[4]); - } - if (p) { - var sd = self.volsurf.getSurface(p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap); - var transferList = [sd.position.buffer, sd.index.buffer]; - if (sd.normal) - { transferList.push(sd.normal.buffer); } - if (sd.atomindex) - { transferList.push(sd.atomindex.buffer); } - var data = { - sd: sd, - p: p - }; - callback(data, transferList); - } -}, [VolumeSurface]); -/** - * Volume - */ -var Volume = function Volume(name, path, data, nx, ny, nz, atomindex) { - this.name = name; - this.path = path; - this.matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.normalMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["x" /* Matrix3 */](); - this.inverseMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.center = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this.setData(data, nx, ny, nz, atomindex); -}; - -var prototypeAccessors$b = { type: { configurable: true },position: { configurable: true },min: { configurable: true },max: { configurable: true },sum: { configurable: true },mean: { configurable: true },rms: { configurable: true } }; -prototypeAccessors$b.type.get = function () { return 'Volume'; }; -/** - * set volume data - * @param {Float32array} data - volume 3d grid - * @param {Integer} nx - x dimension of the 3d volume - * @param {Integer} ny - y dimension of the 3d volume - * @param {Integer} nz - z dimension of the 3d volume - * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid - * @return {undefined} - */ -Volume.prototype.setData = function setData (data, nx, ny, nz, atomindex) { - this.nx = nx || 1; - this.ny = ny || 1; - this.nz = nz || 1; - this.data = data || new Float32Array(1); - this.setAtomindex(atomindex); - delete this._position; - delete this._min; - delete this._max; - delete this._mean; - delete this._rms; - if (this.worker) - { this.worker.terminate(); } -}; -/** - * Set statistics, which can be different from the data in this volume, - * if this volume is a slice of a bigger volume - * @param {Number|undefined} min - minimum value of the whole data set - * @param {Number|undefined} max - maximum value of the whole data set - * @param {Number|undefined} mean - average value of the whole data set - * @param {Number|undefined} rms - sigma value of the whole data set - */ -Volume.prototype.setStats = function setStats (min, max, mean, rms) { - this._min = min; - this._max = max; - this._mean = mean; - this._rms = rms; -}; -/** - * set transformation matrix - * @param {Matrix4} matrix - 4x4 transformation matrix - * @return {undefined} - */ -Volume.prototype.setMatrix = function setMatrix (matrix) { - this.matrix.copy(matrix); - var bb = this.boundingBox; - var v = this.center; // temporary re-purposing - var x = this.nx - 1; - var y = this.ny - 1; - var z = this.nz - 1; - bb.makeEmpty(); - bb.expandByPoint(v.set(x, y, z)); - bb.expandByPoint(v.set(x, y, 0)); - bb.expandByPoint(v.set(x, 0, z)); - bb.expandByPoint(v.set(x, 0, 0)); - bb.expandByPoint(v.set(0, y, z)); - bb.expandByPoint(v.set(0, 0, z)); - bb.expandByPoint(v.set(0, y, 0)); - bb.expandByPoint(v.set(0, 0, 0)); - bb.applyMatrix4(this.matrix); - bb.getCenter(this.center); - // make normal matrix - var me = this.matrix.elements; - var r0 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](me[0], me[1], me[2]); - var r1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](me[4], me[5], me[6]); - var r2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](me[8], me[9], me[10]); - var cp = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - // [ r0 ] [ r1 x r2 ] - // M3x3 = [ r1 ] N = [ r2 x r0 ] - // [ r2 ] [ r0 x r1 ] - var ne = this.normalMatrix.elements; - cp.crossVectors(r1, r2); - ne[0] = cp.x; - ne[1] = cp.y; - ne[2] = cp.z; - cp.crossVectors(r2, r0); - ne[3] = cp.x; - ne[4] = cp.y; - ne[5] = cp.z; - cp.crossVectors(r0, r1); - ne[6] = cp.x; - ne[7] = cp.y; - ne[8] = cp.z; - this.inverseMatrix.getInverse(this.matrix); -}; -/** - * set atom indices - * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid - * @return {undefined} - */ -Volume.prototype.setAtomindex = function setAtomindex (atomindex) { - this.atomindex = atomindex; -}; -Volume.prototype.getBox = function getBox (center, size, target) { - if (!target) - { target = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); } - target.set(center, center); - target.expandByScalar(size); - target.applyMatrix4(this.inverseMatrix); - target.min.round(); - target.max.round(); - return target; -}; -Volume.prototype._getBox = function _getBox (center, size) { - if (!center || !size) - { return; } - if (!this.__box) - { this.__box = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); } - var box = this.getBox(center, size, this.__box); - return [box.min.toArray(), box.max.toArray()]; -}; -Volume.prototype._makeSurface = function _makeSurface (sd, isolevel, smooth) { - var name = this.name + '@' + isolevel.toPrecision(2); - var surface = new Surface(name, '', sd); - surface.info.isolevel = isolevel; - surface.info.smooth = smooth; - surface.info.volume = this; - return surface; -}; -Volume.prototype.getSurface = function getSurface (isolevel, smooth, center, size, contour, wrap) { - if ( wrap === void 0 ) wrap = false; - - isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel; - smooth = defaults(smooth, 0); - // - if (this.volsurf === undefined) { - this.volsurf = new VolumeSurface(this.data, this.nx, this.ny, this.nz, this.atomindex); - } - var box = this._getBox(center, size); - var sd = this.volsurf.getSurface(isolevel, smooth, box, this.matrix.elements, contour, wrap); - return this._makeSurface(sd, isolevel, smooth); -}; -Volume.prototype.getSurfaceWorker = function getSurfaceWorker (isolevel, smooth, center, size, contour, wrap, callback) { - var this$1 = this; - - isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel; - smooth = smooth || 0; - // - if (window.hasOwnProperty('Worker')) { - if (this.workerPool === undefined) { - this.workerPool = new WorkerPool('surf', 2); - } - var msg = {}; - var worker = this.workerPool.getNextWorker(); - if (worker.postCount === 0) { - Object.assign(msg, { - args: [ - this.data, this.nx, this.ny, this.nz, this.atomindex - ] - }); - } - Object.assign(msg, { - params: { - isolevel: isolevel, - smooth: smooth, - box: this._getBox(center, size), - matrix: this.matrix.elements, - contour: contour, - wrap: wrap - } - }); - worker.post(msg, undefined, function (e) { - var sd = e.data.sd; - var p = e.data.p; - callback(this$1._makeSurface(sd, p.isolevel, p.smooth)); - }, function (e) { - console.warn('Volume.getSurfaceWorker error - trying without worker', e); - var surface = this$1.getSurface(isolevel, smooth, center, size, contour, wrap); - callback(surface); - }); - } - else { - var surface = this.getSurface(isolevel, smooth, center, size, contour, wrap); - callback(surface); - } -}; -Volume.prototype.getValueForSigma = function getValueForSigma (sigma) { - return this.mean + defaults(sigma, 2) * this.rms; -}; -Volume.prototype.getSigmaForValue = function getSigmaForValue (value) { - return (defaults(value, 0) - this.mean) / this.rms; -}; -prototypeAccessors$b.position.get = function () { - if (!this._position) { - var nz = this.nz; - var ny = this.ny; - var nx = this.nx; - var position = new Float32Array(nx * ny * nz * 3); - var p = 0; - for (var z = 0; z < nz; ++z) { - for (var y = 0; y < ny; ++y) { - for (var x = 0; x < nx; ++x) { - position[p + 0] = x; - position[p + 1] = y; - position[p + 2] = z; - p += 3; - } - } - } - applyMatrix4toVector3array(this.matrix.elements, position); - this._position = position; - } - return this._position; -}; -Volume.prototype.getDataAtomindex = function getDataAtomindex () { - return this.atomindex; -}; -Volume.prototype.getDataPosition = function getDataPosition () { - return this.position; -}; -Volume.prototype.getDataColor = function getDataColor (params) { - var p = params || {}; - p.volume = this; - p.scale = p.scale || 'Spectral'; - p.domain = p.domain || [this.min, this.max]; - var colormaker = ColormakerRegistry$1.getScheme(p); - var n = this.position.length / 3; - var array = new Float32Array(n * 3); - // var atoms = p.structure.atoms; - // var atomindex = this.atomindex; - for (var i = 0; i < n; ++i) { - colormaker.volumeColorToArray(i, array, i * 3); - // a = atoms[ atomindex[ i ] ]; - // if( a ) colormaker.atomColorToArray( a, array, i * 3 ); - } - return array; -}; -Volume.prototype.getDataPicking = function getDataPicking () { - var picking = serialArray(this.position.length / 3); - return new VolumePicker(picking, this); -}; -Volume.prototype.getDataSize = function getDataSize (size, scale$$1) { - var data = this.data; - var n = this.position.length / 3; - var array; - switch (size) { - case 'value': - array = new Float32Array(data); - break; - case 'abs-value': - array = new Float32Array(data); - for (var i = 0; i < n; ++i) { - array[i] = Math.abs(array[i]); - } - break; - case 'value-min': { - array = new Float32Array(data); - var min = this.min; - for (var i$1 = 0; i$1 < n; ++i$1) { - array[i$1] -= min; - } - break; - } - case 'deviation': - array = new Float32Array(data); - break; - default: - array = uniformArray(n, size); - break; - } - if (scale$$1 !== 1.0) { - for (var i$2 = 0; i$2 < n; ++i$2) { - array[i$2] *= scale$$1; - } - } - return array; -}; -prototypeAccessors$b.min.get = function () { - if (this._min === undefined) { - this._min = arrayMin(this.data); - } - return this._min; -}; -prototypeAccessors$b.max.get = function () { - if (this._max === undefined) { - this._max = arrayMax(this.data); - } - return this._max; -}; -prototypeAccessors$b.sum.get = function () { - if (this._sum === undefined) { - this._sum = arraySum(this.data); - } - return this._sum; -}; -prototypeAccessors$b.mean.get = function () { - if (this._mean === undefined) { - this._mean = arrayMean(this.data); - } - return this._mean; -}; -prototypeAccessors$b.rms.get = function () { - if (this._rms === undefined) { - this._rms = arrayRms(this.data); - } - return this._rms; -}; -Volume.prototype.clone = function clone () { - var vol = new Volume(this.name, this.path, this.data, this.nx, this.ny, this.nz, this.atomindex); - vol.matrix.copy(this.matrix); - vol.header = Object.assign({}, this.header); - return vol; -}; -Volume.prototype.dispose = function dispose () { - if (this.workerPool) - { this.workerPool.terminate(); } -}; - -Object.defineProperties( Volume.prototype, prototypeAccessors$b ); - -ShaderRegistry.add('shader/Mesh.vert', "#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#elif defined( NOLIGHT )\nvarying vec3 vColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#elif defined( NOLIGHT )\nvColor = color;\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"); - -ShaderRegistry.add('shader/Mesh.frag', "#define STANDARD\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\n#elif defined( NOLIGHT )\nvarying vec3 vColor;\n#else\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#elif defined( NOLIGHT )\ngl_FragColor = vec4( vColor, opacity );\n#else\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\n#include interior_fragment\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#include opaque_back_fragment\n#endif\n}"); - -/** - * @file Buffer - * @author Alexander Rose - * @private - */ -function getThreeSide(side) { - if (side === 'front') { - return __WEBPACK_IMPORTED_MODULE_0_three__["r" /* FrontSide */]; - } - else if (side === 'back') { - return __WEBPACK_IMPORTED_MODULE_0_three__["c" /* BackSide */]; - } - else if (side === 'double') { - return __WEBPACK_IMPORTED_MODULE_0_three__["m" /* DoubleSide */]; - } - else { - return __WEBPACK_IMPORTED_MODULE_0_three__["m" /* DoubleSide */]; - } -} -var itemSize = { - 'f': 1, 'v2': 2, 'v3': 3, 'c': 3 -}; -function setObjectMatrix(object, matrix) { - object.matrix.copy(matrix); - object.matrix.decompose(object.position, object.quaternion, object.scale); - object.matrixWorldNeedsUpdate = true; -} -var BufferDefaultParameters = { - opaqueBack: false, - side: 'double', - opacity: 1.0, - depthWrite: true, - clipNear: 0, - clipRadius: 0, - clipCenter: new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - flatShaded: false, - wireframe: false, - roughness: 0.4, - metalness: 0.0, - diffuse: 0xffffff, - diffuseInterior: false, - useInteriorColor: false, - interiorColor: 0xdddddd, - interiorDarkening: 0, - forceTransparent: false, - matrix: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](), - disablePicking: false, - sortParticles: false, - background: false -}; -var BufferParameterTypes = { - opaqueBack: { updateShader: true }, - side: { updateShader: true, property: true }, - opacity: { uniform: true }, - depthWrite: { property: true }, - clipNear: { updateShader: true, property: true }, - clipRadius: { updateShader: true, uniform: true }, - clipCenter: { uniform: true }, - flatShaded: { updateShader: true }, - background: { updateShader: true }, - wireframe: { updateVisibility: true }, - roughness: { uniform: true }, - metalness: { uniform: true }, - diffuse: { uniform: true }, - diffuseInterior: { updateShader: true }, - useInteriorColor: { updateShader: true }, - interiorColor: { uniform: true }, - interiorDarkening: { uniform: true }, - matrix: {} -}; -/** - * Buffer class. Base class for buffers. - * @interface - */ -var Buffer = function Buffer(data, params) { - if ( params === void 0 ) params = {}; - - this.parameterTypes = BufferParameterTypes; - this.geometry = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */](); - this.indexVersion = 0; - this.wireframeIndexVersion = -1; - this.group = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.wireframeGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.pickingGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.vertexShader = ''; - this.fragmentShader = ''; - this.isImpostor = false; - this.isText = false; - this.isSurface = false; - this.isPoint = false; - this.isLine = false; - this.dynamic = true; - this.visible = true; - this.wireframeIndexCount = 0; - this.parameters = createParams(params, this.defaultParameters); - this.uniforms = __WEBPACK_IMPORTED_MODULE_0_three__["U" /* UniformsUtils */].merge([ - __WEBPACK_IMPORTED_MODULE_0_three__["T" /* UniformsLib */].common, - { - fogColor: { value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](0x000000) }, - fogNear: { value: 0.0 }, - fogFar: { value: 0.0 }, - opacity: { value: this.parameters.opacity }, - clipNear: { value: 0.0 }, - clipRadius: { value: this.parameters.clipRadius }, - clipCenter: { value: this.parameters.clipCenter } - }, - { - emissive: { value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](0x000000) }, - roughness: { value: this.parameters.roughness }, - metalness: { value: this.parameters.metalness }, - interiorColor: { value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.parameters.interiorColor) }, - interiorDarkening: { value: this.parameters.interiorDarkening }, - }, - __WEBPACK_IMPORTED_MODULE_0_three__["T" /* UniformsLib */].lights - ]); - this.uniforms.diffuse.value.set(this.parameters.diffuse); - this.pickingUniforms = { - clipNear: { value: 0.0 }, - objectId: { value: 0 }, - opacity: { value: this.parameters.opacity } - }; - // - var position = data.position || data.position1; - this._positionDataSize = position ? position.length / 3 : 0; - if (!data.primitiveId) { - data.primitiveId = serialArray(this._positionDataSize); - } - this.addAttributes({ - position: { type: 'v3', value: data.position }, - color: { type: 'c', value: data.color }, - primitiveId: { type: 'f', value: data.primitiveId } - }); - if (params.matrix) { - this.matrix = params.matrix; - } - if (data.index) { - this.initIndex(data.index); - } - this.picking = data.picking; - this.makeWireframeGeometry(); -}; - -var prototypeAccessors$c = { defaultParameters: { configurable: true },matrix: { configurable: true },transparent: { configurable: true },size: { configurable: true },attributeSize: { configurable: true },pickable: { configurable: true } }; -prototypeAccessors$c.defaultParameters.get = function () { return BufferDefaultParameters; }; -prototypeAccessors$c.matrix.set = function (m) { - this.setMatrix(m); -}; -prototypeAccessors$c.matrix.get = function () { - return this.group.matrix.clone(); -}; -prototypeAccessors$c.transparent.get = function () { - return this.parameters.opacity < 1 || this.parameters.forceTransparent; -}; -prototypeAccessors$c.size.get = function () { - return this._positionDataSize; -}; -prototypeAccessors$c.attributeSize.get = function () { - return this.size; -}; -prototypeAccessors$c.pickable.get = function () { - return !!this.picking && !this.parameters.disablePicking; -}; -Buffer.prototype.setMatrix = function setMatrix (m) { - setObjectMatrix(this.group, m); - setObjectMatrix(this.wireframeGroup, m); - setObjectMatrix(this.pickingGroup, m); -}; -Buffer.prototype.initIndex = function initIndex (index) { - this.geometry.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](index, 1)); - var nindex = this.geometry.getIndex(); - if (!nindex) { - Log.error('Index is null'); - return; - } - nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0); -}; -Buffer.prototype.makeMaterial = function makeMaterial () { - var side = getThreeSide(this.parameters.side); - var m = new __WEBPACK_IMPORTED_MODULE_0_three__["N" /* ShaderMaterial */]({ - uniforms: this.uniforms, - vertexShader: '', - fragmentShader: '', - depthTest: true, - transparent: this.transparent, - depthWrite: this.parameters.depthWrite, - lights: true, - fog: true, - side: side - }); - m.vertexColors = true; - m.extensions.derivatives = true; - m.extensions.fragDepth = this.isImpostor; - var wm = new __WEBPACK_IMPORTED_MODULE_0_three__["N" /* ShaderMaterial */]({ - uniforms: this.uniforms, - vertexShader: '', - fragmentShader: '', - depthTest: true, - transparent: this.transparent, - depthWrite: this.parameters.depthWrite, - lights: false, - fog: true, - side: side - }); - wm.vertexColors = true; - var pm = new __WEBPACK_IMPORTED_MODULE_0_three__["N" /* ShaderMaterial */]({ - uniforms: this.pickingUniforms, - vertexShader: '', - fragmentShader: '', - depthTest: true, - transparent: false, - depthWrite: this.parameters.depthWrite, - lights: false, - fog: false, - side: side, - blending: __WEBPACK_IMPORTED_MODULE_0_three__["B" /* NoBlending */] - }); - pm.vertexColors = true; - pm.extensions.fragDepth = this.isImpostor; - m.clipNear = this.parameters.clipNear; - wm.clipNear = this.parameters.clipNear; - pm.clipNear = this.parameters.clipNear; - this.material = m; - this.wireframeMaterial = wm; - this.pickingMaterial = pm; - // also sets vertexShader/fragmentShader - this.updateShader(); -}; -Buffer.prototype.makeWireframeGeometry = function makeWireframeGeometry () { - this.makeWireframeIndex(); - var geometry = this.geometry; - var wireframeIndex = this.wireframeIndex; - var wireframeGeometry = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */](); - wireframeGeometry.attributes = geometry.attributes; - if (wireframeIndex) { - wireframeGeometry.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)); - wireframeGeometry.setDrawRange(0, this.wireframeIndexCount); - } - this.wireframeGeometry = wireframeGeometry; -}; -Buffer.prototype.makeWireframeIndex = function makeWireframeIndex () { - var edges = []; - function checkEdge(a, b) { - if (a > b) { - var tmp = a; - a = b; - b = tmp; - } - var list = edges[a]; - if (list === undefined) { - edges[a] = [b]; - return true; - } - else if (!list.includes(b)) { - list.push(b); - return true; - } - return false; - } - var geometry = this.geometry; - var index = geometry.index; - if (!this.parameters.wireframe) { - this.wireframeIndex = new Uint16Array(0); - this.wireframeIndexCount = 0; - } - else if (index) { - var array = index.array; - var n = array.length; - if (geometry.drawRange.count !== Infinity) { - n = geometry.drawRange.count; - } - var wireframeIndex; - if (this.wireframeIndex && this.wireframeIndex.length > n * 2) { - wireframeIndex = this.wireframeIndex; - } - else { - var count = geometry.attributes.position.count; // TODO - wireframeIndex = getUintArray(n * 2, count); - } - var j = 0; - edges.length = 0; - for (var i = 0; i < n; i += 3) { - var a = array[i + 0]; - var b = array[i + 1]; - var c = array[i + 2]; - if (checkEdge(a, b)) { - wireframeIndex[j + 0] = a; - wireframeIndex[j + 1] = b; - j += 2; - } - if (checkEdge(b, c)) { - wireframeIndex[j + 0] = b; - wireframeIndex[j + 1] = c; - j += 2; - } - if (checkEdge(c, a)) { - wireframeIndex[j + 0] = c; - wireframeIndex[j + 1] = a; - j += 2; - } - } - this.wireframeIndex = wireframeIndex; - this.wireframeIndexCount = j; - this.wireframeIndexVersion = this.indexVersion; - } - else { - var n$1 = geometry.attributes.position.count; // TODO - var wireframeIndex$1; - if (this.wireframeIndex && this.wireframeIndex.length > n$1 * 2) { - wireframeIndex$1 = this.wireframeIndex; - } - else { - wireframeIndex$1 = getUintArray(n$1 * 2, n$1); - } - for (var i$1 = 0, j$1 = 0; i$1 < n$1; i$1 += 3) { - wireframeIndex$1[j$1 + 0] = i$1; - wireframeIndex$1[j$1 + 1] = i$1 + 1; - wireframeIndex$1[j$1 + 2] = i$1 + 1; - wireframeIndex$1[j$1 + 3] = i$1 + 2; - wireframeIndex$1[j$1 + 4] = i$1 + 2; - wireframeIndex$1[j$1 + 5] = i$1; - j$1 += 6; - } - this.wireframeIndex = wireframeIndex$1; - this.wireframeIndexCount = n$1 * 2; - this.wireframeIndexVersion = this.indexVersion; - } -}; -Buffer.prototype.updateWireframeIndex = function updateWireframeIndex () { - if (!this.wireframeGeometry || !this.wireframeIndex) - { return; } - this.wireframeGeometry.setDrawRange(0, Infinity); - if (this.wireframeIndexVersion < this.indexVersion) - { this.makeWireframeIndex(); } - if (this.wireframeGeometry.index && - this.wireframeIndex.length > this.wireframeGeometry.index.array.length) { - this.wireframeGeometry.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)); - } - else { - var index = this.wireframeGeometry.getIndex(); - if (!index) { - Log.error('Index is null'); - return; - } - index.set(this.wireframeIndex); - index.needsUpdate = this.wireframeIndexCount > 0; - index.updateRange.count = this.wireframeIndexCount; - } - this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount); -}; -Buffer.prototype.getRenderOrder = function getRenderOrder () { - var renderOrder = 0; - if (this.isText) { - renderOrder = 1; - } - else if (this.transparent) { - if (this.isSurface) { - renderOrder = 3; - } - else { - renderOrder = 2; - } - } - return renderOrder; -}; -Buffer.prototype._getMesh = function _getMesh (materialName) { - if (!this.material) - { this.makeMaterial(); } - var g = this.geometry; - var m = this[materialName]; - var mesh; - if (this.isLine) { - mesh = new __WEBPACK_IMPORTED_MODULE_0_three__["v" /* LineSegments */](g, m); - } - else if (this.isPoint) { - mesh = new __WEBPACK_IMPORTED_MODULE_0_three__["I" /* Points */](g, m); - } - else { - mesh = new __WEBPACK_IMPORTED_MODULE_0_three__["z" /* Mesh */](g, m); - } - mesh.frustumCulled = false; - mesh.renderOrder = this.getRenderOrder(); - return mesh; -}; -Buffer.prototype.getMesh = function getMesh () { - return this._getMesh('material'); -}; -Buffer.prototype.getWireframeMesh = function getWireframeMesh () { - var mesh; - if (!this.material) - { this.makeMaterial(); } - if (!this.wireframeGeometry) - { this.makeWireframeGeometry(); } - mesh = new __WEBPACK_IMPORTED_MODULE_0_three__["v" /* LineSegments */](this.wireframeGeometry, this.wireframeMaterial); - mesh.frustumCulled = false; - mesh.renderOrder = this.getRenderOrder(); - return mesh; -}; -Buffer.prototype.getPickingMesh = function getPickingMesh () { - return this._getMesh('pickingMaterial'); -}; -Buffer.prototype.getShader = function getShader$1 (name, type) { - return getShader(name, this.getDefines(type)); -}; -Buffer.prototype.getVertexShader = function getVertexShader (type) { - return this.getShader(this.vertexShader, type); -}; -Buffer.prototype.getFragmentShader = function getFragmentShader (type) { - return this.getShader(this.fragmentShader, type); -}; -Buffer.prototype.getDefines = function getDefines (type) { - var defines = {}; - if (this.parameters.clipNear) { - defines.NEAR_CLIP = 1; - } - if (this.parameters.clipRadius) { - defines.RADIUS_CLIP = 1; - } - if (type === 'picking') { - defines.PICKING = 1; - } - else { - if (type === 'background' || this.parameters.background) { - defines.NOLIGHT = 1; - } - if (this.parameters.flatShaded) { - defines.FLAT_SHADED = 1; - } - if (this.parameters.opaqueBack) { - defines.OPAQUE_BACK = 1; - } - if (this.parameters.diffuseInterior) { - defines.DIFFUSE_INTERIOR = 1; - } - if (this.parameters.useInteriorColor) { - defines.USE_INTERIOR_COLOR = 1; - } - } - return defines; -}; -Buffer.prototype.getParameters = function getParameters () { - return this.parameters; -}; -Buffer.prototype.addUniforms = function addUniforms (uniforms) { - this.uniforms = __WEBPACK_IMPORTED_MODULE_0_three__["U" /* UniformsUtils */].merge([this.uniforms, uniforms]); - this.pickingUniforms = __WEBPACK_IMPORTED_MODULE_0_three__["U" /* UniformsUtils */].merge([this.pickingUniforms, uniforms]); -}; -Buffer.prototype.addAttributes = function addAttributes (attributes) { - for (var name in attributes) { - var buf = (void 0); - var a = attributes[name]; - var arraySize = this.attributeSize * itemSize[a.type]; - if (a.value) { - if (arraySize !== a.value.length) { - Log.error('attribute value has wrong length', name); - } - buf = a.value; - } - else { - buf = getTypedArray('float32', arraySize); - } - this.geometry.setAttribute(name, new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](buf, itemSize[a.type]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)); - } -}; -Buffer.prototype.updateRenderOrder = function updateRenderOrder () { - var renderOrder = this.getRenderOrder(); - function setRenderOrder(mesh) { - mesh.renderOrder = renderOrder; - } - this.group.children.forEach(setRenderOrder); - if (this.pickingGroup) { - this.pickingGroup.children.forEach(setRenderOrder); - } -}; -Buffer.prototype.updateShader = function updateShader () { - var m = this.material; - var wm = this.wireframeMaterial; - var pm = this.pickingMaterial; - m.vertexShader = this.getVertexShader(); - m.fragmentShader = this.getFragmentShader(); - m.needsUpdate = true; - wm.vertexShader = this.getShader('Line.vert'); - wm.fragmentShader = this.getShader('Line.frag'); - wm.needsUpdate = true; - pm.vertexShader = this.getVertexShader('picking'); - pm.fragmentShader = this.getFragmentShader('picking'); - pm.needsUpdate = true; -}; -/** - * Set buffer parameters - * @param {BufferParameters} params - buffer parameters object - * @return {undefined} - */ -Buffer.prototype.setParameters = function setParameters (params) { - var p = params; - var pt = this.parameterTypes; - var pv = this.parameters; - var propertyData = {}; - var uniformData = {}; - var doShaderUpdate = false; - var doVisibilityUpdate = false; - for (var name in p) { - var value = p[name]; - if (value === undefined) - { continue; } - pv[name] = value; - if (pt[name] === undefined) - { continue; } - if (pt[name].property) { - if (pt[name].property !== true) { - propertyData[pt[name].property] = value; - } - else { - propertyData[name] = value; - } - } - if (pt[name].uniform) { - if (pt[name].uniform !== true) { - uniformData[pt[name].uniform] = value; - } - else { - uniformData[name] = value; - } - } - if (pt[name].updateShader) { - doShaderUpdate = true; - } - if (pt[name].updateVisibility) { - doVisibilityUpdate = true; - } - if (this.dynamic && name === 'wireframe' && value === true) { - this.updateWireframeIndex(); - } - if (name === 'forceTransparent') { - propertyData.transparent = this.transparent; - } - if (name === 'matrix') { - this.matrix = value; - } - } - this.setProperties(propertyData); - this.setUniforms(uniformData); - if (doShaderUpdate) - { this.updateShader(); } - if (doVisibilityUpdate) - { this.setVisibility(this.visible); } -}; -/** - * Sets buffer attributes - * @param {Object} data - An object where the keys are the attribute names - * and the values are the attribute data. - * @example - * var buffer = new Buffer(); - * buffer.setAttributes({ attrName: attrData }); - */ -Buffer.prototype.setAttributes = function setAttributes (data) { - var geometry = this.geometry; - var attributes = geometry.attributes; // TODO - for (var name in data) { - if (name === 'picking') - { continue; } - var array = data[name]; - var length = array.length; - if (name === 'index') { - var index = geometry.getIndex(); - if (!index) { - Log.error('Index is null'); - continue; - } - geometry.setDrawRange(0, Infinity); - if (length > index.array.length) { - geometry.setIndex(new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](array, 1) - .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)); - } - else { - index.set(array); - index.needsUpdate = length > 0; - index.updateRange.count = length; - geometry.setDrawRange(0, length); - } - this.indexVersion++; - if (this.parameters.wireframe) - { this.updateWireframeIndex(); } - } - else { - var attribute = attributes[name]; - if (length > attribute.array.length) { - geometry.setAttribute(name, new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](array, attribute.itemSize) - .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)); - } - else { - attributes[name].set(array); - attributes[name].needsUpdate = length > 0; - attributes[name].updateRange.count = length; - } - } - } -}; -Buffer.prototype.setUniforms = function setUniforms (data) { - if (!data) - { return; } - var u = this.material.uniforms; - var wu = this.wireframeMaterial.uniforms; - var pu = this.pickingMaterial.uniforms; - for (var name in data) { - if (name === 'opacity') { - this.setProperties({ transparent: this.transparent }); - } - if (u[name] !== undefined) { - if (u[name].value.isVector3) { - u[name].value.copy(data[name]); - } - else if (u[name].value.set) { - u[name].value.set(data[name]); - } - else { - u[name].value = data[name]; - } - } - if (wu[name] !== undefined) { - if (wu[name].value.isVector3) { - wu[name].value.copy(data[name]); - } - else if (wu[name].value.set) { - wu[name].value.set(data[name]); - } - else { - wu[name].value = data[name]; - } - } - if (pu[name] !== undefined) { - if (pu[name].value.isVector3) { - pu[name].value.copy(data[name]); - } - else if (pu[name].value.set) { - pu[name].value.set(data[name]); - } - else { - pu[name].value = data[name]; - } - } - } -}; -Buffer.prototype.setProperties = function setProperties (data) { - if (!data) - { return; } - var m = this.material; - var wm = this.wireframeMaterial; - var pm = this.pickingMaterial; - for (var _name in data) { - var name = _name; // TODO - var value = data[name]; - if (name === 'transparent') { - this.updateRenderOrder(); - } - else if (name === 'side') { - value = getThreeSide(value); - } - m[name] = value; - wm[name] = value; - pm[name] = value; - } - m.needsUpdate = true; - wm.needsUpdate = true; - pm.needsUpdate = true; -}; -/** - * Set buffer visibility - * @param {Boolean} value - visibility value - * @return {undefined} - */ -Buffer.prototype.setVisibility = function setVisibility (value) { - this.visible = value; - if (this.parameters.wireframe) { - this.group.visible = false; - this.wireframeGroup.visible = value; - if (this.pickable) { - this.pickingGroup.visible = false; - } - } - else { - this.group.visible = value; - this.wireframeGroup.visible = false; - if (this.pickable) { - this.pickingGroup.visible = value; - } - } -}; -/** - * Free buffer resources - * @return {undefined} - */ -Buffer.prototype.dispose = function dispose () { - if (this.material) - { this.material.dispose(); } - if (this.wireframeMaterial) - { this.wireframeMaterial.dispose(); } - if (this.pickingMaterial) - { this.pickingMaterial.dispose(); } - this.geometry.dispose(); - if (this.wireframeGeometry) - { this.wireframeGeometry.dispose(); } -}; -/** - * Customize JSON serialization to avoid circular references - */ -Buffer.prototype.toJSON = function toJSON () { - var result = {}; - for (var x in this) { - if (x !== "group" && x !== "wireframeGroup" && x != "pickingGroup" - && x !== "picking") { - result[x] = this[x]; - } - } - return result; -}; - -Object.defineProperties( Buffer.prototype, prototypeAccessors$c ); - -/** - * @file Mesh Buffer - * @author Alexander Rose - * @private - */ -/** - * Mesh buffer. Draws a triangle mesh. - * - * @example - * var meshBuffer = new MeshBuffer({ - * position: new Float32Array( - * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ] - * ), - * color: new Float32Array( - * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ] - * ) - * }); - */ -var MeshBuffer = /*@__PURE__*/(function (Buffer$$1) { - function MeshBuffer(data, params) { - if ( params === void 0 ) params = {}; - - Buffer$$1.call(this, data, params); - this.vertexShader = 'Mesh.vert'; - this.fragmentShader = 'Mesh.frag'; - this.addAttributes({ - 'normal': { type: 'v3', value: data.normal } - }); - if (data.normal === undefined) { - this.geometry.computeVertexNormals(); - } - } - - if ( Buffer$$1 ) MeshBuffer.__proto__ = Buffer$$1; - MeshBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - MeshBuffer.prototype.constructor = MeshBuffer; - - return MeshBuffer; -}(Buffer)); - -/** - * @file Surface Buffer - * @author Alexander Rose - * @private - */ -/** - * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`. - */ -var SurfaceBuffer = /*@__PURE__*/(function (MeshBuffer$$1) { - function SurfaceBuffer() { - MeshBuffer$$1.apply(this, arguments); - this.isSurface = true; - } - - if ( MeshBuffer$$1 ) SurfaceBuffer.__proto__ = MeshBuffer$$1; - SurfaceBuffer.prototype = Object.create( MeshBuffer$$1 && MeshBuffer$$1.prototype ); - SurfaceBuffer.prototype.constructor = SurfaceBuffer; - - return SurfaceBuffer; -}(MeshBuffer)); - -/** - * @file Double Sided Buffer - * @author Alexander Rose - * @private - */ -function setVisibilityTrue(m) { m.visible = true; } -function setVisibilityFalse(m) { m.visible = false; } -/** - * A double-sided mesh buffer. Takes a buffer and renders the front and - * the back as seperate objects to avoid some artifacts when rendering - * transparent meshes. Also allows to render the back of a mesh opaque - * while the front is transparent. - * @implements {Buffer} - * - * @example - * var sphereGeometryBuffer = new SphereGeometryBuffer({ - * position: new Float32Array([ 0, 0, 0 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer); - */ -var DoubleSidedBuffer = function DoubleSidedBuffer(buffer) { - this.group = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.wireframeGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.pickingGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.frontMeshes = []; - this.backMeshes = []; - this.size = buffer.size; - this.side = buffer.parameters.side; - this.visible = buffer.visible; - this.geometry = buffer.geometry; - this.picking = buffer.picking; - this.group = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.wireframeGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.pickingGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - // requires Group objects to be present - this.matrix = buffer.matrix; - var frontBuffer = buffer; - var backBuffer = new buffer.constructor({ - position: new Float32Array(0) - }); - frontBuffer.makeMaterial(); - backBuffer.makeMaterial(); - backBuffer.picking = buffer.picking; - backBuffer.geometry = buffer.geometry; - backBuffer.wireframeGeometry = buffer.wireframeGeometry; - backBuffer.setParameters(buffer.getParameters()); - backBuffer.updateShader(); - frontBuffer.setParameters({ - side: 'front' - }); - backBuffer.setParameters({ - side: 'back', - opacity: backBuffer.parameters.opacity - }); - this.buffer = buffer; - this.frontBuffer = frontBuffer; - this.backBuffer = backBuffer; -}; - -var prototypeAccessors$d = { matrix: { configurable: true },pickable: { configurable: true },parameters: { configurable: true } }; -prototypeAccessors$d.matrix.set = function (m) { - Buffer.prototype.setMatrix.call(this, m); -}; -prototypeAccessors$d.matrix.get = function () { - return this.group.matrix.clone(); -}; -prototypeAccessors$d.pickable.get = function () { - return !!this.picking && !this.parameters.disablePicking; -}; -prototypeAccessors$d.parameters.get = function () { - return this.buffer.parameters; -}; -DoubleSidedBuffer.prototype.getParameters = function getParameters () { - var p = Object.assign({}, this.buffer.parameters); - p.side = this.side; - return p; -}; -DoubleSidedBuffer.prototype.getMesh = function getMesh (picking) { - var front, back; - if (picking) { - back = this.backBuffer.getPickingMesh(); - front = this.frontBuffer.getPickingMesh(); - } - else { - back = this.backBuffer.getMesh(); - front = this.frontBuffer.getMesh(); - } - this.frontMeshes.push(front); - this.backMeshes.push(back); - this.setParameters({ side: this.side }); - return new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]().add(back, front); -}; -DoubleSidedBuffer.prototype.getWireframeMesh = function getWireframeMesh () { - return this.buffer.getWireframeMesh(); -}; -DoubleSidedBuffer.prototype.getPickingMesh = function getPickingMesh () { - return this.getMesh(true); -}; -DoubleSidedBuffer.prototype.setAttributes = function setAttributes (data) { - this.buffer.setAttributes(data); -}; -DoubleSidedBuffer.prototype.setParameters = function setParameters (data) { - data = Object.assign({}, data); - if (data.side === 'front') { - this.frontMeshes.forEach(setVisibilityTrue); - this.backMeshes.forEach(setVisibilityFalse); - } - else if (data.side === 'back') { - this.frontMeshes.forEach(setVisibilityFalse); - this.backMeshes.forEach(setVisibilityTrue); - } - else if (data.side === 'double') { - this.frontMeshes.forEach(setVisibilityTrue); - this.backMeshes.forEach(setVisibilityTrue); - } - if (data.side !== undefined) { - this.side = data.side; - } - delete data.side; - if (data.matrix !== undefined) { - this.matrix = data.matrix; - } - delete data.matrix; - this.frontBuffer.setParameters(data); - if (data.wireframe !== undefined) { - this.wireframe = data.wireframe; - this.setVisibility(this.visible); - } - delete data.wireframe; - this.backBuffer.setParameters(data); -}; -DoubleSidedBuffer.prototype.setVisibility = function setVisibility (value) { - this.visible = value; - if (this.parameters.wireframe) { - this.group.visible = false; - this.wireframeGroup.visible = value; - if (this.pickable) { - this.pickingGroup.visible = false; - } - } - else { - this.group.visible = value; - this.wireframeGroup.visible = false; - if (this.pickable) { - this.pickingGroup.visible = value; - } - } -}; -DoubleSidedBuffer.prototype.dispose = function dispose () { - this.frontBuffer.dispose(); - this.backBuffer.dispose(); -}; -/** - * Customize JSON serialization to avoid circular references. - * Only export simple params which could be useful. - */ -DoubleSidedBuffer.prototype.toJSON = function toJSON () { - var result = {}; - for (var x in this) { - if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) { - result[x] = this[x]; - } - } - return result; -}; - -Object.defineProperties( DoubleSidedBuffer.prototype, prototypeAccessors$d ); - -ShaderRegistry.add('shader/Line.vert', "uniform float clipNear;\nuniform vec3 clipCenter;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include color_pars_vertex\nvoid main(){\n#include color_vertex\n#include begin_vertex\n#include project_vertex\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"); - -ShaderRegistry.add('shader/Line.frag', "uniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\ngl_FragColor = vec4( vColor, opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}"); - -/** - * @file Contour Buffer - * @author Fred ludlow - * @private - */ -/** - * Contour buffer. A buffer that draws lines (instead of triangle meshes). - */ -var ContourBuffer = /*@__PURE__*/(function (Buffer$$1) { - function ContourBuffer() { - Buffer$$1.apply(this, arguments); - this.isLine = true; - this.vertexShader = 'Line.vert'; - this.fragmentShader = 'Line.frag'; - } - - if ( Buffer$$1 ) ContourBuffer.__proto__ = Buffer$$1; - ContourBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - ContourBuffer.prototype.constructor = ContourBuffer; - - return ContourBuffer; -}(Buffer)); - -/** - * @file Surface Representation - * @author Alexander Rose - * @private - */ -/** - * Surface representation - */ -/** - * Create Surface representation object - * @param {Surface|Volume} surface - the surface or volume to be represented - * @param {Viewer} viewer - a viewer object - * @param {SurfaceRepresentationParameters} params - surface representation parameters - */ -var SurfaceRepresentation = /*@__PURE__*/(function (Representation$$1) { - function SurfaceRepresentation(surface, viewer, params) { - Representation$$1.call(this, surface, viewer, params); - this.type = 'surface'; - this.parameters = Object.assign({ - isolevelType: { - type: 'select', - options: { - 'value': 'value', 'sigma': 'sigma' - } - }, - isolevel: { - type: 'number', precision: 2, max: 1000, min: -1000 - }, - negateIsolevel: { - type: 'boolean' - }, - isolevelScroll: { - type: 'boolean' - }, - smooth: { - type: 'integer', precision: 1, max: 10, min: 0 - }, - background: { - type: 'boolean', rebuild: true // FIXME - }, - opaqueBack: { - type: 'boolean', buffer: true - }, - boxSize: { - type: 'integer', precision: 1, max: 100, min: 0 - }, - colorVolume: { - type: 'hidden' - }, - contour: { - type: 'boolean', rebuild: true - }, - useWorker: { - type: 'boolean', rebuild: true - }, - wrap: { - type: 'boolean', rebuild: true - } - }, this.parameters); - if (surface instanceof Volume) { - this.surface = undefined; - this.volume = surface; - } - else { - this.surface = surface; - this.volume = undefined; - } - this.boxCenter = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.__boxCenter = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.box = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this.__box = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this._position = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.inverseMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.setBox = function setBox() { - this._position.copy(viewer.translationGroup.position).negate(); - this._position.applyMatrix4(this.inverseMatrix); - if (!this._position.equals(this.boxCenter)) { - this.setParameters({ 'boxCenter': this._position }); - } - }; - this.toBePrepared = true; - this.viewer.signals.ticked.add(this.setBox, this); - this.init(params); - } - - if ( Representation$$1 ) SurfaceRepresentation.__proto__ = Representation$$1; - SurfaceRepresentation.prototype = Object.create( Representation$$1 && Representation$$1.prototype ); - SurfaceRepresentation.prototype.constructor = SurfaceRepresentation; - SurfaceRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'uniform'); - p.colorValue = defaults(p.colorValue, 0xDDDDDD); - this.isolevelType = defaults(p.isolevelType, 'sigma'); - this.isolevel = defaults(p.isolevel, 2.0); - this.negateIsolevel = defaults(p.negateIsolevel, false); - this.isolevelScroll = defaults(p.isolevelScroll, false); - this.smooth = defaults(p.smooth, 0); - this.background = defaults(p.background, false); - this.opaqueBack = defaults(p.opaqueBack, true); - this.boxSize = defaults(p.boxSize, 0); - this.colorVolume = defaults(p.colorVolume, undefined); - this.contour = defaults(p.contour, false); - this.useWorker = defaults(p.useWorker, true); - this.wrap = defaults(p.wrap, false); - Representation$$1.prototype.init.call(this, p); - this.inverseMatrix.getInverse(this.matrix); - this.build(); - }; - SurfaceRepresentation.prototype.attach = function attach (callback) { - var this$1 = this; - - this.bufferList.forEach(function (buffer) { - this$1.viewer.add(buffer); - }); - this.setVisibility(this.visible); - callback(); - }; - SurfaceRepresentation.prototype.prepare = function prepare (callback) { - var this$1 = this; - - if (this.volume) { - var isolevel; - if (this.isolevelType === 'sigma') { - isolevel = this.volume.getValueForSigma(this.isolevel); - } - else { - isolevel = this.isolevel; - } - if (this.negateIsolevel) - { isolevel *= -1; } - if (!this.surface || - this.__isolevel !== isolevel || - this.__smooth !== this.smooth || - this.__contour !== this.contour || - this.__wrap !== this.wrap || - this.__boxSize !== this.boxSize || - (this.boxSize > 0 && - !this.__boxCenter.equals(this.boxCenter))) { - this.__isolevel = isolevel; - this.__smooth = this.smooth; - this.__contour = this.contour; - this.__wrap = this.wrap; - this.__boxSize = this.boxSize; - this.__boxCenter.copy(this.boxCenter); - this.__box.copy(this.box); - var onSurfaceFinish = function (surface) { - this$1.surface = surface; - callback(); - }; - if (this.useWorker) { - this.volume.getSurfaceWorker(isolevel, this.smooth, this.boxCenter, this.boxSize, this.contour, this.wrap, onSurfaceFinish); - } - else { - onSurfaceFinish(this.volume.getSurface(isolevel, this.smooth, this.boxCenter, this.boxSize, this.contour, this.wrap)); - } - } - else { - callback(); - } - } - else { - callback(); - } - }; - SurfaceRepresentation.prototype.create = function create () { - var sd = { - position: this.surface.getPosition(), - color: this.surface.getColor(this.getColorParams()), - index: this.surface.getIndex() - }; - var buffer; - if (this.contour) { - buffer = new ContourBuffer(sd, this.getBufferParams({ wireframe: false })); - } - else { - Object.assign(sd, { - normal: this.surface.getNormal(), - picking: this.surface.getPicking() - }); - var surfaceBuffer = new SurfaceBuffer(sd, this.getBufferParams({ - background: this.background, - opaqueBack: this.opaqueBack, - dullInterior: false - })); - buffer = new DoubleSidedBuffer(surfaceBuffer); - } - this.bufferList.push(buffer); - }; - SurfaceRepresentation.prototype.update = function update (what) { - if (this.bufferList.length === 0) - { return; } - what = what || {}; - var surfaceData = {}; - if (what.position) { - surfaceData.position = this.surface.getPosition(); - } - if (what.color) { - surfaceData.color = this.surface.getColor(this.getColorParams()); - } - if (what.index) { - surfaceData.index = this.surface.getIndex(); - } - if (what.normal) { - surfaceData.normal = this.surface.getNormal(); - } - this.bufferList.forEach(function (buffer) { - buffer.setAttributes(surfaceData); - }); - }; - /** - * Set representation parameters - * @alias SurfaceRepresentation#setParameters - * @param {SurfaceRepresentationParameters} params - surface parameter object - * @param {Object} [what] - buffer data attributes to be updated, - * note that this needs to be implemented in the - * derived classes. Generally it allows more - * fine-grained control over updating than - * forcing a rebuild. - * @param {Boolean} what.position - update position data - * @param {Boolean} what.color - update color data - * @param {Boolean} [rebuild] - whether or not to rebuild the representation - * @return {SurfaceRepresentation} this object - */ - SurfaceRepresentation.prototype.setParameters = function setParameters (params, what, rebuild) { - if (params && params.isolevelType !== undefined && - this.volume) { - if (this.isolevelType === 'value' && - params.isolevelType === 'sigma') { - this.isolevel = this.volume.getSigmaForValue(this.isolevel); - } - else if (this.isolevelType === 'sigma' && - params.isolevelType === 'value') { - this.isolevel = this.volume.getValueForSigma(this.isolevel); - } - this.isolevelType = params.isolevelType; - } - if (params && params.boxCenter) { - this.boxCenter.copy(params.boxCenter); - delete params.boxCenter; - } - // Forbid wireframe && contour as in molsurface - if (params && params.wireframe && (params.contour || (params.contour === undefined && this.contour))) { - params.wireframe = false; - } - Representation$$1.prototype.setParameters.call(this, params, what, rebuild); - if (params.matrix) { - this.inverseMatrix.getInverse(params.matrix); - } - if (this.volume) { - this.volume.getBox(this.boxCenter, this.boxSize, this.box); - } - if (params && params.colorVolume !== undefined) { - if (what) - { what.color = true; } - } - if (this.surface && (params.isolevel !== undefined || - params.negateIsolevel !== undefined || - params.smooth !== undefined || - params.wrap !== undefined || - params.boxSize !== undefined || - (this.boxSize > 0 && - !this.__box.equals(this.box)))) { - this.build({ - 'position': true, - 'color': true, - 'index': true, - 'normal': !this.contour - }); - } - return this; - }; - SurfaceRepresentation.prototype.getColorParams = function getColorParams () { - var p = Representation$$1.prototype.getColorParams.call(this); - p.volume = this.colorVolume; - return p; - }; - SurfaceRepresentation.prototype.dispose = function dispose () { - this.viewer.signals.ticked.remove(this.setBox, this); - Representation$$1.prototype.dispose.call(this); - }; - - return SurfaceRepresentation; -}(Representation)); - -/** - * @file Mouse Actions - * @author Alexander Rose - * @private - */ -/** - * Mouse actions provided as static methods - */ -var MouseActions = function MouseActions () {}; - -MouseActions.zoomScroll = function zoomScroll (stage, delta) { - stage.trackballControls.zoom(delta); -}; -/** - * Move near clipping plane based on scroll-delta - * @param {Stage} stage - the stage - * @param {Number} delta - amount to move clipping plane - * @return {undefined} - */ -MouseActions.clipNearScroll = function clipNearScroll (stage, delta) { - var sp = stage.getParameters(); - stage.setParameters({ clipNear: sp.clipNear + delta / 10 }); -}; -/** - * Move clipping planes based on scroll-delta. - * @param {Stage} stage - the stage - * @param {Number} delta - direction to move planes - * @return {undefined} - */ -MouseActions.focusScroll = function focusScroll (stage, delta) { - var focus = stage.getFocus(); - var sign = Math.sign(delta); - var step = sign * almostIdentity((100 - focus) / 10, 5, 0.2); - stage.setFocus(focus + step); -}; -/** - * Zoom scene based on scroll-delta and - * move focus planes based on camera position (zoom) - * @param {Stage} stage - the stage - * @param {Number} delta - amount to move focus planes and zoom - * @return {undefined} - */ -MouseActions.zoomFocusScroll = function zoomFocusScroll (stage, delta) { - stage.trackballControls.zoom(delta); - var z = stage.viewer.camera.position.z; - stage.setFocus(100 - Math.abs(z / 8)); -}; -/** - * Change isolevel of volume surfaces based on scroll-delta - * @param {Stage} stage - the stage - * @param {Number} delta - amount to change isolevel - * @return {undefined} - */ -MouseActions.isolevelScroll = function isolevelScroll (stage, delta) { - var d = Math.sign(delta) / 10; - stage.eachRepresentation(function (reprElem, comp) { - if (reprElem.repr instanceof SurfaceRepresentation) { - var p = reprElem.getParameters(); // TODO - if (p.isolevelScroll) { - reprElem.setParameters({ isolevel: p.isolevel + d }); - } - } - }); -}; -/** - * Pan scene based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to pan in x direction - * @param {Number} dy - amount to pan in y direction - * @return {undefined} - */ -MouseActions.panDrag = function panDrag (stage, dx, dy) { - stage.trackballControls.pan(dx, dy); -}; -/** - * Rotate scene based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to rotate in x direction - * @param {Number} dy - amount to rotate in y direction - * @return {undefined} - */ -MouseActions.rotateDrag = function rotateDrag (stage, dx, dy) { - stage.trackballControls.rotate(dx, dy); -}; -/** - * Rotate scene around z axis based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to rotate in x direction - * @param {Number} dy - amount to rotate in y direction - * @return {undefined} - */ -MouseActions.zRotateDrag = function zRotateDrag (stage, dx, dy) { - stage.trackballControls.zRotate(dx, dy); -}; -/** - * Zoom scene based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to zoom - * @param {Number} dy - amount to zoom - * @return {undefined} - */ -MouseActions.zoomDrag = function zoomDrag (stage, dx, dy) { - stage.trackballControls.zoom((dx + dy) / -2); -}; -/** - * Zoom scene based on mouse coordinate changes and - * move focus planes based on camera position (zoom) - * @param {Stage} stage - the stage - * @param {Number} dx - amount to zoom and focus - * @param {Number} dy - amount to zoom and focus - * @return {undefined} - */ -MouseActions.zoomFocusDrag = function zoomFocusDrag (stage, dx, dy) { - stage.trackballControls.zoom((dx + dy) / -2); - var z = stage.viewer.camera.position.z; - stage.setFocus(100 - Math.abs(z / 8)); -}; -/** - * Pan picked component based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to pan in x direction - * @param {Number} dy - amount to pan in y direction - * @return {undefined} - */ -MouseActions.panComponentDrag = function panComponentDrag (stage, dx, dy) { - stage.trackballControls.panComponent(dx, dy); -}; -/** - * Pan picked atom based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to pan in x direction - * @param {Number} dy - amount to pan in y direction - * @return {undefined} - */ -MouseActions.panAtomDrag = function panAtomDrag (stage, dx, dy) { - stage.trackballControls.panAtom(dx, dy); -}; -/** - * Rotate picked component based on mouse coordinate changes - * @param {Stage} stage - the stage - * @param {Number} dx - amount to rotate in x direction - * @param {Number} dy - amount to rotate in y direction - * @return {undefined} - */ -MouseActions.rotateComponentDrag = function rotateComponentDrag (stage, dx, dy) { - stage.trackballControls.rotateComponent(dx, dy); -}; -/** - * Move picked element to the center of the screen - * @param {Stage} stage - the stage - * @param {PickingProxy} pickingProxy - the picking data object - * @return {undefined} - */ -MouseActions.movePick = function movePick (stage, pickingProxy) { - if (pickingProxy) { - stage.animationControls.move(pickingProxy.position.clone()); - } -}; -/** - * Show tooltip with information of picked element - * @param {Stage} stage - the stage - * @param {PickingProxy} pickingProxy - the picking data object - * @return {undefined} - */ -MouseActions.tooltipPick = function tooltipPick (stage, pickingProxy) { - var tt = stage.tooltip; - var sp = stage.getParameters(); - if (sp.tooltip && pickingProxy) { - var mp = pickingProxy.mouse.position; - tt.innerText = pickingProxy.getLabel(); - tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'; - tt.style.left = (mp.x + 3) + 'px'; - tt.style.display = 'block'; - } - else { - tt.style.display = 'none'; - } -}; -MouseActions.measurePick = function measurePick (stage, pickingProxy) { - if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) { - var atom = pickingProxy.atom || pickingProxy.closestBondAtom; - var sc = pickingProxy.component; - sc.measurePick(atom); - } - else { - stage.measureClear(); - } -}; -var MouseActionPresets = { - default: [ - ['scroll', MouseActions.zoomScroll], - ['scroll-shift', MouseActions.focusScroll], - ['scroll-ctrl', MouseActions.isolevelScroll], - ['scroll-shift-ctrl', MouseActions.zoomFocusScroll], - ['drag-left', MouseActions.rotateDrag], - ['drag-right', MouseActions.panDrag], - ['drag-ctrl-left', MouseActions.panDrag], - ['drag-ctrl-right', MouseActions.zRotateDrag], - ['drag-shift-left', MouseActions.zoomDrag], - ['drag-middle', MouseActions.zoomFocusDrag], - ['drag-ctrl-shift-right', MouseActions.panComponentDrag], - ['drag-ctrl-shift-left', MouseActions.rotateComponentDrag], - ['clickPick-right', MouseActions.measurePick], - ['clickPick-ctrl-left', MouseActions.measurePick], - ['clickPick-middle', MouseActions.movePick], - ['clickPick-left', MouseActions.movePick], - ['hoverPick', MouseActions.tooltipPick] - ], - pymol: [ - ['drag-left', MouseActions.rotateDrag], - ['drag-middle', MouseActions.panDrag], - ['drag-right', MouseActions.zoomDrag], - ['drag-shift-right', MouseActions.focusScroll], - ['clickPick-ctrl+shift-middle', MouseActions.movePick], - ['hoverPick', MouseActions.tooltipPick] - ], - coot: [ - ['scroll', MouseActions.isolevelScroll], - ['drag-left', MouseActions.rotateDrag], - ['drag-middle', MouseActions.panDrag], - ['drag-ctrl-left', MouseActions.panDrag], - ['drag-right', MouseActions.zoomFocusDrag], - ['drag-ctrl-right', MouseActions.focusScroll], - ['clickPick-middle', MouseActions.movePick], - ['hoverPick', MouseActions.tooltipPick] - ], - astexviewer: [ - ['drag-left', MouseActions.rotateDrag], - ['drag-ctrl-left', MouseActions.panDrag], - ['drag-shift-left', MouseActions.zoomDrag], - ['scroll', MouseActions.focusScroll], - ['clickPick-middle', MouseActions.movePick], - ['hoverPick', MouseActions.tooltipPick] - ] -}; - -/** - * @file Mouse Controls - * @author Alexander Rose - * @private - */ -/** - * Strings to describe mouse events (including optional keyboard modifiers). - * Must contain an event type: "scroll", "drag", "click", "doubleClick", - * "hover", "clickPick" or "hoverPick". Optionally contain one or more - * (seperated by plus signs) keyboard modifiers: "alt", "ctrl", "meta" or - * "shift". Can contain the mouse button performing the event: "left", - * "middle" or "right". The type, key and button parts must be seperated by - * dashes. - * - * @example - * // triggered on scroll event (no key or button) - * "scroll" - * - * @example - * // triggered on scroll event while shift key is pressed - * "scroll-shift" - * - * @example - * // triggered on drag event with left mouse button - * "drag-left" - * - * @example - * // triggered on drag event with right mouse button - * // while ctrl and shift keys are pressed - * "drag-right-ctrl+shift" - * - * @typedef {String} TriggerString - */ -/** - * Get event type, key and button - * @param {TriggerString} str - input trigger string - * @return {Array} event type, key and button - */ -function triggerFromString(str) { - var tokens = str.split(/[-+]/); - var type = ''; - if (tokens.includes('scroll')) - { type = 'scroll'; } - if (tokens.includes('drag')) - { type = 'drag'; } - if (tokens.includes('click')) - { type = 'click'; } - if (tokens.includes('doubleClick')) - { type = 'doubleClick'; } - if (tokens.includes('hover')) - { type = 'hover'; } - if (tokens.includes('clickPick')) - { type = 'clickPick'; } - if (tokens.includes('hoverPick')) - { type = 'hoverPick'; } - var key = 0; - if (tokens.includes('alt')) - { key += 1; } - if (tokens.includes('ctrl')) - { key += 2; } - if (tokens.includes('meta')) - { key += 4; } - if (tokens.includes('shift')) - { key += 8; } - var button = 0; - if (tokens.includes('left')) - { button += 1; } - if (tokens.includes('right')) - { button += 2; } - if (tokens.includes('middle')) - { button += 4; } - return [type, key, button]; -} -/** - * Mouse controls - */ -var MouseControls = function MouseControls(stage, params) { - if ( params === void 0 ) params = {}; - - this.stage = stage; - this.actionList = []; - this.mouse = stage.mouseObserver; - this.disabled = params.disabled || false; - this.preset(params.preset || 'default'); -}; -MouseControls.prototype.run = function run (type) { - var this$1 = this; - var args = [], len = arguments.length - 1; - while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - if (this.disabled) - { return; } - var key = this.mouse.key || 0; - var button = this.mouse.buttons || 0; - this.actionList.forEach(function (a) { - if (a.type === type && a.key === key && a.button === button) { - a.callback.apply(a, [ this$1.stage ].concat( args )); // TODO - } - }); -}; -/** - * Add a new mouse action triggered by an event, key and button combination. - * The {@link MouseActions} class provides a number of static methods for - * use as callback functions. - * - * @example - * // change ambient light intensity on mouse scroll - * // while the ctrl and shift keys are pressed - * stage.mouseControls.add( "scroll-ctrl+shift", function( stage, delta ){ - * var ai = stage.getParameters().ambientIntensity; - * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } ); - * } ); - * - * @example - * // Call the MouseActions.zoomDrag method on mouse drag events - * // with left and right mouse buttons simultaneous - * stage.mouseControls.add( "drag-left+right", MouseActions.zoomDrag ); - * - * @param {TriggerString} triggerStr - the trigger for the action - * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action - * @return {undefined} - */ -MouseControls.prototype.add = function add (triggerStr, callback) { - var ref = triggerFromString(triggerStr); - var type = ref[0]; - var key = ref[1]; - var button = ref[2]; - this.actionList.push({ type: type, key: key, button: button, callback: callback }); -}; -/** - * Remove a mouse action. The trigger string can contain an asterix (*) - * as a wildcard for any key or mouse button. When the callback function - * is given, only actions that call that function are removed. - * - * @example - * // remove actions triggered solely by a scroll event - * stage.mouseControls.remove( "scroll" ); - * - * @example - * // remove actions triggered by a scroll event, including - * // those requiring a key pressed or mouse button used - * stage.mouseControls.remove( "scroll-*" ); - * - * @example - * // remove actions triggered by a scroll event - * // while the shift key is pressed - * stage.mouseControls.remove( "scroll-shift" ); - * - * @param {TriggerString} triggerStr - the trigger for the action - * @param {Function} [callback] - the callback function for the action - * @return {undefined} - */ -MouseControls.prototype.remove = function remove (triggerStr, callback) { - var wildcard = triggerStr.includes('*'); - var ref = triggerFromString(triggerStr); - var type = ref[0]; - var key = ref[1]; - var button = ref[2]; - var actionList = this.actionList.filter(function (a) { - return !((a.type === type || (wildcard && type === '')) && - (a.key === key || (wildcard && key === 0)) && - (a.button === button || (wildcard && button === 0)) && - (a.callback === callback || callback === undefined)); - }); - this.actionList = actionList; -}; -/** - * Set mouse action preset - * @param {String} name - one of "default", "pymol", "coot" - * @return {undefined} - */ -MouseControls.prototype.preset = function preset (name) { - var this$1 = this; - - this.clear(); - var list = MouseActionPresets[name] || []; - list.forEach(function (action) { return this$1.add(action[0], action[1]); }); -}; -/** - * Remove all mouse actions - * @return {undefined} - */ -MouseControls.prototype.clear = function clear () { - this.actionList.length = 0; -}; - -/** - * @file Key Actions - * @author Alexander Rose - * @private - */ -/** - * Key actions provided as static methods - */ -var KeyActions = function KeyActions () {}; - -KeyActions.autoView = function autoView (stage) { - stage.autoView(1000); -}; -/** - * Toggle stage animations - */ -KeyActions.toggleAnimations = function toggleAnimations (stage) { - stage.animationControls.toggle(); -}; -/** - * Toggle stage rocking - */ -KeyActions.toggleRock = function toggleRock (stage) { - stage.toggleRock(); -}; -/** - * Toggle stage spinning - */ -KeyActions.toggleSpin = function toggleSpin (stage) { - stage.toggleSpin(); -}; -/** - * Toggle anti-aliasing - */ -KeyActions.toggleAntialiasing = function toggleAntialiasing (stage) { - var p = stage.getParameters(); - stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 }); -}; -var KeyActionPresets = { - default: [ - ['i', KeyActions.toggleSpin], - ['k', KeyActions.toggleRock], - ['p', KeyActions.toggleAnimations], - ['a', KeyActions.toggleAntialiasing], - ['r', KeyActions.autoView] - ] -}; - -/** - * @file Key Controls - * @author Alexander Rose - * @private - */ -/** - * Mouse controls - */ -var KeyControls = function KeyControls(stage, params) { - if ( params === void 0 ) params = {}; - - this.stage = stage; - this.actionList = []; - this.disabled = params.disabled || false; - this.preset(params.preset || 'default'); -}; -KeyControls.prototype.run = function run (key) { - var this$1 = this; - - if (this.disabled) - { return; } - this.actionList.forEach(function (a) { - if (a.key === key) { - a.callback(this$1.stage); - } - }); -}; -/** - * Add a key action triggered by pressing the given character. - * The {@link KeyActions} class provides a number of static methods for - * use as callback functions. - * - * @example - * // call KeyActions.toggleRock when "k" is pressed - * stage.keyControls.remove( "k", KeyActions.toggleRock ); - * - * @param {Char} char - the key/character - * @param {Function} callback - the callback function for the action - * @return {undefined} - */ -KeyControls.prototype.add = function add (char, callback) { - this.actionList.push({ key: char, callback: callback }); -}; -/** - * Remove a key action. When the callback function - * is given, only actions that call that function are removed. - * - * @example - * // remove all actions triggered by pressing "k" - * stage.keyControls.remove( "k" ); - * - * @example - * // remove action `toggleRock` triggered by pressing "k" - * stage.keyControls.remove( "k", toggleRock ); - * - * @param {Char} char - the key/character - * @param {Function} [callback] - the callback function for the action - * @return {undefined} - */ -KeyControls.prototype.remove = function remove (char, callback) { - var actionList = this.actionList.filter(function (a) { - return !((a.key === char) && - (a.callback === callback || callback === undefined)); - }); - this.actionList = actionList; -}; -/** - * Set key action preset - * @param {String} name - one of "default" - * @return {undefined} - */ -KeyControls.prototype.preset = function preset (name) { - var this$1 = this; - - this.clear(); - var list = KeyActionPresets[name] || []; - list.forEach(function (action) { return this$1.add(action[0], action[1]); }); -}; -/** - * Remove all key actions - * @return {undefined} - */ -KeyControls.prototype.clear = function clear () { - this.actionList.length = 0; -}; - -/** - * @file Picking Behavior - * @author Alexander Rose - * @private - */ -var PickingBehavior = function PickingBehavior(stage) { - this.stage = stage; - this.stage = stage; - this.mouse = stage.mouseObserver; - this.controls = stage.mouseControls; - this.mouse.signals.clicked.add(this._onClick, this); - this.mouse.signals.hovered.add(this._onHover, this); -}; -PickingBehavior.prototype._onClick = function _onClick (x, y) { - var pickingProxy = this.stage.pickingControls.pick(x, y); - this.stage.signals.clicked.dispatch(pickingProxy); - this.controls.run('clickPick', pickingProxy); -}; -PickingBehavior.prototype._onHover = function _onHover (x, y) { - var pickingProxy = this.stage.pickingControls.pick(x, y); - if (pickingProxy && this.mouse.down.equals(this.mouse.position)) { - this.stage.transformComponent = pickingProxy.component; - this.stage.transformAtom = pickingProxy.atom; - } - this.stage.signals.hovered.dispatch(pickingProxy); - this.controls.run('hoverPick', pickingProxy); -}; -PickingBehavior.prototype.dispose = function dispose () { - this.mouse.signals.clicked.remove(this._onClick, this); - this.mouse.signals.hovered.remove(this._onHover, this); -}; - -/** - * @file Mouse Behavior - * @author Alexander Rose - * @private - */ -var MouseBehavior = function MouseBehavior(stage) { - this.stage = stage; - this.stage = stage; - this.mouse = stage.mouseObserver; - this.controls = stage.mouseControls; - this.mouse.signals.moved.add(this._onMove, this); - this.mouse.signals.scrolled.add(this._onScroll, this); - this.mouse.signals.dragged.add(this._onDrag, this); - this.mouse.signals.clicked.add(this._onClick, this); - this.mouse.signals.hovered.add(this._onHover, this); - this.mouse.signals.doubleClicked.add(this._onDblclick, this); -}; -MouseBehavior.prototype._onMove = function _onMove ( /* x, y */) { - this.stage.tooltip.style.display = 'none'; -}; -MouseBehavior.prototype._onScroll = function _onScroll (delta) { - this.controls.run('scroll', delta); -}; -MouseBehavior.prototype._onDrag = function _onDrag (dx, dy) { - this.controls.run('drag', dx, dy); -}; -MouseBehavior.prototype._onClick = function _onClick (x, y) { - this.controls.run('click', x, y); -}; -MouseBehavior.prototype._onDblclick = function _onDblclick (x, y) { - this.controls.run('doubleClick', x, y); -}; -MouseBehavior.prototype._onHover = function _onHover (x, y) { - this.controls.run('hover', x, y); -}; -MouseBehavior.prototype.dispose = function dispose () { - this.mouse.signals.moved.remove(this._onMove, this); - this.mouse.signals.scrolled.remove(this._onScroll, this); - this.mouse.signals.dragged.remove(this._onDrag, this); - this.mouse.signals.clicked.remove(this._onClick, this); - this.mouse.signals.hovered.remove(this._onHover, this); -}; - -/** - * @file Animation Behavior - * @author Alexander Rose - * @private - */ -var AnimationBehavior = function AnimationBehavior(stage) { - this.stage = stage; - this.viewer = stage.viewer; - this.animationControls = stage.animationControls; - this.viewer.signals.ticked.add(this._onTick, this); -}; -AnimationBehavior.prototype._onTick = function _onTick (stats) { - this.animationControls.run(stats); -}; -AnimationBehavior.prototype.dispose = function dispose () { - this.viewer.signals.ticked.remove(this._onTick, this); -}; - -/** - * @file Key Behavior - * @author Alexander Rose - * @private - */ -var passive = SupportsPassiveEventHandler ? { passive: true } : false; -var KeyBehavior = function KeyBehavior(stage) { - this.stage = stage; - this.stage = stage; - this.controls = stage.keyControls; - this.domElement = stage.viewer.renderer.domElement; - // ensure the domElement is focusable - this.domElement.setAttribute('tabIndex', '-1'); - this.domElement.style.outline = 'none'; - this._focusDomElement = this._focusDomElement.bind(this); - this._onKeydown = this._onKeydown.bind(this); - this._onKeyup = this._onKeyup.bind(this); - this._onKeypress = this._onKeypress.bind(this); - this.domElement.addEventListener('mousedown', this._focusDomElement); - this.domElement.addEventListener('touchstart', this._focusDomElement, passive); // TODO - this.domElement.addEventListener('keydown', this._onKeydown); - this.domElement.addEventListener('keyup', this._onKeyup); - this.domElement.addEventListener('keypress', this._onKeypress); -}; -/** - * handle key down - * @param {Event} event - key event - * @return {undefined} - */ -KeyBehavior.prototype._onKeydown = function _onKeydown ( /* event */) { - // console.log( "down", event.keyCode, String.fromCharCode( event.keyCode ) ); -}; -/** - * handle key up - * @param {Event} event - key event - * @return {undefined} - */ -KeyBehavior.prototype._onKeyup = function _onKeyup ( /* event */) { - // console.log( "up", event.keyCode, String.fromCharCode( event.keyCode ) ); -}; -/** - * handle key press - * @param {Event} event - key event - * @return {undefined} - */ -KeyBehavior.prototype._onKeypress = function _onKeypress (event) { - // console.log( "press", event.keyCode, String.fromCharCode( event.keyCode ) ); - var pressedKey; - if ("key" in KeyboardEvent.prototype) { - pressedKey = event.key; - // some mobile browsers don't support this attribute - } - else { - pressedKey = String.fromCharCode(event.which || event.keyCode); - } - this.controls.run(pressedKey); -}; -KeyBehavior.prototype._focusDomElement = function _focusDomElement () { - this.domElement.focus(); -}; -KeyBehavior.prototype.dispose = function dispose () { - this.domElement.removeEventListener('mousedown', this._focusDomElement); - this.domElement.removeEventListener('touchstart', this._focusDomElement, passive); // TODO - this.domElement.removeEventListener('keydown', this._onKeypress); - this.domElement.removeEventListener('keyup', this._onKeypress); - this.domElement.removeEventListener('keypress', this._onKeypress); -}; - -/** - * @file Annotation - * @author Alexander Rose - * @private - */ -/** - * Annotation HTML element floating on top of a position rendered in 3d - */ -var Annotation = function Annotation(component, position, content, params) { - if ( params === void 0 ) params = {}; - - this.component = component; - this.position = position; - this.offsetX = defaults(params.offsetX, 0); - this.offsetY = defaults(params.offsetY, 0); - this.visible = defaults(params.visible, true); - this.stage = component.stage; - this.viewer = component.stage.viewer; - this._viewerPosition = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this._updateViewerPosition(); - this._canvasPosition = new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](); - this._cameraPosition = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.element = document.createElement('div'); - Object.assign(this.element.style, { - display: 'block', - position: 'absolute', - pointerEvents: 'none', - whiteSpace: 'nowrap', - left: '-10000px' - }); - this.viewer.wrapper.appendChild(this.element); - this.setContent(content); - this.updateVisibility(); - this.viewer.signals.rendered.add(this._update, this); - this.component.signals.matrixChanged.add(this._updateViewerPosition, this); -}; -/** - * Set HTML content of the annotation - * @param {String|Element} value - HTML content - * @return {undefined} - */ -Annotation.prototype.setContent = function setContent (value) { - var displayValue = this.element.style.display; - if (displayValue === 'none') { - this.element.style.left = '-10000px'; - this.element.style.display = 'block'; - } - if (value instanceof HTMLElement) { - this.element.appendChild(value); - } - else { - var content = document.createElement('div'); - content.innerText = value; - Object.assign(content.style, { - backgroundColor: 'rgba( 0, 0, 0, 0.6 )', - color: 'lightgrey', - padding: '8px', - fontFamily: 'sans-serif', - }); - this.element.appendChild(content); - } - this._clientRect = this.element.getBoundingClientRect(); - if (displayValue === 'none') { - this.element.style.display = displayValue; - } -}; -/** - * Set visibility of the annotation - * @param {Boolean} value - visibility flag - * @return {undefined} - */ -Annotation.prototype.setVisibility = function setVisibility (value) { - this.visible = value; - this.updateVisibility(); -}; -Annotation.prototype.getVisibility = function getVisibility () { - return this.visible && this.component.parameters.visible; -}; -Annotation.prototype.updateVisibility = function updateVisibility () { - this.element.style.display = this.getVisibility() ? 'block' : 'none'; -}; -Annotation.prototype._updateViewerPosition = function _updateViewerPosition () { - this._viewerPosition - .copy(this.position) - .applyMatrix4(this.component.matrix); -}; -Annotation.prototype._update = function _update () { - if (!this.getVisibility()) - { return; } - var s = this.element.style; - var cp = this._canvasPosition; - var vp = this._viewerPosition; - var cr = this._clientRect; - this._cameraPosition.copy(vp) - .add(this.viewer.translationGroup.position) - .applyMatrix4(this.viewer.rotationGroup.matrix) - .sub(this.viewer.camera.position); - if (this._cameraPosition.z < 0) { - s.display = 'none'; - return; - } - else { - s.display = 'block'; - } - var depth = this._cameraPosition.length(); - var fog = this.viewer.scene.fog; // TODO - s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString(); - s.zIndex = (Math.round((fog.far - depth) * 100)).toString(); - this.stage.viewerControls.getPositionOnCanvas(vp, cp); - s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'; - s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'; -}; -/** - * Safely remove the annotation - * @return {undefined} - */ -Annotation.prototype.dispose = function dispose () { - this.viewer.wrapper.removeChild(this.element); - this.viewer.signals.ticked.remove(this._update, this); - this.component.signals.matrixChanged.remove(this._updateViewerPosition, this); -}; - -/** - * @file Component Controls - * @author Alexander Rose - * @private - */ -var tmpRotateMatrix$2 = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var tmpRotateVector$2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var tmpRotateQuaternion$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); -/** - * Component controls - */ -var ComponentControls = function ComponentControls(component) { - this.component = component; - this.signals = { - changed: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.stage = component.stage; - this.viewer = component.stage.viewer; -}; - -var prototypeAccessors$e = { position: { configurable: true },rotation: { configurable: true } }; -/** - * component center position - * @type {Vector3} - */ -prototypeAccessors$e.position.get = function () { - return this.component.position; -}; -/** - * component rotation - * @type {Quaternion} - */ -prototypeAccessors$e.rotation.get = function () { - return this.component.quaternion; -}; -/** - * Trigger render and emit changed event - * @emits {ComponentControls.signals.changed} - * @return {undefined} - */ -ComponentControls.prototype.changed = function changed () { - this.component.updateMatrix(); - this.viewer.requestRender(); - this.signals.changed.dispatch(); -}; -/** - * spin component on axis - * @param {Vector3|Array} axis - rotation axis - * @param {Number} angle - amount to spin - * @return {undefined} - */ -ComponentControls.prototype.spin = function spin (axis, angle) { - tmpRotateMatrix$2.getInverse(this.viewer.rotationGroup.matrix); - tmpRotateVector$2 - .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix$2); - tmpRotateMatrix$2.extractRotation(this.component.transform); - tmpRotateMatrix$2.premultiply(this.viewer.rotationGroup.matrix); - tmpRotateMatrix$2.getInverse(tmpRotateMatrix$2); - tmpRotateVector$2.copy(ensureVector3(axis)); - tmpRotateVector$2.applyMatrix4(tmpRotateMatrix$2); - tmpRotateMatrix$2.makeRotationAxis(tmpRotateVector$2, angle); - tmpRotateQuaternion$1.setFromRotationMatrix(tmpRotateMatrix$2); - this.component.quaternion.premultiply(tmpRotateQuaternion$1); - this.changed(); -}; - -Object.defineProperties( ComponentControls.prototype, prototypeAccessors$e ); - -/** - * @file Radius Factory - * @author Alexander Rose - * @private - */ -var RadiusFactoryTypes = { - '': '', - 'vdw': 'by vdW radius', - 'covalent': 'by covalent radius', - 'sstruc': 'by secondary structure', - 'bfactor': 'by bfactor', - 'size': 'size', - 'data': 'data', - 'explicit': 'explicit' -}; -var RadiusFactory = function RadiusFactory(params) { - if ( params === void 0 ) params = {}; - - this.max = 10; - this.type = defaults(params.type, 'size'); - this.scale = defaults(params.scale, 1); - this.size = defaults(params.size, 1); - this.data = defaults(params.data, {}); -}; -RadiusFactory.prototype.atomRadius = function atomRadius (a) { - var r; - switch (this.type) { - case 'vdw': - r = a.vdw; - break; - case 'covalent': - r = a.covalent; - break; - case 'bfactor': - r = a.bfactor || 1.0; - break; - case 'sstruc': - var sstruc = a.sstruc; - if (sstruc === 'h') { - r = 0.25; - } - else if (sstruc === 'g') { - r = 0.25; - } - else if (sstruc === 'i') { - r = 0.25; - } - else if (sstruc === 'e') { - r = 0.25; - } - else if (sstruc === 'b') { - r = 0.25; - } - else if (NucleicBackboneAtoms.includes(a.atomname)) { - r = 0.4; - } - else { - r = 0.1; - } - break; - case 'data': - r = defaults(this.data[a.index], 1.0); - break; - case 'explicit': - // defaults is inappropriate as AtomProxy.radius returns - // null for missing radii - r = a.radius; - if (r === null) - { r = this.size; } - break; - default: - r = this.size; - break; - } - return Math.min(r * this.scale, this.max); -}; -RadiusFactory.types = RadiusFactoryTypes; - -/** - * @file Principal Axes - * @author Alexander Rose - * @private - */ -var negateVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](-1, -1, -1); -var tmpMatrix$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -/** - * Principal axes - */ -var PrincipalAxes = function PrincipalAxes(points) { - // console.time( "PrincipalAxes" ); - var n = points.rows; - var n3 = n / 3; - var pointsT = new Matrix(n, 3); - var A = new Matrix(3, 3); - var W = new Matrix(1, 3); - var U = new Matrix(3, 3); - var V = new Matrix(3, 3); - // calculate - var mean = meanRows(points); - subRows(points, mean); - transpose(pointsT, points); - multiplyABt(A, pointsT, pointsT); - svd(A, W, U, V); - // console.log( points, pointsT, mean ) - // console.log( n, A, W, U, V ); - // center - var vm = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](mean[0], mean[1], mean[2]); - // normalized - var van = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](U.data[0], U.data[3], U.data[6]); - var vbn = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](U.data[1], U.data[4], U.data[7]); - var vcn = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](U.data[2], U.data[5], U.data[8]); - // scaled - var va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3)); - var vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3)); - var vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3)); - // points - this.begA = vm.clone().sub(va); - this.endA = vm.clone().add(va); - this.begB = vm.clone().sub(vb); - this.endB = vm.clone().add(vb); - this.begC = vm.clone().sub(vc); - this.endC = vm.clone().add(vc); - // - this.center = vm; - this.vecA = va; - this.vecB = vb; - this.vecC = vc; - this.normVecA = van; - this.normVecB = vbn; - this.normVecC = vcn; - // console.timeEnd( "PrincipalAxes" ); -}; -/** - * Get the basis matrix descriping the axes - * @param {Matrix4} [optionalTarget] - target object - * @return {Matrix4} the basis - */ -PrincipalAxes.prototype.getBasisMatrix = function getBasisMatrix (optionalTarget) { - if ( optionalTarget === void 0 ) optionalTarget = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - - var basis = optionalTarget; - basis.makeBasis(this.normVecB, this.normVecA, this.normVecC); - if (basis.determinant() < 0) { - basis.scale(negateVector); - } - return basis; -}; -/** - * Get a quaternion descriping the axes rotation - * @param {Quaternion} [optionalTarget] - target object - * @return {Quaternion} the rotation - */ -PrincipalAxes.prototype.getRotationQuaternion = function getRotationQuaternion (optionalTarget) { - if ( optionalTarget === void 0 ) optionalTarget = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); - - var q = optionalTarget; - q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix$1)); - return q.inverse(); -}; -/** - * Get the scale/length for each dimension for a box around the axes - * to enclose the atoms of a structure - * @param {Structure|StructureView} structure - the structure - * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale - */ -PrincipalAxes.prototype.getProjectedScaleForAtoms = function getProjectedScaleForAtoms (structure) { - var d1a = -Infinity; - var d1b = -Infinity; - var d2a = -Infinity; - var d2b = -Infinity; - var d3a = -Infinity; - var d3b = -Infinity; - var p = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var t = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var center = this.center; - var ax1 = this.normVecA; - var ax2 = this.normVecB; - var ax3 = this.normVecC; - structure.eachAtom(function (ap) { - projectPointOnVector(p.copy(ap), ax1, center); // TODO - var dp1 = t.subVectors(p, center).normalize().dot(ax1); - var dt1 = p.distanceTo(center); - if (dp1 > 0) { - if (dt1 > d1a) - { d1a = dt1; } - } - else { - if (dt1 > d1b) - { d1b = dt1; } - } - projectPointOnVector(p.copy(ap), ax2, center); - var dp2 = t.subVectors(p, center).normalize().dot(ax2); - var dt2 = p.distanceTo(center); - if (dp2 > 0) { - if (dt2 > d2a) - { d2a = dt2; } - } - else { - if (dt2 > d2b) - { d2b = dt2; } - } - projectPointOnVector(p.copy(ap), ax3, center); - var dp3 = t.subVectors(p, center).normalize().dot(ax3); - var dt3 = p.distanceTo(center); - if (dp3 > 0) { - if (dt3 > d3a) - { d3a = dt3; } - } - else { - if (dt3 > d3b) - { d3b = dt3; } - } - }); - return { - d1a: d1a, - d2a: d2a, - d3a: d3a, - d1b: -d1b, - d2b: -d2b, - d3b: -d3b - }; -}; - -/** - * @file Filtered Volume - * @author Alexander Rose - * @private - */ -var FilteredVolume = function FilteredVolume(volume, minValue, maxValue, outside) { - this.volume = volume; - this.setFilter(minValue, maxValue, outside); -}; - -var prototypeAccessors$f = { header: { configurable: true },matrix: { configurable: true },normalMatrix: { configurable: true },inverseMatrix: { configurable: true },center: { configurable: true },boundingBox: { configurable: true },min: { configurable: true },max: { configurable: true },mean: { configurable: true },rms: { configurable: true } }; -prototypeAccessors$f.header.get = function () { return this.volume.header; }; -prototypeAccessors$f.matrix.get = function () { return this.volume.matrix; }; -prototypeAccessors$f.normalMatrix.get = function () { return this.volume.normalMatrix; }; -prototypeAccessors$f.inverseMatrix.get = function () { return this.volume.inverseMatrix; }; -prototypeAccessors$f.center.get = function () { return this.volume.center; }; -prototypeAccessors$f.boundingBox.get = function () { return this.volume.boundingBox; }; -prototypeAccessors$f.min.get = function () { return this.volume.min; }; -prototypeAccessors$f.max.get = function () { return this.volume.max; }; -prototypeAccessors$f.mean.get = function () { return this.volume.mean; }; -prototypeAccessors$f.rms.get = function () { return this.volume.rms; }; -FilteredVolume.prototype._getFilterHash = function _getFilterHash (minValue, maxValue, outside) { - return JSON.stringify([minValue, maxValue, outside]); -}; -FilteredVolume.prototype.setFilter = function setFilter (minValue, maxValue, outside) { - if (isNaN(minValue) && this.header) { - minValue = this.header.DMEAN + 2.0 * this.header.ARMS; - } - minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity; - maxValue = defaults(maxValue, Infinity); - outside = defaults(outside, false); - var data = this.volume.data; - var position = this.volume.position; - var atomindex = this.volume.atomindex; - var filterHash = this._getFilterHash(minValue, maxValue, outside); - if (filterHash === this._filterHash) { - // already filtered - return; - } - else if (minValue === -Infinity && maxValue === Infinity) { - this.data = data; - this.position = position; - this.atomindex = atomindex; - } - else { - var n = data.length; - if (!this._dataBuffer) { - // ArrayBuffer for re-use as Float32Array backend - this._dataBuffer = new ArrayBuffer(n * 4); - this._positionBuffer = new ArrayBuffer(n * 3 * 4); - if (atomindex) - { this._atomindexBuffer = new ArrayBuffer(n * 4); } - } - var filteredData = new Float32Array(this._dataBuffer); - var filteredPosition = new Float32Array(this._positionBuffer); - var filteredAtomindex; - if (atomindex) - { filteredAtomindex = new Uint32Array(this._atomindexBuffer); } - var j = 0; - for (var i = 0; i < n; ++i) { - var i3 = i * 3; - var v = data[i]; - if ((!outside && v >= minValue && v <= maxValue) || - (outside && (v < minValue || v > maxValue))) { - var j3 = j * 3; - filteredData[j] = v; - filteredPosition[j3 + 0] = position[i3 + 0]; - filteredPosition[j3 + 1] = position[i3 + 1]; - filteredPosition[j3 + 2] = position[i3 + 2]; - if (atomindex && filteredAtomindex) - { filteredAtomindex[j] = atomindex[i]; } - j += 1; - } - } - // set views - this.data = new Float32Array(this._dataBuffer, 0, j); - this.position = new Float32Array(this._positionBuffer, 0, j * 3); - if (atomindex) - { this.atomindex = new Int32Array(this._atomindexBuffer, 0, j); } - } - this._filterHash = filterHash; -}; - -Object.defineProperties( FilteredVolume.prototype, prototypeAccessors$f ); -FilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma; -FilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue; -FilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex; -FilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition; -FilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor; -FilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking; -FilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize; - -/** - * @file Bond Hash - * @author Alexander Rose - * @private - */ -var BondHash = function BondHash(bondStore, atomCount) { - var al = createAdjacencyList({ - nodeArray1: bondStore.atomIndex1, - nodeArray2: bondStore.atomIndex2, - edgeCount: bondStore.count, - nodeCount: atomCount - }); - this.countArray = al.countArray; - this.offsetArray = al.offsetArray; - this.indexArray = al.indexArray; -}; - -/** - * @file Bond Store - * @author Alexander Rose - * @private - */ -/** - * Bond store - */ -var BondStore = /*@__PURE__*/(function (Store$$1) { - function BondStore () { - Store$$1.apply(this, arguments); - } - - if ( Store$$1 ) BondStore.__proto__ = Store$$1; - BondStore.prototype = Object.create( Store$$1 && Store$$1.prototype ); - BondStore.prototype.constructor = BondStore; - - var prototypeAccessors = { _defaultFields: { configurable: true } }; - - prototypeAccessors._defaultFields.get = function () { - return [ - ['atomIndex1', 1, 'int32'], - ['atomIndex2', 1, 'int32'], - ['bondOrder', 1, 'int8'] - ]; - }; - BondStore.prototype.addBond = function addBond (atom1, atom2, bondOrder) { - this.growIfFull(); - var i = this.count; - var ai1 = atom1.index; - var ai2 = atom2.index; - if (ai1 < ai2) { - this.atomIndex1[i] = ai1; - this.atomIndex2[i] = ai2; - } - else { - this.atomIndex2[i] = ai1; - this.atomIndex1[i] = ai2; - } - if (bondOrder) - { this.bondOrder[i] = bondOrder; } - this.count += 1; - }; - BondStore.prototype.addBondIfConnected = function addBondIfConnected (atom1, atom2, bondOrder) { - if (atom1.connectedTo(atom2)) { - this.addBond(atom1, atom2, bondOrder); - return true; - } - return false; - }; - - Object.defineProperties( BondStore.prototype, prototypeAccessors ); - - return BondStore; -}(Store)); - -/** - * @file Atom Store - * @author Alexander Rose - * @private - */ -/** - * Atom store - */ -var AtomStore = /*@__PURE__*/(function (Store$$1) { - function AtomStore () { - Store$$1.apply(this, arguments); - } - - if ( Store$$1 ) AtomStore.__proto__ = Store$$1; - AtomStore.prototype = Object.create( Store$$1 && Store$$1.prototype ); - AtomStore.prototype.constructor = AtomStore; - - var prototypeAccessors = { _defaultFields: { configurable: true } }; - - prototypeAccessors._defaultFields.get = function () { - return [ - ['residueIndex', 1, 'uint32'], - ['atomTypeId', 1, 'uint16'], - ['x', 1, 'float32'], - ['y', 1, 'float32'], - ['z', 1, 'float32'], - ['serial', 1, 'int32'], - ['bfactor', 1, 'float32'], - ['altloc', 1, 'uint8'], - ['occupancy', 1, 'float32'] - ]; - }; - AtomStore.prototype.setAltloc = function setAltloc (i, str) { - this.altloc[i] = str.charCodeAt(0); - }; - AtomStore.prototype.getAltloc = function getAltloc (i) { - var code = this.altloc[i]; - return code ? String.fromCharCode(code) : ''; - }; - - Object.defineProperties( AtomStore.prototype, prototypeAccessors ); - - return AtomStore; -}(Store)); - -/** - * @file Residue Store - * @author Alexander Rose - * @private - */ -/** - * Residue store - */ -var ResidueStore = /*@__PURE__*/(function (Store$$1) { - function ResidueStore () { - Store$$1.apply(this, arguments); - } - - if ( Store$$1 ) ResidueStore.__proto__ = Store$$1; - ResidueStore.prototype = Object.create( Store$$1 && Store$$1.prototype ); - ResidueStore.prototype.constructor = ResidueStore; - - var prototypeAccessors = { _defaultFields: { configurable: true } }; - - prototypeAccessors._defaultFields.get = function () { - return [ - ['chainIndex', 1, 'uint32'], - ['atomOffset', 1, 'uint32'], - ['atomCount', 1, 'uint32'], - ['residueTypeId', 1, 'uint16'], - ['resno', 1, 'int32'], - ['sstruc', 1, 'uint8'], - ['inscode', 1, 'uint8'] - ]; - }; - ResidueStore.prototype.setSstruc = function setSstruc (i, str) { - this.sstruc[i] = str.charCodeAt(0); - }; - ResidueStore.prototype.getSstruc = function getSstruc (i) { - var code = this.sstruc[i]; - return code ? String.fromCharCode(code) : ''; - }; - ResidueStore.prototype.setInscode = function setInscode (i, str) { - this.inscode[i] = str.charCodeAt(0); - }; - ResidueStore.prototype.getInscode = function getInscode (i) { - var code = this.inscode[i]; - return code ? String.fromCharCode(code) : ''; - }; - - Object.defineProperties( ResidueStore.prototype, prototypeAccessors ); - - return ResidueStore; -}(Store)); - -/** - * @file Chain Store - * @author Alexander Rose - * @private - */ -/** - * Chain store - */ -var ChainStore = /*@__PURE__*/(function (Store$$1) { - function ChainStore () { - Store$$1.apply(this, arguments); - } - - if ( Store$$1 ) ChainStore.__proto__ = Store$$1; - ChainStore.prototype = Object.create( Store$$1 && Store$$1.prototype ); - ChainStore.prototype.constructor = ChainStore; - - var prototypeAccessors = { _defaultFields: { configurable: true } }; - - prototypeAccessors._defaultFields.get = function () { - return [ - ['entityIndex', 1, 'uint16'], - ['modelIndex', 1, 'uint16'], - ['residueOffset', 1, 'uint32'], - ['residueCount', 1, 'uint32'], - ['chainname', 4, 'uint8'], - ['chainid', 4, 'uint8'] - ]; - }; - ChainStore.prototype.setChainname = function setChainname (i, str) { - var j = 4 * i; - this.chainname[j] = str.charCodeAt(0); - this.chainname[j + 1] = str.charCodeAt(1); - this.chainname[j + 2] = str.charCodeAt(2); - this.chainname[j + 3] = str.charCodeAt(3); - }; - ChainStore.prototype.getChainname = function getChainname (i) { - var chainname = ''; - for (var k = 0; k < 4; ++k) { - var code = this.chainname[4 * i + k]; - if (code) { - chainname += String.fromCharCode(code); - } - else { - break; - } - } - return chainname; - }; - ChainStore.prototype.setChainid = function setChainid (i, str) { - var j = 4 * i; - this.chainid[j] = str.charCodeAt(0); - this.chainid[j + 1] = str.charCodeAt(1); - this.chainid[j + 2] = str.charCodeAt(2); - this.chainid[j + 3] = str.charCodeAt(3); - }; - ChainStore.prototype.getChainid = function getChainid (i) { - var chainid = ''; - for (var k = 0; k < 4; ++k) { - var code = this.chainid[4 * i + k]; - if (code) { - chainid += String.fromCharCode(code); - } - else { - break; - } - } - return chainid; - }; - - Object.defineProperties( ChainStore.prototype, prototypeAccessors ); - - return ChainStore; -}(Store)); - -/** - * @file Model Store - * @author Alexander Rose - * @private - */ -/** - * Model store - */ -var ModelStore = /*@__PURE__*/(function (Store$$1) { - function ModelStore () { - Store$$1.apply(this, arguments); - } - - if ( Store$$1 ) ModelStore.__proto__ = Store$$1; - ModelStore.prototype = Object.create( Store$$1 && Store$$1.prototype ); - ModelStore.prototype.constructor = ModelStore; - - var prototypeAccessors = { _defaultFields: { configurable: true } }; - - prototypeAccessors._defaultFields.get = function () { - return [ - ['chainOffset', 1, 'uint32'], - ['chainCount', 1, 'uint32'] - ]; - }; - - Object.defineProperties( ModelStore.prototype, prototypeAccessors ); - - return ModelStore; -}(Store)); - -/** - * @file Helixorient - * @author Alexander Rose - * @private - */ -var Helixorient = function Helixorient(polymer) { - this.polymer = polymer; - this.size = polymer.residueCount; -}; -Helixorient.prototype.getCenterIterator = function getCenterIterator (smooth) { - if ( smooth === void 0 ) smooth = 0; - - var center = this.getPosition().center; - var size = center.length / 3; - var i = 0; - var j = -1; - var cache = [ - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]() - ]; - function next() { - var vector = this.get(j); - j += 1; - return vector; - } - function get(idx) { - idx = Math.min(size - 1, Math.max(0, idx)); - var v = cache[i % 4]; - var idx3 = 3 * idx; - v.fromArray(center, idx3); // TODO - if (smooth) { - var w = Math.min(smooth, idx, size - idx - 1); - for (var k = 1; k <= w; ++k) { - var l = k * 3; - var t = (w + 1 - k) / (w + 1); - v.x += t * center[idx3 - l + 0] + t * center[idx3 + l + 0]; - v.y += t * center[idx3 - l + 1] + t * center[idx3 + l + 1]; - v.z += t * center[idx3 - l + 2] + t * center[idx3 + l + 2]; - } - v.x /= w + 1; - v.y /= w + 1; - v.z /= w + 1; - } - i += 1; - return v; - } - function reset() { - i = 0; - j = -1; - } - return { size: size, next: next, get: get, reset: reset }; -}; -Helixorient.prototype.getColor = function getColor (params) { - var polymer = this.polymer; - var structure = polymer.structure; - var n = polymer.residueCount; - var residueIndexStart = polymer.residueIndexStart; - var col = new Float32Array(n * 3); - var p = params || {}; - p.structure = structure; - var colormaker = ColormakerRegistry$1.getScheme(p); - var rp = structure.getResidueProxy(); - var ap = structure.getAtomProxy(); - for (var i = 0; i < n; ++i) { - rp.index = residueIndexStart + i; - ap.index = rp.traceAtomIndex; - colormaker.atomColorToArray(ap, col, i * 3); - } - return { - 'color': col - }; -}; -Helixorient.prototype.getPicking = function getPicking () { - var polymer = this.polymer; - var structure = polymer.structure; - var n = polymer.residueCount; - var residueIndexStart = polymer.residueIndexStart; - var pick = new Float32Array(n); - var rp = structure.getResidueProxy(); - for (var i = 0; i < n; ++i) { - rp.index = residueIndexStart + i; - pick[i] = rp.traceAtomIndex; - } - return { - 'picking': new AtomPicker(pick, structure) - }; -}; -Helixorient.prototype.getSize = function getSize (params) { - var polymer = this.polymer; - var structure = polymer.structure; - var n = polymer.residueCount; - var residueIndexStart = polymer.residueIndexStart; - var size = new Float32Array(n); - var radiusFactory = new RadiusFactory(params); - var rp = structure.getResidueProxy(); - var ap = structure.getAtomProxy(); - for (var i = 0; i < n; ++i) { - rp.index = residueIndexStart + i; - ap.index = rp.traceAtomIndex; - size[i] = radiusFactory.atomRadius(ap); - } - return { size: size }; -}; -Helixorient.prototype.getPosition = function getPosition () { - var polymer = this.polymer; - var structure = polymer.structure; - var n = polymer.residueCount; - var n3 = n - 3; - var center = new Float32Array(3 * n); - var axis = new Float32Array(3 * n); - var diff = new Float32Array(n); - var radius = new Float32Array(n); - var rise = new Float32Array(n); - var twist = new Float32Array(n); - var resdir = new Float32Array(3 * n); - var r12 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var r23 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var r34 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var diff13 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var diff24 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var v1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var v2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vt = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var _axis = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var _prevAxis = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var _resdir = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var _center = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); - var type = 'trace'; - var a1 = structure.getAtomProxy(); - var a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type)); - var a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type)); - var a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type)); - for (var i = 0; i < n3; ++i) { - a1.index = a2.index; - a2.index = a3.index; - a3.index = a4.index; - a4.index = polymer.getAtomIndexByType(i + 3, type); // TODO - var j = 3 * i; - // ported from GROMACS src/tools/gmx_helixorient.c - r12.subVectors(a2, a1); // TODO - r23.subVectors(a3, a2); // TODO - r34.subVectors(a4, a3); // TODO - diff13.subVectors(r12, r23); - diff24.subVectors(r23, r34); - _axis.crossVectors(diff13, diff24).normalize(); - _axis.toArray(axis, j); // TODO - if (i > 0) { - diff[i] = _axis.angleTo(_prevAxis); - } - var tmp = Math.cos(diff13.angleTo(diff24)); - twist[i] = 180.0 / Math.PI * Math.acos(tmp); - var diff13Length = diff13.length(); - var diff24Length = diff24.length(); - radius[i] = (Math.sqrt(diff24Length * diff13Length) / - // clamp, to avoid instabilities for when - // angle between diff13 and diff24 is near 0 - Math.max(2.0, 2.0 * (1.0 - tmp))); - rise[i] = Math.abs(r23.dot(_axis)); - // - v1.copy(diff13).multiplyScalar(radius[i] / diff13Length); - v2.copy(diff24).multiplyScalar(radius[i] / diff24Length); - v1.subVectors(a2, v1); // TODO - v2.subVectors(a3, v2); // TODO - v1.toArray(center, j + 3); // TODO - v2.toArray(center, j + 6); // TODO - // - _resdir.subVectors(a1, _center); // TODO - _resdir.toArray(resdir, j); // TODO - _prevAxis.copy(_axis); - _center.copy(v1); - } - // - // calc axis as dir of second and third center pos - // project first traceAtom onto axis to get first center pos - v1.fromArray(center, 3); // TODO - v2.fromArray(center, 6); // TODO - _axis.subVectors(v1, v2).normalize(); - // _center.copy( res[ 0 ].getTraceAtom() ); - a1.index = polymer.getAtomIndexByType(0, type); // TODO - _center.copy(a1); // TODO - vt.copy(a1); // TODO - projectPointOnVector(vt, _axis, v1); - vt.toArray(center, 0); // TODO - // calc first resdir - _resdir.subVectors(_center, v1); - _resdir.toArray(resdir, 0); // TODO - // calc axis as dir of n-1 and n-2 center pos - // project last traceAtom onto axis to get last center pos - v1.fromArray(center, 3 * n - 6); // TODO - v2.fromArray(center, 3 * n - 9); // TODO - _axis.subVectors(v1, v2).normalize(); - // _center.copy( res[ n - 1 ].getTraceAtom() ); - a1.index = polymer.getAtomIndexByType(n - 1, type); // TODO - _center.copy(a1); // TODO - vt.copy(a1); // TODO - projectPointOnVector(vt, _axis, v1); - vt.toArray(center, 3 * n - 3); // TODO - // calc last three resdir - for (var i$1 = n - 3; i$1 < n; ++i$1) { - v1.fromArray(center, 3 * i$1); // TODO - // _center.copy( res[ i ].getTraceAtom() ); - a1.index = polymer.getAtomIndexByType(i$1, type); // TODO - _center.copy(a1); // TODO - _resdir.subVectors(_center, v1); - _resdir.toArray(resdir, 3 * i$1); // TODO - } - // average measures to define them on the residues - var resRadius = new Float32Array(n); - var resTwist = new Float32Array(n); - var resRise = new Float32Array(n); - var resBending = new Float32Array(n); - resRadius[1] = radius[0]; - resTwist[1] = twist[0]; - resRise[1] = radius[0]; - for (var i$2 = 2; i$2 < n - 2; ++i$2) { - resRadius[i$2] = 0.5 * (radius[i$2 - 2] + radius[i$2 - 1]); - resTwist[i$2] = 0.5 * (twist[i$2 - 2] + twist[i$2 - 1]); - resRise[i$2] = 0.5 * (rise[i$2 - 2] + rise[i$2 - 1]); - v1.fromArray(axis, 3 * (i$2 - 2)); // TODO - v2.fromArray(axis, 3 * (i$2 - 1)); // TODO - resBending[i$2] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2))); - } - resRadius[n - 2] = radius[n - 4]; - resTwist[n - 2] = twist[n - 4]; - resRise[n - 2] = rise[n - 4]; - // average helix axes to define them on the residues - var resAxis = new Float32Array(3 * n); - copyArray(axis, resAxis, 0, 0, 3); - copyArray(axis, resAxis, 0, 3, 3); - for (var i$3 = 2; i$3 < n - 2; ++i$3) { - v1.fromArray(axis, 3 * (i$3 - 2)); // TODO - v2.fromArray(axis, 3 * (i$3 - 1)); // TODO - _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize(); - _axis.toArray(resAxis, 3 * i$3); // TODO - } - copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3); - copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3); - return { - center: center, - axis: resAxis, - bending: resBending, - radius: resRadius, - rise: resRise, - twist: resTwist, - resdir: resdir - }; -}; - -/** - * @file Helixbundle - * @author Alexander Rose - * @private - */ -var Helixbundle = function Helixbundle(polymer) { - this.polymer = polymer; - this.helixorient = new Helixorient(polymer); - this.position = this.helixorient.getPosition(); -}; -Helixbundle.prototype.getAxis = function getAxis (localAngle, centerDist, ssBorder, colorParams, radiusParams) { - localAngle = localAngle || 30; - centerDist = centerDist || 2.5; - ssBorder = ssBorder === undefined ? false : ssBorder; - var polymer = this.polymer; - var structure = polymer.structure; - var n = polymer.residueCount; - var residueIndexStart = polymer.residueIndexStart; - var pos = this.position; - var cp = colorParams || {}; - cp.structure = structure; - var colormaker = ColormakerRegistry$1.getScheme(cp); - var radiusFactory = new RadiusFactory(radiusParams); - var j = 0; - var k = 0; - var axis = []; - var center = []; - var beg = []; - var end = []; - var col = []; - var pick = []; - var size = []; - var residueOffset = []; - var residueCount = []; - var tmpAxis = new Float32Array(n * 3); - var tmpCenter = new Float32Array(n * 3); - var _axis, _center; - var _beg = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var _end = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var rp1 = structure.getResidueProxy(); - var rp2 = structure.getResidueProxy(); - var ap = structure.getAtomProxy(); - var c1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var c2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var split = false; - for (var i = 0; i < n; ++i) { - rp1.index = residueIndexStart + i; - c1.fromArray(pos.center, i * 3); - if (i === n - 1) { - split = true; - } - else { - rp2.index = residueIndexStart + i + 1; - c2.fromArray(pos.center, i * 3 + 3); - if (ssBorder && rp1.sstruc !== rp2.sstruc) { - split = true; - } - else if (c1.distanceTo(c2) > centerDist) { - split = true; - } - else if (pos.bending[i] > localAngle) { - split = true; - } - } - if (split) { - if (i - j < 4) { - j = i; - split = false; - continue; - } - ap.index = rp1.traceAtomIndex; - // ignore first and last axis - tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3); - tmpCenter = pos.center.subarray(j * 3, i * 3 + 3); - _axis = calculateMeanVector3(tmpAxis).normalize(); - _center = calculateMeanVector3(tmpCenter); - _beg.fromArray(tmpCenter); - projectPointOnVector(_beg, _axis, _center); - _end.fromArray(tmpCenter, tmpCenter.length - 3); - projectPointOnVector(_end, _axis, _center); - _axis.subVectors(_end, _beg); - _axis.toArray(axis, k); - _center.toArray(center, k); - _beg.toArray(beg, k); - _end.toArray(end, k); - colormaker.atomColorToArray(ap, col, k); - pick.push(ap.index); - size.push(radiusFactory.atomRadius(ap)); - residueOffset.push(residueIndexStart + j); - residueCount.push(residueIndexStart + i + 1 - j); - k += 3; - j = i; - split = false; - } - } - var picking = new Float32Array(pick); - return { - axis: new Float32Array(axis), - center: new Float32Array(center), - begin: new Float32Array(beg), - end: new Float32Array(end), - color: new Float32Array(col), - picking: new AtomPicker(picking, structure), - size: new Float32Array(size), - residueOffset: residueOffset, - residueCount: residueCount - }; -}; - -/** - * @file Binary Heap - * @author Alexander Rose - * @private - */ -/** - * Binary heap implementation - * @class - * @author http://eloquentjavascript.net/appendix2.htm - * @param {Function} scoreFunction - the heap scoring function - */ -var BinaryHeap = function BinaryHeap(scoreFunction) { - this.scoreFunction = scoreFunction; - this.content = []; - this.scoreFunction = scoreFunction; -}; -BinaryHeap.prototype.push = function push (element) { - // Add the new element to the end of the array. - this.content.push(element); - // Allow it to bubble up. - this.bubbleUp(this.content.length - 1); -}; -BinaryHeap.prototype.pop = function pop () { - // Store the first element so we can return it later. - var result = this.content[0]; - // Get the element at the end of the array. - var end = this.content.pop(); - // If there are any elements left, put the end element at the - // start, and let it sink down. - if (end && this.content.length > 0) { - this.content[0] = end; - this.sinkDown(0); - } - return result; -}; -BinaryHeap.prototype.peek = function peek () { - return this.content[0]; -}; -BinaryHeap.prototype.remove = function remove (element) { - var len = this.content.length; - // To remove a value, we must search through the array to find it. - for (var i = 0; i < len; i++) { - if (this.content[i] === element) { - // When it is found, the process seen in 'pop' is repeated - // to fill up the hole. - var end = this.content.pop(); - if (end && i !== len - 1) { - this.content[i] = end; - if (this.scoreFunction(end) < this.scoreFunction(element)) { - this.bubbleUp(i); - } - else { - this.sinkDown(i); - } - } - return; - } - } - throw new Error('Node not found.'); -}; -BinaryHeap.prototype.size = function size () { - return this.content.length; -}; -BinaryHeap.prototype.bubbleUp = function bubbleUp (n) { - // Fetch the element that has to be moved. - var element = this.content[n]; - // When at 0, an element can not go up any further. - while (n > 0) { - // Compute the parent element's index, and fetch it. - var parentN = Math.floor((n + 1) / 2) - 1; - var parent = this.content[parentN]; - // Swap the elements if the parent is greater. - if (this.scoreFunction(element) < this.scoreFunction(parent)) { - this.content[parentN] = element; - this.content[n] = parent; - // Update 'n' to continue at the new position. - n = parentN; - } - else { - // Found a parent that is less, no need to move it further. - break; - } - } -}; -BinaryHeap.prototype.sinkDown = function sinkDown (n) { - // Look up the target element and its score. - var length = this.content.length; - var element = this.content[n]; - var elemScore = this.scoreFunction(element); - var child1Score = 0; - var child2Score = 0; - while (true) { - // Compute the indices of the child elements. - var child2N = (n + 1) * 2; - var child1N = child2N - 1; - // This is used to store the new position of the element, if any. - var swap = null; - // If the first child exists (is inside the array)... - if (child1N < length) { - // Look it up and compute its score. - var child1 = this.content[child1N]; - child1Score = this.scoreFunction(child1); - // If the score is less than our element's, we need to swap. - if (child1Score < elemScore) - { swap = child1N; } - } - // Do the same checks for the other child. - if (child2N < length) { - var child2 = this.content[child2N]; - child2Score = this.scoreFunction(child2); - if (child2Score < (swap === null ? elemScore : child1Score)) - { swap = child2N; } - } - // If the element needs to be moved, swap it, and continue. - if (swap !== null) { - this.content[n] = this.content[swap]; - this.content[swap] = element; - n = swap; - } - else { - // Otherwise, we are done. - break; - } - } -}; - -/** - * @file Kdtree - * @author Alexander Rose - * @private - */ -/** - * Kdtree - * @class - * @author Alexander Rose , 2016 - * @author Roman Bolzern , 2013 - * @author I4DS http://www.fhnw.ch/i4ds, 2013 - * @license MIT License - * @description - * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place - * provides fast nearest neighbour search - * - * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs - * - * Further information (including mathematical properties) - * http://en.wikipedia.org/wiki/Binary_tree - * http://en.wikipedia.org/wiki/K-d_tree - * - * @example - * points: [x, y, z, x, y, z, x, y, z, ...] - * metric: function(a, b){ - * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2); - * } - * - * @param {Float32Array} points - points - * @param {Function} metric - metric - */ -var Kdtree = function Kdtree(points, metric) { - this.points = points; - this.metric = metric; - this.maxDepth = 0; - this.currentNode = 0; - var n = points.length / 3; - var indices = new Uint32Array(n); - for (var i = 0; i < n; ++i) { - indices[i] = i; - } - this.indices = indices; - this.nodes = new Int32Array(n * 4); - this.rootIndex = this.buildTree(0, -1, 0, n); -}; -Kdtree.prototype.buildTree = function buildTree (depth, parent, arrBegin, arrEnd) { - if (depth > this.maxDepth) - { this.maxDepth = depth; } - var plength = arrEnd - arrBegin; - if (plength === 0) { - return -1; - } - var nodeIndex = this.currentNode * 4; - var nodes = this.nodes; - this.currentNode += 1; - if (plength === 1) { - nodes[nodeIndex] = arrBegin; - nodes[nodeIndex + 1] = -1; - nodes[nodeIndex + 2] = -1; - nodes[nodeIndex + 3] = parent; - return nodeIndex; - } - // if(plength <= 32){ - // return nodeIndex; - // } - var indices = this.indices; - var points = this.points; - var arrMedian = arrBegin + Math.floor(plength / 2); - var currentDim = depth % 3; - // inlined quickselect function - var j, tmp, pivotIndex, pivotValue, storeIndex; - var left = arrBegin; - var right = arrEnd - 1; - while (right > left) { - pivotIndex = (left + right) >> 1; - pivotValue = points[indices[pivotIndex] * 3 + currentDim]; - // swap( pivotIndex, right ); - tmp = indices[pivotIndex]; - indices[pivotIndex] = indices[right]; - indices[right] = tmp; - storeIndex = left; - for (j = left; j < right; ++j) { - if (points[indices[j] * 3 + currentDim] < pivotValue) { - // swap( storeIndex, j ); - tmp = indices[storeIndex]; - indices[storeIndex] = indices[j]; - indices[j] = tmp; - ++storeIndex; - } - } - // swap( right, storeIndex ); - tmp = indices[right]; - indices[right] = indices[storeIndex]; - indices[storeIndex] = tmp; - pivotIndex = storeIndex; - if (arrMedian === pivotIndex) { - break; - } - else if (arrMedian < pivotIndex) { - right = pivotIndex - 1; - } - else { - left = pivotIndex + 1; - } - } - nodes[nodeIndex] = arrMedian; - nodes[nodeIndex + 1] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian); - nodes[nodeIndex + 2] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd); - nodes[nodeIndex + 3] = parent; - return nodeIndex; -}; -Kdtree.prototype.getNodeDepth = function getNodeDepth (nodeIndex) { - var parentIndex = this.nodes[nodeIndex + 3]; - return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1; -}; -// TODO -// function getNodePos (node) {} -/** - * find nearest points - * @param {Array} point - array of size 3 - * @param {Integer} maxNodes - max amount of nodes to return - * @param {Float} maxDistance - maximum distance of point to result nodes - * @return {Array} array of point, distance pairs - */ -Kdtree.prototype.nearest = function nearest (point, maxNodes, maxDistance) { - var this$1 = this; - - var bestNodes = new BinaryHeap(function (e) { return -e[1]; }); - var nodes = this.nodes; - var points = this.points; - var indices = this.indices; - var nearestSearch = function (nodeIndex) { - var bestChild, otherChild; - var dimension = this$1.getNodeDepth(nodeIndex) % 3; - var pointIndex = indices[nodes[nodeIndex]] * 3; - var ownPoint = [ - points[pointIndex + 0], - points[pointIndex + 1], - points[pointIndex + 2] - ]; - var ownDistance = this$1.metric(point, ownPoint); - function saveNode(nodeIndex, distance) { - bestNodes.push([nodeIndex, distance]); - if (bestNodes.size() > maxNodes) { - bestNodes.pop(); - } - } - var leftIndex = nodes[nodeIndex + 1]; - var rightIndex = nodes[nodeIndex + 2]; - // if it's a leaf - if (rightIndex === -1 && leftIndex === -1) { - if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) && - ownDistance <= maxDistance) { - saveNode(nodeIndex, ownDistance); - } - return; - } - if (rightIndex === -1) { - bestChild = leftIndex; - } - else if (leftIndex === -1) { - bestChild = rightIndex; - } - else { - if (point[dimension] <= points[pointIndex + dimension]) { - bestChild = leftIndex; - } - else { - bestChild = rightIndex; - } - } - // recursive search - nearestSearch(bestChild); - if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) && - ownDistance <= maxDistance) { - saveNode(nodeIndex, ownDistance); - } - // if there's still room or the current distance is nearer than the best distance - var linearPoint = []; - for (var i = 0; i < 3; i += 1) { - if (i === dimension) { - linearPoint[i] = point[i]; - } - else { - linearPoint[i] = points[pointIndex + i]; - } - } - var linearDistance = this$1.metric(linearPoint, ownPoint); - if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[1]) && - Math.abs(linearDistance) <= maxDistance) { - if (bestChild === leftIndex) { - otherChild = rightIndex; - } - else { - otherChild = leftIndex; - } - if (otherChild !== -1) { - nearestSearch(otherChild); - } - } - }; - nearestSearch(this.rootIndex); - var result = []; - for (var i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) { - result.push(bestNodes.content[i]); - } - return result; -}; -Kdtree.prototype.verify = function verify (nodeIndex, depth) { - if ( depth === void 0 ) depth = 0; - - var count = 1; - if (nodeIndex === undefined) { - nodeIndex = this.rootIndex; - } - if (nodeIndex === -1) { - throw new Error('node is null'); - } - var dim = depth % 3; - var nodes = this.nodes; - var points = this.points; - var indices = this.indices; - var leftIndex = nodes[nodeIndex + 1]; - var rightIndex = nodes[nodeIndex + 2]; - if (leftIndex !== -1) { - if (points[indices[nodes[leftIndex]] * 3 + dim] > - points[indices[nodes[nodeIndex]] * 3 + dim]) { - throw new Error('left child is > parent!'); - } - count += this.verify(leftIndex, depth + 1); - } - if (rightIndex !== -1) { - if (points[indices[nodes[rightIndex]] * 3 + dim] < - points[indices[nodes[nodeIndex]] * 3 + dim]) { - throw new Error('right child is < parent!'); - } - count += this.verify(rightIndex, depth + 1); - } - return count; -}; - -/** - * @file Atom Proxy - * @author Alexander Rose - * @private - */ -/** - * Atom proxy - */ -var AtomProxy = function AtomProxy(structure, index) { - if ( index === void 0 ) index = 0; - - this.structure = structure; - this.index = index; - this.chainStore = structure.chainStore; - this.residueStore = structure.residueStore; - this.atomStore = structure.atomStore; - this.residueMap = structure.residueMap; - this.atomMap = structure.atomMap; -}; - -var prototypeAccessors$g = { bondHash: { configurable: true },entity: { configurable: true },entityIndex: { configurable: true },modelIndex: { configurable: true },chainIndex: { configurable: true },residue: { configurable: true },residueIndex: { configurable: true },sstruc: { configurable: true },inscode: { configurable: true },resno: { configurable: true },chainname: { configurable: true },chainid: { configurable: true },residueType: { configurable: true },atomType: { configurable: true },residueAtomOffset: { configurable: true },resname: { configurable: true },hetero: { configurable: true },atomname: { configurable: true },number: { configurable: true },element: { configurable: true },vdw: { configurable: true },covalent: { configurable: true },x: { configurable: true },y: { configurable: true },z: { configurable: true },serial: { configurable: true },bfactor: { configurable: true },occupancy: { configurable: true },altloc: { configurable: true },partialCharge: { configurable: true },radius: { configurable: true },formalCharge: { configurable: true },aromatic: { configurable: true },bondCount: { configurable: true } }; -/** - * @type {BondHash} - */ -prototypeAccessors$g.bondHash.get = function () { return this.structure.bondHash; }; -/** - * Molecular enity - * @type {Entity} - */ -prototypeAccessors$g.entity.get = function () { - return this.structure.entityList[this.entityIndex]; -}; -prototypeAccessors$g.entityIndex.get = function () { - return this.chainStore.entityIndex[this.chainIndex]; -}; -prototypeAccessors$g.modelIndex.get = function () { - return this.chainStore.modelIndex[this.chainIndex]; -}; -prototypeAccessors$g.chainIndex.get = function () { - return this.residueStore.chainIndex[this.residueIndex]; -}; -/** - * @type {ResidueProxy} - */ -prototypeAccessors$g.residue.get = function () { - console.warn('residue - might be expensive'); - return this.structure.getResidueProxy(this.residueIndex); -}; -prototypeAccessors$g.residueIndex.get = function () { - return this.atomStore.residueIndex[this.index]; -}; -prototypeAccessors$g.residueIndex.set = function (value) { - this.atomStore.residueIndex[this.index] = value; -}; -// -/** - * Secondary structure code - * @type {String} - */ -prototypeAccessors$g.sstruc.get = function () { - return this.residueStore.getSstruc(this.residueIndex); -}; -/** - * Insertion code - * @type {String} - */ -prototypeAccessors$g.inscode.get = function () { - return this.residueStore.getInscode(this.residueIndex); -}; -/** - * Residue number/label - * @type {Integer} - */ -prototypeAccessors$g.resno.get = function () { - return this.residueStore.resno[this.residueIndex]; -}; -/** - * Chain name - * @type {String} - */ -prototypeAccessors$g.chainname.get = function () { - return this.chainStore.getChainname(this.chainIndex); -}; -/** - * Chain id - * @type {String} - */ -prototypeAccessors$g.chainid.get = function () { - return this.chainStore.getChainid(this.chainIndex); -}; -// -/** - * @type {ResidueType} - */ -prototypeAccessors$g.residueType.get = function () { - return this.residueMap.get(this.residueStore.residueTypeId[this.residueIndex]); -}; -/** - * @type {AtomType} - */ -prototypeAccessors$g.atomType.get = function () { - return this.atomMap.get(this.atomStore.atomTypeId[this.index]); -}; -prototypeAccessors$g.residueAtomOffset.get = function () { - return this.residueStore.atomOffset[this.residueIndex]; -}; -// -/** - * Residue name - */ -prototypeAccessors$g.resname.get = function () { - return this.residueType.resname; -}; -/** - * Hetero flag - */ -prototypeAccessors$g.hetero.get = function () { - return this.residueType.hetero; -}; -// -/** - * Atom name - */ -prototypeAccessors$g.atomname.get = function () { - return this.atomType.atomname; -}; -/** - * Atomic number - */ -prototypeAccessors$g.number.get = function () { - return this.atomType.number; -}; -/** - * Element - */ -prototypeAccessors$g.element.get = function () { - return this.atomType.element; -}; -/** - * Van-der-Waals radius - */ -prototypeAccessors$g.vdw.get = function () { - return this.atomType.vdw; -}; -/** - * Covalent radius - */ -prototypeAccessors$g.covalent.get = function () { - return this.atomType.covalent; -}; -// -/** - * X coordinate - */ -prototypeAccessors$g.x.get = function () { - return this.atomStore.x[this.index]; -}; -prototypeAccessors$g.x.set = function (value) { - this.atomStore.x[this.index] = value; -}; -/** - * Y coordinate - */ -prototypeAccessors$g.y.get = function () { - return this.atomStore.y[this.index]; -}; -prototypeAccessors$g.y.set = function (value) { - this.atomStore.y[this.index] = value; -}; -/** - * Z coordinate - */ -prototypeAccessors$g.z.get = function () { - return this.atomStore.z[this.index]; -}; -prototypeAccessors$g.z.set = function (value) { - this.atomStore.z[this.index] = value; -}; -/** - * Serial number - */ -prototypeAccessors$g.serial.get = function () { - return this.atomStore.serial[this.index]; -}; -prototypeAccessors$g.serial.set = function (value) { - this.atomStore.serial[this.index] = value; -}; -/** - * B-factor value - */ -prototypeAccessors$g.bfactor.get = function () { - return this.atomStore.bfactor[this.index]; -}; -prototypeAccessors$g.bfactor.set = function (value) { - this.atomStore.bfactor[this.index] = value; -}; -/** - * Occupancy value - */ -prototypeAccessors$g.occupancy.get = function () { - return this.atomStore.occupancy[this.index]; -}; -prototypeAccessors$g.occupancy.set = function (value) { - this.atomStore.occupancy[this.index] = value; -}; -/** - * Alternate location identifier - */ -prototypeAccessors$g.altloc.get = function () { - return this.atomStore.getAltloc(this.index); -}; -prototypeAccessors$g.altloc.set = function (value) { - this.atomStore.setAltloc(this.index, value); -}; -/** - * Partial charge - */ -prototypeAccessors$g.partialCharge.get = function () { - return this.atomStore.partialCharge ? this.atomStore.partialCharge[this.index] : null; -}; -prototypeAccessors$g.partialCharge.set = function (value) { - if (this.atomStore.partialCharge) { - this.atomStore.partialCharge[this.index] = value; - } -}; -/** - * Explicit radius - */ -prototypeAccessors$g.radius.get = function () { - return this.atomStore.radius ? this.atomStore.radius[this.index] : null; -}; -prototypeAccessors$g.radius.set = function (value) { - if (this.atomStore.radius) { - this.atomStore.radius[this.index] = value; - } -}; -/** - * Formal charge - */ -prototypeAccessors$g.formalCharge.get = function () { - return this.atomStore.formalCharge ? this.atomStore.formalCharge[this.index] : null; -}; -prototypeAccessors$g.formalCharge.set = function (value) { - if (this.atomStore.formalCharge) { - this.atomStore.formalCharge[this.index] = value; - } -}; -/** - * Aromaticity flag - */ -prototypeAccessors$g.aromatic.get = function () { - if (this.atomStore.aromatic) { - return this.atomStore.aromatic[this.index]; - } - else { - return this.residueType.isAromatic(this) ? 1 : 0; - } -}; -prototypeAccessors$g.aromatic.set = function (value) { - if (this.atomStore.aromatic) { - this.atomStore.aromatic[this.index] = value; - } -}; -// -prototypeAccessors$g.bondCount.get = function () { - return this.bondHash.countArray[this.index]; // TODO -}; -// -/** - * Iterate over each bond - * @param {function(bond: BondProxy)} callback - iterator callback function - * @param {BondProxy} [bp] - optional target bond proxy for use in the callback - * @return {undefined} - */ -AtomProxy.prototype.eachBond = function eachBond (callback, bp) { - bp = bp || this.structure._bp; - var idx = this.index; - var bondHash = this.bondHash; // TODO - var indexArray = bondHash.indexArray; - var n = bondHash.countArray[idx]; - var offset = bondHash.offsetArray[idx]; - for (var i = 0; i < n; ++i) { - bp.index = indexArray[offset + i]; - callback(bp); - } -}; -/** - * Iterate over each bonded atom - * @param {function(atom: AtomProxy)} callback - iterator callback function - * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback - * @return {undefined} - */ -AtomProxy.prototype.eachBondedAtom = function eachBondedAtom (callback, _ap) { - var ap = _ap ? _ap : this.structure._ap; - var idx = this.index; - this.eachBond(function (bp) { - ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2; - callback(ap); - }); - this.index = idx; -}; -/** - * Check if this atom is bonded to the given atom, - * assumes both atoms are from the same structure - * @param {AtomProxy} ap - the given atom - * @return {Boolean} whether a bond exists or not - */ -AtomProxy.prototype.hasBondTo = function hasBondTo (ap) { - var flag = false; - this.eachBondedAtom(function (bap) { - if (ap.index === bap.index) - { flag = true; } - }); - return flag; -}; -AtomProxy.prototype.bondToElementCount = function bondToElementCount (element) { - var count = 0; - var idx = this.index; // Avoid reentrancy problems - this.eachBondedAtom(function (bap) { - if (bap.number === element) - { count += 1; } - }); - this.index = idx; - return count; -}; -AtomProxy.prototype.hasBondToElement = function hasBondToElement (element) { - return this.bondToElementCount(element) > 0; -}; -// -/** - * If atom is part of a backbone - * @return {Boolean} flag - */ -AtomProxy.prototype.isBackbone = function isBackbone () { - var backboneIndexList = this.residueType.backboneIndexList; - if (backboneIndexList.length > 0) { - return backboneIndexList.includes(this.index - this.residueAtomOffset); - } - else { - return false; - } -}; -/** - * If atom is part of a polymer - * @return {Boolean} flag - */ -AtomProxy.prototype.isPolymer = function isPolymer () { - if (this.structure.entityList.length > 0) { - return this.entity.isPolymer(); - } - else { - var moleculeType = this.residueType.moleculeType; - return (moleculeType === ProteinType || - moleculeType === RnaType || - moleculeType === DnaType); - } -}; -/** - * If atom is part of a sidechin - * @return {Boolean} flag - */ -AtomProxy.prototype.isSidechain = function isSidechain () { - return this.isPolymer() && !this.isBackbone(); -}; -/** - * If atom is part of a coarse-grain group - * @return {Boolean} flag - */ -AtomProxy.prototype.isCg = function isCg () { - var backboneType = this.residueType.backboneType; - return (backboneType === CgProteinBackboneType || - backboneType === CgRnaBackboneType || - backboneType === CgDnaBackboneType); -}; -AtomProxy.prototype.isTrace = function isTrace () { - return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset); -}; -/** - * If atom is part of a hetero group - * @return {Boolean} flag - */ -AtomProxy.prototype.isHetero = function isHetero () { - return this.residueType.hetero === 1; -}; -/** - * If atom is part of a protein molecule - * @return {Boolean} flag - */ -AtomProxy.prototype.isProtein = function isProtein () { - return this.residueType.moleculeType === ProteinType; -}; -/** - * If atom is part of a nucleic molecule - * @return {Boolean} flag - */ -AtomProxy.prototype.isNucleic = function isNucleic () { - var moleculeType = this.residueType.moleculeType; - return moleculeType === RnaType || moleculeType === DnaType; -}; -/** - * If atom is part of a rna - * @return {Boolean} flag - */ -AtomProxy.prototype.isRna = function isRna () { - return this.residueType.moleculeType === RnaType; -}; -/** - * If atom is part of a dna - * @return {Boolean} flag - */ -AtomProxy.prototype.isDna = function isDna () { - return this.residueType.moleculeType === DnaType; -}; -/** - * If atom is part of a water molecule - * @return {Boolean} flag - */ -AtomProxy.prototype.isWater = function isWater () { - return this.residueType.moleculeType === WaterType; -}; -/** - * If atom is part of an ion - * @return {Boolean} flag - */ -AtomProxy.prototype.isIon = function isIon () { - return this.residueType.moleculeType === IonType; -}; -/** - * If atom is part of a saccharide - * @return {Boolean} flag - */ -AtomProxy.prototype.isSaccharide = function isSaccharide () { - return this.residueType.moleculeType === SaccharideType; -}; -/** - * If atom is part of a helix - * @return {Boolean} flag - */ -AtomProxy.prototype.isHelix = function isHelix () { - return SecStrucHelix.includes(this.sstruc); -}; -/** - * If atom is part of a sheet - * @return {Boolean} flag - */ -AtomProxy.prototype.isSheet = function isSheet () { - return SecStrucSheet.includes(this.sstruc); -}; -/** - * If atom is part of a turn - * @return {Boolean} flag - */ -AtomProxy.prototype.isTurn = function isTurn () { - return SecStrucTurn.includes(this.sstruc) && this.isProtein(); -}; -AtomProxy.prototype.isBonded = function isBonded () { - return this.bondHash.countArray[this.index] !== 0; // TODO -}; -/** - * If atom is part of a ring - * @return {Boolean} flag - */ -AtomProxy.prototype.isRing = function isRing () { - var atomRings = this.residueType.getRings().atomRings; // TODO - return atomRings[this.index - this.residueAtomOffset] !== undefined; -}; -AtomProxy.prototype.isAromatic = function isAromatic () { - return this.aromatic === 1; -}; -AtomProxy.prototype.isPolarHydrogen = function isPolarHydrogen () { - var result = false; - if (this.number !== 1) - { return result; } - result = !this.hasBondToElement(6 /* C */); - return result; -}; -AtomProxy.prototype.isMetal = function isMetal () { return this.atomType.isMetal(); }; -AtomProxy.prototype.isNonmetal = function isNonmetal () { return this.atomType.isNonmetal(); }; -AtomProxy.prototype.isMetalloid = function isMetalloid () { return this.atomType.isMetalloid(); }; -AtomProxy.prototype.isHalogen = function isHalogen () { return this.atomType.isHalogen(); }; -AtomProxy.prototype.isDiatomicNonmetal = function isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal(); }; -AtomProxy.prototype.isPolyatomicNonmetal = function isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal(); }; -AtomProxy.prototype.isAlkaliMetal = function isAlkaliMetal () { return this.atomType.isAlkaliMetal(); }; -AtomProxy.prototype.isAlkalineEarthMetal = function isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal(); }; -AtomProxy.prototype.isNobleGas = function isNobleGas () { return this.atomType.isNobleGas(); }; -AtomProxy.prototype.isTransitionMetal = function isTransitionMetal () { return this.atomType.isTransitionMetal(); }; -AtomProxy.prototype.isPostTransitionMetal = function isPostTransitionMetal () { return this.atomType.isPostTransitionMetal(); }; -AtomProxy.prototype.isLanthanide = function isLanthanide () { return this.atomType.isLanthanide(); }; -AtomProxy.prototype.isActinide = function isActinide () { return this.atomType.isActinide(); }; -AtomProxy.prototype.getDefaultValence = function getDefaultValence () { return this.atomType.getDefaultValence(); }; -AtomProxy.prototype.getValenceList = function getValenceList () { return this.atomType.getValenceList(); }; -AtomProxy.prototype.getOuterShellElectronCount = function getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount(); }; -/** - * Distance to another atom - * @param {AtomProxy} atom - the other atom - * @return {Number} the distance - */ -AtomProxy.prototype.distanceTo = function distanceTo (atom) { - var taa = this.atomStore; - var aaa = atom.atomStore; - var ti = this.index; - var ai = atom.index; - var x = taa.x[ti] - aaa.x[ai]; - var y = taa.y[ti] - aaa.y[ai]; - var z = taa.z[ti] - aaa.z[ai]; - var distSquared = x * x + y * y + z * z; - return Math.sqrt(distSquared); -}; -/** - * If connected to another atom - * @param {AtomProxy} atom - the other atom - * @return {Boolean} flag - */ -AtomProxy.prototype.connectedTo = function connectedTo (atom) { - var taa = this.atomStore; - var aaa = atom.atomStore; - var ti = this.index; - var ai = atom.index; - if (taa.altloc && aaa.altloc) { - var ta = taa.altloc[ti]; // use Uint8 value to compare - var aa = aaa.altloc[ai]; // no need to convert to char - // 0 is the Null character, 32 is the space character - if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) - { return false; } - } - var x = taa.x[ti] - aaa.x[ai]; - var y = taa.y[ti] - aaa.y[ai]; - var z = taa.z[ti] - aaa.z[ai]; - var distSquared = x * x + y * y + z * z; - // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared ) - if (distSquared < 48.0 && this.isCg()) - { return true; } - if (isNaN(distSquared)) - { return false; } - var d = this.covalent + atom.covalent; - var d1 = d + 0.3; - var d2 = d - 0.5; - return distSquared < (d1 * d1) && distSquared > (d2 * d2); -}; -/** - * Set atom position from array - * @param {Array|TypedArray} array - input array - * @param {Integer} [offset] - the offset - * @return {AtomProxy} this object - */ -AtomProxy.prototype.positionFromArray = function positionFromArray (array, offset) { - if ( offset === void 0 ) offset = 0; - - this.x = array[offset + 0]; - this.y = array[offset + 1]; - this.z = array[offset + 2]; - return this; -}; -/** - * Write atom position to array - * @param {Array|TypedArray} [array] - target array - * @param {Integer} [offset] - the offset - * @return {Array|TypedArray} target array - */ -AtomProxy.prototype.positionToArray = function positionToArray (array, offset) { - if ( array === void 0 ) array = []; - if ( offset === void 0 ) offset = 0; - - var index = this.index; - var atomStore = this.atomStore; - array[offset + 0] = atomStore.x[index]; - array[offset + 1] = atomStore.y[index]; - array[offset + 2] = atomStore.z[index]; - return array; -}; -/** - * Write atom position to vector - * @param {Vector3} [v] - target vector - * @return {Vector3} target vector - */ -AtomProxy.prototype.positionToVector3 = function positionToVector3 (v) { - if (v === undefined) - { v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); } - v.x = this.x; - v.y = this.y; - v.z = this.z; - return v; -}; -/** - * Set atom position from vector - * @param {Vector3} v - input vector - * @return {AtomProxy} this object - */ -AtomProxy.prototype.positionFromVector3 = function positionFromVector3 (v) { - this.x = v.x; - this.y = v.y; - this.z = v.z; - return this; -}; -/** - * Add vector to atom position - * @param {Vector3} v - input vector - * @return {AtomProxy} this object - */ -AtomProxy.prototype.positionAdd = function positionAdd (v) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - return this; -}; -/** - * Subtract vector from atom position - * @param {Vector3} v - input vector - * @return {AtomProxy} this object - */ -AtomProxy.prototype.positionSub = function positionSub (v) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - return this; -}; -/** - * Get intra group/residue bonds - * @param {Boolean} firstOnly - immediately return the first connected atomIndex - * @return {Integer[]|Integer|undefined} connected atomIndices - */ -AtomProxy.prototype.getResidueBonds = function getResidueBonds (firstOnly) { - if ( firstOnly === void 0 ) firstOnly = false; - - var residueAtomOffset = this.residueAtomOffset; - var relativeIndex = this.index - this.residueAtomOffset; - var bonds = this.residueType.getBonds(); // TODO - var atomIndices1 = bonds.atomIndices1; - var atomIndices2 = bonds.atomIndices2; - var idx1, idx2, connectedAtomIndex; - var connectedAtomIndices; - if (!firstOnly) - { connectedAtomIndices = []; } - idx1 = atomIndices1.indexOf(relativeIndex); - while (idx1 !== -1) { - connectedAtomIndex = atomIndices2[idx1] + residueAtomOffset; - if (connectedAtomIndices) { - connectedAtomIndices.push(connectedAtomIndex); - idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1); - } - else { - return connectedAtomIndex; - } - } - idx2 = atomIndices2.indexOf(relativeIndex); - while (idx2 !== -1) { - connectedAtomIndex = atomIndices1[idx2] + residueAtomOffset; - if (connectedAtomIndices) { - connectedAtomIndices.push(connectedAtomIndex); - idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1); - } - else { - return connectedAtomIndex; - } - } - return connectedAtomIndices; -}; -// -AtomProxy.prototype.qualifiedName = function qualifiedName (noResname) { - if ( noResname === void 0 ) noResname = false; - - var name = ''; - if (this.resname && !noResname) - { name += '[' + this.resname + ']'; } - if (this.resno !== undefined) - { name += this.resno; } - if (this.inscode) - { name += '^' + this.inscode; } - if (this.chainname) - { name += ':' + this.chainname; } - if (this.atomname) - { name += '.' + this.atomname; } - if (this.altloc) - { name += '%' + this.altloc; } - if (this.structure.modelStore.count > 1) - { name += '/' + this.modelIndex; } - return name; -}; -/** - * Clone object - * @return {AtomProxy} cloned atom - */ -AtomProxy.prototype.clone = function clone () { - return new AtomProxy(this.structure, this.index); -}; -AtomProxy.prototype.toObject = function toObject () { - return { - index: this.index, - residueIndex: this.residueIndex, - resname: this.resname, - x: this.x, - y: this.y, - z: this.z, - element: this.element, - chainname: this.chainname, - resno: this.resno, - serial: this.serial, - vdw: this.vdw, - covalent: this.covalent, - hetero: this.hetero, - bfactor: this.bfactor, - altloc: this.altloc, - atomname: this.atomname, - modelIndex: this.modelIndex - }; -}; - -Object.defineProperties( AtomProxy.prototype, prototypeAccessors$g ); - -/** - * @file Kdtree - * @author Alexander Rose - * @private - */ -function euclideanDistSq(a, b) { - var dx = a[0] - b[0]; - var dy = a[1] - b[1]; - var dz = a[2] - b[2]; - return dx * dx + dy * dy + dz * dz; -} -function euclideanDist(a, b) { - return Math.sqrt(euclideanDistSq(a, b)); -} -var pointArray = new Float32Array(3); -var Kdtree$1 = function Kdtree$$1(structure, useSquaredDist) { - if ( useSquaredDist === void 0 ) useSquaredDist = false; - - if (Debug) - { Log.time('Kdtree build'); } - var metric = useSquaredDist ? euclideanDistSq : euclideanDist; - var points = new Float32Array(structure.atomCount * 3); - var atomIndices = new Uint32Array(structure.atomCount); - var i = 0; - structure.eachAtom(function (ap) { - points[i + 0] = ap.x; - points[i + 1] = ap.y; - points[i + 2] = ap.z; - atomIndices[i / 3] = ap.index; - i += 3; - }); - this.atomIndices = atomIndices; - this.points = points; - this.kdtree = new Kdtree(points, metric); - if (Debug) - { Log.timeEnd('Kdtree build'); } - // console.log("this.kdtree.verify()", this.kdtree.verify()) -}; -Kdtree$1.prototype.nearest = function nearest (point, maxNodes, maxDistance) { - // Log.time( "Kdtree nearest" ); - if (point instanceof __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]) { - point.toArray(pointArray); - } - else if (point instanceof AtomProxy) { - point.positionToArray(pointArray); - } - var nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance); - var indices = this.kdtree.indices; - var nodes = this.kdtree.nodes; - var atomIndices = this.atomIndices; - var resultList = []; - for (var i = 0, n = nodeList.length; i < n; ++i) { - var d = nodeList[i]; - var nodeIndex = d[0]; - var dist = d[1]; - resultList.push({ - index: atomIndices[indices[nodes[nodeIndex]]], - distance: dist - }); - } - // Log.timeEnd( "Kdtree nearest" ); - return resultList; -}; - -/** - * @file Symmetry Constants - * @author Alexander Rose - * @private - */ -var SymOpCode = { - ' ': 'X', - '!': 'Y', - '#': 'Z', - '$': '-X', - '%': '-Y', - '&': '-Z', - "'": 'Y+1/2', - '(': '1/2+X', - ')': '1/2+Y', - '*': '1/2-X', - '+': '1/2+Z', - ',': '1/2-Y', - '-': '1/2-Z', - '.': 'X+1/2', - '/': 'Z+1/2', - '0': '-X+1/2', - '1': '-Y+1/2', - '2': '-Z+1/2', - '3': '1/4+X', - '4': '1/4-Y', - '5': '1/4+Z', - '6': '1/4-X', - '7': '1/4+Y', - '8': '3/4-Y', - '9': '3/4+Z', - ':': '3/4+Y', - ';': '3/4+X', - '<': '3/4-X', - '=': '1/4-Z', - '>': '3/4-Z', - '?': 'X-Y', - '@': 'Y-X', - 'A': 'Z+1/3', - 'B': 'Z+2/3', - 'C': 'X+2/3', - 'D': 'Y+1/3', - 'E': '-Y+2/3', - 'F': 'X-Y+1/3', - 'G': 'Y-X+2/3', - 'H': '-X+1/3', - 'I': 'X+1/3', - 'J': 'Y+2/3', - 'K': '-Y+1/3', - 'L': 'X-Y+2/3', - 'M': 'Y-X+1/3', - 'N': '-X+2/3', - 'O': '2/3+X', - 'P': '1/3+Y', - 'Q': '1/3+Z', - 'R': '2/3-Y', - 'S': '1/3+X-Y', - 'T': '2/3+Y-X', - 'U': '1/3-X', - 'V': '2/3-X', - 'W': '1/3-Y', - 'X': '1/3-Z', - 'Y': '2/3+Y', - 'Z': '1/3+Y-X', - '[': '2/3+X-Y', - ']': '1/3+X', - '^': '2/3+Z', - '_': '2/3-Z', - '`': '5/6+Z', - 'a': '1/6+Z', - 'b': '5/6-Z', - 'c': '1/6-Z', - 'd': 'Z+5/6', - 'e': 'Z+1/6', - 'f': 'Z+1/4', - 'g': '+Y' -}; -// encoded, originally from CCP4 symop.lib -var EncodedSymOp = { - 'P 1': ' !#', - 'P -1': ' !#$%&', - 'P 1 2 1': ' !#$!&', - 'P 1 21 1': " !#$'&", - 'C 1 2 1': ' !#$!&()#*)&', - 'P 1 m 1': ' !# %#', - 'P 1 c 1': ' !# %+', - 'C 1 m 1': ' !# %#()#(,#', - 'C 1 c 1': ' !# %+()#(,+', - 'P 1 2/m 1': ' !# %#$!&$%&', - 'P 1 21/m 1': ' !#$)&$%& ,#', - 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&', - 'P 1 2/c 1': ' !#$!-$%& %+', - 'P 1 21/c 1': ' !#$%&$)- ,+', - 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+', - 'P 2 2 2': ' !#$%#$!& %&', - 'P 2 2 21': ' !#$%+$!- %&', - 'P 21 21 2': ' !#$%#*)&(,&', - 'P 21 21 21': ' !#*%+$)-(,&', - 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&', - 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&', - 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&', - 'I 2 2 2': " !#$%# %&$!&.'/01/.120'2", - 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-', - 'P m m 2': ' !#$%# %#$!#', - 'P m c 21': ' !#$%+ %+$!#', - 'P c c 2': ' !#$%# %+$!+', - 'P m a 2': ' !#$%#(%#*!#', - 'P c a 21': ' !#$%+(%#*!+', - 'P n c 2': ' !#$%# ,+$)+', - 'P m n 21': ' !#*%+(%+$!#', - 'P b a 2': ' !#$%#(,#*)#', - 'P n a 21': ' !#$%+(,#*)+', - 'P n n 2': ' !#$%#(,+*)+', - 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#', - 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#', - 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+', - 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+', - 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+', - 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+', - 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+', - 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#', - 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5', - 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+', - 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+', - 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+', - 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#', - 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+', - 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+', - 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#', - 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#', - 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+', - 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#', - 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+', - 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#', - 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+', - 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#', - 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+', - 'P 21/m 21/m 2/n': " !#$%#*'&.,&*,&.'& %#$!#", - 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#', - 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#', - 'P 21/n 21/m 21/a': " !#0%/$'&.12$%&.!2 1#0'/", - 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#', - 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#', - 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#', - 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+', - 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#', - 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+', - 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#', - 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5', - 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+', - 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+', - 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+', - 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+', - 'P 4': ' !#$%#% #!$#', - 'P 41': ' !#$%+% 5!$9', - 'P 42': ' !#$%#% +!$+', - 'P 43': ' !#$%+% 9!$5', - 'I 4': ' !#$%#% #!$#()+*,+,(+)*+', - 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5', - 'P -4': ' !#$%#!$&% &', - 'I -4': ' !#$%#!$&% &()+*,+)*-,(-', - 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &', - 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -', - 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &', - 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &', - 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-', - 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &', - 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&', - 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&', - 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=', - 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-', - 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-', - 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&', - 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>', - 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-', - 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-', - 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-', - 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #', - 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#', - 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #', - 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #', - 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +', - 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+', - 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +', - 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+', - 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+', - 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#', - 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5', - 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9', - 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #', - 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +', - 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#', - 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+', - 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&', - 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-', - 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&', - 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-', - 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-', - 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&', - 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+', - 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5', - 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #', - 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +', - 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#', - 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+', - 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#', - 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+', - 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#', - 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+', - 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +', - 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #', - 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +', - 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #', - 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+', - 'P 42/m 21/n 2/m': " !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #", - 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+', - 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#', - 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+', - 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#', - 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9', - 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5', - 'P 3': ' !#%?#@$#', - 'P 31': ' !#%?A@$B', - 'P 32': ' !#%?B@$A', - 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB', - 'R 3': ' !## !!# ', - 'P -3': ' !#%?#@$#$%&!@&? &', - 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_', - 'R -3': ' !## !!# $%&&$%%&$', - 'P 3 1 2': ' !#%?#@$#%$&@!& ?&', - 'P 3 2 1': ' !#%?#@$#! &?%&$@&', - 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&', - 'P 31 2 1': ' !#%?A@$B! &?%_$@X', - 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&', - 'P 32 2 1': ' !#%?B@$A! &?%X$@_', - 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_', - 'R 3 2': ' !## !!# %$&$&%&%$', - 'P 3 m 1': ' !#%?#@$#%$#@!# ?#', - 'P 3 1 m': ' !#%?#@$#! #?%#$@#', - 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+', - 'P 3 1 c': ' !#%?#@$#! +?%+$@+', - 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^', - 'R 3 m': ' !## !!# ! # #!#! ', - 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a', - 'R 3 c': " !## !!# '././'/'.", - 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#', - 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+', - 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#', - 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+', - 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^', - 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ', - 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a', - 'R -3 2/c': " !## !!# 102021210$%&&$%%&$'././'/'.", - 'P 6': ' !#%?#@$#$%#!@#? #', - 'P 61': ' !#%?A@$B$%/!@d? e', - 'P 65': ' !#%?B@$A$%/!@e? d', - 'P 62': ' !#%?^@$Q$%#!@^? Q', - 'P 64': ' !#%?Q@$^$%#!@Q? ^', - 'P 63': ' !#%?#@$#$%+!@+? +', - 'P -6': ' !#%?#@$# !&%?&@$&', - 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&', - 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-', - 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&', - 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c', - 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b', - 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X', - 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_', - 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-', - 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#', - 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+', - 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#', - 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+', - 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&', - 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&', - 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#', - 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+', - 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#', - 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+', - 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#', - 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+', - 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ', - 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ', - 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(', - 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(', - 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ', - 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$', - 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*', - 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$', - 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96', - 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*', - 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*', - 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$', - 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$', - 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*', - 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$', - 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86', - 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*', - 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46', - 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<', - 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46', - 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ', - 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ', - 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(', - 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(', - 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(', - 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43', - 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ', - 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(', - 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(', - 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ', - 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ', - 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(', - 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ', - 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(', - 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(', - 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;', - 'P 1 1 2': ' !#$%#', - 'P 1 1 21': ' !#$%+', - 'B 1 1 2': ' !#$%#(g+*%+', - 'A 1 2 1': ' !#$!& )+$)-', - 'C 1 21 1': ' !#$)&()#*!&', - 'I 1 2 1': " !#$!&.'/0'2", - 'I 1 21 1': " !#$)&.'/0!-", - 'P 1 1 m': ' !# !&', - 'P 1 1 b': ' !# )&', - 'B 1 1 m': ' !# !&(!+(!-', - 'B 1 1 b': ' !# )&(!+()-', - 'P 1 1 2/m': ' !# !&$%#$%&', - 'P 1 1 21/m': ' !#$%+$%& !-', - 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-', - 'P 1 1 2/b': ' !#$,#$%& )&', - 'P 1 1 21/b': ' !#$%&$,+ )-', - 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-', - 'P 21 2 2': ' !#$!&(%&*%#', - 'P 2 21 2': ' !# ,&$)&$%#', - 'P 21 21 2 (a)': " !#*,#.%&$'&", - 'P 21 2 21': ' !#$!&(%-*%+', - 'P 2 21 21': ' !# %&$)-$,+', - 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-', - 'C 2 2 2a': " !#*,#.%&$'&()#$%# ,&*!&", - 'F 2 2 2a': " !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&", - 'I 2 2 2a': " !#*,#.%&$'&()+$%+*!- ,-", - 'P 21/m 21/m 2/n a': " !#*,#$)&(%&$%&.'& ,#*!#", - 'P 42 21 2a': " !#*,#%.+'$+$'&.%&! -,*-", - 'I 2 3a': " !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ," -}; - -/** - * @file Symmetry Utils - * @author Alexander Rose - * @private - */ -var reInteger = /^[1-9]$/; -function getSymmetryOperations(spacegroup) { - var encodedSymopList = EncodedSymOp[spacegroup]; - var matrixDict = {}; - if (encodedSymopList === undefined) { - console.warn(("spacegroup '" + spacegroup + "' not found in symop library")); - return matrixDict; - } - var symopList = []; - for (var i = 0, il = encodedSymopList.length; i < il; i += 3) { - var symop = []; - for (var j = 0; j < 3; ++j) { - symop.push(SymOpCode[encodedSymopList[i + j]]); - } - symopList.push(symop); - } - symopList.forEach(function (symop) { - var row = 0; - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); - var me = matrix.elements; - matrixDict[symop.toString()] = matrix; - symop.forEach(function (elm) { - var negate = false; - var denominator = false; - for (var i = 0, n = elm.length; i < n; ++i) { - var c = elm[i]; - if (c === '-') { - negate = true; - } - else if (c === '+') { - negate = false; - } - else if (c === '/') { - denominator = true; - } - else if (c === 'X') { - me[0 + row] = negate ? -1 : 1; - } - else if (c === 'Y') { - me[4 + row] = negate ? -1 : 1; - } - else if (c === 'Z') { - me[8 + row] = negate ? -1 : 1; - } - else if (reInteger.test(c)) { - var integer = parseInt(c); - if (denominator) { - me[12 + row] /= integer; - } - else { - me[12 + row] = integer; - } - } - else { - Log.warn(("getSymmetryOperations: unknown token '" + c + "'")); - } - } - row += 1; - }); - }); - return matrixDict; -} - -/** - * @file Assembly - * @author Alexander Rose - * @private - */ -function selectionFromChains(chainList) { - var sele = ''; - if (chainList.length > 0) { - sele = ':' + uniqueArray(chainList).join(' OR :'); - } - return new Selection(sele); -} -/** - * Assembly of transformed parts of a {@link Structure} - */ -var Assembly = function Assembly(name) { - if ( name === void 0 ) name = ''; - - this.name = name; - this.partList = []; -}; - -var prototypeAccessors$h = { type: { configurable: true } }; -prototypeAccessors$h.type.get = function () { return 'Assembly'; }; -/** - * Add transformed parts to the assembly - * @example - * var m1 = new NGL.Matrix4().set( ... ); - * var m2 = new NGL.Matrix4().set( ... ); - * var assembly = new NGL.Assembly( "myAssembly" ); - * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2` - * assembly.addPart( [ m1, m2 ], [ "A", "B" ] ) - * - * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices - * @param {String[]} chainList - array of chain names - * @return {AssemblyPart} the added assembly part - */ -Assembly.prototype.addPart = function addPart (matrixList, chainList) { - var part = new AssemblyPart(matrixList, chainList); - this.partList.push(part); - return part; -}; -/** - * Get the number of atom for a given structure - * @param {Structure} structure - the given structure - * @return {Integer} number of atoms in the assembly - */ -Assembly.prototype.getAtomCount = function getAtomCount (structure) { - return this.partList.reduce(function (count, part) { return count + part.getAtomCount(structure); }, 0); -}; -/** - * Get the number of residues for a given structure - * @param {Structure} structure - the given structure - * @return {Integer} number of residues in the assembly - */ -Assembly.prototype.getResidueCount = function getResidueCount (structure) { - return this.partList.reduce(function (count, part) { return count + part.getResidueCount(structure); }, 0); -}; -/** - * Get number of instances the assembly will produce, i.e. - * the number of transformations performed by the assembly - * @return {Integer} number of instances - */ -Assembly.prototype.getInstanceCount = function getInstanceCount () { - var instanceCount = 0; - this.partList.forEach(function (part) { - instanceCount += part.matrixList.length; - }); - return instanceCount; -}; -/** - * Determine if the assembly is the full and untransformed structure - * @param {Structure} structure - the given structure - * @return {Boolean} whether the assembly is identical to the structure - */ -Assembly.prototype.isIdentity = function isIdentity (structure) { - if (this.partList.length !== 1) - { return false; } - var part = this.partList[0]; - if (part.matrixList.length !== 1) - { return false; } - var identityMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - if (!identityMatrix.equals(part.matrixList[0])) - { return false; } - var structureChainList = []; - structure.eachChain(function (cp) { - structureChainList.push(cp.chainname); - }); - structureChainList = uniqueArray(structureChainList); - if (part.chainList.length !== structureChainList.length) - { return false; } - return true; -}; -Assembly.prototype.getBoundingBox = function getBoundingBox (structure) { - var boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this.partList.forEach(function (part) { - var partBox = part.getBoundingBox(structure); - boundingBox.expandByPoint(partBox.min); - boundingBox.expandByPoint(partBox.max); - }); - return boundingBox; -}; -Assembly.prototype.getCenter = function getCenter (structure) { - return this.getBoundingBox(structure).getCenter(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); -}; -Assembly.prototype.getSelection = function getSelection () { - var chainList = []; - this.partList.forEach(function (part) { - chainList = chainList.concat(part.chainList); - }); - return selectionFromChains(chainList); -}; - -Object.defineProperties( Assembly.prototype, prototypeAccessors$h ); -var AssemblyPart = function AssemblyPart(matrixList, chainList) { - if ( matrixList === void 0 ) matrixList = []; - if ( chainList === void 0 ) chainList = []; - - this.matrixList = matrixList; - this.chainList = chainList; -}; - -var prototypeAccessors$1$2 = { type: { configurable: true } }; -prototypeAccessors$1$2.type.get = function () { return 'AssemblyPart'; }; -AssemblyPart.prototype._getCount = function _getCount (structure, propertyName) { - var this$1 = this; - - var count = 0; - structure.eachChain(function (cp) { - if (this$1.chainList.length === 0 || this$1.chainList.includes(cp.chainname)) { - count += cp[propertyName]; - } - }); - return this.matrixList.length * count; -}; -AssemblyPart.prototype.getAtomCount = function getAtomCount (structure) { - return this._getCount(structure, 'atomCount'); -}; -AssemblyPart.prototype.getResidueCount = function getResidueCount (structure) { - return this._getCount(structure, 'residueCount'); -}; -AssemblyPart.prototype.getBoundingBox = function getBoundingBox (structure) { - var partBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - var instanceBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - var selection = this.getSelection(); - var structureBox = structure.getBoundingBox(selection); - this.matrixList.forEach(function (matrix) { - instanceBox.copy(structureBox).applyMatrix4(matrix); - partBox.expandByPoint(instanceBox.min); - partBox.expandByPoint(instanceBox.max); - }); - return partBox; -}; -AssemblyPart.prototype.getSelection = function getSelection () { - return selectionFromChains(this.chainList); -}; -AssemblyPart.prototype.getView = function getView (structure) { - var selection = this.getSelection(); - if (selection) { - return structure.getView(selection); - } - else { - return structure; - } -}; -AssemblyPart.prototype.getInstanceList = function getInstanceList () { - var instanceList = []; - for (var j = 0, jl = this.matrixList.length; j < jl; ++j) { - instanceList.push({ - id: j + 1, - name: j, - matrix: this.matrixList[j] - }); - } - return instanceList; -}; - -Object.defineProperties( AssemblyPart.prototype, prototypeAccessors$1$2 ); - -/** - * @file Structure Builder - * @author Alexander Rose - * @private - */ -var StructureBuilder = function StructureBuilder(structure) { - this.structure = structure; - this.currentModelindex = null; - this.currentChainid = null; - this.currentResname = null; - this.currentResno = null; - this.currentInscode = undefined; - this.currentHetero = null; - this.previousResname = ''; - this.previousHetero = null; - this.ai = -1; - this.ri = -1; - this.ci = -1; - this.mi = -1; -}; -StructureBuilder.prototype.addResidueType = function addResidueType (ri) { - var atomStore = this.structure.atomStore; - var residueStore = this.structure.residueStore; - var residueMap = this.structure.residueMap; - var count = residueStore.atomCount[ri]; - var offset = residueStore.atomOffset[ri]; - var atomTypeIdList = new Array(count); - for (var i = 0; i < count; ++i) { - atomTypeIdList[i] = atomStore.atomTypeId[offset + i]; - } - residueStore.residueTypeId[ri] = residueMap.add(this.previousResname, atomTypeIdList, this.previousHetero // TODO - ); -}; -StructureBuilder.prototype.addAtom = function addAtom (modelindex, chainname, chainid, resname, resno, hetero, sstruc, inscode) { - var atomStore = this.structure.atomStore; - var residueStore = this.structure.residueStore; - var chainStore = this.structure.chainStore; - var modelStore = this.structure.modelStore; - var addModel = false; - var addChain = false; - var addResidue = false; - if (this.currentModelindex !== modelindex) { - addModel = true; - addChain = true; - addResidue = true; - this.mi += 1; - this.ci += 1; - this.ri += 1; - } - else if (this.currentChainid !== chainid) { - addChain = true; - addResidue = true; - this.ci += 1; - this.ri += 1; - } - else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) { - addResidue = true; - this.ri += 1; - } - this.ai += 1; - if (addModel) { - modelStore.growIfFull(); - modelStore.chainOffset[this.mi] = this.ci; - modelStore.chainCount[this.mi] = 0; - modelStore.count += 1; - chainStore.modelIndex[this.ci] = this.mi; - } - if (addChain) { - chainStore.growIfFull(); - chainStore.setChainname(this.ci, chainname); - chainStore.setChainid(this.ci, chainid); - chainStore.residueOffset[this.ci] = this.ri; - chainStore.residueCount[this.ci] = 0; - chainStore.count += 1; - chainStore.modelIndex[this.ci] = this.mi; - modelStore.chainCount[this.mi] += 1; - residueStore.chainIndex[this.ri] = this.ci; - } - if (addResidue) { - this.previousResname = this.currentResname; - this.previousHetero = this.currentHetero; - if (this.ri > 0) - { this.addResidueType(this.ri - 1); } - residueStore.growIfFull(); - residueStore.resno[this.ri] = resno; - if (sstruc !== undefined) { - residueStore.sstruc[this.ri] = sstruc.charCodeAt(0); - } - if (inscode !== undefined) { - residueStore.inscode[this.ri] = inscode.charCodeAt(0); - } - residueStore.atomOffset[this.ri] = this.ai; - residueStore.atomCount[this.ri] = 0; - residueStore.count += 1; - residueStore.chainIndex[this.ri] = this.ci; - chainStore.residueCount[this.ci] += 1; - } - atomStore.count += 1; - atomStore.residueIndex[this.ai] = this.ri; - residueStore.atomCount[this.ri] += 1; - this.currentModelindex = modelindex; - this.currentChainid = chainid; - this.currentResname = resname; - this.currentResno = resno; - this.currentInscode = inscode; - this.currentHetero = hetero; -}; -StructureBuilder.prototype.finalize = function finalize () { - this.previousResname = this.currentResname; - this.previousHetero = this.currentHetero; - if (this.ri > -1) - { this.addResidueType(this.ri); } -}; - -/** - * @file Structure Utils - * @author Alexander Rose - * @private - */ -function assignSecondaryStructure(structure, secStruct) { - if (!secStruct) - { return; } - if (Debug) - { Log.time('assignSecondaryStructure'); } - var chainnames = []; - structure.eachModel(function (mp) { - mp.eachChain(function (cp) { - chainnames.push(cp.chainname); - }); - }); - var chainnamesSorted = chainnames.slice().sort(); - var chainnamesIndex = []; - chainnamesSorted.forEach(function (c) { - chainnamesIndex.push(chainnames.indexOf(c)); - }); - // helix assignment - var helices = secStruct.helices.filter(function (h) { - return binarySearchIndexOf(chainnamesSorted, h[0]) >= 0; - }); - helices.sort(function (h1, h2) { - var c1 = h1[0]; - var c2 = h2[0]; - var r1 = h1[1]; - var r2 = h2[1]; - if (c1 === c2) { - if (r1 === r2) { - return 0; - } - else { - return r1 < r2 ? -1 : 1; - } - } - else { - var idx1 = binarySearchIndexOf(chainnamesSorted, c1); - var idx2 = binarySearchIndexOf(chainnamesSorted, c2); - return chainnamesIndex[idx1] < chainnamesIndex[idx2] ? -1 : 1; - } - }); - var residueStore = structure.residueStore; - structure.eachModel(function (mp) { - var i = 0; - var n = helices.length; - if (n === 0) - { return; } - var helix = helices[i]; - var helixRun = false; - var done = false; - mp.eachChain(function (cp) { - var chainChange = false; - if (cp.chainname === helix[0]) { - var count = cp.residueCount; - var offset = cp.residueOffset; - var end = offset + count; - for (var j = offset; j < end; ++j) { - if (residueStore.resno[j] === helix[1] && // resnoBeg - residueStore.getInscode(j) === helix[2] // inscodeBeg - ) { - helixRun = true; - } - if (helixRun) { - residueStore.sstruc[j] = helix[6]; - if (residueStore.resno[j] === helix[4] && // resnoEnd - residueStore.getInscode(j) === helix[5] // inscodeEnd - ) { - helixRun = false; - i += 1; - if (i < n) { - // must look at previous residues as - // residues may not be ordered by resno - j = offset - 1; - helix = helices[i]; - chainChange = cp.chainname !== helix[0]; - } - else { - done = true; - } - } - } - if (chainChange || done) - { return; } - } - } - }); - }); - // sheet assignment - var sheets = secStruct.sheets.filter(function (s) { - return binarySearchIndexOf(chainnamesSorted, s[0]) >= 0; - }); - sheets.sort(function (s1, s2) { - var c1 = s1[0]; - var c2 = s2[0]; - if (c1 === c2) - { return 0; } - var idx1 = binarySearchIndexOf(chainnamesSorted, c1); - var idx2 = binarySearchIndexOf(chainnamesSorted, c2); - return chainnamesIndex[idx1] < chainnamesIndex[idx2] ? -1 : 1; - }); - var strandCharCode = 'e'.charCodeAt(0); - structure.eachModel(function (mp) { - var i = 0; - var n = sheets.length; - if (n === 0) - { return; } - var sheet = sheets[i]; - var sheetRun = false; - var done = false; - mp.eachChain(function (cp) { - var chainChange = false; - if (cp.chainname === sheet[0]) { - var count = cp.residueCount; - var offset = cp.residueOffset; - var end = offset + count; - for (var j = offset; j < end; ++j) { - if (residueStore.resno[j] === sheet[1] && // resnoBeg - residueStore.getInscode(j) === sheet[2] // inscodeBeg - ) { - sheetRun = true; - } - if (sheetRun) { - residueStore.sstruc[j] = strandCharCode; - if (residueStore.resno[j] === sheet[4] && // resnoEnd - residueStore.getInscode(j) === sheet[5] // inscodeEnd - ) { - sheetRun = false; - i += 1; - if (i < n) { - // must look at previous residues as - // residues may not be ordered by resno - j = offset - 1; - sheet = sheets[i]; - chainChange = cp.chainname !== sheet[0]; - } - else { - done = true; - } - } - } - if (chainChange || done) - { return; } - } - } - }); - }); - if (Debug) - { Log.timeEnd('assignSecondaryStructure'); } -} -var calculateSecondaryStructure = (function () { - // Implementation for proteins based on "pv" - // - // assigns secondary structure information based on a simple and very fast - // algorithm published by Zhang and Skolnick in their TM-align paper. - // Reference: - // - // TM-align: a protein structure alignment algorithm based on the Tm-score - // (2005) NAR, 33(7) 2302-2309 - var zhangSkolnickSS = function (polymer, i, distances, delta) { - var structure = polymer.structure; - var offset = polymer.residueIndexStart; - var rp1 = structure.getResidueProxy(); - var rp2 = structure.getResidueProxy(); - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - for (var j = Math.max(0, i - 2); j <= i; ++j) { - for (var k = 2; k < 5; ++k) { - if (j + k >= polymer.residueCount) { - continue; - } - rp1.index = offset + j; - rp2.index = offset + j + k; - ap1.index = rp1.traceAtomIndex; - ap2.index = rp2.traceAtomIndex; - var d = ap1.distanceTo(ap2); - if (Math.abs(d - distances[k - 2]) > delta) { - return false; - } - } - } - return true; - }; - var isHelical = function (polymer, i) { - var helixDistances = [5.45, 5.18, 6.37]; - var helixDelta = 2.1; - return zhangSkolnickSS(polymer, i, helixDistances, helixDelta); - }; - var isSheet = function (polymer, i) { - var sheetDistances = [6.1, 10.4, 13.0]; - var sheetDelta = 1.42; - return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta); - }; - var proteinPolymer = function (p) { - var residueStore = p.residueStore; - var offset = p.residueIndexStart; - for (var i = 0, il = p.residueCount; i < il; ++i) { - var sstruc = 'c'; - if (isHelical(p, i)) { - sstruc = 'h'; - } - else if (isSheet(p, i)) { - sstruc = 'e'; - } - residueStore.sstruc[offset + i] = sstruc.charCodeAt(0); - } - }; - var cgPolymer = function (p) { - var localAngle = 20; - var centerDist = 2.0; - var residueStore = p.residueStore; - var offset = p.residueIndexStart; - var helixbundle = new Helixbundle(p); - var pos = helixbundle.position; - var c1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var c2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - for (var i = 0, il = p.residueCount; i < il; ++i) { - c1.fromArray(pos.center, i * 3); // TODO - c2.fromArray(pos.center, i * 3 + 3); // TODO - var d = c1.distanceTo(c2); - if (d < centerDist && d > 1.0 && pos.bending[i] < localAngle) { - residueStore.sstruc[offset + i] = 'h'.charCodeAt(0); - residueStore.sstruc[offset + i + 1] = 'h'.charCodeAt(0); - } - } - }; - return function calculateSecondaryStructure(structure) { - if (Debug) - { Log.time('calculateSecondaryStructure'); } - structure.eachPolymer(function (p) { - // assign secondary structure - if (p.residueCount < 4) - { return; } - if (p.isCg()) { - cgPolymer(p); - } - else if (p.isProtein()) { - proteinPolymer(p); - } - else { - return; - } - // set lone secondary structure assignments to "c" - var prevSstruc; - var sstrucCount = 0; - p.eachResidue(function (r) { - if (r.sstruc === prevSstruc) { - sstrucCount += 1; - } - else { - if (sstrucCount === 1) { - r.index -= 1; - r.sstruc = 'c'; - } - sstrucCount = 1; - prevSstruc = r.sstruc; - } - }); - }); - if (Debug) - { Log.timeEnd('calculateSecondaryStructure'); } - }; -}()); -// const ChainnameAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + -// "abcdefghijklmnopqrstuvwxyz" + -// "0123456789"; -var ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; -function getChainname(index) { - var n = ChainnameAlphabet.length; - var j = index; - var k = 0; - var chainname = ChainnameAlphabet[j % n]; - while (j >= n) { - j = Math.floor(j / n); - chainname += ChainnameAlphabet[j % n]; - k += 1; - } - if (k >= 5) { - Log.warn('chainname overflow'); - } - return chainname; -} -function calculateChainnames(structure, useExistingBonds) { - if ( useExistingBonds === void 0 ) useExistingBonds = false; - - if (Debug) - { Log.time('calculateChainnames'); } - var doAutoChainName = true; - structure.eachChain(function (c) { - if (c.chainname) - { doAutoChainName = false; } - }); - if (doAutoChainName) { - var modelStore = structure.modelStore; - var chainStore = structure.chainStore; - var residueStore = structure.residueStore; - var addChain = function (mIndex, chainname, rOffset, rCount) { - var ci = chainStore.count; - for (var i = 0; i < rCount; ++i) { - residueStore.chainIndex[rOffset + i] = ci; - } - chainStore.growIfFull(); - chainStore.modelIndex[ci] = mIndex; - chainStore.setChainname(ci, chainname); - chainStore.setChainid(ci, chainname); - chainStore.residueOffset[ci] = rOffset; - chainStore.residueCount[ci] = rCount; - chainStore.count += 1; - modelStore.chainCount[mIndex] += 1; - }; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var i = 0; - var mi = 0; - var rStart = 0; - var rEnd = 0; - var chainData = []; - if (residueStore.count === 1) { - chainData.push({ - mIndex: 0, - chainname: 'A', - rStart: 0, - rCount: 1 - }); - } - else { - structure.eachResidueN(2, function (rp1, rp2) { - var newChain = false; - var bbType1 = rp1.backboneType; - var bbType2 = rp2.backboneType; - var bbTypeUnk = UnknownBackboneType; - rEnd = rp1.index; - if (rp1.modelIndex !== rp2.modelIndex) { - newChain = true; - } - else if (rp1.moleculeType !== rp2.moleculeType) { - newChain = true; - } - else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) { - ap1.index = rp1.backboneEndAtomIndex; - ap2.index = rp2.backboneStartAtomIndex; - if (useExistingBonds) { - newChain = !ap1.hasBondTo(ap2); - } - else { - newChain = !ap1.connectedTo(ap2); - } - } - // current chain goes to end of the structure - if (!newChain && rp2.index === residueStore.count - 1) { - newChain = true; - rEnd = rp2.index; - } - if (newChain) { - chainData.push({ - mIndex: mi, - chainname: getChainname(i), - rStart: rStart, - rCount: rEnd - rStart + 1 - }); - i += 1; - if (rp1.modelIndex !== rp2.modelIndex) { - i = 0; - mi += 1; - } - // new chain for the last residue of the structure - if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) { - chainData.push({ - mIndex: mi, - chainname: getChainname(i), - rStart: residueStore.count - 1, - rCount: 1 - }); - } - rStart = rp2.index; - rEnd = rp2.index; - } - }); - } - // - chainStore.count = 0; - chainData.forEach(function (d) { - addChain(d.mIndex, d.chainname, d.rStart, d.rCount); - }); - var chainOffset = 0; - structure.eachModel(function (mp) { - modelStore.chainOffset[mp.index] = chainOffset; - modelStore.chainCount[mp.index] -= 1; - chainOffset += modelStore.chainCount[mp.index]; - }); - } - if (Debug) - { Log.timeEnd('calculateChainnames'); } -} -function calculateBonds(structure) { - if (Debug) - { Log.time('calculateBonds'); } - calculateBondsWithin(structure); - calculateBondsBetween(structure); - if (Debug) - { Log.timeEnd('calculateBonds'); } -} -var BondOrderTable = { - 'HIS|CD2|CG': 2, - 'HIS|CE1|ND1': 2, - 'ARG|CZ|NH2': 2, - 'PHE|CE1|CZ': 2, - 'PHE|CD2|CE2': 2, - 'PHE|CD1|CG': 2, - 'TRP|CD1|CG': 2, - 'TRP|CD2|CE2': 2, - 'TRP|CE3|CZ3': 2, - 'TRP|CH2|CZ2': 2, - 'ASN|CG|OD1': 2, - 'GLN|CD|OE1': 2, - 'TYR|CD1|CG': 2, - 'TYR|CD2|CE2': 2, - 'TYR|CE1|CZ': 2, - 'ASP|CG|OD1': 2, - 'GLU|CD|OE1': 2, - 'G|C8|N7': 2, - 'G|C4|C5': 2, - 'G|C2|N3': 2, - 'G|C6|O6': 2, - 'C|C4|N3': 2, - 'C|C5|C6': 2, - 'C|C2|O2': 2, - 'A|C2|N3': 2, - 'A|C6|N1': 2, - 'A|C4|C5': 2, - 'A|C8|N7': 2, - 'U|C5|C6': 2, - 'U|C2|O2': 2, - 'U|C4|O4': 2, - 'DG|C8|N7': 2, - 'DG|C4|C5': 2, - 'DG|C2|N3': 2, - 'DG|C6|O6': 2, - 'DC|C4|N3': 2, - 'DC|C5|C6': 2, - 'DC|C2|O2': 2, - 'DA|C2|N3': 2, - 'DA|C6|N1': 2, - 'DA|C4|C5': 2, - 'DA|C8|N7': 2, - 'DT|C5|C6': 2, - 'DT|C2|O2': 2, - 'DT|C4|O4': 2 -}; -function getBondOrderFromTable(resname, atomname1, atomname2) { - var assign; - - (assign = atomname1 < atomname2 ? [atomname1, atomname2] : [atomname2, atomname1], atomname1 = assign[0], atomname2 = assign[1]); - if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') - { return 2; } - if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') - { return 2; } - return BondOrderTable[(resname + "|" + atomname1 + "|" + atomname2)] || 1; -} -function calculateResidueBonds(r) { - var structure = r.structure; - var a1 = structure.getAtomProxy(); - var a2 = structure.getAtomProxy(); - var count = r.atomCount; - var offset = r.atomOffset; - var end = offset + count; - var end1 = end - 1; - var atomIndices1 = []; - var atomIndices2 = []; - var bondOrders = []; - if (count > 500) { - if (Debug) - { Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName()); } - } - else { - if (count > 50) { - var kdtree = new Kdtree$1(r, true); - var radius = r.isCg() ? 1.2 : 2.3; - for (var i = offset; i < end1; ++i) { - a1.index = i; - var maxd = a1.covalent + radius + 0.3; - var nearestAtoms = kdtree.nearest(a1, Infinity, maxd * maxd); // TODO - var m = nearestAtoms.length; - for (var j = 0; j < m; ++j) { - a2.index = nearestAtoms[j].index; - if (a1.index < a2.index) { - if (a1.connectedTo(a2)) { - atomIndices1.push(a1.index - offset); - atomIndices2.push(a2.index - offset); - bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname)); - } - } - } - } - } - else { - for (var i$1 = offset; i$1 < end1; ++i$1) { - a1.index = i$1; - for (var j$1 = i$1 + 1; j$1 <= end1; ++j$1) { - a2.index = j$1; - if (a1.connectedTo(a2)) { - atomIndices1.push(i$1 - offset); - atomIndices2.push(j$1 - offset); - bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname)); - } - } - } - } - } - return { - atomIndices1: atomIndices1, - atomIndices2: atomIndices2, - bondOrders: bondOrders - }; -} -function calculateAtomBondMap(structure) { - if (Debug) - { Log.time('calculateAtomBondMap'); } - var atomBondMap = []; - structure.eachBond(function (bp) { - var ai1 = bp.atomIndex1; - var ai2 = bp.atomIndex2; - if (atomBondMap[ai1] === undefined) - { atomBondMap[ai1] = []; } - atomBondMap[ai1][ai2] = bp.index; - }); - if (Debug) - { Log.timeEnd('calculateAtomBondMap'); } - return atomBondMap; -} -function calculateBondsWithin(structure, onlyAddRung) { - if ( onlyAddRung === void 0 ) onlyAddRung = false; - - if (Debug) - { Log.time('calculateBondsWithin'); } - var bondStore = structure.bondStore; - var rungBondStore = structure.rungBondStore; - var rungAtomSet = structure.getAtomSet(false); - var a1 = structure.getAtomProxy(); - var a2 = structure.getAtomProxy(); - var bp = structure.getBondProxy(); - var atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure); - structure.eachResidue(function (r) { - if (!onlyAddRung && atomBondMap) { - var count = r.atomCount; - var offset = r.atomOffset; - if (count > 500) { - Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName()); - return; - } - var bonds = r.getBonds(); - var atomIndices1 = bonds.atomIndices1; - var atomIndices2 = bonds.atomIndices2; - var bondOrders = bonds.bondOrders; - var nn = atomIndices1.length; - for (var i = 0; i < nn; ++i) { - var rai1 = atomIndices1[i]; - var rai2 = atomIndices2[i]; - var ai1 = rai1 + offset; - var ai2 = rai2 + offset; - var tmp = atomBondMap[ai1]; - if (tmp !== undefined && tmp[ai2] !== undefined) { - bp.index = tmp[ai2]; - var residueTypeBondIndex = r.residueType.getBondIndex(rai1, rai2); // TODO - // overwrite residueType bondOrder with value from existing bond - bondOrders[residueTypeBondIndex] = bp.bondOrder; - } - else { - a1.index = ai1; - a2.index = ai2; - // only add bond if not already in bondStore - bondStore.addBond(a1, a2, bondOrders[i]); - } - } - } - // get RNA/DNA rung pseudo bonds - var traceAtomIndex = r.residueType.traceAtomIndex; - var rungEndAtomIndex = r.residueType.rungEndAtomIndex; - if (traceAtomIndex !== -1 && rungEndAtomIndex !== -1) { - a1.index = r.traceAtomIndex; - a2.index = r.rungEndAtomIndex; - rungBondStore.addBond(a1, a2); - rungAtomSet.set(a1.index); - rungAtomSet.set(a2.index); - } - }); - structure.atomSetDict.rung = rungAtomSet; - if (Debug) - { Log.timeEnd('calculateBondsWithin'); } -} -function calculateBondsBetween(structure, onlyAddBackbone, useExistingBonds) { - if ( onlyAddBackbone === void 0 ) onlyAddBackbone = false; - if ( useExistingBonds === void 0 ) useExistingBonds = false; - - if (Debug) - { Log.time('calculateBondsBetween'); } - var bondStore = structure.bondStore; - var backboneBondStore = structure.backboneBondStore; - var backboneAtomSet = structure.getAtomSet(false); - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - if (backboneBondStore.count === 0) { - backboneBondStore.resize(structure.residueStore.count); - } - function addBondIfConnected(rp1, rp2) { - var bbType1 = rp1.backboneType; - var bbType2 = rp2.backboneType; - if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) { - ap1.index = rp1.backboneEndAtomIndex; - ap2.index = rp2.backboneStartAtomIndex; - if ((useExistingBonds && ap1.hasBondTo(ap2)) || ap1.connectedTo(ap2)) { - if (!onlyAddBackbone) { - bondStore.addBond(ap1, ap2, 1); // assume single bond - } - ap1.index = rp1.traceAtomIndex; - ap2.index = rp2.traceAtomIndex; - backboneBondStore.addBond(ap1, ap2); - backboneAtomSet.set(ap1.index); - backboneAtomSet.set(ap2.index); - } - } - } - structure.eachResidueN(2, addBondIfConnected); - var rp1 = structure.getResidueProxy(); - var rp2 = structure.getResidueProxy(); - // check for cyclic chains - structure.eachChain(function (cp) { - if (cp.residueCount === 0) - { return; } - rp1.index = cp.residueOffset; - rp2.index = cp.residueOffset + cp.residueCount - 1; - addBondIfConnected(rp2, rp1); - }); - structure.atomSetDict.backbone = backboneAtomSet; - if (!onlyAddBackbone) { - if (Debug) - { Log.time('calculateBondsBetween inter'); } - var spatialHash = structure.spatialHash; - structure.eachResidue(function (rp) { - if (rp.backboneType === UnknownBackboneType && !rp.isWater()) { - rp.eachAtom(function (ap) { - if (ap.isMetal()) - { return; } - spatialHash.eachWithin(ap.x, ap.y, ap.z, 4, function (idx) { - ap2.index = idx; - if (ap.modelIndex === ap2.modelIndex && - ap.residueIndex !== ap2.residueIndex && - !ap2.isMetal()) { - bondStore.addBondIfConnected(ap, ap2, 1); // assume single bond - } - }); - }); - } - }); - if (Debug) - { Log.timeEnd('calculateBondsBetween inter'); } - } - if (Debug) - { Log.timeEnd('calculateBondsBetween'); } -} -function buildUnitcellAssembly(structure) { - if (!structure.unitcell) - { return; } - if (Debug) - { Log.time('buildUnitcellAssembly'); } - var uc = structure.unitcell; - var structureCenterFrac = structure.center.clone().applyMatrix4(uc.cartToFrac); - var centerFrac = structureCenterFrac.clone().floor(); - var symopDict = getSymmetryOperations(uc.spacegroup); - var centerFracSymop = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var positionFracSymop = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - function getMatrixList(shift) { - var matrixList = []; - Object.keys(symopDict).forEach(function (name) { - var m = symopDict[name].clone(); - centerFracSymop.copy(structureCenterFrac).applyMatrix4(m).floor(); - positionFracSymop.setFromMatrixPosition(m); - positionFracSymop.sub(centerFracSymop); - positionFracSymop.add(centerFrac); - if (shift) - { positionFracSymop.add(shift); } - m.setPosition(positionFracSymop); - m.multiplyMatrices(uc.fracToCart, m); - m.multiply(uc.cartToFrac); - matrixList.push(m); - }); - return matrixList; - } - var unitcellAssembly = new Assembly('UNITCELL'); - var unitcellMatrixList = getMatrixList(); - var ncsMatrixList = []; - if (structure.biomolDict.NCS) { - ncsMatrixList.push.apply(ncsMatrixList, [ new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() ].concat( structure.biomolDict.NCS.partList[0].matrixList )); - var ncsUnitcellMatrixList = []; - unitcellMatrixList.forEach(function (sm) { - ncsMatrixList.forEach(function (nm) { - ncsUnitcellMatrixList.push(sm.clone().multiply(nm)); - }); - }); - unitcellAssembly.addPart(ncsUnitcellMatrixList); - } - else { - unitcellAssembly.addPart(unitcellMatrixList); - } - var vec = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var supercellAssembly = new Assembly('SUPERCELL'); - var supercellMatrixList = Array.prototype.concat.call(getMatrixList(vec.set(1, 0, 0)), // 655 - getMatrixList(vec.set(0, 1, 0)), // 565 - getMatrixList(vec.set(0, 0, 1)), // 556 - getMatrixList(vec.set(-1, 0, 0)), // 455 - getMatrixList(vec.set(0, -1, 0)), // 545 - getMatrixList(vec.set(0, 0, -1)), // 554 - getMatrixList(vec.set(1, 1, 0)), // 665 - getMatrixList(vec.set(1, 0, 1)), // 656 - getMatrixList(vec.set(0, 1, 1)), // 566 - getMatrixList(vec.set(-1, -1, 0)), // 445 - getMatrixList(vec.set(-1, 0, -1)), // 454 - getMatrixList(vec.set(0, -1, -1)), // 544 - getMatrixList(vec.set(1, -1, -1)), // 644 - getMatrixList(vec.set(1, 1, -1)), // 664 - getMatrixList(vec.set(1, -1, 1)), // 646 - getMatrixList(vec.set(-1, 1, 1)), // 466 - getMatrixList(vec.set(-1, -1, 1)), // 446 - getMatrixList(vec.set(-1, 1, -1)), // 464 - getMatrixList(vec.set(0, 1, -1)), // 564 - getMatrixList(vec.set(0, -1, 1)), // 546 - getMatrixList(vec.set(1, 0, -1)), // 654 - getMatrixList(vec.set(-1, 0, 1)), // 456 - getMatrixList(vec.set(1, -1, 0)), // 645 - getMatrixList(vec.set(-1, 1, 0)), // 465 - getMatrixList(), // 555 - getMatrixList(vec.set(1, 1, 1)), // 666 - getMatrixList(vec.set(-1, -1, -1)) // 444 - ); - if (structure.biomolDict.NCS) { - var ncsSupercellMatrixList = []; - supercellMatrixList.forEach(function (sm) { - ncsMatrixList.forEach(function (nm) { - ncsSupercellMatrixList.push(sm.clone().multiply(nm)); - }); - }); - supercellAssembly.addPart(ncsSupercellMatrixList); - } - else { - supercellAssembly.addPart(supercellMatrixList); - } - structure.biomolDict.UNITCELL = unitcellAssembly; - structure.biomolDict.SUPERCELL = supercellAssembly; - if (Debug) - { Log.timeEnd('buildUnitcellAssembly'); } -} -var elm1 = ['H', 'C', 'O', 'N', 'S', 'P']; -var elm2 = ['NA', 'CL', 'FE']; -function guessElement(atomName) { - var at = atomName.trim().toUpperCase(); - // parseInt('C') -> NaN; (NaN > -1) -> false - if (parseInt(at.charAt(0)) > -1) - { at = at.substr(1); } - // parse again to check for a second integer - if (parseInt(at.charAt(0)) > -1) - { at = at.substr(1); } - var n = at.length; - if (n === 0) - { return ''; } - if (n === 1) - { return at; } - if (n === 2) { - if (elm2.indexOf(at) !== -1) - { return at; } - if (elm1.indexOf(at[0]) !== -1) - { return at[0]; } - } - if (n >= 3) { - if (elm1.indexOf(at[0]) !== -1) - { return at[0]; } - } - return ''; -} -/** - * Assigns ResidueType bonds. - * @param {Structure} structure - the structure object - * @return {undefined} - */ -function assignResidueTypeBonds(structure) { - // if( Debug ) Log.time( "assignResidueTypeBonds" ) - var bondHash = structure.bondHash; // TODO - var countArray = bondHash.countArray; - var offsetArray = bondHash.offsetArray; - var indexArray = bondHash.indexArray; - var bp = structure.getBondProxy(); - structure.eachResidue(function (rp) { - var residueType = rp.residueType; - if (residueType.bonds !== undefined) - { return; } - var atomOffset = rp.atomOffset; - var atomIndices1 = []; - var atomIndices2 = []; - var bondOrders = []; - var bondDict = {}; - var nextAtomOffset = atomOffset + rp.atomCount; - rp.eachAtom(function (ap) { - var index = ap.index; - var offset = offsetArray[index]; - var count = countArray[index]; - for (var i = 0, il = count; i < il; ++i) { - bp.index = indexArray[offset + i]; - var idx1 = bp.atomIndex1; - if (idx1 < atomOffset || idx1 >= nextAtomOffset) { - // Don't add bonds outside of this resiude - continue; - } - var idx2 = bp.atomIndex2; - if (idx2 < atomOffset || idx2 >= nextAtomOffset) { - continue; - } - if (idx1 > idx2) { - var tmp = idx2; - idx2 = idx1; - idx1 = tmp; - } - var hash = idx1 + '|' + idx2; - if (bondDict[hash] === undefined) { - bondDict[hash] = true; - atomIndices1.push(idx1 - atomOffset); - atomIndices2.push(idx2 - atomOffset); - bondOrders.push(bp.bondOrder); - } - } - }); - residueType.bonds = { - atomIndices1: atomIndices1, - atomIndices2: atomIndices2, - bondOrders: bondOrders - }; - }); - // if( Debug ) Log.timeEnd( "assignResidueTypeBonds" ) -} -function concatStructures(name) { - var structures = [], len = arguments.length - 1; - while ( len-- > 0 ) structures[ len ] = arguments[ len + 1 ]; - - if (Debug) - { Log.time("concatStructures"); } - var s = new Structure(name, ''); - var sb = new StructureBuilder(s); - var atomStore = s.atomStore; - var atomMap = s.atomMap; - atomStore.addField('formalCharge', 1, 'int8'); - atomStore.addField('partialCharge', 1, 'float32'); - var atomIndexDict = {}; - var idx = 0; - var atomCount = 0; - var modelCount = 0; - structures.forEach(function (structure) { - structure.eachAtom(function (a) { - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(a.atomname, a.element); - atomStore.x[idx] = a.x; - atomStore.y[idx] = a.y; - atomStore.z[idx] = a.z; - atomStore.serial[idx] = a.serial; - atomStore.formalCharge[idx] = a.formalCharge; - atomStore.partialCharge[idx] = a.partialCharge; - atomStore.altloc[idx] = a.altloc; - atomStore.occupancy[idx] = a.occupancy; - atomStore.bfactor[idx] = a.bfactor; - sb.addAtom(a.modelIndex + modelCount, a.chainname, a.chainid, a.resname, a.resno, a.hetero === 1, a.sstruc, a.inscode); - atomIndexDict[a.index + atomCount] = idx; - idx += 1; - }); - atomCount += structure.atomStore.count; - modelCount += structure.modelStore.count; - }); - var bondStore = s.bondStore; - var a1 = s.getAtomProxy(); - var a2 = s.getAtomProxy(); - atomCount = 0; - structures.forEach(function (structure) { - structure.eachBond(function (b) { - a1.index = atomIndexDict[b.atomIndex1 + atomCount]; - a2.index = atomIndexDict[b.atomIndex2 + atomCount]; - bondStore.addBond(a1, a2, b.bondOrder); - }); - atomCount += structure.atomStore.count; - }); - sb.finalize(); - calculateBondsBetween(s, true); // calculate backbone bonds - calculateBondsWithin(s, true); // calculate rung bonds - s.finalizeAtoms(); - s.finalizeBonds(); - assignResidueTypeBonds(s); - if (Debug) - { Log.timeEnd("concatStructures"); } - return s; -} - -/** - * @file Atom Type - * @author Alexander Rose - * @private - */ -// Li, Na, K, Rb, Cs Fr -var AlkaliMetals = [3, 11, 19, 37, 55, 87]; -// Be, Mg, Ca, Sr, Ba, Ra -var AlkalineEarthMetals = [4, 12, 20, 38, 56, 88]; -// C, P, S, Se -var PolyatomicNonmetals = [6, 15, 16, 34 ]; -// H, N, O, F, Cl, Br, I -var DiatomicNonmetals = [1, 7, 8, 9, 17, 35, 53]; -// He, Ne, Ar, Kr, Xe, Rn -var NobleGases = [2, 10, 18, 36, 54, 86]; -// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn -var PostTransitionMetals = [13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112]; -// B, Si, Ge, As, Sb, Te, At -var Metalloids = [5, 14, 32, 33, 51, 52, 85]; -// F, Cl, Br, I, At -var Halogens = [9, 17, 35, 53, 85]; -/** - * Atom type - */ -var AtomType = function AtomType(structure, atomname, element) { - this.structure = structure; - this.atomname = atomname; - element = element || guessElement(atomname); - this.element = element; - this.number = AtomicNumbers[element] || DefaultAtomicNumber; - this.vdw = VdwRadii[this.number] || DefaultVdwRadius; - this.covalent = CovalentRadii[this.number] || DefaultCovalentRadius; -}; -AtomType.prototype.getDefaultValence = function getDefaultValence () { - var vl = Valences[this.number]; - return vl ? vl[0] : DefaultValence; -}; -AtomType.prototype.getValenceList = function getValenceList () { - return Valences[this.number] || []; -}; -AtomType.prototype.getOuterShellElectronCount = function getOuterShellElectronCount () { - return OuterShellElectronCounts[this.number] || DefaultOuterShellElectronCount; -}; -AtomType.prototype.isMetal = function isMetal () { - return (this.isAlkaliMetal() || - this.isAlkalineEarthMetal() || - this.isLanthanide() || - this.isActinide() || - this.isTransitionMetal() || - this.isPostTransitionMetal()); -}; -AtomType.prototype.isNonmetal = function isNonmetal () { - return (this.isDiatomicNonmetal() || - this.isPolyatomicNonmetal() || - this.isNobleGas()); -}; -AtomType.prototype.isMetalloid = function isMetalloid () { - return Metalloids.includes(this.number); -}; -AtomType.prototype.isHalogen = function isHalogen () { - return Halogens.includes(this.number); -}; -AtomType.prototype.isDiatomicNonmetal = function isDiatomicNonmetal () { - return DiatomicNonmetals.includes(this.number); -}; -AtomType.prototype.isPolyatomicNonmetal = function isPolyatomicNonmetal () { - return PolyatomicNonmetals.includes(this.number); -}; -AtomType.prototype.isAlkaliMetal = function isAlkaliMetal () { - return AlkaliMetals.includes(this.number); -}; -AtomType.prototype.isAlkalineEarthMetal = function isAlkalineEarthMetal () { - return AlkalineEarthMetals.includes(this.number); -}; -AtomType.prototype.isNobleGas = function isNobleGas () { - return NobleGases.includes(this.number); -}; -AtomType.prototype.isTransitionMetal = function isTransitionMetal () { - var no = this.number; - return ((no >= 21 && no <= 29) || - (no >= 39 && no <= 47) || - (no >= 72 && no <= 79) || - (no >= 104 && no <= 108)); -}; -AtomType.prototype.isPostTransitionMetal = function isPostTransitionMetal () { - return PostTransitionMetals.includes(this.number); -}; -AtomType.prototype.isLanthanide = function isLanthanide () { - return this.number >= 57 && this.number <= 71; -}; -AtomType.prototype.isActinide = function isActinide () { - return this.number >= 89 && this.number <= 103; -}; - -/** - * @file Atom Map - * @author Alexander Rose - * @private - */ -function getHash(atomname, element) { - return atomname + '|' + element; -} -var AtomMap = function AtomMap(structure) { - this.structure = structure; - this.dict = {}; - this.list = []; - this.structure = structure; -}; -AtomMap.prototype.add = function add (atomname, element) { - atomname = atomname.toUpperCase(); - if (!element) { - element = guessElement(atomname); - } - else { - element = element.toUpperCase(); - } - var hash = getHash(atomname, element); - var id = this.dict[hash]; - if (id === undefined) { - var atomType = new AtomType(this.structure, atomname, element); - id = this.list.length; - this.dict[hash] = id; - this.list.push(atomType); - } - return id; -}; -AtomMap.prototype.get = function get (id) { - return this.list[id]; -}; - -/** - * @file Residue Type - * @author Alexander Rose - * @author Fred Ludlow - * @private - */ -/** - * Residue type - */ -var ResidueType = function ResidueType(structure, resname, atomTypeIdList, hetero, chemCompType, bonds) { - this.structure = structure; - // Sparse array containing the reference atom index for each bond. - this.bondReferenceAtomIndices = []; - this.resname = resname; - this.atomTypeIdList = atomTypeIdList; - this.hetero = hetero ? 1 : 0; - this.chemCompType = chemCompType; - this.bonds = bonds; - this.atomCount = atomTypeIdList.length; - this.moleculeType = this.getMoleculeType(); - this.backboneType = this.getBackboneType(0); - this.backboneEndType = this.getBackboneType(-1); - this.backboneStartType = this.getBackboneType(1); - this.backboneIndexList = this.getBackboneIndexList(); - var atomnames = ResidueTypeAtoms[this.backboneType]; - var atomnamesStart = ResidueTypeAtoms[this.backboneStartType]; - var atomnamesEnd = ResidueTypeAtoms[this.backboneEndType]; - var traceIndex = this.getAtomIndexByName(atomnames.trace); - this.traceAtomIndex = defaults(traceIndex, -1); - var dir1Index = this.getAtomIndexByName(atomnames.direction1); - this.direction1AtomIndex = defaults(dir1Index, -1); - var dir2Index = this.getAtomIndexByName(atomnames.direction2); - this.direction2AtomIndex = defaults(dir2Index, -1); - var bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart); - this.backboneStartAtomIndex = defaults(bbStartIndex, -1); - var bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd); - this.backboneEndAtomIndex = defaults(bbEndIndex, -1); - var rungEndIndex; - if (PurinBases.includes(resname)) { - rungEndIndex = this.getAtomIndexByName('N1'); - } - else { - rungEndIndex = this.getAtomIndexByName('N3'); - } - this.rungEndAtomIndex = defaults(rungEndIndex, -1); -}; -ResidueType.prototype.getBackboneIndexList = function getBackboneIndexList () { - var backboneIndexList = []; - var atomnameList; - switch (this.moleculeType) { - case ProteinType: - atomnameList = ProteinBackboneAtoms; - break; - case RnaType: - case DnaType: - atomnameList = NucleicBackboneAtoms; - break; - default: - return backboneIndexList; - } - var atomMap = this.structure.atomMap; - var atomTypeIdList = this.atomTypeIdList; - for (var i = 0, il = this.atomCount; i < il; ++i) { - var atomType = atomMap.get(atomTypeIdList[i]); - if (atomnameList.includes(atomType.atomname)) { - backboneIndexList.push(i); - } - } - return backboneIndexList; -}; -ResidueType.prototype.getMoleculeType = function getMoleculeType () { - if (this.isProtein()) { - return ProteinType; - } - else if (this.isRna()) { - return RnaType; - } - else if (this.isDna()) { - return DnaType; - } - else if (this.isWater()) { - return WaterType; - } - else if (this.isIon()) { - return IonType; - } - else if (this.isSaccharide()) { - return SaccharideType; - } - else { - return UnknownType; - } -}; -ResidueType.prototype.getBackboneType = function getBackboneType (position) { - if (this.hasProteinBackbone(position)) { - return ProteinBackboneType; - } - else if (this.hasRnaBackbone(position)) { - return RnaBackboneType; - } - else if (this.hasDnaBackbone(position)) { - return DnaBackboneType; - } - else if (this.hasCgProteinBackbone(position)) { - return CgProteinBackboneType; - } - else if (this.hasCgRnaBackbone(position)) { - return CgRnaBackboneType; - } - else if (this.hasCgDnaBackbone(position)) { - return CgDnaBackboneType; - } - else { - return UnknownBackboneType; - } -}; -ResidueType.prototype.isProtein = function isProtein () { - if (this.chemCompType) { - return ChemCompProtein.includes(this.chemCompType); - } - else { - return (this.hasAtomWithName('CA', 'C', 'N') || - AA3.includes(this.resname)); - } -}; -ResidueType.prototype.isCg = function isCg () { - var backboneType = this.backboneType; - return (backboneType === CgProteinBackboneType || - backboneType === CgRnaBackboneType || - backboneType === CgDnaBackboneType); -}; -ResidueType.prototype.isNucleic = function isNucleic () { - return this.isRna() || this.isDna(); -}; -ResidueType.prototype.isRna = function isRna () { - if (this.chemCompType) { - return ChemCompRna.includes(this.chemCompType); - } - else if (this.hetero === 1) { - return false; - } - else { - return (this.hasAtomWithName(['P', "O3'", 'O3*'], ["C4'", 'C4*'], ["O2'", 'O2*', "F2'", 'F2*']) || - (RnaBases.includes(this.resname) && - (this.hasAtomWithName(["O2'", 'O2*', "F2'", 'F2*'])))); - } -}; -ResidueType.prototype.isDna = function isDna () { - if (this.chemCompType) { - return ChemCompDna.includes(this.chemCompType); - } - else if (this.hetero === 1) { - return false; - } - else { - return ((this.hasAtomWithName(['P', "O3'", 'O3*'], ["C3'", 'C3*']) && - !this.hasAtomWithName(["O2'", 'O2*', "F2'", 'F2*'])) || - DnaBases.includes(this.resname)); - } -}; -ResidueType.prototype.isHetero = function isHetero () { - return this.hetero === 1; -}; -ResidueType.prototype.isIon = function isIon () { - return IonNames.includes(this.resname); -}; -ResidueType.prototype.isWater = function isWater () { - return WaterNames.includes(this.resname); -}; -ResidueType.prototype.isSaccharide = function isSaccharide () { - if (this.chemCompType) { - return ChemCompSaccharide.includes(this.chemCompType); - } - else { - return SaccharideNames.includes(this.resname); - } -}; -ResidueType.prototype.isStandardAminoacid = function isStandardAminoacid () { - return AA3.includes(this.resname); -}; -ResidueType.prototype.isStandardBase = function isStandardBase () { - return Bases.includes(this.resname); -}; -ResidueType.prototype.hasBackboneAtoms = function hasBackboneAtoms (position, type) { - var atomnames = ResidueTypeAtoms[type]; - if (position === -1) { - return this.hasAtomWithName(atomnames.trace, atomnames.backboneEnd, atomnames.direction1, atomnames.direction2); - } - else if (position === 0) { - return this.hasAtomWithName(atomnames.trace, atomnames.direction1, atomnames.direction2); - } - else if (position === 1) { - return this.hasAtomWithName(atomnames.trace, atomnames.backboneStart, atomnames.direction1, atomnames.direction2); - } - else { - return this.hasAtomWithName(atomnames.trace, atomnames.backboneStart, atomnames.backboneEnd, atomnames.direction1, atomnames.direction2); - } -}; -ResidueType.prototype.hasProteinBackbone = function hasProteinBackbone (position) { - return (this.isProtein() && - this.hasBackboneAtoms(position, ProteinBackboneType)); -}; -ResidueType.prototype.hasRnaBackbone = function hasRnaBackbone (position) { - return (this.isRna() && - this.hasBackboneAtoms(position, RnaBackboneType)); -}; -ResidueType.prototype.hasDnaBackbone = function hasDnaBackbone (position) { - return (this.isDna() && - this.hasBackboneAtoms(position, DnaBackboneType)); -}; -ResidueType.prototype.hasCgProteinBackbone = function hasCgProteinBackbone (position) { - return (this.atomCount < 7 && - this.isProtein() && - this.hasBackboneAtoms(position, CgProteinBackboneType)); -}; -ResidueType.prototype.hasCgRnaBackbone = function hasCgRnaBackbone (position) { - return (this.atomCount < 11 && - this.isRna() && - this.hasBackboneAtoms(position, CgRnaBackboneType)); -}; -ResidueType.prototype.hasCgDnaBackbone = function hasCgDnaBackbone (position) { - return (this.atomCount < 11 && - this.isDna() && - this.hasBackboneAtoms(position, CgDnaBackboneType)); -}; -ResidueType.prototype.hasBackbone = function hasBackbone (position) { - return (this.hasProteinBackbone(position) || - this.hasRnaBackbone(position) || - this.hasDnaBackbone(position) || - this.hasCgProteinBackbone(position) || - this.hasCgRnaBackbone(position) || - this.hasCgDnaBackbone(position)); -}; -ResidueType.prototype.getAtomIndexByName = function getAtomIndexByName (atomname) { - var n = this.atomCount; - var atomMap = this.structure.atomMap; - var atomTypeIdList = this.atomTypeIdList; - if (Array.isArray(atomname)) { - for (var i = 0; i < n; ++i) { - var index = atomTypeIdList[i]; - if (atomname.includes(atomMap.get(index).atomname)) { - return i; - } - } - } - else { - for (var i$1 = 0; i$1 < n; ++i$1) { - var index$1 = atomTypeIdList[i$1]; - if (atomname === atomMap.get(index$1).atomname) { - return i$1; - } - } - } - return undefined; -}; -ResidueType.prototype.hasAtomWithName = function hasAtomWithName () { - var atomnames = [], len = arguments.length; - while ( len-- ) atomnames[ len ] = arguments[ len ]; - - var n = atomnames.length; - for (var i = 0; i < n; ++i) { - if (atomnames[i] === undefined) - { continue; } - if (this.getAtomIndexByName(atomnames[i]) === undefined) { - return false; - } - } - return true; -}; -ResidueType.prototype.getBonds = function getBonds (r) { - if (this.bonds === undefined) { - this.bonds = calculateResidueBonds(r); // TODO - } - return this.bonds; -}; -ResidueType.prototype.getRings = function getRings () { - if (this.rings === undefined) { - this.calculateRings(); - } - return this.rings; -}; -ResidueType.prototype.getBondGraph = function getBondGraph () { - if (this.bondGraph === undefined) { - this.calculateBondGraph(); - } - return this.bondGraph; -}; -ResidueType.prototype.getAromatic = function getAromatic (a) { - if (this.aromaticAtoms === undefined) { - this.calculateAromatic(this.structure.getResidueProxy((a).residueIndex)); // TODO - } - return this.aromaticAtoms; -}; -ResidueType.prototype.getAromaticRings = function getAromaticRings (r) { - if (this.aromaticRings === undefined) { - this.calculateAromatic(r); // TODO - } - return this.aromaticRings; -}; -/** - * @return {Object} bondGraph - represents the bonding in this - * residue: { ai1: [ ai2, ai3, ...], ...} - */ -ResidueType.prototype.calculateBondGraph = function calculateBondGraph () { - var bondGraph = this.bondGraph = {}; - var bonds = this.getBonds(); - var nb = bonds.atomIndices1.length; - var atomIndices1 = bonds.atomIndices1; - var atomIndices2 = bonds.atomIndices2; - for (var i = 0; i < nb; ++i) { - var ai1 = atomIndices1[i]; - var ai2 = atomIndices2[i]; - var a1 = bondGraph[ai1] = bondGraph[ai1] || []; - a1.push(ai2); - var a2 = bondGraph[ai2] = bondGraph[ai2] || []; - a2.push(ai1); - } -}; -/** - * Find all rings up to 2 * RingFinderMaxDepth - */ -ResidueType.prototype.calculateRings = function calculateRings () { - var bondGraph = this.getBondGraph(); // TODO - var state = RingFinderState(bondGraph, this.atomCount); - for (var i = 0; i < state.count; i++) { - if (state.visited[i] >= 0) - { continue; } - findRings(state, i); - } - this.rings = { atomRings: state.atomRings, rings: state.rings }; -}; -ResidueType.prototype.isAromatic = function isAromatic (atom) { - this.aromaticAtoms = this.getAromatic(atom); // TODO - return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1; -}; -ResidueType.prototype.calculateAromatic = function calculateAromatic (r) { - var this$1 = this; - - var aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount); - var rings = this.getRings().rings; - var aromaticRingFlags = rings.map(function (ring) { - return isRingAromatic(ring.map(function (idx) { - return this$1.structure.getAtomProxy(idx + r.atomOffset); - })); - }); - var aromaticRings = this.aromaticRings = []; - rings.forEach(function (ring, i) { - if (aromaticRingFlags[i]) { - aromaticRings.push(ring); - ring.forEach(function (idx) { return aromaticAtoms[idx] = 1; }); - } - }); -}; -/** - * For bonds with order > 1, pick a reference atom - * @return {undefined} - */ -ResidueType.prototype.assignBondReferenceAtomIndices = function assignBondReferenceAtomIndices () { - var bondGraph = this.getBondGraph(); // TODO - var rings = this.getRings(); // TODO - var atomRings = rings.atomRings; - var ringData = rings.rings; - var bonds = this.bonds; // TODO - var atomIndices1 = bonds.atomIndices1; - var atomIndices2 = bonds.atomIndices2; - var bondOrders = bonds.bondOrders; - var bondReferenceAtomIndices = this.bondReferenceAtomIndices; - var nb = bonds.atomIndices1.length; - bondReferenceAtomIndices.length = 0; // reset array - for (var i = 0; i < nb; ++i) { - // Not required for single bonds - if (bondOrders[i] <= 1) - { continue; } - var refRing = (void 0); - var ai1 = atomIndices1[i]; - var ai2 = atomIndices2[i]; - var rings1 = atomRings[ai1]; - var rings2 = atomRings[ai2]; - // Are both atoms in a ring? - if (rings1 && rings2) { - // Are they in the same ring? (If not, ignore ring info) - for (var ri1 = 0; ri1 < rings1.length; ri1++) { - if (rings2.indexOf(rings1[ri1]) !== -1) { - refRing = ringData[rings1[ri1]]; - break; - } - } - } - // Find the first neighbour. - if (bondGraph[ai1].length > 1) { - for (var j = 0; j < bondGraph[ai1].length; ++j) { - var ai3 = bondGraph[ai1][j]; - if (ai3 !== ai2) { - if (refRing === undefined || refRing.indexOf(ai3) !== -1) { - bondReferenceAtomIndices[i] = ai3; - break; - } - } - } - } - else if (bondGraph[ai2].length > 1) { - for (var j$1 = 0; j$1 < bondGraph[ai2].length; ++j$1) { - var ai3$1 = bondGraph[ai2][j$1]; - if (ai3$1 !== ai1) { - if (refRing === undefined || refRing.indexOf(ai3$1) !== -1) { - bondReferenceAtomIndices[i] = ai3$1; - break; - } - } - } - } // No reference atom could be found (e.g. diatomic molecule/fragment) - } -}; -ResidueType.prototype.getBondIndex = function getBondIndex (atomIndex1, atomIndex2) { - var bonds = this.bonds; // TODO - var atomIndices1 = bonds.atomIndices1; - var atomIndices2 = bonds.atomIndices2; - var idx1 = atomIndices1.indexOf(atomIndex1); - var idx2 = atomIndices2.indexOf(atomIndex2); - var _idx2 = idx2; - while (idx1 !== -1) { - while (idx2 !== -1) { - if (idx1 === idx2) - { return idx1; } - idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1); - } - idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1); - idx2 = _idx2; - } - // returns undefined when no bond is found -}; -ResidueType.prototype.getBondReferenceAtomIndex = function getBondReferenceAtomIndex (atomIndex1, atomIndex2) { - var bondIndex = this.getBondIndex(atomIndex1, atomIndex2); - if (bondIndex === undefined) - { return undefined; } - if (this.bondReferenceAtomIndices.length === 0) { - this.assignBondReferenceAtomIndices(); - } - return this.bondReferenceAtomIndices[bondIndex]; -}; -// -var AromaticRingElements = [ - 5 /* B */, 6 /* C */, 7 /* N */, 8 /* O */, - 14 /* SI */, 15 /* P */, 16 /* S */, - 32 /* GE */, 33 /* AS */, - 50 /* SN */, 51 /* SB */, - 83 /* BI */ -]; -var AromaticRingPlanarityThreshold = 0.05; -function isRingAromatic(ring) { - if (ring.some(function (a) { return !AromaticRingElements.includes(a.number); })) - { return false; } - var i = 0; - var coords = new Matrix(3, ring.length); - var cd = coords.data; - ring.forEach(function (a) { - cd[i + 0] = a.x; - cd[i + 1] = a.y; - cd[i + 2] = a.z; - i += 3; - }); - var pa = new PrincipalAxes(coords); - return pa.vecC.length() < AromaticRingPlanarityThreshold; -} -// -/** - * Ring finding code below adapted from MolQL - * Copyright (c) 2017 MolQL contributors, licensed under MIT - * @author David Sehnal - */ -function addRing(state, a, b) { - // only "monotonous" rings - if (b < a) - { return; } - var pred = state.pred; - var color = state.color; - var left = state.left; - var right = state.right; - var nc = ++state.currentColor; - var current = a; - for (var t = 0; t < RingFinderMaxDepth; t++) { - color[current] = nc; - current = pred[current]; - if (current < 0) - { break; } - } - var leftOffset = 0; - var rightOffset = 0; - var found = false; - var target = 0; - current = b; - for (var t$1 = 0; t$1 < RingFinderMaxDepth; t$1++) { - if (color[current] === nc) { - target = current; - found = true; - break; - } - right[rightOffset++] = current; - current = pred[current]; - if (current < 0) - { break; } - } - if (!found) - { return; } - current = a; - for (var t$2 = 0; t$2 < RingFinderMaxDepth; t$2++) { - left[leftOffset++] = current; - if (target === current) - { break; } - current = pred[current]; - if (current < 0) - { break; } - } - var rn = leftOffset + rightOffset; - var ring = new Array(rn); - var ringOffset = 0; - for (var t$3 = 0; t$3 < leftOffset; t$3++) { - ring[ringOffset++] = left[t$3]; - } - for (var t$4 = rightOffset - 1; t$4 >= 0; t$4--) { - ring[ringOffset++] = right[t$4]; - } - var ri = state.rings.length; - // set atomRing indices: - for (var i = 0; i < rn; ++i) { - var ai = ring[i]; - if (state.atomRings[ai]) { - state.atomRings[ai].push(ri); - } - else { - state.atomRings[ai] = [ri]; - } - } - state.rings.push(ring); -} -function findRings(state, from) { - var bonds = state.bonds; - var visited = state.visited; - var queue = state.queue; - var pred = state.pred; - visited[from] = 1; - queue[0] = from; - var head = 0; - var size = 1; - while (head < size) { - var top = queue[head++]; - var start = 0; - if (bonds[top] === undefined) { - continue; - } - var end = bonds[top].length; - for (var i = start; i < end; i++) { - var other = bonds[top][i]; - if (visited[other] > 0) { - if (pred[other] !== top && pred[top] !== other) { - addRing(state, top, other); - } - continue; - } - visited[other] = 1; - queue[size++] = other; - pred[other] = top; - } - } -} -var RingFinderMaxDepth = 4; -function RingFinderState(bonds, capacity) { - var state = { - count: capacity, - visited: new Int32Array(capacity), - queue: new Int32Array(capacity), - pred: new Int32Array(capacity), - left: new Int32Array(RingFinderMaxDepth), - right: new Int32Array(RingFinderMaxDepth), - color: new Int32Array(capacity), - currentColor: 0, - rings: [], - atomRings: [], - bonds: bonds - }; - for (var i = 0; i < capacity; i++) { - state.visited[i] = -1; - state.pred[i] = -1; - } - return state; -} - -/** - * @file Residue Map - * @author Alexander Rose - * @private - */ -function getHash$1(resname, atomTypeIdList, hetero, chemCompType) { - if ( chemCompType === void 0 ) chemCompType = ''; - - return (resname + '|' + - atomTypeIdList.join(',') + '|' + - (hetero ? 1 : 0) + '|' + - chemCompType); -} -var ResidueMap = function ResidueMap(structure) { - this.structure = structure; - this.dict = {}; - this.list = []; -}; -ResidueMap.prototype.add = function add (resname, atomTypeIdList, hetero, chemCompType, bonds) { - if ( chemCompType === void 0 ) chemCompType = ''; - - resname = resname.toUpperCase(); - var hash = getHash$1(resname, atomTypeIdList, hetero, chemCompType); - var id = this.dict[hash]; - if (id === undefined) { - var residueType = new ResidueType(this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds); - id = this.list.length; - this.dict[hash] = id; - this.list.push(residueType); - } - return id; -}; -ResidueMap.prototype.get = function get (id) { - return this.list[id]; -}; - -/** - * @file Bond Proxy - * @author Alexander Rose - * @private - */ -/** - * Bond proxy - */ -var BondProxy = function BondProxy(structure, index) { - if ( index === void 0 ) index = 0; - - this.structure = structure; - this.index = index; - this.bondStore = structure.bondStore; - this._v12 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this._v13 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this._ap1 = this.structure.getAtomProxy(); - this._ap2 = this.structure.getAtomProxy(); - this._ap3 = this.structure.getAtomProxy(); -}; - -var prototypeAccessors$i = { atom1: { configurable: true },atom2: { configurable: true },atomIndex1: { configurable: true },atomIndex2: { configurable: true },bondOrder: { configurable: true } }; -/** - * @type {AtomProxy} - */ -prototypeAccessors$i.atom1.get = function () { - return this.structure.getAtomProxy(this.atomIndex1); -}; -/** - * @type {AtomProxy} - */ -prototypeAccessors$i.atom2.get = function () { - return this.structure.getAtomProxy(this.atomIndex2); -}; -/** - * @type {Integer} - */ -prototypeAccessors$i.atomIndex1.get = function () { - return this.bondStore.atomIndex1[this.index]; -}; -prototypeAccessors$i.atomIndex1.set = function (value) { - this.bondStore.atomIndex1[this.index] = value; -}; -/** - * @type {Integer} - */ -prototypeAccessors$i.atomIndex2.get = function () { - return this.bondStore.atomIndex2[this.index]; -}; -prototypeAccessors$i.atomIndex2.set = function (value) { - this.bondStore.atomIndex2[this.index] = value; -}; -/** - * @type {Integer} - */ -prototypeAccessors$i.bondOrder.get = function () { - return this.bondStore.bondOrder[this.index]; -}; -prototypeAccessors$i.bondOrder.set = function (value) { - this.bondStore.bondOrder[this.index] = value; -}; -BondProxy.prototype.getOtherAtomIndex = function getOtherAtomIndex (atomIndex) { - return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1; -}; -BondProxy.prototype.getOtherAtom = function getOtherAtom (atom) { - return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index)); -}; -/** - * Get reference atom index for the bond - * @return {Integer|undefined} atom index, or `undefined` if unavailable - */ -BondProxy.prototype.getReferenceAtomIndex = function getReferenceAtomIndex () { - var ap1 = this._ap1; - var ap2 = this._ap2; - ap1.index = this.atomIndex1; - ap2.index = this.atomIndex2; - if (ap1.residueIndex !== ap2.residueIndex) { - return undefined; // Bond between residues, for now ignore (could detect) - } - var typeAtomIndex1 = ap1.index - ap1.residueAtomOffset; - var typeAtomIndex2 = ap2.index - ap2.residueAtomOffset; - var residueType = ap1.residueType; - var ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2); - if (ix !== undefined) { - return ix + ap1.residueAtomOffset; - } - else { - console.warn('No reference atom found', ap1.index, ap2.index); - } -}; -/** - * calculate shift direction for displaying double/triple bonds - * @param {Vector3} [v] pre-allocated output vector - * @return {Vector3} the shift direction vector - */ -BondProxy.prototype.calculateShiftDir = function calculateShiftDir (v) { - if ( v === void 0 ) v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - - var ap1 = this._ap1; - var ap2 = this._ap2; - var ap3 = this._ap3; - var v12 = this._v12; - var v13 = this._v13; - ap1.index = this.atomIndex1; - ap2.index = this.atomIndex2; - var ai3 = this.getReferenceAtomIndex(); - v12.subVectors(ap1, ap2).normalize(); // TODO - if (ai3 !== undefined) { - ap3.index = ai3; - v13.subVectors(ap1, ap3); // TODO - } - else { - v13.copy(ap1); // no reference point, use origin // TODO - } - v13.normalize(); - // make sure v13 and v12 are not colinear - var dp = v12.dot(v13); - if (1 - Math.abs(dp) < 1e-5) { - v13.set(1, 0, 0); - dp = v12.dot(v13); - if (1 - Math.abs(dp) < 1e-5) { - v13.set(0, 1, 0); - dp = v12.dot(v13); - } - } - return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize(); -}; -BondProxy.prototype.qualifiedName = function qualifiedName () { - return this.atomIndex1 + '=' + this.atomIndex2; -}; -/** - * Clone object - * @return {BondProxy} cloned bond - */ -BondProxy.prototype.clone = function clone () { - return new BondProxy(this.structure, this.index); -}; -BondProxy.prototype.toObject = function toObject () { - return { - atomIndex1: this.atomIndex1, - atomIndex2: this.atomIndex2, - bondOrder: this.bondOrder - }; -}; - -Object.defineProperties( BondProxy.prototype, prototypeAccessors$i ); - -/** - * @file Residue Proxy - * @author Alexander Rose - * @private - */ -/** - * Residue proxy - */ -var ResidueProxy = function ResidueProxy(structure, index) { - if ( index === void 0 ) index = 0; - - this.structure = structure; - this.index = index; - this.chainStore = structure.chainStore; - this.residueStore = structure.residueStore; - this.atomStore = structure.atomStore; - this.residueMap = structure.residueMap; - this.atomMap = structure.atomMap; -}; - -var prototypeAccessors$j = { entity: { configurable: true },entityIndex: { configurable: true },chain: { configurable: true },chainIndex: { configurable: true },atomOffset: { configurable: true },atomCount: { configurable: true },atomEnd: { configurable: true },modelIndex: { configurable: true },chainname: { configurable: true },chainid: { configurable: true },resno: { configurable: true },sstruc: { configurable: true },inscode: { configurable: true },residueType: { configurable: true },resname: { configurable: true },hetero: { configurable: true },moleculeType: { configurable: true },backboneType: { configurable: true },backboneStartType: { configurable: true },backboneEndType: { configurable: true },traceAtomIndex: { configurable: true },direction1AtomIndex: { configurable: true },direction2AtomIndex: { configurable: true },backboneStartAtomIndex: { configurable: true },backboneEndAtomIndex: { configurable: true },rungEndAtomIndex: { configurable: true },x: { configurable: true },y: { configurable: true },z: { configurable: true } }; -/** - * Entity - * @type {Entity} - */ -prototypeAccessors$j.entity.get = function () { - return this.structure.entityList[this.entityIndex]; -}; -prototypeAccessors$j.entityIndex.get = function () { - return this.chainStore.entityIndex[this.chainIndex]; -}; -/** - * Chain - * @type {ChainProxy} - */ -prototypeAccessors$j.chain.get = function () { - return this.structure.getChainProxy(this.chainIndex); -}; -prototypeAccessors$j.chainIndex.get = function () { - return this.residueStore.chainIndex[this.index]; -}; -prototypeAccessors$j.chainIndex.set = function (value) { - this.residueStore.chainIndex[this.index] = value; -}; -prototypeAccessors$j.atomOffset.get = function () { - return this.residueStore.atomOffset[this.index]; -}; -prototypeAccessors$j.atomOffset.set = function (value) { - this.residueStore.atomOffset[this.index] = value; -}; -/** - * Atom count - * @type {Integer} - */ -prototypeAccessors$j.atomCount.get = function () { - return this.residueStore.atomCount[this.index]; -}; -prototypeAccessors$j.atomCount.set = function (value) { - this.residueStore.atomCount[this.index] = value; -}; -prototypeAccessors$j.atomEnd.get = function () { - return this.atomOffset + this.atomCount - 1; -}; -// -prototypeAccessors$j.modelIndex.get = function () { - return this.chainStore.modelIndex[this.chainIndex]; -}; -/** - * Chain name - * @type {String} - */ -prototypeAccessors$j.chainname.get = function () { - return this.chainStore.getChainname(this.chainIndex); -}; -/** - * Chain id - * @type {String} - */ -prototypeAccessors$j.chainid.get = function () { - return this.chainStore.getChainid(this.chainIndex); -}; -// -/** - * Residue number/label - * @type {Integer} - */ -prototypeAccessors$j.resno.get = function () { - return this.residueStore.resno[this.index]; -}; -prototypeAccessors$j.resno.set = function (value) { - this.residueStore.resno[this.index] = value; -}; -/** - * Secondary structure code - * @type {String} - */ -prototypeAccessors$j.sstruc.get = function () { - return this.residueStore.getSstruc(this.index); -}; -prototypeAccessors$j.sstruc.set = function (value) { - this.residueStore.setSstruc(this.index, value); -}; -/** - * Insertion code - * @type {String} - */ -prototypeAccessors$j.inscode.get = function () { - return this.residueStore.getInscode(this.index); -}; -prototypeAccessors$j.inscode.set = function (value) { - this.residueStore.setInscode(this.index, value); -}; -// -prototypeAccessors$j.residueType.get = function () { - return this.residueMap.get(this.residueStore.residueTypeId[this.index]); -}; -/** - * Residue name - * @type {String} - */ -prototypeAccessors$j.resname.get = function () { - return this.residueType.resname; -}; -/** - * Hetero flag - * @type {Boolean} - */ -prototypeAccessors$j.hetero.get = function () { - return this.residueType.hetero; -}; -prototypeAccessors$j.moleculeType.get = function () { - return this.residueType.moleculeType; -}; -prototypeAccessors$j.backboneType.get = function () { - return this.residueType.backboneType; -}; -prototypeAccessors$j.backboneStartType.get = function () { - return this.residueType.backboneStartType; -}; -prototypeAccessors$j.backboneEndType.get = function () { - return this.residueType.backboneEndType; -}; -prototypeAccessors$j.traceAtomIndex.get = function () { - return this.residueType.traceAtomIndex + this.atomOffset; -}; -prototypeAccessors$j.direction1AtomIndex.get = function () { - return this.residueType.direction1AtomIndex + this.atomOffset; -}; -prototypeAccessors$j.direction2AtomIndex.get = function () { - return this.residueType.direction2AtomIndex + this.atomOffset; -}; -prototypeAccessors$j.backboneStartAtomIndex.get = function () { - return this.residueType.backboneStartAtomIndex + this.atomOffset; -}; -prototypeAccessors$j.backboneEndAtomIndex.get = function () { - return this.residueType.backboneEndAtomIndex + this.atomOffset; -}; -prototypeAccessors$j.rungEndAtomIndex.get = function () { - return this.residueType.rungEndAtomIndex + this.atomOffset; -}; -// -prototypeAccessors$j.x.get = function () { - var x = 0; - for (var i = this.atomOffset; i <= this.atomEnd; ++i) { - x += this.atomStore.x[i]; - } - return x / this.atomCount; -}; -prototypeAccessors$j.y.get = function () { - var y = 0; - for (var i = this.atomOffset; i <= this.atomEnd; ++i) { - y += this.atomStore.y[i]; - } - return y / this.atomCount; -}; -prototypeAccessors$j.z.get = function () { - var z = 0; - for (var i = this.atomOffset; i <= this.atomEnd; ++i) { - z += this.atomStore.z[i]; - } - return z / this.atomCount; -}; -// -/** - * Atom iterator - * @param {function(atom: AtomProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ResidueProxy.prototype.eachAtom = function eachAtom (callback, selection) { - var count = this.atomCount; - var offset = this.atomOffset; - var ap = this.structure._ap; - var end = offset + count; - if (selection && selection.atomOnlyTest) { - var atomOnlyTest = selection.atomOnlyTest; - for (var i = offset; i < end; ++i) { - ap.index = i; - if (atomOnlyTest(ap)) - { callback(ap); } - } - } - else { - for (var i$1 = offset; i$1 < end; ++i$1) { - ap.index = i$1; - callback(ap); - } - } -}; -// -/** - * Write residue center position to array - * @param {Array|TypedArray} [array] - target array - * @param {Integer} [offset] - the offset - * @return {Array|TypedArray} target array - */ -ResidueProxy.prototype.positionToArray = function positionToArray (array, offset) { - if ( array === void 0 ) array = []; - if ( offset === void 0 ) offset = 0; - - array[offset + 0] = this.x; - array[offset + 1] = this.y; - array[offset + 2] = this.z; - return array; -}; -// -/** - * If residue is from a protein - * @return {Boolean} flag - */ -ResidueProxy.prototype.isProtein = function isProtein () { - return this.residueType.moleculeType === ProteinType; -}; -/** - * If residue is nucleic - * @return {Boolean} flag - */ -ResidueProxy.prototype.isNucleic = function isNucleic () { - var moleculeType = this.residueType.moleculeType; - return moleculeType === RnaType || moleculeType === DnaType; -}; -/** - * If residue is rna - * @return {Boolean} flag - */ -ResidueProxy.prototype.isRna = function isRna () { - return this.residueType.moleculeType === RnaType; -}; -/** - * If residue is dna - * @return {Boolean} flag - */ -ResidueProxy.prototype.isDna = function isDna () { - return this.residueType.moleculeType === DnaType; -}; -/** - * If residue is coarse-grain - * @return {Boolean} flag - */ -ResidueProxy.prototype.isCg = function isCg () { - var backboneType = this.residueType.backboneType; - return (backboneType === CgProteinBackboneType || - backboneType === CgRnaBackboneType || - backboneType === CgDnaBackboneType); -}; -/** - * If residue is from a polymer - * @return {Boolean} flag - */ -ResidueProxy.prototype.isPolymer = function isPolymer () { - if (this.structure.entityList.length > 0) { - return this.entity.isPolymer(); - } - else { - var moleculeType = this.residueType.moleculeType; - return (moleculeType === ProteinType || - moleculeType === RnaType || - moleculeType === DnaType); - } -}; -/** - * If residue is hetero - * @return {Boolean} flag - */ -ResidueProxy.prototype.isHetero = function isHetero () { - return this.residueType.hetero === 1; -}; -/** - * If residue is a water molecule - * @return {Boolean} flag - */ -ResidueProxy.prototype.isWater = function isWater () { - return this.residueType.moleculeType === WaterType; -}; -/** - * If residue is an ion - * @return {Boolean} flag - */ -ResidueProxy.prototype.isIon = function isIon () { - return this.residueType.moleculeType === IonType; -}; -/** - * If residue is a saccharide - * @return {Boolean} flag - */ -ResidueProxy.prototype.isSaccharide = function isSaccharide () { - return this.residueType.moleculeType === SaccharideType; -}; -ResidueProxy.prototype.isStandardAminoacid = function isStandardAminoacid () { - return this.residueType.isStandardAminoacid(); -}; -ResidueProxy.prototype.isStandardBase = function isStandardBase () { - return this.residueType.isStandardBase(); -}; -/** - * If residue is part of a helix - * @return {Boolean} flag - */ -ResidueProxy.prototype.isHelix = function isHelix () { - return SecStrucHelix.includes(this.sstruc); -}; -/** - * If residue is part of a sheet - * @return {Boolean} flag - */ -ResidueProxy.prototype.isSheet = function isSheet () { - return SecStrucSheet.includes(this.sstruc); -}; -/** - * If residue is part of a turn - * @return {Boolean} flag - */ -ResidueProxy.prototype.isTurn = function isTurn () { - return SecStrucTurn.includes(this.sstruc) && this.isProtein(); -}; -ResidueProxy.prototype.getAtomType = function getAtomType (index) { - return this.atomMap.get(this.atomStore.atomTypeId[index]); -}; -ResidueProxy.prototype.getResname1 = function getResname1 () { - // FIXME nucleic support - return AA1[this.resname.toUpperCase()] || 'X'; -}; -ResidueProxy.prototype.getBackboneType = function getBackboneType (position) { - switch (position) { - case -1: - return this.residueType.backboneStartType; - case 1: - return this.residueType.backboneEndType; - default: - return this.residueType.backboneType; - } -}; -ResidueProxy.prototype.getAtomIndexByName = function getAtomIndexByName (atomname) { - var index = this.residueType.getAtomIndexByName(atomname); - if (index !== undefined) { - index += this.atomOffset; - } - return index; -}; -ResidueProxy.prototype.hasAtomWithName = function hasAtomWithName (atomname) { - return this.residueType.hasAtomWithName(atomname); -}; -ResidueProxy.prototype.getAtomnameList = function getAtomnameList () { - console.warn('getAtomnameList - might be expensive'); - var n = this.atomCount; - var offset = this.atomOffset; - var list = new Array(n); - for (var i = 0; i < n; ++i) { - list[i] = this.getAtomType(offset + i).atomname; - } - return list; -}; -/** - * If residue is connected to another - * @param {ResidueProxy} rNext - the other residue - * @return {Boolean} - flag - */ -ResidueProxy.prototype.connectedTo = function connectedTo (rNext) { - var bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex); - var bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex); - if (bbAtomEnd && bbAtomStart) { - return bbAtomEnd.connectedTo(bbAtomStart); - } - else { - return false; - } -}; -ResidueProxy.prototype.getNextConnectedResidue = function getNextConnectedResidue () { - var rOffset = this.chainStore.residueOffset[this.chainIndex]; - var rCount = this.chainStore.residueCount[this.chainIndex]; - var nextIndex = this.index + 1; - if (nextIndex < rOffset + rCount) { - var rpNext = this.structure.getResidueProxy(nextIndex); - if (this.connectedTo(rpNext)) { - return rpNext; - } - } - else if (nextIndex === rOffset + rCount) { // cyclic - var rpFirst = this.structure.getResidueProxy(rOffset); - if (this.connectedTo(rpFirst)) { - return rpFirst; - } - } - return undefined; -}; -ResidueProxy.prototype.getPreviousConnectedResidue = function getPreviousConnectedResidue (residueProxy) { - var rOffset = this.chainStore.residueOffset[this.chainIndex]; - var prevIndex = this.index - 1; - if (prevIndex >= rOffset) { - var rpPrev = defaults(residueProxy, this.structure.getResidueProxy()); - rpPrev.index = prevIndex; - if (rpPrev.connectedTo(this)) { - return rpPrev; - } - } - else if (prevIndex === rOffset - 1) { // cyclic - var rCount = this.chainStore.residueCount[this.chainIndex]; - var rpLast = defaults(residueProxy, this.structure.getResidueProxy()); - rpLast.index = rOffset + rCount - 1; - if (rpLast.connectedTo(this)) { - return rpLast; - } - } - return undefined; -}; -ResidueProxy.prototype.getBonds = function getBonds () { - return this.residueType.getBonds(this); -}; -ResidueProxy.prototype.getRings = function getRings () { - return this.residueType.getRings(); -}; -ResidueProxy.prototype.getAromaticRings = function getAromaticRings () { - return this.residueType.getAromaticRings(this); -}; -ResidueProxy.prototype.qualifiedName = function qualifiedName (noResname) { - if ( noResname === void 0 ) noResname = false; - - var name = ''; - if (this.resname && !noResname) - { name += '[' + this.resname + ']'; } - if (this.resno !== undefined) - { name += this.resno; } - if (this.inscode) - { name += '^' + this.inscode; } - if (this.chain) - { name += ':' + this.chainname; } - name += '/' + this.modelIndex; - return name; -}; -/** - * Clone object - * @return {ResidueProxy} cloned residue - */ -ResidueProxy.prototype.clone = function clone () { - return new ResidueProxy(this.structure, this.index); -}; -ResidueProxy.prototype.toObject = function toObject () { - return { - index: this.index, - chainIndex: this.chainIndex, - atomOffset: this.atomOffset, - atomCount: this.atomCount, - resno: this.resno, - resname: this.resname, - sstruc: this.sstruc - }; -}; - -Object.defineProperties( ResidueProxy.prototype, prototypeAccessors$j ); - -/** - * @file Polymer - * @author Alexander Rose - * @private - */ -/** - * Polymer - */ -var Polymer = function Polymer(structure, residueIndexStart, residueIndexEnd) { - this.structure = structure; - this.residueIndexStart = residueIndexStart; - this.residueIndexEnd = residueIndexEnd; - this.chainStore = structure.chainStore; - this.residueStore = structure.residueStore; - this.atomStore = structure.atomStore; - /** - * @type {Integer} - */ - this.residueCount = residueIndexEnd - residueIndexStart + 1; - var rpStart = this.structure.getResidueProxy(this.residueIndexStart); - var rpEnd = this.structure.getResidueProxy(this.residueIndexEnd); - this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined; - var rpNext = rpEnd.getNextConnectedResidue(); - this.isNextConnected = rpNext !== undefined; - this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined; - this.isCyclic = rpEnd.connectedTo(rpStart); - this.__residueProxy = this.structure.getResidueProxy(); - // console.log( this.qualifiedName(), this ); -}; - -var prototypeAccessors$k = { chainIndex: { configurable: true },modelIndex: { configurable: true },chainname: { configurable: true } }; -prototypeAccessors$k.chainIndex.get = function () { - return this.residueStore.chainIndex[this.residueIndexStart]; -}; -prototypeAccessors$k.modelIndex.get = function () { - return this.chainStore.modelIndex[this.chainIndex]; -}; -/** - * @type {String} - */ -prototypeAccessors$k.chainname.get = function () { - return this.chainStore.getChainname(this.chainIndex); -}; -// -/** - * If first residue is from aprotein - * @return {Boolean} flag - */ -Polymer.prototype.isProtein = function isProtein () { - this.__residueProxy.index = this.residueIndexStart; - return this.__residueProxy.isProtein(); -}; -/** - * If atom is part of a coarse-grain group - * @return {Boolean} flag - */ -Polymer.prototype.isCg = function isCg () { - this.__residueProxy.index = this.residueIndexStart; - return this.__residueProxy.isCg(); -}; -/** - * If atom is part of a nucleic molecule - * @return {Boolean} flag - */ -Polymer.prototype.isNucleic = function isNucleic () { - this.__residueProxy.index = this.residueIndexStart; - return this.__residueProxy.isNucleic(); -}; -Polymer.prototype.getMoleculeType = function getMoleculeType () { - this.__residueProxy.index = this.residueIndexStart; - return this.__residueProxy.moleculeType; -}; -Polymer.prototype.getBackboneType = function getBackboneType (position) { - this.__residueProxy.index = this.residueIndexStart; - return this.__residueProxy.getBackboneType(position); -}; -Polymer.prototype.getAtomIndexByType = function getAtomIndexByType (index, type) { - // TODO pre-calculate, add to residueStore??? - if (this.isCyclic) { - if (index === -1) { - index = this.residueCount - 1; - } - else if (index === this.residueCount) { - index = 0; - } - } - else { - if (index === -1 && !this.isPrevConnected) - { index += 1; } - if (index === this.residueCount && !this.isNextNextConnected) - { index -= 1; } - // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1; - } - var rp = this.__residueProxy; - rp.index = this.residueIndexStart + index; - var aIndex; - switch (type) { - case 'trace': - aIndex = rp.traceAtomIndex; - break; - case 'direction1': - aIndex = rp.direction1AtomIndex; - break; - case 'direction2': - aIndex = rp.direction2AtomIndex; - break; - default: - aIndex = rp.getAtomIndexByName(type); - } - // if (!ap){ - // console.log(this, type, rp.residueType) - // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1) - // // rp.index = this.residueIndexStart; - // // console.log(rp.qualifiedName(), this.residueIndexStart) - // // rp.index = this.residueIndexEnd; - // // console.log(rp.qualifiedName(), this.residueIndexEnd) - // } - return aIndex; -}; -/** - * Atom iterator - * @param {function(atom: AtomProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Polymer.prototype.eachAtom = function eachAtom (callback, selection) { - this.eachResidue(function (rp) { - rp.eachAtom(callback, selection); - }); -}; -Polymer.prototype.eachAtomN = function eachAtomN (n, callback, type) { - var m = this.residueCount; - var array = new Array(n); - for (var i = 0; i < n; ++i) { - array[i] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type)); - } - callback.apply(this, array); - for (var j = n; j < m; ++j) { - for (var i$1 = 1; i$1 < n; ++i$1) { - array[i$1 - 1].index = array[i$1].index; - } - array[n - 1].index = this.getAtomIndexByType(j, type); // TODO - callback.apply(this, array); - } -}; -/** - * Residue iterator - * @param {function(residue: ResidueProxy)} callback - the callback - * @return {undefined} - */ -Polymer.prototype.eachResidue = function eachResidue (callback) { - var rp = this.structure.getResidueProxy(); - var n = this.residueCount; - var rStartIndex = this.residueIndexStart; - for (var i = 0; i < n; ++i) { - rp.index = rStartIndex + i; - callback(rp); - } -}; -Polymer.prototype.qualifiedName = function qualifiedName () { - var rpStart = this.structure.getResidueProxy(this.residueIndexStart); - var rpEnd = this.structure.getResidueProxy(this.residueIndexEnd); - return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName(); -}; - -Object.defineProperties( Polymer.prototype, prototypeAccessors$k ); - -/** - * @file Chain Proxy - * @author Alexander Rose - * @private - */ -/** - * Chain proxy - */ -var ChainProxy = function ChainProxy(structure, index) { - if ( index === void 0 ) index = 0; - - this.structure = structure; - this.index = index; - this.chainStore = structure.chainStore; - this.residueStore = structure.residueStore; -}; - -var prototypeAccessors$l = { entity: { configurable: true },model: { configurable: true },entityIndex: { configurable: true },modelIndex: { configurable: true },residueOffset: { configurable: true },residueCount: { configurable: true },residueEnd: { configurable: true },atomOffset: { configurable: true },atomEnd: { configurable: true },atomCount: { configurable: true },chainname: { configurable: true },chainid: { configurable: true } }; -/** - * Entity - * @type {Entity} - */ -prototypeAccessors$l.entity.get = function () { - return this.structure.entityList[this.entityIndex]; -}; -/** - * Model - * @type {ModelProxy} - */ -prototypeAccessors$l.model.get = function () { - return this.structure.getModelProxy(this.modelIndex); -}; -prototypeAccessors$l.entityIndex.get = function () { - return this.chainStore.entityIndex[this.index]; -}; -prototypeAccessors$l.entityIndex.set = function (value) { - this.chainStore.entityIndex[this.index] = value; -}; -prototypeAccessors$l.modelIndex.get = function () { - return this.chainStore.modelIndex[this.index]; -}; -prototypeAccessors$l.modelIndex.set = function (value) { - this.chainStore.modelIndex[this.index] = value; -}; -prototypeAccessors$l.residueOffset.get = function () { - return this.chainStore.residueOffset[this.index]; -}; -prototypeAccessors$l.residueOffset.set = function (value) { - this.chainStore.residueOffset[this.index] = value; -}; -/** - * Residue count - * @type {Integer} - */ -prototypeAccessors$l.residueCount.get = function () { - return this.chainStore.residueCount[this.index]; -}; -prototypeAccessors$l.residueCount.set = function (value) { - this.chainStore.residueCount[this.index] = value; -}; -prototypeAccessors$l.residueEnd.get = function () { - return this.residueOffset + this.residueCount - 1; -}; -prototypeAccessors$l.atomOffset.get = function () { - return this.residueStore.atomOffset[this.residueOffset]; -}; -prototypeAccessors$l.atomEnd.get = function () { - return (this.residueStore.atomOffset[this.residueEnd] + - this.residueStore.atomCount[this.residueEnd] - 1); -}; -/** - * Atom count - * @type {Integer} - */ -prototypeAccessors$l.atomCount.get = function () { - if (this.residueCount === 0) { - return 0; - } - else { - return this.atomEnd - this.atomOffset + 1; - } -}; -// -/** - * Chain name - * @type {String} - */ -prototypeAccessors$l.chainname.get = function () { - return this.chainStore.getChainname(this.index); -}; -prototypeAccessors$l.chainname.set = function (value) { - this.chainStore.setChainname(this.index, value); -}; -/** - * Chain id - * @type {String} - */ -prototypeAccessors$l.chainid.get = function () { - return this.chainStore.getChainid(this.index); -}; -prototypeAccessors$l.chainid.set = function (value) { - this.chainStore.setChainid(this.index, value); -}; -// -/** - * Atom iterator - * @param {function(atom: AtomProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ChainProxy.prototype.eachAtom = function eachAtom (callback, selection) { - this.eachResidue(function (rp) { - rp.eachAtom(callback, selection); - }, selection); -}; -/** - * Residue iterator - * @param {function(residue: ResidueProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ChainProxy.prototype.eachResidue = function eachResidue (callback, selection) { - var count = this.residueCount; - var offset = this.residueOffset; - var rp = this.structure._rp; - var end = offset + count; - if (selection && selection.test) { - var residueOnlyTest = selection.residueOnlyTest; - if (residueOnlyTest) { - for (var i = offset; i < end; ++i) { - rp.index = i; - if (residueOnlyTest(rp)) { - callback(rp); - } - } - } - else { - for (var i$1 = offset; i$1 < end; ++i$1) { - rp.index = i$1; - callback(rp); - } - } - } - else { - for (var i$2 = offset; i$2 < end; ++i$2) { - rp.index = i$2; - callback(rp); - } - } -}; -/** - * Multi-residue iterator - * @param {Integer} n - window size - * @param {function(residueList: ResidueProxy[])} callback - the callback - * @return {undefined} - */ -ChainProxy.prototype.eachResidueN = function eachResidueN (n, callback) { - var count = this.residueCount; - var offset = this.residueOffset; - var end = offset + count; - if (count < n) - { return; } - var array = new Array(n); - for (var i = 0; i < n; ++i) { - array[i] = this.structure.getResidueProxy(offset + i); - } - callback.apply(this, array); - for (var j = offset + n; j < end; ++j) { - for (var i$1 = 0; i$1 < n; ++i$1) { - array[i$1].index += 1; - } - callback.apply(this, array); - } -}; -/** - * Polymer iterator - * @param {function(polymer: Polymer)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ChainProxy.prototype.eachPolymer = function eachPolymer (callback, selection) { - var rStartIndex = 0; - var rNextIndex = 0; - var test = selection ? selection.residueOnlyTest : undefined; - var structure = this.model.structure; - var count = this.residueCount; - var offset = this.residueOffset; - var end = offset + count; - var rp1 = this.structure.getResidueProxy(); - var rp2 = this.structure.getResidueProxy(offset); - var ap1 = this.structure.getAtomProxy(); - var ap2 = this.structure.getAtomProxy(); - var first = true; - for (var i = offset + 1; i < end; ++i) { - rp1.index = rp2.index; - rp2.index = i; - var bbType1 = first ? rp1.backboneEndType : rp1.backboneType; - var bbType2 = rp2.backboneType; - if (first) { - rStartIndex = rp1.index; - first = false; - } - rNextIndex = rp2.index; - if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) { - ap1.index = rp1.backboneEndAtomIndex; - ap2.index = rp2.backboneStartAtomIndex; - } - else { - if (bbType1 !== UnknownBackboneType) { - if (rp1.index - rStartIndex > 1) { - // console.log("FOO1",rStartIndex, rp1.index) - callback(new Polymer(structure, rStartIndex, rp1.index)); - } - } - rStartIndex = rNextIndex; - continue; - } - if (!ap1 || !ap2 || !ap1.connectedTo(ap2) || - (test && (!test(rp1) || !test(rp2)))) { - if (rp1.index - rStartIndex > 1) { - // console.log("FOO2",rStartIndex, rp1.index) - callback(new Polymer(structure, rStartIndex, rp1.index)); - } - rStartIndex = rNextIndex; - } - } - if (rNextIndex - rStartIndex > 1) { - if (this.structure.getResidueProxy(rStartIndex).backboneEndType) { - // console.log("FOO3",rStartIndex, rNextIndex) - callback(new Polymer(structure, rStartIndex, rNextIndex)); - } - } -}; -// -ChainProxy.prototype.qualifiedName = function qualifiedName () { - var name = ':' + this.chainname + '/' + this.modelIndex; - return name; -}; -/** - * Clone object - * @return {ChainProxy} cloned chain - */ -ChainProxy.prototype.clone = function clone () { - return new ChainProxy(this.structure, this.index); -}; -ChainProxy.prototype.toObject = function toObject () { - return { - index: this.index, - residueOffset: this.residueOffset, - residueCount: this.residueCount, - chainname: this.chainname - }; -}; - -Object.defineProperties( ChainProxy.prototype, prototypeAccessors$l ); - -/** - * @file Model Proxy - * @author Alexander Rose - * @private - */ -/** - * Model proxy - */ -var ModelProxy = function ModelProxy(structure, index) { - if ( index === void 0 ) index = 0; - - this.structure = structure; - this.index = index; - this.modelStore = structure.modelStore; - this.chainStore = structure.chainStore; - this.residueStore = structure.residueStore; -}; - -var prototypeAccessors$m = { chainOffset: { configurable: true },chainCount: { configurable: true },residueOffset: { configurable: true },atomOffset: { configurable: true },chainEnd: { configurable: true },residueEnd: { configurable: true },atomEnd: { configurable: true },residueCount: { configurable: true },atomCount: { configurable: true } }; -prototypeAccessors$m.chainOffset.get = function () { - return this.modelStore.chainOffset[this.index]; -}; -prototypeAccessors$m.chainOffset.set = function (value) { - this.modelStore.chainOffset[this.index] = value; -}; -prototypeAccessors$m.chainCount.get = function () { - return this.modelStore.chainCount[this.index]; -}; -prototypeAccessors$m.chainCount.set = function (value) { - this.modelStore.chainCount[this.index] = value; -}; -prototypeAccessors$m.residueOffset.get = function () { - return this.chainStore.residueOffset[this.chainOffset]; -}; -prototypeAccessors$m.atomOffset.get = function () { - return this.residueStore.atomOffset[this.residueOffset]; -}; -prototypeAccessors$m.chainEnd.get = function () { - return this.chainOffset + this.chainCount - 1; -}; -prototypeAccessors$m.residueEnd.get = function () { - return (this.chainStore.residueOffset[this.chainEnd] + - this.chainStore.residueCount[this.chainEnd] - 1); -}; -prototypeAccessors$m.atomEnd.get = function () { - return (this.residueStore.atomOffset[this.residueEnd] + - this.residueStore.atomCount[this.residueEnd] - 1); -}; -/** - * Residue count - * @type {Integer} - */ -prototypeAccessors$m.residueCount.get = function () { - if (this.chainCount === 0) { - return 0; - } - else { - return this.residueEnd - this.residueOffset + 1; - } -}; -/** - * Atom count - * @type {Integer} - */ -prototypeAccessors$m.atomCount.get = function () { - if (this.residueCount === 0) { - return 0; - } - else { - return this.atomEnd - this.atomOffset + 1; - } -}; -// -/** - * Atom iterator - * @param {function(atom: AtomProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ModelProxy.prototype.eachAtom = function eachAtom (callback, selection) { - this.eachChain(function (cp) { - cp.eachAtom(callback, selection); - }, selection); -}; -/** - * Residue iterator - * @param {function(residue: ResidueProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ModelProxy.prototype.eachResidue = function eachResidue (callback, selection) { - this.eachChain(function (cp) { - cp.eachResidue(callback, selection); - }, selection); -}; -/** - * Polymer iterator - * @param {function(polymer: Polymer)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ModelProxy.prototype.eachPolymer = function eachPolymer (callback, selection) { - if (selection && selection.chainOnlyTest) { - var chainOnlyTest = selection.chainOnlyTest; - this.eachChain(function (cp) { - if (chainOnlyTest(cp)) { - cp.eachPolymer(callback, selection); - } - }); - } - else { - this.eachChain(function (cp) { - cp.eachPolymer(callback, selection); - }); - } -}; -/** - * Chain iterator - * @param {function(chain: ChainProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -ModelProxy.prototype.eachChain = function eachChain (callback, selection) { - var count = this.chainCount; - var offset = this.chainOffset; - var cp = this.structure._cp; - var end = offset + count; - if (selection && selection.test) { - var chainOnlyTest = selection.chainOnlyTest; - if (chainOnlyTest) { - for (var i = offset; i < end; ++i) { - cp.index = i; - if (chainOnlyTest(cp)) { - callback(cp); - } - } - } - else { - for (var i$1 = offset; i$1 < end; ++i$1) { - cp.index = i$1; - callback(cp); - } - } - } - else { - for (var i$2 = offset; i$2 < end; ++i$2) { - cp.index = i$2; - callback(cp); - } - } -}; -// -ModelProxy.prototype.qualifiedName = function qualifiedName () { - var name = '/' + this.index; - return name; -}; -/** - * Clone object - * @return {ModelProxy} cloned model - */ -ModelProxy.prototype.clone = function clone () { - return new ModelProxy(this.structure, this.index); -}; -ModelProxy.prototype.toObject = function toObject () { - return { - index: this.index, - chainOffset: this.chainOffset, - chainCount: this.chainCount - }; -}; - -Object.defineProperties( ModelProxy.prototype, prototypeAccessors$m ); - -/** - * @file Structure - * @author Alexander Rose - * @private - */ -/** - * Structure - */ -var Structure = function Structure(name, path) { - if ( name === void 0 ) name = ''; - if ( path === void 0 ) path = ''; - - this.signals = { - refreshed: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.init(name, path); -}; - -var prototypeAccessors$n = { type: { configurable: true } }; -Structure.prototype.init = function init (name, path) { - this.name = name; - this.path = path; - this.title = ''; - this.id = ''; - this.data = createData(this); - this.header = {}; - this.extraData = {}; - this.atomSetCache = {}; - this.atomSetDict = {}; - this.biomolDict = {}; - this.entityList = []; - this.unitcell = undefined; - this.frames = []; - this.boxes = []; - this.validation = undefined; - this.bondStore = new BondStore(0); - this.backboneBondStore = new BondStore(0); - this.rungBondStore = new BondStore(0); - this.atomStore = new AtomStore(0); - this.residueStore = new ResidueStore(0); - this.chainStore = new ChainStore(0); - this.modelStore = new ModelStore(0); - this.atomMap = new AtomMap(this); - this.residueMap = new ResidueMap(this); - this.bondHash = undefined; - this.spatialHash = undefined; - this.atomSet = undefined; - this.bondSet = undefined; - this.center = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this._bp = this.getBondProxy(); - this._ap = this.getAtomProxy(); - this._rp = this.getResidueProxy(); - this._cp = this.getChainProxy(); -}; -prototypeAccessors$n.type.get = function () { return 'Structure'; }; -Structure.prototype.finalizeAtoms = function finalizeAtoms () { - this.atomSet = this.getAtomSet(); - this.atomCount = this.atomStore.count; - this.boundingBox = this.getBoundingBox(undefined, this.boundingBox); - this.center = this.boundingBox.getCenter(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); - this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox); -}; -Structure.prototype.finalizeBonds = function finalizeBonds () { - this.bondSet = this.getBondSet(); - this.bondCount = this.bondStore.count; - this.bondHash = new BondHash(this.bondStore, this.atomStore.count); - this.atomSetCache = {}; - if (!this.atomSetDict.rung) { - this.atomSetDict.rung = this.getAtomSet(false); - } - for (var name in this.atomSetDict) { - this.atomSetCache['__' + name] = this.atomSetDict[name].clone(); - } -}; -// -Structure.prototype.getBondProxy = function getBondProxy (index) { - return new BondProxy(this, index); -}; -Structure.prototype.getAtomProxy = function getAtomProxy (index) { - return new AtomProxy(this, index); -}; -Structure.prototype.getResidueProxy = function getResidueProxy (index) { - return new ResidueProxy(this, index); -}; -Structure.prototype.getChainProxy = function getChainProxy (index) { - return new ChainProxy(this, index); -}; -Structure.prototype.getModelProxy = function getModelProxy (index) { - return new ModelProxy(this, index); -}; -// -Structure.prototype.getBondSet = function getBondSet ( /* selection */) { - // TODO implement selection parameter - var n = this.bondStore.count; - var bondSet = new BitArray(n); - var atomSet = this.atomSet; - if (atomSet) { - if (atomSet.isAllSet()) { - bondSet.setAll(); - } - else if (atomSet.isAllClear()) { - bondSet.clearAll(); - } - else { - var bp = this.getBondProxy(); - for (var i = 0; i < n; ++i) { - bp.index = i; - if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) { - bondSet.set(bp.index); - } - } - } - } - else { - bondSet.setAll(); - } - return bondSet; -}; -Structure.prototype.getBackboneBondSet = function getBackboneBondSet ( /* selection */) { - // TODO implement selection parameter - var n = this.backboneBondStore.count; - var backboneBondSet = new BitArray(n); - var backboneAtomSet = this.atomSetCache.__backbone; - if (backboneAtomSet) { - var bp = this.getBondProxy(); - bp.bondStore = this.backboneBondStore; - for (var i = 0; i < n; ++i) { - bp.index = i; - if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) { - backboneBondSet.set(bp.index); - } - } - } - else { - backboneBondSet.setAll(); - } - return backboneBondSet; -}; -Structure.prototype.getRungBondSet = function getRungBondSet ( /* selection */) { - // TODO implement selection parameter - var n = this.rungBondStore.count; - var rungBondSet = new BitArray(n); - var rungAtomSet = this.atomSetCache.__rung; - if (rungAtomSet) { - var bp = this.getBondProxy(); - bp.bondStore = this.rungBondStore; - for (var i = 0; i < n; ++i) { - bp.index = i; - if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) { - rungBondSet.set(bp.index); - } - } - } - else { - rungBondSet.setAll(); - } - return rungBondSet; -}; -/** - * Get a set of atoms - * @param {Boolean|Selection|BitArray} selection - object defining how to - * initialize the atom set. - * Boolean: init with value; - * Selection: init with selection; - * BitArray: return bit array - * @return {BitArray} set of atoms - */ -Structure.prototype.getAtomSet = function getAtomSet (selection) { - var n = this.atomStore.count; - if (selection === undefined) { - return new BitArray(n, true); - } - else if (selection instanceof BitArray) { - return selection; - } - else if (selection === true) { - return new BitArray(n, true); - } - else if (selection && selection.test) { - var seleString = selection.string; - if (seleString in this.atomSetCache) { - return this.atomSetCache[seleString]; - } - else { - if (seleString === '') { - return new BitArray(n, true); - } - else { - var atomSet = new BitArray(n); - this.eachAtom(function (ap) { - atomSet.set(ap.index); - }, selection); - this.atomSetCache[seleString] = atomSet; - return atomSet; - } - } - } - else if (selection === false) { - return new BitArray(n); - } - return new BitArray(n, true); -}; -/** - * Get set of atoms around a set of atoms from a selection - * @param {Selection} selection - the selection object - * @param {Number} radius - radius to select within - * @return {BitArray} set of atoms - */ -Structure.prototype.getAtomSetWithinSelection = function getAtomSetWithinSelection (selection, radius) { - var spatialHash = this.spatialHash; - var atomSet = this.getAtomSet(false); - var ap = this.getAtomProxy(); - if (!spatialHash) - { return atomSet; } - this.getAtomSet(selection).forEach(function (idx) { - ap.index = idx; - spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2) { - atomSet.set(idx2); - }); - }); - return atomSet; -}; -/** - * Get set of atoms around a point - * @param {Vector3|AtomProxy} point - the point - * @param {Number} radius - radius to select within - * @return {BitArray} set of atoms - */ -Structure.prototype.getAtomSetWithinPoint = function getAtomSetWithinPoint (point, radius) { - var p = point; - var atomSet = this.getAtomSet(false); - if (!this.spatialHash) - { return atomSet; } - this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx) { - atomSet.set(idx); - }); - return atomSet; -}; -/** - * Get set of atoms within a volume - * @param {Volume} volume - the volume - * @param {Number} radius - radius to select within - * @param {[type]} minValue - minimum value to be considered as within the volume - * @param {[type]} maxValue - maximum value to be considered as within the volume - * @param {[type]} outside - use only values falling outside of the min/max values - * @return {BitArray} set of atoms - */ -Structure.prototype.getAtomSetWithinVolume = function getAtomSetWithinVolume (volume, radius, minValue, maxValue, outside) { - var fv = new FilteredVolume(volume, minValue, maxValue, outside); // TODO - var dp = fv.getDataPosition(); - var n = dp.length; - var r = fv.matrix.getMaxScaleOnAxis(); - var atomSet = this.getAtomSet(false); - if (!this.spatialHash) - { return atomSet; } - for (var i = 0; i < n; i += 3) { - this.spatialHash.within(dp[i], dp[i + 1], dp[i + 2], r).forEach(function (idx) { - atomSet.set(idx); - }); - } - return atomSet; -}; -/** - * Get set of all atoms within the groups of a selection - * @param {Selection} selection - the selection object - * @return {BitArray} set of atoms - */ -Structure.prototype.getAtomSetWithinGroup = function getAtomSetWithinGroup (selection) { - var atomResidueIndex = this.atomStore.residueIndex; - var atomSet = this.getAtomSet(false); - var rp = this.getResidueProxy(); - this.getAtomSet(selection).forEach(function (idx) { - rp.index = atomResidueIndex[idx]; - for (var idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) { - atomSet.set(idx2); - } - }); - return atomSet; -}; -// -Structure.prototype.getSelection = function getSelection () { - return; -}; -Structure.prototype.getStructure = function getStructure () { - return this; -}; -/** - * Entity iterator - * @param {function(entity: Entity)} callback - the callback - * @param {EntityType} type - entity type - * @return {undefined} - */ -Structure.prototype.eachEntity = function eachEntity (callback, type) { - this.entityList.forEach(function (entity) { - if (type === undefined || entity.getEntityType() === type) { - callback(entity); - } - }); -}; -/** - * Bond iterator - * @param {function(bond: BondProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Structure.prototype.eachBond = function eachBond (callback, selection) { - var bp = this.getBondProxy(); - var bondSet; - if (selection && selection.test) { - bondSet = this.getBondSet( /*selection*/); - if (this.bondSet) { - bondSet.intersection(this.bondSet); - } - } - if (bondSet) { - bondSet.forEach(function (index) { - bp.index = index; - callback(bp); - }); - } - else { - var n = this.bondStore.count; - for (var i = 0; i < n; ++i) { - bp.index = i; - callback(bp); - } - } -}; -/** - * Atom iterator - * @param {function(atom: AtomProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Structure.prototype.eachAtom = function eachAtom (callback, selection) { - if (selection && selection.test) { - this.eachModel(function (mp) { - mp.eachAtom(callback, selection); - }, selection); - } - else { - var an = this.atomStore.count; - var ap = this.getAtomProxy(); - for (var i = 0; i < an; ++i) { - ap.index = i; - callback(ap); - } - } -}; -/** - * Residue iterator - * @param {function(residue: ResidueProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Structure.prototype.eachResidue = function eachResidue (callback, selection) { - if (selection && selection.test) { - var mn = this.modelStore.count; - var mp = this.getModelProxy(); - var modelOnlyTest = selection.modelOnlyTest; - if (modelOnlyTest) { - for (var i = 0; i < mn; ++i) { - mp.index = i; - if (modelOnlyTest(mp)) { - mp.eachResidue(callback, selection); - } - } - } - else { - for (var i$1 = 0; i$1 < mn; ++i$1) { - mp.index = i$1; - mp.eachResidue(callback, selection); - } - } - } - else { - var rn = this.residueStore.count; - var rp = this.getResidueProxy(); - for (var i$2 = 0; i$2 < rn; ++i$2) { - rp.index = i$2; - callback(rp); - } - } -}; -/** - * Multi-residue iterator - * @param {Integer} n - window size - * @param {function(residueList: ResidueProxy[])} callback - the callback - * @return {undefined} - */ -Structure.prototype.eachResidueN = function eachResidueN (n, callback) { - var rn = this.residueStore.count; - if (rn < n) - { return; } - var array = new Array(n); - for (var i = 0; i < n; ++i) { - array[i] = this.getResidueProxy(i); - } - callback.apply(this, array); - for (var j = n; j < rn; ++j) { - for (var i$1 = 0; i$1 < n; ++i$1) { - array[i$1].index += 1; - } - callback.apply(this, array); - } -}; -/** - * Polymer iterator - * @param {function(polymer: Polymer)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Structure.prototype.eachPolymer = function eachPolymer (callback, selection) { - if (selection && selection.modelOnlyTest) { - var modelOnlyTest = selection.modelOnlyTest; - this.eachModel(function (mp) { - if (modelOnlyTest(mp)) { - mp.eachPolymer(callback, selection); - } - }); - } - else { - this.eachModel(function (mp) { - mp.eachPolymer(callback, selection); - }); - } -}; -/** - * Chain iterator - * @param {function(chain: ChainProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Structure.prototype.eachChain = function eachChain (callback, selection) { - if (selection && selection.test) { - this.eachModel(function (mp) { - mp.eachChain(callback, selection); - }); - } - else { - var cn = this.chainStore.count; - var cp = this.getChainProxy(); - for (var i = 0; i < cn; ++i) { - cp.index = i; - callback(cp); - } - } -}; -/** - * Model iterator - * @param {function(model: ModelProxy)} callback - the callback - * @param {Selection} [selection] - the selection - * @return {undefined} - */ -Structure.prototype.eachModel = function eachModel (callback, selection) { - var n = this.modelStore.count; - var mp = this.getModelProxy(); - if (selection && selection.test) { - var modelOnlyTest = selection.modelOnlyTest; - if (modelOnlyTest) { - for (var i = 0; i < n; ++i) { - mp.index = i; - if (modelOnlyTest(mp)) { - callback(mp); - } - } - } - else { - for (var i$1 = 0; i$1 < n; ++i$1) { - mp.index = i$1; - callback(mp); - } - } - } - else { - for (var i$2 = 0; i$2 < n; ++i$2) { - mp.index = i$2; - callback(mp); - } - } -}; -// -Structure.prototype.getAtomData = function getAtomData (params) { - var p = Object.assign({}, params); - if (p.colorParams) - { p.colorParams.structure = this.getStructure(); } - var what = p.what; - var atomSet = defaults(p.atomSet, this.atomSet); - var radiusFactory; // TODO - var colormaker; // TODO - var atomData = {}; - var ap = this.getAtomProxy(); - var atomCount = atomSet.getSize(); - if (!what || what.position) { - atomData.position = new Float32Array(atomCount * 3); - } - if ((!what || what.color) && p.colorParams) { - atomData.color = new Float32Array(atomCount * 3); - colormaker = ColormakerRegistry$1.getScheme(p.colorParams); - } - if (!what || what.picking) { - atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure()); - } - if (!what || what.radius) { - atomData.radius = new Float32Array(atomCount); - radiusFactory = new RadiusFactory(p.radiusParams); - } - if (!what || what.index) { - atomData.index = new Uint32Array(atomCount); - } - var position = atomData.position; - var color = atomData.color; - var picking = atomData.picking; - var radius = atomData.radius; - var index = atomData.index; - atomSet.forEach(function (idx, i) { - var i3 = i * 3; - ap.index = idx; - if (position) { - ap.positionToArray(position, i3); - } - if (color) { - colormaker.atomColorToArray(ap, color, i3); - } - if (picking) { - picking.array[i] = idx; - } - if (radius) { - radius[i] = radiusFactory.atomRadius(ap); - } - if (index) { - index[i] = idx; - } - }); - return atomData; -}; -Structure.prototype.getBondData = function getBondData (params) { - var p = Object.assign({}, params); - if (p.colorParams) - { p.colorParams.structure = this.getStructure(); } - var what = p.what; - var bondSet = defaults(p.bondSet, this.bondSet); - var multipleBond = defaults(p.multipleBond, 'off'); - var isMulti = multipleBond !== 'off'; - var isOffset = multipleBond === 'offset'; - var bondScale = defaults(p.bondScale, 0.4); - var bondSpacing = defaults(p.bondSpacing, 1.0); - var radiusFactory; // TODO - var colormaker; // TODO - var bondData = {}; - var bp = this.getBondProxy(); - if (p.bondStore) - { bp.bondStore = p.bondStore; } - var ap1 = this.getAtomProxy(); - var ap2 = this.getAtomProxy(); - var bondCount; - if (isMulti) { - var storeBondOrder = bp.bondStore.bondOrder; - bondCount = 0; - bondSet.forEach(function (index) { - bondCount += storeBondOrder[index]; - }); - } - else { - bondCount = bondSet.getSize(); - } - if (!what || what.position) { - bondData.position1 = new Float32Array(bondCount * 3); - bondData.position2 = new Float32Array(bondCount * 3); - } - if ((!what || what.color) && p.colorParams) { - bondData.color = new Float32Array(bondCount * 3); - bondData.color2 = new Float32Array(bondCount * 3); - colormaker = ColormakerRegistry$1.getScheme(p.colorParams); - } - if (!what || what.picking) { - bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore); - } - if (!what || what.radius || (isMulti && what.position)) { - radiusFactory = new RadiusFactory(p.radiusParams); - } - if (!what || what.radius) { - bondData.radius = new Float32Array(bondCount); - if (p.radius2) { - bondData.radius2 = new Float32Array(bondCount); - } - } - var position1 = bondData.position1; - var position2 = bondData.position2; - var color = bondData.color; - var color2 = bondData.color2; - var picking = bondData.picking; - var radius = bondData.radius; - var radius2 = bondData.radius2; - var i = 0; - var j, i3, k, bondOrder, absOffset; - var multiRadius; - var vt = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vShortening = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vShift = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - bondSet.forEach(function (index) { - i3 = i * 3; - bp.index = index; - ap1.index = bp.atomIndex1; - ap2.index = bp.atomIndex2; - bondOrder = bp.bondOrder; - if (position1) { - if (isMulti && bondOrder > 1) { - var atomRadius = radiusFactory.atomRadius(ap1); - multiRadius = atomRadius * bondScale / (0.5 * bondOrder); - bp.calculateShiftDir(vShift); - if (isOffset) { - absOffset = 2 * bondSpacing * atomRadius; - vShift.multiplyScalar(absOffset); - vShift.negate(); - // Shortening is calculated so that neighbouring double - // bonds on tetrahedral geometry (e.g. sulphonamide) - // are not quite touching (arccos(1.9 / 2) ~ 109deg) - // but don't shorten beyond 10% each end or it looks odd - vShortening.subVectors(ap2, ap1).multiplyScalar(// TODO - Math.max(0.1, absOffset / 1.88)); - ap1.positionToArray(position1, i3); - ap2.positionToArray(position2, i3); - if (bondOrder >= 2) { - vt.addVectors(ap1, vShift).add(vShortening).toArray(position1, i3 + 3); // TODO - vt.addVectors(ap2, vShift).sub(vShortening).toArray(position2, i3 + 3); // TODO - if (bondOrder >= 3) { - vt.subVectors(ap1, vShift).add(vShortening).toArray(position1, i3 + 6); // TODO - vt.subVectors(ap2, vShift).sub(vShortening).toArray(position2, i3 + 6); // TODO - } - } - } - else { - absOffset = (bondSpacing - bondScale) * atomRadius; - vShift.multiplyScalar(absOffset); - if (bondOrder === 2) { - vt.addVectors(ap1, vShift).toArray(position1, i3); // TODO - vt.subVectors(ap1, vShift).toArray(position1, i3 + 3); // TODO - vt.addVectors(ap2, vShift).toArray(position2, i3); // TODO - vt.subVectors(ap2, vShift).toArray(position2, i3 + 3); // TODO - } - else if (bondOrder === 3) { - ap1.positionToArray(position1, i3); - vt.addVectors(ap1, vShift).toArray(position1, i3 + 3); // TODO - vt.subVectors(ap1, vShift).toArray(position1, i3 + 6); // TODO - ap2.positionToArray(position2, i3); - vt.addVectors(ap2, vShift).toArray(position2, i3 + 3); // TODO - vt.subVectors(ap2, vShift).toArray(position2, i3 + 6); // TODO - } - else { - // todo, better fallback - ap1.positionToArray(position1, i3); - ap2.positionToArray(position2, i3); - } - } - } - else { - ap1.positionToArray(position1, i3); - ap2.positionToArray(position2, i3); - } - } - if (color && color2) { - colormaker.bondColorToArray(bp, 1, color, i3); - colormaker.bondColorToArray(bp, 0, color2, i3); - if (isMulti && bondOrder > 1) { - for (j = 1; j < bondOrder; ++j) { - k = j * 3 + i3; - copyWithin(color, i3, k, 3); - copyWithin(color2, i3, k, 3); - } - } - } - if (picking && picking.array) { - picking.array[i] = index; - if (isMulti && bondOrder > 1) { - for (j = 1; j < bondOrder; ++j) { - picking.array[i + j] = index; - } - } - } - if (radius) { - radius[i] = radiusFactory.atomRadius(ap1); - if (isMulti && bondOrder > 1) { - multiRadius = radius[i] * bondScale / (isOffset ? 1 : (0.5 * bondOrder)); - for (j = isOffset ? 1 : 0; j < bondOrder; ++j) { - radius[i + j] = multiRadius; - } - } - } - if (radius2) { - radius2[i] = radiusFactory.atomRadius(ap2); - if (isMulti && bondOrder > 1) { - multiRadius = radius2[i] * bondScale / (isOffset ? 1 : (0.5 * bondOrder)); - for (j = isOffset ? 1 : 0; j < bondOrder; ++j) { - radius2[i + j] = multiRadius; - } - } - } - i += isMulti ? bondOrder : 1; - }); - return bondData; -}; -Structure.prototype.getBackboneAtomData = function getBackboneAtomData (params) { - params = Object.assign({ - atomSet: this.atomSetCache.__backbone - }, params); - return this.getAtomData(params); -}; -Structure.prototype.getBackboneBondData = function getBackboneBondData (params) { - params = Object.assign({ - bondSet: this.getBackboneBondSet(), - bondStore: this.backboneBondStore - }, params); - return this.getBondData(params); -}; -Structure.prototype.getRungAtomData = function getRungAtomData (params) { - params = Object.assign({ - atomSet: this.atomSetCache.__rung - }, params); - return this.getAtomData(params); -}; -Structure.prototype.getRungBondData = function getRungBondData (params) { - params = Object.assign({ - bondSet: this.getRungBondSet(), - bondStore: this.rungBondStore - }, params); - return this.getBondData(params); -}; -// -/** - * Gets the bounding box of the (selected) structure atoms - * @param {Selection} [selection] - the selection - * @param {Box3} [box] - optional target - * @return {Vector3} the box - */ -Structure.prototype.getBoundingBox = function getBoundingBox (selection, box) { - if (Debug) - { Log.time('getBoundingBox'); } - box = box || new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - var minX = +Infinity; - var minY = +Infinity; - var minZ = +Infinity; - var maxX = -Infinity; - var maxY = -Infinity; - var maxZ = -Infinity; - this.eachAtom(function (ap) { - var x = ap.x; - var y = ap.y; - var z = ap.z; - if (x < minX) - { minX = x; } - if (y < minY) - { minY = y; } - if (z < minZ) - { minZ = z; } - if (x > maxX) - { maxX = x; } - if (y > maxY) - { maxY = y; } - if (z > maxZ) - { maxZ = z; } - }, selection); - box.min.set(minX, minY, minZ); - box.max.set(maxX, maxY, maxZ); - if (Debug) - { Log.timeEnd('getBoundingBox'); } - return box; -}; -/** - * Gets the principal axes of the (selected) structure atoms - * @param {Selection} [selection] - the selection - * @return {PrincipalAxes} the principal axes - */ -Structure.prototype.getPrincipalAxes = function getPrincipalAxes (selection) { - if (Debug) - { Log.time('getPrincipalAxes'); } - var i = 0; - var coords = new Matrix(3, this.atomCount); - var cd = coords.data; - this.eachAtom(function (a) { - cd[i + 0] = a.x; - cd[i + 1] = a.y; - cd[i + 2] = a.z; - i += 3; - }, selection); - if (Debug) - { Log.timeEnd('getPrincipalAxes'); } - return new PrincipalAxes(coords); -}; -/** - * Gets the center of the (selected) structure atoms - * @param {Selection} [selection] - the selection - * @return {Vector3} the center - */ -Structure.prototype.atomCenter = function atomCenter (selection) { - if (selection) { - return this.getBoundingBox(selection).getCenter(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); - } - else { - return this.center.clone(); - } -}; -Structure.prototype.hasCoords = function hasCoords () { - if (this._hasCoords === undefined) { - var atomStore = this.atomStore; - this._hasCoords = (arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 || - arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 || - arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0) || ( - // allow models with a single atom at the origin - atomStore.count / this.modelStore.count === 1); - } - return this._hasCoords; -}; -Structure.prototype.getSequence = function getSequence (selection) { - var seq = []; - var rp = this.getResidueProxy(); - this.eachAtom(function (ap) { - rp.index = ap.residueIndex; - if (ap.index === rp.traceAtomIndex) { - seq.push(rp.getResname1()); - } - }, selection); - return seq; -}; -Structure.prototype.getAtomIndices = function getAtomIndices (selection) { - if (selection && selection.string) { - var indices = []; - this.eachAtom(function (ap) { - indices.push(ap.index); - }, selection); - return new Uint32Array(indices); - } - else { - var p = { what: { index: true } }; - return this.getAtomData(p).index; - } -}; -/** - * Get number of unique chainnames - * @param {Selection} selection - limit count to selection - * @return {Integer} count - */ -Structure.prototype.getChainnameCount = function getChainnameCount (selection) { - var chainnames = new Set(); - this.eachChain(function (cp) { - if (cp.residueCount) { - chainnames.add(cp.chainname); - } - }, selection); - return chainnames.size; -}; -// -Structure.prototype.updatePosition = function updatePosition (position) { - var i = 0; - this.eachAtom(function (ap) { - ap.positionFromArray(position, i); - i += 3; - }, undefined); - this._hasCoords = undefined; // to trigger recalculation -}; -Structure.prototype.refreshPosition = function refreshPosition () { - this.getBoundingBox(undefined, this.boundingBox); - this.boundingBox.getCenter(this.center); - this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox); -}; -/** - * Calls dispose() method of property objects. - * Unsets properties to help garbage collection. - * @return {undefined} - */ -Structure.prototype.dispose = function dispose () { - if (this.frames) - { this.frames.length = 0; } - if (this.boxes) - { this.boxes.length = 0; } - this.bondStore.dispose(); - this.backboneBondStore.dispose(); - this.rungBondStore.dispose(); - this.atomStore.dispose(); - this.residueStore.dispose(); - this.chainStore.dispose(); - this.modelStore.dispose(); - delete this.bondStore; - delete this.atomStore; - delete this.residueStore; - delete this.chainStore; - delete this.modelStore; - delete this.frames; - delete this.boxes; - delete this.bondSet; - delete this.atomSet; -}; - -Object.defineProperties( Structure.prototype, prototypeAccessors$n ); - -/** - * @file Shape - * @author Alexander Rose - * @private - */ -var tmpBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); -var Primitives = [ - ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, - EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, - TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive -]; -var ShapeDefaultParameters = { - aspectRatio: 1.5, - sphereDetail: 2, - radialSegments: 50, - disableImpostor: false, - openEnded: false, - dashedCylinder: false, - labelParams: {}, - pointSize: 2, - sizeAttenuation: false, - useTexture: true, - linewidth: 2 -}; -/** - * Class for building custom shapes. - * - * @example - * var shape = new NGL.Shape('shape', { disableImpostor: true }); - * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 ); - * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]); - * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5); - * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5); - * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0); - * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]); - * var shapeComp = stage.addComponentFromObject(shape); - * geoComp.addRepresentation('buffer'); - */ -var Shape = function Shape(name, params) { - var this$1 = this; - if ( name === void 0 ) name = 'shape'; - if ( params === void 0 ) params = {}; - - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this.bufferList = []; - this.meshCount = 0; - this._primitiveData = {}; - this.name = name; - this.parameters = createParams(params, ShapeDefaultParameters); - Primitives.forEach(function (P) { - Object.keys(P.fields).forEach(function (name) { - this$1._primitiveData[P.getShapeKey(name)] = []; - }); - this$1._primitiveData[P.getShapeKey('name')] = []; - }); -}; - -var prototypeAccessors$o = { center: { configurable: true },type: { configurable: true } }; -/** - * Add a buffer - * @param {Buffer} buffer - buffer object - * @return {Shape} this object - */ -Shape.prototype.addBuffer = function addBuffer (buffer) { - this.bufferList.push(buffer); - var geometry = buffer.geometry; // TODO - if (!geometry.boundingBox) { - geometry.computeBoundingBox(); - } - this.boundingBox.union(geometry.boundingBox); - return this; -}; -/** - * Add a mesh - * @example - * shape.addMesh( - * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ], - * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ] - * ); - * - * @param {Float32Array|Array} position - positions - * @param {Float32Array|Array} color - colors - * @param {Uint32Array|Uint16Array|Array} [index] - indices - * @param {Float32Array|Array} [normal] - normals - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addMesh = function addMesh (position, color, index, normal, name) { - position = ensureFloat32Array(position); - color = ensureFloat32Array(color); - if (Array.isArray(index)) { - index = getUintArray(index, position.length); - } - if (normal) { - normal = ensureFloat32Array(normal); - } - var data; - if (normal === undefined || normal.length == 0) { - data = { position: position, color: color, index: index }; - } - else { - data = { position: position, color: color, index: index, normal: normal }; - } - //const data = { position, color, index, normal } - var picking = new MeshPicker(this, Object.assign({ serial: this.meshCount, name: name }, data)); - var meshBuffer = new MeshBuffer(Object.assign({ picking: picking }, data)); - this.bufferList.push(meshBuffer); - tmpBox.setFromArray(position); - this.boundingBox.union(tmpBox); - this.meshCount += 1; - return this; -}; -/** - * Add a sphere - * @example - * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} radius - radius value - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addSphere = function addSphere (position, color, radius, name) { - SpherePrimitive.objectToShape(this, { position: position, color: color, radius: radius, name: name }); - return this; -}; -/** - * Add an ellipsoid - * @example - * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} radius - radius value - * @param {Vector3|Array} majorAxis - major axis vector or array - * @param {Vector3|Array} minorAxis - minor axis vector or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addEllipsoid = function addEllipsoid (position, color, radius, majorAxis, minorAxis, name) { - EllipsoidPrimitive.objectToShape(this, { position: position, color: color, radius: radius, majorAxis: majorAxis, minorAxis: minorAxis, name: name }); - return this; -}; -/** - * Add a torus - * @example - * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} radius - radius value - * @param {Vector3|Array} majorAxis - major axis vector or array - * @param {Vector3|Array} minorAxis - minor axis vector or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addTorus = function addTorus (position, color, radius, majorAxis, minorAxis, name) { - TorusPrimitive.objectToShape(this, { position: position, color: color, radius: radius, majorAxis: majorAxis, minorAxis: minorAxis, name: name }); - return this; -}; -/** - * Add a cylinder - * @example - * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5); - * - * @param {Vector3|Array} position1 - from position vector or array - * @param {Vector3|Array} position2 - to position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} radius - radius value - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addCylinder = function addCylinder (position1, position2, color, radius, name) { - CylinderPrimitive.objectToShape(this, { position1: position1, position2: position2, color: color, radius: radius, name: name }); - return this; -}; -/** - * Add a cone - * @example - * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5); - * - * @param {Vector3|Array} position1 - from position vector or array - * @param {Vector3|Array} position2 - to position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} radius - radius value - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addCone = function addCone (position1, position2, color, radius, name) { - ConePrimitive.objectToShape(this, { position1: position1, position2: position2, color: color, radius: radius, name: name }); - return this; -}; -/** - * Add an arrow - * @example - * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5); - * - * @param {Vector3|Array} position1 - from position vector or array - * @param {Vector3|Array} position2 - to position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} radius - radius value - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addArrow = function addArrow (position1, position2, color, radius, name) { - ArrowPrimitive.objectToShape(this, { position1: position1, position2: position2, color: color, radius: radius, name: name }); - return this; -}; -/** - * Add a box - * @example - * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} size - size value - * @param {Vector3|Array} heightAxis - height axis vector or array - * @param {Vector3|Array} depthAxis - depth axis vector or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addBox = function addBox (position, color, size, heightAxis, depthAxis, name) { - BoxPrimitive.objectToShape(this, { position: position, color: color, size: size, heightAxis: heightAxis, depthAxis: depthAxis, name: name }); - return this; -}; -/** - * Add an octahedron - * @example - * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} size - size value - * @param {Vector3|Array} heightAxis - height axis vector or array - * @param {Vector3|Array} depthAxis - depth axis vector or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addOctahedron = function addOctahedron (position, color, size, heightAxis, depthAxis, name) { - OctahedronPrimitive.objectToShape(this, { position: position, color: color, size: size, heightAxis: heightAxis, depthAxis: depthAxis, name: name }); - return this; -}; -/** - * Add a tetrahedron - * @example - * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} size - size value - * @param {Vector3|Array} heightAxis - height axis vector or array - * @param {Vector3|Array} depthAxis - depth axis vector or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addTetrahedron = function addTetrahedron (position, color, size, heightAxis, depthAxis, name) { - TetrahedronPrimitive.objectToShape(this, { position: position, color: color, size: size, heightAxis: heightAxis, depthAxis: depthAxis, name: name }); - return this; -}; -/** - * Add text - * @example - * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, "Hello"); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {Float} size - size value - * @param {String} text - text value - * @return {Shape} this object - */ -Shape.prototype.addText = function addText (position, color, size, text) { - TextPrimitive.objectToShape(this, { position: position, color: color, size: size, text: text }); - return this; -}; -/** - * Add point - * @example - * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]); - * - * @param {Vector3|Array} position - position vector or array - * @param {Color|Array} color - color object or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addPoint = function addPoint (position, color, name) { - PointPrimitive.objectToShape(this, { position: position, color: color, name: name }); - return this; -}; -/** - * Add a wideline - * @example - * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]); - * - * @param {Vector3|Array} position1 - from position vector or array - * @param {Vector3|Array} position2 - to position vector or array - * @param {Color|Array} color - color object or array - * @param {String} [name] - text - * @return {Shape} this object - */ -Shape.prototype.addWideline = function addWideline (position1, position2, color, linewidth, name) { - this.parameters.linewidth = linewidth; - WidelinePrimitive.objectToShape(this, { position1: position1, position2: position2, color: color, name: name }); - return this; -}; -/** - * Deprecated, use `.addText` - */ -Shape.prototype.addLabel = function addLabel (position, color, size, text) { - console.warn('Shape.addLabel is deprecated, use .addText instead'); - return this.addText(position, color, size, text); -}; -Shape.prototype.getBufferList = function getBufferList () { - var this$1 = this; - - var buffers = []; - Primitives.forEach(function (P) { - if (this$1._primitiveData[P.getShapeKey('color')].length) { - buffers.push(P.bufferFromShape(this$1, this$1.parameters)); - } - }); - return this.bufferList.concat(buffers); -}; -Shape.prototype.dispose = function dispose () { - var this$1 = this; - - this.bufferList.forEach(function (buffer) { - buffer.dispose(); - }); - this.bufferList.length = 0; - Primitives.forEach(function (P) { - Object.keys(P.fields).forEach(function (name) { - this$1._primitiveData[P.getShapeKey(name)].length = 0; - }); - this$1._primitiveData[P.getShapeKey('name')].length = 0; - }); -}; -prototypeAccessors$o.center.get = function () { - if (!this._center) { - this._center = this.boundingBox.getCenter(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); - } - return this._center; -}; -prototypeAccessors$o.type.get = function () { return 'Shape'; }; - -Object.defineProperties( Shape.prototype, prototypeAccessors$o ); - -/** - * @file Buffer Representation - * @author Alexander Rose - * @private - */ -/** - * Representation for showing buffer objects. Good for efficiently showing - * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}. - * Smaller numbers of geometric primitives are more easily shown with help - * from the {@link Shape} class. - * - * __Name:__ _buffer_ - * - * @example - * // add a single red sphere from a buffer to a shape instance - * var shape = new NGL.Shape( "shape" ); - * var sphereBuffer = new NGL.SphereBuffer( { - * position: new Float32Array( [ 0, 0, 0 ] ), - * color: new Float32Array( [ 1, 0, 0 ] ), - * radius: new Float32Array( [ 1 ] ) - * } ); - * shape.addBuffer( sphereBuffer ); - * var shapeComp = stage.addComponentFromObject( shape ); - * shapeComp.addRepresentation( "buffer" ); - * - * @example - * // add a single red sphere from a buffer to a structure component instance - * stage.loadFile( "rcsb://1crn" ).then( function( o ){ - * var sphereBuffer = new NGL.SphereBuffer( { - * position: new Float32Array( [ 0, 0, 0 ] ), - * color: new Float32Array( [ 1, 0, 0 ] ), - * radius: new Float32Array( [ 1 ] ) - * } ); - * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } ); - * } ); - */ -var BufferRepresentation = /*@__PURE__*/(function (Representation$$1) { - function BufferRepresentation(buffer, viewer, params) { - if (!Array.isArray(buffer)) { - buffer = [buffer]; - } - Representation$$1.call(this, buffer, viewer, params); - this.type = 'buffer'; - this.parameters = Object.assign({}, this.parameters, { - colorScheme: null, - colorScale: null, - colorValue: null, - colorDomain: null, - colorMode: null - }); - this.buffer = buffer; - this.init(params); - } - - if ( Representation$$1 ) BufferRepresentation.__proto__ = Representation$$1; - BufferRepresentation.prototype = Object.create( Representation$$1 && Representation$$1.prototype ); - BufferRepresentation.prototype.constructor = BufferRepresentation; - BufferRepresentation.prototype.init = function init (params) { - Representation$$1.prototype.init.call(this, params); - this.build(); - }; - BufferRepresentation.prototype.create = function create () { - this.bufferList.push.apply(this.bufferList, this.buffer); - }; - BufferRepresentation.prototype.attach = function attach (callback) { - var this$1 = this; - - this.bufferList.forEach(function (buffer) { - this$1.viewer.add(buffer); - buffer.setParameters(this$1.getBufferParams()); - }); - this.setVisibility(this.visible); - callback(); - }; - - return BufferRepresentation; -}(Representation)); - -/** - * @file Geometry Buffer - * @author Alexander Rose - * @private - */ -var matrix$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var normalMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["x" /* Matrix3 */](); -function getData(data, geo) { - var geoPosition = geo.attributes.position.array; - var geoIndex = geo.index ? geo.index.array : undefined; - var n = data.position.length / 3; - var m = geoPosition.length / 3; - var size = n * m; - var meshPosition = new Float32Array(size * 3); - var meshNormal = new Float32Array(size * 3); - var meshColor = new Float32Array(size * 3); - var meshIndex; - if (geoIndex) { - meshIndex = getUintArray(n * geoIndex.length, size); - } - return { - position: meshPosition, - color: meshColor, - index: meshIndex, - normal: meshNormal, - primitiveId: data.primitiveId || serialBlockArray(n, m), - picking: data.picking - }; -} -/** - * Geometry buffer. Base class for geometry-based buffers. Used to draw - * geometry primitives given a mesh. - * @interface - */ -var GeometryBuffer = /*@__PURE__*/(function (MeshBuffer$$1) { - function GeometryBuffer(data, params, geo) { - if ( params === void 0 ) params = {}; - - MeshBuffer$$1.call(this, getData(data, geo), params); - this.updateNormals = false; - var geoPosition = geo.attributes.position.array; - var geoNormal = geo.attributes.normal.array; - var geoIndex = geo.index ? geo.index.array : undefined; - this.geoPosition = geoPosition; - this.geoNormal = geoNormal; - this.geoIndex = geoIndex; - this.positionCount = data.position.length / 3; - this.geoPositionCount = geoPosition.length / 3; - this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3); - this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3); - var attributes = this.geometry.attributes; // TODO - this.meshPosition = attributes.position.array; - this.meshColor = attributes.color.array; - this.meshNormal = attributes.normal.array; - this.setAttributes(data); - if (geoIndex) { - var index = this.geometry.getIndex(); - if (!index) { - Log.error('Index is null'); - return; - } - this.meshIndex = index.array; - this.makeIndex(); - } - } - - if ( MeshBuffer$$1 ) GeometryBuffer.__proto__ = MeshBuffer$$1; - GeometryBuffer.prototype = Object.create( MeshBuffer$$1 && MeshBuffer$$1.prototype ); - GeometryBuffer.prototype.constructor = GeometryBuffer; - GeometryBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - if ( initNormals === void 0 ) initNormals = false; - - var attributes = this.geometry.attributes; // TODO - var position, color; - var geoPosition, geoNormal; - var transformedGeoPosition, transformedGeoNormal; - var meshPosition, meshColor, meshNormal; - var updateNormals = this.updateNormals; - if (data.position) { - position = data.position; - geoPosition = this.geoPosition; - meshPosition = this.meshPosition; - transformedGeoPosition = this.transformedGeoPosition; - attributes.position.needsUpdate = true; - if (updateNormals || initNormals) { - geoNormal = this.geoNormal; - meshNormal = this.meshNormal; - transformedGeoNormal = this.transformedGeoNormal; - attributes.normal.needsUpdate = true; - } - } - if (data.color) { - color = data.color; - meshColor = this.meshColor; - attributes.color.needsUpdate = true; - } - var n = this.positionCount; - var m = this.geoPositionCount; - for (var i = 0; i < n; ++i) { - var j = (void 0), l = (void 0); - var k = i * m * 3; - var i3 = i * 3; - if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) { - transformedGeoPosition.set(geoPosition); - matrix$1.makeTranslation(position[i3], position[i3 + 1], position[i3 + 2]); - this.applyPositionTransform(matrix$1, i, i3); - applyMatrix4toVector3array(matrix$1.elements, transformedGeoPosition); - meshPosition.set(transformedGeoPosition, k); - if (updateNormals && transformedGeoNormal) { - transformedGeoNormal.set(geoNormal); - normalMatrix.getNormalMatrix(matrix$1); - applyMatrix3toVector3array(normalMatrix.elements, transformedGeoNormal); - meshNormal.set(transformedGeoNormal, k); - } - else if (initNormals) { - meshNormal.set(geoNormal, k); - } - } - if (color && meshColor) { - for (j = 0; j < m; ++j) { - l = k + 3 * j; - meshColor[l] = color[i3]; - meshColor[l + 1] = color[i3 + 1]; - meshColor[l + 2] = color[i3 + 2]; - } - } - } - }; - GeometryBuffer.prototype.makeIndex = function makeIndex () { - var geoIndex = this.geoIndex; - var meshIndex = this.meshIndex; - if (!geoIndex) - { return; } - var n = this.positionCount; - var m = this.geoPositionCount; - var o = geoIndex.length / 3; - var o3 = o * 3; - for (var i = 0; i < n; ++i) { - var j = i * o3; - var q = j + o3; - meshIndex.set(geoIndex, j); - for (var p = j; p < q; ++p) - { meshIndex[p] += i * m; } - } - }; - - return GeometryBuffer; -}(MeshBuffer)); - -/** - * @file Sphere Geometry Buffer - * @author Alexander Rose - * @private - */ -var scale$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var SphereGeometryBufferDefaultParameters = Object.assign({ - sphereDetail: 1 -}, BufferDefaultParameters); -/** - * Sphere geometry buffer. - * - * @example - * var sphereGeometryBuffer = new SphereGeometryBuffer({ - * position: new Float32Array([ 0, 0, 0 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var SphereGeometryBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function SphereGeometryBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, data, params, new __WEBPACK_IMPORTED_MODULE_0_three__["u" /* IcosahedronBufferGeometry */](1, defaults(params.sphereDetail, 1))); - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) SphereGeometryBuffer.__proto__ = GeometryBuffer$$1; - SphereGeometryBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - SphereGeometryBuffer.prototype.constructor = SphereGeometryBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return SphereGeometryBufferDefaultParameters; }; - SphereGeometryBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i) { - var r = this._radius[i]; - scale$1.set(r, r, r); - matrix.scale(scale$1); - }; - SphereGeometryBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.radius) - { this._radius = data.radius; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - Object.defineProperties( SphereGeometryBuffer.prototype, prototypeAccessors ); - - return SphereGeometryBuffer; -}(GeometryBuffer)); - -ShaderRegistry.add('shader/SphereImpostor.vert', "uniform mat4 projectionMatrixInverse;\nuniform float clipNear;\nvarying float vRadius;\nvarying float vRadiusSq;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\nattribute vec2 mapping;\nattribute float radius;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#endif\n#include matrix_scale\nconst mat4 D = mat4(\n1.0, 0.0, 0.0, 0.0,\n0.0, 1.0, 0.0, 0.0,\n0.0, 0.0, 1.0, 0.0,\n0.0, 0.0, 0.0, -1.0\n);\nmat4 transposeM( in mat4 inMatrix ) {\nvec4 i0 = inMatrix[0];\nvec4 i1 = inMatrix[1];\nvec4 i2 = inMatrix[2];\nvec4 i3 = inMatrix[3];\nmat4 outMatrix = mat4(\nvec4(i0.x, i1.x, i2.x, i3.x),\nvec4(i0.y, i1.y, i2.y, i3.y),\nvec4(i0.z, i1.z, i2.z, i3.z),\nvec4(i0.w, i1.w, i2.w, i3.w)\n);\nreturn outMatrix;\n}\nvoid ComputePointSizeAndPositionInClipCoordSphere(){\nvec2 xbc;\nvec2 ybc;\nmat4 T = mat4(\nradius, 0.0, 0.0, 0.0,\n0.0, radius, 0.0, 0.0,\n0.0, 0.0, radius, 0.0,\nposition.x, position.y, position.z, 1.0\n);\nmat4 R = transposeM( projectionMatrix * modelViewMatrix * T );\nfloat A = dot( R[ 3 ], D * R[ 3 ] );\nfloat B = -2.0 * dot( R[ 0 ], D * R[ 3 ] );\nfloat C = dot( R[ 0 ], D * R[ 0 ] );\nxbc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nxbc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nfloat sx = abs( xbc[ 0 ] - xbc[ 1 ] ) * 0.5;\nA = dot( R[ 3 ], D * R[ 3 ] );\nB = -2.0 * dot( R[ 1 ], D * R[ 3 ] );\nC = dot( R[ 1 ], D * R[ 1 ] );\nybc[ 0 ] = ( -B - sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nybc[ 1 ] = ( -B + sqrt( B * B - 4.0 * A * C ) ) / ( 2.0 * A );\nfloat sy = abs( ybc[ 0 ] - ybc[ 1 ] ) * 0.5;\ngl_Position.xy = vec2( 0.5 * ( xbc.x + xbc.y ), 0.5 * ( ybc.x + ybc.y ) );\ngl_Position.xy -= mapping * vec2( sx, sy );\ngl_Position.xy *= gl_Position.w;\n}\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#endif\nvRadius = radius * matrixScale( modelViewMatrix );\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nmvPosition.z -= vRadius;\ngl_Position = projectionMatrix * vec4( mvPosition.xyz, 1.0 );\nComputePointSizeAndPositionInClipCoordSphere();\nvRadiusSq = vRadius * vRadius;\nvec4 vPoint4 = projectionMatrixInverse * gl_Position;\nvPoint = vPoint4.xyz / vPoint4.w;\nvPointViewPosition = -mvPosition.xyz / mvPosition.w;\n}"); - -ShaderRegistry.add('shader/SphereImpostor.frag', "#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform mat4 projectionMatrix;\nuniform float ortho;\nvarying float vRadius;\nvarying float vRadiusSq;\nvarying vec3 vPoint;\nvarying vec3 vPointViewPosition;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool flag2 = false;\nbool interior = false;\nvec3 cameraPos;\nvec3 cameraNormal;\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nfloat calcClip( vec3 cameraPos ){\nreturn dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nbool Impostor( out vec3 cameraPos, out vec3 cameraNormal ){\nvec3 cameraSpherePos = -vPointViewPosition;\ncameraSpherePos.z += vRadius;\nvec3 rayOrigin = mix( vec3( 0.0, 0.0, 0.0 ), vPoint, ortho );\nvec3 rayDirection = mix( normalize( vPoint ), vec3( 0.0, 0.0, 1.0 ), ortho );\nvec3 cameraSphereDir = mix( cameraSpherePos, rayOrigin - cameraSpherePos, ortho );\nfloat B = dot( rayDirection, cameraSphereDir );\nfloat det = B * B + vRadiusSq - dot( cameraSphereDir, cameraSphereDir );\nif( det < 0.0 ){\ndiscard;\nreturn false;\n}\nfloat sqrtDet = sqrt( det );\nfloat posT = mix( B + sqrtDet, B + sqrtDet, ortho );\nfloat negT = mix( B - sqrtDet, sqrtDet - B, ortho );\ncameraPos = rayDirection * negT + rayOrigin;\n#ifdef NEAR_CLIP\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}else if( calcClip( cameraPos ) > 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}"); - -/** - * @file Mapped Buffer - * @author Alexander Rose - * @private - */ -/** - * Mapped buffer. Sends mapping attribute to the GPU and repeats data in - * others attributes. Used to render imposters. - * @interface - */ -var MappedBuffer = /*@__PURE__*/(function (Buffer$$1) { - function MappedBuffer(mappingType, data, params) { - if ( params === void 0 ) params = {}; - - Buffer$$1.call(this, data, params); - this.index = getUintArray(this.indexSize, this.attributeSize); - this.makeIndex(); - this.initIndex(this.index); - this.addAttributes({ - 'mapping': { type: mappingType, value: null } - }); - this.setAttributes({ primitiveId: serialArray(this.size) }); - } - - if ( Buffer$$1 ) MappedBuffer.__proto__ = Buffer$$1; - MappedBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - MappedBuffer.prototype.constructor = MappedBuffer; - - var prototypeAccessors = { attributeSize: { configurable: true },indexSize: { configurable: true } }; - prototypeAccessors.attributeSize.get = function () { - return this.size * this.mappingSize; - }; - prototypeAccessors.indexSize.get = function () { - return this.size * this.mappingIndicesSize; - }; - MappedBuffer.prototype.addAttributes = function addAttributes (attributes) { - var nullValueAttributes = {}; - for (var name in attributes) { - var a = attributes[name]; - nullValueAttributes[name] = { - type: a.type, - value: null - }; - } - Buffer$$1.prototype.addAttributes.call(this, nullValueAttributes); - }; - MappedBuffer.prototype.getAttributeIndex = function getAttributeIndex (dataIndex) { - return dataIndex * 3 * this.mappingSize; - }; - MappedBuffer.prototype.setAttributes = function setAttributes (data) { - if (data && !data.position && data.position1 && data.position2) { - data.position = calculateCenterArray(data.position1, data.position2); - } - var size = this.size; - var mappingSize = this.mappingSize; - var attributes = this.geometry.attributes; // TODO - var a, d, itemSize, array, n, i, j; - for (var name in data) { - if (name === 'index' || name === 'picking') - { continue; } - d = data[name]; - a = attributes[name]; - itemSize = a.itemSize; - array = a.array; - for (var k = 0; k < size; ++k) { - n = k * itemSize; - i = n * mappingSize; - for (var l = 0; l < mappingSize; ++l) { - j = i + (itemSize * l); - for (var m = 0; m < itemSize; ++m) { - array[j + m] = d[n + m]; - } - } - } - a.needsUpdate = true; - } - }; - MappedBuffer.prototype.makeMapping = function makeMapping () { - var size = this.size; - var mapping = this.mapping; - var mappingSize = this.mappingSize; - var mappingItemSize = this.mappingItemSize; - var attributes = this.geometry.attributes; // TODO - var aMapping = attributes.mapping.array; - for (var v = 0; v < size; v++) { - aMapping.set(mapping, v * mappingItemSize * mappingSize); - } - }; - MappedBuffer.prototype.makeIndex = function makeIndex () { - var size = this.size; - var mappingSize = this.mappingSize; - var mappingIndices = this.mappingIndices; - var mappingIndicesSize = this.mappingIndicesSize; - var index = this.index; - for (var v = 0; v < size; v++) { - var ix = v * mappingIndicesSize; - var it = v * mappingSize; - index.set(mappingIndices, ix); - for (var s = 0; s < mappingIndicesSize; ++s) { - index[ix + s] += it; - } - } - }; - - Object.defineProperties( MappedBuffer.prototype, prototypeAccessors ); - - return MappedBuffer; -}(Buffer)); - -/** - * @file Mapped Quad Buffer - * @author Alexander Rose - * @private - */ -var mapping = new Float32Array([ - -1.0, 1.0, - -1.0, -1.0, - 1.0, 1.0, - 1.0, -1.0 -]); -var mappingIndices = new Uint16Array([ - 0, 1, 2, - 1, 3, 2 -]); -/** - * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors. - * @interface - */ -var MappedQuadBuffer = /*@__PURE__*/(function (MappedBuffer$$1) { - function MappedQuadBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedBuffer$$1.call(this, 'v2', data, params); - } - - if ( MappedBuffer$$1 ) MappedQuadBuffer.__proto__ = MappedBuffer$$1; - MappedQuadBuffer.prototype = Object.create( MappedBuffer$$1 && MappedBuffer$$1.prototype ); - MappedQuadBuffer.prototype.constructor = MappedQuadBuffer; - - var prototypeAccessors = { mapping: { configurable: true },mappingIndices: { configurable: true },mappingIndicesSize: { configurable: true },mappingSize: { configurable: true },mappingItemSize: { configurable: true } }; - prototypeAccessors.mapping.get = function () { return mapping; }; - prototypeAccessors.mappingIndices.get = function () { return mappingIndices; }; - prototypeAccessors.mappingIndicesSize.get = function () { return 6; }; - prototypeAccessors.mappingSize.get = function () { return 4; }; - prototypeAccessors.mappingItemSize.get = function () { return 2; }; - - Object.defineProperties( MappedQuadBuffer.prototype, prototypeAccessors ); - - return MappedQuadBuffer; -}(MappedBuffer)); - -/** - * @file Sphere Impostor Buffer - * @author Alexander Rose - * @private - */ -/** - * Sphere impostor buffer. - * - * @example - * var sphereImpostorBuffer = new SphereImpostorBuffer({ - * position: new Float32Array([ 0, 0, 0 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var SphereImpostorBuffer = /*@__PURE__*/(function (MappedQuadBuffer$$1) { - function SphereImpostorBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedQuadBuffer$$1.call(this, data, params); - this.isImpostor = true; - this.vertexShader = 'SphereImpostor.vert'; - this.fragmentShader = 'SphereImpostor.frag'; - this.addUniforms({ - 'projectionMatrixInverse': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() }, - 'ortho': { value: 0.0 } - }); - this.addAttributes({ - 'radius': { type: 'f', value: null } - }); - this.setAttributes(data); - this.makeMapping(); - } - - if ( MappedQuadBuffer$$1 ) SphereImpostorBuffer.__proto__ = MappedQuadBuffer$$1; - SphereImpostorBuffer.prototype = Object.create( MappedQuadBuffer$$1 && MappedQuadBuffer$$1.prototype ); - SphereImpostorBuffer.prototype.constructor = SphereImpostorBuffer; - - return SphereImpostorBuffer; -}(MappedQuadBuffer)); - -/** - * @file Sphere Buffer - * @author Alexander Rose - * @private - */ -var SphereBufferDefaultParameters = Object.assign({ - disableImpostor: false -}, SphereGeometryBufferDefaultParameters); -/** - * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and - * `params.disableImpostor` the constructor returns either a - * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer} - * @implements {Buffer} - * - * @example - * var sphereBuffer = new SphereBuffer( { - * position: new Float32Array( [ 0, 0, 0 ] ), - * color: new Float32Array( [ 1, 0, 0 ] ), - * radius: new Float32Array( [ 1 ] ) - * } ); - */ -var SphereBuffer = function SphereBuffer(data, params) { - if (!ExtensionFragDepth || (params && params.disableImpostor)) { - return new SphereGeometryBuffer(data, params); - } - else { - return new SphereImpostorBuffer(data, params); - } -}; -BufferRegistry.add('sphere', SphereBuffer); - -ShaderRegistry.add('shader/Point.vert', "uniform float clipNear;\nuniform float clipRadius;\nuniform vec3 clipCenter;\nuniform float size;\nuniform float canvasHeight;\nuniform float pixelRatio;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\nvarying vec3 vViewPosition;\n#endif\n#include common\nvoid main(){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#endif\n#include begin_vertex\n#include project_vertex\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * pixelRatio * ( ( canvasHeight / 2.0 ) / -mvPosition.z );\n#else\ngl_PointSize = size * pixelRatio;\n#endif\n#ifndef PICKING\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n#include radiusclip_vertex\n}"); - -ShaderRegistry.add('shader/Point.frag', "uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\n#ifdef USE_MAP\nif( texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) ).a < 0.5 )\ndiscard;\n#endif\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\n#ifdef USE_MAP\ndiffuseColor *= texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n#endif\n#include color_fragment\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}"); - -/** - * @file Point Buffer - * @author Alexander Rose - * @private - */ -function distance(x0, y0, x1, y1) { - var dx = x1 - x0; - var dy = y1 - y0; - return Math.sqrt(dx * dx + dy * dy); -} -function makePointTexture(params) { - var p = params || {}; - var width = defaults(p.width, 256); - var height = defaults(p.height, 256); - var center = [width / 2, height / 2]; - var radius = Math.min(width / 2, height / 2); - var delta = defaults(p.delta, 1 / (radius + 1)) * radius; - var x = 0; - var y = 0; - var data = new Uint8Array(width * height * 4); - for (var i = 0, il = data.length; i < il; i += 4) { - var dist = distance(x, y, center[0], center[1]); - var value = 1 - smoothstep(radius - delta, radius, dist); - data[i] = value * 255; - data[i + 1] = value * 255; - data[i + 2] = value * 255; - data[i + 3] = value * 255; - if (++x === width) { - x = 0; - y++; - } - } - var tex = new __WEBPACK_IMPORTED_MODULE_0_three__["l" /* DataTexture */](data, width, height); - tex.needsUpdate = true; - return tex; -} -var PointBufferDefaultParameters = Object.assign({ - pointSize: 1, - sizeAttenuation: true, - sortParticles: false, - alphaTest: 0.5, - useTexture: false, - forceTransparent: false, - edgeBleach: 0.0 -}, BufferDefaultParameters); -var PointBufferParameterTypes = Object.assign({ - pointSize: { uniform: 'size' }, - sizeAttenuation: { updateShader: true }, - sortParticles: {}, - alphaTest: { updateShader: true }, - useTexture: { updateShader: true }, - forceTransparent: {}, - edgeBleach: { uniform: true } -}, BufferParameterTypes); -/** - * Point buffer. Draws points. Optionally textured. - * - * @example - * var pointBuffer = new PointBuffer( { - * position: new Float32Array( [ 0, 0, 0 ] ), - * color: new Float32Array( [ 1, 0, 0 ] ) - * } ); - */ -var PointBuffer = /*@__PURE__*/(function (Buffer$$1) { - function PointBuffer(data, params) { - if ( params === void 0 ) params = {}; - - Buffer$$1.call(this, data, params); - this.parameterTypes = PointBufferParameterTypes; - this.vertexShader = 'Point.vert'; - this.fragmentShader = 'Point.frag'; - this.isPoint = true; - this.addUniforms({ - 'size': { value: this.parameters.pointSize }, - 'canvasHeight': { value: 1.0 }, - 'pixelRatio': { value: 1.0 }, - 'map': { value: null } - }); - } - - if ( Buffer$$1 ) PointBuffer.__proto__ = Buffer$$1; - PointBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - PointBuffer.prototype.constructor = PointBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return PointBufferDefaultParameters; }; - PointBuffer.prototype.makeMaterial = function makeMaterial () { - Buffer$$1.prototype.makeMaterial.call(this); - this.makeTexture(); - var m = this.material; - var wm = this.wireframeMaterial; - var pm = this.pickingMaterial; - m.uniforms.map.value = this.tex; - m.needsUpdate = true; - wm.uniforms.map.value = this.tex; - wm.needsUpdate = true; - pm.uniforms.map.value = this.tex; - pm.needsUpdate = true; - }; - PointBuffer.prototype.makeTexture = function makeTexture () { - if (this.tex) - { this.tex.dispose(); } - this.tex = makePointTexture({ delta: this.parameters.edgeBleach }); - }; - PointBuffer.prototype.getDefines = function getDefines (type) { - var defines = Buffer$$1.prototype.getDefines.call(this, type); - if (this.parameters.sizeAttenuation) { - defines.USE_SIZEATTENUATION = 1; - } - if (this.parameters.useTexture) { - defines.USE_MAP = 1; - } - if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) { - defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2); - } - return defines; - }; - PointBuffer.prototype.setUniforms = function setUniforms (data) { - if (data && data.edgeBleach !== undefined) { - this.makeTexture(); - data.map = this.tex; - } - Buffer$$1.prototype.setUniforms.call(this, data); - }; - PointBuffer.prototype.dispose = function dispose () { - Buffer$$1.prototype.dispose.call(this); - if (this.tex) - { this.tex.dispose(); } - }; - - Object.defineProperties( PointBuffer.prototype, prototypeAccessors ); - - return PointBuffer; -}(Buffer)); -BufferRegistry.add('point', PointBuffer); - -/** - * @file Dot Representation - * @author Alexander Rose - * @private - */ -/** - * Dot representation - */ -var DotRepresentation = /*@__PURE__*/(function (Representation$$1) { - function DotRepresentation(surface, viewer, params) { - Representation$$1.call(this, surface, viewer, params); - this.type = 'dot'; - this.parameters = Object.assign({ - thresholdType: { - type: 'select', - rebuild: true, - options: { - 'value': 'value', 'sigma': 'sigma' - } - }, - thresholdMin: { - type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true - }, - thresholdMax: { - type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true - }, - thresholdOut: { - type: 'boolean', rebuild: true - }, - dotType: { - type: 'select', - rebuild: true, - options: { - '': '', - 'sphere': 'sphere', - 'point': 'point' - } - }, - radiusType: { - type: 'select', - options: { - '': '', - 'value': 'value', - 'abs-value': 'abs-value', - 'value-min': 'value-min', - 'deviation': 'deviation', - 'size': 'size' - } - }, - radius: { - type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size' - }, - scale: { - type: 'number', precision: 3, max: 10.0, min: 0.001 - }, - sphereDetail: true, - disableImpostor: true, - pointSize: { - type: 'number', precision: 1, max: 100, min: 0, buffer: true - }, - sizeAttenuation: { - type: 'boolean', buffer: true - }, - sortParticles: { - type: 'boolean', rebuild: true - }, - useTexture: { - type: 'boolean', buffer: true - }, - alphaTest: { - type: 'range', step: 0.001, max: 1, min: 0, buffer: true - }, - forceTransparent: { - type: 'boolean', buffer: true - }, - edgeBleach: { - type: 'range', step: 0.001, max: 1, min: 0, buffer: true - } - }, this.parameters, { - colorScheme: { - type: 'select', - update: 'color', - options: { - '': '', - 'value': 'value', - 'uniform': 'uniform', - 'random': 'random' - } - } - }); - if (surface instanceof Volume) { - this.surface = undefined; - this.volume = new FilteredVolume(surface); - } - else { - this.surface = surface; - this.volume = undefined; - } - this.init(params); - } - - if ( Representation$$1 ) DotRepresentation.__proto__ = Representation$$1; - DotRepresentation.prototype = Object.create( Representation$$1 && Representation$$1.prototype ); - DotRepresentation.prototype.constructor = DotRepresentation; - DotRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'uniform'); - p.colorValue = defaults(p.colorValue, 0xDDDDDD); - this.thresholdType = defaults(p.thresholdType, 'sigma'); - this.thresholdMin = defaults(p.thresholdMin, 2.0); - this.thresholdMax = defaults(p.thresholdMax, Infinity); - this.thresholdOut = defaults(p.thresholdOut, false); - this.dotType = defaults(p.dotType, 'point'); - this.radius = defaults(p.radius, 0.1); - this.scale = defaults(p.scale, 1.0); - this.pointSize = defaults(p.pointSize, 1); - this.sizeAttenuation = defaults(p.sizeAttenuation, true); - this.sortParticles = defaults(p.sortParticles, false); - this.useTexture = defaults(p.useTexture, false); - this.alphaTest = defaults(p.alphaTest, 0.5); - this.forceTransparent = defaults(p.forceTransparent, false); - this.edgeBleach = defaults(p.edgeBleach, 0.0); - Representation$$1.prototype.init.call(this, p); - this.build(); - }; - DotRepresentation.prototype.attach = function attach (callback) { - var this$1 = this; - - this.bufferList.forEach(function (buffer) { - this$1.viewer.add(buffer); - }); - this.setVisibility(this.visible); - callback(); - }; - DotRepresentation.prototype.create = function create () { - var dotData = {}; - if (this.volume) { - var volume = this.volume; - var thresholdMin, thresholdMax; - if (this.thresholdType === 'sigma') { - thresholdMin = volume.getValueForSigma(this.thresholdMin); - thresholdMax = volume.getValueForSigma(this.thresholdMax); - } - else { - thresholdMin = this.thresholdMin; - thresholdMax = this.thresholdMax; - } - volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut); - Object.assign(dotData, { - position: volume.getDataPosition(), - color: volume.getDataColor(this.getColorParams()) - }); - if (this.dotType === 'sphere') { - Object.assign(dotData, { - radius: volume.getDataSize(this.radius, this.scale), - picking: volume.getDataPicking() - }); - } - } - else { - var surface = this.surface; - Object.assign(dotData, { - position: surface.getPosition(), - color: surface.getColor(this.getColorParams()) - }); - if (this.dotType === 'sphere') { - Object.assign(dotData, { - radius: surface.getSize(this.radius, this.scale), - picking: surface.getPicking() - }); - } - } - if (this.dotType === 'sphere') { - this.dotBuffer = new SphereBuffer(dotData, this.getBufferParams({ - sphereDetail: this.sphereDetail, - disableImpostor: this.disableImpostor, - dullInterior: false - })); - } - else { - this.dotBuffer = new PointBuffer(dotData, this.getBufferParams({ - pointSize: this.pointSize, - sizeAttenuation: this.sizeAttenuation, - sortParticles: this.sortParticles, - useTexture: this.useTexture, - alphaTest: this.alphaTest, - forceTransparent: this.forceTransparent, - edgeBleach: this.edgeBleach - })); - } - this.bufferList.push(this.dotBuffer); - }; - DotRepresentation.prototype.update = function update (what) { - if ( what === void 0 ) what = {}; - - if (this.bufferList.length === 0) - { return; } - var dotData = {}; - if (what.color) { - if (this.volume) { - Object.assign(dotData, { - color: this.volume.getDataColor(this.getColorParams()) - }); - } - else { - Object.assign(dotData, { - color: this.surface.getColor(this.getColorParams()) - }); - } - } - if (this.dotType === 'sphere' && (what.radius || what.scale)) { - if (this.volume) { - Object.assign(dotData, { - radius: this.volume.getDataSize(this.radius, this.scale) - }); - } - else { - Object.assign(dotData, { - radius: this.surface.getSize(this.radius, this.scale) - }); - } - } - this.dotBuffer.setAttributes(dotData); - }; - DotRepresentation.prototype.setParameters = function setParameters (params, what, rebuild) { - if ( what === void 0 ) what = {}; - - if (params && params.thresholdType !== undefined && - this.volume instanceof Volume) { - if (this.thresholdType === 'value' && - params.thresholdType === 'sigma') { - this.thresholdMin = this.volume.getSigmaForValue(this.thresholdMin); - this.thresholdMax = this.volume.getSigmaForValue(this.thresholdMax); - } - else if (this.thresholdType === 'sigma' && - params.thresholdType === 'value') { - this.thresholdMin = this.volume.getValueForSigma(this.thresholdMin); - this.thresholdMax = this.volume.getValueForSigma(this.thresholdMax); - } - this.thresholdType = params.thresholdType; - } - if (params && params.radiusType !== undefined) { - if (params.radiusType === 'radius') { - this.radius = 0.1; - } - else { - this.radius = parseFloat(params.radiusType); - } - what.radius = true; - if (this.dotType === 'sphere' && - (!ExtensionFragDepth || this.disableImpostor)) { - rebuild = true; - } - } - if (params && params.radius !== undefined) { - what.radius = true; - if (this.dotType === 'sphere' && - (!ExtensionFragDepth || this.disableImpostor)) { - rebuild = true; - } - } - if (params && params.scale !== undefined) { - what.scale = true; - if (this.dotType === 'sphere' && - (!ExtensionFragDepth || this.disableImpostor)) { - rebuild = true; - } - } - Representation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - - return DotRepresentation; -}(Representation)); - -ShaderRegistry.add('shader/Image.vert', "uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"); - -ShaderRegistry.add('shader/Image.frag', "uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}"); - -/** - * @file Image Buffer - * @author Alexander Rose - * @private - */ -var quadIndices = new Uint16Array([ - 0, 1, 2, - 1, 3, 2 -]); -var quadUvs = new Float32Array([ - 0, 1, - 0, 0, - 1, 1, - 1, 0 -]); -var ImageBufferDefaultParameters = Object.assign({ - filter: 'nearest', - forceTransparent: true -}, BufferDefaultParameters); -var ImageBufferParameterTypes = Object.assign({ - filter: { updateShader: true, uniform: true } -}, BufferParameterTypes); -/** - * Image buffer. Draw a single image. Optionally interpolate. - */ -var ImageBuffer = /*@__PURE__*/(function (Buffer$$1) { - function ImageBuffer(data, params) { - Buffer$$1.call(this, { - position: data.position, - index: quadIndices, - picking: data.picking - }, params); - this.parameterTypes = ImageBufferParameterTypes; - this.alwaysTransparent = true; - this.hasWireframe = false; - this.vertexShader = 'Image.vert'; - this.fragmentShader = 'Image.frag'; - var imageData = data.imageData; - var width = data.width; - var height = data.height; - var tex = new __WEBPACK_IMPORTED_MODULE_0_three__["l" /* DataTexture */](imageData, width, height); - tex.flipY = true; - this.tex = tex; - var n = imageData.length; - var pickingData = new Uint8Array(n); - for (var i = 0; i < n; i += 4) { - var j = i / 4; - pickingData[i] = j >> 16 & 255; - pickingData[i + 1] = j >> 8 & 255; - pickingData[i + 2] = j & 255; - } - var pickingTex = new __WEBPACK_IMPORTED_MODULE_0_three__["l" /* DataTexture */](pickingData, width, height); - pickingTex.flipY = true; - pickingTex.minFilter = __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */]; - pickingTex.magFilter = __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */]; - this.pickingTex = pickingTex; - this.addUniforms({ - 'map': { value: tex }, - 'pickingMap': { value: pickingTex }, - 'mapSize': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */](width, height) } - }); - this.geometry.setAttribute('uv', new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](quadUvs, 2)); - } - - if ( Buffer$$1 ) ImageBuffer.__proto__ = Buffer$$1; - ImageBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - ImageBuffer.prototype.constructor = ImageBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return ImageBufferDefaultParameters; }; - ImageBuffer.prototype.getDefines = function getDefines (type) { - var defines = Buffer$$1.prototype.getDefines.call(this, type); - var filter = this.parameters.filter; - if (filter.startsWith('cubic')) { - defines.CUBIC_INTERPOLATION = 1; - if (filter.endsWith('bspline')) { - defines.BSPLINE_FILTER = 1; - } - else if (filter.endsWith('catmulrom')) { - defines.CATMULROM_FILTER = 1; - } - else if (filter.endsWith('mitchell')) { - defines.MITCHELL_FILTER = 1; - } - } - return defines; - }; - ImageBuffer.prototype.updateTexture = function updateTexture () { - var tex = this.tex; - var filter = this.parameters.filter; - if (filter.startsWith('cubic')) { - tex.minFilter = __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */]; - tex.magFilter = __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */]; - } - else if (filter === 'linear') { - tex.minFilter = __WEBPACK_IMPORTED_MODULE_0_three__["w" /* LinearFilter */]; - tex.magFilter = __WEBPACK_IMPORTED_MODULE_0_three__["w" /* LinearFilter */]; - } - else { // filter === "nearest" - tex.minFilter = __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */]; - tex.magFilter = __WEBPACK_IMPORTED_MODULE_0_three__["A" /* NearestFilter */]; - } - tex.needsUpdate = true; - this.pickingTex.needsUpdate = true; - }; - ImageBuffer.prototype.makeMaterial = function makeMaterial () { - Buffer$$1.prototype.makeMaterial.call(this); - this.updateTexture(); - var m = this.material; - m.uniforms.map.value = this.tex; - m.blending = __WEBPACK_IMPORTED_MODULE_0_three__["C" /* NormalBlending */]; - m.needsUpdate = true; - var wm = this.wireframeMaterial; - wm.uniforms.map.value = this.tex; - wm.blending = __WEBPACK_IMPORTED_MODULE_0_three__["C" /* NormalBlending */]; - wm.needsUpdate = true; - var pm = this.pickingMaterial; - pm.uniforms.map.value = this.tex; - pm.uniforms.pickingMap.value = this.pickingTex; - pm.blending = __WEBPACK_IMPORTED_MODULE_0_three__["C" /* NormalBlending */]; - pm.needsUpdate = true; - }; - ImageBuffer.prototype.setUniforms = function setUniforms (data) { - if (data && data.filter !== undefined) { - this.updateTexture(); - data.map = this.tex; - } - Buffer$$1.prototype.setUniforms.call(this, data); - }; - - Object.defineProperties( ImageBuffer.prototype, prototypeAccessors ); - - return ImageBuffer; -}(Buffer)); - -/** - * @file Volume Slice - * @author Alexander Rose - * @private - */ -var VolumeSlice = function VolumeSlice(volume, params) { - var p = params || {}; - this.dimension = defaults(p.dimension, 'x'); - this.positionType = defaults(p.positionType, 'percent'); - this.position = defaults(p.position, 30); - this.thresholdType = defaults(p.thresholdType, 'sigma'); - this.thresholdMin = defaults(p.thresholdMin, -Infinity); - this.thresholdMax = defaults(p.thresholdMax, Infinity); - this.normalize = defaults(p.normalize, false); - this.volume = volume; -}; -VolumeSlice.prototype.getPositionFromCoordinate = function getPositionFromCoordinate (coord) { - var dim = this.dimension; - var v = this.volume; - var m = v.matrix; - var mp = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().setFromMatrixPosition(m)[dim]; - var ms = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().setFromMatrixScale(m)[dim]; - var vn; - if (dim === 'x') { - vn = v.nx; - } - else if (dim === 'y') { - vn = v.ny; - } - else { - vn = v.nz; - } - return Math.round((((coord - mp) / (vn / 100)) + 1) / ms); -}; -VolumeSlice.prototype.getData = function getData (params) { - params = params || {}; - var v = this.volume; - var d = v.data; - var m = v.matrix; - var p; - if (this.positionType === 'coordinate') { - p = this.getPositionFromCoordinate(this.position); - } - else { - p = this.position; - } - function pos(dimLen) { - return Math.round((dimLen / 100) * (p - 1)); - } - function index(x, y, z, i) { - return (z * v.ny * v.nx + y * v.nx + x) * 3 + i; - } - var position = new Float32Array(4 * 3); - var vec = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var width, height; - var x; - var y; - var z; - var x0 = 0; - var y0 = 0; - var z0 = 0; - var nx = v.nx; - var ny = v.ny; - var nz = v.nz; - function setVec(x, y, z, offset) { - vec.set(x, y, z).applyMatrix4(m).toArray(position, offset); - } - if (this.dimension === 'x') { - x = pos(v.nx); - y = v.ny - 1; - z = v.nz - 1; - width = v.nz; - height = v.ny; - x0 = x; - nx = x0 + 1; - setVec(x, 0, 0, 0); - setVec(x, y, 0, 3); - setVec(x, 0, z, 6); - setVec(x, y, z, 9); - } - else if (this.dimension === 'y') { - x = v.nx - 1; - y = pos(v.ny); - z = v.nz - 1; - width = v.nz; - height = v.nx; - y0 = y; - ny = y0 + 1; - setVec(0, y, 0, 0); - setVec(x, y, 0, 3); - setVec(0, y, z, 6); - setVec(x, y, z, 9); - } - else if (this.dimension === 'z') { - x = v.nx - 1; - y = v.ny - 1; - z = pos(v.nz); - width = v.nx; - height = v.ny; - z0 = z; - nz = z0 + 1; - setVec(0, 0, z, 0); - setVec(0, y, z, 3); - setVec(x, 0, z, 6); - setVec(x, y, z, 9); - } - var i = 0; - var j = 0; - var imageData = new Uint8Array(width * height * 4); - var pickingArray = new Float32Array(width * height); - var tMin, tMax; - if (this.thresholdType === 'sigma') { - tMin = v.getValueForSigma(this.thresholdMin); - tMax = v.getValueForSigma(this.thresholdMax); - } - else { - tMin = this.thresholdMin; - tMax = this.thresholdMax; - } - var cp = Object.assign({}, params.colorParams, { volume: v }); - if (this.normalize) { - cp.domain = [0, 1]; - } - var colormaker = ColormakerRegistry$1.getScheme(cp); - var tmp = new Float32Array(3); - var scale$$1 = colormaker.getScale(); - var min = 0, max, diff = 0; - if (this.normalize) { - min = +Infinity; - max = -Infinity; - for (var iy = y0; iy < ny; ++iy) { - for (var ix = x0; ix < nx; ++ix) { - for (var iz = z0; iz < nz; ++iz) { - var idx = index(ix, iy, iz, 0) / 3; - var val = d[idx]; - if (val < min) - { min = val; } - if (val > max) - { max = val; } - } - } - } - diff = max - min; - } - for (var iy$1 = y0; iy$1 < ny; ++iy$1) { - for (var ix$1 = x0; ix$1 < nx; ++ix$1) { - for (var iz$1 = z0; iz$1 < nz; ++iz$1) { - var idx$1 = index(ix$1, iy$1, iz$1, 0) / 3; - var val$1 = d[idx$1]; - if (this.normalize) { - val$1 = (val$1 - min) / diff; - } - colormaker.colorToArray(scale$$1(val$1), tmp); - imageData[i] = Math.round(tmp[0] * 255); - imageData[i + 1] = Math.round(tmp[1] * 255); - imageData[i + 2] = Math.round(tmp[2] * 255); - imageData[i + 3] = (val$1 > tMin && val$1 < tMax) ? 255 : 0; - pickingArray[j] = idx$1; - ++j; - i += 4; - } - } - } - var picking = new SlicePicker(pickingArray, v); - return { position: position, imageData: imageData, width: width, height: height, picking: picking }; -}; - -/** - * @file Slice Representation - * @author Alexander Rose - * @private - */ -/** - * Slice representation - */ -var SliceRepresentation = /*@__PURE__*/(function (Representation$$1) { - function SliceRepresentation(volume, viewer, params) { - Representation$$1.call(this, volume, viewer, params); - this.type = 'slice'; - this.parameters = Object.assign({ - filter: { - type: 'select', - buffer: true, - options: { - 'nearest': 'nearest', - 'linear': 'linear', - 'cubic-bspline': 'cubic-bspline', - 'cubic-catmulrom': 'cubic-catmulrom', - 'cubic-mitchell': 'cubic-mitchell' - } - }, - positionType: { - type: 'select', - rebuild: true, - options: { - 'percent': 'percent', 'coordinate': 'coordinate' - } - }, - position: { - type: 'range', - step: 0.1, - max: 100, - min: 1, - rebuild: true - }, - dimension: { - type: 'select', - rebuild: true, - options: { - 'x': 'x', 'y': 'y', 'z': 'z' - } - }, - thresholdType: { - type: 'select', - rebuild: true, - options: { - 'value': 'value', 'sigma': 'sigma' - } - }, - thresholdMin: { - type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true - }, - thresholdMax: { - type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true - }, - normalize: { - type: 'boolean', rebuild: true - } - }, this.parameters, { - flatShaded: null, - side: null, - wireframe: null, - linewidth: null, - colorScheme: null, - roughness: null, - metalness: null, - diffuse: null - }); - this.volume = volume; - this.init(params); - } - - if ( Representation$$1 ) SliceRepresentation.__proto__ = Representation$$1; - SliceRepresentation.prototype = Object.create( Representation$$1 && Representation$$1.prototype ); - SliceRepresentation.prototype.constructor = SliceRepresentation; - SliceRepresentation.prototype.init = function init (params) { - var v = this.volume; - var p = params || {}; - p.colorDomain = defaults(p.colorDomain, [v.min, v.max]); - p.colorScheme = defaults(p.colorScheme, 'value'); - p.colorScale = defaults(p.colorScale, 'Spectral'); - this.colorScheme = 'value'; - this.dimension = defaults(p.dimension, 'x'); - this.filter = defaults(p.filter, 'cubic-bspline'); - this.positionType = defaults(p.positionType, 'percent'); - this.position = defaults(p.position, 30); - this.thresholdType = defaults(p.thresholdType, 'sigma'); - this.thresholdMin = defaults(p.thresholdMin, -Infinity); - this.thresholdMax = defaults(p.thresholdMax, Infinity); - this.normalize = defaults(p.normalize, false); - Representation$$1.prototype.init.call(this, p); - this.build(); - }; - SliceRepresentation.prototype.attach = function attach (callback) { - var this$1 = this; - - this.bufferList.forEach(function (buffer) { - this$1.viewer.add(buffer); - }); - this.setVisibility(this.visible); - callback(); - }; - SliceRepresentation.prototype.create = function create () { - var volumeSlice = new VolumeSlice(this.volume, { - positionType: this.positionType, - position: this.position, - dimension: this.dimension, - thresholdType: this.thresholdType, - thresholdMin: this.thresholdMin, - thresholdMax: this.thresholdMax, - normalize: this.normalize - }); - var sliceBuffer = new ImageBuffer(volumeSlice.getData({ colorParams: this.getColorParams() }), this.getBufferParams({ - filter: this.filter - })); - this.bufferList.push(sliceBuffer); - }; - - return SliceRepresentation; -}(Representation)); - -/** - * @file Representation Utils - * @author Alexander Rose - * @private - */ -function logReprUnknown(type) { - Log.error(("makeRepresentation: representation type " + type + " unknown")); -} -function makeRepresentation(type, object, viewer, params) { - if (Debug) - { Log.time('makeRepresentation ' + type); } - var ReprClass; - if (object instanceof Structure) { - ReprClass = RepresentationRegistry.get(type); - if (!ReprClass) { - logReprUnknown(type); - return; - } - } - else if (object instanceof Surface) { - if (type === 'surface') { - ReprClass = SurfaceRepresentation; - } - else if (type === 'dot') { - ReprClass = DotRepresentation; - } - else { - logReprUnknown(type); - return; - } - } - else if (object instanceof Volume) { - if (type === 'surface') { - ReprClass = SurfaceRepresentation; - } - else if (type === 'dot') { - ReprClass = DotRepresentation; - } - else if (type === 'slice') { - ReprClass = SliceRepresentation; - } - else { - logReprUnknown(type); - return; - } - } - else if (object instanceof Shape) { - ReprClass = BufferRepresentation; - object = object.getBufferList(); - } - else if (type === 'buffer') { - ReprClass = BufferRepresentation; - } - else { - Log.error('makeRepresentation: object ' + object + ' unknown'); - return; - } - var repr = new ReprClass(object, viewer, params); - if (Debug) - { Log.timeEnd('makeRepresentation ' + type); } - return repr; -} - -/** - * @file Element - * @author Alexander Rose - * @private - */ -var ElementDefaultParameters = { - name: 'some element', - status: '' -}; -/** - * Element base class - */ -var Element = function Element(stage, params) { - if ( params === void 0 ) params = {}; - - this.stage = stage; - /** - * Events emitted by the element - */ - this.signals = { - statusChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - nameChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - disposed: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.parameters = createParams(params, this.defaultParameters); - this.uuid = generateUUID(); -}; - -var prototypeAccessors$p = { defaultParameters: { configurable: true },name: { configurable: true } }; -prototypeAccessors$p.defaultParameters.get = function () { return ElementDefaultParameters; }; -prototypeAccessors$p.name.get = function () { return this.parameters.name; }; -Element.prototype.setStatus = function setStatus (value) { - this.parameters.status = value; - this.signals.statusChanged.dispatch(value); - return this; -}; -Element.prototype.setName = function setName (value) { - this.parameters.name = value; - this.signals.nameChanged.dispatch(value); - return this; -}; -Element.prototype.dispose = function dispose () { - this.signals.disposed.dispatch(); -}; - -Object.defineProperties( Element.prototype, prototypeAccessors$p ); - -/** - * @file Representation Element - * @author Alexander Rose - * @private - */ -var RepresentationElementDefaultParameters = Object.assign({ - visible: true -}, ElementDefaultParameters); -/** - * Element wrapping a {@link Representation} object - */ -var RepresentationElement = /*@__PURE__*/(function (Element$$1) { - function RepresentationElement(stage, repr, params, parent) { - if ( params === void 0 ) params = {}; - - Element$$1.call(this, stage, Object.assign({ name: repr.type }, params)); - this.parent = parent; - this.signals = Object.assign({ - visibilityChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - parametersChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }, this.signals); - this.setRepresentation(repr); - } - - if ( Element$$1 ) RepresentationElement.__proto__ = Element$$1; - RepresentationElement.prototype = Object.create( Element$$1 && Element$$1.prototype ); - RepresentationElement.prototype.constructor = RepresentationElement; - - var prototypeAccessors = { defaultParameters: { configurable: true },visible: { configurable: true },type: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return RepresentationElementDefaultParameters; }; - prototypeAccessors.visible.get = function () { return this.parameters.visible; }; - /** - * Component type - * @type {String} - */ - prototypeAccessors.type.get = function () { return 'representation'; }; - RepresentationElement.prototype.getType = function getType () { - return this.repr.type; - }; - RepresentationElement.prototype.setRepresentation = function setRepresentation (repr) { - this._disposeRepresentation(); - this.repr = repr; - // this.name = repr.type; - this.stage.tasks.listen(this.repr.tasks); - this.updateVisibility(); - }; - RepresentationElement.prototype._disposeRepresentation = function _disposeRepresentation () { - if (this.repr) { - this.stage.tasks.unlisten(this.repr.tasks); - this.repr.dispose(); - } - }; - RepresentationElement.prototype.dispose = function dispose () { - if (this.parent && this.parent.hasRepresentation(this)) { - this.parent.removeRepresentation(this); - } - else { - this._disposeRepresentation(); - this.signals.disposed.dispatch(); - } - }; - /** - * Set the visibility of the component, takes parent visibility into account - * @param {Boolean} value - visibility flag - * @return {RepresentationElement} this object - */ - RepresentationElement.prototype.setVisibility = function setVisibility (value) { - this.parameters.visible = value; - this.updateVisibility(); - this.signals.visibilityChanged.dispatch(this.parameters.visible); - return this; - }; - RepresentationElement.prototype.getVisibility = function getVisibility () { - if (this.parent) { - return this.parent.parameters.visible && this.parameters.visible; - } - else { - return this.parameters.visible; - } - }; - /** - * Toggle visibility of the component, takes parent visibility into account - * @return {RepresentationElement} this object - */ - RepresentationElement.prototype.toggleVisibility = function toggleVisibility () { - return this.setVisibility(!this.parameters.visible); - }; - RepresentationElement.prototype.updateVisibility = function updateVisibility () { - this.repr.setVisibility(this.getVisibility()); - }; - /** - * Set selection - * @param {Object} what - flags indicating what attributes to update - * @param {Boolean} what.position - update position attribute - * @param {Boolean} what.color - update color attribute - * @param {Boolean} what.radius - update radius attribute - * @return {RepresentationElement} this object - */ - RepresentationElement.prototype.update = function update (what) { - this.repr.update(what); // TODO - return this; - }; - RepresentationElement.prototype.build = function build (params) { - this.repr.build(params); - return this; - }; - /** - * Set selection - * @param {String} string - selection string - * @return {RepresentationElement} this object - */ - RepresentationElement.prototype.setSelection = function setSelection (string) { - var repr = this.repr; // TODO - if (repr.setSelection) { - repr.setSelection(string); - } - return this; - }; - /** - * Set representation parameters - * @param {RepresentationParameters} params - parameter object - * @return {RepresentationElement} this object - */ - RepresentationElement.prototype.setParameters = function setParameters (params) { - this.repr.setParameters(params); - this.signals.parametersChanged.dispatch(this.repr.getParameters()); - return this; - }; - /** - * Get representation parameters - * @return {RepresentationParameters} parameter object - */ - RepresentationElement.prototype.getParameters = function getParameters () { - return this.repr.getParameters(); - }; - /** - * Set color - * @param {String|Color|Hex} value - color value - * @return {RepresentationElement} this object - */ - RepresentationElement.prototype.setColor = function setColor (value) { - this.repr.setColor(value); - return this; - }; - - Object.defineProperties( RepresentationElement.prototype, prototypeAccessors ); - - return RepresentationElement; -}(Element)); - -/** - * @file Component - * @author Alexander Rose - * @private - */ -var _m = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); -var _v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var ComponentDefaultParameters = { - name: '', - status: '', - visible: true -}; -/** - * Base class for components - */ -var Component = function Component(stage, object, params) { - if ( params === void 0 ) params = {}; - - this.stage = stage; - this.object = object; - /** - * Events emitted by the component - */ - this.signals = { - representationAdded: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - representationRemoved: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - visibilityChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - matrixChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - statusChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - nameChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - disposed: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.reprList = []; - this.annotationList = []; - this.matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.position = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.quaternion = new __WEBPACK_IMPORTED_MODULE_0_three__["J" /* Quaternion */](); - this.scale = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](1, 1, 1); - this.transform = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.parameters = createParams(params, this.defaultParameters); - this.uuid = generateUUID(); - this.viewer = stage.viewer; - this.controls = new ComponentControls(this); -}; - -var prototypeAccessors$q = { defaultParameters: { configurable: true },name: { configurable: true },status: { configurable: true },visible: { configurable: true } }; -prototypeAccessors$q.defaultParameters.get = function () { return ComponentDefaultParameters; }; -prototypeAccessors$q.name.get = function () { return this.parameters.name; }; -prototypeAccessors$q.status.get = function () { return this.parameters.status; }; -prototypeAccessors$q.visible.get = function () { return this.parameters.visible; }; -/** - * Set position transform - * - * @example - * // translate by 25 angstrom along x axis - * component.setPosition([ 25, 0, 0 ]); - * - * @param {Vector3|Array} p - the coordinates - * @return {Component} this object - */ -Component.prototype.setPosition = function setPosition (p) { - if (Array.isArray(p)) { - this.position.fromArray(p); - } - else { - this.position.copy(p); - } - this.updateMatrix(); - return this; -}; -/** - * Set local rotation transform - * (for global rotation use setTransform) - * - * @example - * // rotate by 2 degree radians on x axis - * component.setRotation( [ 2, 0, 0 ] ); - * - * @param {Quaternion|Euler|Array} r - the rotation - * @return {Component} this object - */ -Component.prototype.setRotation = function setRotation (r) { - if (Array.isArray(r)) { - if (r.length === 3) { - var e = new __WEBPACK_IMPORTED_MODULE_0_three__["n" /* Euler */]().fromArray(r); - this.quaternion.setFromEuler(e); - } - else { - this.quaternion.fromArray(r); - } - } - else if (r instanceof __WEBPACK_IMPORTED_MODULE_0_three__["n" /* Euler */]) { - this.quaternion.setFromEuler(r); - } - else { - this.quaternion.copy(r); - } - this.updateMatrix(); - return this; -}; -/** - * Set scale transform - * - * @example - * // scale by factor of two - * component.setScale( 2 ); - * - * @param {Number} s - the scale - * @return {Component} this object - */ -Component.prototype.setScale = function setScale (s) { - this.scale.set(s, s, s); - this.updateMatrix(); - return this; -}; -/** - * Set general transform. Is applied before and in addition - * to the position, rotation and scale transformations - * - * @example - * component.setTransform( matrix ); - * - * @param {Matrix4} m - the matrix - * @return {Component} this object - */ -Component.prototype.setTransform = function setTransform (m) { - this.transform.copy(m); - this.updateMatrix(); - return this; -}; -Component.prototype.updateMatrix = function updateMatrix () { - var c = this.getCenterUntransformed(_v); - this.matrix.makeTranslation(-c.x, -c.y, -c.z); - _m.makeRotationFromQuaternion(this.quaternion); - this.matrix.premultiply(_m); - _m.makeScale(this.scale.x, this.scale.y, this.scale.z); - this.matrix.premultiply(_m); - var p = this.position; - _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z); - this.matrix.premultiply(_m); - this.matrix.premultiply(this.transform); - this.updateRepresentationMatrices(); - this.stage.viewer.updateBoundingBox(); - this.signals.matrixChanged.dispatch(this.matrix); -}; -/** - * Propogates our matrix to each representation - */ -Component.prototype.updateRepresentationMatrices = function updateRepresentationMatrices () { - var this$1 = this; - - this.reprList.forEach(function (repr) { - repr.setParameters({ matrix: this$1.matrix }); - }); -}; -/** - * Add an anotation object - * @param {Vector3} position - the 3d position - * @param {String|Element} content - the HTML content - * @param {Object} [params] - parameters - * @param {Integer} params.offsetX - 2d offset in x direction - * @param {Integer} params.offsetY - 2d offset in y direction - * @return {Annotation} the added annotation object - */ -Component.prototype.addAnnotation = function addAnnotation (position, content, params) { - var annotation = new Annotation(this, position, content, params); - this.annotationList.push(annotation); - return annotation; -}; -/** - * Iterator over each annotation and executing the callback - * @param {Function} callback - function to execute - * @return {undefined} - */ -Component.prototype.eachAnnotation = function eachAnnotation (callback) { - this.annotationList.slice().forEach(callback); -}; -/** - * Remove the give annotation from the component - * @param {Annotation} annotation - the annotation to remove - * @return {undefined} - */ -Component.prototype.removeAnnotation = function removeAnnotation (annotation) { - var idx = this.annotationList.indexOf(annotation); - if (idx !== -1) { - this.annotationList.splice(idx, 1); - annotation.dispose(); - } -}; -/** - * Remove all annotations from the component - * @return {undefined} - */ -Component.prototype.removeAllAnnotations = function removeAllAnnotations () { - this.eachAnnotation(function (annotation) { return annotation.dispose(); }); - this.annotationList.length = 0; -}; -/** - * Add a new representation to the component - * @param {String} type - the name of the representation - * @param {Object} object - the object on which the representation should be based - * @param {RepresentationParameters} [params] - representation parameters - * @return {RepresentationElement} the created representation wrapped into - * a representation element object - */ -Component.prototype._addRepresentation = function _addRepresentation (type, object, params, hidden) { - if ( hidden === void 0 ) hidden = false; - - var p = params || {}; - var sp = this.stage.getParameters(); // TODO - p.matrix = this.matrix.clone(); - p.quality = p.quality || sp.quality; - p.disableImpostor = defaults(p.disableImpostor, !sp.impostor); - p.useWorker = defaults(p.useWorker, sp.workerDefault); - p.visible = defaults(p.visible, true); - var p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible }); - var repr = makeRepresentation(type, object, this.viewer, p2); - var reprElem = new RepresentationElement(this.stage, repr, p, this); - if (!hidden) { - this.reprList.push(reprElem); - this.signals.representationAdded.dispatch(reprElem); - } - return reprElem; -}; -Component.prototype.addBufferRepresentation = function addBufferRepresentation (buffer, params) { - return this._addRepresentation.call(this, 'buffer', buffer, params); -}; -Component.prototype.hasRepresentation = function hasRepresentation (repr) { - return this.reprList.indexOf(repr) !== -1; -}; -/** - * Iterator over each representation and executing the callback - * @param {Function} callback - function to execute - * @return {undefined} - */ -Component.prototype.eachRepresentation = function eachRepresentation (callback) { - this.reprList.slice().forEach(callback); -}; -/** - * Removes a representation component - * @param {RepresentationElement} repr - the representation element - * @return {undefined} - */ -Component.prototype.removeRepresentation = function removeRepresentation (repr) { - var idx = this.reprList.indexOf(repr); - if (idx !== -1) { - this.reprList.splice(idx, 1); - repr.dispose(); - this.signals.representationRemoved.dispatch(repr); - } -}; -Component.prototype.updateRepresentations = function updateRepresentations (what) { - this.reprList.forEach(function (repr) { return repr.update(what); }); - this.stage.viewer.requestRender(); -}; -/** - * Removes all representation components - * @return {undefined} - */ -Component.prototype.removeAllRepresentations = function removeAllRepresentations () { - this.eachRepresentation(function (repr) { return repr.dispose(); }); -}; -Component.prototype.dispose = function dispose () { - this.removeAllAnnotations(); - this.removeAllRepresentations(); - delete this.annotationList; - delete this.reprList; - this.signals.disposed.dispatch(); -}; -/** - * Set the visibility of the component, including added representations - * @param {Boolean} value - visibility flag - * @return {Component} this object - */ -Component.prototype.setVisibility = function setVisibility (value) { - this.parameters.visible = value; - this.eachRepresentation(function (repr) { return repr.updateVisibility(); }); - this.eachAnnotation(function (annotation) { return annotation.updateVisibility(); }); - this.signals.visibilityChanged.dispatch(value); - return this; -}; -Component.prototype.setStatus = function setStatus (value) { - this.parameters.status = value; - this.signals.statusChanged.dispatch(value); - return this; -}; -Component.prototype.setName = function setName (value) { - this.parameters.name = value; - this.signals.nameChanged.dispatch(value); - return this; -}; -/** - * @return {Box3} the component's bounding box - */ -Component.prototype.getBox = function getBox () { - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - return (ref = this).getBoxUntransformed.apply(ref, args) - .clone().applyMatrix4(this.matrix); -}; -/** - * @return {Vector3} the component's center position - */ -Component.prototype.getCenter = function getCenter () { - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - return (ref = this).getCenterUntransformed.apply(ref, args) - .clone().applyMatrix4(this.matrix); -}; -Component.prototype.getZoom = function getZoom () { - var ref; - - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - return this.stage.getZoomForBox((ref = this).getBox.apply(ref, args)); -}; -/** - * @abstract - * @return {Box3} the untransformed component's bounding box - */ -Component.prototype.getBoxUntransformed = function getBoxUntransformed () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - return new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); -}; -Component.prototype.getCenterUntransformed = function getCenterUntransformed () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - return this.getBoxUntransformed().getCenter(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); -}; -/** - * Automatically center and zoom the component - * @param {Integer} [duration] - duration of the animation, defaults to 0 - * @return {undefined} - */ -Component.prototype.autoView = function autoView (duration) { - this.stage.animationControls.zoomMove(this.getCenter(), this.getZoom(), defaults(duration, 0)); -}; - -Object.defineProperties( Component.prototype, prototypeAccessors$q ); - -/** - * @file Collection - * @author Alexander Rose - * @private - */ -var Collection = function Collection(list) { - if ( list === void 0 ) list = []; - - this.list = list; - // remove elements from list when they get disposed - var n = list.length; - for (var i = 0; i < n; ++i) { - var elm = list[i]; - elm.signals.disposed.add(this._remove, this); - } -}; - -var prototypeAccessors$r = { first: { configurable: true } }; -Collection.prototype._remove = function _remove (elm) { - var idx = this.list.indexOf(elm); - if (idx !== -1) { - this.list.splice(idx, 1); - } -}; -prototypeAccessors$r.first.get = function () { - return this.list.length > 0 ? this.list[0] : undefined; -}; -Collection.prototype.forEach = function forEach (fn) { - this.list.forEach(fn); - return this; -}; -Collection.prototype.dispose = function dispose () { - return this.forEach(function (elm) { return elm.dispose(); }); -}; - -Object.defineProperties( Collection.prototype, prototypeAccessors$r ); - -/** - * @file Component Collection - * @author Alexander Rose - * @private - */ -var RepresentationCollection = /*@__PURE__*/(function (Collection$$1) { - function RepresentationCollection () { - Collection$$1.apply(this, arguments); - } - - if ( Collection$$1 ) RepresentationCollection.__proto__ = Collection$$1; - RepresentationCollection.prototype = Object.create( Collection$$1 && Collection$$1.prototype ); - RepresentationCollection.prototype.constructor = RepresentationCollection; - - RepresentationCollection.prototype.setParameters = function setParameters (params) { - return this.forEach(function (repr) { return repr.setParameters(params); }); - }; - RepresentationCollection.prototype.setVisibility = function setVisibility (value) { - return this.forEach(function (repr) { return repr.setVisibility(value); }); - }; - RepresentationCollection.prototype.setSelection = function setSelection (string) { - return this.forEach(function (repr) { return repr.setSelection(string); }); - }; - RepresentationCollection.prototype.setColor = function setColor (color) { - return this.forEach(function (repr) { return repr.setColor(color); }); - }; - RepresentationCollection.prototype.update = function update (what) { - return this.forEach(function (repr) { return repr.update(what); }); - }; - RepresentationCollection.prototype.build = function build (params) { - return this.forEach(function (repr) { return repr.build(params); }); - }; - RepresentationCollection.prototype.dispose = function dispose (params) { - return this.forEach(function (repr) { return repr.dispose(); }); - }; - - return RepresentationCollection; -}(Collection)); - -/** - * @file Trajectory Component - * @author Alexander Rose - * @private - */ -/** - * Trajectory component parameter object. - * @typedef {Object} TrajectoryComponentParameters - component parameters - * - * @property {String} name - component name - * @property {Integer} initialFrame - initial frame the trajectory is set to - * @property {Integer} defaultStep - default step size to be used by trajectory players - * @property {Integer} defaultTimeout - default timeout to be used by trajectory players - * @property {String} defaultInterpolateType - one of "" (empty string), "linear" or "spline" - * @property {Integer} defaultInterpolateStep - window size used for interpolation - * @property {String} defaultMode - either "loop" or "once" - * @property {String} defaultDirection - either "forward" or "backward" - */ -var TrajectoryElementDefaultParameters = Object.assign({ - defaultStep: 1, - defaultTimeout: 50, - defaultInterpolateType: '', - defaultInterpolateStep: 5, - defaultMode: 'loop', - defaultDirection: 'forward', - initialFrame: 0 -}, ElementDefaultParameters); -/** - * Component wrapping a {@link Trajectory} object - */ -var TrajectoryElement = /*@__PURE__*/(function (Element$$1) { - function TrajectoryElement(stage, trajectory, params) { - var this$1 = this; - if ( params === void 0 ) params = {}; - - Element$$1.call(this, stage, Object.assign({ name: trajectory.name }, params)); - this.trajectory = trajectory; - this.signals = Object.assign(this.signals, { - frameChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - playerChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - countChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - parametersChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }); - // signals - trajectory.signals.frameChanged.add(function (i) { - this$1.signals.frameChanged.dispatch(i); - }); - trajectory.signals.playerChanged.add(function (player) { - this$1.signals.playerChanged.dispatch(player); - }); - trajectory.signals.countChanged.add(function (n) { - this$1.signals.countChanged.dispatch(n); - }); - // - if (params.initialFrame !== undefined) { - this.setFrame(params.initialFrame); - } - } - - if ( Element$$1 ) TrajectoryElement.__proto__ = Element$$1; - TrajectoryElement.prototype = Object.create( Element$$1 && Element$$1.prototype ); - TrajectoryElement.prototype.constructor = TrajectoryElement; - - var prototypeAccessors = { defaultParameters: { configurable: true },type: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return TrajectoryElementDefaultParameters; }; - /** - * Component type - * @type {String} - */ - prototypeAccessors.type.get = function () { return 'trajectory'; }; - /** - * Set the frame of the trajectory - * @param {Integer} i - frame number - * @return {undefined} - */ - TrajectoryElement.prototype.setFrame = function setFrame (i) { - this.trajectory.setFrame(i); - }; - /** - * Set trajectory parameters - * @param {TrajectoryParameters} params - trajectory parameters - * @return {undefined} - */ - TrajectoryElement.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - this.trajectory.setParameters(params); - this.signals.parametersChanged.dispatch(params); - }; - TrajectoryElement.prototype.dispose = function dispose () { - this.trajectory.dispose(); - Element$$1.prototype.dispose.call(this); - }; - - Object.defineProperties( TrajectoryElement.prototype, prototypeAccessors ); - - return TrajectoryElement; -}(Element)); - -/** - * @file Frames - * @author Alexander Rose - * @private - */ -var Frames = function Frames(name, path) { - this.name = name; - this.path = path; - this.coordinates = []; - this.boxes = []; - this.times = []; - this.timeOffset = 0; - this.deltaTime = 1; -}; - -var prototypeAccessors$s = { type: { configurable: true } }; -prototypeAccessors$s.type.get = function () { return 'Frames'; }; - -Object.defineProperties( Frames.prototype, prototypeAccessors$s ); - -/** - * @file Superposition - * @author Alexander Rose - * @private - */ -var Superposition = function Superposition(atoms1, atoms2) { - // allocate & init data structures - this.A = new Matrix(3, 3); - this.W = new Matrix(1, 3); - this.U = new Matrix(3, 3); - this.V = new Matrix(3, 3); - this.VH = new Matrix(3, 3); - this.R = new Matrix(3, 3); - this.tmp = new Matrix(3, 3); - this.c = new Matrix(3, 3); - var n1; - if (atoms1 instanceof Structure) { - n1 = atoms1.atomCount; - } - else if (atoms1 instanceof Float32Array) { - n1 = atoms1.length / 3; - } - else { - return; - } - var n2; - if (atoms2 instanceof Structure) { - n2 = atoms2.atomCount; - } - else if (atoms2 instanceof Float32Array) { - n2 = atoms2.length / 3; - } - else { - return; - } - var n = Math.min(n1, n2); - var coords1 = new Matrix(3, n); - var coords2 = new Matrix(3, n); - this.coords1t = new Matrix(n, 3); - this.coords2t = new Matrix(n, 3); - this.transformationMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.c.data.set([1, 0, 0, 0, 1, 0, 0, 0, -1]); - // prep coords - this.prepCoords(atoms1, coords1, n, false); - this.prepCoords(atoms2, coords2, n, false); - // superpose - this._superpose(coords1, coords2); -}; -Superposition.prototype._superpose = function _superpose (coords1, coords2) { - this.mean1 = meanRows(coords1); - this.mean2 = meanRows(coords2); - subRows(coords1, this.mean1); - subRows(coords2, this.mean2); - transpose(this.coords1t, coords1); - transpose(this.coords2t, coords2); - multiplyABt(this.A, this.coords2t, this.coords1t); - svd(this.A, this.W, this.U, this.V); - invert3x3(this.V, this.VH); - multiply3x3(this.R, this.U, this.VH); - if (mat3x3determinant(this.R) < 0.0) { - if (Debug) - { Log.log('R not a right handed system'); } - multiply3x3(this.tmp, this.c, this.VH); - multiply3x3(this.R, this.U, this.tmp); - } - //get the transformation matrix - var transformMat_ = new Matrix(4, 4); - var tmp_1 = new Matrix(4, 4); - var tmp_2 = new Matrix(4, 4); - var sub = new Matrix(4, 4); - var mult = new Matrix(4, 4); - var add = new Matrix(4, 4); - var R = this.R.data; - var M1 = this.mean1; - var M2 = this.mean2; - sub.data.set([1, 0, 0, -M1[0], - 0, 1, 0, -M1[1], - 0, 0, 1, -M1[2], - 0, 0, 0, 1]); - mult.data.set([R[0], R[1], R[2], 0, - R[3], R[4], R[5], 0, - R[6], R[7], R[8], 0, - 0, 0, 0, 1]); - add.data.set([1, 0, 0, M2[0], - 0, 1, 0, M2[1], - 0, 0, 1, M2[2], - 0, 0, 0, 1]); - transpose(tmp_1, sub); - multiplyABt(transformMat_, mult, tmp_1); - transpose(tmp_2, transformMat_); - multiplyABt(tmp_1, add, tmp_2); - transpose(transformMat_, tmp_1); - this.transformationMatrix.elements = transformMat_.data; -}; -Superposition.prototype.prepCoords = function prepCoords (atoms, coords, n, is4X4) { - var i = 0; - var cd = coords.data; - var c = 3; - var d = n * 3; - if (is4X4) { - d = n * 4; - c = 4; - } - if (atoms instanceof Structure) { - atoms.eachAtom(function (a) { - if (i < d) { - cd[i + 0] = a.x; - cd[i + 1] = a.y; - cd[i + 2] = a.z; - if (is4X4) - { cd[i + 3] = 1; } - i += c; - } - }); - } - else if (atoms instanceof Float32Array) { - for (; i < d; i += c) { - if (i < d) { - cd[i] = atoms[i]; - cd[i + 1] = atoms[i + 1]; - cd[i + 2] = atoms[i + 2]; - if (is4X4) - { cd[i + 3] = 1; } - } - } - } - else { - Log.warn('prepCoords: input type unknown'); - } -}; -Superposition.prototype.transform = function transform (atoms) { - // allocate data structures - var n; - if (atoms instanceof Structure) { - n = atoms.atomCount; - } - else if (atoms instanceof Float32Array) { - n = atoms.length / 3; - } - else { - return; - } - var coords = new Matrix(4, n); - var tCoords = new Matrix(n, 4); - // prep coords - this.prepCoords(atoms, coords, n, true); - // check for transformation matrix correctness - var transform = this.transformationMatrix; - var det = transform.determinant(); - if (!det) { - return det; - } - // do transform - var mult = new Matrix(4, 4); - mult.data = transform.elements; - multiply(tCoords, coords, mult); - var i = 0; - var cd = tCoords.data; - if (atoms instanceof Structure) { - atoms.eachAtom(function (a) { - a.x = cd[i]; - a.y = cd[i + 1]; - a.z = cd[i + 2]; - i += 4; - }); - //update transformation matrices for each assembly - var invertTrasform = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - invertTrasform.getInverse(transform); - var biomolDict = atoms.biomolDict; - for (var key in biomolDict) { - if (biomolDict.hasOwnProperty(key)) { - var assembly = biomolDict[key]; - assembly.partList.forEach(function (part) { - part.matrixList.forEach(function (mat) { - mat.premultiply(transform); - mat.multiply(invertTrasform); - }); - }); - } - } - } - else if (atoms instanceof Float32Array) { - var n4 = n * 4; - for (; i < n4; i += 4) { - atoms[i] = cd[i]; - atoms[i + 1] = cd[i + 1]; - atoms[i + 2] = cd[i + 2]; - } - } - else { - Log.warn('transform: input type unknown'); - } - return this.transformationMatrix; -}; - -/** - * @file Trajectory Player - * @author Alexander Rose - * @private - */ -var TrajectoryPlayerDefaultParameters = { - step: 1, - timeout: 50, - start: 0, - end: 0, - interpolateType: '', - interpolateStep: 5, - mode: 'loop', - direction: 'forward' -}; -/** - * Trajectory player for animating coordinate frames - * @example - * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50}); - * player.play(); - */ -var TrajectoryPlayer = function TrajectoryPlayer(traj, params) { - var this$1 = this; - if ( params === void 0 ) params = {}; - - this.signals = { - startedRunning: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - haltedRunning: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this._run = false; - this._previousTime = 0; - this._currentTime = 0; - this._currentStep = 1; - traj.signals.playerChanged.add(function (player) { - if (player !== this$1) { - this$1.pause(); - } - }, this); - var n = defaults(traj.frameCount, 1); - this.traj = traj; - this.parameters = createParams(params, TrajectoryPlayerDefaultParameters); - this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1); - this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100)); - this._currentFrame = this.parameters.start; - this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction; - traj.signals.countChanged.add(function (n) { - this$1.parameters.end = Math.min(defaults(this$1.parameters.end, n - 1), n - 1); - }, this); - this._animate = this._animate.bind(this); -}; - -var prototypeAccessors$t = { isRunning: { configurable: true } }; -prototypeAccessors$t.isRunning.get = function () { return this._run; }; -/** - * set player parameters - * @param {TrajectoryPlayerParameters} [params] - parameter object - */ -TrajectoryPlayer.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - updateParams(this.parameters, params); - if (params.direction !== undefined && this.parameters.direction !== 'bounce') { - this._direction = this.parameters.direction; - } -}; -TrajectoryPlayer.prototype._animate = function _animate () { - if (!this._run) - { return; } - this._currentTime = window.performance.now(); - var dt = this._currentTime - this._previousTime; - var step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1; - var timeout = this.parameters.timeout / step; - var traj = this.traj; - if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) { - if (this.parameters.interpolateType) { - if (this._currentStep > this.parameters.interpolateStep) { - this._currentStep = 1; - } - if (this._currentStep === 1) { - this._currentFrame = this._nextInterpolated(); - } - if (traj.hasFrame(this._currentFrame)) { - this._currentStep += 1; - var t = this._currentStep / (this.parameters.interpolateStep + 1); - var ref = this._currentFrame; - var i = ref[0]; - var ip = ref[1]; - var ipp = ref[2]; - var ippp = ref[3]; - traj.setFrameInterpolated(i, ip, ipp, ippp, t, this.parameters.interpolateType); - this._previousTime = this._currentTime; - } - else { - traj.loadFrame(this._currentFrame); - } - } - else { - var i$1 = this._next(); - if (traj.hasFrame(i$1)) { - traj.setFrame(i$1); - this._previousTime = this._currentTime; - } - else { - traj.loadFrame(i$1); - } - } - } - window.requestAnimationFrame(this._animate); -}; -TrajectoryPlayer.prototype._next = function _next () { - var p = this.parameters; - var i; - if (this._direction === 'forward') { - i = this.traj.currentFrame + p.step; - } - else { - i = this.traj.currentFrame - p.step; - } - if (i > p.end || i < p.start) { - if (p.direction === 'bounce') { - if (this._direction === 'forward') { - this._direction = 'backward'; - } - else { - this._direction = 'forward'; - } - } - if (p.mode === 'once') { - this.pause(); - if (p.direction === 'forward') { - i = p.end; - } - else if (p.direction === 'backward') { - i = p.start; - } - else { - if (this._direction === 'forward') { - i = p.start; - } - else { - i = p.end; - } - } - } - else { - if (this._direction === 'forward') { - i = p.start; - if (p.interpolateType) { - i = Math.min(p.end, i + p.step); - } - } - else { - i = p.end; - if (p.interpolateType) { - i = Math.max(p.start, i - p.step); - } - } - } - } - return i; -}; -TrajectoryPlayer.prototype._nextInterpolated = function _nextInterpolated () { - var p = this.parameters; - var i = this._next(); - var ip, ipp, ippp; - if (this._direction === 'forward') { - ip = Math.max(p.start, i - p.step); - ipp = Math.max(p.start, i - 2 * p.step); - ippp = Math.max(p.start, i - 3 * p.step); - } - else { - ip = Math.min(p.end, i + p.step); - ipp = Math.min(p.end, i + 2 * p.step); - ippp = Math.min(p.end, i + 3 * p.step); - } - return [i, ip, ipp, ippp]; -}; -/** - * toggle between playing and pausing the animation - * @return {undefined} - */ -TrajectoryPlayer.prototype.toggle = function toggle () { - if (this._run) { - this.pause(); - } - else { - this.play(); - } -}; -/** - * start the animation - * @return {undefined} - */ -TrajectoryPlayer.prototype.play = function play () { - if (!this._run) { - if (this.traj.player !== this) { - this.traj.setPlayer(this); - } - this._currentStep = 1; - var p = this.parameters; - var frame = this.traj.currentFrame; - // snap to the grid implied by this.step division and multiplication - // thus minimizing cache misses - var i = Math.ceil(frame / p.step) * p.step; - // wrap when restarting from the limit (i.e. end or start) - if (p.direction === 'forward' && frame >= p.end) { - i = p.start; - } - else if (p.direction === 'backward' && frame <= p.start) { - i = p.end; - } - this.traj.setFrame(i); - this._run = true; - this._animate(); - this.signals.startedRunning.dispatch(); - } -}; -/** - * pause the animation - * @return {undefined} - */ -TrajectoryPlayer.prototype.pause = function pause () { - this._run = false; - this.signals.haltedRunning.dispatch(); -}; -/** - * stop the animation (pause and go to start-frame) - * @return {undefined} - */ -TrajectoryPlayer.prototype.stop = function stop () { - this.pause(); - this.traj.setFrame(this.parameters.start); -}; - -Object.defineProperties( TrajectoryPlayer.prototype, prototypeAccessors$t ); - -/** - * @file Trajectory - * @author Alexander Rose - * @private - */ -function centerPbc(coords, mean, box) { - if (box[0] === 0 || box[8] === 0 || box[4] === 0) { - return; - } - var n = coords.length; - var bx = box[0]; - var by = box[1]; - var bz = box[2]; - var mx = mean[0]; - var my = mean[1]; - var mz = mean[2]; - var fx = -mx + bx + bx / 2; - var fy = -my + by + by / 2; - var fz = -mz + bz + bz / 2; - for (var i = 0; i < n; i += 3) { - coords[i + 0] = (coords[i + 0] + fx) % bx; - coords[i + 1] = (coords[i + 1] + fy) % by; - coords[i + 2] = (coords[i + 2] + fz) % bz; - } -} -function removePbc(x, box) { - if (box[0] === 0 || box[8] === 0 || box[4] === 0) { - return; - } - // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc() - // in-place - var n = x.length; - for (var i = 3; i < n; i += 3) { - for (var j = 0; j < 3; ++j) { - var dist = x[i + j] - x[i - 3 + j]; - if (Math.abs(dist) > 0.9 * box[j * 3 + j]) { - if (dist > 0) { - for (var d = 0; d < 3; ++d) { - x[i + d] -= box[j * 3 + d]; - } - } - else { - for (var d$1 = 0; d$1 < 3; ++d$1) { - x[i + d$1] += box[j * 3 + d$1]; - } - } - } - } - } - return x; -} -function removePeriodicity(x, box, mean) { - if (box[0] === 0 || box[8] === 0 || box[4] === 0) { - return; - } - var n = x.length; - for (var i = 3; i < n; i += 3) { - for (var j = 0; j < 3; ++j) { - var f = (x[i + j] - mean[j]) / box[j * 3 + j]; - if (Math.abs(f) > 0.5) { - x[i + j] -= box[j * 3 + j] * Math.round(f); - } - } - } - return x; -} -function circularMean3(indices, coords, box) { - return [ - circularMean(coords, box[0], 3, 0, indices), - circularMean(coords, box[1], 3, 1, indices), - circularMean(coords, box[2], 3, 2, indices) - ]; -} -function arrayMean3(coords) { - return [ - arrayMean(coords, 3, 0), - arrayMean(coords, 3, 1), - arrayMean(coords, 3, 2) - ]; -} -function interpolateSpline(c, cp, cpp, cppp, t) { - var m = c.length; - var coords = new Float32Array(m); - for (var j0 = 0; j0 < m; j0 += 3) { - var j1 = j0 + 1; - var j2 = j0 + 2; - coords[j0] = spline(cppp[j0], cpp[j0], cp[j0], c[j0], t, 1); - coords[j1] = spline(cppp[j1], cpp[j1], cp[j1], c[j1], t, 1); - coords[j2] = spline(cppp[j2], cpp[j2], cp[j2], c[j2], t, 1); - } - return coords; -} -function interpolateLerp(c, cp, t) { - var m = c.length; - var coords = new Float32Array(m); - for (var j0 = 0; j0 < m; j0 += 3) { - var j1 = j0 + 1; - var j2 = j0 + 2; - coords[j0] = lerp(cp[j0], c[j0], t); - coords[j1] = lerp(cp[j1], c[j1], t); - coords[j2] = lerp(cp[j2], c[j2], t); - } - return coords; -} -/** - * Base class for trajectories, tying structures and coordinates together - * @interface - */ -var Trajectory = function Trajectory(trajPath, structure, params) { - var this$1 = this; - if ( params === void 0 ) params = {}; - - this.signals = { - countChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - frameChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - playerChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - this.frameCache = {}; - this.loadQueue = {}; - this.boxCache = {}; - this.pathCache = {}; - this.frameCacheSize = 0; - this._frameCount = 0; - this._currentFrame = -1; - this._disposed = false; - this.deltaTime = defaults(params.deltaTime, 0); - this.timeOffset = defaults(params.timeOffset, 0); - this.centerPbc = defaults(params.centerPbc, false); - this.removePbc = defaults(params.removePbc, false); - this.removePeriodicity = defaults(params.removePeriodicity, false); - this.superpose = defaults(params.superpose, false); - this.name = trajPath.replace(/^.*[\\/]/, ''); - this.trajPath = trajPath; - this.selection = new Selection(defaults(params.sele, 'backbone and not hydrogen')); - this.selection.signals.stringChanged.add(function () { - this$1.selectionIndices = this$1.structure.getAtomIndices(this$1.selection); - this$1._resetCache(); - this$1._saveInitialCoords(); - this$1.setFrame(this$1._currentFrame); - }); -}; - -var prototypeAccessors$u = { frameCount: { configurable: true },currentFrame: { configurable: true } }; -/** - * Number of frames in the trajectory - */ -prototypeAccessors$u.frameCount.get = function () { - return this._frameCount; -}; -/** - * Currently set frame of the trajectory - */ -prototypeAccessors$u.currentFrame.get = function () { - return this._currentFrame; -}; -Trajectory.prototype._init = function _init (structure) { - this.setStructure(structure); - this._loadFrameCount(); - this.setPlayer(new TrajectoryPlayer(this)); -}; -Trajectory.prototype._loadFrameCount = function _loadFrameCount () { }; -Trajectory.prototype.setStructure = function setStructure (structure) { - this.structure = structure; - this.atomCount = structure.atomCount; - this.backboneIndices = this._getIndices(new Selection('backbone and not hydrogen')); - this._makeAtomIndices(); - this._saveStructureCoords(); - this.selectionIndices = this._getIndices(this.selection); - this._resetCache(); - this._saveInitialCoords(); - this.setFrame(this._currentFrame); -}; -Trajectory.prototype._saveInitialCoords = function _saveInitialCoords () { - var this$1 = this; - - if (this.structure.hasCoords()) { - this.initialCoords = new Float32Array(this.structureCoords); - this._makeSuperposeCoords(); - } - else if (this.frameCache[0]) { - this.initialCoords = new Float32Array(this.frameCache[0]); - this._makeSuperposeCoords(); - } - else { - this.loadFrame(0, function () { return this$1._saveInitialCoords(); }); - } -}; -Trajectory.prototype._saveStructureCoords = function _saveStructureCoords () { - var p = { what: { position: true } }; - this.structureCoords = this.structure.getAtomData(p).position; -}; -Trajectory.prototype.setSelection = function setSelection (string) { - this.selection.setString(string); - return this; -}; -Trajectory.prototype._getIndices = function _getIndices (selection) { - var i = 0; - var test = selection.test; - var indices = []; - if (test) { - this.structure.eachAtom(function (ap) { - if (test(ap)) - { indices.push(i); } - i += 1; - }); - } - return indices; -}; -Trajectory.prototype._makeSuperposeCoords = function _makeSuperposeCoords () { - var n = this.selectionIndices.length * 3; - this.coords1 = new Float32Array(n); - this.coords2 = new Float32Array(n); - var y = this.initialCoords; - var coords2 = this.coords2; - for (var i = 0; i < n; i += 3) { - var j = this.selectionIndices[i / 3] * 3; - coords2[i + 0] = y[j + 0]; - coords2[i + 1] = y[j + 1]; - coords2[i + 2] = y[j + 2]; - } -}; -Trajectory.prototype._makeAtomIndices = function _makeAtomIndices () { - Log.error('Trajectory._makeAtomIndices not implemented'); -}; -Trajectory.prototype._resetCache = function _resetCache () { - this.frameCache = {}; - this.loadQueue = {}; - this.boxCache = {}; - this.pathCache = {}; - this.frameCacheSize = 0; - this.initialCoords = new Float32Array(0); -}; -Trajectory.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - var resetCache = false; - if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) { - this.centerPbc = params.centerPbc; - resetCache = true; - } - if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) { - this.removePeriodicity = params.removePeriodicity; - resetCache = true; - } - if (params.removePbc !== undefined && params.removePbc !== this.removePbc) { - this.removePbc = params.removePbc; - resetCache = true; - } - if (params.superpose !== undefined && params.superpose !== this.superpose) { - this.superpose = params.superpose; - resetCache = true; - } - this.deltaTime = defaults(params.deltaTime, this.deltaTime); - this.timeOffset = defaults(params.timeOffset, this.timeOffset); - if (resetCache) { - this._resetCache(); - this.setFrame(this._currentFrame); - } -}; -/** - * Check if a frame is available - * @param {Integer|Integer[]} i - the frame index - * @return {Boolean} frame availability - */ -Trajectory.prototype.hasFrame = function hasFrame (i) { - var this$1 = this; - - if (Array.isArray(i)) { - return i.every(function (j) { return !!this$1.frameCache[j]; }); - } - else { - return !!this.frameCache[i]; - } -}; -/** - * Set trajectory to a frame index - * @param {Integer} i - the frame index - * @param {Function} [callback] - fired when the frame has been set - */ -Trajectory.prototype.setFrame = function setFrame (i, callback) { - var this$1 = this; - - if (i === undefined) - { return this; } - this.inProgress = true; - // i = parseInt(i) // TODO - if (i === -1 || this.frameCache[i]) { - this._updateStructure(i); - if (callback) - { callback(); } - } - else { - this.loadFrame(i, function () { - this$1._updateStructure(i); - if (callback) - { callback(); } - }); - } - return this; -}; -Trajectory.prototype._interpolate = function _interpolate (i, ip, ipp, ippp, t, type) { - var fc = this.frameCache; - var coords; - if (type === 'spline') { - coords = interpolateSpline(fc[i], fc[ip], fc[ipp], fc[ippp], t); - } - else { - coords = interpolateLerp(fc[i], fc[ip], t); - } - this.structure.updatePosition(coords); - this._currentFrame = i; - this.signals.frameChanged.dispatch(i); -}; -/** - * Interpolated and set trajectory to frame indices - * @param {Integer} i - the frame index - * @param {Integer} ip - one before frame index - * @param {Integer} ipp - two before frame index - * @param {Integer} ippp - three before frame index - * @param {Number} t - interpolation step [0,1] - * @param {String} type - interpolation type, '', 'spline' or 'linear' - * @param {Function} callback - fired when the frame has been set - */ -Trajectory.prototype.setFrameInterpolated = function setFrameInterpolated (i, ip, ipp, ippp, t, type, callback) { - var this$1 = this; - - if (i === undefined) - { return this; } - var fc = this.frameCache; - var iList = []; - if (!fc[ippp]) - { iList.push(ippp); } - if (!fc[ipp]) - { iList.push(ipp); } - if (!fc[ip]) - { iList.push(ip); } - if (!fc[i]) - { iList.push(i); } - if (iList.length) { - this.loadFrame(iList, function () { - this$1._interpolate(i, ip, ipp, ippp, t, type); - if (callback) - { callback(); } - }); - } - else { - this._interpolate(i, ip, ipp, ippp, t, type); - if (callback) - { callback(); } - } - return this; -}; -/** - * Load frame index - * @param {Integer|Integer[]} i - the frame index - * @param {Function} callback - fired when the frame has been loaded - */ -Trajectory.prototype.loadFrame = function loadFrame (i, callback) { - var this$1 = this; - - if (Array.isArray(i)) { - i.forEach(function (j) { - if (!this$1.loadQueue[j] && !this$1.frameCache[j]) { - this$1.loadQueue[j] = true; - this$1._loadFrame(j, function () { - delete this$1.loadQueue[j]; - }); - } - }); - } - else { - if (!this.loadQueue[i] && !this.frameCache[i]) { - this.loadQueue[i] = true; - this._loadFrame(i, function () { - delete this$1.loadQueue[i]; - if (callback) - { callback(); } - }); - } - } -}; -/** - * Load frame index - * @abstract - * @param {Integer} i - the frame index - * @param {Function} callback - fired when the frame has been loaded - */ -Trajectory.prototype._loadFrame = function _loadFrame (i, callback) { - Log.error('Trajectory._loadFrame not implemented', i, callback); -}; -Trajectory.prototype._updateStructure = function _updateStructure (i) { - if (this._disposed) { - console.error('updateStructure: traj disposed'); - return; - } - if (i === -1) { - if (this.structureCoords) { - this.structure.updatePosition(this.structureCoords); - } - } - else { - this.structure.updatePosition(this.frameCache[i]); - } - this.structure.trajectory = { - name: this.trajPath, - frame: i - }; - this._currentFrame = i; - this.inProgress = false; - this.signals.frameChanged.dispatch(i); -}; -Trajectory.prototype._doSuperpose = function _doSuperpose (x) { - var n = this.selectionIndices.length * 3; - var coords1 = this.coords1; - var coords2 = this.coords2; - for (var i = 0; i < n; i += 3) { - var j = this.selectionIndices[i / 3] * 3; - coords1[i + 0] = x[j + 0]; - coords1[i + 1] = x[j + 1]; - coords1[i + 2] = x[j + 2]; - } - // TODO re-use superposition object - var sp = new Superposition(coords1, coords2); - sp.transform(x); -}; -Trajectory.prototype._process = function _process (i, box, coords, frameCount) { - this._setFrameCount(frameCount); - if (box) { - if (this.backboneIndices.length > 0 && this.centerPbc) { - var box2 = [box[0], box[4], box[8]]; - var circMean = circularMean3(this.backboneIndices, coords, box2); - centerPbc(coords, circMean, box2); - } - if (this.removePeriodicity) { - var mean = arrayMean3(coords); - removePeriodicity(coords, box, mean); - } - if (this.removePbc) { - removePbc(coords, box); - } - } - if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) { - this._doSuperpose(coords); - } - this.frameCache[i] = coords; - this.boxCache[i] = box; - this.frameCacheSize += 1; -}; -Trajectory.prototype._setFrameCount = function _setFrameCount (n) { - if (n !== this._frameCount) { - this._frameCount = n; - this.signals.countChanged.dispatch(n); - } -}; -/** - * Dispose of the trajectory object - * @return {undefined} - */ -Trajectory.prototype.dispose = function dispose () { - this._resetCache(); // aid GC - this._disposed = true; - if (this.player) - { this.player.stop(); } -}; -/** - * Set player for this trajectory - * @param {TrajectoryPlayer} player - the player - */ -Trajectory.prototype.setPlayer = function setPlayer (player) { - this.player = player; - this.signals.playerChanged.dispatch(player); -}; -/** - * Get time for frame - * @param {Integer} i - frame index - * @return {Number} time in picoseconds - */ -Trajectory.prototype.getFrameTime = function getFrameTime (i) { - return this.timeOffset + i * this.deltaTime; -}; - -Object.defineProperties( Trajectory.prototype, prototypeAccessors$u ); - -/** - * @file Frames Trajectory - * @author Alexander Rose - * @private - */ -/** - * Frames trajectory class. Gets data from a frames object. - */ -var FramesTrajectory = /*@__PURE__*/(function (Trajectory$$1) { - function FramesTrajectory(frames, structure, params) { - var p = params || {}; - p.timeOffset = defaults(p.timeOffset, frames.timeOffset); - p.deltaTime = defaults(p.deltaTime, frames.deltaTime); - Trajectory$$1.call(this, '', structure, p); - this.name = frames.name; - this.path = frames.path; - this.frames = frames.coordinates; - this.boxes = frames.boxes; - this._init(structure); - } - - if ( Trajectory$$1 ) FramesTrajectory.__proto__ = Trajectory$$1; - FramesTrajectory.prototype = Object.create( Trajectory$$1 && Trajectory$$1.prototype ); - FramesTrajectory.prototype.constructor = FramesTrajectory; - - var prototypeAccessors = { type: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'frames'; }; - FramesTrajectory.prototype._makeAtomIndices = function _makeAtomIndices () { - if (this.structure.type === 'StructureView') { - this.atomIndices = this.structure.getAtomIndices(); - } - else { - this.atomIndices = undefined; - } - }; - FramesTrajectory.prototype._loadFrame = function _loadFrame (i, callback) { - var coords; - var frame = this.frames[i]; - if (this.atomIndices) { - var indices = this.atomIndices; - var m = indices.length; - coords = new Float32Array(m * 3); - for (var j = 0; j < m; ++j) { - var j3 = j * 3; - var idx3 = indices[j] * 3; - coords[j3 + 0] = frame[idx3 + 0]; - coords[j3 + 1] = frame[idx3 + 1]; - coords[j3 + 2] = frame[idx3 + 2]; - } - } - else { - coords = new Float32Array(frame); - } - var box = this.boxes[i]; - var frameCount = this.frames.length; - this._process(i, box, coords, frameCount); - if (typeof callback === 'function') { - callback(); - } - }; - FramesTrajectory.prototype._loadFrameCount = function _loadFrameCount () { - if (this.frames) { - this._setFrameCount(this.frames.length); - } - }; - - Object.defineProperties( FramesTrajectory.prototype, prototypeAccessors ); - - return FramesTrajectory; -}(Trajectory)); - -/** - * @file Structure Trajectory - * @author Alexander Rose - * @private - */ -/** - * Structure trajectory class. Gets data from a structure object. - */ -var StructureTrajectory = /*@__PURE__*/(function (Trajectory$$1) { - function StructureTrajectory(trajPath, structure, params) { - Trajectory$$1.call(this, '', structure, params); - this._init(structure); - } - - if ( Trajectory$$1 ) StructureTrajectory.__proto__ = Trajectory$$1; - StructureTrajectory.prototype = Object.create( Trajectory$$1 && Trajectory$$1.prototype ); - StructureTrajectory.prototype.constructor = StructureTrajectory; - - var prototypeAccessors = { type: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'structure'; }; - StructureTrajectory.prototype._makeAtomIndices = function _makeAtomIndices () { - if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) { - this.atomIndices = this.structure.getAtomIndices(); - } - else { - this.atomIndices = undefined; - } - }; - StructureTrajectory.prototype._loadFrame = function _loadFrame (i, callback) { - var coords; - var structure = this.structure; - var frame = structure.frames[i]; - if (this.atomIndices) { - var indices = this.atomIndices; - var m = indices.length; - coords = new Float32Array(m * 3); - for (var j = 0; j < m; ++j) { - var j3 = j * 3; - var idx3 = indices[j] * 3; - coords[j3 + 0] = frame[idx3 + 0]; - coords[j3 + 1] = frame[idx3 + 1]; - coords[j3 + 2] = frame[idx3 + 2]; - } - } - else { - coords = new Float32Array(frame); - } - var box = structure.boxes[i]; - var frameCount = structure.frames.length; - this._process(i, box, coords, frameCount); - if (typeof callback === 'function') { - callback(); - } - }; - StructureTrajectory.prototype._loadFrameCount = function _loadFrameCount () { - this._setFrameCount(this.structure.frames.length); - }; - - Object.defineProperties( StructureTrajectory.prototype, prototypeAccessors ); - - return StructureTrajectory; -}(Trajectory)); - -/** - * @file Remote Trajectory - * @author Alexander Rose - * @private - */ -/** - * Remote trajectory class. Gets data from an MDsrv instance. - */ -var RemoteTrajectory = /*@__PURE__*/(function (Trajectory$$1) { - function RemoteTrajectory(trajPath, structure, params) { - Trajectory$$1.call(this, trajPath, structure, params); - this._init(structure); - } - - if ( Trajectory$$1 ) RemoteTrajectory.__proto__ = Trajectory$$1; - RemoteTrajectory.prototype = Object.create( Trajectory$$1 && Trajectory$$1.prototype ); - RemoteTrajectory.prototype.constructor = RemoteTrajectory; - - var prototypeAccessors = { type: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'remote'; }; - RemoteTrajectory.prototype._makeAtomIndices = function _makeAtomIndices () { - var atomIndices = []; - if (this.structure.type === 'StructureView') { - var indices = this.structure.getAtomIndices(); // TODO - var n = indices.length; - var p = indices[0]; - var q = indices[0]; - for (var i = 1; i < n; ++i) { - var r = indices[i]; - if (q + 1 < r) { - atomIndices.push([p, q + 1]); - p = r; - } - q = r; - } - atomIndices.push([p, q + 1]); - } - else { - atomIndices.push([0, this.atomCount]); - } - this.atomIndices = atomIndices; - }; - RemoteTrajectory.prototype._loadFrame = function _loadFrame (i, callback) { - var this$1 = this; - - // TODO implement max frameCache size, re-use arrays - var request = new XMLHttpRequest(); - var url = TrajectoryDatasource.getFrameUrl(this.trajPath, i); - var params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices); - request.open('POST', url, true); - request.responseType = 'arraybuffer'; - request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); - request.addEventListener('load', function () { - var arrayBuffer = request.response; - if (!arrayBuffer) { - Log.error(("empty arrayBuffer for '" + url + "'")); - return; - } - var frameCount = new Int32Array(arrayBuffer, 0, 1)[0]; - // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ]; - var box = new Float32Array(arrayBuffer, 2 * 4, 9); - var coords = new Float32Array(arrayBuffer, 11 * 4); - this$1._process(i, box, coords, frameCount); - if (typeof callback === 'function') { - callback(); - } - }, false); - request.send(params); - }; - RemoteTrajectory.prototype._loadFrameCount = function _loadFrameCount () { - var this$1 = this; - - var request = new XMLHttpRequest(); - var url = TrajectoryDatasource.getCountUrl(this.trajPath); - request.open('GET', url, true); - request.addEventListener('load', function () { - this$1._setFrameCount(parseInt(request.response)); - }, false); - request.send(); - }; - - Object.defineProperties( RemoteTrajectory.prototype, prototypeAccessors ); - - return RemoteTrajectory; -}(Trajectory)); - -/** - * @file Callback Trajectory - * @author Tarn W. Burton - * @private - */ -/** - * Callback trajectory class. Gets data from an JavaScript function. - */ -var CallbackTrajectory = /*@__PURE__*/(function (Trajectory$$1) { - function CallbackTrajectory(requestCallback, structure, params) { - Trajectory$$1.call(this, '', structure, params); - this.requestCallback = requestCallback; - this._init(structure); - } - - if ( Trajectory$$1 ) CallbackTrajectory.__proto__ = Trajectory$$1; - CallbackTrajectory.prototype = Object.create( Trajectory$$1 && Trajectory$$1.prototype ); - CallbackTrajectory.prototype.constructor = CallbackTrajectory; - - var prototypeAccessors = { type: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'callback'; }; - CallbackTrajectory.prototype._makeAtomIndices = function _makeAtomIndices () { - var atomIndices = []; - if (this.structure.type === 'StructureView') { - var indices = this.structure.getAtomIndices(); // TODO - var n = indices.length; - var p = indices[0]; - var q = indices[0]; - for (var i = 1; i < n; ++i) { - var r = indices[i]; - if (q + 1 < r) { - atomIndices.push([p, q + 1]); - p = r; - } - q = r; - } - atomIndices.push([p, q + 1]); - } - else { - atomIndices.push([0, this.atomCount]); - } - this.atomIndices = atomIndices; - }; - CallbackTrajectory.prototype._loadFrame = function _loadFrame (i, callback) { - var this$1 = this; - - this.requestCallback(function (i, box, coords, frameCount) { - this$1._process(i, box, coords, frameCount); - if (typeof callback === 'function') { - callback(); - } - }, i, this.atomIndices); - }; - CallbackTrajectory.prototype._loadFrameCount = function _loadFrameCount () { - var this$1 = this; - - this.requestCallback(function (count) { return this$1._setFrameCount(count); }); - }; - - Object.defineProperties( CallbackTrajectory.prototype, prototypeAccessors ); - - return CallbackTrajectory; -}(Trajectory)); - -/** - * @file Trajectory Utils - * @author Alexander Rose - * @private - */ -function makeTrajectory(trajSrc, structure, params) { - var traj; - if (trajSrc && trajSrc instanceof Frames) { - traj = new FramesTrajectory(trajSrc, structure, params); - } - else if (!trajSrc && structure.frames) { - traj = new StructureTrajectory(trajSrc, structure, params); - } - else if (trajSrc && typeof trajSrc === 'function') { - traj = new CallbackTrajectory(trajSrc, structure, params); - } - else { - traj = new RemoteTrajectory(trajSrc, structure, params); - } - return traj; -} - -/** - * @file Structure View - * @author Alexander Rose - * @private - */ -/** - * Get view on structure restricted to the selection - * @param {Selection} selection - the selection - * @return {StructureView} the view on the structure - */ -Structure.prototype.getView = function (selection) { - // added here to avoid cyclic import dependency - return new StructureView(this, selection); -}; -/** - * View on the structure, restricted to the selection - */ -var StructureView = /*@__PURE__*/(function (Structure$$1) { - function StructureView(structure, selection) { - Structure$$1.call(this); - this.structure = structure; - this.selection = selection; - this.center = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - this._bp = this.getBondProxy(); - this._ap = this.getAtomProxy(); - this._rp = this.getResidueProxy(); - this._cp = this.getChainProxy(); - if (this.selection) { - this.selection.signals.stringChanged.add(this.refresh, this); - } - this.structure.signals.refreshed.add(this.refresh, this); - this.refresh(); - } - - if ( Structure$$1 ) StructureView.__proto__ = Structure$$1; - StructureView.prototype = Object.create( Structure$$1 && Structure$$1.prototype ); - StructureView.prototype.constructor = StructureView; - - var prototypeAccessors = { type: { configurable: true },name: { configurable: true },path: { configurable: true },title: { configurable: true },id: { configurable: true },data: { configurable: true },atomSetDict: { configurable: true },biomolDict: { configurable: true },entityList: { configurable: true },unitcell: { configurable: true },frames: { configurable: true },boxes: { configurable: true },validation: { configurable: true },bondStore: { configurable: true },backboneBondStore: { configurable: true },rungBondStore: { configurable: true },atomStore: { configurable: true },residueStore: { configurable: true },chainStore: { configurable: true },modelStore: { configurable: true },atomMap: { configurable: true },residueMap: { configurable: true },bondHash: { configurable: true },spatialHash: { configurable: true },_hasCoords: { configurable: true } }; - StructureView.prototype.init = function init () { }; - prototypeAccessors.type.get = function () { return 'StructureView'; }; - prototypeAccessors.name.get = function () { return this.structure.name; }; - prototypeAccessors.path.get = function () { return this.structure.path; }; - prototypeAccessors.title.get = function () { return this.structure.title; }; - prototypeAccessors.id.get = function () { return this.structure.id; }; - prototypeAccessors.data.get = function () { return this.structure.data; }; - prototypeAccessors.atomSetDict.get = function () { return this.structure.atomSetDict; }; - prototypeAccessors.biomolDict.get = function () { return this.structure.biomolDict; }; - prototypeAccessors.entityList.get = function () { return this.structure.entityList; }; - prototypeAccessors.unitcell.get = function () { return this.structure.unitcell; }; - prototypeAccessors.frames.get = function () { return this.structure.frames; }; - prototypeAccessors.boxes.get = function () { return this.structure.boxes; }; - prototypeAccessors.validation.get = function () { return this.structure.validation; }; - prototypeAccessors.bondStore.get = function () { return this.structure.bondStore; }; - prototypeAccessors.backboneBondStore.get = function () { return this.structure.backboneBondStore; }; - prototypeAccessors.rungBondStore.get = function () { return this.structure.rungBondStore; }; - prototypeAccessors.atomStore.get = function () { return this.structure.atomStore; }; - prototypeAccessors.residueStore.get = function () { return this.structure.residueStore; }; - prototypeAccessors.chainStore.get = function () { return this.structure.chainStore; }; - prototypeAccessors.modelStore.get = function () { return this.structure.modelStore; }; - prototypeAccessors.atomMap.get = function () { return this.structure.atomMap; }; - prototypeAccessors.residueMap.get = function () { return this.structure.residueMap; }; - prototypeAccessors.bondHash.get = function () { return this.structure.bondHash; }; - prototypeAccessors.spatialHash.get = function () { return this.structure.spatialHash; }; - prototypeAccessors._hasCoords.get = function () { return this.structure._hasCoords; }; - prototypeAccessors._hasCoords.set = function (value) { this.structure._hasCoords = value; }; - /** - * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center. - * @emits {Structure.signals.refreshed} when refreshed - * @return {undefined} - */ - StructureView.prototype.refresh = function refresh () { - if (Debug) - { Log.time('StructureView.refresh'); } - this.atomSetCache = {}; - var structure = this.structure; - if (this.selection.isAllSelection() && - structure !== this && structure.atomSet && structure.bondSet) { - this.atomSet = structure.atomSet.clone(); - this.bondSet = structure.bondSet.clone(); - for (var name in this.atomSetDict) { - var atomSet = this.atomSetDict[name]; - this.atomSetCache['__' + name] = atomSet.clone(); - } - this.atomCount = structure.atomCount; - this.bondCount = structure.bondCount; - this.boundingBox.copy(structure.boundingBox); - this.center.copy(structure.center); - } - else if (this.selection.isNoneSelection() && - structure !== this && structure.atomSet && structure.bondSet) { - this.atomSet = new BitArray(structure.atomCount); - this.bondSet = new BitArray(structure.bondCount); - for (var name$1 in this.atomSetDict) { - this.atomSetCache['__' + name$1] = new BitArray(structure.atomCount); - } - this.atomCount = 0; - this.bondCount = 0; - this.boundingBox.makeEmpty(); - this.center.set(0, 0, 0); - } - else { - this.atomSet = this.getAtomSet(this.selection, true); - if (structure.atomSet) { - this.atomSet = this.atomSet.intersection(structure.atomSet); - } - this.bondSet = this.getBondSet(); - for (var name$2 in this.atomSetDict) { - var atomSet$1 = this.atomSetDict[name$2]; - this.atomSetCache['__' + name$2] = atomSet$1.makeIntersection(this.atomSet); - } - this.atomCount = this.atomSet.getSize(); - this.bondCount = this.bondSet.getSize(); - this.boundingBox = this.getBoundingBox(); - this.center = this.boundingBox.getCenter(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); - } - if (Debug) - { Log.timeEnd('StructureView.refresh'); } - this.signals.refreshed.dispatch(); - }; - // - StructureView.prototype.setSelection = function setSelection (selection) { - this.selection = selection; - this.refresh(); - }; - StructureView.prototype.getSelection = function getSelection (selection) { - var seleList = []; - if (selection && selection.string) { - seleList.push(selection.string); - } - var parentSelection = this.structure.getSelection(); - if (parentSelection && parentSelection.string) { - seleList.push(parentSelection.string); - } - if (this.selection && this.selection.string) { - seleList.push(this.selection.string); - } - var sele = ''; - if (seleList.length > 0) { - sele = "( " + (seleList.join(' ) AND ( ')) + " )"; - } - return new Selection(sele); - }; - StructureView.prototype.getStructure = function getStructure () { - return this.structure.getStructure(); - }; - // - StructureView.prototype.eachBond = function eachBond (callback, selection) { - this.structure.eachBond(callback, this.getSelection(selection)); - }; - StructureView.prototype.eachAtom = function eachAtom (callback, selection) { - var ap = this.getAtomProxy(); - var atomSet = this.getAtomSet(selection); - var n = this.atomStore.count; - if (atomSet.getSize() < n) { - atomSet.forEach(function (index) { - ap.index = index; - callback(ap); - }); - } - else { - for (var i = 0; i < n; ++i) { - ap.index = i; - callback(ap); - } - } - }; - StructureView.prototype.eachResidue = function eachResidue (callback, selection) { - this.structure.eachResidue(callback, this.getSelection(selection)); - }; - /** - * Not implemented - * @alias StructureView#eachResidueN - * @return {undefined} - */ - StructureView.prototype.eachResidueN = function eachResidueN (n, callback) { - console.error('StructureView.eachResidueN() not implemented'); - }; - StructureView.prototype.eachChain = function eachChain (callback, selection) { - this.structure.eachChain(callback, this.getSelection(selection)); - }; - StructureView.prototype.eachModel = function eachModel (callback, selection) { - this.structure.eachModel(callback, this.getSelection(selection)); - }; - // - StructureView.prototype.getAtomSet = function getAtomSet (selection, ignoreView) { - if ( ignoreView === void 0 ) ignoreView = false; - - var atomSet = this.structure.getAtomSet(selection); - if (!ignoreView && this.atomSet) { - atomSet = atomSet.makeIntersection(this.atomSet); - } - return atomSet; - }; - // - StructureView.prototype.getAtomIndices = function getAtomIndices (selection) { - return this.structure.getAtomIndices(this.getSelection(selection)); - }; - StructureView.prototype.refreshPosition = function refreshPosition () { - return this.structure.refreshPosition(); - }; - // - StructureView.prototype.dispose = function dispose () { - if (this.selection) { - this.selection.signals.stringChanged.remove(this.refresh, this); - } - this.structure.signals.refreshed.remove(this.refresh, this); - delete this.structure; - delete this.atomSet; - delete this.bondSet; - delete this.atomCount; - delete this.bondCount; - }; - - Object.defineProperties( StructureView.prototype, prototypeAccessors ); - - return StructureView; -}(Structure)); - -/** - * @file Alignment - * @author Alexander Rose - * @private - */ -// const nucleotides = 'ACTG'; -var aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'; -var aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'; -var blosum62x = [ - [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], - [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], - [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], - [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], - [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], - [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], - [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], - [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], - [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], - [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], - [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], - [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], - [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], - [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], - [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], - [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], - [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], - [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], - [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], - [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y -]; -var blosum62 = [ - // A R N D C Q E G H I L K M F P S T W Y V B Z X - [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], - [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], - [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], - [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], - [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], - [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], - [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], - [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], - [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], - [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], - [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], - [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], - [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], - [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], - [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], - [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], - [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], - [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], - [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], - [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], - [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], - [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], - [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X -]; -function prepareMatrix(cellNames, mat) { - var j; - var i = 0; - var matDict = {}; - mat.forEach(function (row) { - j = 0; - var rowDict = {}; - row.forEach(function (elm) { - rowDict[cellNames[j++]] = elm; - }); - matDict[cellNames[i++]] = rowDict; - }); - return matDict; -} -var SubstitutionMatrices = (function () { - return { - blosum62: prepareMatrix(aminoacids, blosum62), - blosum62x: prepareMatrix(aminoacidsX, blosum62x) - }; -}()); -var Alignment = function Alignment(seq1, seq2, gapPenalty, gapExtensionPenalty, substMatrix) { - if ( gapPenalty === void 0 ) gapPenalty = -10; - if ( gapExtensionPenalty === void 0 ) gapExtensionPenalty = -1; - if ( substMatrix === void 0 ) substMatrix = 'blosum62'; - - // TODO try encoding seqs as integers and use array subst matrix, maybe faster - this.seq1 = seq1; - this.seq2 = seq2; - this.gapPenalty = gapPenalty; - this.gapExtensionPenalty = gapExtensionPenalty; - if (substMatrix) { - this.substMatrix = SubstitutionMatrices[substMatrix]; - } -}; -Alignment.prototype.initMatrices = function initMatrices () { - this.n = this.seq1.length; - this.m = this.seq2.length; - // Log.log(this.n, this.m); - this.score = undefined; - this.ali = ''; - this.S = []; - this.V = []; - this.H = []; - for (var i = 0; i <= this.n; ++i) { - this.S[i] = []; - this.V[i] = []; - this.H[i] = []; - for (var j = 0; j <= this.m; ++j) { - this.S[i][j] = 0; - this.V[i][j] = 0; - this.H[i][j] = 0; - } - } - for (var i$1 = 0; i$1 <= this.n; ++i$1) { - this.S[i$1][0] = this.gap(0); - this.H[i$1][0] = -Infinity; - } - for (var j$1 = 0; j$1 <= this.m; ++j$1) { - this.S[0][j$1] = this.gap(0); - this.V[0][j$1] = -Infinity; - } - this.S[0][0] = 0; - // Log.log(this.S, this.V, this.H); -}; -Alignment.prototype.gap = function gap (len) { - return this.gapPenalty + len * this.gapExtensionPenalty; -}; -Alignment.prototype.makeScoreFn = function makeScoreFn () { - var seq1 = this.seq1; - var seq2 = this.seq2; - var substMatrix = this.substMatrix; - if (substMatrix) { - return function score(i, j) { - var c1 = seq1[i]; - var c2 = seq2[j]; - try { - return substMatrix[c1][c2]; - } - catch (e) { - return -4; - } - }; - } - else { - Log.warn('Alignment: no subst matrix'); - return function scoreNoSubstMat(i, j) { - var c1 = seq1[i]; - var c2 = seq2[j]; - return c1 === c2 ? 5 : -3; - }; - } -}; -Alignment.prototype.calc = function calc () { - if (Debug) - { Log.time('Alignment.calc'); } - this.initMatrices(); - var gap0 = this.gap(0); - var scoreFn = this.makeScoreFn(); - var gapExtensionPenalty = this.gapExtensionPenalty; - var V = this.V; - var H = this.H; - var S = this.S; - var n = this.n; - var m = this.m; - var Vi1, Si1, Vi, Hi, Si; - for (var i = 1; i <= n; ++i) { - Si1 = S[i - 1]; - Vi1 = V[i - 1]; - Vi = V[i]; - Hi = H[i]; - Si = S[i]; - for (var j = 1; j <= m; ++j) { - Vi[j] = Math.max(Si1[j] + gap0, Vi1[j] + gapExtensionPenalty); - Hi[j] = Math.max(Si[j - 1] + gap0, Hi[j - 1] + gapExtensionPenalty); - Si[j] = Math.max(Si1[j - 1] + scoreFn(i - 1, j - 1), // match - Vi[j], // del - Hi[j] // ins - ); - } - } - if (Debug) - { Log.timeEnd('Alignment.calc'); } - if (Debug) - { Log.log(this.S, this.V, this.H); } -}; -Alignment.prototype.trace = function trace () { - if (Debug) - { Log.time('Alignment.trace'); } - this.ali1 = ''; - this.ali2 = ''; - var scoreFn = this.makeScoreFn(); - var i = this.n; - var j = this.m; - var mat; - if (this.S[i][j] >= this.V[i][j]) { - mat = 'S'; - this.score = this.S[i][j]; - } - else if (this.V[i][j] >= this.H[i][j]) { - mat = 'V'; - this.score = this.V[i][j]; - } - else { - mat = 'H'; - this.score = this.H[i][j]; - } - if (Debug) - { Log.log('Alignment: SCORE', this.score); } - if (Debug) - { Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j]); } - while (i > 0 && j > 0) { - if (mat === 'S') { - if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) { - this.ali1 = this.seq1[i - 1] + this.ali1; - this.ali2 = this.seq2[j - 1] + this.ali2; - --i; - --j; - mat = 'S'; - } - else if (this.S[i][j] === this.V[i][j]) { - mat = 'V'; - } - else if (this.S[i][j] === this.H[i][j]) { - mat = 'H'; - } - else { - // Log.debug('Alignment: S'); - --i; - --j; - } - } - else if (mat === 'V') { - if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) { - this.ali1 = this.seq1[i - 1] + this.ali1; - this.ali2 = '-' + this.ali2; - --i; - mat = 'V'; - } - else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) { - this.ali1 = this.seq1[i - 1] + this.ali1; - this.ali2 = '-' + this.ali2; - --i; - mat = 'S'; - } - else { - // Log.debug('Alignment: V'); - --i; - } - } - else if (mat === 'H') { - if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) { - this.ali1 = '-' + this.ali1; - this.ali2 = this.seq2[j - 1] + this.ali2; - --j; - mat = 'H'; - } - else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) { - this.ali1 = '-' + this.ali1; - this.ali2 = this.seq2[j - 1] + this.ali2; - --j; - mat = 'S'; - } - else { - // Log.debug('Alignment: H'); - --j; - } - } - else { - Log.error('Alignment: no matrix'); - } - } - while (i > 0) { - this.ali1 = this.seq1[i - 1] + this.ali1; - this.ali2 = '-' + this.ali2; - --i; - } - while (j > 0) { - this.ali1 = '-' + this.ali1; - this.ali2 = this.seq2[j - 1] + this.ali2; - --j; - } - if (Debug) - { Log.timeEnd('Alignment.trace'); } - if (Debug) - { Log.log([this.ali1, this.ali2]); } -}; - -/** - * @file Align Utils - * @author Alexander Rose - * @private - */ -/** - * Perform structural superposition of two structures, - * optionally guided by a sequence alignment - * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2 - * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed - * @param {Boolean} [align] - guide the superposition by a sequence alignment - * @param {String} [sele1] - selection string for structure 1 - * @param {String} [sele2] - selection string for structure 2 - * @return {undefined} - */ -function superpose(s1, s2, align, sele1, sele2) { - if ( align === void 0 ) align = false; - if ( sele1 === void 0 ) sele1 = ''; - if ( sele2 === void 0 ) sele2 = ''; - - var i; - var j; - var n; - var atoms1; - var atoms2; - if (align) { - var _s1 = s1; - var _s2 = s2; - if (sele1 && sele2) { - _s1 = s1.getView(new Selection(sele1)); - _s2 = s2.getView(new Selection(sele2)); - } - var seq1 = _s1.getSequence(); - var seq2 = _s2.getSequence(); - // Log.log( seq1.join("") ); - // Log.log( seq2.join("") ); - var ali = new Alignment(seq1.join(''), seq2.join('')); - ali.calc(); - ali.trace(); - // Log.log( "superpose alignment score", ali.score ); - // Log.log( ali.ali1 ); - // Log.log( ali.ali2 ); - var _i, _j; - i = 0; - j = 0; - n = ali.ali1.length; - var aliIdx1 = []; - var aliIdx2 = []; - for (var l = 0; l < n; ++l) { - var x = ali.ali1[l]; - var y = ali.ali2[l]; - _i = 0; - _j = 0; - if (x === '-') { - aliIdx2[j] = false; - } - else { - aliIdx2[j] = true; - _i = 1; - } - if (y === '-') { - aliIdx1[i] = false; - } - else { - aliIdx1[i] = true; - _j = 1; - } - i += _i; - j += _j; - } - // Log.log( i, j ); - // Log.log( aliIdx1 ); - // Log.log( aliIdx2 ); - var _atoms1 = []; - var _atoms2 = []; - var ap1 = _s1.getAtomProxy(); - var ap2 = _s2.getAtomProxy(); - i = 0; - _s1.eachResidue(function (r) { - if (r.traceAtomIndex === undefined || - r.traceAtomIndex !== r.getAtomIndexByName('CA')) - { return; } - if (aliIdx1[i]) { - ap1.index = r.getAtomIndexByName('CA'); // TODO - _atoms1.push(ap1.x, ap1.y, ap1.z); - } - i += 1; - }); - i = 0; - _s2.eachResidue(function (r) { - if (r.traceAtomIndex === undefined || - r.traceAtomIndex !== r.getAtomIndexByName('CA')) - { return; } - if (aliIdx2[i]) { - ap2.index = r.getAtomIndexByName('CA'); // TODO - _atoms2.push(ap2.x, ap2.y, ap2.z); - } - i += 1; - }); - atoms1 = new Float32Array(_atoms1); - atoms2 = new Float32Array(_atoms2); - } - else { - var sviewCa1 = s1.getView(new Selection((sele1 + " and .CA"))); - var sviewCa2 = s2.getView(new Selection((sele2 + " and .CA"))); - atoms1 = sviewCa1; - atoms2 = sviewCa2; - } - var superpose = new Superposition(atoms1, atoms2); - var result = superpose.transform(s1); - s1.refreshPosition(); - return result; -} - -/** - * @file Sturucture Component - * @author Alexander Rose - * @private - */ -var StructureComponentDefaultParameters = Object.assign({ - sele: '', - defaultAssembly: '' -}, ComponentDefaultParameters); -/** - * Component wrapping a {@link Structure} object - * - * @example - * // get a structure component by loading a structure file into the stage - * stage.loadFile( "rcsb://4opj" ).then( function( structureComponent ){ - * structureComponent.addRepresentation( "cartoon" ); - * structureComponent.autoView(); - * } ); - */ -var StructureComponent = /*@__PURE__*/(function (Component$$1) { - function StructureComponent(stage, structure, params) { - if ( params === void 0 ) params = {}; - - Component$$1.call(this, stage, structure, Object.assign({ name: structure.name }, params)); - this.structure = structure; - this.trajList = []; - this.signals = Object.assign(this.signals, { - trajectoryAdded: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - trajectoryRemoved: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - defaultAssemblyChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }); - this.initSelection(this.parameters.sele); - // - this.pickBuffer = createRingBuffer(4); - this.pickDict = createSimpleDict(); - this.spacefillRepresentation = this.addRepresentation('spacefill', { - sele: 'none', - opacity: MeasurementDefaultParams.opacity, - color: MeasurementDefaultParams.color, - disablePicking: true, - radiusType: 'data' - }, true); - this.distanceRepresentation = this.addRepresentation('distance', MeasurementDefaultParams, true); - this.angleRepresentation = this.addRepresentation('angle', MeasurementDefaultParams, true); - this.dihedralRepresentation = this.addRepresentation('dihedral', MeasurementDefaultParams, true); - this.measureRepresentations = new RepresentationCollection([ - this.spacefillRepresentation, - this.distanceRepresentation, - this.angleRepresentation, - this.dihedralRepresentation - ]); - // - this.setDefaultAssembly(this.parameters.defaultAssembly); - } - - if ( Component$$1 ) StructureComponent.__proto__ = Component$$1; - StructureComponent.prototype = Object.create( Component$$1 && Component$$1.prototype ); - StructureComponent.prototype.constructor = StructureComponent; - - var prototypeAccessors = { defaultParameters: { configurable: true },type: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return StructureComponentDefaultParameters; }; - /** - * Component type - * @type {String} - */ - prototypeAccessors.type.get = function () { return 'structure'; }; - /** - * Initialize selection - * @private - * @param {String} sele - selection string - * @return {undefined} - */ - StructureComponent.prototype.initSelection = function initSelection (sele) { - var this$1 = this; - - /** - * Selection for {@link StructureComponent#structureView} - * @private - * @type {Selection} - */ - this.selection = new Selection(sele); - /** - * View on {@link StructureComponent#structure}. - * Change its selection via {@link StructureComponent#setSelection}. - * @type {StructureView} - */ - this.structureView = new StructureView(this.structure, this.selection); - this.selection.signals.stringChanged.add(function () { - this$1.structureView.setSelection(this$1.selection); - this$1.rebuildRepresentations(); - this$1.rebuildTrajectories(); - }); - }; - /** - * Set selection of {@link StructureComponent#structureView} - * @param {String} string - selection string - * @return {StructureComponent} this object - */ - StructureComponent.prototype.setSelection = function setSelection (string) { - this.parameters.sele = string; - this.selection.setString(string); - return this; - }; - /** - * Set the default assembly - * @param {String} value - assembly name - * @return {undefined} - */ - StructureComponent.prototype.setDefaultAssembly = function setDefaultAssembly (value) { - // filter out non-exsisting assemblies - if (this.structure.biomolDict[value] === undefined) - { value = ''; } - // only set default assembly when changed - if (this.parameters.defaultAssembly !== value) { - var reprParams = { defaultAssembly: value }; - this.reprList.forEach(function (repr) { return repr.setParameters(reprParams); }); - this.measureRepresentations.setParameters(reprParams); - this.parameters.defaultAssembly = value; - this.signals.defaultAssemblyChanged.dispatch(value); - } - return this; - }; - /** - * Rebuild all representations - * @return {undefined} - */ - StructureComponent.prototype.rebuildRepresentations = function rebuildRepresentations () { - this.reprList.forEach(function (repr) { - repr.build(); - }); - this.measureRepresentations.build(); - }; - /** - * Rebuild all trajectories - * @return {undefined} - */ - StructureComponent.prototype.rebuildTrajectories = function rebuildTrajectories () { - var this$1 = this; - - this.trajList.forEach(function (trajComp) { - trajComp.trajectory.setStructure(this$1.structureView); - }); - }; - StructureComponent.prototype.updateRepresentations = function updateRepresentations (what) { - Component$$1.prototype.updateRepresentations.call(this, what); - this.measureRepresentations.update(what); - }; - /** - * Overrides {@link Component.updateRepresentationMatrices} - * to also update matrix for measureRepresentations - */ - StructureComponent.prototype.updateRepresentationMatrices = function updateRepresentationMatrices () { - Component$$1.prototype.updateRepresentationMatrices.call(this); - this.measureRepresentations.setParameters({ matrix: this.matrix }); - }; - StructureComponent.prototype.addRepresentation = function addRepresentation (type, params, hidden) { - var this$1 = this; - if ( params === void 0 ) params = {}; - if ( hidden === void 0 ) hidden = false; - - params.defaultAssembly = this.parameters.defaultAssembly; - var reprComp = this._addRepresentation(type, this.structureView, params, hidden); - if (!hidden) { - reprComp.signals.parametersChanged.add(function () { return this$1.measureUpdate(); }); - } - return reprComp; - }; - /** - * Add a new trajectory component to the structure - */ - StructureComponent.prototype.addTrajectory = function addTrajectory (trajPath, params) { - var this$1 = this; - if ( trajPath === void 0 ) trajPath = ''; - if ( params === void 0 ) params = {}; - - var traj = makeTrajectory(trajPath, this.structureView, params); - traj.signals.frameChanged.add(function () { - this$1.updateRepresentations({ 'position': true }); - }); - var trajComp = new TrajectoryElement(this.stage, traj, params); - this.trajList.push(trajComp); - this.signals.trajectoryAdded.dispatch(trajComp); - return trajComp; - }; - StructureComponent.prototype.removeTrajectory = function removeTrajectory (traj) { - var idx = this.trajList.indexOf(traj); - if (idx !== -1) { - this.trajList.splice(idx, 1); - } - traj.dispose(); - this.signals.trajectoryRemoved.dispatch(traj); - }; - StructureComponent.prototype.dispose = function dispose () { - // copy via .slice because side effects may change trajList - this.trajList.slice().forEach(function (traj) { return traj.dispose(); }); - this.trajList.length = 0; - this.structure.dispose(); - this.measureRepresentations.dispose(); - Component$$1.prototype.dispose.call(this); - }; - StructureComponent.prototype.autoView = function autoView (sele, duration) { - if (typeof sele === 'number') { - duration = sele; - sele = ''; - } - this.stage.animationControls.zoomMove(this.getCenter(sele), this.getZoom(sele), defaults(duration, 0)); - }; - StructureComponent.prototype.getBoxUntransformed = function getBoxUntransformed (sele) { - var bb; - if (sele) { - bb = this.structureView.getBoundingBox(new Selection(sele)); - } - else { - bb = this.structureView.boundingBox; - } - return bb; - }; - StructureComponent.prototype.getCenterUntransformed = function getCenterUntransformed (sele) { - if (sele && typeof sele === 'string') { - return this.structure.atomCenter(new Selection(sele)); - } - else { - return this.structure.center; - } - }; - StructureComponent.prototype.superpose = function superpose$1 (component, align, sele1, sele2) { - superpose(this.structureView, component.structureView, align, sele1, sele2); - this.updateRepresentations({ 'position': true }); - return this; - }; - StructureComponent.prototype.getMaxRepresentationRadius = function getMaxRepresentationRadius (atomIndex) { - var maxRadius = 0; - var atom = this.structure.getAtomProxy(atomIndex); - this.eachRepresentation(function (reprElem) { - if (reprElem.getVisibility()) { - var repr = reprElem.repr; // TODO - maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius); - } - }); - return maxRadius; - }; - StructureComponent.prototype.measurePick = function measurePick (atom) { - var pickCount = this.pickBuffer.count; - if (this.lastPick === atom.index && pickCount >= 1) { - if (pickCount > 1) { - var atomList = this.pickBuffer.data; - var atomListSorted = this.pickBuffer.data.sort(); - if (this.pickDict.has(atomListSorted)) { - this.pickDict.del(atomListSorted); - } - else { - this.pickDict.add(atomListSorted, atomList); - } - if (pickCount === 2) { - this.distanceRepresentation.setParameters({ - atomPair: this.pickDict.values.filter(function (l) { return l.length === 2; }) - }); - } - else if (pickCount === 3) { - this.angleRepresentation.setParameters({ - atomTriple: this.pickDict.values.filter(function (l) { return l.length === 3; }) - }); - } - else if (pickCount === 4) { - this.dihedralRepresentation.setParameters({ - atomQuad: this.pickDict.values.filter(function (l) { return l.length === 4; }) - }); - } - } - this.pickBuffer.clear(); - this.lastPick = undefined; - } - else { - if (!this.pickBuffer.has(atom.index)) { - this.pickBuffer.push(atom.index); - } - this.lastPick = atom.index; - } - this.measureUpdate(); - }; - StructureComponent.prototype.measureClear = function measureClear () { - this.pickBuffer.clear(); - this.lastPick = undefined; - this.spacefillRepresentation.setSelection('none'); - }; - StructureComponent.prototype.measureBuild = function measureBuild () { - var md = this.measureData(); - this.distanceRepresentation.setParameters({ atomPair: md.distance }); - this.angleRepresentation.setParameters({ atomTriple: md.angle }); - this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral }); - }; - StructureComponent.prototype.measureUpdate = function measureUpdate () { - var this$1 = this; - - var pickData = this.pickBuffer.data; - var radiusData = {}; - pickData.forEach(function (ai) { - var r = Math.max(0.1, this$1.getMaxRepresentationRadius(ai)); - radiusData[ai] = r * (2.3 - smoothstep(0.1, 2, r)); - }); - this.spacefillRepresentation.setSelection(pickData.length ? ('@' + pickData.join(',')) : 'none'); - if (pickData.length) - { this.spacefillRepresentation.setParameters({ radiusData: radiusData }); } - }; - StructureComponent.prototype.measureData = function measureData () { - var pv = this.pickDict.values; - return { - distance: pv.filter(function (l) { return l.length === 2; }), - angle: pv.filter(function (l) { return l.length === 3; }), - dihedral: pv.filter(function (l) { return l.length === 4; }) - }; - }; - /** - * Remove all measurements, optionally limit to distance, angle or dihedral - */ - StructureComponent.prototype.removeAllMeasurements = function removeAllMeasurements (type) { - var pd = this.pickDict; - var pv = pd.values; - var remove = function (len) { - pv.filter(function (l) { return l.length === len; }).forEach(function (l) { return pd.del(l.slice().sort()); }); - }; - if (!type || type & 1 /* Distance */) - { remove(2); } - if (!type || type & 2 /* Angle */) - { remove(3); } - if (!type || type & 4 /* Dihedral */) - { remove(4); } - this.measureBuild(); - }; - /** - * Remove a measurement given as a pair, triple, quad of atom indices - */ - StructureComponent.prototype.removeMeasurement = function removeMeasurement (atomList) { - this.pickDict.del(atomList.slice().sort()); - this.measureBuild(); - }; - /** - * Add a measurement given as a pair, triple, quad of atom indices - */ - StructureComponent.prototype.addMeasurement = function addMeasurement (atomList) { - if (atomList.length < 2 || atomList.length > 4) - { return; } - var atomListSorted = atomList.slice().sort(); - if (!this.pickDict.has(atomListSorted)) { - this.pickDict.add(atomListSorted, atomList); - } - this.measureBuild(); - }; - - Object.defineProperties( StructureComponent.prototype, prototypeAccessors ); - - return StructureComponent; -}(Component)); -ComponentRegistry.add('structure', StructureComponent); -ComponentRegistry.add('structureview', StructureComponent); - -/** - * @file Surface Component - * @author Alexander Rose - * @private - */ -/** - * Component wrapping a {@link Surface} object - * - * @example - * // get a surface component by loading a surface file into the stage - * stage.loadFile( "url/for/surface" ).then( function( surfaceComponent ){ - * surfaceComponent.addRepresentation( "surface" ); - * surfaceComponent.autoView(); - * } ); - */ -var SurfaceComponent = /*@__PURE__*/(function (Component$$1) { - function SurfaceComponent(stage, surface, params) { - if ( params === void 0 ) params = {}; - - Component$$1.call(this, stage, surface, Object.assign({ name: surface.name }, params)); - this.surface = surface; - } - - if ( Component$$1 ) SurfaceComponent.__proto__ = Component$$1; - SurfaceComponent.prototype = Object.create( Component$$1 && Component$$1.prototype ); - SurfaceComponent.prototype.constructor = SurfaceComponent; - - var prototypeAccessors = { type: { configurable: true } }; - /** - * Component type - * @type {String} - */ - prototypeAccessors.type.get = function () { return 'surface'; }; - /** - * Add a new surface representation to the component - * @param {String} type - the name of the representation, one of: - * surface, dot. - * @param {SurfaceRepresentationParameters} params - representation parameters - * @return {RepresentationComponent} the created representation wrapped into - * a representation component object - */ - SurfaceComponent.prototype.addRepresentation = function addRepresentation (type, params) { - if ( params === void 0 ) params = {}; - - return this._addRepresentation(type, this.surface, params); - }; - SurfaceComponent.prototype.getBoxUntransformed = function getBoxUntransformed () { - return this.surface.boundingBox; - }; - SurfaceComponent.prototype.getCenterUntransformed = function getCenterUntransformed () { - return this.surface.center; - }; - SurfaceComponent.prototype.dispose = function dispose () { - this.surface.dispose(); - Component$$1.prototype.dispose.call(this); - }; - - Object.defineProperties( SurfaceComponent.prototype, prototypeAccessors ); - - return SurfaceComponent; -}(Component)); -ComponentRegistry.add('surface', SurfaceComponent); - -/** - * @file Volume Component - * @author Alexander Rose - * @private - */ -/** - * Component wrapping a {@link Volume} object - * - * @example - * // get a volume component by loading a volume file into the stage - * stage.loadFile( "url/for/volume" ).then(function(volumeComponent){ - * volumeComponent.addRepresentation('surface'); - * volumeComponent.autoView(); - * }); - */ -var VolumeComponent = /*@__PURE__*/(function (Component$$1) { - function VolumeComponent(stage, volume, params) { - if ( params === void 0 ) params = {}; - - Component$$1.call(this, stage, volume, Object.assign({ name: volume.name }, params)); - this.volume = volume; - } - - if ( Component$$1 ) VolumeComponent.__proto__ = Component$$1; - VolumeComponent.prototype = Object.create( Component$$1 && Component$$1.prototype ); - VolumeComponent.prototype.constructor = VolumeComponent; - - var prototypeAccessors = { type: { configurable: true } }; - /** - * Component type - * @type {String} - */ - prototypeAccessors.type.get = function () { return 'volume'; }; - /** - * Add a new volume representation to the component - */ - VolumeComponent.prototype.addRepresentation = function addRepresentation (type, params) { - if ( params === void 0 ) params = {}; - - return this._addRepresentation(type, this.volume, params); - }; - VolumeComponent.prototype.getBoxUntransformed = function getBoxUntransformed () { - return this.volume.boundingBox; - }; - VolumeComponent.prototype.getCenterUntransformed = function getCenterUntransformed () { - return this.volume.center; - }; - VolumeComponent.prototype.dispose = function dispose () { - this.volume.dispose(); - Component$$1.prototype.dispose.call(this); - }; - - Object.defineProperties( VolumeComponent.prototype, prototypeAccessors ); - - return VolumeComponent; -}(Component)); -ComponentRegistry.add('volume', VolumeComponent); - -/** - * @file Component Collection - * @author Alexander Rose - * @private - */ -var ComponentCollection = /*@__PURE__*/(function (Collection$$1) { - function ComponentCollection () { - Collection$$1.apply(this, arguments); - } - - if ( Collection$$1 ) ComponentCollection.__proto__ = Collection$$1; - ComponentCollection.prototype = Object.create( Collection$$1 && Collection$$1.prototype ); - ComponentCollection.prototype.constructor = ComponentCollection; - - ComponentCollection.prototype.addRepresentation = function addRepresentation (name, params) { - return this.forEach(function (comp) { return comp.addRepresentation(name, params); }); - }; - ComponentCollection.prototype.autoView = function autoView (duration) { - return this.forEach(function (comp) { return comp.autoView(duration); }); - }; - - return ComponentCollection; -}(Collection)); - -/** - * @file Stage - * @author Alexander Rose - * @private - */ -function matchName(name, object) { - if (name instanceof RegExp) { - return object.name.match(name) !== null; - } - else { - return object.name === name; - } -} -var tmpZoomVector = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var StageDefaultParameters = { - impostor: true, - quality: 'medium', - workerDefault: true, - sampleLevel: 0, - backgroundColor: 'black', - rotateSpeed: 2.0, - zoomSpeed: 1.2, - panSpeed: 1.0, - clipNear: 0, - clipFar: 100, - clipDist: 10, - clipMode: 'scene', - clipScale: 'relative', - fogNear: 50, - fogFar: 100, - cameraFov: 40, - cameraEyeSep: 0.3, - cameraType: 'perspective', - lightColor: 0xdddddd, - lightIntensity: 1.0, - ambientColor: 0xdddddd, - ambientIntensity: 0.2, - hoverTimeout: 0, - tooltip: true, - mousePreset: 'default' -}; -/** - * Stage class, central for creating molecular scenes with NGL. - * - * @example - * var stage = new Stage( "elementId", { backgroundColor: "white" } ); - */ -var Stage = function Stage(idOrElement, params) { - if ( params === void 0 ) params = {}; - - this.signals = { - parametersChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - fullscreenChanged: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - componentAdded: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - componentRemoved: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - clicked: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"](), - hovered: new __WEBPACK_IMPORTED_MODULE_2_signals__["Signal"]() - }; - /** - * Counter that keeps track of various potentially long-running tasks, - * including file loading and surface calculation. - */ - this.tasks = new Counter(); - this.compList = []; - this.defaultFileParams = {}; - this.logList = []; - this.viewer = new Viewer(idOrElement); - if (!this.viewer.renderer) - { return; } - this.tooltip = document.createElement('div'); - Object.assign(this.tooltip.style, { - display: 'none', - position: 'fixed', - zIndex: '1000000', - pointerEvents: 'none', - backgroundColor: 'rgba( 0, 0, 0, 0.6 )', - color: 'lightgrey', - padding: '8px', - fontFamily: 'sans-serif' - }); - this.viewer.container.appendChild(this.tooltip); - this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement); - this.viewerControls = new ViewerControls(this); - this.trackballControls = new TrackballControls(this); - this.pickingControls = new PickingControls(this); - this.animationControls = new AnimationControls(this); - this.mouseControls = new MouseControls(this); - this.keyControls = new KeyControls(this); - this.pickingBehavior = new PickingBehavior(this); - this.mouseBehavior = new MouseBehavior(this); - this.animationBehavior = new AnimationBehavior(this); - this.keyBehavior = new KeyBehavior(this); - this.spinAnimation = this.animationControls.spin([0, 1, 0], 0.005); - this.spinAnimation.pause(true); - this.rockAnimation = this.animationControls.rock([0, 1, 0], 0.005); - this.rockAnimation.pause(true); - // must come after the viewer has been instantiated - this.parameters = createParams(params, StageDefaultParameters); - this.setParameters(this.parameters); - this.viewer.animate(); -}; -/** - * Set stage parameters - */ -Stage.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - updateParams(this.parameters, params); - var p = params; - var tp = this.parameters; - var viewer = this.viewer; - var controls = this.trackballControls; - // apply parameters - if (p.quality !== undefined) - { this.setQuality(tp.quality); } - if (p.impostor !== undefined) - { this.setImpostor(tp.impostor); } - if (p.rotateSpeed !== undefined) - { controls.rotateSpeed = tp.rotateSpeed; } - if (p.zoomSpeed !== undefined) - { controls.zoomSpeed = tp.zoomSpeed; } - if (p.panSpeed !== undefined) - { controls.panSpeed = tp.panSpeed; } - if (p.mousePreset !== undefined) - { this.mouseControls.preset(tp.mousePreset); } - this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout }); - viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale); - viewer.setFog(undefined, tp.fogNear, tp.fogFar); - viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep); - viewer.setSampling(tp.sampleLevel); - viewer.setBackground(tp.backgroundColor); - viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity); - this.signals.parametersChanged.dispatch(this.getParameters()); - return this; -}; -Stage.prototype.log = function log (msg) { - console.log('STAGE LOG', msg); - this.logList.push(msg); -}; -/** - * Get stage parameters - */ -Stage.prototype.getParameters = function getParameters () { - return Object.assign({}, this.parameters); -}; -/** - * Create default representations for the given component - * @param {StructureComponent|SurfaceComponent} object - component to create the representations for - * @return {undefined} - */ -Stage.prototype.defaultFileRepresentation = function defaultFileRepresentation (component) { - if (component instanceof StructureComponent) { - component.setSelection('/0'); - var atomCount, residueCount, instanceCount; - var structure = component.structure; - if (structure.biomolDict.BU1) { - var assembly = structure.biomolDict.BU1; - atomCount = assembly.getAtomCount(structure); - residueCount = assembly.getResidueCount(structure); - instanceCount = assembly.getInstanceCount(); - component.setDefaultAssembly('BU1'); - } - else { - atomCount = structure.getModelProxy(0).atomCount; - residueCount = structure.getModelProxy(0).residueCount; - instanceCount = 1; - } - var sizeScore = atomCount; - if (Mobile) { - sizeScore *= 4; - } - var backboneOnly = structure.atomStore.count / structure.residueStore.count < 2; - if (backboneOnly) { - sizeScore *= 10; - } - var colorScheme = 'chainname'; - var colorScale = 'RdYlBu'; - var colorReverse = false; - if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) { - colorScheme = 'residueindex'; - colorScale = 'spectral'; - colorReverse = true; - } - if (Debug) - { console.log(sizeScore, atomCount, instanceCount, backboneOnly); } - if (residueCount / instanceCount < 4) { - component.addRepresentation('ball+stick', { - colorScheme: 'element', - radiusScale: 2.0, - aspectRatio: 1.5, - bondScale: 0.3, - bondSpacing: 0.75, - quality: 'auto' - }); - } - else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) { - var scaleFactor = (Math.min(1.5, Math.max(0.1, 2000 / (sizeScore / instanceCount)))); - if (backboneOnly) - { scaleFactor = Math.min(scaleFactor, 0.15); } - component.addRepresentation('surface', { - colorScheme: colorScheme, colorScale: colorScale, colorReverse: colorReverse, - sele: 'polymer', - surfaceType: 'sas', - probeRadius: 1.4, - scaleFactor: scaleFactor, - useWorker: false - }); - } - else if (sizeScore > 250000) { - component.addRepresentation('backbone', { - colorScheme: colorScheme, colorScale: colorScale, colorReverse: colorReverse, - lineOnly: true - }); - } - else if (sizeScore > 100000) { - component.addRepresentation('backbone', { - colorScheme: colorScheme, colorScale: colorScale, colorReverse: colorReverse, - quality: 'low', - disableImpostor: true, - radiusScale: 2.0 - }); - } - else if (sizeScore > 80000) { - component.addRepresentation('backbone', { - colorScheme: colorScheme, colorScale: colorScale, colorReverse: colorReverse, - radiusScale: 2.0 - }); - } - else { - component.addRepresentation('cartoon', { - colorScheme: colorScheme, colorScale: colorScale, colorReverse: colorReverse, - radiusScale: 0.7, - aspectRatio: 5, - quality: 'auto' - }); - if (sizeScore < 50000) { - component.addRepresentation('base', { - colorScheme: colorScheme, colorScale: colorScale, colorReverse: colorReverse, - quality: 'auto' - }); - } - component.addRepresentation('ball+stick', { - sele: 'ligand', - colorScheme: 'element', - radiusScale: 2.0, - aspectRatio: 1.5, - bondScale: 0.3, - bondSpacing: 0.75, - quality: 'auto' - }); - } - // add frames as trajectory - if (component.structure.frames.length) { - component.addTrajectory(); - } - } - else if (component instanceof SurfaceComponent) { - component.addRepresentation('surface'); - } - else if (component instanceof VolumeComponent) { - component.addRepresentation('surface'); - } - this.tasks.onZeroOnce(this.autoView, this); -}; -/** - * Load a file onto the stage - * - * @example - * // load from URL - * stage.loadFile( "http://files.rcsb.org/download/5IOS.cif" ); - * - * @example - * // load binary data in CCP4 format via a Blob - * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} ); - * stage.loadFile( binaryBlob, { ext: "ccp4" } ); - * - * @example - * // load string data in PDB format via a Blob - * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} ); - * stage.loadFile( stringBlob, { ext: "pdb" } ); - * - * @example - * // load a File object - * stage.loadFile( file ); - * - * @example - * // load from URL and add a 'ball+stick' representation with double/triple bonds - * stage.loadFile( "http://files.rcsb.org/download/1crn.cif" ).then( function( comp ){ - * comp.addRepresentation( "ball+stick", { multipleBond: true } ); - * } ); - * - * @param {String|File|Blob} path - either a URL or an object containing the file data - * @param {LoaderParameters} params - loading parameters - * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory - * @return {Promise} A Promise object that resolves to a {@link StructureComponent}, - * a {@link SurfaceComponent} or a {@link ScriptComponent} object, - * depending on the type of the loaded file. - */ -Stage.prototype.loadFile = function loadFile (path, params) { - var this$1 = this; - if ( params === void 0 ) params = {}; - - var p = Object.assign({}, this.defaultFileParams, params); - var name = getFileInfo(path).name; - this.tasks.increment(); - this.log(("loading file '" + name + "'")); - var onLoadFn = function (object) { - this$1.log(("loaded '" + name + "'")); - var component = this$1.addComponentFromObject(object, p); - if (p.defaultRepresentation) { - this$1.defaultFileRepresentation(component); - } - this$1.tasks.decrement(); - return component; - }; - var onErrorFn = function (e) { - this$1.tasks.decrement(); - var errorMsg = "error loading file: '" + e + "'"; - this$1.log(errorMsg); - throw errorMsg; // throw so it can be catched - }; - var ext = defaults(p.ext, getFileInfo(path).ext); - var promise; - if (ParserRegistry$1.isTrajectory(ext)) { - promise = Promise.reject(new Error(("loadFile: ext '" + ext + "' is a trajectory and must be loaded into a structure component"))); - } - else { - promise = autoLoad(path, p); - } - return promise.then(onLoadFn, onErrorFn); -}; -Stage.prototype.loadScript = function loadScript (path) { - var this$1 = this; - - var name = getFileInfo(path).name; - this.log(("loading script '" + name + "'")); - return autoLoad(path).then(function (script) { - this$1.tasks.increment(); - this$1.log(("running script '" + name + "'")); - script.run(this$1).then(function () { - this$1.tasks.decrement(); - this$1.log(("finished script '" + name + "'")); - }); - this$1.log(("called script '" + name + "'")); - }, function (error) { - this$1.tasks.decrement(); - var errorMsg = "errored script '" + name + "' \"" + error + "\""; - this$1.log(errorMsg); - throw errorMsg; // throw so it can be catched - }); -}; -/** - * Add the given component to the stage - * @param {Component} component - the component to add - * @return {undefined} - */ -Stage.prototype.addComponent = function addComponent (component) { - if (!component) { - Log.warn('Stage.addComponent: no component given'); - return; - } - this.compList.push(component); - this.signals.componentAdded.dispatch(component); -}; -/** - * Create a component from the given object and add to the stage - */ -Stage.prototype.addComponentFromObject = function addComponentFromObject (object, params) { - if ( params === void 0 ) params = {}; - - var CompClass = ComponentRegistry.get(object.type); - if (CompClass) { - var component = new CompClass(this, object, params); - this.addComponent(component); - return component; - } - Log.warn('no component for object type', object.type); -}; -/** - * Remove the given component - * @param {Component} component - the component to remove - * @return {undefined} - */ -Stage.prototype.removeComponent = function removeComponent (component) { - var idx = this.compList.indexOf(component); - if (idx !== -1) { - this.compList.splice(idx, 1); - component.dispose(); - this.signals.componentRemoved.dispatch(component); - } -}; -/** - * Remove all components from the stage - */ -Stage.prototype.removeAllComponents = function removeAllComponents () { - var this$1 = this; - - this.compList.slice().forEach(function (o) { return this$1.removeComponent(o); }); -}; -/** - * Handle any size-changes of the container element - * @return {undefined} - */ -Stage.prototype.handleResize = function handleResize () { - this.viewer.handleResize(); -}; -/** - * Set width and height - * @param {String} width - CSS width value - * @param {String} height - CSS height value - * @return {undefined} - */ -Stage.prototype.setSize = function setSize (width, height) { - var container = this.viewer.container; - if (container !== document.body) { - if (width !== undefined) - { container.style.width = width; } - if (height !== undefined) - { container.style.height = height; } - this.handleResize(); - } -}; -/** - * Toggle fullscreen - * @param {Element} [element] - document element to put into fullscreen, - * defaults to the viewer container - * @return {undefined} - */ -Stage.prototype.toggleFullscreen = function toggleFullscreen (element) { - if (!document.fullscreenEnabled && !document.mozFullScreenEnabled && - !document.webkitFullscreenEnabled && !document.msFullscreenEnabled) { - Log.log('fullscreen mode (currently) not possible'); - return; - } - var self = this; - element = element || this.viewer.container; - this.lastFullscreenElement = element; - // - function getFullscreenElement() { - return document.fullscreenElement || document.mozFullScreenElement || - document.webkitFullscreenElement || document.msFullscreenElement; - } - function resizeElement() { - if (!getFullscreenElement() && self.lastFullscreenElement) { - var element = self.lastFullscreenElement; - element.style.width = element.dataset.normalWidth || ''; - element.style.height = element.dataset.normalHeight || ''; - document.removeEventListener('fullscreenchange', resizeElement); - document.removeEventListener('mozfullscreenchange', resizeElement); - document.removeEventListener('webkitfullscreenchange', resizeElement); - document.removeEventListener('MSFullscreenChange', resizeElement); - self.handleResize(); - self.signals.fullscreenChanged.dispatch(false); - } - } - // - if (!getFullscreenElement()) { - element.dataset.normalWidth = element.style.width || ''; - element.dataset.normalHeight = element.style.height || ''; - element.style.width = window.screen.width + 'px'; - element.style.height = window.screen.height + 'px'; - if (element.requestFullscreen) { - element.requestFullscreen(); - } - else if (element.msRequestFullscreen) { - element.msRequestFullscreen(); - } - else if (element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } - else if (element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } - document.addEventListener('fullscreenchange', resizeElement); - document.addEventListener('mozfullscreenchange', resizeElement); - document.addEventListener('webkitfullscreenchange', resizeElement); - document.addEventListener('MSFullscreenChange', resizeElement); - this.handleResize(); - this.signals.fullscreenChanged.dispatch(true); - // workaround for Safari - setTimeout(function () { self.handleResize(); }, 100); - } - else { - if (document.exitFullscreen) { - document.exitFullscreen(); - } - else if (document.msExitFullscreen) { - document.msExitFullscreen(); - } - else if (document.mozCancelFullScreen) { - document.mozCancelFullScreen(); - } - else if (document.webkitExitFullscreen) { - document.webkitExitFullscreen(); - } - } -}; -/** - * Set spin - * @param {Boolean} flag - if true start rocking and stop spinning - * @return {undefined} - */ -Stage.prototype.setSpin = function setSpin (flag) { - if (flag) { - this.spinAnimation.resume(true); - this.rockAnimation.pause(true); - } - else { - this.spinAnimation.pause(true); - } -}; -/** - * Set rock - * @param {Boolean} flag - if true start rocking and stop spinning - * @return {undefined} - */ -Stage.prototype.setRock = function setRock (flag) { - if (flag) { - this.rockAnimation.resume(true); - this.spinAnimation.pause(true); - } - else { - this.rockAnimation.pause(true); - } -}; -/** - * Toggle spin - * @return {undefined} - */ -Stage.prototype.toggleSpin = function toggleSpin () { - this.setSpin(this.spinAnimation.paused); -}; -/** - * Toggle rock - * @return {undefined} - */ -Stage.prototype.toggleRock = function toggleRock () { - this.setRock(this.rockAnimation.paused); -}; -/** - * Get the current focus from the current clipNear value expressed - * as 0 (full view) to 100 (completely clipped) - * Negative values may be returned in some cases. - * - * In 'camera' clipMode focus isn't applicable, this method returns 0.0 - * - * @return {number} focus - */ -Stage.prototype.getFocus = function getFocus () { - var p = this.parameters; - if (p.clipMode !== 'scene') - { return 0.0; } - var clipNear = p.clipNear; - if (p.clipScale === 'absolute') { - clipNear = this.viewer.absoluteToRelative(clipNear); - } - return clipNear * 2; -}; -/** - * Set the focus, a value of 0 sets clipping planes to show full scene, - * while a value of 100 will compltely clip the scene. - * - * @param {number} value focus - */ -Stage.prototype.setFocus = function setFocus (value) { - if (this.parameters.clipMode !== 'scene') - { return; } - var clipNear; - var clipFar; - var fogNear; - var fogFar; - if (this.parameters.clipScale === 'relative') { - clipNear = clamp(value / 2.0, 0.0, 49.9); - clipFar = 100 - clipNear; - fogNear = 50; - fogFar = pclamp(2 * clipFar - 50); - } - else { - clipNear = this.viewer.relativeToAbsolute(value / 2.0); - clipFar = clipNear; - fogNear = 0; - fogFar = 2 * clipFar; - } - this.setParameters({ clipNear: clipNear, clipFar: clipFar, fogNear: fogNear, fogFar: fogFar }); -}; -Stage.prototype.getZoomForBox = function getZoomForBox (boundingBox) { - var bbSize = boundingBox.getSize(tmpZoomVector); - var maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z); - var minSize = Math.min(bbSize.x, bbSize.y, bbSize.z); - var distance = maxSize + Math.sqrt(minSize); - var fov = degToRad(this.viewer.perspectiveCamera.fov); - var width = this.viewer.width; - var height = this.viewer.height; - var aspect = width / height; - var aspectFactor = (height < width ? 1 : aspect); - distance = Math.abs(((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)); - distance += this.parameters.clipDist; - return -distance; -}; -Stage.prototype.getBox = function getBox () { - return this.viewer.boundingBox; -}; -Stage.prototype.getZoom = function getZoom () { - return this.getZoomForBox(this.getBox()); -}; -Stage.prototype.getCenter = function getCenter (optionalTarget) { - return this.getBox().getCenter(optionalTarget || new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); -}; -/** - * Add a zoom and a move animation with automatic targets - * @param {Integer} duration - animation time in milliseconds - * @return {undefined} - */ -Stage.prototype.autoView = function autoView (duration) { - this.animationControls.zoomMove(this.getCenter(), this.getZoom(), defaults(duration, 0)); -}; -/** - * Make image from what is shown in a viewer canvas - */ -Stage.prototype.makeImage = function makeImage (params) { - var this$1 = this; - if ( params === void 0 ) params = {}; - - return new Promise(function (resolve, reject) { - this$1.tasks.onZeroOnce(function () { - this$1.tasks.increment(); - this$1.viewer.makeImage(params).then(function (blob) { - this$1.tasks.decrement(); - resolve(blob); - }).catch(function (e) { - this$1.tasks.decrement(); - reject(e); - }); - }); - }); -}; -Stage.prototype.setImpostor = function setImpostor (value) { - this.parameters.impostor = value; - var types = [ - 'spacefill', 'ball+stick', 'licorice', 'hyperball', - 'backbone', 'rocket', 'helixorient', 'contact', 'distance', - 'dot' - ]; - this.eachRepresentation(function (reprElem) { - if (!types.includes(reprElem.getType())) - { return; } - var p = reprElem.getParameters(); // TODO - p.disableImpostor = !value; - reprElem.build(p); - }); -}; -Stage.prototype.setQuality = function setQuality (value) { - this.parameters.quality = value; - var types = [ - 'tube', 'cartoon', 'ribbon', 'trace', 'rope' - ]; - var impostorTypes = [ - 'spacefill', 'ball+stick', 'licorice', 'hyperball', - 'backbone', 'rocket', 'helixorient', 'contact', 'distance', - 'dot' - ]; - this.eachRepresentation(function (repr) { - var p = repr.getParameters(); // TODO - if (!types.includes(repr.getType())) { - if (!impostorTypes.includes(repr.getType())) - { return; } - if (!p.disableImpostor) { - repr.repr.quality = value; // TODO - return; - } - } - p.quality = value; - repr.build(p); - }); -}; -/** - * Iterator over each component and executing the callback - */ -Stage.prototype.eachComponent = function eachComponent (callback, type) { - this.compList.slice().forEach(function (comp) { - if (type === undefined || type === comp.type) - { callback(comp); } - }); -}; -/** - * Iterator over each representation and executing the callback - */ -Stage.prototype.eachRepresentation = function eachRepresentation (callback, type) { - this.eachComponent(function (comp) { - comp.reprList.slice().forEach(function (reprElem) { - if (type === undefined || type === reprElem.getType()) - { callback(reprElem, comp); } - }); - }); -}; -/** - * Get collection of components by name - */ -Stage.prototype.getComponentsByName = function getComponentsByName (name) { - var compList = []; - this.eachComponent(function (comp) { - if (name === undefined || matchName(name, comp)) - { compList.push(comp); } - }); - return new ComponentCollection(compList); -}; -/** - * Get collection of components by object - */ -Stage.prototype.getComponentsByObject = function getComponentsByObject (object) { - var compList = []; - this.eachComponent(function (comp) { - if (comp.object === object) - { compList.push(comp); } - }); - return new ComponentCollection(compList); -}; -/** - * Get collection of representations by name - */ -Stage.prototype.getRepresentationsByName = function getRepresentationsByName (name) { - var reprList = []; - this.eachRepresentation(function (repr, comp) { - if (name === undefined || matchName(name, repr)) - { reprList.push(repr); } - }); - return new RepresentationCollection(reprList); -}; -Stage.prototype.measureClear = function measureClear () { - this.eachComponent(function (sc) { return sc.measureClear(); }, 'structure'); -}; -Stage.prototype.measureUpdate = function measureUpdate () { - this.eachComponent(function (sc) { return sc.measureUpdate(); }, 'structure'); -}; -/** - * Cleanup when disposing of a stage object - */ -Stage.prototype.dispose = function dispose () { - this.tasks.dispose(); - this.viewer.dispose(); -}; - -/** - * @file Shape Component - * @author Alexander Rose - * @private - */ -/** - * Component wrapping a {@link Shape} object - * - * @example - * // get a shape component by adding a shape object to the stage - * var shape = new NGL.Shape( "shape" ); - * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 ); - * var shapeComponent = stage.addComponentFromObject( shape ); - * shapeComponent.addRepresentation( "buffer" ); - */ -var ShapeComponent = /*@__PURE__*/(function (Component$$1) { - function ShapeComponent(stage, shape, params) { - if ( params === void 0 ) params = {}; - - Component$$1.call(this, stage, shape, Object.assign({ name: shape.name }, params)); - this.shape = shape; - } - - if ( Component$$1 ) ShapeComponent.__proto__ = Component$$1; - ShapeComponent.prototype = Object.create( Component$$1 && Component$$1.prototype ); - ShapeComponent.prototype.constructor = ShapeComponent; - - var prototypeAccessors = { type: { configurable: true } }; - /** - * Component type - * @type {String} - */ - prototypeAccessors.type.get = function () { return 'shape'; }; - /** - * Add a new shape representation to the component - * @param {String} type - the name of the representation, one of: - * buffer. - * @param {BufferRepresentationParameters} params - representation parameters - * @return {RepresentationComponent} the created representation wrapped into - * a representation component object - */ - ShapeComponent.prototype.addRepresentation = function addRepresentation (type, params) { - if ( params === void 0 ) params = {}; - - return this._addRepresentation(type, this.shape, params); - }; - ShapeComponent.prototype.getBoxUntransformed = function getBoxUntransformed () { - return this.shape.boundingBox; - }; - ShapeComponent.prototype.getCenterUntransformed = function getCenterUntransformed () { - return this.shape.center; - }; - ShapeComponent.prototype.dispose = function dispose () { - this.shape.dispose(); - Component$$1.prototype.dispose.call(this); - }; - - Object.defineProperties( ShapeComponent.prototype, prototypeAccessors ); - - return ShapeComponent; -}(Component)); -ComponentRegistry.add('shape', ShapeComponent); - -/** - * @file Atomindex Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by atom index. The {@link AtomProxy.index} property is used for coloring. - * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The - * `params.domain` parameter is ignored. - * - * __Name:__ _atomindex_ - * - * @example - * stage.loadFile( "rcsb://1crn" ).then( function( o ){ - * o.addRepresentation( "ball+stick", { colorScheme: "atomindex" } ); - * o.autoView(); - * } ); - */ -var AtomindexColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function AtomindexColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - if (!params.scale) { - this.parameters.scale = 'rainbow'; - this.parameters.reverse = defaults(params.reverse, true); - } - this.scalePerModel = {}; - params.structure.eachModel(function (mp) { - this$1.parameters.domain = [mp.atomOffset, mp.atomEnd]; - this$1.scalePerModel[mp.index] = this$1.getScale(); // TODO - }); - } - - if ( Colormaker$$1 ) AtomindexColormaker.__proto__ = Colormaker$$1; - AtomindexColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - AtomindexColormaker.prototype.constructor = AtomindexColormaker; - /** - * get color for an atom - * @param {AtomProxy} atom - atom to get color for - * @return {Integer} hex atom color - */ - AtomindexColormaker.prototype.atomColor = function atomColor (atom) { - return this.scalePerModel[atom.modelIndex](atom.index); - }; - - return AtomindexColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('atomindex', AtomindexColormaker); // TODO - -/** - * @file Bfactor Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring. - * By default the min and max b-factor values are used for the scale`s domain. - * - * __Name:__ _bfactor_ - * - * @example - * stage.loadFile( "rcsb://1crn" ).then( function( o ){ - * o.addRepresentation( "ball+stick", { colorScheme: "bfactor" } ); - * o.autoView(); - * } ); - */ -var BfactorColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function BfactorColormaker(params) { - Colormaker$$1.call(this, params); - if (!params.scale) { - this.parameters.scale = 'OrRd'; - } - if (!params.domain) { - var selection; - var min = Infinity; - var max = -Infinity; - if (params.sele) { - selection = new Selection(params.sele); - } - params.structure.eachAtom(function (a) { - var bfactor = a.bfactor; - min = Math.min(min, bfactor); - max = Math.max(max, bfactor); - }, selection); - this.parameters.domain = [min, max]; - } - this.bfactorScale = this.getScale(); - } - - if ( Colormaker$$1 ) BfactorColormaker.__proto__ = Colormaker$$1; - BfactorColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - BfactorColormaker.prototype.constructor = BfactorColormaker; - BfactorColormaker.prototype.atomColor = function atomColor (a) { - return this.bfactorScale(a.bfactor); - }; - - return BfactorColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('bfactor', BfactorColormaker); - -/** - * @file Chainid Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by chain id - */ -var ChainidColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ChainidColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - this.chainidDictPerModel = {}; - this.scalePerModel = {}; - if (!params.scale) { - this.parameters.scale = 'Spectral'; - } - params.structure.eachModel(function (mp) { - var i = 0; - var chainidDict = {}; - mp.eachChain(function (cp) { - if (chainidDict[cp.chainid] === undefined) { - chainidDict[cp.chainid] = i; - i += 1; - } - }); - this$1.parameters.domain = [0, i - 1]; - this$1.chainidDictPerModel[mp.index] = chainidDict; - this$1.scalePerModel[mp.index] = this$1.getScale(); - }); - } - - if ( Colormaker$$1 ) ChainidColormaker.__proto__ = Colormaker$$1; - ChainidColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ChainidColormaker.prototype.constructor = ChainidColormaker; - ChainidColormaker.prototype.atomColor = function atomColor (a) { - var chainidDict = this.chainidDictPerModel[a.modelIndex]; - return this.scalePerModel[a.modelIndex](chainidDict[a.chainid]); - }; - - return ChainidColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('chainid', ChainidColormaker); - -/** - * @file Chainindex Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by chain index - */ -var ChainindexColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ChainindexColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - this.scalePerModel = {}; - if (!params.scale) { - this.parameters.scale = 'Spectral'; - } - params.structure.eachModel(function (mp) { - this$1.parameters.domain = [mp.chainOffset, mp.chainEnd]; - this$1.scalePerModel[mp.index] = this$1.getScale(); - }); - } - - if ( Colormaker$$1 ) ChainindexColormaker.__proto__ = Colormaker$$1; - ChainindexColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ChainindexColormaker.prototype.constructor = ChainindexColormaker; - ChainindexColormaker.prototype.atomColor = function atomColor (a) { - return this.scalePerModel[a.modelIndex](a.chainIndex); - }; - - return ChainindexColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('chainindex', ChainindexColormaker); - -/** - * @file Chainname Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by chain name - */ -var ChainnameColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ChainnameColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - this.chainnameDictPerModel = {}; - this.scalePerModel = {}; - if (!params.scale) { - this.parameters.scale = 'Spectral'; - } - params.structure.eachModel(function (mp) { - var i = 0; - var chainnameDict = {}; - mp.eachChain(function (cp) { - if (chainnameDict[cp.chainname] === undefined) { - chainnameDict[cp.chainname] = i; - i += 1; - } - }); - this$1.parameters.domain = [0, i - 1]; - this$1.chainnameDictPerModel[mp.index] = chainnameDict; - this$1.scalePerModel[mp.index] = this$1.getScale(); - }); - } - - if ( Colormaker$$1 ) ChainnameColormaker.__proto__ = Colormaker$$1; - ChainnameColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ChainnameColormaker.prototype.constructor = ChainnameColormaker; - ChainnameColormaker.prototype.atomColor = function atomColor (a) { - var chainnameDict = this.chainnameDictPerModel[a.modelIndex]; - return this.scalePerModel[a.modelIndex](chainnameDict[a.chainname]); - }; - - return ChainnameColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('chainname', ChainnameColormaker); - -/** - * @file Densityfit Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by validation density fit - */ -var DensityfitColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function DensityfitColormaker(params) { - Colormaker$$1.call(this, params); - this.rsrzDict = {}; - this.rsccDict = {}; - if (!params.scale) { - this.parameters.scale = 'RdYlBu'; - } - this.rsrzScale = this.getScale({ domain: [2, 0] }); - this.rsccScale = this.getScale({ domain: [0.678, 1.0] }); - var val = params.structure.validation; - if (val) { - this.rsrzDict = val.rsrzDict; - this.rsccDict = val.rsccDict; - } - } - - if ( Colormaker$$1 ) DensityfitColormaker.__proto__ = Colormaker$$1; - DensityfitColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - DensityfitColormaker.prototype.constructor = DensityfitColormaker; - DensityfitColormaker.prototype.atomColor = function atomColor (atom) { - var sele = atom.resno + ''; - if (atom.inscode) - { sele += '^' + atom.inscode; } - if (atom.chainname) - { sele += ':' + atom.chainname; } - sele += '/' + atom.modelIndex; - var rsrz = this.rsrzDict[sele]; - if (rsrz !== undefined) { - return this.rsrzScale(rsrz); - } - var rscc = this.rsccDict[sele]; - if (rscc !== undefined) { - return this.rsccScale(rscc); - } - return 0x909090; - }; - - return DensityfitColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('densityfit', DensityfitColormaker); - -/** - * @file Atomindex Colormaker - * @author Fred Ludlow - * @author Alexander Rose - * @private - */ -// from CHARMM -var partialCharges = { - 'ARG': { - 'CD': 0.1, - 'CZ': 0.5, - 'NE': -0.1 - }, - 'ASN': { - 'CG': 0.55, - 'OD1': -0.55 - }, - 'ASP': { - 'CB': -0.16, - 'CG': 0.36, - 'OD1': -0.6, - 'OD2': -0.6 - }, - 'CYS': { - 'CB': 0.19, - 'SG': -0.19 - }, - 'GLN': { - 'CD': 0.55, - 'OE1': -0.55 - }, - 'GLU': { - 'CD': 0.36, - 'CG': -0.16, - 'OE1': -0.6, - 'OE2': -0.6 - }, - 'HIS': { - 'CB': 0.1, - 'CD2': 0.2, - 'CE1': 0.45, - 'CG': 0.15, - 'ND1': 0.05, - 'NE2': 0.05 - }, - 'LYS': { - 'CE': 0.25, - 'NZ': 0.75 - }, - 'MET': { - 'CE': 0.06, - 'CG': 0.06, - 'SD': -0.12 - }, - 'PTR': { - 'C': 0.55, - 'CA': 0.1, - 'CZ': 0.25, - 'N': -0.35, - 'O': -0.55, - 'O1P': -0.85, - 'O2P': -0.85, - 'O3P': -0.85, - 'OG1': -1.1, - 'P': 1.4 - }, - 'SEP': { - 'C': 0.55, - 'CA': 0.1, - 'CB': 0.25, - 'N': -0.35, - 'O': -0.55, - 'O1P': -0.85, - 'O2P': -0.85, - 'O3P': -0.85, - 'OG1': -1.1, - 'P': 1.4 - }, - 'SER': { - 'CB': 0.25, - 'OG': -0.25 - }, - 'THR': { - 'CB': 0.25, - 'OG1': -0.25 - }, - 'TPO': { - 'C': 0.55, - 'CA': 0.1, - 'CB': 0.25, - 'N': -0.35, - 'O': -0.55, - 'OG1': -1.1, - 'O1P': -0.85, - 'O2P': -0.85, - 'O3P': -0.85, - 'P': 1.4 - }, - 'TRP': { - 'CD1': 0.06, - 'CD2': 0.1, - 'CE2': -0.04, - 'CE3': -0.03, - 'CG': -0.03, - 'NE1': -0.06 - }, - 'TYR': { - 'CZ': 0.25, - 'OH': -0.25 - }, - 'backbone': { - 'C': 0.55, - 'O': -0.55, - 'N': -0.35, - 'CA': 0.1 - } -}; -var maxRadius = 12.0; -var nHBondDistance = 1.04; -var nHCharge = 0.25; -/** - * Populates position vector with location of implicit or explicit H - * Returns position or undefined if not able to locate H - * - * @param {AtomProxy} ap - the nitrogen atom - * @param {Vector3} [position] - optional target - * @return {Vectors|undefined} the hydrogen atom position - */ -function backboneNHPosition(ap, position) { - if ( position === void 0 ) position = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - - var h = false; - var ca = false; - var c = false; - position.set(2 * ap.x, 2 * ap.y, 2 * ap.z); - ap.eachBondedAtom(function (a2) { - // Any time we detect H, reset position and skip - // future tests - if (h) - { return; } - if (a2.atomname === 'H') { - position.set(a2.x, a2.y, a2.z); - h = true; - return; - } - if (!ca && a2.atomname === 'CA') { - position.sub(a2); // TODO - ca = true; - } - else if (!c && a2.atomname === 'C') { - c = true; - position.sub(a2); // TODO - } - }); - if (h) { - return position; - } - if (ca && c) { - position.normalize(); - position.multiplyScalar(nHBondDistance); - position.add(ap); - return position; - } -} -/** - * Takes an array of Vector3 objects and - * converts to an object that looks like an AtomStore - * - * @param {Vector3[]} positions - array of positions - * @return {Object} AtomStore-like object - */ -function buildStoreLike(positions) { - var n = positions.length; - var x = new Float32Array(n); - var y = new Float32Array(n); - var z = new Float32Array(n); - for (var i = 0; i < positions.length; i++) { - var v = positions[i]; - x[i] = v.x; - y[i] = v.y; - z[i] = v.z; - } - return { x: x, y: y, z: z, count: n }; -} -function chargeForAtom(a) { - if (a.partialCharge !== null) - { return a.partialCharge; } - if (!a.isProtein()) { - return 0.0; - } - return ((partialCharges[a.resname] && - partialCharges[a.resname][a.atomname]) || - partialCharges['backbone'][a.atomname] || 0.0); -} -/** - * Color a surface by electrostatic charge. This is a highly approximate - * calculation! The partial charges are CHARMM with hydrogens added to heavy - * atoms and hydrogen positions generated for amides. - * - * __Name:__ _electrostatic_ - * - * @example - * stage.loadFile( "rcsb://3dqb" ).then( function( o ){ - * o.addRepresentation( "surface", { colorScheme: "electrostatic" } ); - * o.autoView(); - * } ); - */ -var ElectrostaticColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ElectrostaticColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - this.delta = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.hCharges = []; - if (!params.scale) { - this.parameters.scale = 'rwb'; - } - if (!params.domain) { - this.parameters.domain = [-50, 50]; - } - this.scale = this.getScale(); - this.charges = new Float32Array(params.structure.atomCount); - var hPositions = []; - params.structure.eachAtom(function (ap) { - this$1.charges[ap.index] = chargeForAtom(ap) * ap.occupancy; - if (ap.atomname === 'N') { - // In the specific case where N forms two bonds to - // CA and C, try and place a dummy hydrogen - if (ap.bondCount >= 3) - { return; } // Skip if 3 bonds already (e.g. PRO) - if (ap.bondToElementCount(1)) - { return; } // Skip if any H specificed - var hPos = backboneNHPosition(ap); - if (hPos !== undefined) { - hPositions.push(hPos); - this$1.hCharges.push(nHCharge * ap.occupancy); - } - } - }); - var bbox = params.structure.getBoundingBox(); - bbox.expandByScalar(nHBondDistance); // Worst case - // SpatialHash requires x,y,z and count - this.hStore = buildStoreLike(hPositions); - this.hHash = new SpatialHash(this.hStore, bbox); // TODO - this.hash = new SpatialHash(params.structure.atomStore, bbox); - } - - if ( Colormaker$$1 ) ElectrostaticColormaker.__proto__ = Colormaker$$1; - ElectrostaticColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ElectrostaticColormaker.prototype.constructor = ElectrostaticColormaker; - ElectrostaticColormaker.prototype.positionColor = function positionColor (v) { - var charges = this.charges; - var hCharges = this.hCharges; - var p = 0.0; - this.hash.eachWithin(v.x, v.y, v.z, maxRadius, function (atomIndex, dSq) { - var charge = charges[atomIndex]; - if (charge === 0.0) - { return; } - p += charge / dSq; - }); - this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, function (atomIndex, dSq) { - var charge = hCharges[atomIndex]; - if (charge === 0.0) - { return; } - p += charge / dSq; - }); - return this.scale(p * 332); // 332 to convert to kcal/mol - }; - - return ElectrostaticColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('electrostatic', ElectrostaticColormaker); - -/** - * @file Element Colormaker - * @author Alexander Rose - * @private - */ -// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF) -var ElementColors = { - 'H': 0xFFFFFF, - 'HE': 0xD9FFFF, - 'LI': 0xCC80FF, - 'BE': 0xC2FF00, - 'B': 0xFFB5B5, - 'C': 0x909090, - 'N': 0x3050F8, - 'O': 0xFF0D0D, - 'F': 0x90E050, - 'NE': 0xB3E3F5, - 'NA': 0xAB5CF2, - 'MG': 0x8AFF00, - 'AL': 0xBFA6A6, - 'SI': 0xF0C8A0, - 'P': 0xFF8000, - 'S': 0xFFFF30, - 'CL': 0x1FF01F, - 'AR': 0x80D1E3, - 'K': 0x8F40D4, - 'CA': 0x3DFF00, - 'SC': 0xE6E6E6, - 'TI': 0xBFC2C7, - 'V': 0xA6A6AB, - 'CR': 0x8A99C7, - 'MN': 0x9C7AC7, - 'FE': 0xE06633, - 'CO': 0xF090A0, - 'NI': 0x50D050, - 'CU': 0xC88033, - 'ZN': 0x7D80B0, - 'GA': 0xC28F8F, - 'GE': 0x668F8F, - 'AS': 0xBD80E3, - 'SE': 0xFFA100, - 'BR': 0xA62929, - 'KR': 0x5CB8D1, - 'RB': 0x702EB0, - 'SR': 0x00FF00, - 'Y': 0x94FFFF, - 'ZR': 0x94E0E0, - 'NB': 0x73C2C9, - 'MO': 0x54B5B5, - 'TC': 0x3B9E9E, - 'RU': 0x248F8F, - 'RH': 0x0A7D8C, - 'PD': 0x006985, - 'AG': 0xC0C0C0, - 'CD': 0xFFD98F, - 'IN': 0xA67573, - 'SN': 0x668080, - 'SB': 0x9E63B5, - 'TE': 0xD47A00, - 'I': 0x940094, - 'XE': 0x940094, - 'CS': 0x57178F, - 'BA': 0x00C900, - 'LA': 0x70D4FF, - 'CE': 0xFFFFC7, - 'PR': 0xD9FFC7, - 'ND': 0xC7FFC7, - 'PM': 0xA3FFC7, - 'SM': 0x8FFFC7, - 'EU': 0x61FFC7, - 'GD': 0x45FFC7, - 'TB': 0x30FFC7, - 'DY': 0x1FFFC7, - 'HO': 0x00FF9C, - 'ER': 0x00E675, - 'TM': 0x00D452, - 'YB': 0x00BF38, - 'LU': 0x00AB24, - 'HF': 0x4DC2FF, - 'TA': 0x4DA6FF, - 'W': 0x2194D6, - 'RE': 0x267DAB, - 'OS': 0x266696, - 'IR': 0x175487, - 'PT': 0xD0D0E0, - 'AU': 0xFFD123, - 'HG': 0xB8B8D0, - 'TL': 0xA6544D, - 'PB': 0x575961, - 'BI': 0x9E4FB5, - 'PO': 0xAB5C00, - 'AT': 0x754F45, - 'RN': 0x428296, - 'FR': 0x420066, - 'RA': 0x007D00, - 'AC': 0x70ABFA, - 'TH': 0x00BAFF, - 'PA': 0x00A1FF, - 'U': 0x008FFF, - 'NP': 0x0080FF, - 'PU': 0x006BFF, - 'AM': 0x545CF2, - 'CM': 0x785CE3, - 'BK': 0x8A4FE3, - 'CF': 0xA136D4, - 'ES': 0xB31FD4, - 'FM': 0xB31FBA, - 'MD': 0xB30DA6, - 'NO': 0xBD0D87, - 'LR': 0xC70066, - 'RF': 0xCC0059, - 'DB': 0xD1004F, - 'SG': 0xD90045, - 'BH': 0xE00038, - 'HS': 0xE6002E, - 'MT': 0xEB0026, - 'DS': 0xFFFFFF, - 'RG': 0xFFFFFF, - 'CN': 0xFFFFFF, - 'UUT': 0xFFFFFF, - 'FL': 0xFFFFFF, - 'UUP': 0xFFFFFF, - 'LV': 0xFFFFFF, - 'UUH': 0xFFFFFF, - 'D': 0xFFFFC0, - 'T': 0xFFFFA0 -}; -var DefaultElementColor = 0xFFFFFF; -/** - * Color by element - */ -var ElementColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ElementColormaker(params) { - params.value = defaults(params.value, ElementColors.C); - Colormaker$$1.call(this, params); - } - - if ( Colormaker$$1 ) ElementColormaker.__proto__ = Colormaker$$1; - ElementColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ElementColormaker.prototype.constructor = ElementColormaker; - ElementColormaker.prototype.atomColor = function atomColor (a) { - var element = a.element; - if (element === 'C') { - return this.parameters.value; - } - else { - return ElementColors[element] || DefaultElementColor; - } - }; - - return ElementColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('element', ElementColormaker); - -/** - * @file Entityindex Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by entity index - */ -var EntityindexColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function EntityindexColormaker(params) { - Colormaker$$1.call(this, params); - if (!params.scale) { - this.parameters.scale = 'Spectral'; - } - if (!params.domain) { - this.parameters.domain = [0, params.structure.entityList.length - 1]; - } - this.entityindexScale = this.getScale(); - } - - if ( Colormaker$$1 ) EntityindexColormaker.__proto__ = Colormaker$$1; - EntityindexColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - EntityindexColormaker.prototype.constructor = EntityindexColormaker; - EntityindexColormaker.prototype.atomColor = function atomColor (a) { - return this.entityindexScale(a.entityIndex); - }; - - return EntityindexColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('entityindex', EntityindexColormaker); - -/** - * @file Entitytype Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by entity type - */ -var EntitytypeColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function EntitytypeColormaker () { - Colormaker$$1.apply(this, arguments); - } - - if ( Colormaker$$1 ) EntitytypeColormaker.__proto__ = Colormaker$$1; - EntitytypeColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - EntitytypeColormaker.prototype.constructor = EntitytypeColormaker; - - EntitytypeColormaker.prototype.atomColor = function atomColor (a) { - var e = a.entity; - var et = e ? e.entityType : undefined; - switch (et) { - case PolymerEntity: - return 0x7fc97f; - case NonPolymerEntity: - return 0xfdc086; - case MacrolideEntity: - return 0xbeaed4; - case WaterEntity: - return 0x386cb0; - default: - return 0xffff99; - } - }; - - return EntitytypeColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('entitytype', EntitytypeColormaker); - -/** - * @file Geoquality Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by validation gometry quality - */ -var GeoqualityColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function GeoqualityColormaker(params) { - Colormaker$$1.call(this, params); - this.geoAtomDict = {}; - this.geoDict = {}; - var val = params.structure.validation; - if (val) { - this.geoAtomDict = val.geoAtomDict; - this.geoDict = val.geoDict; - } - } - - if ( Colormaker$$1 ) GeoqualityColormaker.__proto__ = Colormaker$$1; - GeoqualityColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - GeoqualityColormaker.prototype.constructor = GeoqualityColormaker; - GeoqualityColormaker.prototype.atomColor = function atomColor (atom) { - var sele = atom.resno + ''; - if (atom.inscode) - { sele += '^' + atom.inscode; } - if (atom.chainname) - { sele += ':' + atom.chainname; } - sele += '/' + atom.modelIndex; - var geoProblemCount; - var geoAtom = this.geoAtomDict[sele]; - if (geoAtom !== undefined) { - var atomProblems = geoAtom[atom.atomname] || 0; - geoProblemCount = countSetBits(atomProblems); - } - else { - geoProblemCount = this.geoDict[sele] || 0; - } - if (geoProblemCount === 0) { - return 0x2166ac; - } - else if (geoProblemCount === 1) { - return 0xfee08b; - } - else if (geoProblemCount === 2) { - return 0xf46d43; - } - else if (geoProblemCount >= 3) { - return 0xa50026; - } - return 0x909090; - }; - - return GeoqualityColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('geoquality', GeoqualityColormaker); - -/** - * @file Hydrophobicity Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by hydrophobicity - */ -var HydrophobicityColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function HydrophobicityColormaker(params) { - Colormaker$$1.call(this, params); - this.resHF = {}; - if (!params.scale) { - this.parameters.scale = 'RdYlGn'; - } - var idx = 0; // 0: DGwif, 1: DGwoct, 2: Oct-IF - for (var name in ResidueHydrophobicity) { - this.resHF[name] = ResidueHydrophobicity[name][idx]; - } - this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]; - if (!params.domain) { - var min = Infinity; - var max = -Infinity; - for (var name$1 in this.resHF) { - var val = this.resHF[name$1]; - min = Math.min(min, val); - max = Math.max(max, val); - } - this.parameters.domain = [min, 0, max]; - } - this.hfScale = this.getScale(); - } - - if ( Colormaker$$1 ) HydrophobicityColormaker.__proto__ = Colormaker$$1; - HydrophobicityColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - HydrophobicityColormaker.prototype.constructor = HydrophobicityColormaker; - HydrophobicityColormaker.prototype.atomColor = function atomColor (a) { - return this.hfScale(this.resHF[a.resname] || this.defaultResidueHydrophobicity); - }; - - return HydrophobicityColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('hydrophobicity', HydrophobicityColormaker); - -/** - * @file Modelindex Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by model index - */ -var ModelindexColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ModelindexColormaker(params) { - Colormaker$$1.call(this, params); - if (!params.scale) { - this.parameters.scale = 'rainbow'; - } - if (!params.domain) { - this.parameters.domain = [0, params.structure.modelStore.count]; - } - this.modelindexScale = this.getScale(); - } - - if ( Colormaker$$1 ) ModelindexColormaker.__proto__ = Colormaker$$1; - ModelindexColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ModelindexColormaker.prototype.constructor = ModelindexColormaker; - ModelindexColormaker.prototype.atomColor = function atomColor (a) { - return this.modelindexScale(a.modelIndex); - }; - - return ModelindexColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('modelindex', ModelindexColormaker); - -/** - * @file Moleculetype Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by molecule type - */ -var MoleculetypeColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function MoleculetypeColormaker () { - Colormaker$$1.apply(this, arguments); - } - - if ( Colormaker$$1 ) MoleculetypeColormaker.__proto__ = Colormaker$$1; - MoleculetypeColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - MoleculetypeColormaker.prototype.constructor = MoleculetypeColormaker; - - MoleculetypeColormaker.prototype.atomColor = function atomColor (a) { - switch (a.residueType.moleculeType) { - case WaterType: - return 0x386cb0; - case IonType: - return 0xf0027f; - case ProteinType: - return 0xbeaed4; - case RnaType: - return 0xfdc086; - case DnaType: - return 0xbf5b17; - case SaccharideType: - return 0x7fc97f; - default: - return 0xffff99; - } - }; - - return MoleculetypeColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('moleculetype', MoleculetypeColormaker); - -/** - * @file Occupancy Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by occupancy - */ -var OccupancyColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function OccupancyColormaker(params) { - Colormaker$$1.call(this, params); - if (!params.scale) { - this.parameters.scale = 'PuBu'; - } - if (!params.domain) { - this.parameters.domain = [0.0, 1.0]; - } - this.occupancyScale = this.getScale(); - } - - if ( Colormaker$$1 ) OccupancyColormaker.__proto__ = Colormaker$$1; - OccupancyColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - OccupancyColormaker.prototype.constructor = OccupancyColormaker; - OccupancyColormaker.prototype.atomColor = function atomColor (a) { - return this.occupancyScale(a.occupancy); - }; - - return OccupancyColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('occupancy', OccupancyColormaker); - -/** - * @file Partialcharge Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring. - * The default domain is [-1, 1]. - * - * __Name:__ _partialCharge_ - * - * @example - * stage.loadFile("rcsb://1crn").then(function (o) { - * o.addRepresentation("ball+stick", {colorScheme: "partialCharge"}); - * o.autoView(); - * }); - */ -var PartialchargeColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function PartialchargeColormaker(params) { - Colormaker$$1.call(this, params); - if (!params.scale) { - this.parameters.scale = 'rwb'; - } - if (!params.domain) { - this.parameters.domain = [-1, 1]; - } - this.partialchargeScale = this.getScale(); - } - - if ( Colormaker$$1 ) PartialchargeColormaker.__proto__ = Colormaker$$1; - PartialchargeColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - PartialchargeColormaker.prototype.constructor = PartialchargeColormaker; - PartialchargeColormaker.prototype.atomColor = function atomColor (a) { - return this.partialchargeScale(a.partialCharge || 0); - }; - - return PartialchargeColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('partialcharge', PartialchargeColormaker); - -/** - * @file Random Colormaker - * @author Alexander Rose - * @private - */ -function randomColor() { - return Math.random() * 0xFFFFFF; -} -/** - * Class by random color - */ -var RandomColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function RandomColormaker () { - Colormaker$$1.apply(this, arguments); - } - - if ( Colormaker$$1 ) RandomColormaker.__proto__ = Colormaker$$1; - RandomColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - RandomColormaker.prototype.constructor = RandomColormaker; - - RandomColormaker.prototype.atomColor = function atomColor () { - return randomColor(); - }; - /** - * get color for volume cell - * @return {Integer} random hex color - */ - RandomColormaker.prototype.volumeColor = function volumeColor () { - return randomColor(); - }; - /** - * get color for coordinates in space - * @return {Integer} random hex color - */ - RandomColormaker.prototype.positionColor = function positionColor () { - return randomColor(); - }; - - return RandomColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('random', RandomColormaker); - -/** - * @file Randomcoilindex Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by random coil index - */ -var RandomcoilindexColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function RandomcoilindexColormaker(params) { - Colormaker$$1.call(this, params); - this.rciDict = {}; - if (!params.scale) { - this.parameters.scale = 'RdYlBu'; - } - this.rciScale = this.getScale({ domain: [0.6, 0] }); - var val = params.structure.validation; - if (val) - { this.rciDict = val.rciDict; } - } - - if ( Colormaker$$1 ) RandomcoilindexColormaker.__proto__ = Colormaker$$1; - RandomcoilindexColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - RandomcoilindexColormaker.prototype.constructor = RandomcoilindexColormaker; - RandomcoilindexColormaker.prototype.atomColor = function atomColor (atom) { - var sele = "[" + (atom.resname) + "]" + (atom.resno); - if (atom.chainname) - { sele += ':' + atom.chainname; } - var rci = this.rciDict[sele]; - return rci !== undefined ? this.rciScale(rci) : 0x909090; - }; - - return RandomcoilindexColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('randomcoilindex', RandomcoilindexColormaker); - -/** - * @file Residueindex Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by residue index - */ -var ResidueindexColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ResidueindexColormaker(params) { - var this$1 = this; - - Colormaker$$1.call(this, params); - this.scalePerChain = {}; - if (!params.scale) { - this.parameters.scale = 'rainbow'; - this.parameters.reverse = defaults(params.reverse, true); - } - params.structure.eachChain(function (cp) { - this$1.parameters.domain = [cp.residueOffset, cp.residueEnd]; - this$1.scalePerChain[cp.index] = this$1.getScale(); - }); - } - - if ( Colormaker$$1 ) ResidueindexColormaker.__proto__ = Colormaker$$1; - ResidueindexColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ResidueindexColormaker.prototype.constructor = ResidueindexColormaker; - ResidueindexColormaker.prototype.atomColor = function atomColor (a) { - return this.scalePerChain[a.chainIndex](a.residueIndex); - }; - - return ResidueindexColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('residueindex', ResidueindexColormaker); - -/** - * @file Resname Colormaker - * @author Alexander Rose - * @private - */ -// protein colors from Jmol http://jmol.sourceforge.net/jscolors/ -var ResidueColors = { - 'ALA': 0x8CFF8C, - 'ARG': 0x00007C, - 'ASN': 0xFF7C70, - 'ASP': 0xA00042, - 'CYS': 0xFFFF70, - 'GLN': 0xFF4C4C, - 'GLU': 0x660000, - 'GLY': 0xFFFFFF, - 'HIS': 0x7070FF, - 'ILE': 0x004C00, - 'LEU': 0x455E45, - 'LYS': 0x4747B8, - 'MET': 0xB8A042, - 'PHE': 0x534C52, - 'PRO': 0x525252, - 'SER': 0xFF7042, - 'THR': 0xB84C00, - 'TRP': 0x4F4600, - 'TYR': 0x8C704C, - 'VAL': 0xFF8CFF, - 'ASX': 0xFF00FF, - 'GLX': 0xFF00FF, - 'ASH': 0xFF00FF, - 'GLH': 0xFF00FF, - 'A': 0xDC143C, - 'G': 0x32CD32, - 'I': 0x9ACD32, - 'X': 0x7CFC00, - 'C': 0xFFD700, - 'T': 0x4169E1, - 'U': 0x40E0D0, - 'D': 0x008B8B, - 'DA': 0xDC143C, - 'DG': 0x32CD32, - 'DI': 0x9ACD32, - 'DX': 0x7CFC00, - 'DC': 0xFFD700, - 'DT': 0x4169E1, - 'DU': 0x40E0D0, - 'DD': 0x008B8B -}; -var DefaultResidueColor = 0xFF00FF; -/** - * Color by residue name - */ -var ResnameColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ResnameColormaker () { - Colormaker$$1.apply(this, arguments); - } - - if ( Colormaker$$1 ) ResnameColormaker.__proto__ = Colormaker$$1; - ResnameColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ResnameColormaker.prototype.constructor = ResnameColormaker; - - ResnameColormaker.prototype.atomColor = function atomColor (a) { - return ResidueColors[a.resname] || DefaultResidueColor; - }; - - return ResnameColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('resname', ResnameColormaker); - -/** - * @file Sstruc Colormaker - * @author Alexander Rose - * @private - */ -// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely) -var StructureColors = { - 'alphaHelix': 0xFF0080, - 'threeTenHelix': 0xA00080, - 'piHelix': 0x600080, - 'betaStrand': 0xFFC800, - 'betaTurn': 0x6080FF, - 'coil': 0xFFFFFF, - 'dna': 0xAE00FE, - 'rna': 0xFD0162, - 'carbohydrate': 0xA6A6FA -}; -var DefaultStructureColor = 0x808080; -/** - * Color by secondary structure - */ -var SstrucColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function SstrucColormaker(params) { - Colormaker$$1.call(this, params); - this.residueProxy = params.structure.getResidueProxy(); - } - - if ( Colormaker$$1 ) SstrucColormaker.__proto__ = Colormaker$$1; - SstrucColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - SstrucColormaker.prototype.constructor = SstrucColormaker; - SstrucColormaker.prototype.atomColor = function atomColor (ap) { - var sstruc = ap.sstruc; - var rp = this.residueProxy; - if (sstruc === 'h') { - return StructureColors.alphaHelix; - } - else if (sstruc === 'g') { - return StructureColors.threeTenHelix; - } - else if (sstruc === 'i') { - return StructureColors.piHelix; - } - else if (sstruc === 'e' || sstruc === 'b') { - return StructureColors.betaStrand; - } - else if (sstruc === 't') { - return StructureColors.betaTurn; - } - else { - rp.index = ap.residueIndex; - if (rp.isDna()) { - return StructureColors.dna; - } - else if (rp.isRna()) { - return StructureColors.rna; - } - else if (rp.isSaccharide()) { - return StructureColors.carbohydrate; - } - else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') { - return StructureColors.coil; - } - else { - return DefaultStructureColor; - } - } - }; - - return SstrucColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('sstruc', SstrucColormaker); - -/** - * @file Uniform Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by uniform color - */ -var UniformColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function UniformColormaker () { - Colormaker$$1.apply(this, arguments); - } - - if ( Colormaker$$1 ) UniformColormaker.__proto__ = Colormaker$$1; - UniformColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - UniformColormaker.prototype.constructor = UniformColormaker; - - UniformColormaker.prototype.atomColor = function atomColor () { - return this.parameters.value; - }; - UniformColormaker.prototype.bondColor = function bondColor () { - return this.parameters.value; - }; - UniformColormaker.prototype.valueColor = function valueColor () { - return this.parameters.value; - }; - UniformColormaker.prototype.volumeColor = function volumeColor () { - return this.parameters.value; - }; - - return UniformColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('uniform', UniformColormaker); - -/** - * @file Value Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by volume value - */ -var ValueColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function ValueColormaker(params) { - Colormaker$$1.call(this, params); - this.valueScale = this.getScale(); - } - - if ( Colormaker$$1 ) ValueColormaker.__proto__ = Colormaker$$1; - ValueColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - ValueColormaker.prototype.constructor = ValueColormaker; - /** - * return the color for a volume cell - * @param {Integer} index - volume cell index - * @return {Integer} hex cell color - */ - ValueColormaker.prototype.volumeColor = function volumeColor (index) { - return this.valueScale(this.parameters.volume.data[index]); // TODO - }; - - return ValueColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('value', ValueColormaker); - -/** - * @file Volume Colormaker - * @author Alexander Rose - * @private - */ -/** - * Color by volume position - */ -var VolumeColormaker = /*@__PURE__*/(function (Colormaker$$1) { - function VolumeColormaker(params) { - Colormaker$$1.call(this, params); - this.vec = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.valueScale = this.getScale(); - } - - if ( Colormaker$$1 ) VolumeColormaker.__proto__ = Colormaker$$1; - VolumeColormaker.prototype = Object.create( Colormaker$$1 && Colormaker$$1.prototype ); - VolumeColormaker.prototype.constructor = VolumeColormaker; - /** - * return the color for coordinates in space - * @param {Vector3} coords - xyz coordinates - * @return {Integer} hex coords color - */ - VolumeColormaker.prototype.positionColor = function positionColor (coords) { - var volume = this.parameters.volume; // TODO - if (!volume || !volume.inverseMatrix) { - return this.parameters.value; - } - var vec = this.vec; - var data = volume.data; - var nx = volume.nx; - var ny = volume.ny; - var nxy = nx * ny; - vec.copy(coords); - vec.applyMatrix4(volume.inverseMatrix); - // position of grid cell - var x0 = Math.floor(vec.x); - var y0 = Math.floor(vec.y); - var z0 = Math.floor(vec.z); - // Indices - var i = ((((z0 * ny) + y0) * nx) + x0); - var i1 = i + 1; - var iy = i + nx; - var iz = i + nxy; - var i1y = iy + 1; - var i1z = iz + 1; - var iyz = iy + nxy; - var i1yz = iyz + 1; - // Values - var v = data[i]; - var v1 = data[i1]; - var vy = data[iy]; - var vz = data[iz]; - var v1y = data[i1y]; - var v1z = data[i1z]; - var vyz = data[iyz]; - var v1yz = data[i1yz]; - // Position of point in fraction of grid - var xd = vec.x - x0; - var yd = vec.y - y0; - var zd = vec.z - z0; - // 1st Dimension - var c00 = lerp(v, v1, xd); - var c01 = lerp(vz, v1z, xd); - var c10 = lerp(vy, v1y, xd); - var c11 = lerp(vyz, v1yz, xd); - // 2nd Dimension - var c0 = lerp(c00, c10, yd); - var c1 = lerp(c01, c11, yd); - // 3rd Dimension - var c = lerp(c0, c1, zd); - return this.valueScale(c); - }; - - return VolumeColormaker; -}(Colormaker)); -ColormakerRegistry$1.add('volume', VolumeColormaker); - -/** - * @file Structure Representation - * @author Alexander Rose - * @private - */ -/** - * Structure representation - * @interface - */ -var StructureRepresentation = /*@__PURE__*/(function (Representation$$1) { - function StructureRepresentation(structure, viewer, params) { - var p = params || {}; - Representation$$1.call(this, structure, viewer, p); - this.type = 'structure'; - this.parameters = Object.assign({ - radiusType: { - type: 'select', options: RadiusFactory.types - }, - radiusData: { - type: 'hidden' - }, - radiusSize: { - type: 'number', precision: 3, max: 10.0, min: 0.001 - }, - radiusScale: { - type: 'number', precision: 3, max: 10.0, min: 0.001 - }, - assembly: null, - defaultAssembly: { - type: 'hidden' - } - }, this.parameters); - /** - * @type {Selection} - * @private - */ - this.selection = new Selection(p.sele); - /** - * @type {Array} - * @private - */ - this.dataList = []; - /** - * @type {Structure} - */ - this.structure = structure; - /** - * @type {StructureView} - */ - this.structureView = this.structure.getView(this.selection); - if (structure.biomolDict) { - var biomolOptions = { - 'default': 'default', - '': (structure.unitcell ? 'AU' : 'FULL') - }; - Object.keys(structure.biomolDict).forEach(function (k) { - biomolOptions[k] = k; - }); - this.parameters.assembly = { - type: 'select', - options: biomolOptions, - rebuild: true - }; - } - else { - this.parameters.assembly = null; - } - } - - if ( Representation$$1 ) StructureRepresentation.__proto__ = Representation$$1; - StructureRepresentation.prototype = Object.create( Representation$$1 && Representation$$1.prototype ); - StructureRepresentation.prototype.constructor = StructureRepresentation; - - var prototypeAccessors = { defaultScale: { configurable: true } }; - prototypeAccessors.defaultScale.get = function () { - return { - 'vdw': 1.0, - 'covalent': 1.0, - 'bfactor': 0.01, - 'sstruc': 1.0 - }; - }; - StructureRepresentation.prototype.init = function init (params) { - var this$1 = this; - - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'element'); - this.setRadius(p.radius, p); - this.radiusType = defaults(p.radiusType, 'vdw'); - this.radiusData = defaults(p.radiusData, {}); - this.radiusSize = defaults(p.radiusSize, 1.0); - this.radiusScale = defaults(p.radiusScale, 1.0); - this.assembly = defaults(p.assembly, 'default'); - this.defaultAssembly = defaults(p.defaultAssembly, ''); - if (p.quality === 'auto') { - p.quality = this.getQuality(); - } - Representation$$1.prototype.init.call(this, p); - this.selection.signals.stringChanged.add(function ( /* sele */) { - this$1.build(); - }); - this.build(); - }; - StructureRepresentation.prototype.setRadius = function setRadius (value, p) { - var types = Object.keys(RadiusFactoryTypes); - if (typeof value === 'string' && types.includes(value.toLowerCase())) { - p.radiusType = value; - } - else if (value !== undefined) { - p.radiusType = 'size'; - p.radiusSize = value; - } - return this; - }; - StructureRepresentation.prototype.getAssembly = function getAssembly () { - var name = this.assembly === 'default' ? this.defaultAssembly : this.assembly; - return this.structure.biomolDict[name]; - }; - StructureRepresentation.prototype.getQuality = function getQuality () { - var atomCount; - var s = this.structureView; - var assembly = this.getAssembly(); - if (assembly) { - atomCount = assembly.getAtomCount(s); - } - else { - atomCount = s.atomCount; - } - if (Mobile) { - atomCount *= 4; - } - var backboneOnly = s.atomStore.count / s.residueStore.count < 2; - if (backboneOnly) { - atomCount *= 10; - } - if (atomCount < 15000) { - return 'high'; - } - else if (atomCount < 80000) { - return 'medium'; - } - else { - return 'low'; - } - }; - StructureRepresentation.prototype.create = function create () { - var this$1 = this; - - if (this.structureView.atomCount === 0) - { return; } - if (!this.structureView.hasCoords()) { - this.needsBuild = true; - return; - } - else { - this.needsBuild = false; - } - var assembly = this.getAssembly(); - if (assembly) { - assembly.partList.forEach(function (part, i) { - var sview = part.getView(this$1.structureView); - if (sview.atomCount === 0) - { return; } - var data = this$1.createData(sview, i); - if (data) { - data.sview = sview; - data.instanceList = part.getInstanceList(); - this$1.dataList.push(data); - } - }); - } - else { - var data = this.createData(this.structureView, 0); - if (data) { - data.sview = this.structureView; - this.dataList.push(data); - } - } - }; - StructureRepresentation.prototype.update = function update (what) { - var this$1 = this; - - if (this.lazy && !this.visible) { - Object.assign(this.lazyProps.what, what); - return; - } - if (this.needsBuild) { - this.build(); - return; - } - this.dataList.forEach(function (data) { - if (data.bufferList.length > 0) { - this$1.updateData(what, data); - } - }, this); - }; - StructureRepresentation.prototype.updateData = function updateData (what, data) { - this.build(); - }; - StructureRepresentation.prototype.getColorParams = function getColorParams () { - return Object.assign(Object.assign({}, Representation$$1.prototype.getColorParams.call(this)), { structure: this.structure }); - }; - StructureRepresentation.prototype.getRadiusParams = function getRadiusParams (param) { - return { - type: this.radiusType, - scale: this.radiusScale, - size: this.radiusSize, - data: this.radiusData - }; - }; - StructureRepresentation.prototype.getAtomParams = function getAtomParams (what, params) { - return Object.assign({ - what: what, - colorParams: this.getColorParams(), - radiusParams: this.getRadiusParams() - }, params); - }; - StructureRepresentation.prototype.getBondParams = function getBondParams (what, params) { - return Object.assign({ - what: what, - colorParams: this.getColorParams(), - radiusParams: this.getRadiusParams() - }, params); - }; - StructureRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - if (this.structureView.atomSet.isSet(atom.index)) { - var radiusFactory = new RadiusFactory(this.getRadiusParams()); - return radiusFactory.atomRadius(atom); - } - return 0; - }; - /** - * Set representation parameters - * @alias StructureRepresentation#setSelection - * @param {String} string - selection string, see {@tutorial selection-language} - * @param {Boolean} [silent] - don't trigger a change event in the selection - * @return {StructureRepresentation} this object - */ - StructureRepresentation.prototype.setSelection = function setSelection (string, silent) { - this.selection.setString(string, silent); - return this; - }; - /** - * Set representation parameters - * @alias StructureRepresentation#setParameters - * @param {StructureRepresentationParameters} params - structure parameter object - * @param {Object} [what] - buffer data attributes to be updated, - * note that this needs to be implemented in the - * derived classes. Generally it allows more - * fine-grained control over updating than - * forcing a rebuild. - * @param {Boolean} what.position - update position data - * @param {Boolean} what.color - update color data - * @param {Boolean} [rebuild] - whether or not to rebuild the representation - * @return {StructureRepresentation} this object - */ - StructureRepresentation.prototype.setParameters = function setParameters (params, what, rebuild) { - if ( what === void 0 ) what = {}; - if ( rebuild === void 0 ) rebuild = false; - - var p = params || {}; - this.setRadius(p.radius, p); - if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) { - what.radius = true; - if (!ExtensionFragDepth || this.disableImpostor) { - rebuild = true; - } - } - if (p.defaultAssembly !== undefined && - p.defaultAssembly !== this.defaultAssembly && - ((this.assembly === 'default' && p.assembly === undefined) || - p.assembly === 'default')) { - rebuild = true; - } - Representation$$1.prototype.setParameters.call(this, p, what, rebuild); - return this; - }; - StructureRepresentation.prototype.getParameters = function getParameters () { - var params = Object.assign(Representation$$1.prototype.getParameters.call(this), { - sele: this.selection ? this.selection.string : undefined, - defaultAssembly: this.defaultAssembly - }); - return params; - }; - StructureRepresentation.prototype.attach = function attach (callback) { - var viewer = this.viewer; - var bufferList = this.bufferList; - this.dataList.forEach(function (data) { - data.bufferList.forEach(function (buffer) { - bufferList.push(buffer); - viewer.add(buffer, data.instanceList); - }); - }); - this.setVisibility(this.visible); - callback(); - }; - StructureRepresentation.prototype.clear = function clear () { - this.dataList.length = 0; - Representation$$1.prototype.clear.call(this); - }; - StructureRepresentation.prototype.dispose = function dispose () { - this.structureView.dispose(); - delete this.structure; - delete this.structureView; - Representation$$1.prototype.dispose.call(this); - }; - - Object.defineProperties( StructureRepresentation.prototype, prototypeAccessors ); - - return StructureRepresentation; -}(Representation)); - -/** - * @file Measurement Representation - * @author Fred Ludlow - * @private - */ -/** - * Measurement representation - * @interface - */ -var MeasurementRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function MeasurementRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.n = 0; // Subclass create sets value - this.parameters = Object.assign({ - labelVisible: { - type: 'boolean' - }, - labelSize: { - type: 'number', precision: 3, max: 10.0, min: 0.001 - }, - labelColor: { - type: 'color' - }, - labelFontFamily: { - type: 'select', - options: { - 'sans-serif': 'sans-serif', - 'monospace': 'monospace', - 'serif': 'serif' - }, - buffer: 'fontFamily' - }, - labelFontStyle: { - type: 'select', - options: { - 'normal': 'normal', - 'italic': 'italic' - }, - buffer: 'fontStyle' - }, - labelFontWeight: { - type: 'select', - options: { - 'normal': 'normal', - 'bold': 'bold' - }, - buffer: 'fontWeight' - }, - labelsdf: { - type: 'boolean', buffer: 'sdf' - }, - labelXOffset: { - type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset' - }, - labelYOffset: { - type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset' - }, - labelZOffset: { - type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset' - }, - labelAttachment: { - type: 'select', - options: { - 'bottom-left': 'bottom-left', - 'bottom-center': 'bottom-center', - 'bottom-right': 'bottom-right', - 'middle-left': 'middle-left', - 'middle-center': 'middle-center', - 'middle-right': 'middle-right', - 'top-left': 'top-left', - 'top-center': 'top-center', - 'top-right': 'top-right' - }, - rebuild: true - }, - labelBorder: { - type: 'boolean', buffer: 'showBorder' - }, - labelBorderColor: { - type: 'color', buffer: 'borderColor' - }, - labelBorderWidth: { - type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth' - }, - labelBackground: { - type: 'boolean', rebuild: true - }, - labelBackgroundColor: { - type: 'color', buffer: 'backgroundColor' - }, - labelBackgroundMargin: { - type: 'number', precision: 2, max: 2, min: 0, rebuild: true - }, - labelBackgroundOpacity: { - type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity' - }, - labelFixedSize: { - type: 'boolean', buffer: 'fixedSize' - }, - lineOpacity: { - type: 'range', min: 0.0, max: 1.0, step: 0.01 - }, - linewidth: { - type: 'integer', max: 50, min: 1, buffer: true - } - }, this.parameters, { - flatShaded: null - }); - } - - if ( StructureRepresentation$$1 ) MeasurementRepresentation.__proto__ = StructureRepresentation$$1; - MeasurementRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - MeasurementRepresentation.prototype.constructor = MeasurementRepresentation; - MeasurementRepresentation.prototype.init = function init (params) { - var p = params || {}; - this.labelVisible = defaults(p.labelVisible, true); - this.labelSize = defaults(p.labelSize, 2.0); - this.labelColor = defaults(p.labelColor, 0xFFFFFF); - this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif'); - this.labelFontStyle = defaults(p.labelFontstyle, 'normal'); - this.labelFontWeight = defaults(p.labelFontWeight, 'bold'); - this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome'); - this.labelXOffset = defaults(p.labelXOffset, 0.0); - this.labelYOffset = defaults(p.labelYOffset, 0.0); - this.labelZOffset = defaults(p.labelZOffset, 0.5); - this.labelAttachment = defaults(p.labelAttachment, 'bottom-left'); - this.labelBorder = defaults(p.labelBorder, false); - this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey'); - this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15); - this.labelBackground = defaults(p.labelBackground, false); - this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey'); - this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5); - this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0); - this.labelFixedSize = defaults(p.labelFixedSize, false); - this.lineOpacity = defaults(p.lineOpacity, 1.0); - this.linewidth = defaults(p.linewidth, 2); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - // All measurements need to rebuild on position change - MeasurementRepresentation.prototype.update = function update (what) { - if (what.position) { - this.build(); - } - else { - StructureRepresentation$$1.prototype.update.call(this, what); - } - }; - MeasurementRepresentation.prototype.updateData = function updateData (what, data) { - var textData = {}; - if (!what || what.labelSize) { - Object.assign(textData, { size: uniformArray(this.n, this.labelSize) }); - } - if (!what || what.labelColor) { - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.labelColor); - Object.assign(textData, { color: uniformArray3(this.n, c.r, c.g, c.b) }); - } - this.textBuffer.setAttributes(textData); - }; - MeasurementRepresentation.prototype.setParameters = function setParameters (params, what, rebuild) { - if ( what === void 0 ) what = {}; - if ( rebuild === void 0 ) rebuild = false; - - if (params && params.labelSize) { - what.labelSize = true; - } - if (params && (params.labelColor || params.labelColor === 0x000000)) { - what.labelColor = true; - rebuild = true; - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - if (params && params.opacity !== undefined) { - this.textBuffer.setParameters({ opacity: 1.0 }); // only opaque labels - } - if (params && params.labelVisible !== undefined) { - this.setVisibility(this.visible); - } - return this; - }; - MeasurementRepresentation.prototype.setVisibility = function setVisibility (value, noRenderRequest) { - StructureRepresentation$$1.prototype.setVisibility.call(this, value, true); - if (this.textBuffer) { - this.textBuffer.setVisibility(this.labelVisible && this.visible); - } - if (!noRenderRequest) - { this.viewer.requestRender(); } - return this; - }; - MeasurementRepresentation.prototype.getLabelBufferParams = function getLabelBufferParams (params) { - if ( params === void 0 ) params = {}; - - return StructureRepresentation$$1.prototype.getBufferParams.call(this, Object.assign({ - fontFamily: this.labelFontFamily, - fontStyle: this.labelFontStyle, - fontWeight: this.labelFontWeight, - sdf: this.labelsdf, - xOffset: this.labelXOffset, - yOffset: this.labelYOffset, - zOffset: this.labelZOffset, - attachment: this.labelAttachment, - showBorder: this.labelBorder, - borderColor: this.labelBorderColor, - borderWidth: this.labelBorderWidth, - showBackground: this.labelBackground, - backgroundColor: this.labelBackgroundColor, - backgroundMargin: this.labelBackgroundMargin, - backgroundOpacity: this.labelBackgroundOpacity, - fixedSize: this.labelFixedSize, - disablePicking: true, - visible: this.labelVisible - }, params, { - opacity: 1.0 // only opaque labels - })); - }; - MeasurementRepresentation.prototype.getAtomRadius = function getAtomRadius () { - return 0; - }; - - return MeasurementRepresentation; -}(StructureRepresentation)); -/** - * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters. - * - * Parses nested array of either integer atom indices or selection - * expressions into a flat array of coordinates. - * - * @param {Structure} sview The structure to which the atoms refer - * @param {Array} atoms Nested array of atom pairs|triples|quads as - * Integer indices or selection expressions - * @return {Float32Array} Flattened array of position coordinates - */ -function parseNestedAtoms(sview, atoms) { - var ap = sview.getAtomProxy(); - var sele = new Selection(); - var nSets = atoms.length; - if (nSets === 0) - { return new Float32Array(0); } - // Peek-ahead at first item to determine order and parse mode - var order = atoms[0].length; - var selected = sview.getAtomSet(); - var a = new Float32Array(nSets * order * 3); - var p = 0; - atoms.forEach(function (group) { - var _break = false; - for (var j = 0; j < order; j++) { - var value = group[j]; - if (typeof (value) === 'number' && Number.isInteger(value)) { - if (selected.get(value)) { - ap.index = value; - } - else { - _break = true; - break; - } - } - else { - sele.setString(value); - var atomIndices = sview.getAtomIndices(sele); - if (atomIndices.length) { - ap.index = atomIndices[0]; - } - else { - _break = true; - break; - } - } - var offset = p + j * 3; - a[offset++] = ap.x; - a[offset++] = ap.y; - a[offset++] = ap.z; - } - if (!_break) - { p += 3 * order; } - }); - return a.subarray(0, p); -} -/* out = v1 * cos(angle) + v2 * sin(angle) */ -function calcArcPoint(out, center, v1, v2, angle) { - var x = Math.cos(angle); - var y = Math.sin(angle); - out[0] = center[0] + v1[0] * x + v2[0] * y; - out[1] = center[1] + v1[1] * x + v2[1] * y; - out[2] = center[2] + v1[2] * x + v2[2] * y; -} - -ShaderRegistry.add('shader/SDFFont.vert', "uniform float clipNear;\nuniform float clipRadius;\nuniform vec3 clipCenter;\nuniform float xOffset;\nuniform float yOffset;\nuniform float zOffset;\nuniform bool ortho;\nuniform float canvasHeight;\nuniform float pixelRatio;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvarying vec3 vViewPosition;\n#endif\nvarying vec2 texCoord;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#endif\nattribute vec2 mapping;\nattribute vec2 inputTexCoord;\nattribute float inputSize;\n#include matrix_scale\n#include common\nvoid main(void){\n#if defined( PICKING )\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#endif\ntexCoord = inputTexCoord;\nfloat scale = matrixScale( modelViewMatrix );\nfloat _xOffset = xOffset * scale;\nfloat _yOffset = yOffset * scale;\nfloat _zOffset = zOffset * scale;\nif( texCoord.x == 10.0 ){\n_zOffset -= 0.001;\n}\nvec4 cameraPos = modelViewMatrix * vec4( position, 1.0 );\n#ifdef FIXED_SIZE\nif ( ortho ) {\nscale /= pixelRatio * (( canvasHeight / 2.0 ) / -cameraPosition.z) * 0.1;\n} else {\nscale /= pixelRatio * (( canvasHeight / 2.0 ) / -cameraPos.z) * 0.1;\n}\n#endif\nvec4 cameraCornerPos = vec4( cameraPos.xyz, 1.0 );\ncameraCornerPos.xy += mapping * inputSize * 0.01 * scale;\ncameraCornerPos.x += _xOffset;\ncameraCornerPos.y += _yOffset;\nif( ortho ){\ncameraCornerPos.xyz += normalize( -cameraPosition ) * _zOffset;\n} else {\ncameraCornerPos.xyz += normalize( -cameraCornerPos.xyz ) * _zOffset;\n}\ngl_Position = projectionMatrix * cameraCornerPos;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || ( !defined( PICKING ) && !defined( NOLIGHT ) )\nvViewPosition = -cameraCornerPos.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n#include radiusclip_vertex\n}"); - -ShaderRegistry.add('shader/SDFFont.frag', "uniform sampler2D fontTexture;\nuniform float opacity;\nuniform bool showBorder;\nuniform vec3 borderColor;\nuniform float borderWidth;\nuniform vec3 backgroundColor;\nuniform float backgroundOpacity;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\nvarying vec2 texCoord;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform float objectId;\nvarying vec3 vPickingColor;\nconst vec3 vColor = vec3( 0.0 );\n#else\n#include common\n#include color_pars_fragment\n#include fog_pars_fragment\n#endif\nconst float gamma = 2.2 * 1.4142 / 128.0;\nconst float padding = 0.75;\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\nif( texCoord.x > 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}"); - -/** - * @file Edt - * @author Alexander Rose - * @private - */ -// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf -function edt(data, width, height, f, d, v, z) { - for (var x = 0; x < width; x++) { - for (var y = 0; y < height; y++) { - f[y] = data[y * width + x]; - } - edt1d(f, d, v, z, height); - for (var y$1 = 0; y$1 < height; y$1++) { - data[y$1 * width + x] = d[y$1]; - } - } - for (var y$2 = 0; y$2 < height; y$2++) { - for (var x$1 = 0; x$1 < width; x$1++) { - f[x$1] = data[y$2 * width + x$1]; - } - edt1d(f, d, v, z, width); - for (var x$2 = 0; x$2 < width; x$2++) { - data[y$2 * width + x$2] = Math.sqrt(d[x$2]); - } - } -} -// 1D squared distance transform -function edt1d(f, d, v, z, n) { - v[0] = 0; - z[0] = Number.MIN_SAFE_INTEGER; - z[1] = Number.MAX_SAFE_INTEGER; - for (var q = 1, k = 0; q < n; q++) { - var s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k]); - while (s <= z[k]) { - k--; - s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k]); - } - k++; - v[k] = q; - z[k] = s; - z[k + 1] = Number.MAX_SAFE_INTEGER; - } - for (var q$1 = 0, k$1 = 0; q$1 < n; q$1++) { - while (z[k$1 + 1] < q$1) - { k$1++; } - d[q$1] = (q$1 - v[k$1]) * (q$1 - v[k$1]) + f[v[k$1]]; - } -} - -/** - * @file Text Buffer - * @author Alexander Rose - * @private - */ -var TextAtlasCache = {}; -function getTextAtlas(params) { - var hash = JSON.stringify(params); - if (TextAtlasCache[hash] === undefined) { - TextAtlasCache[hash] = new TextAtlas(params); - } - return TextAtlasCache[hash]; -} -var TextAtlasDefaultParams = { - font: 'sans-serif', - size: 36, - style: 'normal', - variant: 'normal', - weight: 'normal', - outline: 3, - width: 1024, - height: 1024 -}; -var TextAtlas = function TextAtlas(params) { - if ( params === void 0 ) params = {}; - - this.gamma = 1; - this.mapped = {}; - this.scratchW = 0; - this.scratchH = 0; - this.currentX = 0; - this.currentY = 0; - this.cutoff = 0.25; - this.parameters = createParams(params, TextAtlasDefaultParams); - var p = this.parameters; - this.radius = p.size / 8; - this.padding = p.size / 3; - // Prepare line-height with room for outline and descenders/ascenders - var lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4); - var maxWidth = this.maxWidth = p.width / 4; - // Prepare scratch canvas - var canvas = this.canvas = document.createElement('canvas'); - canvas.width = maxWidth; - canvas.height = lineHeight; - var ctx = this.context = this.canvas.getContext('2d'); - ctx.font = (p.style) + " " + (p.variant) + " " + (p.weight) + " " + (p.size) + "px " + (p.font); - ctx.fillStyle = 'black'; - ctx.textAlign = 'left'; - ctx.textBaseline = 'bottom'; - ctx.lineJoin = 'round'; - // temporary arrays for the distance transform - this.gridOuter = new Float64Array(lineHeight * maxWidth); - this.gridInner = new Float64Array(lineHeight * maxWidth); - this.f = new Float64Array(Math.max(lineHeight, maxWidth)); - this.d = new Float64Array(Math.max(lineHeight, maxWidth)); - this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1); - this.v = new Int16Array(Math.max(lineHeight, maxWidth)); - // - this.data = new Uint8Array(p.width * p.height * 4); - this.canvas2 = document.createElement('canvas'); - this.canvas2.width = p.width; - this.canvas2.height = p.height; - this.context2 = this.canvas2.getContext('2d'); - // Replacement Character - this.placeholder = this.map(String.fromCharCode(0xFFFD)); - // Basic Latin (subset) - for (var i = 0x0020; i <= 0x007E; ++i) { - this.map(String.fromCharCode(i)); - } - // TODO: to slow to always prepare them - // // Latin-1 Supplement (subset) - // for (let i = 0x00A1; i <= 0x00FF; ++i) { - // this.map(String.fromCharCode(i)) - // } - // Degree sign - this.map(String.fromCharCode(0x00B0)); - // // Greek and Coptic (subset) - // for (let i = 0x0391; i <= 0x03C9; ++i) { - // this.map(String.fromCharCode(i)) - // } - // // Cyrillic (subset) - // for (let i = 0x0400; i <= 0x044F; ++i) { - // this.map(String.fromCharCode(i)) - // } - // Angstrom Sign - this.map(String.fromCharCode(0x212B)); - this.texture = new __WEBPACK_IMPORTED_MODULE_0_three__["h" /* CanvasTexture */](this.canvas2); - this.texture.flipY = false; - this.texture.needsUpdate = true; -}; -TextAtlas.prototype.map = function map (text) { - var p = this.parameters; - if (this.mapped[text] === undefined) { - this.draw(text); - if (this.currentX + this.scratchW > p.width) { - this.currentX = 0; - this.currentY += this.scratchH; - } - if (this.currentY + this.scratchH > p.height) { - console.warn('canvas to small'); - } - this.mapped[text] = { - x: this.currentX, - y: this.currentY, - w: this.scratchW, - h: this.scratchH - }; - this.context2.drawImage(this.canvas, 0, 0, this.scratchW, this.scratchH, this.currentX, this.currentY, this.scratchW, this.scratchH); - this.currentX += this.scratchW; - } - return this.mapped[text]; -}; -TextAtlas.prototype.get = function get (text) { - return this.mapped[text] || this.placeholder; -}; -TextAtlas.prototype.draw = function draw (text) { - var p = this.parameters; - var h = this.lineHeight; - var o = p.outline; - var ctx = this.context; - // const dst = this.scratch - var max = this.maxWidth; - // const colors = this.colors - // Bottom aligned, take outline into account - var x = o; - var y = h - p.outline; - // Measure text - var m = ctx.measureText(text); - var w = Math.min(max, Math.ceil(m.width + 2 * x + 1)); - var n = w * h; - // Clear scratch area - ctx.clearRect(0, 0, w, h); - // Draw text - ctx.fillText(text, x, y); - var imageData = ctx.getImageData(0, 0, w, h); - var data = imageData.data; - for (var i = 0; i < n; i++) { - var a = imageData.data[i * 4 + 3] / 255; // alpha value - this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2); - this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2); - } - edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z); - edt(this.gridInner, w, h, this.f, this.d, this.v, this.z); - for (var i$1 = 0; i$1 < n; i$1++) { - var d = this.gridOuter[i$1] - this.gridInner[i$1]; - data[i$1 * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff)))); - } - ctx.putImageData(imageData, 0, 0); - this.scratchW = w; - this.scratchH = h; -}; -var TextBufferDefaultParameters = Object.assign({ - fontFamily: 'sans-serif', - fontStyle: 'normal', - fontWeight: 'bold', - fontSize: 36, - xOffset: 0.0, - yOffset: 0.0, - zOffset: 0.5, - attachment: 'bottom-left', - showBorder: false, - borderColor: 'lightgrey', - borderWidth: 0.15, - showBackground: false, - backgroundColor: 'lightgrey', - backgroundMargin: 0.5, - backgroundOpacity: 1.0, - forceTransparent: true, - fixedSize: false -}, BufferDefaultParameters); -var TextBufferParameterTypes = Object.assign({ - fontFamily: { uniform: true }, - fontStyle: { uniform: true }, - fontWeight: { uniform: true }, - fontSize: { uniform: true }, - xOffset: { uniform: true }, - yOffset: { uniform: true }, - zOffset: { uniform: true }, - showBorder: { uniform: true }, - borderColor: { uniform: true }, - borderWidth: { uniform: true }, - backgroundColor: { uniform: true }, - backgroundOpacity: { uniform: true }, - fixedSize: { updateShader: true } -}, BufferParameterTypes); -function getCharCount(data, params) { - var n = data.position.length / 3; - var charCount = 0; - for (var i = 0; i < n; ++i) { - charCount += data.text[i].length; - } - if (params.showBackground) - { charCount += n; } - return charCount; -} -/** - * Text buffer. Renders screen-aligned text strings. - * - * @example - * var textBuffer = new TextBuffer({ - * position: new Float32Array([ 0, 0, 0 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * size: new Float32Array([ 2 ]), - * text: [ "Hello" ] - * }); - */ -var TextBuffer = /*@__PURE__*/(function (MappedQuadBuffer$$1) { - function TextBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedQuadBuffer$$1.call(this, { - position: new Float32Array(getCharCount(data, params) * 3), - color: new Float32Array(getCharCount(data, params) * 3), - picking: new IgnorePicker() - }, params); - this.parameterTypes = TextBufferParameterTypes; - this.alwaysTransparent = true; - this.hasWireframe = false; - this.isText = true; - this.vertexShader = 'SDFFont.vert'; - this.fragmentShader = 'SDFFont.frag'; - this.text = data.text; - this.positionCount = data.position.length / 3; - this.addUniforms({ - 'fontTexture': { value: null }, - 'xOffset': { value: this.parameters.xOffset }, - 'yOffset': { value: this.parameters.yOffset }, - 'zOffset': { value: this.parameters.zOffset }, - 'ortho': { value: false }, - 'showBorder': { value: this.parameters.showBorder }, - 'borderColor': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.parameters.borderColor) }, - 'borderWidth': { value: this.parameters.borderWidth }, - 'backgroundColor': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.parameters.backgroundColor) }, - 'backgroundOpacity': { value: this.parameters.backgroundOpacity }, - 'canvasHeight': { value: 1.0 }, - 'pixelRatio': { value: 1.0 } - }); - this.addAttributes({ - 'inputTexCoord': { type: 'v2', value: null }, - 'inputSize': { type: 'f', value: null } - }); - this.setAttributes(data); - this.makeTexture(); - this.makeMapping(); - } - - if ( MappedQuadBuffer$$1 ) TextBuffer.__proto__ = MappedQuadBuffer$$1; - TextBuffer.prototype = Object.create( MappedQuadBuffer$$1 && MappedQuadBuffer$$1.prototype ); - TextBuffer.prototype.constructor = TextBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return TextBufferDefaultParameters; }; - TextBuffer.prototype.makeMaterial = function makeMaterial () { - MappedQuadBuffer$$1.prototype.makeMaterial.call(this); - var tex = this.texture; - var m = this.material; - m.transparent = true; - m.extensions.derivatives = true; - m.lights = false; - m.uniforms.fontTexture.value = tex; - m.needsUpdate = true; - var wm = this.wireframeMaterial; - wm.transparent = true; - wm.extensions.derivatives = true; - wm.lights = false; - wm.uniforms.fontTexture.value = tex; - wm.needsUpdate = true; - var pm = this.pickingMaterial; - pm.extensions.derivatives = true; - pm.lights = false; - pm.uniforms.fontTexture.value = tex; - pm.needsUpdate = true; - }; - TextBuffer.prototype.setAttributes = function setAttributes (data) { - if ( data === void 0 ) data = {}; - - var position, size, color; - var aPosition, inputSize, aColor; - var text = this.text; - var attributes = this.geometry.attributes; // TODO - if (data.position) { - position = data.position; - aPosition = attributes.position.array; - attributes.position.needsUpdate = true; - } - if (data.size) { - size = data.size; - inputSize = attributes.inputSize.array; - attributes.inputSize.needsUpdate = true; - } - if (data.color) { - color = data.color; - aColor = attributes.color.array; - attributes.color.needsUpdate = true; - } - var n = this.positionCount; - var j, o; - var iCharAll = 0; - var txt, iChar, nChar; - for (var v = 0; v < n; ++v) { - o = 3 * v; - txt = text[v]; - nChar = txt.length; - if (this.parameters.showBackground) - { nChar += 1; } - for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) { - for (var m = 0; m < 4; m++) { - j = iCharAll * 4 * 3 + (3 * m); - if (position) { - aPosition[j] = position[o]; - aPosition[j + 1] = position[o + 1]; - aPosition[j + 2] = position[o + 2]; - } - if (size) { - inputSize[(iCharAll * 4) + m] = size[v]; - } - if (color) { - aColor[j] = color[o]; - aColor[j + 1] = color[o + 1]; - aColor[j + 2] = color[o + 2]; - } - } - } - } - }; - TextBuffer.prototype.makeTexture = function makeTexture () { - this.textAtlas = getTextAtlas({ - font: this.parameters.fontFamily, - style: this.parameters.fontStyle, - weight: this.parameters.fontWeight, - size: this.parameters.fontSize - }); - this.texture = this.textAtlas.texture; - }; - TextBuffer.prototype.makeMapping = function makeMapping () { - var ta = this.textAtlas; - var text = this.text; - var attachment = this.parameters.attachment; - var margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10; - var attribs = this.geometry.attributes; // TODO - var inputTexCoord = attribs.inputTexCoord.array; - var inputMapping = attribs.mapping.array; - var n = this.positionCount; - var iCharAll = 0; - var c, i, txt, xadvance, iChar, nChar, xShift, yShift; - for (var v = 0; v < n; ++v) { - txt = text[v]; - xadvance = 0; - nChar = txt.length; - // calculate width - for (iChar = 0; iChar < nChar; ++iChar) { - c = ta.get(txt[iChar]); - xadvance += c.w - 2 * ta.parameters.outline; - } - // attachment - if (attachment.startsWith('top')) { - yShift = ta.lineHeight / 1.25; - } - else if (attachment.startsWith('middle')) { - yShift = ta.lineHeight / 2.5; - } - else { - yShift = 0; // "bottom" - } - if (attachment.endsWith('right')) { - xShift = xadvance; - } - else if (attachment.endsWith('center')) { - xShift = xadvance / 2; - } - else { - xShift = 0; // "left" - } - xShift += ta.parameters.outline; - yShift += ta.parameters.outline; - // background - if (this.parameters.showBackground) { - i = iCharAll * 2 * 4; - inputMapping[i + 0] = -ta.lineHeight / 6 - xShift - margin; // top left - inputMapping[i + 1] = ta.lineHeight - yShift + margin; - inputMapping[i + 2] = -ta.lineHeight / 6 - xShift - margin; // bottom left - inputMapping[i + 3] = 0 - yShift - margin; - inputMapping[i + 4] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin; // top right - inputMapping[i + 5] = ta.lineHeight - yShift + margin; - inputMapping[i + 6] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin; // bottom right - inputMapping[i + 7] = 0 - yShift - margin; - inputTexCoord[i + 0] = 10; - inputTexCoord[i + 2] = 10; - inputTexCoord[i + 4] = 10; - inputTexCoord[i + 6] = 10; - iCharAll += 1; - } - xadvance = 0; - for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) { - c = ta.get(txt[iChar]); - i = iCharAll * 2 * 4; - inputMapping[i + 0] = xadvance - xShift; // top left - inputMapping[i + 1] = c.h - yShift; - inputMapping[i + 2] = xadvance - xShift; // bottom left - inputMapping[i + 3] = 0 - yShift; - inputMapping[i + 4] = xadvance + c.w - xShift; // top right - inputMapping[i + 5] = c.h - yShift; - inputMapping[i + 6] = xadvance + c.w - xShift; // bottom right - inputMapping[i + 7] = 0 - yShift; - var texWidth = ta.parameters.width; - var texHeight = ta.parameters.height; - var texCoords = [ - c.x / texWidth, c.y / texHeight, - c.x / texWidth, (c.y + c.h) / texHeight, - (c.x + c.w) / texWidth, c.y / texHeight, - (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right - ]; - inputTexCoord.set(texCoords, i); - xadvance += c.w - 2 * ta.parameters.outline; - } - } - attribs.inputTexCoord.needsUpdate = true; - attribs.mapping.needsUpdate = true; - }; - TextBuffer.prototype.getDefines = function getDefines (type) { - var defines = MappedQuadBuffer$$1.prototype.getDefines.call(this, type); - if (this.parameters.fixedSize) { - defines.FIXED_SIZE = 1; - } - return defines; - }; - TextBuffer.prototype.setUniforms = function setUniforms (data) { - if (data && (data.fontFamily !== undefined || - data.fontStyle !== undefined || - data.fontWeight !== undefined || - data.fontSize !== undefined)) { - this.makeTexture(); - this.makeMapping(); - this.texture.needsUpdate = true; - data.fontTexture = this.texture; - } - MappedQuadBuffer$$1.prototype.setUniforms.call(this, data); - }; - - Object.defineProperties( TextBuffer.prototype, prototypeAccessors ); - - return TextBuffer; -}(MappedQuadBuffer)); -BufferRegistry.add('text', TextBuffer); - -ShaderRegistry.add('shader/WideLine.vert', "\nuniform float clipNear;\nuniform vec3 clipCenter;\nuniform float linewidth;\nuniform vec2 resolution;\nuniform mat4 projectionMatrixInverse;\nattribute vec2 mapping;\nattribute vec3 position1;\nattribute vec3 position2;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\nattribute vec3 color2;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid trimSegment( const in vec4 start, inout vec4 end ) {\nfloat a = projectionMatrix[ 2 ][ 2 ]; float b = projectionMatrix[ 3 ][ 2 ]; float nearEstimate = - 0.5 * b / a;\nfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\nend.xyz = mix( start.xyz, end.xyz, alpha );\n}\nvoid main() {\nfloat aspect = resolution.x / resolution.y;\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\nflag = mapping.y;\nvColor = color;\nvColor2 = color2;\n#endif\nvec4 start = modelViewMatrix * vec4( position1, 1.0 );\nvec4 end = modelViewMatrix * vec4( position2, 1.0 );\nbool perspective = ( projectionMatrix[ 2 ][ 3 ] == -1.0 ); if ( perspective ) {\nif ( start.z < 0.0 && end.z >= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"); - -ShaderRegistry.add('shader/WideLine.frag', "uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}"); - -/** - * @file Wide Line Buffer - * @author Alexander Rose - * @private - */ -var WideLineBufferDefaultParameters = Object.assign({ - linewidth: 2 -}, BufferDefaultParameters); -var WideLineBufferParameterTypes = Object.assign({ - linewidth: { uniform: true } -}, BufferParameterTypes); -/** - * Wide Line buffer. Draws lines with a fixed width in pixels. - * - * @example - * var lineBuffer = new WideLineBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 1, 1, 1 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]) - * }); - */ -var WideLineBuffer = /*@__PURE__*/(function (MappedQuadBuffer$$1) { - function WideLineBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedQuadBuffer$$1.call(this, data, params); - this.parameterTypes = WideLineBufferParameterTypes; - this.vertexShader = 'WideLine.vert'; - this.fragmentShader = 'WideLine.frag'; - if (!data.color2 && data.color) - { data.color2 = data.color; } - this.addUniforms({ - 'linewidth': { value: this.parameters.linewidth }, - 'resolution': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["W" /* Vector2 */]() }, - 'projectionMatrixInverse': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() } - }); - this.addAttributes({ - 'position1': { type: 'v3', value: null }, - 'position2': { type: 'v3', value: null }, - 'color2': { type: 'c', value: null } - }); - this.setAttributes(data); - this.makeMapping(); - } - - if ( MappedQuadBuffer$$1 ) WideLineBuffer.__proto__ = MappedQuadBuffer$$1; - WideLineBuffer.prototype = Object.create( MappedQuadBuffer$$1 && MappedQuadBuffer$$1.prototype ); - WideLineBuffer.prototype.constructor = WideLineBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return WideLineBufferDefaultParameters; }; - WideLineBuffer.prototype.setParameters = function setParameters (params) { - MappedQuadBuffer$$1.prototype.setParameters.call(this, params); - }; - - Object.defineProperties( WideLineBuffer.prototype, prototypeAccessors ); - - return WideLineBuffer; -}(MappedQuadBuffer)); -BufferRegistry.add('wideline', WideLineBuffer); - -/** - * @file Angle Representation - * @author Fred Ludlow - * @private - */ -/** - * Angle representation object - * - * Reperesentation consists of four parts, visibility can be set for each - * label - the text label with the angle size - * vectors - lines joining the three points - * sector - triangles representing the angle - * arc - line bordering the sector - * - * @param {Structure} structure - the structure to measure angles in - * @param {Viewer} viewer - a viewer object - * @param {AngleRepresentationParameters} params - angle representation parameters - */ -var AngleRepresentation = /*@__PURE__*/(function (MeasurementRepresentation$$1) { - function AngleRepresentation(structure, viewer, params) { - MeasurementRepresentation$$1.call(this, structure, viewer, params); - this.type = 'angle'; - this.parameters = Object.assign({ - atomTriple: { - type: 'hidden', rebuild: true - }, - vectorVisible: { - type: 'boolean', default: true - }, - arcVisible: { - type: 'boolean', default: true - }, - sectorVisible: { - type: 'boolean', default: true - } - }, this.parameters); - this.init(params); - } - - if ( MeasurementRepresentation$$1 ) AngleRepresentation.__proto__ = MeasurementRepresentation$$1; - AngleRepresentation.prototype = Object.create( MeasurementRepresentation$$1 && MeasurementRepresentation$$1.prototype ); - AngleRepresentation.prototype.constructor = AngleRepresentation; - AngleRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.side = defaults(p.side, 'double'); - p.opacity = defaults(p.opacity, 0.5); - this.atomTriple = defaults(p.atomTriple, []); - this.arcVisible = defaults(p.arcVisible, true); - this.sectorVisible = defaults(p.sectorVisible, true); - this.vectorVisible = defaults(p.vectorVisible, true); - MeasurementRepresentation$$1.prototype.init.call(this, p); - }; - AngleRepresentation.prototype.createData = function createData (sview) { - if (!sview.atomCount || !this.atomTriple.length) - { return; } - var atomPosition = atomTriplePositions(sview, this.atomTriple); - var angleData = getAngleData(atomPosition); - var n = this.n = angleData.labelPosition.length / 3; - var labelColor = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.labelColor); - // Create buffers - this.textBuffer = new TextBuffer({ - position: angleData.labelPosition, - size: uniformArray(n, this.labelSize), - color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b), - text: angleData.labelText - }, this.getLabelBufferParams()); - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.colorValue); - this.vectorBuffer = new WideLineBuffer(getFixedLengthWrappedDashData({ - position1: angleData.vectorPosition1, - position2: angleData.vectorPosition2, - color: uniformArray3(2 * n, c.r, c.g, c.b), - color2: uniformArray3(2 * n, c.r, c.g, c.b) - }), this.getBufferParams({ - linewidth: this.linewidth, - visible: this.vectorVisible, - opacity: this.lineOpacity - })); - this.arcLength = angleData.arcPosition1.length / 3; - this.arcBuffer = new WideLineBuffer(getFixedLengthWrappedDashData({ - position1: angleData.arcPosition1, - position2: angleData.arcPosition2, - color: uniformArray3(this.arcLength, c.r, c.g, c.b), - color2: uniformArray3(this.arcLength, c.r, c.g, c.b) - }), this.getBufferParams({ - linewidth: this.linewidth, - visible: this.arcVisible, - opacity: this.lineOpacity - })); - this.sectorLength = angleData.sectorPosition.length / 3; - this.sectorBuffer = new MeshBuffer({ - position: angleData.sectorPosition, - color: uniformArray3(this.sectorLength, c.r, c.g, c.b) - }, this.getBufferParams({ - visible: this.sectorVisible - })); - return { - bufferList: [ - this.textBuffer, - this.vectorBuffer, - this.arcBuffer, - this.sectorBuffer - ] - }; - }; - AngleRepresentation.prototype.updateData = function updateData (what, data) { - MeasurementRepresentation$$1.prototype.updateData.call(this, what, data); - var vectorData = {}; - var arcData = {}; - var sectorData = {}; - if (what.color) { - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.colorValue); - Object.assign(vectorData, { - color: uniformArray3(this.n * 2, c.r, c.g, c.b), - color2: uniformArray3(this.n * 2, c.r, c.g, c.b) - }); - Object.assign(arcData, { - color: uniformArray3(this.arcLength, c.r, c.g, c.b), - color2: uniformArray3(this.arcLength, c.r, c.g, c.b) - }); - Object.assign(sectorData, { - color: uniformArray3(this.sectorLength, c.r, c.g, c.b) - }); - } - // if (what.sectorOpacity) { - // this.sectorBuffer.opacity = what.sectorOpacity - // } - this.vectorBuffer.setAttributes(vectorData); - this.arcBuffer.setAttributes(arcData); - this.sectorBuffer.setAttributes(sectorData); - }; - AngleRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - MeasurementRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - if (params && (params.vectorVisible !== undefined || - params.arcVisible !== undefined || - params.sectorVisible !== undefined)) { - this.setVisibility(this.visible); - } - if (params && params.lineOpacity) { - this.vectorBuffer.setParameters({ opacity: params.lineOpacity }); - this.arcBuffer.setParameters({ opacity: params.lineOpacity }); - } - if (params && params.opacity !== undefined) { - this.vectorBuffer.setParameters({ opacity: this.lineOpacity }); - this.arcBuffer.setParameters({ opacity: this.lineOpacity }); - } - if (params && params.linewidth) { - this.vectorBuffer.setParameters({ linewidth: params.linewidth }); - this.arcBuffer.setParameters({ linewidth: params.linewidth }); - } - return this; - }; - AngleRepresentation.prototype.setVisibility = function setVisibility (value, noRenderRequest) { - MeasurementRepresentation$$1.prototype.setVisibility.call(this, value, true); - if (this.vectorBuffer) { - this.vectorBuffer.setVisibility(this.vectorVisible && this.visible); - } - if (this.arcBuffer) { - this.arcBuffer.setVisibility(this.arcVisible && this.visible); - } - if (this.sectorBuffer) { - this.sectorBuffer.setVisibility(this.sectorVisible && this.visible); - } - if (!noRenderRequest) - { this.viewer.requestRender(); } - return this; - }; - - return AngleRepresentation; -}(MeasurementRepresentation)); -/** - * Ensure mid point does not coincide with first or second - * @param {Float32Array} position 9*nAngle array of coordinates - * @return {Float32Array} Filtered position array, may be shorter - */ -function validatePositions(position) { - var include = []; - var n = position.length / 9; - for (var i = 0; i < n; i++) { - // Check that first point not same as second and that second not same as third - var okay = true; - for (var j = i; j < i + 3; j += 3) { - if (position[j] === position[j + 3] && - position[j + 1] === position[j + 4] && - position[j + 2] === position[j + 5]) { - okay = false; - } - } - if (okay) - { include.push(i); } - } - var outPosition = new Float32Array(include.length * 9); - var outIdx = 0; - include.forEach(function (i) { - copyArray(position, outPosition, i * 9, outIdx * 9, 9); - outIdx++; - }); - return outPosition; -} -function atomTriplePositions(sview, atomTriple) { - return validatePositions(parseNestedAtoms(sview, atomTriple)); -} -/** - * Converts triple positions into data required to build various buffers. - */ -function getAngleData(position, params) { - if ( params === void 0 ) params = {}; - - var angleStep = defaults(params.angleStep, Math.PI / 90); - var n = position.length / 9; - var angles = new Float32Array(n); - var labelPosition = new Float32Array(n * 3); - var labelText = new Array(n); - var vectorPosition1 = new Float32Array(n * 6); // Two lines per angle - var vectorPosition2 = new Float32Array(n * 6); - var arcPositionTmp1 = new Array(n); // Start points for arc lines - var arcPositionTmp2 = new Array(n); // End points for arc lines - var sectorPositionTmp = new Array(n); // Triangle points - var totalSegments = 0; - // Re-used vectors etc - var p1 = v3new(); // Positions of points for each angel - var p2 = v3new(); - var p3 = v3new(); - var v21 = v3new(); // Vectors - var v23 = v3new(); - var cross = v3new(); // Cross product v21xv23 - var cross2 = v3new(); // In-plane cross product v21 x (v21 x v23) - var labelTmp = v3new(); - var arcPoint = v3new(); - var loop = function ( i ) { - var p = 9 * i; - v3fromArray(p1, position, p); - v3fromArray(p2, position, p + 3); - v3fromArray(p3, position, p + 6); - var v = 6 * i; - v3toArray(p1, vectorPosition1, v); - v3toArray(p2, vectorPosition2, v); - v3toArray(p2, vectorPosition1, v + 3); - v3toArray(p3, vectorPosition2, v + 3); - v3sub(v21, p1, p2); - v3sub(v23, p3, p2); - v3normalize(v21, v21); // validatePositions ensures valid - v3normalize(v23, v23); - v3cross(cross, v21, v23); - var crossLength = v3length(cross); - var dot = v3dot(v21, v23); - var angle = angles[i] = Math.atan2(crossLength, dot); - labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0); - if (v3length(cross) === 0.0) { - // Angle exactly 0/180, pick an arbitrary direction - cross[0] = 1.0; - cross[1] = 0.0; - cross[2] = 0.0; - } - v3cross(cross2, cross, v21); - v3normalize(cross2, cross2); - calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0); - // TODO: Scale label position? - v3toArray(labelTmp, labelPosition, 3 * i); - // Build the arc and sector - var nSegments = Math.ceil(angle / angleStep); - var sectorVertices = new Float32Array(nSegments * 9); - sectorPositionTmp[i] = sectorVertices; - var arcVertices1 = new Float32Array(nSegments * 3); - var arcVertices2 = new Float32Array(nSegments * 3); - arcPositionTmp1[i] = arcVertices1; - arcPositionTmp2[i] = arcVertices2; - v3add(arcPoint, p2, v21); // Our initial arc point - var appendArcSection = function (a, j) { - var si = j * 9; - var ai = j * 3; - v3toArray(p2, sectorVertices, si); - v3toArray(arcPoint, sectorVertices, si + 3); - v3toArray(arcPoint, arcVertices1, ai); - calcArcPoint(arcPoint, p2, v21, cross2, a); - v3toArray(arcPoint, sectorVertices, si + 6); - v3toArray(arcPoint, arcVertices2, ai); - }; - var j = 0; - for (var a = angleStep; a < angle; a += angleStep) { - appendArcSection(a, j); - j++; - } - appendArcSection(angle, j); - totalSegments += nSegments; - }; - - for (var i = 0; i < n; i++) loop( i ); - // Flatten nested arrays of arc/segment points - var arcSize = totalSegments * 3; - var sectorSize = totalSegments * 9; - var arcPosition1 = new Float32Array(arcSize); - var arcPosition2 = new Float32Array(arcSize); - var sectorPosition = new Float32Array(sectorSize); - var sectorOffset = 0; - var arcOffset = 0; - for (var i$1 = 0; i$1 < n; i$1++) { - var ap1 = arcPositionTmp1[i$1]; - var ap2 = arcPositionTmp2[i$1]; - copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length); - copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length); - arcOffset += ap1.length; // === ap2.length - var sp = sectorPositionTmp[i$1]; - copyArray(sp, sectorPosition, 0, sectorOffset, sp.length); - sectorOffset += sp.length; - } - return { - labelPosition: labelPosition, - labelText: labelText, - vectorPosition1: vectorPosition1, - vectorPosition2: vectorPosition2, - arcPosition1: arcPosition1, - arcPosition2: arcPosition2, - sectorPosition: sectorPosition - }; -} -RepresentationRegistry.add('angle', AngleRepresentation); - -/** - * @file Cylinder Geometry Buffer - * @author Alexander Rose - * @private - */ -var scale$2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 1, 0); -var CylinderGeometryBufferDefaultParameters = Object.assign({ - radialSegments: 1, - openEnded: true -}, BufferDefaultParameters); -function getData$1(data, params) { - if ( params === void 0 ) params = {}; - - var geo = getGeo(params); - var n = data.position1.length; - var geoLength = geo.attributes.position.array.length / 3; - var count = n / 3; - var primitiveId = new Float32Array(count * 2 * geoLength); - serialBlockArray(count, geoLength, 0, primitiveId); - serialBlockArray(count, geoLength, count * geoLength, primitiveId); - var position = new Float32Array(n * 2); - var color = new Float32Array(n * 2); - return { - position: position, color: color, primitiveId: primitiveId, picking: data.picking - }; -} -function getGeo(params) { - if ( params === void 0 ) params = {}; - - var radialSegments = defaults(params.radialSegments, 10); - var openEnded = defaults(params.openEnded, true); - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeRotationX(Math.PI / 2); - var geo = new __WEBPACK_IMPORTED_MODULE_0_three__["k" /* CylinderBufferGeometry */](1, // radiusTop, - 1, // radiusBottom, - 1, // height, - radialSegments, // radialSegments, - 1, // heightSegments, - openEnded // openEnded - ); - geo.applyMatrix4(matrix); - return geo; -} -/** - * Cylinder geometry buffer. - * - * @example - * var cylinderGeometryBuffer = new CylinderGeometryBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 1, 1, 1 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var CylinderGeometryBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function CylinderGeometryBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, getData$1(data, params), params, getGeo(params)); - this.updateNormals = true; - var n = data.position1.length; - var m = data.radius.length; - this.__center = new Float32Array(n); - this._position = new Float32Array(n * 2); - this._color = new Float32Array(n * 2); - this._from = new Float32Array(n * 2); - this._to = new Float32Array(n * 2); - this._radius = new Float32Array(m * 2); - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) CylinderGeometryBuffer.__proto__ = GeometryBuffer$$1; - CylinderGeometryBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - CylinderGeometryBuffer.prototype.constructor = CylinderGeometryBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return CylinderGeometryBufferDefaultParameters; }; - CylinderGeometryBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - eye.fromArray(this._from, i3); - target.fromArray(this._to, i3); - matrix.lookAt(eye, target, up); - var r = this._radius[i]; - scale$2.set(r, r, eye.distanceTo(target)); - matrix.scale(scale$2); - }; - CylinderGeometryBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - var meshData = {}; - if (data.position1 && data.position2) { - calculateCenterArray(data.position1, data.position2, this.__center); - calculateCenterArray(data.position1, this.__center, this._position); - calculateCenterArray(this.__center, data.position2, this._position, data.position1.length); - this._from.set(data.position1); - this._from.set(this.__center, data.position1.length); - this._to.set(this.__center); - this._to.set(data.position2, this.__center.length); - meshData.position = this._position; - } - if (data.color && data.color2) { - this._color.set(data.color); - this._color.set(data.color2, data.color.length); - meshData.color = this._color; - } - if (data.radius) { - this._radius.set(data.radius); - this._radius.set(data.radius, data.radius.length); - meshData.radius = this._radius; - } - GeometryBuffer$$1.prototype.setAttributes.call(this, meshData, initNormals); - }; - - Object.defineProperties( CylinderGeometryBuffer.prototype, prototypeAccessors ); - - return CylinderGeometryBuffer; -}(GeometryBuffer)); - -ShaderRegistry.add('shader/CylinderImpostor.vert', "\nattribute vec3 mapping;\nattribute vec3 position1;\nattribute vec3 position2;\nattribute float radius;\nvarying vec3 axis;\nvarying vec4 base_radius;\nvarying vec4 end_b;\nvarying vec3 U;\nvarying vec3 V;\nvarying vec4 w;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\nattribute vec3 color2;\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#endif\nuniform mat4 modelViewMatrixInverse;\nuniform float ortho;\n#include matrix_scale\nvoid main(){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\nvColor1 = color;\nvColor2 = color2;\n#endif\nbase_radius.w = radius * matrixScale( modelViewMatrix );\nvec3 center = position;\nvec3 dir = normalize( position2 - position1 );\nfloat ext = length( position2 - position1 ) / 2.0;\nvec3 cam_dir;\nif( ortho == 0.0 ){\ncam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 0, 1 ) ).xyz - center;\n}else{\ncam_dir = ( modelViewMatrixInverse * vec4( 0, 0, 1, 0 ) ).xyz;\n}\ncam_dir = normalize( cam_dir );\nvec3 ldir;\nfloat b = dot( cam_dir, dir );\nend_b.w = b;\nif( b < 0.0 )\nldir = -ext * dir;\nelse\nldir = ext * dir;\nvec3 left = normalize( cross( cam_dir, ldir ) );\nleft = radius * left;\nvec3 up = radius * normalize( cross( left, ldir ) );\naxis = normalize( normalMatrix * ldir );\nU = normalize( normalMatrix * up );\nV = normalize( normalMatrix * left );\nvec4 base4 = modelViewMatrix * vec4( center - ldir, 1.0 );\nbase_radius.xyz = base4.xyz / base4.w;\nvec4 top_position = modelViewMatrix * vec4( center + ldir, 1.0 );\nvec4 end4 = top_position;\nend_b.xyz = end4.xyz / end4.w;\nw = modelViewMatrix * vec4(\ncenter + mapping.x*ldir + mapping.y*left + mapping.z*up, 1.0\n);\ngl_Position = projectionMatrix * w;\ngl_Position.z = 0.99;\n}"); - -ShaderRegistry.add('shader/CylinderImpostor.frag', "#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform mat4 projectionMatrix;\nuniform float ortho;\nvarying vec3 axis;\nvarying vec4 base_radius;\nvarying vec4 end_b;\nvarying vec3 U;\nvarying vec3 V;\nvarying vec4 w;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat distSq3( vec3 v3a, vec3 v3b ){\nreturn (\n( v3a.x - v3b.x ) * ( v3a.x - v3b.x ) +\n( v3a.y - v3b.y ) * ( v3a.y - v3b.y ) +\n( v3a.z - v3b.z ) * ( v3a.z - v3b.z )\n);\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nfloat calcClip( vec3 cameraPos ){\nreturn dot( vec4( cameraPos, 1.0 ), vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nvoid main(){\nvec3 point = w.xyz / w.w;\nvec3 base = base_radius.xyz;\nfloat vRadius = base_radius.w;\nvec3 end = end_b.xyz;\nfloat b = end_b.w;\nvec3 end_cyl = end;\nvec3 surface_point = point;\nvec3 ray_target = surface_point;\nvec3 ray_origin = vec3(0.0);\nvec3 ray_direction = mix(normalize(ray_origin - ray_target), vec3(0.0, 0.0, 1.0), ortho);\nmat3 basis = mat3( U, V, axis );\nvec3 diff = ray_target - 0.5 * (base + end_cyl);\nvec3 P = diff * basis;\nfloat dz = dot( axis, ray_direction );\nfloat radius2 = vRadius*vRadius;\nvec3 D = vec3(dot(U, ray_direction),\ndot(V, ray_direction),\ndz);\nfloat a0 = P.x*P.x + P.y*P.y - radius2;\nfloat a1 = P.x*D.x + P.y*D.y;\nfloat a2 = D.x*D.x + D.y*D.y;\nfloat d = a1*a1 - a0*a2;\nif (d < 0.0)\ndiscard;\nfloat dist = (-a1 + sqrt(d)) / a2;\nvec3 new_point = ray_target + dist * ray_direction;\nvec3 tmp_point = new_point - base;\nvec3 _normal = normalize( tmp_point - axis * dot(tmp_point, axis) );\nray_origin = mix( ray_origin, surface_point, ortho );\nfloat front_cap_test = dot( tmp_point, axis );\nfloat end_cap_test = dot((new_point - end_cyl), axis);\n#ifndef CAP\nvec3 new_point2 = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\nvec3 tmp_point2 = new_point2 - base;\n#endif\nif (front_cap_test < 0.0)\n{\nfloat dNV = dot(-axis, ray_direction);\nif (dNV < 0.0)\ndiscard;\nfloat near = dot(-axis, (base)) / dNV;\nvec3 front_point = ray_direction * near + ray_origin;\nif (dot(front_point - base, front_point-base) > radius2)\ndiscard;\n#ifdef CAP\nnew_point = front_point;\n_normal = axis;\n#else\nnew_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end_cyl) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end_cyl, new_point2-base) < radius2)\ndiscard;\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV = dot(axis, ray_direction);\nif (dNV < 0.0)\ndiscard;\nfloat near = dot(axis, end_cyl) / dNV;\nvec3 end_point = ray_direction * near + ray_origin;\nif( dot(end_point - end_cyl, end_point-base) > radius2 )\ndiscard;\n#ifdef CAP\nnew_point = end_point;\n_normal = axis;\n#else\nnew_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2)\ndiscard;\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( new_point );\n#ifdef NEAR_CLIP\nif( calcClip( new_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\nif( calcClip( new_point ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nnew_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( new_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -new_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( new_point, end_cyl ) < distSq3( new_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}"); - -/** - * @file Mapped Aligned Box Buffer - * @author Alexander Rose - * @private - */ -var mapping$1 = new Float32Array([ - -1.0, 1.0, -1.0, - -1.0, -1.0, -1.0, - 1.0, 1.0, -1.0, - 1.0, 1.0, 1.0, - 1.0, -1.0, -1.0, - 1.0, -1.0, 1.0 -]); -var mappingIndices$1 = new Uint16Array([ - 0, 1, 2, - 1, 4, 2, - 2, 4, 3, - 4, 5, 3 -]); -/** - * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned. - * Used to render cylinder imposters. - * @interface - */ -var MappedAlignedBoxBuffer = /*@__PURE__*/(function (MappedBuffer$$1) { - function MappedAlignedBoxBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedBuffer$$1.call(this, 'v3', data, params); - } - - if ( MappedBuffer$$1 ) MappedAlignedBoxBuffer.__proto__ = MappedBuffer$$1; - MappedAlignedBoxBuffer.prototype = Object.create( MappedBuffer$$1 && MappedBuffer$$1.prototype ); - MappedAlignedBoxBuffer.prototype.constructor = MappedAlignedBoxBuffer; - - var prototypeAccessors = { mapping: { configurable: true },mappingIndices: { configurable: true },mappingIndicesSize: { configurable: true },mappingSize: { configurable: true },mappingItemSize: { configurable: true } }; - prototypeAccessors.mapping.get = function () { return mapping$1; }; - prototypeAccessors.mappingIndices.get = function () { return mappingIndices$1; }; - prototypeAccessors.mappingIndicesSize.get = function () { return 12; }; - prototypeAccessors.mappingSize.get = function () { return 6; }; - prototypeAccessors.mappingItemSize.get = function () { return 3; }; - - Object.defineProperties( MappedAlignedBoxBuffer.prototype, prototypeAccessors ); - - return MappedAlignedBoxBuffer; -}(MappedBuffer)); - -/** - * @file Cylinder Impostor Buffer - * @author Alexander Rose - * @private - */ -var CylinderImpostorBufferDefaultParameters = Object.assign({ - openEnded: false -}, BufferDefaultParameters); -var CylinderImpostorBufferParameterTypes = Object.assign({ - openEnded: { updateShader: true } -}, BufferParameterTypes); -/** - * Cylinder impostor buffer. - * - * @example - * var cylinderimpostorBuffer = new CylinderImpostorBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 1, 1, 1 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var CylinderImpostorBuffer = /*@__PURE__*/(function (MappedAlignedBoxBuffer$$1) { - function CylinderImpostorBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedAlignedBoxBuffer$$1.call(this, data, params); - this.parameterTypes = CylinderImpostorBufferParameterTypes; - this.isImpostor = true; - this.vertexShader = 'CylinderImpostor.vert'; - this.fragmentShader = 'CylinderImpostor.frag'; - this.addUniforms({ - 'modelViewMatrixInverse': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() }, - 'ortho': { value: 0.0 } - }); - this.addAttributes({ - 'position1': { type: 'v3', value: null }, - 'position2': { type: 'v3', value: null }, - 'color2': { type: 'c', value: null }, - 'radius': { type: 'f', value: null } - }); - this.setAttributes(data); - this.makeMapping(); - } - - if ( MappedAlignedBoxBuffer$$1 ) CylinderImpostorBuffer.__proto__ = MappedAlignedBoxBuffer$$1; - CylinderImpostorBuffer.prototype = Object.create( MappedAlignedBoxBuffer$$1 && MappedAlignedBoxBuffer$$1.prototype ); - CylinderImpostorBuffer.prototype.constructor = CylinderImpostorBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return CylinderImpostorBufferDefaultParameters; }; - CylinderImpostorBuffer.prototype.getDefines = function getDefines (type) { - var defines = MappedAlignedBoxBuffer$$1.prototype.getDefines.call(this, type); - if (!this.parameters.openEnded) { - defines.CAP = 1; - } - return defines; - }; - - Object.defineProperties( CylinderImpostorBuffer.prototype, prototypeAccessors ); - - return CylinderImpostorBuffer; -}(MappedAlignedBoxBuffer)); - -/** - * @file Cylinder Buffer - * @author Alexander Rose - * @private - */ -var CylinderBufferDefaultParameters = Object.assign({ - disableImpostor: false -}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters); -/** - * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and - * `params.disableImpostor` the constructor returns either a - * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer} - * @implements {Buffer} - * - * @example - * var cylinderBuffer = new CylinderBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 1, 1, 1 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var CylinderBuffer = function CylinderBuffer(data, params) { - if ( params === void 0 ) params = {}; - - if (!data.color2 && data.color) - { data.color2 = data.color; } - if (!ExtensionFragDepth || (params && params.disableImpostor)) { - return new CylinderGeometryBuffer(data, params); - } - else { - return new CylinderImpostorBuffer(data, params); - } -}; -BufferRegistry.add('cylinder', CylinderBuffer); - -/** - * @file Axes Representation - * @author Alexander Rose - * @private - */ -/** - * Axes representation. Show principal axes and/or a box aligned with them - * that fits the structure or selection. - * - * __Name:__ _axes_ - * - * @example - * stage.loadFile( "rcsb://3pqr", { - * assembly: "BU1" - * } ).then( function( o ){ - * o.addRepresentation( "cartoon" ); - * o.addRepresentation( "axes", { - * sele: "RET", showAxes: false, showBox: true, radius: 0.2 - * } ); - * o.addRepresentation( "ball+stick", { sele: "RET" } ); - * o.addRepresentation( "axes", { - * sele: ":B and backbone", showAxes: false, showBox: true, radius: 0.2 - * } ); - * stage.autoView(); - * var pa = o.structure.getPrincipalAxes(); - * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 ); - * } ); - */ -var AxesRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function AxesRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'axes'; - this.parameters = Object.assign({ - radiusSize: { - type: 'number', precision: 3, max: 10.0, min: 0.001 - }, - sphereDetail: true, - radialSegments: true, - disableImpostor: true, - showAxes: { - type: 'boolean', rebuild: true - }, - showBox: { - type: 'boolean', rebuild: true - } - }, this.parameters, { - assembly: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) AxesRepresentation.__proto__ = StructureRepresentation$$1; - AxesRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - AxesRepresentation.prototype.constructor = AxesRepresentation; - AxesRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.radiusSize = defaults(p.radiusSize, 0.5); - p.colorValue = defaults(p.colorValue, 'lightgreen'); - p.useInteriorColor = defaults(p.useInteriorColor, true); - this.showAxes = defaults(p.showAxes, true); - this.showBox = defaults(p.showBox, false); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - AxesRepresentation.prototype.getPrincipalAxes = function getPrincipalAxes () { - var selection; - var assembly = this.getAssembly(); - if (assembly) { - selection = assembly.partList[0].getSelection(); - } - return this.structureView.getPrincipalAxes(selection); - }; - AxesRepresentation.prototype.getAxesData = function getAxesData (sview) { - var pa = this.getPrincipalAxes(); - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.colorValue); - var vn = 0; - var en = 0; - if (this.showAxes) { - vn += 6; - en += 3; - } - if (this.showBox) { - vn += 8; - en += 12; - } - var vertexPosition = new Float32Array(3 * vn); - var vertexColor = uniformArray3(vn, c.r, c.g, c.b); - var vertexRadius = uniformArray(vn, this.radiusSize); - var edgePosition1 = new Float32Array(3 * en); - var edgePosition2 = new Float32Array(3 * en); - var edgeColor = uniformArray3(en, c.r, c.g, c.b); - var edgeRadius = uniformArray(en, this.radiusSize); - var offset = 0; - if (this.showAxes) { - var addAxis = function (v1, v2) { - v1.toArray(vertexPosition, offset * 2); - v2.toArray(vertexPosition, offset * 2 + 3); - v1.toArray(edgePosition1, offset); - v2.toArray(edgePosition2, offset); - offset += 3; - }; - addAxis(pa.begA, pa.endA); - addAxis(pa.begB, pa.endB); - addAxis(pa.begC, pa.endC); - } - if (this.showBox) { - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var ref = pa.getProjectedScaleForAtoms(sview); - var d1a = ref.d1a; - var d2a = ref.d2a; - var d3a = ref.d3a; - var d1b = ref.d1b; - var d2b = ref.d2b; - var d3b = ref.d3b; - // console.log(d1a, d2a, d3a, d1b, d2b, d3b) - var offset2 = offset * 2; - var addCorner = function (d1, d2, d3) { - v.copy(pa.center) - .addScaledVector(pa.normVecA, d1) - .addScaledVector(pa.normVecB, d2) - .addScaledVector(pa.normVecC, d3); - v.toArray(vertexPosition, offset2); - offset2 += 3; - }; - addCorner(d1a, d2a, d3a); - addCorner(d1a, d2a, d3b); - addCorner(d1a, d2b, d3b); - addCorner(d1a, d2b, d3a); - addCorner(d1b, d2b, d3b); - addCorner(d1b, d2b, d3a); - addCorner(d1b, d2a, d3a); - addCorner(d1b, d2a, d3b); - var edgeOffset = offset; - var addEdge = function (a, b) { - v.fromArray(vertexPosition, offset * 2 + a * 3) - .toArray(edgePosition1, edgeOffset); - v.fromArray(vertexPosition, offset * 2 + b * 3) - .toArray(edgePosition2, edgeOffset); - edgeOffset += 3; - }; - addEdge(0, 1); - addEdge(0, 3); - addEdge(0, 6); - addEdge(1, 2); - addEdge(1, 7); - addEdge(2, 3); - addEdge(2, 4); - addEdge(3, 5); - addEdge(4, 5); - addEdge(4, 7); - addEdge(5, 6); - addEdge(6, 7); - } - var picker = new AxesPicker(pa); - return { - vertex: { - position: vertexPosition, - color: vertexColor, - radius: vertexRadius, - picking: picker - }, - edge: { - position1: edgePosition1, - position2: edgePosition2, - color: edgeColor, - color2: edgeColor, - radius: edgeRadius, - picking: picker - } - }; - }; - AxesRepresentation.prototype.create = function create () { - var axesData = this.getAxesData(this.structureView); - this.sphereBuffer = new SphereBuffer(axesData.vertex, this.getBufferParams({ - sphereDetail: this.sphereDetail, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - this.cylinderBuffer = new CylinderBuffer(axesData.edge, this.getBufferParams({ - openEnded: true, - radialSegments: this.radialSegments, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - this.dataList.push({ - sview: this.structureView, - bufferList: [this.sphereBuffer, this.cylinderBuffer] - }); - }; - AxesRepresentation.prototype.createData = function createData (sview) { - return; - }; - AxesRepresentation.prototype.updateData = function updateData (what, data) { - var axesData = this.getAxesData(data.sview); - var sphereData = {}; - var cylinderData = {}; - if (!what || what.position) { - Object.assign(sphereData, { - position: axesData.vertex.position - }); - Object.assign(cylinderData, { - position1: axesData.edge.position1, - position2: axesData.edge.position2 - }); - } - if (!what || what.color) { - Object.assign(sphereData, { - color: axesData.vertex.color - }); - Object.assign(cylinderData, { - color: axesData.edge.color, - color2: axesData.edge.color - }); - } - if (!what || what.radius) { - Object.assign(sphereData, { - radius: axesData.vertex.radius - }); - Object.assign(cylinderData, { - radius: axesData.edge.radius - }); - } - this.sphereBuffer.setAttributes(sphereData); - this.cylinderBuffer.setAttributes(cylinderData); - }; - - return AxesRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('axes', AxesRepresentation); - -/** - * @file Ball And Stick Representation - * @author Alexander Rose - * @private - */ -/** - * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and - * {@link StructureRepresentationParameters}. - * - * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters - * - * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions) - * @property {Integer} radialSegments - cylinder quality (number of segments) - * @property {Boolean} openEnded - capped or not - * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering - * @property {Float} aspectRatio - size difference between atom and bond radii - * @property {Boolean} lineOnly - render only bonds, and only as lines - * @property {Integer} linewidth - width of lines - * @property {Boolean} cylinderOnly - render only bonds (no atoms) - * @property {String} multipleBond - one off "off", "symmetric", "offset" - * @property {Float} bondSpacing - spacing for multiple bond rendering - * @property {Float} bondScale - scale/radius for multiple bond rendering - */ -/** - * Ball And Stick representation. Show atoms as spheres and bonds as cylinders. - * - * __Name:__ _ball+stick_ - * - * @example - * stage.loadFile( "rcsb://1crn" ).then( function( o ){ - * o.addRepresentation( "ball+stick" ); - * o.autoView(); - * } ); - */ -var BallAndStickRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function BallAndStickRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'ball+stick'; - this.parameters = Object.assign({ - sphereDetail: true, - radialSegments: true, - openEnded: true, - disableImpostor: true, - aspectRatio: { - type: 'number', precision: 1, max: 10.0, min: 1.0 - }, - lineOnly: { - type: 'boolean', rebuild: true - }, - cylinderOnly: { - type: 'boolean', rebuild: true - }, - multipleBond: { - type: 'select', - rebuild: true, - options: { - 'off': 'off', - 'symmetric': 'symmetric', - 'offset': 'offset' - } - }, - bondScale: { - type: 'number', precision: 2, max: 1.0, min: 0.01 - }, - bondSpacing: { - type: 'number', precision: 2, max: 2.0, min: 0.5 - }, - linewidth: { - type: 'integer', max: 50, min: 1, buffer: true - } - }, this.parameters); - this.init(params); - } - - if ( StructureRepresentation$$1 ) BallAndStickRepresentation.__proto__ = StructureRepresentation$$1; - BallAndStickRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - BallAndStickRepresentation.prototype.constructor = BallAndStickRepresentation; - BallAndStickRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.radiusType = defaults(p.radiusType, 'size'); - p.radiusSize = defaults(p.radiusSize, 0.15); - p.useInteriorColor = defaults(p.useInteriorColor, true); - this.aspectRatio = defaults(p.aspectRatio, 2.0); - this.lineOnly = defaults(p.lineOnly, false); - this.cylinderOnly = defaults(p.cylinderOnly, false); - this.multipleBond = defaults(p.multipleBond, 'off'); - this.bondSpacing = defaults(p.bondSpacing, 1.0); - this.bondScale = defaults(p.bondScale, 0.4); - this.linewidth = defaults(p.linewidth, 2); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - BallAndStickRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - return this.aspectRatio * StructureRepresentation$$1.prototype.getAtomRadius.call(this, atom); - }; - BallAndStickRepresentation.prototype.getAtomParams = function getAtomParams (what, params) { - var p = StructureRepresentation$$1.prototype.getAtomParams.call(this, what, params); - p.radiusParams.scale *= this.aspectRatio; - return p; - }; - BallAndStickRepresentation.prototype.getAtomData = function getAtomData (sview, what, params) { - return sview.getAtomData(this.getAtomParams(what, params)); - }; - BallAndStickRepresentation.prototype.getBondParams = function getBondParams (what, params) { - params = Object.assign({ - multipleBond: this.multipleBond, - bondSpacing: this.bondSpacing, - bondScale: this.bondScale - }, params); - return StructureRepresentation$$1.prototype.getBondParams.call(this, what, params); - }; - BallAndStickRepresentation.prototype.getBondData = function getBondData (sview, what, params) { - return sview.getBondData(this.getBondParams(what, params)); - }; - BallAndStickRepresentation.prototype.createData = function createData (sview) { - var bufferList = []; - if (this.lineOnly) { - this.lineBuffer = new WideLineBuffer(this.getBondData(sview, { position: true, color: true, picking: true }), this.getBufferParams({ linewidth: this.linewidth })); - bufferList.push(this.lineBuffer); - } - else { - var cylinderBuffer = new CylinderBuffer(this.getBondData(sview), this.getBufferParams({ - openEnded: this.openEnded, - radialSegments: this.radialSegments, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - bufferList.push(cylinderBuffer); - if (!this.cylinderOnly) { - var sphereBuffer = new SphereBuffer(this.getAtomData(sview), this.getBufferParams({ - sphereDetail: this.sphereDetail, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - bufferList.push(sphereBuffer); - } - } - return { - bufferList: bufferList - }; - }; - BallAndStickRepresentation.prototype.updateData = function updateData (what, data) { - if (this.multipleBond !== 'off' && what && what.radius) { - what.position = true; - } - var bondData = this.getBondData(data.sview, what); - if (this.lineOnly) { - var lineData = {}; - if (!what || what.position) { - Object.assign(lineData, { - position1: bondData.position1, - position2: bondData.position2 - }); - } - if (!what || what.color) { - Object.assign(lineData, { - color: bondData.color, - color2: bondData.color2 - }); - } - data.bufferList[0].setAttributes(lineData); - } - else { - var cylinderData = {}; - if (!what || what.position) { - Object.assign(cylinderData, { - position1: bondData.position1, - position2: bondData.position2 - }); - } - if (!what || what.color) { - Object.assign(cylinderData, { - color: bondData.color, - color2: bondData.color2 - }); - } - if (!what || what.radius) { - Object.assign(cylinderData, { - radius: bondData.radius - }); - } - data.bufferList[0].setAttributes(cylinderData); - if (!this.cylinderOnly) { - var atomData = this.getAtomData(data.sview, what); - var sphereData = {}; - if (!what || what.position) { - Object.assign(sphereData, { - position: atomData.position - }); - } - if (!what || what.color) { - Object.assign(sphereData, { - color: atomData.color - }); - } - if (!what || what.radius) { - Object.assign(sphereData, { - radius: atomData.radius - }); - } - data.bufferList[1].setAttributes(sphereData); - } - } - }; - BallAndStickRepresentation.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - var rebuild = false; - var what = {}; - if (params.aspectRatio || params.bondSpacing || params.bondScale) { - Object.assign(what, { radius: true }); - if (!ExtensionFragDepth || this.disableImpostor) { - rebuild = true; - } - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - - return BallAndStickRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('ball+stick', BallAndStickRepresentation); - -/** - * @file Backbone Representation - * @author Alexander Rose - * @private - */ -/** - * Backbone representation. Show cylinders (or lines) connecting .CA (protein) - * or .C4'/.C3' (RNA/DNA) of polymers. - * - * __Name:__ _backbone_ - * - * @example - * stage.loadFile( "rcsb://1sfi" ).then( function( o ){ - * o.addRepresentation( "backbone" ); - * o.autoView(); - * } ); - */ -var BackboneRepresentation = /*@__PURE__*/(function (BallAndStickRepresentation$$1) { - function BackboneRepresentation(structure, viewer, params) { - BallAndStickRepresentation$$1.call(this, structure, viewer, params); - this.type = 'backbone'; - this.parameters = Object.assign({}, this.parameters, { - multipleBond: null, - bondSpacing: null - }); - this.init(params); - } - - if ( BallAndStickRepresentation$$1 ) BackboneRepresentation.__proto__ = BallAndStickRepresentation$$1; - BackboneRepresentation.prototype = Object.create( BallAndStickRepresentation$$1 && BallAndStickRepresentation$$1.prototype ); - BackboneRepresentation.prototype.constructor = BackboneRepresentation; - BackboneRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.aspectRatio = defaults(p.aspectRatio, 1.0); - p.radiusSize = defaults(p.radiusSize, 0.25); - BallAndStickRepresentation$$1.prototype.init.call(this, p); - }; - BackboneRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - return atom.isTrace() ? BallAndStickRepresentation$$1.prototype.getAtomRadius.call(this, atom) : 0; - }; - BackboneRepresentation.prototype.getAtomData = function getAtomData (sview, what, params) { - return sview.getBackboneAtomData(this.getAtomParams(what, params)); - }; - BackboneRepresentation.prototype.getBondData = function getBondData (sview, what, params) { - return sview.getBackboneBondData(this.getBondParams(what, params)); - }; - - return BackboneRepresentation; -}(BallAndStickRepresentation)); -RepresentationRegistry.add('backbone', BackboneRepresentation); - -/** - * @file Base Representation - * @author Alexander Rose - * @private - */ -/** - * Base representation. Show cylinders for RNA/DNA ladders. - * - * __Name:__ _base_ - * - * @example - * stage.loadFile( "rcsb://1d66" ).then( function( o ){ - * o.addRepresentation( "cartoon", { sele: "nucleic" } ); - * o.addRepresentation( "base", { color: "resname" } ); - * o.autoView( "nucleic" ); - * } ); - */ -var BaseRepresentation = /*@__PURE__*/(function (BallAndStickRepresentation$$1) { - function BaseRepresentation(structure, viewer, params) { - BallAndStickRepresentation$$1.call(this, structure, viewer, params); - this.type = 'base'; - this.parameters = Object.assign({}, this.parameters, { - multipleBond: null, - bondSpacing: null - }); - } - - if ( BallAndStickRepresentation$$1 ) BaseRepresentation.__proto__ = BallAndStickRepresentation$$1; - BaseRepresentation.prototype = Object.create( BallAndStickRepresentation$$1 && BallAndStickRepresentation$$1.prototype ); - BaseRepresentation.prototype.constructor = BaseRepresentation; - BaseRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.aspectRatio = defaults(p.aspectRatio, 1.0); - p.radiusSize = defaults(p.radiusSize, 0.3); - BallAndStickRepresentation$$1.prototype.init.call(this, p); - }; - BaseRepresentation.prototype.getAtomData = function getAtomData (sview, what, params) { - return sview.getRungAtomData(this.getAtomParams(what, params)); - }; - BaseRepresentation.prototype.getBondData = function getBondData (sview, what, params) { - var p = this.getBondParams(what, params); - Object.assign(p.colorParams, { rung: true }); - return sview.getRungBondData(p); - }; - - return BaseRepresentation; -}(BallAndStickRepresentation)); -RepresentationRegistry.add('base', BaseRepresentation); - -/** - * @file Spline - * @author Alexander Rose - * @private - */ -var Interpolator = function Interpolator(m, tension) { - this.m = m; - this.tension = tension; - this.dt = 1.0 / this.m; - this.delta = 0.0001; - this.vec1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.vec2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.vDir = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.vTan = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.vNorm = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.vBin = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - this.m2 = Math.ceil(this.m / 2); -}; -Interpolator.prototype.interpolateToArr = function interpolateToArr (v0, v1, v2, v3, t, arr, offset) { - arr[offset + 0] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension); - arr[offset + 1] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension); - arr[offset + 2] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension); -}; -Interpolator.prototype.interpolateToVec = function interpolateToVec (v0, v1, v2, v3, t, vec) { - vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension); - vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension); - vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension); -}; -Interpolator.prototype.interpolatePosition = function interpolatePosition (v0, v1, v2, v3, pos, offset) { - for (var j = 0; j < this.m; ++j) { - var l = offset + j * 3; - var d = this.dt * j; - this.interpolateToArr(v0, v1, v2, v3, d, pos, l); - } -}; -Interpolator.prototype.interpolateTangent = function interpolateTangent (v0, v1, v2, v3, tan, offset) { - for (var j = 0; j < this.m; ++j) { - var d = this.dt * j; - var d1 = d - this.delta; - var d2 = d + this.delta; - var l = offset + j * 3; - // capping as a precaution - if (d1 < 0) - { d1 = 0; } - if (d2 > 1) - { d2 = 1; } - // - this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1); - this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2); - // - this.vec2.sub(this.vec1).normalize(); - this.vec2.toArray(tan, l); - } -}; -Interpolator.prototype.vectorSubdivide = function vectorSubdivide (interpolationFn, iterator, array, offset, isCyclic) { - var v0; - var v1 = iterator.next(); - var v2 = iterator.next(); - var v3 = iterator.next(); - // - var n = iterator.size; - var n1 = n - 1; - var k = offset || 0; - for (var i = 0; i < n1; ++i) { - v0 = v1; - v1 = v2; - v2 = v3; - v3 = iterator.next(); - interpolationFn.apply(this, [v0, v1, v2, v3, array, k]); - k += 3 * this.m; - } - if (isCyclic) { - v0 = iterator.get(n - 2); - v1 = iterator.get(n - 1); - v2 = iterator.get(0); - v3 = iterator.get(1); - interpolationFn.apply(this, [v0, v1, v2, v3, array, k]); - k += 3 * this.m; - } -}; -// -Interpolator.prototype.getPosition = function getPosition (iterator, array, offset, isCyclic) { - iterator.reset(); - this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic); - var n1 = iterator.size - 1; - var k = n1 * this.m * 3; - if (isCyclic) - { k += this.m * 3; } - var v = iterator.get(isCyclic ? 0 : n1); - array[k] = v.x; - array[k + 1] = v.y; - array[k + 2] = v.z; -}; -Interpolator.prototype.getTangent = function getTangent (iterator, array, offset, isCyclic) { - iterator.reset(); - this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic); - var n1 = iterator.size - 1; - var k = n1 * this.m * 3; - if (isCyclic) - { k += this.m * 3; } - copyArray(array, array, k - 3, k, 3); -}; -Interpolator.prototype.interpolateNormalDir = function interpolateNormalDir (u0, u1, u2, u3, v0, v1, v2, v3, tan, norm, bin, offset, shift) { - for (var j = 0; j < this.m; ++j) { - var l = offset + j * 3; - if (shift) - { l += this.m2 * 3; } - var d = this.dt * j; - this.interpolateToVec(u0, u1, u2, u3, d, this.vec1); - this.interpolateToVec(v0, v1, v2, v3, d, this.vec2); - this.vDir.subVectors(this.vec2, this.vec1).normalize(); - this.vTan.fromArray(tan, l); - this.vBin.crossVectors(this.vDir, this.vTan).normalize(); - this.vBin.toArray(bin, l); - this.vNorm.crossVectors(this.vTan, this.vBin).normalize(); - this.vNorm.toArray(norm, l); - } -}; -Interpolator.prototype.interpolateNormal = function interpolateNormal (vDir, tan, norm, bin, offset) { - for (var j = 0; j < this.m; ++j) { - var l = offset + j * 3; - vDir.copy(this.vNorm); - this.vTan.fromArray(tan, l); - this.vBin.crossVectors(vDir, this.vTan).normalize(); - this.vBin.toArray(bin, l); - this.vNorm.crossVectors(this.vTan, this.vBin).normalize(); - this.vNorm.toArray(norm, l); - } -}; -Interpolator.prototype.getNormal = function getNormal (size, tan, norm, bin, offset, isCyclic) { - this.vNorm.set(0, 0, 1); - var n = size; - var n1 = n - 1; - var k = offset || 0; - for (var i = 0; i < n1; ++i) { - this.interpolateNormal(this.vDir, tan, norm, bin, k); - k += 3 * this.m; - } - if (isCyclic) { - this.interpolateNormal(this.vDir, tan, norm, bin, k); - k += 3 * this.m; - } - this.vBin.toArray(bin, k); - this.vNorm.toArray(norm, k); -}; -Interpolator.prototype.getNormalDir = function getNormalDir (iterDir1, iterDir2, tan, norm, bin, offset, isCyclic, shift) { - iterDir1.reset(); - iterDir2.reset(); - // - var vSub1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vSub2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vSub3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vSub4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - // - var d1v1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var d1v2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(iterDir1.next()); - var d1v3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(iterDir1.next()); - var d1v4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(iterDir1.next()); - var d2v1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var d2v2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(iterDir2.next()); - var d2v3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(iterDir2.next()); - var d2v4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]().copy(iterDir2.next()); - // - this.vNorm.set(0, 0, 1); - var n = iterDir1.size; - var n1 = n - 1; - var k = offset || 0; - for (var i = 0; i < n1; ++i) { - d1v1.copy(d1v2); - d1v2.copy(d1v3); - d1v3.copy(d1v4); - d1v4.copy(iterDir1.next()); - d2v1.copy(d2v2); - d2v2.copy(d2v3); - d2v3.copy(d2v4); - d2v4.copy(iterDir2.next()); - // - if (i === 0) { - vSub1.subVectors(d2v1, d1v1); - vSub2.subVectors(d2v2, d1v2); - if (vSub1.dot(vSub2) < 0) { - vSub2.multiplyScalar(-1); - d2v2.addVectors(d1v2, vSub2); - } - vSub3.subVectors(d2v3, d1v3); - if (vSub2.dot(vSub3) < 0) { - vSub3.multiplyScalar(-1); - d2v3.addVectors(d1v3, vSub3); - } - } - else { - vSub3.copy(vSub4); - } - vSub4.subVectors(d2v4, d1v4); - if (vSub3.dot(vSub4) < 0) { - vSub4.multiplyScalar(-1); - d2v4.addVectors(d1v4, vSub4); - } - this.interpolateNormalDir(d1v1, d1v2, d1v3, d1v4, d2v1, d2v2, d2v3, d2v4, tan, norm, bin, k, shift); - k += 3 * this.m; - } - if (isCyclic) { - d1v1.copy(iterDir1.get(n - 2)); - d1v2.copy(iterDir1.get(n - 1)); - d1v3.copy(iterDir1.get(0)); - d1v4.copy(iterDir1.get(1)); - d2v1.copy(iterDir2.get(n - 2)); - d2v2.copy(iterDir2.get(n - 1)); - d2v3.copy(iterDir2.get(0)); - d2v4.copy(iterDir2.get(1)); - // - vSub3.copy(vSub4); - vSub4.subVectors(d2v4, d1v4); - if (vSub3.dot(vSub4) < 0) { - vSub4.multiplyScalar(-1); - d2v4.addVectors(d1v4, vSub4); - } - this.interpolateNormalDir(d1v1, d1v2, d1v3, d1v4, d2v1, d2v2, d2v3, d2v4, tan, norm, bin, k, shift); - k += 3 * this.m; - } - if (shift) { - // FIXME shift requires data from one this.more preceeding residue - this.vBin.fromArray(bin, this.m2 * 3); - this.vNorm.fromArray(norm, this.m2 * 3); - for (var j = 0; j < this.m2; ++j) { - this.vBin.toArray(bin, j * 3); - this.vNorm.toArray(norm, j * 3); - } - } - else { - this.vBin.toArray(bin, k); - this.vNorm.toArray(norm, k); - } -}; -// -Interpolator.prototype.interpolateColor = function interpolateColor (item1, item2, colFn, col, offset) { - var j, l; - for (j = 0; j < this.m2; ++j) { - l = offset + j * 3; - colFn.apply(this, [item1, col, l]); // itemColorToArray - } - for (j = this.m2; j < this.m; ++j) { - l = offset + j * 3; - colFn.apply(this, [item2, col, l]); // itemColorToArray - } -}; -Interpolator.prototype.getColor = function getColor (iterator, colFn, col, offset, isCyclic) { - iterator.reset(); - iterator.next(); // first element not needed - var i0; - var i1 = iterator.next(); - // - var n = iterator.size; - var n1 = n - 1; - var k = offset || 0; - for (var i = 0; i < n1; ++i) { - i0 = i1; - i1 = iterator.next(); - this.interpolateColor(i0, i1, colFn, col, k); - k += 3 * this.m; - } - if (isCyclic) { - i0 = iterator.get(n - 1); - i1 = iterator.get(0); - this.interpolateColor(i0, i1, colFn, col, k); - k += 3 * this.m; - } - // - col[k] = col[k - 3]; - col[k + 1] = col[k - 2]; - col[k + 2] = col[k - 1]; -}; -// -Interpolator.prototype.interpolatePicking = function interpolatePicking (item1, item2, pickFn, pick, offset) { - var j; - for (j = 0; j < this.m2; ++j) { - pick[offset + j] = pickFn.apply(this, [item1]); - } - for (j = this.m2; j < this.m; ++j) { - pick[offset + j] = pickFn.apply(this, [item2]); - } -}; -Interpolator.prototype.getPicking = function getPicking (iterator, pickFn, pick, offset, isCyclic) { - iterator.reset(); - iterator.next(); // first element not needed - var i0; - var i1 = iterator.next(); - // - var n = iterator.size; - var n1 = n - 1; - var k = offset || 0; - for (var i = 0; i < n1; ++i) { - i0 = i1; - i1 = iterator.next(); - this.interpolatePicking(i0, i1, pickFn, pick, k); - k += this.m; - } - if (isCyclic) { - i0 = iterator.get(n - 1); - i1 = iterator.get(0); - this.interpolatePicking(i0, i1, pickFn, pick, k); - k += this.m; - } - // - pick[k] = pick[k - 1]; -}; -// -Interpolator.prototype.interpolateSize = function interpolateSize (item1, item2, sizeFn, size, offset) { - var s1 = sizeFn.apply(this, [item1]); - var s2 = sizeFn.apply(this, [item2]); - for (var j = 0; j < this.m; ++j) { - // linear interpolation - var t = j / this.m; - size[offset + j] = (1 - t) * s1 + t * s2; - } -}; -Interpolator.prototype.getSize = function getSize (iterator, sizeFn, size, offset, isCyclic) { - iterator.reset(); - iterator.next(); // first element not needed - var i0; - var i1 = iterator.next(); - // - var n = iterator.size; - var n1 = n - 1; - var k = offset || 0; - for (var i = 0; i < n1; ++i) { - i0 = i1; - i1 = iterator.next(); - this.interpolateSize(i0, i1, sizeFn, size, k); - k += this.m; - } - if (isCyclic) { - i0 = iterator.get(n - 1); - i1 = iterator.get(0); - this.interpolateSize(i0, i1, sizeFn, size, k); - k += this.m; - } - // - size[k] = size[k - 1]; -}; -var Spline = function Spline(polymer, params) { - this.polymer = polymer; - this.size = polymer.residueCount; - var p = params || {}; - this.directional = p.directional || false; - this.positionIterator = p.positionIterator || false; - this.subdiv = p.subdiv || 1; - this.smoothSheet = p.smoothSheet || false; - if (!p.tension) { - this.tension = this.polymer.isNucleic() ? 0.5 : 0.9; - } - else { - this.tension = p.tension; - } - this.interpolator = new Interpolator(this.subdiv, this.tension); -}; -Spline.prototype.getAtomIterator = function getAtomIterator (type, smooth) { - var polymer = this.polymer; - var structure = polymer.structure; - var n = polymer.residueCount; - var i = 0; - var j = -1; - var cache = [ - structure.getAtomProxy(), - structure.getAtomProxy(), - structure.getAtomProxy(), - structure.getAtomProxy() - ]; - var cache2 = [ - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](), - new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]() - ]; - function next() { - var atomProxy = get(j); - j += 1; - return atomProxy; - } - var apPrev = structure.getAtomProxy(); - var apNext = structure.getAtomProxy(); - function get(idx) { - var atomProxy = cache[i % 4]; - atomProxy.index = polymer.getAtomIndexByType(idx, type); - if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') { - var vec = cache2[i % 4]; - apPrev.index = polymer.getAtomIndexByType(idx + 1, type); - apNext.index = polymer.getAtomIndexByType(idx - 1, type); - vec.addVectors(apPrev, apNext) - .add(atomProxy).add(atomProxy) - .multiplyScalar(0.25); - i += 1; - return vec; - } - i += 1; - return atomProxy; - } - function reset() { - i = 0; - j = -1; - } - return { - size: n, - next: next, - get: get, - reset: reset - }; -}; -Spline.prototype.getSubdividedColor = function getSubdividedColor (params) { - var m = this.subdiv; - var polymer = this.polymer; - var n = polymer.residueCount; - var n1 = n - 1; - var nCol = n1 * m * 3 + 3; - if (polymer.isCyclic) - { nCol += m * 3; } - var col = new Float32Array(nCol); - var iterator = this.getAtomIterator('trace'); - var p = params || {}; - p.structure = polymer.structure; - var colormaker = ColormakerRegistry$1.getScheme(p); - function colFn(item, array, offset) { - colormaker.atomColorToArray(item, array, offset); - } - this.interpolator.getColor(iterator, colFn, col, 0, polymer.isCyclic); - return { - 'color': col - }; -}; -Spline.prototype.getSubdividedPicking = function getSubdividedPicking () { - var m = this.subdiv; - var polymer = this.polymer; - var n = polymer.residueCount; - var n1 = n - 1; - var nCol = n1 * m + 1; - if (polymer.isCyclic) - { nCol += m; } - var structure = polymer.structure; - var iterator = this.getAtomIterator('trace'); - var pick = new Float32Array(nCol); - function pickFn(item) { - return item.index; - } - this.interpolator.getPicking(iterator, pickFn, pick, 0, polymer.isCyclic); - return { - 'picking': new AtomPicker(pick, structure) - }; -}; -Spline.prototype.getSubdividedPosition = function getSubdividedPosition () { - var pos = this.getPosition(); - return { - 'position': pos - }; -}; -Spline.prototype.getSubdividedOrientation = function getSubdividedOrientation () { - var tan = this.getTangent(); - var normals = this.getNormals(tan); - return { - 'tangent': tan, - 'normal': normals.normal, - 'binormal': normals.binormal - }; -}; -Spline.prototype.getSubdividedSize = function getSubdividedSize (params) { - var m = this.subdiv; - var polymer = this.polymer; - var n = polymer.residueCount; - var n1 = n - 1; - var nSize = n1 * m + 1; - if (polymer.isCyclic) - { nSize += m; } - var size = new Float32Array(nSize); - var iterator = this.getAtomIterator('trace'); - var radiusFactory = new RadiusFactory(params); - function sizeFn(item) { - return radiusFactory.atomRadius(item); - } - this.interpolator.getSize(iterator, sizeFn, size, 0, polymer.isCyclic); - return { - 'size': size - }; -}; -Spline.prototype.getPosition = function getPosition () { - var m = this.subdiv; - var polymer = this.polymer; - var n = polymer.residueCount; - var n1 = n - 1; - var nPos = n1 * m * 3 + 3; - if (polymer.isCyclic) - { nPos += m * 3; } - var pos = new Float32Array(nPos); - var iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet); - this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic); - return pos; -}; -Spline.prototype.getTangent = function getTangent () { - var m = this.subdiv; - var polymer = this.polymer; - var n = this.size; - var n1 = n - 1; - var nTan = n1 * m * 3 + 3; - if (polymer.isCyclic) - { nTan += m * 3; } - var tan = new Float32Array(nTan); - var iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet); - this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic); - return tan; -}; -Spline.prototype.getNormals = function getNormals (tan) { - var m = this.subdiv; - var polymer = this.polymer; - var isProtein = polymer.isProtein(); - var n = this.size; - var n1 = n - 1; - var nNorm = n1 * m * 3 + 3; - if (polymer.isCyclic) - { nNorm += m * 3; } - var norm = new Float32Array(nNorm); - var bin = new Float32Array(nNorm); - if (this.directional && !this.polymer.isCg()) { - var iterDir1 = this.getAtomIterator('direction1'); - var iterDir2 = this.getAtomIterator('direction2'); - this.interpolator.getNormalDir(iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein); - } - else { - this.interpolator.getNormal(n, tan, norm, bin, 0, polymer.isCyclic); - } - return { - 'normal': norm, - 'binormal': bin - }; -}; - -/** - * @file Tube Mesh Buffer - * @author Alexander Rose - * @private - */ -var vTangent = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var vMeshNormal = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var TubeMeshBufferDefaultParameters = Object.assign({ - radialSegments: 4, - capped: false, - aspectRatio: 1.0 -}, BufferDefaultParameters); -function getData$2(data, params) { - if ( params === void 0 ) params = {}; - - var radialSegments = defaults(params.radialSegments, 4); - var capped = defaults(params.capped, false); - var capVertices = capped ? radialSegments : 0; - var capTriangles = capped ? radialSegments - 2 : 0; - var n = data.position.length / 3; - var n1 = n - 1; - var x = n * radialSegments * 3 + 2 * capVertices * 3; - var xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3; - return { - position: new Float32Array(x), - color: new Float32Array(x), - index: getUintArray(xi, x / 3), - normal: new Float32Array(x), - picking: data.picking - }; -} -/** - * Tube mesh buffer. Draws a tube. - */ -var TubeMeshBuffer = /*@__PURE__*/(function (MeshBuffer$$1) { - function TubeMeshBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MeshBuffer$$1.call(this, getData$2(data, params), params); - this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0; - this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0; - this.size2 = data.position.length / 3; - data.primitiveId = serialArray(this.size2); - this.setAttributes(data); - this.makeIndex(); - } - - if ( MeshBuffer$$1 ) TubeMeshBuffer.__proto__ = MeshBuffer$$1; - TubeMeshBuffer.prototype = Object.create( MeshBuffer$$1 && MeshBuffer$$1.prototype ); - TubeMeshBuffer.prototype.constructor = TubeMeshBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return TubeMeshBufferDefaultParameters; }; - TubeMeshBuffer.prototype.setAttributes = function setAttributes (data) { - if ( data === void 0 ) data = {}; - - var aspectRatio = this.parameters.aspectRatio; - var n = this.size2; - var n1 = n - 1; - var radialSegments = this.parameters.radialSegments; - var attributes = this.geometry.attributes; - var position, normal, binormal, tangent, color, size, primitiveId; - var meshPosition, meshColor, meshNormal, meshPrimitiveId; - if (data.position) { - position = data.position; - normal = data.normal; - binormal = data.binormal; - tangent = data.tangent; - size = data.size; - meshPosition = attributes.position.array; - meshNormal = attributes.normal.array; - attributes.position.needsUpdate = true; - attributes.normal.needsUpdate = true; - } - if (data.color) { - color = data.color; - meshColor = attributes.color.array; - attributes.color.needsUpdate = true; - } - if (data.primitiveId) { - primitiveId = data.primitiveId; - meshPrimitiveId = attributes.primitiveId.array; - attributes.primitiveId.needsUpdate = true; - } - var k, l; - var radius = 0; - var normX = 0; - var normY = 0; - var normZ = 0; - var biX = 0; - var biY = 0; - var biZ = 0; - var posX = 0; - var posY = 0; - var posZ = 0; - var cxArr = []; - var cyArr = []; - var cx1Arr = []; - var cy1Arr = []; - var cx2Arr = []; - var cy2Arr = []; - if (position) { - for (var j = 0; j < radialSegments; ++j) { - var v = (j / radialSegments) * 2 * Math.PI; - cxArr[j] = aspectRatio * Math.cos(v); - cyArr[j] = Math.sin(v); - cx1Arr[j] = aspectRatio * Math.cos(v - 0.01); - cy1Arr[j] = Math.sin(v - 0.01); - cx2Arr[j] = aspectRatio * Math.cos(v + 0.01); - cy2Arr[j] = Math.sin(v + 0.01); - } - } - for (var i = 0; i < n; ++i) { - k = i * 3; - l = k * radialSegments; - if (position && tangent && normal && binormal && size) { - vTangent.set(tangent[k], tangent[k + 1], tangent[k + 2]); - normX = normal[k]; - normY = normal[k + 1]; - normZ = normal[k + 2]; - biX = binormal[k]; - biY = binormal[k + 1]; - biZ = binormal[k + 2]; - posX = position[k]; - posY = position[k + 1]; - posZ = position[k + 2]; - radius = size[i]; - } - for (var j$1 = 0; j$1 < radialSegments; ++j$1) { - var s = l + j$1 * 3; - if (position) { - var cx = -radius * cxArr[j$1]; // TODO: Hack: Negating it so it faces outside. - var cy = radius * cyArr[j$1]; - var cx1 = -radius * cx1Arr[j$1]; - var cy1 = radius * cy1Arr[j$1]; - var cx2 = -radius * cx2Arr[j$1]; - var cy2 = radius * cy2Arr[j$1]; - meshPosition[s] = posX + cx * normX + cy * biX; - meshPosition[s + 1] = posY + cx * normY + cy * biY; - meshPosition[s + 2] = posZ + cx * normZ + cy * biZ; - // TODO half of these are symmetric - vMeshNormal.set( - // ellipse tangent approximated as vector from/to adjacent points - (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX), (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY), (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)).cross(vTangent); - meshNormal[s] = vMeshNormal.x; - meshNormal[s + 1] = vMeshNormal.y; - meshNormal[s + 2] = vMeshNormal.z; - } - if (color) { - meshColor[s] = color[k]; - meshColor[s + 1] = color[k + 1]; - meshColor[s + 2] = color[k + 2]; - } - if (primitiveId) { - meshPrimitiveId[i * radialSegments + j$1] = primitiveId[i]; - } - } - } - // front cap - k = 0; - l = n * 3 * radialSegments; - for (var j$2 = 0; j$2 < radialSegments; ++j$2) { - var s$1 = k + j$2 * 3; - var t = l + j$2 * 3; - if (position && tangent) { - meshPosition[t] = meshPosition[s$1]; - meshPosition[t + 1] = meshPosition[s$1 + 1]; - meshPosition[t + 2] = meshPosition[s$1 + 2]; - meshNormal[t] = tangent[k]; - meshNormal[t + 1] = tangent[k + 1]; - meshNormal[t + 2] = tangent[k + 2]; - } - if (color) { - meshColor[t] = meshColor[s$1]; - meshColor[t + 1] = meshColor[s$1 + 1]; - meshColor[t + 2] = meshColor[s$1 + 2]; - } - if (primitiveId) { - meshPrimitiveId[n * radialSegments + j$2] = meshPrimitiveId[0 + j$2]; - } - } - // back cap - k = (n - 1) * 3 * radialSegments; - l = (n + 1) * 3 * radialSegments; - for (var j$3 = 0; j$3 < radialSegments; ++j$3) { - var s$2 = k + j$3 * 3; - var t$1 = l + j$3 * 3; - if (position && tangent) { - meshPosition[t$1] = meshPosition[s$2]; - meshPosition[t$1 + 1] = meshPosition[s$2 + 1]; - meshPosition[t$1 + 2] = meshPosition[s$2 + 2]; - meshNormal[t$1] = tangent[n1 * 3]; - meshNormal[t$1 + 1] = tangent[n1 * 3 + 1]; - meshNormal[t$1 + 2] = tangent[n1 * 3 + 2]; - } - if (color) { - meshColor[t$1] = meshColor[s$2]; - meshColor[t$1 + 1] = meshColor[s$2 + 1]; - meshColor[t$1 + 2] = meshColor[s$2 + 2]; - } - if (primitiveId) { - meshPrimitiveId[(n + 1) * radialSegments + j$3] = meshPrimitiveId[(n - 1) * radialSegments + j$3]; - } - } - }; - TubeMeshBuffer.prototype.makeIndex = function makeIndex () { - var index = this.geometry.getIndex(); - if (!index) { - Log.error('Index is null'); - return; - } - var meshIndex = index.array; - var n = this.size2; - var n1 = n - 1; - var capTriangles = this.capTriangles; - var radialSegments = this.parameters.radialSegments; - var radialSegments1 = this.parameters.radialSegments + 1; - var k, l; - for (var i = 0; i < n1; ++i) { - var k$1 = i * radialSegments * 3 * 2; - var irs = i * radialSegments; - var irs1 = (i + 1) * radialSegments; - for (var j = 0; j < radialSegments; ++j) { - l = k$1 + j * 3 * 2; - // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments ); - meshIndex[l] = irs + j; - meshIndex[l + 1] = irs + ((j + 1) % radialSegments); - // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments ); - meshIndex[l + 2] = irs1 + j; - // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments ); - meshIndex[l + 3] = irs1 + j; - meshIndex[l + 4] = irs + ((j + 1) % radialSegments); - meshIndex[l + 5] = irs1 + ((j + 1) % radialSegments); - } - } - // capping - var strip = [0]; - for (var j$1 = 1; j$1 < radialSegments1 / 2; ++j$1) { - strip.push(j$1); - if (radialSegments - j$1 !== j$1) { - strip.push(radialSegments - j$1); - } - } - // front cap - l = n1 * radialSegments * 3 * 2; - k = n * radialSegments; - for (var j$2 = 0; j$2 < strip.length - 2; ++j$2) { - if (j$2 % 2 === 0) { - meshIndex[l + j$2 * 3 + 0] = k + strip[j$2 + 0]; - meshIndex[l + j$2 * 3 + 1] = k + strip[j$2 + 1]; - meshIndex[l + j$2 * 3 + 2] = k + strip[j$2 + 2]; - } - else { - meshIndex[l + j$2 * 3 + 0] = k + strip[j$2 + 2]; - meshIndex[l + j$2 * 3 + 1] = k + strip[j$2 + 1]; - meshIndex[l + j$2 * 3 + 2] = k + strip[j$2 + 0]; - } - } - // back cap - l = n1 * radialSegments * 3 * 2 + 3 * capTriangles; - k = n * radialSegments + radialSegments; - for (var j$3 = 0; j$3 < strip.length - 2; ++j$3) { - if (j$3 % 2 === 0) { - meshIndex[l + j$3 * 3 + 0] = k + strip[j$3 + 0]; - meshIndex[l + j$3 * 3 + 1] = k + strip[j$3 + 1]; - meshIndex[l + j$3 * 3 + 2] = k + strip[j$3 + 2]; - } - else { - meshIndex[l + j$3 * 3 + 0] = k + strip[j$3 + 2]; - meshIndex[l + j$3 * 3 + 1] = k + strip[j$3 + 1]; - meshIndex[l + j$3 * 3 + 2] = k + strip[j$3 + 0]; - } - } - }; - - Object.defineProperties( TubeMeshBuffer.prototype, prototypeAccessors ); - - return TubeMeshBuffer; -}(MeshBuffer)); - -/** - * @file Cartoon Representation - * @author Alexander Rose - * @private - */ -/** - * Cartoon representation. Show a thick ribbon that - * smoothly connecting backbone atoms in polymers. - * - * __Name:__ _cartoon_ - * - * @example - * stage.loadFile( "rcsb://1crn" ).then( function( o ){ - * o.addRepresentation( "cartoon" ); - * o.autoView(); - * } ); - */ -var CartoonRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function CartoonRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'cartoon'; - this.parameters = Object.assign({ - aspectRatio: { - type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true - }, - subdiv: { - type: 'integer', max: 50, min: 1, rebuild: true - }, - radialSegments: { - type: 'integer', max: 50, min: 1, rebuild: true - }, - tension: { - type: 'number', precision: 1, max: 1.0, min: 0.1 - }, - capped: { - type: 'boolean', rebuild: true - }, - smoothSheet: { - type: 'boolean', rebuild: true - } - }, this.parameters); - this.init(params); - } - - if ( StructureRepresentation$$1 ) CartoonRepresentation.__proto__ = StructureRepresentation$$1; - CartoonRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - CartoonRepresentation.prototype.constructor = CartoonRepresentation; - CartoonRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'chainname'); - p.colorScale = defaults(p.colorScale, 'RdYlBu'); - p.radiusType = defaults(p.radiusType, 'sstruc'); - p.radiusScale = defaults(p.radiusScale, 0.7); - p.useInteriorColor = defaults(p.useInteriorColor, true); - this.aspectRatio = defaults(p.aspectRatio, 5.0); - this.tension = defaults(p.tension, NaN); - this.capped = defaults(p.capped, true); - this.smoothSheet = defaults(p.smoothSheet, false); - if (p.quality === 'low') { - this.subdiv = 3; - this.radialSegments = 6; - } - else if (p.quality === 'medium') { - this.subdiv = 6; - } - else if (p.quality === 'high') { - this.subdiv = 12; - } - else { - this.subdiv = defaults(p.subdiv, 6); - } - StructureRepresentation$$1.prototype.init.call(this, p); - }; - CartoonRepresentation.prototype.getSplineParams = function getSplineParams (params) { - return Object.assign({ - subdiv: this.subdiv, - tension: this.tension, - directional: this.aspectRatio !== 1.0, - smoothSheet: this.smoothSheet - }, params); - }; - CartoonRepresentation.prototype.getSpline = function getSpline (polymer) { - return new Spline(polymer, this.getSplineParams()); - }; - CartoonRepresentation.prototype.getAspectRatio = function getAspectRatio (polymer) { - return polymer.isCg() ? 1.0 : this.aspectRatio; - }; - CartoonRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - return atom.isTrace() ? StructureRepresentation$$1.prototype.getAtomRadius.call(this, atom) : 0; - }; - CartoonRepresentation.prototype.createData = function createData (sview) { - var this$1 = this; - - var bufferList = []; - var polymerList = []; - this.structure.eachPolymer(function (polymer) { - if (polymer.residueCount < 4) - { return; } - polymerList.push(polymer); - var spline = this$1.getSpline(polymer); - var aspectRatio = this$1.getAspectRatio(polymer); - var subPos = spline.getSubdividedPosition(); - var subOri = spline.getSubdividedOrientation(); - var subCol = spline.getSubdividedColor(this$1.getColorParams()); - var subPick = spline.getSubdividedPicking(); - var subSize = spline.getSubdividedSize(this$1.getRadiusParams()); - bufferList.push(new TubeMeshBuffer(Object.assign({}, subPos, subOri, subCol, subPick, subSize), this$1.getBufferParams({ - radialSegments: this$1.radialSegments, - aspectRatio: aspectRatio, - capped: this$1.capped - }))); - }, sview.getSelection()); - return { - bufferList: bufferList, - polymerList: polymerList - }; - }; - CartoonRepresentation.prototype.updateData = function updateData (what, data) { - if (Debug) - { Log.time(this.type + ' repr update'); } - what = what || {}; - for (var i = 0, il = data.polymerList.length; i < il; ++i) { - var bufferData = {}; - var polymer = data.polymerList[i]; - var spline = this.getSpline(polymer); - var aspectRatio = this.getAspectRatio(polymer); - Object.assign(data.bufferList[i], { aspectRatio: aspectRatio }); - if (what.position || what.radius) { - var subPos = spline.getSubdividedPosition(); - var subOri = spline.getSubdividedOrientation(); - var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio)); - bufferData.position = subPos.position; - bufferData.normal = subOri.normal; - bufferData.binormal = subOri.binormal; - bufferData.tangent = subOri.tangent; - bufferData.size = subSize.size; - } - if (what.color) { - var subCol = spline.getSubdividedColor(this.getColorParams()); - bufferData.color = subCol.color; - } - if (what.picking) { - var subPick = spline.getSubdividedPicking(); - bufferData.picking = subPick.picking; - } - data.bufferList[i].setAttributes(bufferData); - } - if (Debug) - { Log.timeEnd(this.type + ' repr update'); } - }; - CartoonRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - if (params && params.aspectRatio) { - what.radius = true; - } - if (params && params.tension) { - what.position = true; - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - - return CartoonRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('cartoon', CartoonRepresentation); - -/** - * @file Contact Representation - * @author Alexander Rose - * @private - */ -/** - * Contact representation. - */ -var ContactRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function ContactRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'contact'; - this.parameters = Object.assign({ - hydrogenBond: { - type: 'boolean', rebuild: true - }, - weakHydrogenBond: { - type: 'boolean', rebuild: true - }, - waterHydrogenBond: { - type: 'boolean', rebuild: true - }, - backboneHydrogenBond: { - type: 'boolean', rebuild: true - }, - hydrophobic: { - type: 'boolean', rebuild: true - }, - halogenBond: { - type: 'boolean', rebuild: true - }, - ionicInteraction: { - type: 'boolean', rebuild: true - }, - metalCoordination: { - type: 'boolean', rebuild: true - }, - cationPi: { - type: 'boolean', rebuild: true - }, - piStacking: { - type: 'boolean', rebuild: true - }, - filterSele: { - type: 'text', rebuild: true - }, - labelVisible: { - type: 'boolean', rebuild: true - }, - labelFixedSize: { - type: 'boolean', buffer: 'fixedSize' - }, - labelSize: { - type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true - }, - labelUnit: { - type: 'select', - rebuild: true, - options: { '': '', angstrom: 'angstrom', nm: 'nm' } - }, - maxHydrophobicDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxHbondDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxHbondSulfurDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxHbondAccAngle: { - type: 'integer', max: 180, min: 0, rebuild: true - }, - maxHbondDonAngle: { - type: 'integer', max: 180, min: 0, rebuild: true - }, - maxHbondAccPlaneAngle: { - type: 'integer', max: 90, min: 0, rebuild: true - }, - maxHbondDonPlaneAngle: { - type: 'integer', max: 90, min: 0, rebuild: true - }, - maxPiStackingDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxPiStackingOffset: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxPiStackingAngle: { - type: 'integer', max: 180, min: 0, rebuild: true - }, - maxCationPiDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxCationPiOffset: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxIonicDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxHalogenBondDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - maxHalogenBondAngle: { - type: 'integer', max: 180, min: 0, rebuild: true - }, - maxMetalDist: { - type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true - }, - refineSaltBridges: { - type: 'boolean', rebuild: true - }, - masterModelIndex: { - type: 'integer', max: 1000, min: -1, rebuild: true - }, - lineOfSightDistFactor: { - type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true - }, - radialSegments: true, - disableImpostor: true - }, this.parameters); - this.init(params); - } - - if ( StructureRepresentation$$1 ) ContactRepresentation.__proto__ = StructureRepresentation$$1; - ContactRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - ContactRepresentation.prototype.constructor = ContactRepresentation; - ContactRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.radiusSize = defaults(p.radiusSize, 0.05); - p.useInteriorColor = defaults(p.useInteriorColor, true); - this.hydrogenBond = defaults(p.hydrogenBond, true); - this.weakHydrogenBond = defaults(p.weakHydrogenBond, false); - this.waterHydrogenBond = defaults(p.waterHydrogenBond, false); - this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false); - this.hydrophobic = defaults(p.hydrophobic, false); - this.halogenBond = defaults(p.halogenBond, true); - this.ionicInteraction = defaults(p.ionicInteraction, true); - this.metalCoordination = defaults(p.metalCoordination, true); - this.cationPi = defaults(p.cationPi, true); - this.piStacking = defaults(p.piStacking, true); - this.filterSele = defaults(p.filterSele, ''); - this.labelVisible = defaults(p.labelVisible, false); - this.labelFixedSize = defaults(p.labelFixedSize, false); - this.labelSize = defaults(p.labelSize, 2.0); - this.labelUnit = defaults(p.labelUnit, ''); - this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0); - this.maxHbondDist = defaults(p.maxHbondDist, 3.5); - this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1); - this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45); - this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45); - this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90); - this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30); - this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5); - this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0); - this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30); - this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0); - this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0); - this.maxIonicDist = defaults(p.maxIonicDist, 5.0); - this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5); - this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30); - this.maxMetalDist = defaults(p.maxMetalDist, 3.0); - this.refineSaltBridges = defaults(p.refineSaltBridges, true); - this.masterModelIndex = defaults(p.masterModelIndex, -1); - this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - ContactRepresentation.prototype.getAtomRadius = function getAtomRadius () { - return 0; - }; - ContactRepresentation.prototype.getContactData = function getContactData$1 (sview) { - var params = { - maxHydrophobicDist: this.maxHydrophobicDist, - maxHbondDist: this.maxHbondDist, - maxHbondSulfurDist: this.maxHbondSulfurDist, - maxHbondAccAngle: this.maxHbondAccAngle, - maxHbondDonAngle: this.maxHbondDonAngle, - maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle, - maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle, - maxPiStackingDist: this.maxPiStackingDist, - maxPiStackingOffset: this.maxPiStackingOffset, - maxPiStackingAngle: this.maxPiStackingAngle, - maxCationPiDist: this.maxCationPiDist, - maxCationPiOffset: this.maxCationPiOffset, - maxIonicDist: this.maxIonicDist, - maxHalogenBondDist: this.maxHalogenBondDist, - maxHalogenBondAngle: this.maxHalogenBondAngle, - maxMetalDist: this.maxMetalDist, - refineSaltBridges: this.refineSaltBridges, - masterModelIndex: this.masterModelIndex, - lineOfSightDistFactor: this.lineOfSightDistFactor - }; - var dataParams = { - hydrogenBond: this.hydrogenBond, - weakHydrogenBond: this.weakHydrogenBond, - waterHydrogenBond: this.waterHydrogenBond, - backboneHydrogenBond: this.backboneHydrogenBond, - hydrophobic: this.hydrophobic, - halogenBond: this.halogenBond, - ionicInteraction: this.ionicInteraction, - metalCoordination: this.metalCoordination, - cationPi: this.cationPi, - piStacking: this.piStacking, - radius: this.radiusSize * this.radiusScale, - filterSele: this.filterSele - }; - var contacts = calculateContacts(sview, params); - return getContactData(contacts, sview, dataParams); - }; - ContactRepresentation.prototype.createData = function createData (sview) { - var contactData = this.getContactData(sview); - var bufferList = [ - new CylinderBuffer(getFixedCountDashData(contactData), this.getBufferParams({ - sphereDetail: 1, - dullInterior: true, - disableImpostor: this.disableImpostor - })) - ]; - if (this.labelVisible) { - var labelParams = { - size: this.labelSize, - unit: this.labelUnit - }; - bufferList.push(new TextBuffer(getLabelData(contactData, labelParams), this.getBufferParams({ fixedSize: this.labelFixedSize }))); - } - return { bufferList: bufferList }; - }; - - return ContactRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('contact', ContactRepresentation); - -/** - * @file Dihedral Representation - * @author Fred Ludlow - * @private - */ -/** - * Dihedral representation object - * - * Reperesentation consists of three parts, visibility can be set for each - * label - text label indicating dihedral angle - * line - line indicating four positions that define the dihedral - * sector - filled arc section - * - * @param {Structure} structure - the structure to measure angles in - * @param {Viewer} viewer - a viewer object - * @param {AngleRepresentationParameters} params - angle representation parameters - */ -var DihedralRepresentation = /*@__PURE__*/(function (MeasurementRepresentation$$1) { - function DihedralRepresentation(structure, viewer, params) { - MeasurementRepresentation$$1.call(this, structure, viewer, params); - this.type = 'dihedral'; - this.parameters = Object.assign({ - atomQuad: { - type: 'hidden', rebuild: true - }, - extendLine: { - type: 'boolean', rebuild: true, default: true - }, - lineVisible: { - type: 'boolean', default: true - }, - planeVisible: { - type: 'boolean', default: true - }, - sectorVisible: { - type: 'boolean', default: true - } - }, this.parameters); - this.init(params); - } - - if ( MeasurementRepresentation$$1 ) DihedralRepresentation.__proto__ = MeasurementRepresentation$$1; - DihedralRepresentation.prototype = Object.create( MeasurementRepresentation$$1 && MeasurementRepresentation$$1.prototype ); - DihedralRepresentation.prototype.constructor = DihedralRepresentation; - DihedralRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.side = defaults(p.side, 'double'); - p.opacity = defaults(p.opacity, 0.5); - this.atomQuad = defaults(p.atomQuad, []); - this.extendLine = defaults(p.extendLine, true); - this.lineVisible = defaults(p.lineVisible, true); - this.planeVisible = defaults(p.planeVisible, true); - this.sectorVisible = defaults(p.sectorVisible, true); - MeasurementRepresentation$$1.prototype.init.call(this, p); - }; - DihedralRepresentation.prototype.createData = function createData (sview) { - if (!sview.atomCount || !this.atomQuad.length) - { return; } - var atomPosition = parseNestedAtoms(sview, this.atomQuad); - var dihedralData = getDihedralData(atomPosition, { - extendLine: this.extendLine - }); - var n = this.n = dihedralData.labelText.length; - var labelColor = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.labelColor); - this.textBuffer = new TextBuffer({ - position: dihedralData.labelPosition, - size: uniformArray(n, this.labelSize), - color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b), - text: dihedralData.labelText - }, this.getLabelBufferParams()); - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.colorValue); - this.lineLength = dihedralData.linePosition1.length / 3; - var lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b); - this.lineBuffer = new WideLineBuffer(getFixedLengthWrappedDashData({ - position1: dihedralData.linePosition1, - position2: dihedralData.linePosition2, - color: lineColor, - color2: lineColor - }), this.getBufferParams({ - linewidth: this.linewidth, - visible: this.lineVisible, - opacity: this.lineOpacity - })); - this.planeLength = dihedralData.planePosition.length / 3; - this.planeBuffer = new MeshBuffer({ - position: dihedralData.planePosition, - color: uniformArray3(this.planeLength, c.r, c.g, c.b) - }, this.getBufferParams({ - visible: this.planeVisible - })); - this.sectorLength = dihedralData.sectorPosition.length / 3; - this.sectorBuffer = new MeshBuffer({ - position: dihedralData.sectorPosition, - color: uniformArray3(this.sectorLength, c.r, c.g, c.b) - }, this.getBufferParams({ - visible: this.sectorVisible - })); - return { - bufferList: [ - this.textBuffer, - this.lineBuffer, - this.planeBuffer, - this.sectorBuffer - ] - }; - }; - DihedralRepresentation.prototype.updateData = function updateData (what, data) { - MeasurementRepresentation$$1.prototype.updateData.call(this, what, data); - var lineData = {}; - var planeData = {}; - var sectorData = {}; - if (what.color) { - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.colorValue); - Object.assign(lineData, { - color: uniformArray3(this.lineLength, c.r, c.g, c.b), - color2: uniformArray3(this.lineLength, c.r, c.g, c.b) - }); - Object.assign(planeData, { - color: uniformArray3(this.planeLength, c.r, c.g, c.b) - }); - Object.assign(sectorData, { - color: uniformArray3(this.sectorLength, c.r, c.g, c.b) - }); - } - this.lineBuffer.setAttributes(lineData); - this.planeBuffer.setAttributes(planeData); - this.sectorBuffer.setAttributes(sectorData); - }; - DihedralRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - MeasurementRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - if (params && (params.lineVisible !== undefined || - params.sectorVisible !== undefined || - params.planeVisible !== undefined)) { - this.setVisibility(this.visible); - } - if (params && params.lineOpacity) { - this.lineBuffer.setParameters({ opacity: params.lineOpacity }); - } - if (params && params.opacity !== undefined) { - this.lineBuffer.setParameters({ opacity: this.lineOpacity }); - } - if (params && params.linewidth) { - this.lineBuffer.setParameters({ linewidth: params.linewidth }); - } - return this; - }; - DihedralRepresentation.prototype.setVisibility = function setVisibility (value, noRenderRequest) { - MeasurementRepresentation$$1.prototype.setVisibility.call(this, value, true); - if (this.lineBuffer) { - this.lineBuffer.setVisibility(this.lineVisible && this.visible); - } - if (this.planeBuffer) { - this.planeBuffer.setVisibility(this.planeVisible && this.visible); - } - if (this.sectorBuffer) { - this.sectorBuffer.setVisibility(this.sectorVisible && this.visible); - } - if (!noRenderRequest) - { this.viewer.requestRender(); } - return this; - }; - - return DihedralRepresentation; -}(MeasurementRepresentation)); -/** - * Build the data required to create {Buffer} objects, given positions - * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates - * @return {Object} Arrays for building buffers - */ -function getDihedralData(position, params) { - if ( params === void 0 ) params = {}; - - var angleStep = defaults(params.angleStep, Math.PI / 90); - var nPos = position.length; - var n = position.length / 12; - var angles = new Float32Array(n); - var labelPosition = new Float32Array(n * 3); - var labelText = new Array(n); - // Temporary arrays as don't know output length yet - var lineTmp1 = new Array(n); - var lineTmp2 = new Array(n); - var sectorTmp = new Array(n); - var planeTmp = new Array(n); - // Eventual sizes of output arrays - var totalLines = 0; - var totalSegments = 0; - var totalPlanes = 0; - var p1 = v3new(); - var p2 = v3new(); - var p3 = v3new(); - var p4 = v3new(); - var v21 = v3new(); - var v23 = v3new(); - var v34 = v3new(); - var tmp = v3new(); - var mid = v3new(); - var inPlane1 = v3new(); - var inPlane2 = v3new(); - var start = v3new(); - var end = v3new(); - var cross = v3new(); - var arcPoint = v3new(); - var i = 0; // Actual output index (after skipping inappropriate) - var loop = function ( p ) { - // Set Positions - v3fromArray(p1, position, p); - v3fromArray(p2, position, p + 3); - v3fromArray(p3, position, p + 6); - v3fromArray(p4, position, p + 9); - // Vectors between points - v3sub(v21, p1, p2); - v3sub(v23, p3, p2); - if (v3length(v23) === 0.0) { - return; // Can't define axis - } - v3sub(v34, p4, p3); - v3multiplyScalar(tmp, v23, 0.5); - v3add(mid, p2, tmp); - v3normalize(v21, v21); - v3normalize(v23, v23); - v3normalize(v34, v34); - // Which side of plane are p1, p4 (are we measuring something that - // looks more like an improper? e.g. C, CA, CB, N) - v3sub(tmp, p1, mid); - var improperStart = v3dot(tmp, v23) > 0.0; - v3sub(tmp, p4, mid); - var improperEnd = v3dot(tmp, v23) < 0.0; - // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4)) - v3multiplyScalar(tmp, v23, v3dot(v23, v21)); - v3sub(inPlane1, v21, tmp); - v3multiplyScalar(tmp, v23, v3dot(v23, v34)); - v3sub(inPlane2, v34, tmp); - if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) { - return; // Indeterminate angle - } - v3normalize(inPlane1, inPlane1); - v3normalize(inPlane2, inPlane2); - // Can use acos as normalized and non-zero - var angle = angles[i] = Math.acos(v3dot(inPlane1, inPlane2)); - labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0); - v3cross(cross, inPlane1, v23); - v3normalize(cross, cross); - if (v3dot(cross, inPlane2) < 0.0) { - v3negate(cross, cross); // Ensure cp faces correct way - } - calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0); - v3toArray(tmp, labelPosition, 3 * i); - var nSegments = Math.ceil(angle / angleStep); - // For extended display mode, 4 straight lines plus arc/segment edge - // For non-extended, 2 straight lines plus segment edge - var nLines = nSegments + ((params.extendLine) ? 4 : 2); - // Don't draw planes if not extending lines - var nPlanes = params.extendLine ? 36 : 0; - var line1 = new Float32Array(nLines * 3); - var line2 = new Float32Array(nLines * 3); - var sector = new Float32Array(nSegments * 9); - // 2 planes, 2 triangles each per dihedral (2*2*9) - var plane = new Float32Array(nPlanes); - lineTmp1[i] = line1; - lineTmp2[i] = line2; - sectorTmp[i] = sector; - planeTmp[i] = plane; - // Start points for lines/planes, only required - // if extending lines - if (params.extendLine) { - if (improperStart) { // We'll start on the v3->1 line (tmp) - v3sub(tmp, p1, p3); - v3normalize(tmp, tmp); - v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp)); - v3add(start, start, p3); - } - else { // start on the 2->1 line - v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21)); - v3add(start, start, p2); - } - if (improperEnd) { // Finish on 2->4 line - v3sub(tmp, p4, p2); - v3normalize(tmp, tmp); - v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp)); - v3add(end, end, p2); - } - else { // end on the 3->4 line - v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34)); - v3add(end, end, p3); - } - } - v3add(arcPoint, mid, inPlane1); - // index into line1, line2 - var li = 0; - // If extending lines, there's a bit of stuff to do here - // figuring out start and end positions - if (params.extendLine) { - v3toArray(p1, line1, li); - v3toArray(start, line2, li); - li += 3; - v3toArray(start, line1, li); - v3toArray(arcPoint, line2, li); - li += 3; - // Construct plane at start, if not extening lines - // this is skipped - v3toArray(start, plane, 0); - v3toArray(arcPoint, plane, 3); - v3toArray(improperStart ? p3 : p2, plane, 6); - v3toArray(improperStart ? p3 : p2, plane, 9); - v3toArray(arcPoint, plane, 12); - v3toArray(mid, plane, 15); - } - else { - // Not extending lines - v3toArray(mid, line1, li); - v3toArray(arcPoint, line2, li); - li += 3; - } - var appendArcSection = function (a, j) { - var si = j * 9; - v3toArray(mid, sector, si); - v3toArray(arcPoint, sector, si + 3); - v3toArray(arcPoint, line1, li); - calcArcPoint(arcPoint, mid, inPlane1, cross, a); - v3toArray(arcPoint, sector, si + 6); - v3toArray(arcPoint, line2, li); - li += 3; - }; - var j = 0; - for (var a = angleStep; a < angle; a += angleStep) { - appendArcSection(a, j++); - } - appendArcSection(angle, j++); - if (params.extendLine) { - v3toArray(arcPoint, line1, (nLines - 2) * 3); - v3toArray(end, line2, (nLines - 2) * 3); - v3toArray(end, line1, (nLines - 1) * 3); - v3toArray(p4, line2, (nLines - 1) * 3); - // Construct plane at end - v3toArray(end, plane, 18); - v3toArray(arcPoint, plane, 21); - v3toArray(improperEnd ? p2 : p3, plane, 24); - v3toArray(improperEnd ? p2 : p3, plane, 27); - v3toArray(arcPoint, plane, 30); - v3toArray(mid, plane, 33); - } - else { - v3toArray(arcPoint, line1, li); - v3toArray(mid, line2, li); - li += 3; - } - totalLines += nLines * 3; - totalSegments += nSegments * 9; - totalPlanes += nPlanes; - i += 1; - }; - - for (var p = 0; p < nPos; p += 12) loop( p ); - var nSuccess = i; - var linePosition1 = new Float32Array(totalLines); - var linePosition2 = new Float32Array(totalLines); - var sectorPosition = new Float32Array(totalSegments); - var planePosition = new Float32Array(totalPlanes); - var lineOffset = 0; - var sectorOffset = 0; - var planeOffset = 0; - for (var i$1 = 0; i$1 < nSuccess; i$1++) { - var lp1 = lineTmp1[i$1]; - var lp2 = lineTmp2[i$1]; - var sp = sectorTmp[i$1]; - var pp = planeTmp[i$1]; - copyArray(lp1, linePosition1, 0, lineOffset, lp1.length); - copyArray(lp2, linePosition2, 0, lineOffset, lp2.length); - copyArray(sp, sectorPosition, 0, sectorOffset, sp.length); - copyArray(pp, planePosition, 0, planeOffset, pp.length); - lineOffset += lp1.length; - sectorOffset += sp.length; - planeOffset += pp.length; - } - return { - labelPosition: labelPosition.subarray(0, nSuccess * 3), - labelText: labelText.slice(0, nSuccess), - linePosition1: linePosition1, - linePosition2: linePosition2, - planePosition: planePosition, - sectorPosition: sectorPosition - }; -} -RepresentationRegistry.add('dihedral', DihedralRepresentation); - -/** - * @file Dihedral Histogram Representation - * @author Rudolfs Petrovs - * @private - */ -var pointLength = 3; // One Point Length (number of coordinates of one point in 3D) -var pointsInTriangle = 3; -function createUpdatedObject(o, updateSource) { - function hasKey(obj, key) { - return key in obj; - } - var result = Object.assign({}, o); // Shallow copy - for (var key in result) { - if (hasKey(result, key) && hasKey(updateSource, key)) { - result[key] = defaults(updateSource[key], result[key]); - } - } - return result; -} -function createColorArray(color, arrayLength) { - var colorValue = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](color); - var targetArray = new Float32Array(arrayLength * 3); - uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray); - return targetArray; -} -/** - * Dihedral Histogram representation object - * - * Reperesentation consists of several parts: - * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms - * frontHistogram - circular histogram from the adjacent bond viewpoint - * backHistogram - circular histogram from the distant bond viewpoint - * histogramBinBorder - lines, which separate histogram bins - * bondArrows - lines, which show the actual angle on the histogram disc - * - * @param {Structure} structure - the structure to measure angles in - * @param {Viewer} viewer - a viewer object - * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters - */ -var DihedralHistogramRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function DihedralHistogramRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'dihedral-histogram'; - this.parameters = Object.assign({ - histogramsData: { - type: 'hidden', rebuild: true - }, - histogramBinBorderVisible: { - type: 'boolean', default: true - }, - scaleBinToSectorArea: { - type: 'boolean', - rebuild: true, - default: false - } - }, this.parameters); - this.init(params); - } - - if ( StructureRepresentation$$1 ) DihedralHistogramRepresentation.__proto__ = StructureRepresentation$$1; - DihedralHistogramRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - DihedralHistogramRepresentation.prototype.constructor = DihedralHistogramRepresentation; - DihedralHistogramRepresentation.prototype.init = function init (params) { - var p = params || {}; - var defaultColorData = { - histogramBinBorderColor: 'grey', - adjacentBondArrowColor: 'black', - distantBondArrowColor: 'magenta', - frontHistogramColor: 'green', - backHistogramColor: 'blue', - opaqueMiddleDiscColor: 'white' - }; - var colorData = createUpdatedObject(defaultColorData, p); - Object.assign(this, colorData); - var defaultParameters = { - histogramsData: [], - histogramOpacity: 1.0, - opaqueMiddleDiscVisible: true, - opaqueMiddleDiscOpacity: 1.0, - histogramBinBorderVisible: true, - histogramBinBorderWidth: 1, - histogramBinBorderOpacity: 0.5, - bondArrowVisible: true, - bondArrowWidth: 2, - bondArrowOpacity: 1.0, - scaleBinToSectorArea: false, - }; - var parameters = createUpdatedObject(defaultParameters, p); - Object.assign(this, parameters); - this.histogramsData.forEach(function (x) { - var specificColorData = createUpdatedObject(colorData, x); - Object.assign(x, specificColorData); - }); - p.side = defaults(p.side, 'double'); - p.opacity = defaults(p.opacity, 0.5); - p.radiusType = defaults(p.radiusType, 'size'); - p.radiusSize = defaults(p.radiusSize, 0.15); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - DihedralHistogramRepresentation.prototype.getHistogramBinBorderBufferParameters = function getHistogramBinBorderBufferParameters () { - return this.getBufferParams({ - linewidth: this.histogramBinBorderWidth, - visible: this.histogramBinBorderVisible, - opacity: this.histogramBinBorderOpacity, - }); - }; - DihedralHistogramRepresentation.prototype.getBondArrowsBufferParameters = function getBondArrowsBufferParameters () { - return this.getBufferParams({ - linewidth: this.bondArrowWidth, - visible: this.bondArrowVisible, - opacity: this.bondArrowOpacity, - }); - }; - DihedralHistogramRepresentation.prototype.getOpaqueMiddleDiscBufferParameters = function getOpaqueMiddleDiscBufferParameters () { - return this.getBufferParams({ - visible: this.opaqueMiddleDiscVisible, - opacity: this.opaqueMiddleDiscOpacity - }); - }; - DihedralHistogramRepresentation.prototype.getHistogramBufferParameters = function getHistogramBufferParameters () { - return this.getBufferParams({ - visible: true, - opacity: this.histogramOpacity, - side: "double" - }); - }; - DihedralHistogramRepresentation.prototype.createData = function createData (sview) { - if (!sview.atomCount || !this.histogramsData.length) - { return; } - this.histogramsData.forEach(function (x) { return x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]); }); - var scaleData = this.scaleBinToSectorArea ? function (y) { return Math.sqrt(y); } : function (y) { return y; }; - this.histogramsData.forEach(function (x) { return x.histogram360Scaled = x.histogram360.map(scaleData); }); - function Float32Concat(arrays) { - var lengths = arrays.map(function (x) { return x.length; }); - var result = new Float32Array(arraySum(lengths)); - var accumulatedOffset = 0; - for (var i = 0; i < arrays.length; i++) { - result.set(arrays[i], accumulatedOffset); - accumulatedOffset += arrays[i].length; - } - return result; - } - function createWideLineBuffer(linesList, params) { - return new WideLineBuffer({ - position1: Float32Concat(linesList.map(function (x) { return x.startPoints; })), - position2: Float32Concat(linesList.map(function (x) { return x.endPoints; })), - color: Float32Concat(linesList.map(function (x) { return x.startColors; })), - color2: Float32Concat(linesList.map(function (x) { return x.endColors; })), - }, params); - } - function createMeshBuffer(mesh, params) { - return new MeshBuffer({ - position: Float32Concat(mesh.map(function (x) { return x.triangles; })), - color: Float32Concat(mesh.map(function (x) { return x.triangleColors; })) - }, params); - } - var dihedralDataArray = []; - for (var i = 0; i < this.histogramsData.length; i++) { - var dihedralData = undefined; - var currentHistogramData = this.histogramsData[i]; - var currentHistogram360 = currentHistogramData.histogram360; - if (currentHistogram360.length >= 3) { - dihedralData = calculateDihedralHistogram(currentHistogramData); - } - if (typeof dihedralData === "undefined") - { continue; } - dihedralDataArray.push(dihedralData); - } - this.frontHistogramBinBordersBuffer = createWideLineBuffer(dihedralDataArray.map(function (x) { return x.frontHistogramBinBorders; }), this.getHistogramBinBorderBufferParameters()); - this.backHistogramBinBordersBuffer = createWideLineBuffer(dihedralDataArray.map(function (x) { return x.backHistogramBinBorders; }), this.getHistogramBinBorderBufferParameters()); - this.adjacentBondArrowsBuffer = createWideLineBuffer(dihedralDataArray.map(function (x) { return x.adjacentBondArrows; }), this.getBondArrowsBufferParameters()); - this.distantBondArrowsBuffer = createWideLineBuffer(dihedralDataArray.map(function (x) { return x.distantBondArrows; }), this.getBondArrowsBufferParameters()); - this.opaqueMiddleDiscBuffer = createMeshBuffer(dihedralDataArray.map(function (x) { return x.opaqueMiddleDisc; }), this.getOpaqueMiddleDiscBufferParameters()); - this.frontHistogramBuffer = createMeshBuffer(dihedralDataArray.map(function (x) { return x.frontHistogram; }), this.getHistogramBufferParameters()); - this.backHistogramBuffer = createMeshBuffer(dihedralDataArray.map(function (x) { return x.backHistogram; }), this.getHistogramBufferParameters()); - return { - bufferList: [].concat(this.frontHistogramBinBordersBuffer, this.backHistogramBinBordersBuffer, this.adjacentBondArrowsBuffer, this.distantBondArrowsBuffer, this.opaqueMiddleDiscBuffer, this.frontHistogramBuffer, this.backHistogramBuffer) - }; - }; - DihedralHistogramRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - if (params && (params.histogramBinBorderVisible !== undefined)) { - this.setVisibility(this.visible); - } - return this; - }; - DihedralHistogramRepresentation.prototype.setVisibility = function setVisibility (value, noRenderRequest) { - StructureRepresentation$$1.prototype.setVisibility.call(this, value, true); - if (this.frontHistogramBinBordersBuffer) { - this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible); - } - if (this.backHistogramBinBordersBuffer) { - this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible); - } - if (!noRenderRequest) - { this.viewer.requestRender(); } - return this; - }; - - return DihedralHistogramRepresentation; -}(StructureRepresentation)); -/** - * Calculates the data required to create {Buffer} objects for one histogram, given positions - * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates - * @param NumberArray histogram array of coordinates - * @return Arrays for building buffers - */ -function calculateDihedralHistogram(histogramData) { - var positionOfDihedralAtoms = histogramData.atomPositions; - var histogram = histogramData.histogram360Scaled; - var totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2; - var frontAndBack = 2; - var opaqueMiddleDisc = { - triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength), - triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle) - }; - var frontHistogram = { - triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength), - triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle) - }; - var backHistogram = { - triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength), - triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle) - }; - var frontHistogramBinBorders = { - startPoints: new Float32Array(histogram.length * pointLength), - endPoints: new Float32Array(histogram.length * pointLength), - startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length), - endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length) - }; - var backHistogramBinBorders = { - startPoints: new Float32Array(histogram.length * pointLength), - endPoints: new Float32Array(histogram.length * pointLength), - startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length), - endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length) - }; - var adjacentBondArrows = { - startPoints: new Float32Array(frontAndBack * pointLength), - endPoints: new Float32Array(frontAndBack * pointLength), - startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length), - endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length) - }; - var distantBondArrows = { - startPoints: new Float32Array(frontAndBack * pointLength), - endPoints: new Float32Array(frontAndBack * pointLength), - startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length), - endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length) - }; - var p1 = v3new(); - var p2 = v3new(); - var p3 = v3new(); - var p4 = v3new(); - var v21 = v3new(); - var v23 = v3new(); - var v32 = v3new(); - var v34 = v3new(); - var mid = v3new(); - var inPlane1 = v3new(); - var inPlane2 = v3new(); - var cross1 = v3new(); - var cross2 = v3new(); - var arcPoint = v3new(); - var tmp = v3new(); - var tmp2 = v3new(); - // Set Atom Coordinates - var dihedralAtomVectors = [p1, p2, p3, p4]; - for (var i = 0; i < dihedralAtomVectors.length; i++) { - v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength); - } - // Vectors between points - v3sub(v21, p1, p2); - v3sub(v23, p3, p2); - v3sub(v34, p4, p3); - if (v3length(v23) === 0.0) { - return; // Can't define axis - } - v3multiplyScalar(tmp, v23, 0.5); - v3add(mid, p2, tmp); - v3normalize(v21, v21); - v3normalize(v23, v23); - v3normalize(v34, v34); - v3negate(v32, v23); - // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4)) - v3multiplyScalar(tmp, v32, v3dot(v32, v21)); - v3sub(inPlane1, v21, tmp); - v3multiplyScalar(tmp, v23, v3dot(v23, v34)); - v3sub(inPlane2, v34, tmp); - if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) { - return; // Indeterminate angle - } - v3normalize(inPlane1, inPlane1); - v3normalize(inPlane2, inPlane2); - // Can use acos as normalized and non-zero - var absAngle = Math.acos(v3dot(inPlane1, inPlane2)); - v3cross(cross1, v32, inPlane1); - v3cross(cross2, v23, inPlane2); - v3normalize(cross1, cross1); - v3normalize(cross2, cross2); - var angle = absAngle; - if (v3dot(cross1, inPlane2) < 0.0) { - angle = -absAngle; - } - v3add(arcPoint, mid, inPlane1); - // Calculate necessary constants - var maxHist = Math.max.apply(null, histogram); - var histBinAngleStep = (Math.PI * 2) / histogram.length; - function setHistogramBinCoordinates(out, ind, zeroDegreeVector, crossVector, histBinAngleStep) { - var startOffset = ind * pointsInTriangle * pointLength; - v3toArray(mid, out, startOffset); - var scalingFactor = Number(histogram[ind]) / maxHist; - v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor); - v3multiplyScalar(tmp2, crossVector, scalingFactor); - calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep); - v3toArray(arcPoint, out, startOffset + 1 * pointLength); - calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep); - v3toArray(arcPoint, out, startOffset + 2 * pointLength); - } - function setOneSideHistogram(discHistogram, binBorders, ind, zeroDegreeVector, crossVector) { - // Set Bond Arrows - copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length); - calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0); - copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length); - copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length); - calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle); - copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length); - // Set Histogram Bin Borders - for (var i = 0; i < histogram.length; i++) { - copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length); - calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i); - copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length); - } - // Set Histogram Bins - for (var sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) { - setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep); - } - } - // Opaque disc - var opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc; - for (var sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) { - var startOffset = sectionIndex * pointsInTriangle * pointLength; - v3toArray(mid, opaqueMiddleDisc.triangles, startOffset); - calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep); - v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength); - calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep); - v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength); - } - // Front Histogram - var distanceToOpaqueDisc = 0.01; - v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc); // Get a vector to move "mid" just a bit from opaque disc - v3add(mid, mid, tmp); - setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1); - // Back Histogram - v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc); // Get a vector to move "mid" back and plus just a bit from opaque disc the other way - v3add(mid, mid, tmp); - setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2); - return { - opaqueMiddleDisc: opaqueMiddleDisc, - frontHistogram: frontHistogram, - backHistogram: backHistogram, - frontHistogramBinBorders: frontHistogramBinBorders, - backHistogramBinBorders: backHistogramBinBorders, - adjacentBondArrows: adjacentBondArrows, - distantBondArrows: distantBondArrows - }; -} -RepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation); - -/** - * @file Distance Representation - * @author Alexander Rose - * @author Fred Ludlow - * @private - */ -/** - * Distance representation - */ -var DistanceRepresentation = /*@__PURE__*/(function (MeasurementRepresentation$$1) { - function DistanceRepresentation(structure, viewer, params) { - MeasurementRepresentation$$1.call(this, structure, viewer, params); - this.type = 'distance'; - this.parameters = Object.assign({ - radialSegments: true, - openEnded: true, - disableImpostor: true, - labelUnit: { - type: 'select', - rebuild: true, - options: { '': '', angstrom: 'angstrom', nm: 'nm' } - }, - useCylinder: { - type: 'boolean', rebuild: true - }, - atomPair: { - type: 'hidden', rebuild: true - } - }, this.parameters); - this.init(params); - } - - if ( MeasurementRepresentation$$1 ) DistanceRepresentation.__proto__ = MeasurementRepresentation$$1; - DistanceRepresentation.prototype = Object.create( MeasurementRepresentation$$1 && MeasurementRepresentation$$1.prototype ); - DistanceRepresentation.prototype.constructor = DistanceRepresentation; - DistanceRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.linewidth = defaults(p.linewidth, 5.0); - p.radiusType = defaults(p.radiusType, 'size'); - p.radiusSize = defaults(p.radiusSize, 0.2); - this.labelUnit = defaults(p.labelUnit, ''); - this.useCylinder = defaults(p.useCylinder, false); - this.atomPair = defaults(p.atomPair, []); - MeasurementRepresentation$$1.prototype.init.call(this, p); - }; - DistanceRepresentation.prototype.getDistanceData = function getDistanceData (sview, atomPair) { - var this$1 = this; - - var n = atomPair.length; - var text = new Array(n); - var position = new Float32Array(n * 3); - var sele1 = new Selection(); - var sele2 = new Selection(); - var bondStore = new BondStore(); - var ap1 = sview.getAtomProxy(); - var ap2 = sview.getAtomProxy(); - var j = 0; // Skipped pairs - var selected = sview.getAtomSet(); - atomPair.forEach(function (pair, i) { - var v1 = pair[0]; - var v2 = pair[1]; - if (typeof (v1) === 'number' && Number.isInteger(v1) && typeof (v2) === 'number' && Number.isInteger(v2)) { - if (selected.get(v1) && selected.get(v2)) { - ap1.index = v1; - ap2.index = v2; - } - else { - j += 1; - return; - } - } - else { - sele1.setString(v1); - sele2.setString(v2); - var atomIndices1 = sview.getAtomIndices(sele1); - var atomIndices2 = sview.getAtomIndices(sele2); - if (atomIndices1.length && atomIndices2.length) { - ap1.index = atomIndices1[0]; - ap2.index = atomIndices2[0]; - } - else { - j += 1; - return; - } - } - bondStore.addBond(ap1, ap2, 1); - i -= j; - var d = ap1.distanceTo(ap2); - switch (this$1.labelUnit) { - case 'angstrom': - text[i] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B); - break; - case 'nm': - text[i] = (d / 10).toFixed(2) + ' nm'; - break; - default: - text[i] = d.toFixed(2); - break; - } - var i3 = i * 3; - position[i3 + 0] = (ap1.x + ap2.x) / 2; - position[i3 + 1] = (ap1.y + ap2.y) / 2; - position[i3 + 2] = (ap1.z + ap2.z) / 2; - }); - if (j > 0) { - n -= j; - position = position.subarray(0, n * 3); - } - var bondSet = new BitArray(bondStore.count, true); - return { - text: text, - position: position, - bondSet: bondSet, - bondStore: bondStore - }; - }; - DistanceRepresentation.prototype.getBondData = function getBondData (sview, what, params) { - var bondData = sview.getBondData(this.getBondParams(what, params)); - if (bondData.picking) { - bondData.picking = new DistancePicker(bondData.picking.array, bondData.picking.structure, params.bondStore); - } - return bondData; - }; - DistanceRepresentation.prototype.createData = function createData (sview) { - if (!sview.atomCount || !this.atomPair.length) - { return; } - var n = this.atomPair.length; - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.labelColor); - var distanceData = this.getDistanceData(sview, this.atomPair); - this.textBuffer = new TextBuffer({ - position: distanceData.position, - size: uniformArray(n, this.labelSize), - color: uniformArray3(n, c.r, c.g, c.b), - text: distanceData.text - }, this.getLabelBufferParams()); - var bondParams = { - bondSet: distanceData.bondSet, - bondStore: distanceData.bondStore - }; - var bondData = this.getBondData(sview, { position: true, color: true, picking: true, radius: this.useCylinder }, bondParams); - if (this.useCylinder) { - this.distanceBuffer = new CylinderBuffer(bondData, this.getBufferParams({ - openEnded: this.openEnded, - radialSegments: this.radialSegments, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - } - else { - this.distanceBuffer = new WideLineBuffer(getFixedLengthDashData(bondData), this.getBufferParams({ - linewidth: this.linewidth, - visible: this.lineVisible, - opacity: this.lineOpacity - })); - } - return { - bondSet: distanceData.bondSet, - bondStore: distanceData.bondStore, - position: distanceData.position, - bufferList: [this.textBuffer, this.distanceBuffer] - }; - }; - DistanceRepresentation.prototype.updateData = function updateData (what, data) { - MeasurementRepresentation$$1.prototype.updateData.call(this, what, data); - var bondParams = { - bondSet: data.bondSet, - bondStore: data.bondStore - }; - var bondData = this.getBondData(data.sview, what, bondParams); - var distanceData = {}; - if (!what || what.color) { - Object.assign(distanceData, { - color: bondData.color, - color2: bondData.color2 - }); - } - if (!what || what.radius) { - Object.assign(distanceData, { radius: bondData.radius }); - } - this.distanceBuffer.setAttributes(distanceData); - }; - DistanceRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - MeasurementRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - if (!this.useCylinder) { - if (params && params.lineOpacity) { - this.distanceBuffer.setParameters({ opacity: params.lineOpacity }); - } - if (params && params.opacity !== undefined) { - this.distanceBuffer.setParameters({ opacity: this.lineOpacity }); - } - if (params && params.linewidth) { - this.distanceBuffer.setParameters({ linewidth: params.linewidth }); - } - } - return this; - }; - - return DistanceRepresentation; -}(MeasurementRepresentation)); -RepresentationRegistry.add('distance', DistanceRepresentation); - -/** - * @file Vector Buffer - * @author Alexander Rose - * @private - */ -function getSize(data) { - var n = data.position.length / 3; - return n * 2 * 3; -} -var VectorBufferDefaultParameters = Object.assign({ - scale: 1, - color: 'grey' -}, BufferDefaultParameters); -/** - * Vector buffer. Draws vectors as lines. - */ -var VectorBuffer = /*@__PURE__*/(function (Buffer$$1) { - function VectorBuffer(data, params) { - if ( params === void 0 ) params = {}; - - Buffer$$1.call(this, { - position: new Float32Array(getSize(data)), - color: new Float32Array(getSize(data)) - }, params); - this.isLine = true; - this.vertexShader = 'Line.vert'; - this.fragmentShader = 'Line.frag'; - var color = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](this.parameters.color); - var attributes = this.geometry.attributes; // TODO - uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array); - this.setAttributes(data); - } - - if ( Buffer$$1 ) VectorBuffer.__proto__ = Buffer$$1; - VectorBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - VectorBuffer.prototype.constructor = VectorBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return VectorBufferDefaultParameters; }; - VectorBuffer.prototype.setAttributes = function setAttributes (data) { - if ( data === void 0 ) data = {}; - - var attributes = this.geometry.attributes; // TODO - var position, vector; - var aPosition; - if (data.position && data.vector) { - position = data.position; - vector = data.vector; - aPosition = attributes.position.array; - attributes.position.needsUpdate = true; - } - var n = this.size / 2; - var scale$$1 = this.parameters.scale; - if (position && vector) { - for (var v = 0; v < n; v++) { - var i = v * 2 * 3; - var j = v * 3; - aPosition[i + 0] = position[j + 0]; - aPosition[i + 1] = position[j + 1]; - aPosition[i + 2] = position[j + 2]; - aPosition[i + 3] = position[j + 0] + vector[j + 0] * scale$$1; - aPosition[i + 4] = position[j + 1] + vector[j + 1] * scale$$1; - aPosition[i + 5] = position[j + 2] + vector[j + 2] * scale$$1; - } - } - }; - - Object.defineProperties( VectorBuffer.prototype, prototypeAccessors ); - - return VectorBuffer; -}(Buffer)); - -/** - * @file Helixorient Representation - * @author Alexander Rose - * @private - */ -/** - * Helixorient Representation - */ -var HelixorientRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function HelixorientRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'helixorient'; - this.parameters = Object.assign({ - sphereDetail: true, - disableImpostor: true - }, this.parameters); - this.init(params); - } - - if ( StructureRepresentation$$1 ) HelixorientRepresentation.__proto__ = StructureRepresentation$$1; - HelixorientRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - HelixorientRepresentation.prototype.constructor = HelixorientRepresentation; - HelixorientRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'sstruc'); - p.radiusType = defaults(p.radiusType, 'size'); - p.radiusSize = defaults(p.radiusSize, 0.15); - p.radiusScale = defaults(p.radiusScale, 1.0); - p.useInteriorColor = defaults(p.useInteriorColor, true); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - HelixorientRepresentation.prototype.createData = function createData (sview) { - var this$1 = this; - - var bufferList = []; - var polymerList = []; - this.structure.eachPolymer(function (polymer) { - if (polymer.residueCount < 4) - { return; } - polymerList.push(polymer); - var helixorient = new Helixorient(polymer); - var position = helixorient.getPosition(); - var color = helixorient.getColor(this$1.getColorParams()); - var size = helixorient.getSize(this$1.getRadiusParams()); - var picking = helixorient.getPicking(); - bufferList.push(new SphereBuffer({ - position: position.center, - color: color.color, - radius: size.size, - picking: picking.picking - }, this$1.getBufferParams({ - sphereDetail: this$1.sphereDetail, - disableImpostor: this$1.disableImpostor, - dullInterior: true - })), new VectorBuffer({ - position: position.center, - vector: position.axis - }, this$1.getBufferParams({ - color: 'skyblue', - scale: 1 - })), new VectorBuffer({ - position: position.center, - vector: position.resdir - }, this$1.getBufferParams({ - color: 'lightgreen', - scale: 1 - }))); - }, sview.getSelection()); - return { - bufferList: bufferList, - polymerList: polymerList - }; - }; - HelixorientRepresentation.prototype.updateData = function updateData (what, data) { - if (Debug) - { Log.time(this.type + ' repr update'); } - what = what || {}; - for (var i = 0, il = data.polymerList.length; i < il; ++i) { - var j = i * 3; - var bufferData = {}; - var polymer = data.polymerList[i]; - var helixorient = new Helixorient(polymer); - if (what.position) { - var position = helixorient.getPosition(); - Object.assign(bufferData, { position: position.center }); - data.bufferList[j + 1].setAttributes({ - 'position': position.center, - 'vector': position.axis - }); - data.bufferList[j + 2].setAttributes({ - 'position': position.center, - 'vector': position.resdir - }); - } - data.bufferList[j].setAttributes(bufferData); - } - if (Debug) - { Log.timeEnd(this.type + ' repr update'); } - }; - - return HelixorientRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('helixorient', HelixorientRepresentation); - -/** - * @file Licorice Representation - * @author Alexander Rose - * @private - */ -/** - * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0) - */ -var LicoriceRepresentation = /*@__PURE__*/(function (BallAndStickRepresentation$$1) { - function LicoriceRepresentation(structure, viewer, params) { - BallAndStickRepresentation$$1.call(this, structure, viewer, params); - this.type = 'licorice'; - this.parameters = Object.assign({}, this.parameters, { aspectRatio: null }); - } - - if ( BallAndStickRepresentation$$1 ) LicoriceRepresentation.__proto__ = BallAndStickRepresentation$$1; - LicoriceRepresentation.prototype = Object.create( BallAndStickRepresentation$$1 && BallAndStickRepresentation$$1.prototype ); - LicoriceRepresentation.prototype.constructor = LicoriceRepresentation; - LicoriceRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.aspectRatio = 1.0; - BallAndStickRepresentation$$1.prototype.init.call(this, p); - }; - - return LicoriceRepresentation; -}(BallAndStickRepresentation)); -RepresentationRegistry.add('licorice', LicoriceRepresentation); - -ShaderRegistry.add('shader/HyperballStickImpostor.vert', "\nattribute vec3 mapping;\nattribute float radius;\nattribute float radius2;\nattribute vec3 position1;\nattribute vec3 position2;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\nattribute vec3 color2;\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#endif\nuniform float shrink;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewProjectionMatrixInverse;\nvoid main(){\nvRadius = radius;\nvRadius2 = radius2;\nvec4 spaceposition;\nvec3 position_atom1;\nvec3 position_atom2;\nvec4 vertex_position;\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\nvColor1 = color;\nvColor2 = color2;\n#endif\nfloat radius1 = radius;\nposition_atom1 = position1;\nposition_atom2 = position2;\nfloat distance = distance( position_atom1, position_atom2 );\nspaceposition.z = mapping.z * distance;\nif (radius1 > radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"); - -ShaderRegistry.add('shader/HyperballStickImpostor.frag', "#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}"); - -/** - * @file Mapped Box Buffer - * @author Alexander Rose - * @private - */ -var mapping$2 = new Float32Array([ - -1.0, -1.0, -1.0, - 1.0, -1.0, -1.0, - 1.0, -1.0, 1.0, - -1.0, -1.0, 1.0, - -1.0, 1.0, -1.0, - 1.0, 1.0, -1.0, - 1.0, 1.0, 1.0, - -1.0, 1.0, 1.0 -]); -var mappingIndices$2 = new Uint16Array([ - 0, 1, 2, - 0, 2, 3, - 1, 5, 6, - 1, 6, 2, - 4, 6, 5, - 4, 7, 6, - 0, 7, 4, - 0, 3, 7, - 0, 5, 1, - 0, 4, 5, - 3, 2, 6, - 3, 6, 7 -]); -/** - * Mapped Box buffer. Draws boxes. Used to render general imposters. - * @interface - */ -var MappedBoxBuffer = /*@__PURE__*/(function (MappedBuffer$$1) { - function MappedBoxBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedBuffer$$1.call(this, 'v3', data, params); - } - - if ( MappedBuffer$$1 ) MappedBoxBuffer.__proto__ = MappedBuffer$$1; - MappedBoxBuffer.prototype = Object.create( MappedBuffer$$1 && MappedBuffer$$1.prototype ); - MappedBoxBuffer.prototype.constructor = MappedBoxBuffer; - - var prototypeAccessors = { mapping: { configurable: true },mappingIndices: { configurable: true },mappingIndicesSize: { configurable: true },mappingSize: { configurable: true },mappingItemSize: { configurable: true } }; - prototypeAccessors.mapping.get = function () { return mapping$2; }; - prototypeAccessors.mappingIndices.get = function () { return mappingIndices$2; }; - prototypeAccessors.mappingIndicesSize.get = function () { return 36; }; - prototypeAccessors.mappingSize.get = function () { return 8; }; - prototypeAccessors.mappingItemSize.get = function () { return 3; }; - - Object.defineProperties( MappedBoxBuffer.prototype, prototypeAccessors ); - - return MappedBoxBuffer; -}(MappedBuffer)); - -/** - * @file Hyperball Stick Impostor Buffer - * @author Alexander Rose - * @private - */ -var HyperballStickImpostorBufferDefaultParameters = Object.assign({ - shrink: 0.14 -}, BufferDefaultParameters); -var HyperballStickImpostorBufferParameterTypes = Object.assign({ - shrink: { uniform: true } -}, BufferParameterTypes); -/** - * Hyperball stick impostor buffer. - * - * @example - * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 2, 2, 2 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]), - * radius: new Float32Array([ 1 ]), - * radius2: new Float32Array([ 2 ]) - * }); - */ -var HyperballStickImpostorBuffer = /*@__PURE__*/(function (MappedBoxBuffer$$1) { - function HyperballStickImpostorBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MappedBoxBuffer$$1.call(this, data, params); - this.parameterTypes = HyperballStickImpostorBufferParameterTypes; - this.isImpostor = true; - this.vertexShader = 'HyperballStickImpostor.vert'; - this.fragmentShader = 'HyperballStickImpostor.frag'; - this.addUniforms({ - 'modelViewProjectionMatrix': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() }, - 'modelViewProjectionMatrixInverse': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() }, - 'modelViewMatrixInverseTranspose': { value: new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]() }, - 'shrink': { value: this.parameters.shrink } - }); - this.addAttributes({ - 'position1': { type: 'v3', value: null }, - 'position2': { type: 'v3', value: null }, - 'color2': { type: 'c', value: null }, - 'radius': { type: 'f', value: null }, - 'radius2': { type: 'f', value: null } - }); - this.setAttributes(data); - this.makeMapping(); - } - - if ( MappedBoxBuffer$$1 ) HyperballStickImpostorBuffer.__proto__ = MappedBoxBuffer$$1; - HyperballStickImpostorBuffer.prototype = Object.create( MappedBoxBuffer$$1 && MappedBoxBuffer$$1.prototype ); - HyperballStickImpostorBuffer.prototype.constructor = HyperballStickImpostorBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return HyperballStickImpostorBufferDefaultParameters; }; - - Object.defineProperties( HyperballStickImpostorBuffer.prototype, prototypeAccessors ); - - return HyperballStickImpostorBuffer; -}(MappedBoxBuffer)); - -/** - * @file Hyperball Stick Buffer - * @author Alexander Rose - * @private - */ -var HyperballStickBufferDefaultParameters = Object.assign({ - disableImpostor: false -}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters); -/** - * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and - * `params.disableImpostor` the constructor returns either a - * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer} - * @implements {Buffer} - * - * @example - * var hyperballStickBuffer = new HyperballStickBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 2, 2, 2 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]), - * radius: new Float32Array([ 1 ]), - * radius2: new Float32Array([ 2 ]) - * }); - */ -var HyperballStickBuffer = function HyperballStickBuffer(data, params) { - if ( params === void 0 ) params = {}; - - if (!ExtensionFragDepth || (params && params.disableImpostor)) { - data.radius = calculateMinArray(data.radius, data.radius2); - return new CylinderGeometryBuffer(data, params); - } - else { - return new HyperballStickImpostorBuffer(data, params); - } -}; - -/** - * @file Hyperball Representation - * @author Alexander Rose - * @private - */ -/** - * Hyperball Representation - */ -var HyperballRepresentation = /*@__PURE__*/(function (LicoriceRepresentation$$1) { - function HyperballRepresentation(structure, viewer, params) { - LicoriceRepresentation$$1.call(this, structure, viewer, params); - this.type = 'hyperball'; - this.parameters = Object.assign({ - shrink: { - type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true - } - }, this.parameters, { - multipleBond: null, - bondSpacing: null - }); - } - - if ( LicoriceRepresentation$$1 ) HyperballRepresentation.__proto__ = LicoriceRepresentation$$1; - HyperballRepresentation.prototype = Object.create( LicoriceRepresentation$$1 && LicoriceRepresentation$$1.prototype ); - HyperballRepresentation.prototype.constructor = HyperballRepresentation; - HyperballRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.radiusScale = defaults(p.radiusScale, 0.2); - p.radiusType = defaults(p.radiusType, 'vdw'); - p.useInteriorColor = defaults(p.useInteriorColor, true); - this.shrink = defaults(p.shrink, 0.12); - LicoriceRepresentation$$1.prototype.init.call(this, p); - }; - HyperballRepresentation.prototype.getBondParams = function getBondParams (what, params) { - if (!what || what.radius) { - params = Object.assign({ radius2: true }, params); - } - return LicoriceRepresentation$$1.prototype.getBondParams.call(this, what, params); - }; - HyperballRepresentation.prototype.createData = function createData (sview) { - var sphereBuffer = new SphereBuffer(sview.getAtomData(this.getAtomParams()), this.getBufferParams({ - sphereDetail: this.sphereDetail, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - this.__center = new Float32Array(sview.bondCount * 3); - var stickBuffer = new HyperballStickBuffer(sview.getBondData(this.getBondParams()), this.getBufferParams({ - shrink: this.shrink, - radialSegments: this.radialSegments, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - return { - bufferList: [sphereBuffer, stickBuffer] - }; - }; - HyperballRepresentation.prototype.updateData = function updateData (what, data) { - var atomData = data.sview.getAtomData(this.getAtomParams()); - var bondData = data.sview.getBondData(this.getBondParams()); - var sphereData = {}; - var stickData = {}; - if (!what || what.position) { - Object.assign(sphereData, { position: atomData.position }); - var from = bondData.position1; - var to = bondData.position2; - Object.assign(stickData, { - position: calculateCenterArray(from, to, this.__center), - position1: from, - position2: to - }); - } - if (!what || what.color) { - Object.assign(sphereData, { color: atomData.color }); - Object.assign(stickData, { - color: bondData.color, - color2: bondData.color2 - }); - } - if (!what || what.radius) { - Object.assign(sphereData, { radius: atomData.radius }); - Object.assign(stickData, { - radius: bondData.radius, - radius2: bondData.radius2 - }); - } - data.bufferList[0].setAttributes(sphereData); - data.bufferList[1].setAttributes(stickData); - }; - - return HyperballRepresentation; -}(LicoriceRepresentation)); -RepresentationRegistry.add('hyperball', HyperballRepresentation); - -/** - * @file Label Factory - * @author Alexander Rose - * @private - */ -var LabelFactoryTypes = { - '': '', - 'atomname': 'atom name', - 'atomindex': 'atom index', - 'occupancy': 'occupancy', - 'bfactor': 'b-factor', - 'serial': 'serial', - 'element': 'element', - 'atom': 'atom name + index', - 'resname': 'residue name', - 'resno': 'residue no', - 'res': 'one letter code + no', - 'residue': '[residue name] + no + inscode', - 'text': 'text', - 'format': 'format', - 'qualified': 'qualified name' -}; -var LabelFactory = function LabelFactory(type, text, format) { - if ( text === void 0 ) text = {}; - if ( format === void 0 ) format = ''; - - this.type = type; - this.text = text; - this.format = format; - this.errorLogged = false; -}; -LabelFactory.prototype.atomLabel = function atomLabel (a) { - var type = this.type; - var l; - switch (type) { - case 'atomname': - l = a.atomname; - break; - case 'atomindex': - l = "" + (a.index); - break; - case 'occupancy': - l = a.occupancy.toFixed(2); - break; - case 'bfactor': - l = a.bfactor.toFixed(2); - break; - case 'serial': - l = "" + (a.serial); - break; - case 'element': - l = a.element; - break; - case 'atom': - l = (a.atomname) + "|" + (a.index); - break; - case 'resname': - l = a.resname; - break; - case 'resno': - l = "" + (a.resno); - break; - case 'res': - l = "" + ((AA1[a.resname.toUpperCase()] || a.resname)) + (a.resno); - break; - case 'residue': - var aa1 = AA1[a.resname.toUpperCase()]; - if (aa1 && !a.inscode) { - l = "" + aa1 + (a.resno); - } - else { - l = "[" + (a.resname) + "]" + (a.resno) + (a.inscode); - } - break; - case 'text': - l = this.text[a.index]; - break; - case 'format': - try { - l = Object(__WEBPACK_IMPORTED_MODULE_3_sprintf_js__["sprintf"])(this.format, a); - } - catch (e) { - if (!this.errorLogged) { - this.errorLogged = true; - console.log(e.message); - } - } - break; - // case "qualified": - default: - l = a.qualifiedName(); - break; - } - return l === undefined ? '' : l; -}; -LabelFactory.types = LabelFactoryTypes; - -/** - * @file Label Representation - * @author Alexander Rose - * @private - */ -/** - * Label representation - */ -var LabelRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function LabelRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'label'; - this.parameters = Object.assign({ - labelType: { - type: 'select', options: LabelFactory.types, rebuild: true - }, - labelText: { - type: 'hidden', rebuild: true - }, - labelFormat: { - type: 'text', rebuild: true - }, - labelGrouping: { - type: 'select', - options: { - 'atom': 'atom', - 'residue': 'residue' - }, - rebuild: true - }, - fontFamily: { - type: 'select', - options: { - 'sans-serif': 'sans-serif', - 'monospace': 'monospace', - 'serif': 'serif' - }, - buffer: true - }, - fontStyle: { - type: 'select', - options: { - 'normal': 'normal', - 'italic': 'italic' - }, - buffer: true - }, - fontWeight: { - type: 'select', - options: { - 'normal': 'normal', - 'bold': 'bold' - }, - buffer: true - }, - xOffset: { - type: 'number', precision: 1, max: 20, min: -20, buffer: true - }, - yOffset: { - type: 'number', precision: 1, max: 20, min: -20, buffer: true - }, - zOffset: { - type: 'number', precision: 1, max: 20, min: -20, buffer: true - }, - attachment: { - type: 'select', - options: { - 'bottom-left': 'bottom-left', - 'bottom-center': 'bottom-center', - 'bottom-right': 'bottom-right', - 'middle-left': 'middle-left', - 'middle-center': 'middle-center', - 'middle-right': 'middle-right', - 'top-left': 'top-left', - 'top-center': 'top-center', - 'top-right': 'top-right' - }, - rebuild: true - }, - showBorder: { - type: 'boolean', buffer: true - }, - borderColor: { - type: 'color', buffer: true - }, - borderWidth: { - type: 'number', precision: 2, max: 0.3, min: 0, buffer: true - }, - showBackground: { - type: 'boolean', rebuild: true - }, - backgroundColor: { - type: 'color', buffer: true - }, - backgroundMargin: { - type: 'number', precision: 2, max: 2, min: 0, rebuild: true - }, - backgroundOpacity: { - type: 'range', step: 0.01, max: 1, min: 0, buffer: true - }, - fixedSize: { - type: 'boolean', buffer: true - } - }, this.parameters, { - side: null, - flatShaded: null, - wireframe: null, - linewidth: null, - roughness: null, - metalness: null, - diffuse: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) LabelRepresentation.__proto__ = StructureRepresentation$$1; - LabelRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - LabelRepresentation.prototype.constructor = LabelRepresentation; - LabelRepresentation.prototype.init = function init (params) { - var p = params || {}; - this.labelType = defaults(p.labelType, 'res'); - this.labelText = defaults(p.labelText, {}); - this.labelFormat = defaults(p.labelFormat, ''); - this.labelGrouping = defaults(p.labelGrouping, 'atom'); - this.fontFamily = defaults(p.fontFamily, 'sans-serif'); - this.fontStyle = defaults(p.fontStyle, 'normal'); - this.fontWeight = defaults(p.fontWeight, 'bold'); - this.xOffset = defaults(p.xOffset, 0.0); - this.yOffset = defaults(p.yOffset, 0.0); - this.zOffset = defaults(p.zOffset, 0.5); - this.attachment = defaults(p.attachment, 'bottom-left'); - this.showBorder = defaults(p.showBorder, false); - this.borderColor = defaults(p.borderColor, 'lightgrey'); - this.borderWidth = defaults(p.borderWidth, 0.15); - this.showBackground = defaults(p.showBackground, false); - this.backgroundColor = defaults(p.backgroundColor, 'lightgrey'); - this.backgroundMargin = defaults(p.backgroundMargin, 0.5); - this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0); - this.fixedSize = defaults(p.fixedSize, false); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - LabelRepresentation.prototype.getTextData = function getTextData (sview, what) { - var p = this.getAtomParams(what); - var labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat); - var position, size, color, text, positionN, sizeN, colorN; - if (this.labelGrouping === 'atom') { - var atomData = sview.getAtomData(p); - position = atomData.position; - size = atomData.radius; - color = atomData.color; - if (!what || what.text) { - text = []; - sview.eachAtom(function (ap) { return text.push(labelFactory.atomLabel(ap)); }); - } - } - else if (this.labelGrouping === 'residue') { - if (!what || what.position) - { positionN = []; } - if (!what || what.color) - { colorN = []; } - if (!what || what.radius) - { sizeN = []; } - if (!what || what.text) - { text = []; } - if (p.colorParams) - { p.colorParams.structure = sview.getStructure(); } - var colormaker = ColormakerRegistry$1.getScheme(p.colorParams); - var radiusFactory = new RadiusFactory(p.radiusParams); - var ap1 = sview.getAtomProxy(); - var i = 0; - sview.eachResidue(function (rp) { - var i3 = i * 3; - if (rp.isProtein() || rp.isNucleic()) { - ap1.index = rp.traceAtomIndex; - if (!what || what.position) { - ap1.positionToArray(positionN, i3); - } - } - else { - ap1.index = rp.atomOffset; - if (!what || what.position) { - rp.positionToArray(positionN, i3); - } - } - if (!what || what.color) { - colormaker.atomColorToArray(ap1, colorN, i3); - } - if (!what || what.radius) { - sizeN[i] = radiusFactory.atomRadius(ap1); - } - if (!what || what.text) { - text.push(labelFactory.atomLabel(ap1)); - } - ++i; - }); - if (!what || what.position) - { position = new Float32Array(positionN); } - if (!what || what.color) - { color = new Float32Array(colorN); } - if (!what || what.radius) - { size = new Float32Array(sizeN); } - } - return { position: position, size: size, color: color, text: text }; - }; - LabelRepresentation.prototype.createData = function createData (sview) { - var what = { position: true, color: true, radius: true, text: true }; - var textBuffer = new TextBuffer(this.getTextData(sview, what), this.getBufferParams({ - fontFamily: this.fontFamily, - fontStyle: this.fontStyle, - fontWeight: this.fontWeight, - xOffset: this.xOffset, - yOffset: this.yOffset, - zOffset: this.zOffset, - attachment: this.attachment, - showBorder: this.showBorder, - borderColor: this.borderColor, - borderWidth: this.borderWidth, - showBackground: this.showBackground, - backgroundColor: this.backgroundColor, - backgroundMargin: this.backgroundMargin, - backgroundOpacity: this.backgroundOpacity, - fixedSize: this.fixedSize - })); - return { bufferList: [textBuffer] }; - }; - LabelRepresentation.prototype.updateData = function updateData (what, data) { - data.bufferList[0].setAttributes(this.getTextData(data.sview, what)); - }; - LabelRepresentation.prototype.getAtomRadius = function getAtomRadius () { - return 0; - }; - - return LabelRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('label', LabelRepresentation); - -/** - * @file Line Representation - * @author Alexander Rose - * @private - */ -/** - * Determine which atoms in a Structure[View] form no bonds to any other atoms - * in that Structure. - * - * This differs from setting the selection to "nonbonded" as it finds atoms - * that have no bonds within the current selection. - * @param {Structure} structure - The Structure or StructureView object - * @return {AtomSet} AtomSet of lone atoms - */ -function getLoneAtomSet(structure) { - var atomSet = structure.getAtomSet(); - var bondSet = structure.getBondSet(); - var bp = structure.getBondProxy(); - bondSet.forEach(function (idx) { - bp.index = idx; - atomSet.clear(bp.atomIndex1); - atomSet.clear(bp.atomIndex2); - }); - return atomSet; -} -/** - * Line representation - */ -var LineRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function LineRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'line'; - this.parameters = Object.assign({ - multipleBond: { - type: 'select', - rebuild: true, - options: { - 'off': 'off', - 'symmetric': 'symmetric', - 'offset': 'offset' - } - }, - bondSpacing: { - type: 'number', precision: 2, max: 2.0, min: 0.5 - }, - linewidth: { - type: 'integer', max: 50, min: 1, buffer: true - }, - lines: { - type: 'boolean', rebuild: true - }, - crosses: { - type: 'select', - rebuild: true, - options: { - 'off': 'off', - 'lone': 'lone', - 'all': 'all' - } - }, - crossSize: { - type: 'number', precision: 2, max: 2.0, min: 0.1 - } - }, this.parameters, { - flatShaded: null, - side: null, - wireframe: null, - roughness: null, - metalness: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) LineRepresentation.__proto__ = StructureRepresentation$$1; - LineRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - LineRepresentation.prototype.constructor = LineRepresentation; - LineRepresentation.prototype.init = function init (params) { - var p = params || {}; - this.multipleBond = defaults(p.multipleBond, 'off'); - this.bondSpacing = defaults(p.bondSpacing, 1.0); - this.linewidth = defaults(p.linewidth, 2); - this.lines = defaults(p.lines, true); - this.crosses = defaults(p.crosses, 'lone'); - this.crossSize = defaults(p.crossSize, 0.4); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - LineRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - return 0.1; - }; - LineRepresentation.prototype.getBondParams = function getBondParams (what, params) { - params = Object.assign({ - multipleBond: this.multipleBond, - bondSpacing: this.bondSpacing, - radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 } - }, params); - return StructureRepresentation$$1.prototype.getBondParams.call(this, what, params); - }; - LineRepresentation.prototype._crossData = function _crossData (what, sview) { - if (what) { - if (!what.position && !what.color) - { return; } - } - var p = {}; - if (this.crosses === 'lone') { - Object.assign(p, { atomSet: getLoneAtomSet(sview) }); - } - var atomData = sview.getAtomData(this.getAtomParams(what, p)); - var crossData = {}; - var position = atomData.position; - var color = atomData.color; - var picking = atomData.picking; - var size = (position || color).length; - var attrSize = size * 3; - var cPosition1 = new Float32Array(0); - var cPosition2 = new Float32Array(0); - var cColor = new Float32Array(0); - var cColor2 = new Float32Array(0); - var cOffset = 0; - var pickingArray = new Float32Array(0); - if (!what || what.position) { - cPosition1 = crossData.position1 = new Float32Array(attrSize); - cPosition2 = crossData.position2 = new Float32Array(attrSize); - cOffset = this.crossSize / 2; - } - if (!what || what.color) { - cColor = crossData.color = new Float32Array(attrSize); - cColor2 = crossData.color2 = new Float32Array(attrSize); - } - if (!what || what.picking) { - pickingArray = new Float32Array(atomData.picking.array.length * 3); // Needs padding?? - } - for (var v = 0; v < size; v++) { - var j = v * 3; - var i = j * 3; - if (!what || what.position) { - var x = position[j]; - var y = position[j + 1]; - var z = position[j + 2]; - cPosition1[i] = x - cOffset; - cPosition1[i + 1] = y; - cPosition1[i + 2] = z; - cPosition2[i] = x + cOffset; - cPosition2[i + 1] = y; - cPosition2[i + 2] = z; - cPosition1[i + 3] = x; - cPosition1[i + 4] = y - cOffset; - cPosition1[i + 5] = z; - cPosition2[i + 3] = x; - cPosition2[i + 4] = y + cOffset; - cPosition2[i + 5] = z; - cPosition1[i + 6] = x; - cPosition1[i + 7] = y; - cPosition1[i + 8] = z - cOffset; - cPosition2[i + 6] = x; - cPosition2[i + 7] = y; - cPosition2[i + 8] = z + cOffset; - } - if (!what || what.color) { - var cimax = i + 9; - for (var ci = i; ci < cimax; ci += 3) { - cColor[ci] = cColor2[ci] = color[j]; - cColor[ci + 1] = cColor2[ci + 1] = color[j + 1]; - cColor[ci + 2] = cColor2[ci + 2] = color[j + 2]; - } - } - if (!what || what.picking) { - pickingArray[j] = - pickingArray[j + 1] = - pickingArray[j + 2] = picking.array[v]; - } - } - if (!what || what.picking) { - crossData.picking = new AtomPicker(pickingArray, picking.structure); - } - return crossData; - }; - LineRepresentation.prototype.createData = function createData (sview) { - var what = { position: true, color: true, picking: true }; - var bufferList = []; - if (this.lines) { - var bondData = sview.getBondData(this.getBondParams(what)); - var lineBuffer = new WideLineBuffer(bondData, this.getBufferParams({ linewidth: this.linewidth })); - bufferList.push(lineBuffer); - } - if (this.crosses !== 'off') { - var crossBuffer = new WideLineBuffer(this._crossData(what, sview), this.getBufferParams({ linewidth: this.linewidth })); - bufferList.push(crossBuffer); - } - return { - bufferList: bufferList - }; - }; - LineRepresentation.prototype.updateData = function updateData (what, data) { - var bufferIdx = 0; - if (this.lines) { - var bondData = data.sview.getBondData(this.getBondParams(what)); - var lineAttributes = {}; - if (!what || what.position) { - Object.assign(lineAttributes, { - position1: bondData.position1, - position2: bondData.position2 - }); - } - if (!what || what.color) { - Object.assign(lineAttributes, { - color: bondData.color, - color2: bondData.color2 - }); - } - data.bufferList[bufferIdx++].setAttributes(lineAttributes); - } - if (this.crosses !== 'off') { - var crossData = this._crossData(what, data.sview); - var crossAttributes = {}; - if (!what || what.position) { - Object.assign(crossAttributes, { - position1: crossData.position1, - position2: crossData.position2 - }); - } - if (!what || what.color) { - Object.assign(crossAttributes, { - color: crossData.color, - color2: crossData.color2 - }); - } - data.bufferList[bufferIdx++].setAttributes(crossAttributes); - } - }; - LineRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - if (params && (params.bondSpacing || params.crossSize)) { - Object.assign(what, { position: true }); - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - - return LineRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('line', LineRepresentation); - -function makeGrid(length, width, height, DataCtor, elemSize) { - DataCtor = DataCtor || Int32Array; - elemSize = elemSize || 1; - var data = new DataCtor(length * width * height * elemSize); - function index(x, y, z) { - return ((((x * width) + y) * height) + z) * elemSize; - } - function set(x, y, z) { - var args = [], len = arguments.length - 3; - while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ]; - - var i = index(x, y, z); - for (var j = 0; j < elemSize; ++j) { - data[i + j] = args[j]; - } - } - function toArray(x, y, z, array, offset) { - if ( array === void 0 ) array = []; - if ( offset === void 0 ) offset = 0; - - var i = index(x, y, z); - for (var j = 0; j < elemSize; ++j) { - array[offset + j] = data[i + j]; - } - } - function fromArray(x, y, z, array, offset) { - if ( offset === void 0 ) offset = 0; - - var i = index(x, y, z); - for (var j = 0; j < elemSize; ++j) { - data[i + j] = array[offset + j]; - } - } - function copy(grid) { - data.set(grid.data); - } - // function clone() { - // return makeGrid( - // length, width, height, DataCtor, elemSize - // ).copy(this) - // } - return { data: data, index: index, set: set, toArray: toArray, fromArray: fromArray, copy: copy }; -} - -/** - * @file EDT Surface - * @author Alexander Rose - * @private - */ -function EDTSurface(coordList, radiusList, indexList) { - // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular - // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140. - // - // Permission to use, copy, modify, and distribute this program for - // any purpose, with or without fee, is hereby granted, provided that - // the notices on the head, the reference information, and this - // copyright notice appear in all copies or substantial portions of - // the Software. It is provided "as is" without express or implied - // warranty. - // - // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/) - // refactored by dkoes (https://github.com/dkoes) - // - // adapted to NGL by Alexander Rose - var radiusDict = getRadiusDict(radiusList); - var bbox = computeBoundingBox(coordList); - if (coordList.length === 0) { - bbox[0].set([0, 0, 0]); - bbox[1].set([0, 0, 0]); - } - var min = bbox[0]; - var max = bbox[1]; - var probeRadius, scaleFactor, cutoff; - var pLength, pWidth, pHeight; - var matrix, ptran; - var depty, widxz; - var cutRadius; - var setAtomID; - var vpBits, vpDistance, vpAtomID; - function init(btype, _probeRadius, _scaleFactor, _cutoff, _setAtomID) { - probeRadius = _probeRadius || 1.4; - scaleFactor = _scaleFactor || 2.0; - setAtomID = _setAtomID || true; - var maxRadius = 0; - for (var radius in radiusDict) { - maxRadius = Math.max(maxRadius, radius); - } - var grid = getSurfaceGrid(min, max, maxRadius, scaleFactor, btype ? probeRadius : 0); - pLength = grid.dim[0]; - pWidth = grid.dim[1]; - pHeight = grid.dim[2]; - matrix = grid.matrix; - ptran = grid.tran; - scaleFactor = grid.scaleFactor; - // boundingatom caches - depty = {}; - widxz = {}; - boundingatom(btype); - cutRadius = probeRadius * scaleFactor; - if (_cutoff) { - cutoff = _cutoff; - } - else { - // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius ); - cutoff = probeRadius / scaleFactor; - } - vpBits = new Uint8Array(pLength * pWidth * pHeight); - if (btype) { - vpDistance = new Float64Array(pLength * pWidth * pHeight); - } - if (setAtomID) { - vpAtomID = new Int32Array(pLength * pWidth * pHeight); - } - } - // constants for vpBits bitmasks - var INOUT = 1; - var ISDONE = 2; - var ISBOUND = 4; - var nb = [ - new Int32Array([1, 0, 0]), new Int32Array([-1, 0, 0]), - new Int32Array([0, 1, 0]), new Int32Array([0, -1, 0]), - new Int32Array([0, 0, 1]), new Int32Array([0, 0, -1]), - new Int32Array([1, 1, 0]), new Int32Array([1, -1, 0]), - new Int32Array([-1, 1, 0]), new Int32Array([-1, -1, 0]), - new Int32Array([1, 0, 1]), new Int32Array([1, 0, -1]), - new Int32Array([-1, 0, 1]), new Int32Array([-1, 0, -1]), - new Int32Array([0, 1, 1]), new Int32Array([0, 1, -1]), - new Int32Array([0, -1, 1]), new Int32Array([0, -1, -1]), - new Int32Array([1, 1, 1]), new Int32Array([1, 1, -1]), - new Int32Array([1, -1, 1]), new Int32Array([-1, 1, 1]), - new Int32Array([1, -1, -1]), new Int32Array([-1, -1, 1]), - new Int32Array([-1, 1, -1]), new Int32Array([-1, -1, -1]) - ]; - // - this.getVolume = function (type, probeRadius, scaleFactor, cutoff, setAtomID) { - console.time('EDTSurface.getVolume'); - var btype = type !== 'vws'; - init(btype, probeRadius, scaleFactor, cutoff, setAtomID); - fillvoxels(btype); - buildboundary(); - if (type === 'ms' || type === 'ses') { - fastdistancemap(); - } - if (type === 'ses') { - boundingatom(false); - fillvoxelswaals(); - } - marchingcubeinit(type); - // set atomindex in the volume data - for (var i = 0, il = vpAtomID.length; i < il; ++i) { - vpAtomID[i] = indexList[vpAtomID[i]]; - } - console.timeEnd('EDTSurface.getVolume'); - return { - data: vpBits, - nx: pHeight, - ny: pWidth, - nz: pLength, - atomindex: vpAtomID - }; - }; - this.getSurface = function (type, probeRadius, scaleFactor, cutoff, setAtomID, smooth, contour) { - var vd = this.getVolume(type, probeRadius, scaleFactor, cutoff, setAtomID); - var volsurf = new VolumeSurface(vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex); - return volsurf.getSurface(1, smooth, undefined, matrix, contour); - }; - function boundingatom(btype) { - var r; - var j; - var k; - var txz; - var tdept; - var sradius; - var tradius; - var widxzR; - var deptyName; - var indx; - for (var name in radiusDict) { - r = parseFloat(name); - if (depty[name]) - { continue; } - if (!btype) { - tradius = r * scaleFactor + 0.5; - } - else { - tradius = (r + probeRadius) * scaleFactor + 0.5; - } - sradius = tradius * tradius; - widxzR = Math.floor(tradius) + 1; - deptyName = new Int32Array(widxzR * widxzR); - indx = 0; - for (j = 0; j < widxzR; ++j) { - for (k = 0; k < widxzR; ++k) { - txz = j * j + k * k; - if (txz > sradius) { - deptyName[indx] = -1; - } - else { - tdept = Math.sqrt(sradius - txz); - deptyName[indx] = Math.floor(tdept); - } - ++indx; - } - } - widxz[name] = widxzR; - depty[name] = deptyName; - } - } - function fillatom(idx) { - var ci = idx * 3; - var ri = idx; - var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk; - var ii, jj, kk; - cx = Math.floor(0.5 + scaleFactor * (coordList[ci] + ptran[0])); - cy = Math.floor(0.5 + scaleFactor * (coordList[ci + 1] + ptran[1])); - cz = Math.floor(0.5 + scaleFactor * (coordList[ci + 2] + ptran[2])); - var at = radiusList[ri]; - var deptyAt = depty[at]; - var nind = 0; - var pWH = pWidth * pHeight; - var n = widxz[at]; - var deptyAtNind; - for (i = 0; i < n; ++i) { - for (j = 0; j < n; ++j) { - deptyAtNind = deptyAt[nind]; - if (deptyAtNind !== -1) { - for (ii = -1; ii < 2; ++ii) { - for (jj = -1; jj < 2; ++jj) { - for (kk = -1; kk < 2; ++kk) { - if (ii !== 0 && jj !== 0 && kk !== 0) { - mi = ii * i; - mk = kk * j; - for (k = 0; k <= deptyAtNind; ++k) { - mj = k * jj; - si = cx + mi; - sj = cy + mj; - sk = cz + mk; - if (si < 0 || sj < 0 || sk < 0 || - si >= pLength || sj >= pWidth || sk >= pHeight) { - continue; - } - var index = si * pWH + sj * pHeight + sk; - if (!setAtomID) { - vpBits[index] |= INOUT; - } - else { - if (!(vpBits[index] & INOUT)) { - vpBits[index] |= INOUT; - vpAtomID[index] = idx; - } - else if (vpBits[index] & INOUT) { - var ci2 = vpAtomID[index]; - if (ci2 !== ci) { - ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0])); - oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1])); - oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2])); - if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) { - vpAtomID[index] = idx; - } - } - } - } - } // k - } // if - } // kk - } // jj - } // ii - } // if - nind++; - } // j - } // i - } - function fillvoxels(btype) { - console.time('EDTSurface fillvoxels'); - var i, il; - for (i = 0, il = vpBits.length; i < il; ++i) { - vpBits[i] = 0; - if (btype) - { vpDistance[i] = -1.0; } - if (setAtomID) - { vpAtomID[i] = -1; } - } - for (i = 0, il = coordList.length / 3; i < il; ++i) { - fillatom(i); - } - for (i = 0, il = vpBits.length; i < il; ++i) { - if (vpBits[i] & INOUT) { - vpBits[i] |= ISDONE; - } - } - console.timeEnd('EDTSurface fillvoxels'); - } - function fillAtomWaals(idx) { - var ci = idx * 3; - var ri = idx; - var cx; - var cy; - var cz; - var ox; - var oy; - var oz; - var nind = 0; - var mi; - var mj; - var mk; - var si; - var sj; - var sk; - var i; - var j; - var k; - var ii; - var jj; - var kk; - var n; - cx = Math.floor(0.5 + scaleFactor * (coordList[ci] + ptran[0])); - cy = Math.floor(0.5 + scaleFactor * (coordList[ci + 1] + ptran[1])); - cz = Math.floor(0.5 + scaleFactor * (coordList[ci + 2] + ptran[2])); - var at = radiusList[ri]; - var pWH = pWidth * pHeight; - for (i = 0, n = widxz[at]; i < n; ++i) { - for (j = 0; j < n; ++j) { - if (depty[at][nind] !== -1) { - for (ii = -1; ii < 2; ++ii) { - for (jj = -1; jj < 2; ++jj) { - for (kk = -1; kk < 2; ++kk) { - if (ii !== 0 && jj !== 0 && kk !== 0) { - mi = ii * i; - mk = kk * j; - for (k = 0; k <= depty[at][nind]; ++k) { - mj = k * jj; - si = cx + mi; - sj = cy + mj; - sk = cz + mk; - if (si < 0 || sj < 0 || sk < 0 || - si >= pLength || sj >= pWidth || sk >= pHeight) { - continue; - } - var index = si * pWH + sj * pHeight + sk; - if (!(vpBits[index] & ISDONE)) { - vpBits[index] |= ISDONE; - if (setAtomID) - { vpAtomID[index] = idx; } - } - else if (setAtomID) { - var ci2 = vpAtomID[index]; - ox = Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0])); - oy = Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1])); - oz = Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2])); - if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) { - vpAtomID[index] = idx; - } - } - } // k - } // if - } // kk - } // jj - } // ii - } // if - nind++; - } // j - } // i - } - function fillvoxelswaals() { - var i, il; - for (i = 0, il = vpBits.length; i < il; ++i) { - vpBits[i] &= ~ISDONE; // not isdone - } - for (i = 0, il = coordList.length / 3; i < il; ++i) { - fillAtomWaals(i); - } - } - function buildboundary() { - var i, j, k; - var pWH = pWidth * pHeight; - for (i = 0; i < pLength; ++i) { - for (j = 0; j < pHeight; ++j) { - for (k = 0; k < pWidth; ++k) { - var index = i * pWH + k * pHeight + j; - if (vpBits[index] & INOUT) { - // var flagbound = false; - var ii = 0; - // while( !flagbound && ii < 26 ){ - while (ii < 26) { - var ti = i + nb[ii][0]; - var tj = j + nb[ii][2]; - var tk = k + nb[ii][1]; - if (ti > -1 && ti < pLength && - tk > -1 && tk < pWidth && - tj > -1 && tj < pHeight && - !(vpBits[ti * pWH + tk * pHeight + tj] & INOUT)) { - vpBits[index] |= ISBOUND; - // flagbound = true; - break; - } - else { - ii++; - } - } - } - } // k - } // j - } // i - } - function fastdistancemap() { - console.time('EDTSurface fastdistancemap'); - var i, j, k, n; - var boundPoint = makeGrid(pLength, pWidth, pHeight, Uint16Array, 3); - var pWH = pWidth * pHeight; - var cutRSq = cutRadius * cutRadius; - var totalsurfacevox = 0; - // var totalinnervox = 0; - var index; - for (i = 0; i < pLength; ++i) { - for (j = 0; j < pWidth; ++j) { - for (k = 0; k < pHeight; ++k) { - index = i * pWH + j * pHeight + k; - vpBits[index] &= ~ISDONE; - if (vpBits[index] & INOUT) { - if (vpBits[index] & ISBOUND) { - boundPoint.set(i, j, k, i, j, k); - vpDistance[index] = 0; - vpBits[index] |= ISDONE; - totalsurfacevox += 1; - } /* else{ - totalinnervox += 1; - } */ - } - } - } - } - var inarray = new Int32Array(3 * totalsurfacevox); - var positin = 0; - var outarray = new Int32Array(3 * totalsurfacevox); - var positout = 0; - for (i = 0; i < pLength; ++i) { - for (j = 0; j < pWidth; ++j) { - for (k = 0; k < pHeight; ++k) { - index = i * pWH + j * pHeight + k; - if (vpBits[index] & ISBOUND) { - inarray[positin] = i; - inarray[positin + 1] = j; - inarray[positin + 2] = k; - positin += 3; - vpBits[index] &= ~ISBOUND; - } - } - } - } - do { - positout = fastoneshell(inarray, boundPoint, positin, outarray); - positin = 0; - for (i = 0, n = positout; i < n; i += 3) { - index = pWH * outarray[i] + pHeight * outarray[i + 1] + outarray[i + 2]; - vpBits[index] &= ~ISBOUND; - if (vpDistance[index] <= 1.0404 * cutRSq) { - // if( vpDistance[ index ] <= 1.02 * cutRadius ){ - inarray[positin] = outarray[i]; - inarray[positin + 1] = outarray[i + 1]; - inarray[positin + 2] = outarray[i + 2]; - positin += 3; - } - } - } while (positin > 0); - // var cutsf = Math.max( 0, scaleFactor - 0.5 ); - // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf ); - var cutoffSq = cutoff * cutoff; - var index2; - var bp = new Uint16Array(3); - for (i = 0; i < pLength; ++i) { - for (j = 0; j < pWidth; ++j) { - for (k = 0; k < pHeight; ++k) { - index = i * pWH + j * pHeight + k; - vpBits[index] &= ~ISBOUND; - // ses solid - if (vpBits[index] & INOUT) { - if (!(vpBits[index] & ISDONE) || - ((vpBits[index] & ISDONE) && vpDistance[index] >= cutoffSq)) { - vpBits[index] |= ISBOUND; - if (setAtomID && (vpBits[index] & ISDONE)) { - boundPoint.toArray(i, j, k, bp); - index2 = bp[0] * pWH + bp[1] * pHeight + bp[2]; - vpAtomID[index] = vpAtomID[index2]; - } - } - } - } - } - } - console.timeEnd('EDTSurface fastdistancemap'); - } - function fastoneshell(inarray, boundPoint, positin, outarray) { - // *allocout,voxel2 - // ***boundPoint, int* - // outnum, int *elimi) - var tx, ty, tz; - var dx, dy, dz; - var i, j, n; - var square; - var index; - var nbj; - var bp = new Uint16Array(3); - var positout = 0; - if (positin === 0) { - return positout; - } - var tnvix = -1; - var tnviy = -1; - var tnviz = -1; - var pWH = pWidth * pHeight; - for (i = 0, n = positin; i < n; i += 3) { - tx = inarray[i]; - ty = inarray[i + 1]; - tz = inarray[i + 2]; - boundPoint.toArray(tx, ty, tz, bp); - for (j = 0; j < 6; ++j) { - nbj = nb[j]; - tnvix = tx + nbj[0]; - tnviy = ty + nbj[1]; - tnviz = tz + nbj[2]; - if (tnvix < pLength && tnvix > -1 && - tnviy < pWidth && tnviy > -1 && - tnviz < pHeight && tnviz > -1) { - index = tnvix * pWH + pHeight * tnviy + tnviz; - if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) { - boundPoint.fromArray(tnvix, tnviy, tnviz, bp); - dx = tnvix - bp[0]; - dy = tnviy - bp[1]; - dz = tnviz - bp[2]; - square = dx * dx + dy * dy + dz * dz; - // square = Math.sqrt( square ); - vpDistance[index] = square; - vpBits[index] |= ISDONE; - vpBits[index] |= ISBOUND; - outarray[positout] = tnvix; - outarray[positout + 1] = tnviy; - outarray[positout + 2] = tnviz; - positout += 3; - } - else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) { - dx = tnvix - bp[0]; - dy = tnviy - bp[1]; - dz = tnviz - bp[2]; - square = dx * dx + dy * dy + dz * dz; - // square = Math.sqrt( square ); - if (square < vpDistance[index]) { - boundPoint.fromArray(tnvix, tnviy, tnviz, bp); - vpDistance[index] = square; - if (!(vpBits[index] & ISBOUND)) { - vpBits[index] |= ISBOUND; - outarray[positout] = tnvix; - outarray[positout + 1] = tnviy; - outarray[positout + 2] = tnviz; - positout += 3; - } - } - } - } - } - } - for (i = 0, n = positin; i < n; i += 3) { - tx = inarray[i]; - ty = inarray[i + 1]; - tz = inarray[i + 2]; - boundPoint.toArray(tx, ty, tz, bp); - for (j = 6; j < 18; j++) { - nbj = nb[j]; - tnvix = tx + nbj[0]; - tnviy = ty + nbj[1]; - tnviz = tz + nbj[2]; - if (tnvix < pLength && tnvix > -1 && - tnviy < pWidth && tnviy > -1 && - tnviz < pHeight && tnviz > -1) { - index = tnvix * pWH + pHeight * tnviy + tnviz; - if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) { - boundPoint.fromArray(tnvix, tnviy, tnviz, bp); - dx = tnvix - bp[0]; - dy = tnviy - bp[1]; - dz = tnviz - bp[2]; - square = dx * dx + dy * dy + dz * dz; - // square = Math.sqrt( square ); - vpDistance[index] = square; - vpBits[index] |= ISDONE; - vpBits[index] |= ISBOUND; - outarray[positout] = tnvix; - outarray[positout + 1] = tnviy; - outarray[positout + 2] = tnviz; - positout += 3; - } - else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) { - dx = tnvix - bp[0]; - dy = tnviy - bp[1]; - dz = tnviz - bp[2]; - square = dx * dx + dy * dy + dz * dz; - // square = Math.sqrt( square ); - if (square < vpDistance[index]) { - boundPoint.fromArray(tnvix, tnviy, tnviz, bp); - vpDistance[index] = square; - if (!(vpBits[index] & ISBOUND)) { - vpBits[index] |= ISBOUND; - outarray[positout] = tnvix; - outarray[positout + 1] = tnviy; - outarray[positout + 2] = tnviz; - positout += 3; - } - } - } - } - } - } - for (i = 0, n = positin; i < n; i += 3) { - tx = inarray[i]; - ty = inarray[i + 1]; - tz = inarray[i + 2]; - boundPoint.toArray(tx, ty, tz, bp); - for (j = 18; j < 26; j++) { - nbj = nb[j]; - tnvix = tx + nbj[0]; - tnviy = ty + nbj[1]; - tnviz = tz + nbj[2]; - if (tnvix < pLength && tnvix > -1 && - tnviy < pWidth && tnviy > -1 && - tnviz < pHeight && tnviz > -1) { - index = tnvix * pWH + pHeight * tnviy + tnviz; - if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) { - boundPoint.fromArray(tnvix, tnviy, tnviz, bp); - dx = tnvix - bp[0]; - dy = tnviy - bp[1]; - dz = tnviz - bp[2]; - square = dx * dx + dy * dy + dz * dz; - // square = Math.sqrt( square ); - vpDistance[index] = square; - vpBits[index] |= ISDONE; - vpBits[index] |= ISBOUND; - outarray[positout] = tnvix; - outarray[positout + 1] = tnviy; - outarray[positout + 2] = tnviz; - positout += 3; - } - else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) { - dx = tnvix - bp[0]; - dy = tnviy - bp[1]; - dz = tnviz - bp[2]; - square = dx * dx + dy * dy + dz * dz; - // square = Math.sqrt( square ); - if (square < vpDistance[index]) { - boundPoint.fromArray(tnvix, tnviy, tnviz, bp); - vpDistance[index] = square; - if (!(vpBits[index] & ISBOUND)) { - vpBits[index] |= ISBOUND; - outarray[positout] = tnvix; - outarray[positout + 1] = tnviy; - outarray[positout + 2] = tnviz; - positout += 3; - } - } - } - } - } - } - return positout; - } - function marchingcubeinit(stype) { - var i; - var n = vpBits.length; - if (stype === 'vws') { - for (i = 0; i < n; ++i) { - vpBits[i] &= ~ISBOUND; - vpBits[i] = (vpBits[i] & ISDONE) ? 1 : 0; - } - } - else if (stype === 'ms') { // ses without vdw => ms - for (i = 0; i < n; ++i) { - vpBits[i] &= ~ISDONE; - if (vpBits[i] & ISBOUND) { - vpBits[i] |= ISDONE; - } - vpBits[i] &= ~ISBOUND; - vpBits[i] = (vpBits[i] & ISDONE) ? 1 : 0; - } - } - else if (stype === 'ses') { - for (i = 0; i < n; ++i) { - if ((vpBits[i] & ISBOUND) && (vpBits[i] & ISDONE)) { - vpBits[i] &= ~ISBOUND; - } - else if ((vpBits[i] & ISBOUND) && !(vpBits[i] & ISDONE)) { - vpBits[i] |= ISDONE; - } - vpBits[i] = (vpBits[i] & ISDONE) ? 1 : 0; - } - } - else if (stype === 'sas') { - for (i = 0; i < n; ++i) { - vpBits[i] &= ~ISBOUND; - vpBits[i] = (vpBits[i] & ISDONE) ? 1 : 0; - } - } - } -} -Object.assign(EDTSurface, { __deps: [ - getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid - ] }); - -/** - * @file AV Surface - * @author Fred Ludlow - * @private - */ -function makeAVHash(atomsX, atomsY, atomsZ, atomsR, min, max, maxDistance) { - maxDistance = Math.max(0.1, maxDistance); // Avoid maxDistance of zero, see #802 - var nAtoms = atomsX.length; - var minX = min[0]; - var minY = min[1]; - var minZ = min[2]; - var maxX = max[0]; - var maxY = max[1]; - var maxZ = max[2]; - function hashFunc(w, minW) { - return Math.floor((w - minW) / maxDistance); - } - var iDim = hashFunc(maxX, minX) + 1; - var jDim = hashFunc(maxY, minY) + 1; - var kDim = hashFunc(maxZ, minZ) + 1; - var nCells = iDim * jDim * kDim; - var jkDim = jDim * kDim; - /* Get cellID for cartesian x,y,z */ - var cellID = function (x, y, z) { - return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ); - }; - /* Initial building, could probably be optimized further */ - var preHash = []; // preHash[ cellID ] = [ atomId1, atomId2 ]; - for (var i = 0; i < nAtoms; i++) { - var cid = cellID(atomsX[i], atomsY[i], atomsZ[i]); - if (preHash[cid] === undefined) { - preHash[cid] = [i]; - } - else { - preHash[cid].push(i); - } - } - var cellOffsets = new Uint32Array(nCells); - var cellLengths = new Uint16Array(nCells); - var data = new Uint32Array(nAtoms); - var offset = 0; - var maxCellLength = 0; - for (i = 0; i < nCells; i++) { - var start = cellOffsets[i] = offset; - var subArray = preHash[i]; - if (subArray !== undefined) { - for (var j = 0; j < subArray.length; j++) { - data[offset] = subArray[j]; - offset++; - } - } - var cellLength = offset - start; - cellLengths[i] = cellLength; - if (cellLength > maxCellLength) { - maxCellLength = cellLength; - } - } - // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population) - var neighbourListLength = (27 * maxCellLength) + 1; - /** - * Populate the supplied out array with atom indices that are within rAtom + rExtra - * of x,y,z - * - * -1 in out array indicates the end of the list - * - * @param {Float} x - x coordinate - * @param {Float} y - y coordinate - * @param {Float} z - z coordinate - * @param {Float} rExtra - additional radius - * @param {Float32Array} out - pre-allocated output array - * @return {undefined} - */ - var withinRadii = function (x, y, z, rExtra, out) { - var outIdx = 0; - var nearI = hashFunc(x, minX); - var nearJ = hashFunc(y, minY); - var nearK = hashFunc(z, minZ); - var loI = Math.max(0, nearI - 1); - var loJ = Math.max(0, nearJ - 1); - var loK = Math.max(0, nearK - 1); - var hiI = Math.min(iDim, nearI + 2); - var hiJ = Math.min(jDim, nearJ + 2); - var hiK = Math.min(kDim, nearK + 2); - for (var i = loI; i < hiI; ++i) { - var iOffset = i * jkDim; - for (var j = loJ; j < hiJ; ++j) { - var jOffset = j * kDim; - for (var k = loK; k < hiK; ++k) { - var cid = iOffset + jOffset + k; - var cellStart = cellOffsets[cid]; - var cellEnd = cellStart + cellLengths[cid]; - for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) { - var atomIndex = data[dataIndex]; - var dx = atomsX[atomIndex] - x; - var dy = atomsY[atomIndex] - y; - var dz = atomsZ[atomIndex] - z; - var rSum = atomsR[atomIndex] + rExtra; - if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) { - out[outIdx++] = data[dataIndex]; - } - } - } - } - } - // Add terminator - out[outIdx] = -1; - }; - return { - neighbourListLength: neighbourListLength, - withinRadii: withinRadii - }; -} -function AVSurface(coordList, radiusList, indexList) { - // Field generation method adapted from AstexViewer (Mike Hartshorn) - // by Fred Ludlow. - // Other parts based heavily on NGL (Alexander Rose) EDT Surface class - // - // Should work as a drop-in alternative to EDTSurface (though some of - // the EDT paramters are not relevant in this method). - var nAtoms = radiusList.length; - var x = new Float32Array(nAtoms); - var y = new Float32Array(nAtoms); - var z = new Float32Array(nAtoms); - for (var i = 0; i < nAtoms; i++) { - var ci = 3 * i; - x[i] = coordList[ci]; - y[i] = coordList[ci + 1]; - z[i] = coordList[ci + 2]; - } - var bbox = computeBoundingBox(coordList); - if (coordList.length === 0) { - bbox[0].set([0, 0, 0]); - bbox[1].set([0, 0, 0]); - } - var min = bbox[0]; - var max = bbox[1]; - var r, r2; // Atom positions, expanded radii (squared) - var maxRadius; - // Parameters - var probeRadius, scaleFactor, setAtomID, probePositions; - // Cache last value for obscured test - var lastClip = -1; - // Grid params - var dim, matrix, grid, atomIndex; - // grid indices -> xyz coords - var gridx, gridy, gridz; - // Lookup tables: - var sinTable, cosTable; - // Spatial Hash - var hash; - // Neighbour array to be filled by hash - var neighbours; - // Vectors for Torus Projection - var atob = new Float32Array([0.0, 0.0, 0.0]); - var mid = new Float32Array([0.0, 0.0, 0.0]); - var n1 = new Float32Array([0.0, 0.0, 0.0]); - var n2 = new Float32Array([0.0, 0.0, 0.0]); - var ngTorus; - function init(_probeRadius, _scaleFactor, _setAtomID, _probePositions) { - probeRadius = defaults(_probeRadius, 1.4); - scaleFactor = defaults(_scaleFactor, 2.0); - setAtomID = defaults(_setAtomID, true); - probePositions = defaults(_probePositions, 30); - r = new Float32Array(nAtoms); - r2 = new Float32Array(nAtoms); - for (var i = 0; i < r.length; ++i) { - var rExt = radiusList[i] + probeRadius; - r[i] = rExt; - r2[i] = rExt * rExt; - } - maxRadius = 0; - for (var j = 0; j < r.length; ++j) { - if (r[j] > maxRadius) - { maxRadius = r[j]; } - } - initializeGrid(); - initializeAngleTables(); - initializeHash(); - lastClip = -1; - } - function fillGridDim(a, start, step) { - for (var i = 0; i < a.length; i++) { - a[i] = start + (step * i); - } - } - function initializeGrid() { - var surfGrid = getSurfaceGrid(min, max, maxRadius, scaleFactor, 0.0); - scaleFactor = surfGrid.scaleFactor; - dim = surfGrid.dim; - matrix = surfGrid.matrix; - ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor)); - grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0); - atomIndex = new Int32Array(grid.length); - gridx = new Float32Array(dim[0]); - gridy = new Float32Array(dim[1]); - gridz = new Float32Array(dim[2]); - fillGridDim(gridx, min[0], 1 / scaleFactor); - fillGridDim(gridy, min[1], 1 / scaleFactor); - fillGridDim(gridz, min[2], 1 / scaleFactor); - } - function initializeAngleTables() { - var theta = 0.0; - var step = 2 * Math.PI / probePositions; - cosTable = new Float32Array(probePositions); - sinTable = new Float32Array(probePositions); - for (var i = 0; i < probePositions; i++) { - cosTable[i] = Math.cos(theta); - sinTable[i] = Math.sin(theta); - theta += step; - } - } - function initializeHash() { - hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius); - neighbours = new Int32Array(hash.neighbourListLength); - } - function obscured(x, y, z, a, b) { - // Is the point at x,y,z obscured by any of the atoms - // specifeid by indices in neighbours. Ignore indices - // a and b (these are the relevant atoms in projectPoints/Torii) - // Cache the last clipped atom (as very often the same one in - // subsequent calls) - var ai; - if (lastClip !== -1) { - ai = lastClip; - if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) { - return ai; - } - else { - lastClip = -1; - } - } - var ni = 0; - ai = neighbours[ni]; - while (ai >= 0) { - if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) { - lastClip = ai; - return ai; - } - ai = neighbours[++ni]; - } - lastClip = -1; - return -1; - } - function singleAtomObscures(ai, x, y, z) { - var ci = 3 * ai; - var ra2 = r2[ai]; - var dx = coordList[ci] - x; - var dy = coordList[ci + 1] - y; - var dz = coordList[ci + 2] - z; - var d2 = dx * dx + dy * dy + dz * dz; - return d2 < ra2; - } - function projectPoints() { - // For each atom: - // Iterate over a subsection of the grid, for each point: - // If current value < 0.0, unvisited, set positive - // - // In any case: Project this point onto surface of the atomic sphere - // If this projected point is not obscured by any other atom - // Calcualte delta distance and set grid value to minimum of - // itself and delta - // Should we alias frequently accessed closure variables?? - // Assume JS engine capable of optimizing this - // anyway... - for (var i = 0; i < nAtoms; i++) { - var ax = x[i]; - var ay = y[i]; - var az = z[i]; - var ar = r[i]; - var ar2 = r2[i]; - hash.withinRadii(ax, ay, az, ar, neighbours); - // Number of grid points, round this up... - var ng = Math.ceil(ar * scaleFactor); - // Center of the atom, mapped to grid points (take floor) - var iax = Math.floor(scaleFactor * (ax - min[0])); - var iay = Math.floor(scaleFactor * (ay - min[1])); - var iaz = Math.floor(scaleFactor * (az - min[2])); - // Extents of grid to consider for this atom - var minx = Math.max(0, iax - ng); - var miny = Math.max(0, iay - ng); - var minz = Math.max(0, iaz - ng); - // Add two to these points: - // - iax are floor'd values so this ensures coverage - // - these are loop limits (exclusive) - var maxx = Math.min(dim[0], iax + ng + 2); - var maxy = Math.min(dim[1], iay + ng + 2); - var maxz = Math.min(dim[2], iaz + ng + 2); - for (var ix = minx; ix < maxx; ix++) { - var dx = gridx[ix] - ax; - var xoffset = dim[1] * dim[2] * ix; - for (var iy = miny; iy < maxy; iy++) { - var dy = gridy[iy] - ay; - var dxy2 = dx * dx + dy * dy; - var xyoffset = xoffset + dim[2] * iy; - for (var iz = minz; iz < maxz; iz++) { - var dz = gridz[iz] - az; - var d2 = dxy2 + dz * dz; - if (d2 < ar2) { - var idx = iz + xyoffset; - if (grid[idx] < 0.0) { - // Unvisited, make positive - grid[idx] = -grid[idx]; - } - // Project on to the surface of the sphere - // sp is the projected point ( dx, dy, dz ) * ( ra / d ) - var d = Math.sqrt(d2); - var ap = ar / d; - var spx = dx * ap; - var spy = dy * ap; - var spz = dz * ap; - spx += ax; - spy += ay; - spz += az; - if (obscured(spx, spy, spz, i, -1) === -1) { - var dd = ar - d; - if (dd < grid[idx]) { - grid[idx] = dd; - if (setAtomID) - { atomIndex[idx] = i; } - } - } - } - } - } - } - } - } - function projectTorii() { - for (var i = 0; i < nAtoms; i++) { - hash.withinRadii(x[i], y[i], z[i], r[i], neighbours); - var ia = 0; - var ni = neighbours[ia]; - while (ni >= 0) { - if (i < ni) { - projectTorus(i, ni); - } - ni = neighbours[++ia]; - } - } - } - function projectTorus(a, b) { - var r1 = r[a]; - var r2 = r[b]; - var dx = atob[0] = x[b] - x[a]; - var dy = atob[1] = y[b] - y[a]; - var dz = atob[2] = z[b] - z[a]; - var d2 = dx * dx + dy * dy + dz * dz; - // This check now redundant as already done in AVHash.withinRadii - // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; } - var d = Math.sqrt(d2); - // Find angle between a->b vector and the circle - // of their intersection by cosine rule - var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d); - // distance along a->b at intersection - var dmp = r1 * cosA; - v3normalize(atob, atob); - // Create normal to line - normalToLine(n1, atob); - v3normalize(n1, n1); - // Cross together for second normal vector - v3cross(n2, atob, n1); - v3normalize(n2, n2); - // r is radius of circle of intersection - var rInt = Math.sqrt(r1 * r1 - dmp * dmp); - v3multiplyScalar(n1, n1, rInt); - v3multiplyScalar(n2, n2, rInt); - v3multiplyScalar(atob, atob, dmp); - mid[0] = atob[0] + x[a]; - mid[1] = atob[1] + y[a]; - mid[2] = atob[2] + z[a]; - lastClip = -1; - var ng = ngTorus; - for (var i = 0; i < probePositions; i++) { - var cost = cosTable[i]; - var sint = sinTable[i]; - var px = mid[0] + cost * n1[0] + sint * n2[0]; - var py = mid[1] + cost * n1[1] + sint * n2[1]; - var pz = mid[2] + cost * n1[2] + sint * n2[2]; - if (obscured(px, py, pz, a, b) === -1) { - // As above, iterate over our grid... - // px, py, pz in grid coords - var iax = Math.floor(scaleFactor * (px - min[0])); - var iay = Math.floor(scaleFactor * (py - min[1])); - var iaz = Math.floor(scaleFactor * (pz - min[2])); - var minx = Math.max(0, iax - ng); - var miny = Math.max(0, iay - ng); - var minz = Math.max(0, iaz - ng); - var maxx = Math.min(dim[0], iax + ng + 2); - var maxy = Math.min(dim[1], iay + ng + 2); - var maxz = Math.min(dim[2], iaz + ng + 2); - for (var ix = minx; ix < maxx; ix++) { - dx = px - gridx[ix]; - var xoffset = dim[1] * dim[2] * ix; - for (var iy = miny; iy < maxy; iy++) { - dy = py - gridy[iy]; - var dxy2 = dx * dx + dy * dy; - var xyoffset = xoffset + dim[2] * iy; - for (var iz = minz; iz < maxz; iz++) { - dz = pz - gridz[iz]; - d2 = dxy2 + dz * dz; - var idx = iz + xyoffset; - var current = grid[idx]; - if (current > 0.0 && d2 < (current * current)) { - grid[idx] = Math.sqrt(d2); - if (setAtomID) { - // Is this grid point closer to a or b? - // Take dot product of atob and gridpoint->p (dx, dy, dz) - var dp = dx * atob[0] + dy * atob[1] + dz * atob[2]; - atomIndex[idx] = dp < 0.0 ? b : a; - } - } - } - } - } - } - } - } - function normalToLine(out, p) { - out[0] = out[1] = out[2] = 1.0; - if (p[0] !== 0) { - out[0] = (p[1] + p[2]) / -p[0]; - } - else if (p[1] !== 0) { - out[1] = (p[0] + p[2]) / -p[1]; - } - else if (p[2] !== 0) { - out[2] = (p[0] + p[1]) / -p[2]; - } - return out; - } - function fixNegatives() { - for (var i = 0; i < grid.length; i++) { - if (grid[i] < 0) - { grid[i] = 0; } - } - } - function fixAtomIDs() { - for (var i = 0; i < atomIndex.length; i++) { - atomIndex[i] = indexList[atomIndex[i]]; - } - } - function getVolume(probeRadius, scaleFactor, setAtomID) { - // Basic steps are: - // 1) Initialize - // 2) Project points - // 3) Project torii - console.time('AVSurface.getVolume'); - console.time('AVSurface.init'); - init(probeRadius, scaleFactor, setAtomID); - console.timeEnd('AVSurface.init'); - console.time('AVSurface.projectPoints'); - projectPoints(); - console.timeEnd('AVSurface.projectPoints'); - console.time('AVSurface.projectTorii'); - projectTorii(); - console.timeEnd('AVSurface.projectTorii'); - fixNegatives(); - fixAtomIDs(); - console.timeEnd('AVSurface.getVolume'); - } - this.getSurface = function (type, probeRadius, scaleFactor, cutoff, setAtomID, smooth, contour) { - // type and cutoff left in for compatibility with EDTSurface.getSurface - // function signature - getVolume(probeRadius, scaleFactor, setAtomID); - var volsurf = new VolumeSurface(grid, dim[2], dim[1], dim[0], atomIndex); - return volsurf.getSurface(probeRadius, false, undefined, matrix, contour); - }; -} -Object.assign(AVSurface, { __deps: [ - getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox, - v3multiplyScalar, v3cross, v3normalize, - makeAVHash, - defaults - ] }); - -/** - * @file Molecular Surface - * @author Alexander Rose - * @private - */ -WorkerRegistry$1.add('molsurf', function func(e, callback) { - var a = e.data.args; - var p = e.data.params; - if (a && p) { - var SurfClass = (p.type === 'av') ? AVSurface : EDTSurface; - var surf = new SurfClass(a.coordList, a.radiusList, a.indexList); - var sd = surf.getSurface(p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour); - var transferList = [sd.position.buffer, sd.index.buffer]; - if (sd.normal) - { transferList.push(sd.normal.buffer); } - if (sd.atomindex) - { transferList.push(sd.atomindex.buffer); } - var data = { - sd: sd, - p: p - }; - callback(data, transferList); - } -}, [EDTSurface, AVSurface]); -/** - * Create Molecular surfaces - */ -var MolecularSurface = function MolecularSurface(structure) { - this.structure = structure; -}; -MolecularSurface.prototype._getAtomData = function _getAtomData (params) { - return this.structure.getAtomData({ - what: { position: true, radius: true, index: true }, - radiusParams: defaults(params.radiusParams, { - type: 'vdw', scale: 1.0 - }) - }); -}; -MolecularSurface.prototype._makeSurface = function _makeSurface (sd, p) { - var surface = new Surface(p.name, '', sd); - surface.info.type = p.type; - surface.info.probeRadius = p.probeRadius; - surface.info.scaleFactor = p.scaleFactor; - surface.info.smooth = p.smooth; - surface.info.cutoff = p.cutoff; - return surface; -}; -/** - * Get molecular surface - * @param {MolecularSurfaceParameters} params - parameters for surface creation - * @return {Surface} the surface - */ -MolecularSurface.prototype.getSurface = function getSurface (params) { - var p = params || {}; - var atomData = this._getAtomData(params); - var coordList = atomData.position; - var radiusList = atomData.radius; - var indexList = atomData.index; - var SurfClass = (p.type === 'av') ? AVSurface : EDTSurface; - var surf = new SurfClass(coordList, radiusList, indexList); - var sd = surf.getSurface(p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour); - return this._makeSurface(sd, p); -}; -/** - * Get molecular surface asynchronous - * @param {MolecularSurfaceParameters} params - parameters for surface creation - * @param {function(surface: Surface)} callback - function to be called after surface is created - * @return {undefined} - */ -MolecularSurface.prototype.getSurfaceWorker = function getSurfaceWorker (params, callback) { - var this$1 = this; - - var p = Object.assign({}, params); - if (window.hasOwnProperty('Worker')) { - if (this.worker === undefined) { - this.worker = new _Worker('molsurf'); - } - var atomData = this._getAtomData(params); - var coordList = atomData.position; - var radiusList = atomData.radius; - var indexList = atomData.index; - var msg = { - args: { - coordList: coordList, - radiusList: radiusList, - indexList: indexList - }, - params: p - }; - var transferList = [ - coordList.buffer, radiusList.buffer, indexList.buffer - ]; - this.worker.post(msg, transferList, function (e) { - callback(this$1._makeSurface(e.data.sd, p)); - }, function (e) { - console.warn('MolecularSurface.getSurfaceWorker error - trying without worker', e); - this$1.worker.terminate(); - this$1.worker = undefined; - var surface = this$1.getSurface(p); - callback(surface); - }); - } - else { - var surface = this.getSurface(p); - callback(surface); - } -}; -/** - * Cleanup - * @return {undefined} - */ -MolecularSurface.prototype.dispose = function dispose () { - if (this.worker) - { this.worker.terminate(); } -}; - -/** - * @file Molecular Surface Representation - * @author Alexander Rose - * @private - */ -/** - * Molecular Surface Representation - */ -var MolecularSurfaceRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function MolecularSurfaceRepresentation(structure, viewer, params) { - var this$1 = this; - - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'surface'; - this.parameters = Object.assign({ - surfaceType: { - type: 'select', - rebuild: true, - options: { - 'vws': 'vws', - 'sas': 'sas', - 'ms': 'ms', - 'ses': 'ses', - 'av': 'av' - } - }, - probeRadius: { - type: 'number', - precision: 1, - max: 20, - min: 0, - rebuild: true - }, - smooth: { - type: 'integer', - precision: 1, - max: 10, - min: 0, - rebuild: true - }, - scaleFactor: { - type: 'number', - precision: 1, - max: 5, - min: 0, - rebuild: true - }, - cutoff: { - type: 'number', - precision: 2, - max: 50, - min: 0, - rebuild: true - }, - contour: { - type: 'boolean', rebuild: true - }, - background: { - type: 'boolean', rebuild: true // FIXME - }, - opaqueBack: { - type: 'boolean', buffer: true - }, - filterSele: { - type: 'text', rebuild: true - }, - colorVolume: { - type: 'hidden' - }, - useWorker: { - type: 'boolean', rebuild: true - } - }, this.parameters, { - radius: null, - scale: null - }); - this.__infoList = []; - // TODO find a more direct way - this.structure.signals.refreshed.add(function () { - this$1.__forceNewMolsurf = true; - }); - this.toBePrepared = true; - this.init(params); - } - - if ( StructureRepresentation$$1 ) MolecularSurfaceRepresentation.__proto__ = StructureRepresentation$$1; - MolecularSurfaceRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - MolecularSurfaceRepresentation.prototype.constructor = MolecularSurfaceRepresentation; - MolecularSurfaceRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'uniform'); - p.colorValue = defaults(p.colorValue, 0xDDDDDD); - p.disablePicking = defaults(p.disablePicking, true); - this.surfaceType = defaults(p.surfaceType, 'ms'); - this.probeRadius = defaults(p.probeRadius, 1.4); - this.smooth = defaults(p.smooth, 2); - this.scaleFactor = defaults(p.scaleFactor, 2.0); - this.cutoff = defaults(p.cutoff, 0.0); - this.contour = defaults(p.contour, false); - this.background = defaults(p.background, false); - this.opaqueBack = defaults(p.opaqueBack, true); - this.filterSele = defaults(p.filterSele, ''); - this.colorVolume = defaults(p.colorVolume, undefined); - this.useWorker = defaults(p.useWorker, true); - StructureRepresentation$$1.prototype.init.call(this, params); - }; - MolecularSurfaceRepresentation.prototype.prepareData = function prepareData (sview, i, callback) { - var info = this.__infoList[i]; - if (!info) { - info = {}; - this.__infoList[i] = info; - } - if (!info.molsurf || info.sele !== sview.selection.string) { - if (this.filterSele) { - var sviewFilter = sview.structure.getView(new Selection(this.filterSele)); - var bbSize = sviewFilter.boundingBox.getSize(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */]()); - var maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z); - var asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0); - sview = sview.getView(new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())); - if (sview.atomCount === 0) { - callback(i); - return; - } - } - info.sele = sview.selection.string; - info.molsurf = new MolecularSurface(sview); - var p = this.getSurfaceParams(); - var onSurfaceFinish = function (surface) { - info.surface = surface; - callback(i); - }; - if (this.useWorker) { - info.molsurf.getSurfaceWorker(p, onSurfaceFinish); - } - else { - onSurfaceFinish(info.molsurf.getSurface(p)); - } - } - else { - callback(i); - } - }; - MolecularSurfaceRepresentation.prototype.prepare = function prepare (callback) { - var this$1 = this; - - if (this.__forceNewMolsurf || this.__sele !== this.selection.string || - this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) { - this.__infoList.forEach(function (info) { - if (info && info.molsurf) { - info.molsurf.dispose(); - } - }); - this.__infoList.length = 0; - } - if (this.structureView.atomCount === 0) { - callback(); - return; - } - var after = function () { - this$1.__sele = this$1.selection.string; - this$1.__surfaceParams = JSON.stringify(this$1.getSurfaceParams()); - this$1.__forceNewMolsurf = false; - callback(); - }; - var name = this.assembly === 'default' ? this.defaultAssembly : this.assembly; - var assembly = this.structure.biomolDict[name]; - if (assembly) { - assembly.partList.forEach(function (part, i) { - var sview = part.getView(this$1.structureView); - this$1.prepareData(sview, i, function (_i) { - if (_i === assembly.partList.length - 1) - { after(); } - }); - }); - } - else { - this.prepareData(this.structureView, 0, after); - } - }; - MolecularSurfaceRepresentation.prototype.createData = function createData (sview, i) { - var info = this.__infoList[i]; - var surface = info.surface; - if (!surface) { - // Surface creation bailed (no surface generated for this sview) - return; - } - var surfaceData = { - position: surface.getPosition(), - color: surface.getColor(this.getColorParams()), - index: surface.getFilteredIndex(this.filterSele, sview) - }; - var bufferList = []; - if (surface.contour) { - var contourBuffer = new ContourBuffer(surfaceData, this.getBufferParams({ - wireframe: false - })); - bufferList.push(contourBuffer); - } - else { - Object.assign(surfaceData, { - normal: surface.getNormal(), - picking: surface.getPicking(sview.getStructure()) - }); - var surfaceBuffer = new SurfaceBuffer(surfaceData, this.getBufferParams({ - background: this.background, - opaqueBack: this.opaqueBack, - dullInterior: false - })); - if (this.getBufferParams().side == 'double') { - var doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer); - bufferList.push(doubleSidedBuffer); - } - else { - bufferList.push(surfaceBuffer); - } - } - return { bufferList: bufferList, info: info }; - }; - MolecularSurfaceRepresentation.prototype.updateData = function updateData (what, data) { - var surfaceData = {}; - if (what.position || what.radius) { - this.__forceNewMolsurf = true; - this.build(); - return; - } - if (what.color) { - surfaceData.color = data.info.surface.getColor(this.getColorParams()); - } - if (what.index) { - surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview); - } - data.bufferList[0].setAttributes(surfaceData); - }; - MolecularSurfaceRepresentation.prototype.setParameters = function setParameters (params, what, rebuild) { - if ( what === void 0 ) what = {}; - - if (params && params.filterSele) { - what.index = true; - } - if (params && params.colorVolume !== undefined) { - what.color = true; - } - // forbid setting wireframe to true when contour is true - if (params && params.wireframe && (params.contour || (params.contour === undefined && this.contour))) { - params.wireframe = false; - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - MolecularSurfaceRepresentation.prototype.getSurfaceParams = function getSurfaceParams (params) { - if ( params === void 0 ) params = {}; - - var p = Object.assign({ - type: this.surfaceType, - probeRadius: this.probeRadius, - scaleFactor: this.scaleFactor, - smooth: this.smooth && !this.contour, - cutoff: this.cutoff, - contour: this.contour, - useWorker: this.useWorker, - radiusParams: this.getRadiusParams() - }, params); - return p; - }; - MolecularSurfaceRepresentation.prototype.getColorParams = function getColorParams () { - var p = StructureRepresentation$$1.prototype.getColorParams.call(this); - p.volume = this.colorVolume; - return p; - }; - MolecularSurfaceRepresentation.prototype.getAtomRadius = function getAtomRadius () { - return 0; - }; - MolecularSurfaceRepresentation.prototype.clear = function clear () { - StructureRepresentation$$1.prototype.clear.call(this); - }; - MolecularSurfaceRepresentation.prototype.dispose = function dispose () { - this.__infoList.forEach(function (info) { - if (info && info.molsurf) { - info.molsurf.dispose(); - } - }); - this.__infoList.length = 0; - StructureRepresentation$$1.prototype.dispose.call(this); - }; - - return MolecularSurfaceRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('surface', MolecularSurfaceRepresentation); - -/** - * @file Point Representation - * @author Alexander Rose - * @private - */ -/** - * Point Representation - */ -var PointRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function PointRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'point'; - this.parameters = Object.assign({ - pointSize: { - type: 'number', precision: 1, max: 100, min: 0, buffer: true - }, - sizeAttenuation: { - type: 'boolean', buffer: true - }, - sortParticles: { - type: 'boolean', rebuild: true - }, - useTexture: { - type: 'boolean', buffer: true - }, - alphaTest: { - type: 'range', step: 0.001, max: 1, min: 0, buffer: true - }, - forceTransparent: { - type: 'boolean', buffer: true - }, - edgeBleach: { - type: 'range', step: 0.001, max: 1, min: 0, buffer: true - } - }, this.parameters, { - flatShaded: null, - wireframe: null, - linewidth: null, - side: null, - roughness: null, - metalness: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) PointRepresentation.__proto__ = StructureRepresentation$$1; - PointRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - PointRepresentation.prototype.constructor = PointRepresentation; - PointRepresentation.prototype.init = function init (params) { - var p = params || {}; - this.pointSize = defaults(p.pointSize, 1); - this.sizeAttenuation = defaults(p.sizeAttenuation, true); - this.sortParticles = defaults(p.sortParticles, false); - this.useTexture = defaults(p.useTexture, false); - this.alphaTest = defaults(p.alphaTest, 0.5); - this.forceTransparent = defaults(p.forceTransparent, false); - this.edgeBleach = defaults(p.edgeBleach, 0.0); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - PointRepresentation.prototype.createData = function createData (sview) { - var what = { position: true, color: true, picking: true }; - var atomData = sview.getAtomData(this.getAtomParams(what)); - var pointBuffer = new PointBuffer(atomData, this.getBufferParams({ - pointSize: this.pointSize, - sizeAttenuation: this.sizeAttenuation, - sortParticles: this.sortParticles, - useTexture: this.useTexture, - alphaTest: this.alphaTest, - forceTransparent: this.forceTransparent, - edgeBleach: this.edgeBleach - })); - return { - bufferList: [pointBuffer] - }; - }; - PointRepresentation.prototype.updateData = function updateData (what, data) { - var atomData = data.sview.getAtomData(this.getAtomParams(what)); - var pointData = {}; - if (!what || what.position) { - Object.assign(pointData, { position: atomData.position }); - } - if (!what || what.color) { - Object.assign(pointData, { color: atomData.color }); - } - data.bufferList[0].setAttributes(pointData); - }; - PointRepresentation.prototype.getAtomRadius = function getAtomRadius () { - return 0.1; - }; - - return PointRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('point', PointRepresentation); - -ShaderRegistry.add('shader/Ribbon.vert', "#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"); - -/** - * @file Ribbon Buffer - * @author Alexander Rose - * @private - */ -var quadIndices$1 = new Uint16Array([ - 0, 1, 2, - 1, 3, 2 -]); -function getSize$1(data) { - var n = (data.position.length / 3) - 1; - var n4 = n * 4; - var x = n4 * 3; - return x; -} -/** - * Ribbon buffer. Draws a thin ribbon. - */ -var RibbonBuffer = /*@__PURE__*/(function (MeshBuffer$$1) { - function RibbonBuffer(data, params) { - if ( params === void 0 ) params = {}; - - MeshBuffer$$1.call(this, { - position: new Float32Array(getSize$1(data)), - color: new Float32Array(getSize$1(data)), - index: getUintArray(getSize$1(data), getSize$1(data) / 3), - normal: new Float32Array(getSize$1(data)), - picking: data.picking - }, params); - this.vertexShader = 'Ribbon.vert'; - var n = (data.position.length / 3) - 1; - var n4 = n * 4; - var x = n4 * 3; - this.addAttributes({ - 'dir': { type: 'v3', value: new Float32Array(x) } - }); - this.addAttributes({ - 'size': { type: 'f', value: new Float32Array(n4) } - }); - data.primitiveId = serialArray(n); - this.setAttributes(data); - this.makeIndex(); - } - - if ( MeshBuffer$$1 ) RibbonBuffer.__proto__ = MeshBuffer$$1; - RibbonBuffer.prototype = Object.create( MeshBuffer$$1 && MeshBuffer$$1.prototype ); - RibbonBuffer.prototype.constructor = RibbonBuffer; - RibbonBuffer.prototype.setAttributes = function setAttributes (data) { - if ( data === void 0 ) data = {}; - - var n4 = this.size; - var n = n4 / 4; - var attributes = this.geometry.attributes; // TODO - var position, normal, size, dir, color, primitiveId; - var aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId; - if (data.position) { - position = data.position; - aPosition = attributes.position.array; - attributes.position.needsUpdate = true; - } - if (data.normal) { - normal = data.normal; - aNormal = attributes.normal.array; - attributes.normal.needsUpdate = true; - } - if (data.size) { - size = data.size; - aSize = attributes.size.array; - attributes.size.needsUpdate = true; - } - if (data.dir) { - dir = data.dir; - aDir = attributes.dir.array; - attributes.dir.needsUpdate = true; - } - if (data.color) { - color = data.color; - aColor = attributes.color.array; - attributes.color.needsUpdate = true; - } - if (data.primitiveId) { - primitiveId = data.primitiveId; - aPrimitiveId = attributes.primitiveId.array; - attributes.primitiveId.needsUpdate = true; - } - var v, i, k, p, l, v3; - var currSize; - var prevSize = size ? size[0] : null; - for (v = 0; v < n; ++v) { - v3 = v * 3; - k = v * 3 * 4; - l = v * 4; - if (position) { - aPosition[k] = aPosition[k + 3] = position[v3]; - aPosition[k + 1] = aPosition[k + 4] = position[v3 + 1]; - aPosition[k + 2] = aPosition[k + 5] = position[v3 + 2]; - aPosition[k + 6] = aPosition[k + 9] = position[v3 + 3]; - aPosition[k + 7] = aPosition[k + 10] = position[v3 + 4]; - aPosition[k + 8] = aPosition[k + 11] = position[v3 + 5]; - } - if (normal) { - aNormal[k] = aNormal[k + 3] = -normal[v3]; - aNormal[k + 1] = aNormal[k + 4] = -normal[v3 + 1]; - aNormal[k + 2] = aNormal[k + 5] = -normal[v3 + 2]; - aNormal[k + 6] = aNormal[k + 9] = -normal[v3 + 3]; - aNormal[k + 7] = aNormal[k + 10] = -normal[v3 + 4]; - aNormal[k + 8] = aNormal[k + 11] = -normal[v3 + 5]; - } - for (i = 0; i < 4; ++i) { - p = k + 3 * i; - if (color) { - aColor[p] = color[v3]; - aColor[p + 1] = color[v3 + 1]; - aColor[p + 2] = color[v3 + 2]; - } - if (primitiveId) { - aPrimitiveId[l + i] = primitiveId[v]; - } - } - if (size) { - currSize = size[v]; - if (prevSize !== size[v]) { - aSize[l] = prevSize; - aSize[l + 1] = prevSize; - aSize[l + 2] = currSize; - aSize[l + 3] = currSize; - } - else { - aSize[l] = currSize; - aSize[l + 1] = currSize; - aSize[l + 2] = currSize; - aSize[l + 3] = currSize; - } - prevSize = currSize; - } - if (dir) { - aDir[k] = dir[v3]; - aDir[k + 1] = dir[v3 + 1]; - aDir[k + 2] = dir[v3 + 2]; - aDir[k + 3] = -dir[v3]; - aDir[k + 4] = -dir[v3 + 1]; - aDir[k + 5] = -dir[v3 + 2]; - aDir[k + 6] = dir[v3 + 3]; - aDir[k + 7] = dir[v3 + 4]; - aDir[k + 8] = dir[v3 + 5]; - aDir[k + 9] = -dir[v3 + 3]; - aDir[k + 10] = -dir[v3 + 4]; - aDir[k + 11] = -dir[v3 + 5]; - } - } - }; - RibbonBuffer.prototype.makeIndex = function makeIndex () { - var index = this.geometry.getIndex(); - if (!index) { - Log.error('Index is null'); - return; - } - var meshIndex = index.array; - var n = meshIndex.length / 4 / 3; - for (var v = 0; v < n; ++v) { - var ix = v * 6; - var it = v * 4; - meshIndex.set(quadIndices$1, ix); - for (var s = 0; s < 6; ++s) { - meshIndex[ix + s] += it; - } - } - }; - - return RibbonBuffer; -}(MeshBuffer)); - -/** - * @file Ribbon Representation - * @author Alexander Rose - * @private - */ -/** - * Ribbon Representation - */ -var RibbonRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function RibbonRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'ribbon'; - this.parameters = Object.assign({ - subdiv: { - type: 'integer', max: 50, min: 1, rebuild: true - }, - tension: { - type: 'number', precision: 1, max: 1.0, min: 0.1 - }, - smoothSheet: { - type: 'boolean', rebuild: true - } - }, this.parameters, { - side: null, - wireframe: null, - linewidth: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) RibbonRepresentation.__proto__ = StructureRepresentation$$1; - RibbonRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - RibbonRepresentation.prototype.constructor = RibbonRepresentation; - RibbonRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'chainname'); - p.colorScale = defaults(p.colorScale, 'RdYlBu'); - p.radiusType = defaults(p.radiusType, 'sstruc'); - p.radiusScale = defaults(p.radiusScale, 4.0); - if (p.quality === 'low') { - this.subdiv = 3; - } - else if (p.quality === 'medium') { - this.subdiv = 6; - } - else if (p.quality === 'high') { - this.subdiv = 12; - } - else { - this.subdiv = defaults(p.subdiv, 6); - } - this.tension = defaults(p.tension, NaN); - this.smoothSheet = defaults(p.smoothSheet, false); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - RibbonRepresentation.prototype.getSplineParams = function getSplineParams (params) { - return Object.assign({ - subdiv: this.subdiv, - tension: this.tension, - directional: true, - smoothSheet: this.smoothSheet - }, params); - }; - RibbonRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - return atom.isTrace() ? StructureRepresentation$$1.prototype.getAtomRadius.call(this, atom) : 0; - }; - RibbonRepresentation.prototype.createData = function createData (sview) { - var this$1 = this; - - var bufferList = []; - var polymerList = []; - this.structure.eachPolymer(function (polymer) { - if (polymer.residueCount < 4) - { return; } - polymerList.push(polymer); - var spline = new Spline(polymer, this$1.getSplineParams()); - var subPos = spline.getSubdividedPosition(); - var subOri = spline.getSubdividedOrientation(); - var subCol = spline.getSubdividedColor(this$1.getColorParams()); - var subPick = spline.getSubdividedPicking(); - var subSize = spline.getSubdividedSize(this$1.getRadiusParams()); - bufferList.push(new RibbonBuffer(({ - position: subPos.position, - normal: subOri.binormal, - dir: subOri.normal, - color: subCol.color, - size: subSize.size, - picking: subPick.picking - }), this$1.getBufferParams())); - }, sview.getSelection()); - return { - bufferList: bufferList, - polymerList: polymerList - }; - }; - RibbonRepresentation.prototype.updateData = function updateData (what, data) { - what = what || {}; - var i = 0; - var n = data.polymerList.length; - for (i = 0; i < n; ++i) { - var bufferData = {}; - var spline = new Spline(data.polymerList[i], this.getSplineParams()); - if (what.position) { - var subPos = spline.getSubdividedPosition(); - var subOri = spline.getSubdividedOrientation(); - Object.assign(bufferData, { - position: subPos.position, - normal: subOri.binormal, - dir: subOri.normal - }); - } - if (what.radius || what.scale) { - var subSize = spline.getSubdividedSize(this.getRadiusParams()); - Object.assign(bufferData, { size: subSize.size }); - } - if (what.color) { - var subCol = spline.getSubdividedColor(this.getColorParams()); - Object.assign(bufferData, { color: subCol.color }); - } - data.bufferList[i].setAttributes(bufferData); - } - }; - RibbonRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - if (params && params.tension) { - Object.assign(what, { position: true }); - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - - return RibbonRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('ribbon', RibbonRepresentation); - -/** - * @file Rocket Representation - * @author Alexander Rose - * @private - */ -/** - * Rocket Representation - */ -var RocketRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function RocketRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'rocket'; - this.parameters = Object.assign({ - localAngle: { - type: 'integer', max: 180, min: 0, rebuild: true - }, - centerDist: { - type: 'number', precision: 1, max: 10, min: 0, rebuild: true - }, - ssBorder: { - type: 'boolean', rebuild: true - }, - radialSegments: true, - openEnded: true, - disableImpostor: true - }, this.parameters); - // this.helixbundleList = [] - this.init(params); - } - - if ( StructureRepresentation$$1 ) RocketRepresentation.__proto__ = StructureRepresentation$$1; - RocketRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - RocketRepresentation.prototype.constructor = RocketRepresentation; - RocketRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'sstruc'); - p.radiusSize = defaults(p.radiusSize, 1.5); - p.radiusScale = defaults(p.radiusScale, 1.0); - p.openEnded = defaults(p.openEnded, false); - p.useInteriorColor = defaults(p.useInteriorColor, true); - this.localAngle = defaults(p.localAngle, 30); - this.centerDist = defaults(p.centerDist, 2.5); - this.ssBorder = defaults(p.ssBorder, false); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - RocketRepresentation.prototype.createData = function createData (sview) { - var this$1 = this; - - var length = 0; - var axisList = []; - var helixbundleList = []; - this.structure.eachPolymer(function (polymer) { - if (polymer.residueCount < 4 || polymer.isNucleic()) - { return; } - var helixbundle = new Helixbundle(polymer); - var axis = helixbundle.getAxis(this$1.localAngle, this$1.centerDist, this$1.ssBorder, this$1.getColorParams(), this$1.getRadiusParams()); - length += axis.size.length; - axisList.push(axis); - helixbundleList.push(helixbundle); - }, sview.getSelection()); - var axisData = { - begin: new Float32Array(length * 3), - end: new Float32Array(length * 3), - size: new Float32Array(length), - color: new Float32Array(length * 3), - picking: {} - }; - var picking = new Float32Array(length); - var offset = 0; - axisList.forEach(function (axis) { - axisData.begin.set(axis.begin, offset * 3); - axisData.end.set(axis.end, offset * 3); - axisData.size.set(axis.size, offset); - axisData.color.set(axis.color, offset * 3); - picking.set(axis.picking.array, offset); - offset += axis.size.length; - }); - if (length) { - axisData.picking = new AtomPicker(picking, sview.getStructure()); - } - var cylinderBuffer = new CylinderBuffer({ - position1: axisData.begin, - position2: axisData.end, - color: axisData.color, - color2: axisData.color, - radius: axisData.size, - picking: axisData.picking - }, this.getBufferParams({ - openEnded: this.openEnded, - radialSegments: this.radialSegments, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - return { - bufferList: [cylinderBuffer], - axisList: axisList, - helixbundleList: helixbundleList, - axisData: axisData - }; - }; - RocketRepresentation.prototype.updateData = function updateData (what, data) { - var this$1 = this; - - what = what || {}; - if (what.position) { - this.build(); - return; - } - var cylinderData = {}; - if (what.color || what.radius) { - var offset = 0; - data.helixbundleList.forEach(function (helixbundle) { - var axis = helixbundle.getAxis(this$1.localAngle, this$1.centerDist, this$1.ssBorder, this$1.getColorParams(), this$1.getRadiusParams()); - if (what.color) { - data.axisData.color.set(axis.color, offset * 3); - } - if (what.radius || what.scale) { - data.axisData.size.set(axis.size, offset); - } - offset += axis.size.length; - }); - if (what.color) { - Object.assign(cylinderData, { - color: data.axisData.color, - color2: data.axisData.color - }); - } - if (what.radius || what.scale) { - Object.assign(cylinderData, { - radius: data.axisData.size - }); - } - } - data.bufferList[0].setAttributes(cylinderData); - }; - - return RocketRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('rocket', RocketRepresentation); - -/** - * @file Rope Representation - * @author Alexander Rose - * @private - */ -/** - * Rope Representation - */ -var RopeRepresentation = /*@__PURE__*/(function (CartoonRepresentation$$1) { - function RopeRepresentation(structure, viewer, params) { - CartoonRepresentation$$1.call(this, structure, viewer, params); - this.type = 'rope'; - this.parameters = Object.assign({ - smooth: { - type: 'integer', max: 15, min: 0, rebuild: true - } - }, this.parameters, { - aspectRatio: null, - smoothSheet: null - }); - } - - if ( CartoonRepresentation$$1 ) RopeRepresentation.__proto__ = CartoonRepresentation$$1; - RopeRepresentation.prototype = Object.create( CartoonRepresentation$$1 && CartoonRepresentation$$1.prototype ); - RopeRepresentation.prototype.constructor = RopeRepresentation; - RopeRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.aspectRatio = 1.0; - p.tension = defaults(p.tension, 0.5); - p.radiusScale = defaults(p.radiusScale, 5.0); - p.smoothSheet = false; - this.smooth = defaults(p.smooth, 2); - CartoonRepresentation$$1.prototype.init.call(this, p); - }; - RopeRepresentation.prototype.getSpline = function getSpline (polymer) { - var helixorient = new Helixorient(polymer); - return new Spline(polymer, this.getSplineParams({ - directional: false, - positionIterator: helixorient.getCenterIterator(this.smooth) - })); - }; - - return RopeRepresentation; -}(CartoonRepresentation)); -RepresentationRegistry.add('rope', RopeRepresentation); - -/** - * @file Spacefill Representation - * @author Alexander Rose - * @private - */ -/** - * Spacefill Representation - */ -var SpacefillRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function SpacefillRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'spacefill'; - this.parameters = Object.assign({ - sphereDetail: true, - disableImpostor: true - }, this.parameters); - this.init(params); - } - - if ( StructureRepresentation$$1 ) SpacefillRepresentation.__proto__ = StructureRepresentation$$1; - SpacefillRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - SpacefillRepresentation.prototype.constructor = SpacefillRepresentation; - SpacefillRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.useInteriorColor = defaults(p.useInteriorColor, true); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - SpacefillRepresentation.prototype.createData = function createData (sview) { - var sphereBuffer = new SphereBuffer(sview.getAtomData(this.getAtomParams()), this.getBufferParams({ - sphereDetail: this.sphereDetail, - dullInterior: true, - disableImpostor: this.disableImpostor - })); - return { - bufferList: [sphereBuffer] - }; - }; - SpacefillRepresentation.prototype.updateData = function updateData (what, data) { - var atomData = data.sview.getAtomData(this.getAtomParams(what)); - var sphereData = {}; - if (!what || what.position) { - Object.assign(sphereData, { position: atomData.position }); - } - if (!what || what.color) { - Object.assign(sphereData, { color: atomData.color }); - } - if (!what || what.radius) { - Object.assign(sphereData, { radius: atomData.radius }); - } - data.bufferList[0].setAttributes(sphereData); - }; - - return SpacefillRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('spacefill', SpacefillRepresentation); - -/** - * @file Trace Buffer - * @author Alexander Rose - * @private - */ -function getSize$2(data) { - var n = data.position.length / 3; - var n1 = n - 1; - return n1 * 3 * 2; -} -/** - * Trace buffer. Draws a series of lines. - */ -var TraceBuffer = /*@__PURE__*/(function (Buffer$$1) { - function TraceBuffer(data, params) { - if ( params === void 0 ) params = {}; - - Buffer$$1.call(this, { - position: new Float32Array(getSize$2(data)), - color: new Float32Array(getSize$2(data)) - }, params); - this.isLine = true; - this.vertexShader = 'Line.vert'; - this.fragmentShader = 'Line.frag'; - this.setAttributes(data); - } - - if ( Buffer$$1 ) TraceBuffer.__proto__ = Buffer$$1; - TraceBuffer.prototype = Object.create( Buffer$$1 && Buffer$$1.prototype ); - TraceBuffer.prototype.constructor = TraceBuffer; - TraceBuffer.prototype.setAttributes = function setAttributes (data) { - var position, color; - var linePosition, lineColor; - var attributes = this.geometry.attributes; // TODO - if (data.position) { - position = data.position; - linePosition = attributes.position.array; - attributes.position.needsUpdate = true; - } - if (data.color) { - color = data.color; - lineColor = attributes.color.array; - attributes.color.needsUpdate = true; - } - if (!position && !color) { - Log.warn('TraceBuffer.prototype.setAttributes no data'); - return; - } - var v, v2; - var n = this.size; - var n1 = n - 1; - for (var i = 0; i < n1; ++i) { - v = 3 * i; - v2 = 3 * i * 2; - if (position) { - linePosition[v2] = position[v]; - linePosition[v2 + 1] = position[v + 1]; - linePosition[v2 + 2] = position[v + 2]; - linePosition[v2 + 3] = position[v + 3]; - linePosition[v2 + 4] = position[v + 4]; - linePosition[v2 + 5] = position[v + 5]; - } - if (color) { - lineColor[v2] = color[v]; - lineColor[v2 + 1] = color[v + 1]; - lineColor[v2 + 2] = color[v + 2]; - lineColor[v2 + 3] = color[v + 3]; - lineColor[v2 + 4] = color[v + 4]; - lineColor[v2 + 5] = color[v + 5]; - } - } - }; - - return TraceBuffer; -}(Buffer)); - -/** - * @file Trace Representation - * @author Alexander Rose - * @private - */ -/** - * Trace Representation - */ -var TraceRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function TraceRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'trace'; - this.parameters = Object.assign({ - subdiv: { - type: 'integer', max: 50, min: 1, rebuild: true - }, - tension: { - type: 'number', precision: 1, max: 1.0, min: 0.1 - }, - smoothSheet: { - type: 'boolean', rebuild: true - } - }, this.parameters, { - flatShaded: null, - side: null, - wireframe: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) TraceRepresentation.__proto__ = StructureRepresentation$$1; - TraceRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - TraceRepresentation.prototype.constructor = TraceRepresentation; - TraceRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorScheme = defaults(p.colorScheme, 'chainname'); - p.colorScale = defaults(p.colorScale, 'RdYlBu'); - if (p.quality === 'low') { - this.subdiv = 3; - } - else if (p.quality === 'medium') { - this.subdiv = 6; - } - else if (p.quality === 'high') { - this.subdiv = 12; - } - else { - this.subdiv = defaults(p.subdiv, 6); - } - this.tension = defaults(p.tension, NaN); - this.smoothSheet = defaults(p.smoothSheet, false); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - TraceRepresentation.prototype.getSplineParams = function getSplineParams (params) { - return Object.assign({ - subdiv: this.subdiv, - tension: this.tension, - directional: false, - smoothSheet: this.smoothSheet - }, params); - }; - TraceRepresentation.prototype.getAtomRadius = function getAtomRadius (atom) { - return atom.isTrace() ? 0.1 : 0; - }; - TraceRepresentation.prototype.createData = function createData (sview) { - var this$1 = this; - - var bufferList = []; - var polymerList = []; - this.structure.eachPolymer(function (polymer) { - if (polymer.residueCount < 4) - { return; } - polymerList.push(polymer); - var spline = new Spline(polymer, this$1.getSplineParams()); - var subPos = spline.getSubdividedPosition(); - var subCol = spline.getSubdividedColor(this$1.getColorParams()); - bufferList.push(new TraceBuffer(Object.assign({}, subPos, subCol), this$1.getBufferParams())); - }, sview.getSelection()); - return { - bufferList: bufferList, - polymerList: polymerList - }; - }; - TraceRepresentation.prototype.updateData = function updateData (what, data) { - what = what || {}; - var i = 0; - var n = data.polymerList.length; - for (i = 0; i < n; ++i) { - var bufferData = {}; - var spline = new Spline(data.polymerList[i], this.getSplineParams()); - if (what.position) { - var subPos = spline.getSubdividedPosition(); - Object.assign(bufferData, { position: subPos.position }); - } - if (what.color) { - var subCol = spline.getSubdividedColor(this.getColorParams()); - Object.assign(bufferData, { color: subCol.color }); - } - data.bufferList[i].setAttributes(bufferData); - } - }; - TraceRepresentation.prototype.setParameters = function setParameters (params) { - var rebuild = false; - var what = {}; - if (params && params.tension) { - Object.assign(what, { position: true }); - } - StructureRepresentation$$1.prototype.setParameters.call(this, params, what, rebuild); - return this; - }; - - return TraceRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('trace', TraceRepresentation); - -/** - * @file Tube Representation - * @author Alexander Rose - * @private - */ -/** - * Tube Representation - */ -var TubeRepresentation = /*@__PURE__*/(function (CartoonRepresentation$$1) { - function TubeRepresentation(structure, viewer, params) { - CartoonRepresentation$$1.call(this, structure, viewer, params); - this.type = 'tube'; - this.parameters = Object.assign({}, this.parameters, { aspectRatio: null }); - } - - if ( CartoonRepresentation$$1 ) TubeRepresentation.__proto__ = CartoonRepresentation$$1; - TubeRepresentation.prototype = Object.create( CartoonRepresentation$$1 && CartoonRepresentation$$1.prototype ); - TubeRepresentation.prototype.constructor = TubeRepresentation; - TubeRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.aspectRatio = 1.0; - p.radiusScale = defaults(p.radiusScale, 2.0); - if (p.quality === 'low') { - this.radialSegments = 5; - } - CartoonRepresentation$$1.prototype.init.call(this, p); - }; - TubeRepresentation.prototype.getSplineParams = function getSplineParams ( /* params */) { - return CartoonRepresentation$$1.prototype.getSplineParams.call(this, { - directional: false - }); - }; - - return TubeRepresentation; -}(CartoonRepresentation)); -RepresentationRegistry.add('tube', TubeRepresentation); - -/** - * @file Unitcell Representation - * @author Alexander Rose - * @private - */ -/** - * Unitcell Representation - */ -var UnitcellRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function UnitcellRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'unitcell'; - this.parameters = Object.assign({ - radiusSize: { - type: 'number', precision: 3, max: 10.0, min: 0.001 - }, - sphereDetail: true, - radialSegments: true, - disableImpostor: true - }, this.parameters, { - assembly: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) UnitcellRepresentation.__proto__ = StructureRepresentation$$1; - UnitcellRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - UnitcellRepresentation.prototype.constructor = UnitcellRepresentation; - UnitcellRepresentation.prototype.init = function init (params) { - var p = params || {}; - var defaultRadius = 0.5; - if (this.structure.unitcell) { - defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200; - } - p.radiusSize = defaults(p.radiusSize, defaultRadius); - p.colorValue = defaults(p.colorValue, 'orange'); - p.useInteriorColor = defaults(p.useInteriorColor, true); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - UnitcellRepresentation.prototype.getUnitcellData = function getUnitcellData (structure) { - return structure.unitcell.getData(structure); - }; - UnitcellRepresentation.prototype.create = function create () { - var structure = this.structureView.getStructure(); - if (!structure.unitcell) - { return; } - var unitcellData = this.getUnitcellData(structure); - this.sphereBuffer = new SphereBuffer(unitcellData.vertex, this.getBufferParams({ - sphereDetail: this.sphereDetail, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - this.cylinderBuffer = new CylinderBuffer(unitcellData.edge, this.getBufferParams({ - openEnded: true, - radialSegments: this.radialSegments, - disableImpostor: this.disableImpostor, - dullInterior: true - })); - this.dataList.push({ - sview: this.structureView, - bufferList: [this.sphereBuffer, this.cylinderBuffer] - }); - }; - UnitcellRepresentation.prototype.createData = function createData (sview) { - return; - }; - UnitcellRepresentation.prototype.updateData = function updateData (what, data) { - var structure = data.sview.getStructure(); - if (!structure.unitcell) - { return; } - var unitcellData = this.getUnitcellData(structure); - var sphereData = {}; - var cylinderData = {}; - if (!what || what.position) { - Object.assign(sphereData, { position: unitcellData.vertex.position }); - Object.assign(cylinderData, { - position1: unitcellData.edge.position1, - position2: unitcellData.edge.position2 - }); - } - if (!what || what.color) { - Object.assign(sphereData, { color: unitcellData.vertex.color }); - Object.assign(cylinderData, { - color: unitcellData.edge.color, - color2: unitcellData.edge.color2 - }); - } - if (!what || what.radius) { - Object.assign(sphereData, { radius: unitcellData.vertex.radius }); - Object.assign(cylinderData, { radius: unitcellData.edge.radius }); - } - this.sphereBuffer.setAttributes(sphereData); - this.cylinderBuffer.setAttributes(cylinderData); - }; - - return UnitcellRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('unitcell', UnitcellRepresentation); - -/** - * @file Validation Representation - * @author Alexander Rose - * @private - */ -/** - * Validation representation - */ -var ValidationRepresentation = /*@__PURE__*/(function (StructureRepresentation$$1) { - function ValidationRepresentation(structure, viewer, params) { - StructureRepresentation$$1.call(this, structure, viewer, params); - this.type = 'validation'; - this.parameters = Object.assign({}, this.parameters, { - radiusType: null, - radiusSize: null, - radiusScale: null - }); - this.init(params); - } - - if ( StructureRepresentation$$1 ) ValidationRepresentation.__proto__ = StructureRepresentation$$1; - ValidationRepresentation.prototype = Object.create( StructureRepresentation$$1 && StructureRepresentation$$1.prototype ); - ValidationRepresentation.prototype.constructor = ValidationRepresentation; - ValidationRepresentation.prototype.init = function init (params) { - var p = params || {}; - p.colorValue = defaults(p.colorValue, '#f0027f'); - p.useInteriorColor = defaults(p.useInteriorColor, true); - StructureRepresentation$$1.prototype.init.call(this, p); - }; - ValidationRepresentation.prototype.createData = function createData (sview) { - if (!sview.validation) - { return; } - var clashData = sview.validation.getClashData({ - structure: sview, - color: this.colorValue - }); - var cylinderBuffer = new CylinderBuffer(clashData, this.getBufferParams({ openEnded: false })); - return { - bufferList: [cylinderBuffer] - }; - }; - - return ValidationRepresentation; -}(StructureRepresentation)); -RepresentationRegistry.add('validation', ValidationRepresentation); - -/** - * @file Cone Buffer - * @author Alexander Rose - * @private - */ -var scale$3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 1, 0); -function getGeo$1(params) { - if ( params === void 0 ) params = {}; - - var geo = new __WEBPACK_IMPORTED_MODULE_0_three__["j" /* ConeBufferGeometry */](1, // radius - 1, // height - defaults(params.radialSegments, 60), // radialSegments - 1, // heightSegments - defaults(params.openEnded, false) // openEnded - ); - geo.applyMatrix4(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeRotationX(-Math.PI / 2)); - return geo; -} -var ConeBufferDefaultParameters = Object.assign({ - radialSegments: 60, - openEnded: false -}, BufferDefaultParameters); -/** - * Cone geometry buffer. - * - * @example - * var coneBuffer = new ConeBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 1, 1, 1 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * color2: new Float32Array([ 0, 1, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var ConeBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function ConeBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, { - position: new Float32Array(data.position1.length), - color: data.color, - picking: data.picking - }, params, getGeo$1(params)); - this.updateNormals = true; - this._position = new Float32Array(data.position1.length); - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) ConeBuffer.__proto__ = GeometryBuffer$$1; - ConeBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - ConeBuffer.prototype.constructor = ConeBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return ConeBufferDefaultParameters; }; - ConeBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - eye$1.fromArray(this._position1, i3); - target$1.fromArray(this._position2, i3); - matrix.lookAt(eye$1, target$1, up$1); - var r = this._radius[i]; - scale$3.set(r, r, eye$1.distanceTo(target$1)); - matrix.scale(scale$3); - }; - ConeBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.position1 && data.position2) { - calculateCenterArray(data.position1, data.position2, this._position); - this._position1 = data.position1; - this._position2 = data.position2; - data.position = this._position; - } - if (data.radius) - { this._radius = data.radius; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - Object.defineProperties( ConeBuffer.prototype, prototypeAccessors ); - - return ConeBuffer; -}(GeometryBuffer)); -BufferRegistry.add('cone', ConeBuffer); - -/** - * @file Geometry Group - * @author Alexander Rose - * @private - */ -var GeometryGroup = function GeometryGroup(geometryList) { - if ( geometryList === void 0 ) geometryList = []; - - this.geometryList = geometryList; -}; -GeometryGroup.prototype.computeBoundingBox = function computeBoundingBox () { - var this$1 = this; - - if (!this.boundingBox) { - this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0_three__["d" /* Box3 */](); - } - else { - this.boundingBox.empty(); - } - this.geometryList.forEach(function (geo) { - if (!geo.boundingBox) - { geo.computeBoundingBox(); } - this$1.boundingBox.union(geo.boundingBox); - }); -}; - -/** - * @file Arrow Buffer - * @author Alexander Rose - * @private - */ -var ArrowBufferDefaultParameters = Object.assign({ - aspectRatio: 1.5, - radialSegments: 50, - openEnded: false, - disableImpostor: false -}, BufferDefaultParameters); -/** - * Arrow buffer. Draws arrows made from a cylinder and a cone. - * @implements {Buffer} - * - * @example - * var arrowBuffer = new ArrowBuffer({ - * position1: new Float32Array([ 0, 0, 0 ]), - * position2: new Float32Array([ 10, 1, 1 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * radius: new Float32Array([ 1 ]) - * }); - */ -var ArrowBuffer = function ArrowBuffer(data, params) { - if ( params === void 0 ) params = {}; - - this.group = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.wireframeGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.pickingGroup = new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */](); - this.visible = true; - this.parameters = createParams(params, this.defaultParameters); - this.splitPosition = new Float32Array(data.position1.length); - this.cylinderRadius = new Float32Array(data.radius.length); - var attr = this.makeAttributes(data); - var bufferParams = { - radialSegments: this.parameters.radialSegments, - openEnded: this.parameters.openEnded, - disableImpostor: this.parameters.disableImpostor - }; - this.cylinderBuffer = new CylinderBuffer(attr.cylinder, bufferParams); - this.coneBuffer = new ConeBuffer(attr.cone, bufferParams); - this.geometry = new GeometryGroup([ - this.cylinderBuffer.geometry, - this.coneBuffer.geometry - ]); - // requires Group objects to be present - this.matrix = defaults(params.matrix, new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]()); - this.picking = data.picking; -}; - -var prototypeAccessors$v = { defaultParameters: { configurable: true },matrix: { configurable: true },pickable: { configurable: true } }; -prototypeAccessors$v.defaultParameters.get = function () { return ArrowBufferDefaultParameters; }; -prototypeAccessors$v.matrix.set = function (m) { - Buffer.prototype.setMatrix.call(this, m); -}; -prototypeAccessors$v.matrix.get = function () { - return this.group.matrix.clone(); -}; -prototypeAccessors$v.pickable.get = function () { - return !!this.picking; -}; -ArrowBuffer.prototype.makeAttributes = function makeAttributes (data) { - if ( data === void 0 ) data = {}; - - var splitPosition = this.splitPosition; - var cylinderRadius = this.cylinderRadius; - var aspectRatio = this.parameters.aspectRatio; - var i, il; - var cylinder = {}; - var cone = {}; - if (data.radius) { - for (i = 0, il = cylinderRadius.length; i < il; ++i) { - cylinderRadius[i] = data.radius[i] / aspectRatio; - } - cylinder.radius = cylinderRadius; - cone.radius = data.radius; - } - if (data.position1 && data.position2) { - var vFrom = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vTo = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vDir = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vSplit = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - for (i = 0, il = splitPosition.length; i < il; i += 3) { - vFrom.fromArray(data.position1, i); - vTo.fromArray(data.position2, i); - vDir.subVectors(vFrom, vTo); - var fullLength = vDir.length(); - var coneLength = cylinderRadius[i / 3] * aspectRatio * 2; - var length = Math.min(fullLength, coneLength); - vDir.setLength(length); - vSplit.copy(vTo).add(vDir); - vSplit.toArray(splitPosition, i); - } - cylinder.position1 = data.position1; - cylinder.position2 = splitPosition; - cone.position1 = splitPosition; - cone.position2 = data.position2; - } - if (data.color) { - cylinder.color = data.color; - cylinder.color2 = data.color; - cone.color = data.color; - } - return { - cylinder: cylinder, - cone: cone - }; -}; -ArrowBuffer.prototype.getMesh = function getMesh () { - return new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]().add(this.cylinderBuffer.getMesh(), this.coneBuffer.getMesh()); -}; -ArrowBuffer.prototype.getWireframeMesh = function getWireframeMesh () { - return new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]().add(this.cylinderBuffer.getWireframeMesh(), this.coneBuffer.getWireframeMesh()); -}; -ArrowBuffer.prototype.getPickingMesh = function getPickingMesh () { - return new __WEBPACK_IMPORTED_MODULE_0_three__["t" /* Group */]().add(this.cylinderBuffer.getPickingMesh(), this.coneBuffer.getPickingMesh()); -}; -ArrowBuffer.prototype.setAttributes = function setAttributes (data) { - if ( data === void 0 ) data = {}; - - var attr = this.makeAttributes(data); - this.cylinderBuffer.setAttributes(attr.cylinder); - this.coneBuffer.setAttributes(attr.cone); -}; -/** - * Set buffer parameters - * @param {BufferParameters} params - buffer parameters object - * @return {undefined} - */ -ArrowBuffer.prototype.setParameters = function setParameters (params) { - if ( params === void 0 ) params = {}; - - params = Object.assign({}, params); - if (params && params.matrix !== undefined) { - this.matrix = params.matrix; - } - delete params.matrix; - if (params && params.wireframe !== undefined) { - this.parameters.wireframe = params.wireframe; - this.setVisibility(this.visible); - } - this.cylinderBuffer.setParameters(params); - this.coneBuffer.setParameters(params); -}; -ArrowBuffer.prototype.setVisibility = function setVisibility (value) { - Buffer.prototype.setVisibility.call(this, value); -}; -ArrowBuffer.prototype.dispose = function dispose () { - this.cylinderBuffer.dispose(); - this.coneBuffer.dispose(); -}; - -Object.defineProperties( ArrowBuffer.prototype, prototypeAccessors$v ); -BufferRegistry.add('arrow', ArrowBuffer); - -/** - * @file Box Buffer - * @author Alexander Rose - * @private - */ -var scale$4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target$2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up$2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye$2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); -/** - * Box buffer. Draws boxes. - * - * @example - * var boxBuffer = new BoxBuffer({ - * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]), - * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]), - * size: new Float32Array([ 2, 1.5 ]), - * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]), - * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ]) - * }) - */ -var BoxBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function BoxBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, data, params, new __WEBPACK_IMPORTED_MODULE_0_three__["e" /* BoxBufferGeometry */](1, 1, 1)); - this.updateNormals = true; - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) BoxBuffer.__proto__ = GeometryBuffer$$1; - BoxBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - BoxBuffer.prototype.constructor = BoxBuffer; - BoxBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - target$2.fromArray(this._heightAxis, i3); - up$2.fromArray(this._depthAxis, i3); - matrix.lookAt(eye$2, target$2, up$2); - scale$4.set(this._size[i], up$2.length(), target$2.length()); - matrix.scale(scale$4); - }; - BoxBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.size) - { this._size = data.size; } - if (data.heightAxis) - { this._heightAxis = data.heightAxis; } - if (data.depthAxis) - { this._depthAxis = data.depthAxis; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - return BoxBuffer; -}(GeometryBuffer)); -BufferRegistry.add('box', BoxBuffer); - -/** - * @file Ellipsoid Geometry Buffer - * @author Alexander Rose - * @private - */ -var scale$5 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target$3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up$3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye$3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); -var EllipsoidBufferDefaultParameters = Object.assign({ - sphereDetail: 2, -}, BufferDefaultParameters); -/** - * Ellipsoid buffer. Draws ellipsoids. - * - * @example - * var ellipsoidBuffer = new EllipsoidBuffer({ - * position: new Float32Array([ 0, 0, 0 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * radius: new Float32Array([ 1 ]), - * majorAxis: new Float32Array([ 1, 1, 0 ]), - * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]), - * }); - */ -var EllipsoidBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function EllipsoidBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, data, params, new __WEBPACK_IMPORTED_MODULE_0_three__["u" /* IcosahedronBufferGeometry */](1, defaults(params.sphereDetail, 2))); - this.updateNormals = true; - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) EllipsoidBuffer.__proto__ = GeometryBuffer$$1; - EllipsoidBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - EllipsoidBuffer.prototype.constructor = EllipsoidBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return EllipsoidBufferDefaultParameters; }; - EllipsoidBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - target$3.fromArray(this._majorAxis, i3); - up$3.fromArray(this._minorAxis, i3); - matrix.lookAt(eye$3, target$3, up$3); - scale$5.set(this._radius[i], up$3.length(), target$3.length()); - matrix.scale(scale$5); - }; - EllipsoidBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.radius) - { this._radius = data.radius; } - if (data.majorAxis) - { this._majorAxis = data.majorAxis; } - if (data.minorAxis) - { this._minorAxis = data.minorAxis; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - Object.defineProperties( EllipsoidBuffer.prototype, prototypeAccessors ); - - return EllipsoidBuffer; -}(GeometryBuffer)); -BufferRegistry.add('ellipsoid', EllipsoidBuffer); - -/** - * @file Octahedron Buffer - * @author Alexander Rose - * @private - */ -var scale$6 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target$4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up$4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye$4 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); -/** - * Octahedron buffer. Draws octahedrons. - * - * @example - * var octahedronBuffer = new OctahedronBuffer({ - * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]), - * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]), - * size: new Float32Array([ 2, 1.5 ]), - * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]), - * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ]) - * }) - */ -var OctahedronBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function OctahedronBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, data, params, new __WEBPACK_IMPORTED_MODULE_0_three__["D" /* OctahedronBufferGeometry */](1, 0)); - this.updateNormals = true; - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) OctahedronBuffer.__proto__ = GeometryBuffer$$1; - OctahedronBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - OctahedronBuffer.prototype.constructor = OctahedronBuffer; - OctahedronBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - target$4.fromArray(this._heightAxis, i3); - up$4.fromArray(this._depthAxis, i3); - matrix.lookAt(eye$4, target$4, up$4); - scale$6.set(this._size[i], up$4.length(), target$4.length()); - matrix.scale(scale$6); - }; - OctahedronBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.size) - { this._size = data.size; } - if (data.heightAxis) - { this._heightAxis = data.heightAxis; } - if (data.depthAxis) - { this._depthAxis = data.depthAxis; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - return OctahedronBuffer; -}(GeometryBuffer)); -BufferRegistry.add('octahedron', OctahedronBuffer); - -/** - * @file Tetrahedron Buffer - * @author Alexander Rose - * @private - */ -var scale$7 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target$5 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up$5 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye$5 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); -/** - * Tetrahedron buffer. Draws tetrahedrons. - * - * @example - * var tetrahedronBuffer = new TetrahedronBuffer({ - * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]), - * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]), - * size: new Float32Array([ 2, 1.5 ]), - * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]), - * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ]) - * }) - */ -var TetrahedronBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function TetrahedronBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, data, params, new __WEBPACK_IMPORTED_MODULE_0_three__["Q" /* TetrahedronBufferGeometry */](1, 0)); - this.updateNormals = true; - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) TetrahedronBuffer.__proto__ = GeometryBuffer$$1; - TetrahedronBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - TetrahedronBuffer.prototype.constructor = TetrahedronBuffer; - TetrahedronBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - target$5.fromArray(this._heightAxis, i3); - up$5.fromArray(this._depthAxis, i3); - matrix.lookAt(eye$5, target$5, up$5); - scale$7.set(this._size[i], up$5.length(), target$5.length()); - matrix.scale(scale$7); - }; - TetrahedronBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.size) - { this._size = data.size; } - if (data.heightAxis) - { this._heightAxis = data.heightAxis; } - if (data.depthAxis) - { this._depthAxis = data.depthAxis; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - return TetrahedronBuffer; -}(GeometryBuffer)); -BufferRegistry.add('tetrahedron', TetrahedronBuffer); - -/** - * @file Tetrahedron Geometry Buffer - * @author Alexander Rose - * @private - */ -var scale$8 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var target$6 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var up$6 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); -var eye$6 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](0, 0, 0); -var TorusBufferDefaultParameters = Object.assign({ - radiusRatio: 0.2, - radialSegments: 16, - tubularSegments: 32 -}, BufferDefaultParameters); -/** - * Torus geometry buffer. Draws torii. - * - * @example - * var torusBuffer = new TorusBuffer({ - * position: new Float32Array([ 0, 0, 0 ]), - * color: new Float32Array([ 1, 0, 0 ]), - * radius: new Float32Array([ 1 ]), - * majorAxis: new Float32Array([ 1, 1, 0 ]), - * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]), - * }); - */ -var TorusBuffer = /*@__PURE__*/(function (GeometryBuffer$$1) { - function TorusBuffer(data, params) { - if ( params === void 0 ) params = {}; - - GeometryBuffer$$1.call(this, data, params, new __WEBPACK_IMPORTED_MODULE_0_three__["R" /* TorusBufferGeometry */](1, defaults(params.radiusRatio, 0.2), defaults(params.radialSegments, 16), defaults(params.tubularSegments, 32))); - this.updateNormals = true; - this.setAttributes(data, true); - } - - if ( GeometryBuffer$$1 ) TorusBuffer.__proto__ = GeometryBuffer$$1; - TorusBuffer.prototype = Object.create( GeometryBuffer$$1 && GeometryBuffer$$1.prototype ); - TorusBuffer.prototype.constructor = TorusBuffer; - - var prototypeAccessors = { defaultParameters: { configurable: true } }; - prototypeAccessors.defaultParameters.get = function () { return TorusBufferDefaultParameters; }; - TorusBuffer.prototype.applyPositionTransform = function applyPositionTransform (matrix, i, i3) { - target$6.fromArray(this._majorAxis, i3); - up$6.fromArray(this._minorAxis, i3); - matrix.lookAt(eye$6, target$6, up$6); - var r = this._radius[i]; - scale$8.set(r, r, r); - matrix.scale(scale$8); - }; - TorusBuffer.prototype.setAttributes = function setAttributes (data, initNormals) { - if ( data === void 0 ) data = {}; - - if (data.radius) - { this._radius = data.radius; } - if (data.majorAxis) - { this._majorAxis = data.majorAxis; } - if (data.minorAxis) - { this._minorAxis = data.minorAxis; } - GeometryBuffer$$1.prototype.setAttributes.call(this, data, initNormals); - }; - - Object.defineProperties( TorusBuffer.prototype, prototypeAccessors ); - - return TorusBuffer; -}(GeometryBuffer)); -BufferRegistry.add('torus', TorusBuffer); - -/** - * @file Parser - * @author Alexander Rose - * @private - */ -var Parser = function Parser(streamer, params) { - var p = params || {}; - this.streamer = streamer; - this.name = defaults(p.name, ''); - this.path = defaults(p.path, ''); -}; - -var prototypeAccessors$w = { type: { configurable: true },__objName: { configurable: true },isBinary: { configurable: true },isJson: { configurable: true },isXml: { configurable: true } }; -prototypeAccessors$w.type.get = function () { return ''; }; -prototypeAccessors$w.__objName.get = function () { return ''; }; -prototypeAccessors$w.isBinary.get = function () { return false; }; -prototypeAccessors$w.isJson.get = function () { return false; }; -prototypeAccessors$w.isXml.get = function () { return false; }; -Parser.prototype.parse = function parse () { - var this$1 = this; - - return this.streamer.read().then(function () { - this$1._beforeParse(); - this$1._parse(); - this$1._afterParse(); - return this$1[this$1.__objName]; - }); -}; -Parser.prototype._parse = function _parse () { }; -Parser.prototype._beforeParse = function _beforeParse () { }; -Parser.prototype._afterParse = function _afterParse () { - if (Debug) - { Log.log(this[this.__objName]); } -}; - -Object.defineProperties( Parser.prototype, prototypeAccessors$w ); - -/** - * @file Structure Parser - * @author Alexander Rose - * @private - */ -var StructureParser = /*@__PURE__*/(function (Parser$$1) { - function StructureParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.firstModelOnly = defaults(p.firstModelOnly, false); - this.asTrajectory = defaults(p.asTrajectory, false); - this.cAlphaOnly = defaults(p.cAlphaOnly, false); - this.structure = new Structure(this.name, this.path); - this.structureBuilder = new StructureBuilder(this.structure); - } - - if ( Parser$$1 ) StructureParser.__proto__ = Parser$$1; - StructureParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - StructureParser.prototype.constructor = StructureParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'structure'; }; - prototypeAccessors.__objName.get = function () { return 'structure'; }; - - Object.defineProperties( StructureParser.prototype, prototypeAccessors ); - - return StructureParser; -}(Parser)); - -/** - * @file Entity - * @author Alexander Rose - * @private - */ -function entityTypeFromString(string) { - string = string.toLowerCase(); - switch (string) { - case 'polymer': - return PolymerEntity; - case 'non-polymer': - return NonPolymerEntity; - case 'macrolide': - return MacrolideEntity; - case 'water': - return WaterEntity; - default: - return UnknownEntity; - } -} -function entityFromType(type) { - switch (type) { - case PolymerEntity: - return 'polymer'; - case NonPolymerEntity: - return 'non-polymer'; - case MacrolideEntity: - return 'macrolide'; - case WaterEntity: - return 'water'; - default: - return undefined; - } -} -/** - * Entity of a {@link Structure} - */ -var Entity = function Entity(structure, index, description, type, chainIndexList) { - if ( description === void 0 ) description = ''; - if ( chainIndexList === void 0 ) chainIndexList = []; - - this.structure = structure; - this.index = index; - this.description = description; - this.entityType = entityTypeFromString(type || ''); - this.chainIndexList = chainIndexList; - chainIndexList.forEach(function (ci) { - structure.chainStore.entityIndex[ci] = index; - }); -}; - -var prototypeAccessors$x = { type: { configurable: true } }; -prototypeAccessors$x.type.get = function () { return entityFromType(this.entityType); }; -Entity.prototype.getEntityType = function getEntityType () { - return this.entityType; -}; -Entity.prototype.isPolymer = function isPolymer () { - return this.entityType === PolymerEntity; -}; -Entity.prototype.isNonPolymer = function isNonPolymer () { - return this.entityType === NonPolymerEntity; -}; -Entity.prototype.isMacrolide = function isMacrolide () { - return this.entityType === MacrolideEntity; -}; -Entity.prototype.isWater = function isWater () { - return this.entityType === WaterEntity; -}; -Entity.prototype.eachChain = function eachChain (callback) { - var cp = this.structure.getChainProxy(); - this.chainIndexList.forEach(function (index) { - cp.index = index; - callback(cp); - }); -}; - -Object.defineProperties( Entity.prototype, prototypeAccessors$x ); - -/** - * @file Unitcell - * @author Alexander Rose - * @private - */ -var DefaultBoxParams = { - a: 1, - b: 1, - c: 1, - alpha: 90, - beta: 90, - gamma: 90, - spacegroup: 'P 1' -}; -/** - * Unitcell class - */ -var Unitcell = function Unitcell(params) { - if ( params === void 0 ) params = DefaultBoxParams; - - this.cartToFrac = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.fracToCart = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - this.a = params.a; - this.b = params.b; - this.c = params.c; - this.alpha = params.alpha; - this.beta = params.beta; - this.gamma = params.gamma; - this.spacegroup = params.spacegroup; - var alphaRad = degToRad(this.alpha); - var betaRad = degToRad(this.beta); - var gammaRad = degToRad(this.gamma); - var cosAlpha = Math.cos(alphaRad); - var cosBeta = Math.cos(betaRad); - var cosGamma = Math.cos(gammaRad); - var sinBeta = Math.sin(betaRad); - var sinGamma = Math.sin(gammaRad); - this.volume = (this.a * this.b * this.c * - Math.sqrt(1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma + - 2.0 * cosAlpha * cosBeta * cosGamma)); - if (params.cartToFrac === undefined) { - // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java - var cStar = (this.a * this.b * sinGamma) / this.volume; - var cosAlphaStar = ((cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)); - this.fracToCart.set(this.a, 0, 0, 0, this.b * cosGamma, this.b * sinGamma, 0, 0, this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0, 0, 0, 0, 1).transpose(); - this.cartToFrac.getInverse(this.fracToCart); - } - else { - this.cartToFrac.copy(params.cartToFrac); - this.fracToCart.getInverse(this.cartToFrac); - } -}; -Unitcell.prototype.getPosition = function getPosition (structure) { - var vertexPosition = new Float32Array(3 * 8); - if (structure.unitcell) { - var uc = structure.unitcell; - var centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor(); - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var cornerOffset = 0; - var addCorner = function (x, y, z) { - v.set(x, y, z) - .add(centerFrac) - .applyMatrix4(uc.fracToCart) - .toArray(vertexPosition, cornerOffset); - cornerOffset += 3; - }; - addCorner(0, 0, 0); - addCorner(1, 0, 0); - addCorner(0, 1, 0); - addCorner(0, 0, 1); - addCorner(1, 1, 0); - addCorner(1, 0, 1); - addCorner(0, 1, 1); - addCorner(1, 1, 1); - } - return vertexPosition; -}; -Unitcell.prototype.getCenter = function getCenter (structure) { - return centerArray3(this.getPosition(structure)); -}; -Unitcell.prototype.getData = function getData (structure, params) { - if ( params === void 0 ) params = {}; - - var colorValue = defaults(params.colorValue, 'orange'); - var radius = defaults(params.radius, Math.cbrt(this.volume) / 200); - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](colorValue); - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vertexPosition = this.getPosition(structure); - var vertexColor = uniformArray3(8, c.r, c.g, c.b); - var vertexRadius = uniformArray(8, radius); - var edgePosition1 = new Float32Array(3 * 12); - var edgePosition2 = new Float32Array(3 * 12); - var edgeColor = uniformArray3(12, c.r, c.g, c.b); - var edgeRadius = uniformArray(12, radius); - var edgeOffset = 0; - function addEdge(a, b) { - v.fromArray(vertexPosition, a * 3) - .toArray(edgePosition1, edgeOffset); - v.fromArray(vertexPosition, b * 3) - .toArray(edgePosition2, edgeOffset); - edgeOffset += 3; - } - addEdge(0, 1); - addEdge(0, 2); - addEdge(0, 3); - addEdge(1, 4); - addEdge(1, 5); - addEdge(2, 6); - addEdge(3, 5); - addEdge(4, 7); - addEdge(5, 7); - addEdge(2, 4); - addEdge(7, 6); - addEdge(3, 6); - var picker = new UnitcellPicker(this, structure); - return { - vertex: { - position: vertexPosition, - color: vertexColor, - radius: vertexRadius, - picking: picker - }, - edge: { - position1: edgePosition1, - position2: edgePosition2, - color: edgeColor, - color2: edgeColor, - radius: edgeRadius, - picking: picker - } - }; -}; - -/** - * @file Pdb Parser - * @author Alexander Rose - * @private - */ -// PDB helix record encoding -var HelixTypes = { - 1: 'h', - 2: 'h', - 3: 'i', - 4: 'h', - 5: 'g', - 6: 'h', - 7: 'h', - 8: 'h', - 9: 'h', - 10: 'h', - 0: 'h' //Used to be '' -}; -var dAminoAcids = [ - 'DAL', - 'DAR', - 'DSG', - 'DAS', - 'DCY', - 'DGL', - 'DGN', - 'DHI', - 'DIL', - 'DLE', - 'DLY', - 'MED', - 'DPN', - 'DPR', - 'DSN', - 'DTH', - 'DTR', - 'DTY', - 'DVA', - 'DNE' // D-NORLEUCINE - // ??? // D-SELENOCYSTEINE -]; -var entityKeyList = [ - 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM', - 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS' -]; -var reWhitespace = /\s+/; -function getModresId(resno, chainname, inscode) { - var id = "" + resno; - if (chainname) - { id += ":" + chainname; } - if (inscode) - { id += "^" + inscode; } - return id; -} -var PdbParser = /*@__PURE__*/(function (StructureParser$$1) { - function PdbParser(streamer, params) { - var p = params || {}; - StructureParser$$1.call(this, streamer, p); - this.hex = defaults(p.hex, false); - } - - if ( StructureParser$$1 ) PdbParser.__proto__ = StructureParser$$1; - PdbParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - PdbParser.prototype.constructor = PdbParser; - - var prototypeAccessors = { type: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'pdb'; }; - PdbParser.prototype._parse = function _parse () { - // http://www.wwpdb.org/documentation/file-format.php - if (Debug) - { Log.time('PdbParser._parse ' + this.name); } - var isLegacy = false; - var headerLine = this.streamer.peekLines(1)[0]; - var headerId = headerLine.substr(62, 4); - var legacyId = headerLine.substr(72, 4); - if (headerId === legacyId && legacyId.trim()) { - isLegacy = true; - } - var isPqr = this.type === 'pqr'; - var isPdbqt = this.type === 'pdbqt'; - var s = this.structure; - var sb = this.structureBuilder; - var hex = this.hex; - var serialRadix = 10; - var resnoRadix = 10; - var firstModelOnly = this.firstModelOnly; - var asTrajectory = this.asTrajectory; - var cAlphaOnly = this.cAlphaOnly; - var frames = s.frames; - var boxes = s.boxes; - var doFrames = false; - var currentFrame, currentCoord; - var biomolDict = s.biomolDict; - var currentBiomol; - var currentPart; - var currentMatrix; - var line, recordName; - var serial, chainname, resno, resname, occupancy; - var inscode, atomname, hetero, bfactor, altloc; - var startChain, startResi, startIcode; - var endChain, endResi, endIcode; - var serialDict = {}; - var unitcellDict = {}; - var bondDict = {}; - var entityDataList = []; - var currentEntityData; - var currentEntityKey; - // MOL_ID Numbers each component; also used in SOURCE to associate - // the information. - // MOLECULE Name of the macromolecule. - // CHAIN Comma-separated list of chain identifier(s). - // FRAGMENT Specifies a domain or region of the molecule. - // SYNONYM Comma-separated list of synonyms for the MOLECULE. - // EC The Enzyme Commission number associated with the molecule. - // If there is more than one EC number, they are presented - // as a comma-separated list. - // ENGINEERED Indicates that the molecule was produced using - // recombinant technology or by purely chemical synthesis. - // MUTATION Indicates if there is a mutation. - // OTHER_DETAILS Additional comments. - var hetnameDict = {}; - var modresDict = {}; - var chainDict = {}; - var chainIdx, chainid, newChain; - var currentChainname, currentResno, currentResname, currentInscode; - var seqresDict = {}; - var currentSeqresChainname; - var secStruct = { - helices: [], - sheets: [] - }; - var helices = secStruct.helices; - var sheets = secStruct.sheets; - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.resize(Math.round(this.streamer.data.length / 80)); - if (isPqr || isPdbqt) - { atomStore.addField('partialCharge', 1, 'float32'); } - if (isPqr) - { atomStore.addField('radius', 1, 'float32'); } - var ap1 = s.getAtomProxy(); - var ap2 = s.getAtomProxy(); - var idx = 0; - var modelIdx = 0; - var pendingStart = true; - function _parseChunkOfLines(_i, _n, lines) { - var ref; - - for (var i = _i; i < _n; ++i) { - line = lines[i]; - recordName = line.substr(0, 6); - if (recordName === 'ATOM ' || recordName === 'HETATM') { - // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM - // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius - if (pendingStart) { - if (asTrajectory) { - if (doFrames) { - currentFrame = new Float32Array(atomStore.count * 3); - frames.push(currentFrame); - } - else { - currentFrame = []; - } - currentCoord = 0; - } - else { - if (!firstModelOnly) - { serialDict = {}; } - } - chainIdx = 1; - chainid = chainIdx.toString(); - newChain = true; - pendingStart = false; - } - if (firstModelOnly && modelIdx > 0) - { continue; } - var x = (void 0), y = (void 0), z = (void 0), ls = (void 0), dd = 0; - if (isPqr) { - ls = line.split(reWhitespace); - dd = ls.length === 10 ? 1 : 0; - atomname = ls[2]; - if (cAlphaOnly && atomname !== 'CA') - { continue; } - x = parseFloat(ls[6 - dd]); - y = parseFloat(ls[7 - dd]); - z = parseFloat(ls[8 - dd]); - } - else { - atomname = line.substr(12, 4).trim(); - if (cAlphaOnly && atomname !== 'CA') - { continue; } - x = parseFloat(line.substr(30, 8)); - y = parseFloat(line.substr(38, 8)); - z = parseFloat(line.substr(46, 8)); - } - if (asTrajectory) { - var j = currentCoord * 3; - currentFrame[j + 0] = x; - currentFrame[j + 1] = y; - currentFrame[j + 2] = z; - currentCoord += 1; - if (doFrames) - { continue; } - } - var element = (void 0); - if (isPqr) { - serial = parseInt(ls[1]); - element = ''; - hetero = (line[0] === 'H') ? 1 : 0; - chainname = dd ? '' : ls[4]; - resno = parseInt(ls[5 - dd]); - inscode = ''; - resname = ls[3]; - altloc = ''; - occupancy = 1.0; - } - else { - serial = parseInt(line.substr(6, 5), serialRadix); - if (hex && serial === 99999) { - serialRadix = 16; - } - hetero = (line[0] === 'H') ? 1 : 0; - chainname = line[21].trim(); - resno = parseInt(line.substr(22, 4), resnoRadix); - if (hex && resno === 9999) { - resnoRadix = 16; - } - inscode = line[26].trim(); - resname = line.substr(17, 4).trim() || 'MOL'; - bfactor = parseFloat(line.substr(60, 6)); - altloc = line[16].trim(); - occupancy = parseFloat(line.substr(54, 6)); - if (!isLegacy) { - if (isPdbqt) { - element = line.substr(12, 2).trim(); - } - else { - element = line.substr(76, 2).trim(); - if (!chainname) { - chainname = line.substr(72, 4).trim(); // segid - } - } - } - } - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(atomname, element); - atomStore.x[idx] = x; - atomStore.y[idx] = y; - atomStore.z[idx] = z; - atomStore.serial[idx] = serial; - atomStore.altloc[idx] = altloc.charCodeAt(0); - atomStore.occupancy[idx] = isNaN(occupancy) ? 0 : occupancy; - if (isPqr) { - atomStore.partialCharge[idx] = parseFloat(ls[9 - dd]); - atomStore.radius[idx] = parseFloat(ls[10 - dd]); - } - else { - atomStore.bfactor[idx] = isNaN(bfactor) ? 0 : bfactor; - if (isPdbqt) { - atomStore.partialCharge[idx] = parseFloat(line.substr(70, 6)); - } - } - var modresId = getModresId(resno, chainname, inscode); - // TODO instead of looking at MODRES look at SEQRES and - // missing residues in REMARK 465 - if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) { - if (currentChainname !== chainname || currentResname !== resname || - (!WaterNames.includes(resname) && - (currentResno !== resno || currentInscode !== inscode))) { - chainIdx += 1; - chainid = chainIdx.toString(); - currentResno = resno; - currentResname = resname; - currentInscode = inscode; - } - } - else if (!newChain && currentChainname !== chainname) { - chainIdx += 1; - chainid = chainIdx.toString(); - } - sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode); - serialDict[serial] = idx; - idx += 1; - newChain = false; - currentChainname = chainname; - } - else if (recordName === 'CONECT') { - var fromIdx = serialDict[parseInt(line.substr(6, 5))]; - var pos = [11, 16, 21, 26]; - var bondIndex = {}; - if (fromIdx === undefined) { - // Log.log( "missing CONNECT serial" ); - continue; - } - for (var j$1 = 0; j$1 < 4; ++j$1) { - var toIdx = parseInt(line.substr(pos[j$1], 5)); - if (Number.isNaN(toIdx)) - { continue; } - toIdx = serialDict[toIdx]; - if (toIdx === undefined) { - // Log.log( "missing CONNECT serial" ); - continue; - } /* else if( toIdx < fromIdx ){ - // likely a duplicate in standard PDB format - // but not necessarily, so better remove duplicates - // in a pass after parsing (and auto bonding) - continue; - } */ - if (fromIdx < toIdx) { - ap1.index = fromIdx; - ap2.index = toIdx; - } - else { - ap1.index = toIdx; - ap2.index = fromIdx; - } - // interpret records where a 'toIdx' atom is given multiple times - // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond - if (bondIndex[toIdx] !== undefined) { - s.bondStore.bondOrder[bondIndex[toIdx]] += 1; - } - else { - var hash = ap1.index + '|' + ap2.index; - if (bondDict[hash] === undefined) { - bondDict[hash] = true; - bondIndex[toIdx] = s.bondStore.count; - s.bondStore.addBond(ap1, ap2, 1); // start/assume with single bond - } - } - } - } - else if (recordName === 'HELIX ') { - startChain = line[19].trim(); - startResi = parseInt(line.substr(21, 4)); - startIcode = line[25].trim(); - endChain = line[31].trim(); - endResi = parseInt(line.substr(33, 4)); - endIcode = line[37].trim(); - var helixType = parseInt(line.substr(39, 1)); - helixType = (HelixTypes[helixType] || HelixTypes[0]).charCodeAt(0); - helices.push([ - startChain, startResi, startIcode, - endChain, endResi, endIcode, - helixType - ]); - } - else if (recordName === 'SHEET ') { - startChain = line[21].trim(); - startResi = parseInt(line.substr(22, 4)); - startIcode = line[26].trim(); - endChain = line[32].trim(); - endResi = parseInt(line.substr(33, 4)); - endIcode = line[37].trim(); - sheets.push([ - startChain, startResi, startIcode, - endChain, endResi, endIcode - ]); - } - else if (recordName === 'HETNAM') { - hetnameDict[line.substr(11, 3)] = line.substr(15).trim(); - } - else if (recordName === 'SEQRES') { - var seqresChainname = line[11].trim(); - if (seqresChainname !== currentSeqresChainname) { - seqresDict[seqresChainname] = []; - currentSeqresChainname = seqresChainname; - } - (ref = seqresDict[seqresChainname]).push.apply(ref, line.substr(19).trim().split(reWhitespace)); - } - else if (recordName === 'MODRES') { - // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE - var resname$1 = line.substr(12, 3).trim(); - var chainname$1 = line[16].trim(); - var inscode$1 = line[22].trim(); - var resno$1 = parseInt(line.substr(18, 4).trim()); - var id = getModresId(resno$1, chainname$1, inscode$1); - modresDict[id] = { resname: resname$1, chainname: chainname$1, inscode: inscode$1, resno: resno$1 }; - } - else if (recordName === 'COMPND') { - var comp = line.substr(10, 70).trim(); - var keyEnd = comp.indexOf(':'); - var key = comp.substring(0, keyEnd); - var value = (void 0); - if (entityKeyList.includes(key)) { - currentEntityKey = key; - value = comp.substring(keyEnd + 2); - } - else { - value = comp; - } - value = value.replace(/;$/, ''); - if (currentEntityKey === 'MOL_ID') { - currentEntityData = { - chainList: [], - name: '' - }; - entityDataList.push(currentEntityData); - } - else if (currentEntityKey === 'MOLECULE') { - if (currentEntityData.name) - { currentEntityData.name += ' '; } - currentEntityData.name += value; - } - else if (currentEntityKey === 'CHAIN') { - Array.prototype.push.apply(currentEntityData.chainList, value.split(/\s*,\s*/)); - } - } - else if (line.startsWith('TER')) { - var cp = s.getChainProxy(s.chainStore.count - 1); - chainDict[cp.chainname] = cp.index; - chainIdx += 1; - chainid = chainIdx.toString(); - newChain = true; - } - else if (recordName === 'REMARK' && line.substr(7, 3) === '350') { - if (line.substr(11, 12) === 'BIOMOLECULE:') { - var name = line.substr(23).trim(); - if (/^(0|[1-9][0-9]*)$/.test(name)) - { name = 'BU' + name; } - currentBiomol = new Assembly(name); - biomolDict[name] = currentBiomol; - } - else if (line.substr(13, 5) === 'BIOMT') { - var biomt = line.split(/\s+/); - var row = parseInt(line[18]) - 1; - if (row === 0) { - currentMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - currentPart.matrixList.push(currentMatrix); - } - var biomtElms = currentMatrix.elements; - biomtElms[4 * 0 + row] = parseFloat(biomt[4]); - biomtElms[4 * 1 + row] = parseFloat(biomt[5]); - biomtElms[4 * 2 + row] = parseFloat(biomt[6]); - biomtElms[4 * 3 + row] = parseFloat(biomt[7]); - } - else if (line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' || - line.substr(11, 30) === ' AND CHAINS:') { - if (line.substr(11, 5) === 'APPLY') { - currentPart = currentBiomol.addPart(); - } - var chainList = line.substr(41, 30).split(','); - for (var j$2 = 0, jl = chainList.length; j$2 < jl; ++j$2) { - var c = chainList[j$2].trim(); - if (c) - { currentPart.chainList.push(c); } - } - } - } - else if (recordName === 'HEADER') { - s.id = line.substr(62, 4); - } - else if (recordName === 'TITLE ') { - s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim(); - } - else if (recordName === 'MODEL ') { - pendingStart = true; - } - else if (recordName === 'ENDMDL' || line.trim() === 'END') { - if (pendingStart) - { continue; } - if (asTrajectory && !doFrames) { - frames.push(new Float32Array(currentFrame)); - doFrames = true; - } - modelIdx += 1; - pendingStart = true; - } - else if (line.substr(0, 5) === 'MTRIX') { - // ignore 'given' operators - if (line[59] === '1') - { continue; } - if (!currentBiomol || currentBiomol.name !== 'NCS') { - var ncsName = 'NCS'; - currentBiomol = new Assembly(ncsName); - biomolDict[ncsName] = currentBiomol; - currentPart = currentBiomol.addPart(); - } - var ncs = line.split(/\s+/); - var ncsRow = parseInt(line[5]) - 1; - if (ncsRow === 0) { - currentMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - currentPart.matrixList.push(currentMatrix); - } - var ncsElms = currentMatrix.elements; - ncsElms[4 * 0 + ncsRow] = parseFloat(ncs[2]); - ncsElms[4 * 1 + ncsRow] = parseFloat(ncs[3]); - ncsElms[4 * 2 + ncsRow] = parseFloat(ncs[4]); - ncsElms[4 * 3 + ncsRow] = parseFloat(ncs[5]); - } - else if (line.substr(0, 5) === 'ORIGX') { - if (!unitcellDict.origx) { - unitcellDict.origx = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - } - var orgix = line.split(/\s+/); - var origxRow = parseInt(line[5]) - 1; - var origxElms = unitcellDict.origx.elements; - origxElms[4 * 0 + origxRow] = parseFloat(orgix[1]); - origxElms[4 * 1 + origxRow] = parseFloat(orgix[2]); - origxElms[4 * 2 + origxRow] = parseFloat(orgix[3]); - origxElms[4 * 3 + origxRow] = parseFloat(orgix[4]); - } - else if (line.substr(0, 5) === 'SCALE') { - if (!unitcellDict.scale) { - unitcellDict.scale = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - } - var scale$$1 = line.split(/\s+/); - var scaleRow = parseInt(line[5]) - 1; - var scaleElms = unitcellDict.scale.elements; - scaleElms[4 * 0 + scaleRow] = parseFloat(scale$$1[1]); - scaleElms[4 * 1 + scaleRow] = parseFloat(scale$$1[2]); - scaleElms[4 * 2 + scaleRow] = parseFloat(scale$$1[3]); - scaleElms[4 * 3 + scaleRow] = parseFloat(scale$$1[4]); - } - else if (recordName === 'CRYST1') { - // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1 - // 7 - 15 Real(9.3) a (Angstroms) - // 16 - 24 Real(9.3) b (Angstroms) - // 25 - 33 Real(9.3) c (Angstroms) - // 34 - 40 Real(7.2) alpha alpha (degrees). - // 41 - 47 Real(7.2) beta beta (degrees). - // 48 - 54 Real(7.2) gamma gamma (degrees). - // 56 - 66 LString sGroup Space group. - // 67 - 70 Integer z Z value. - var aLength = parseFloat(line.substr(6, 9)); - var bLength = parseFloat(line.substr(15, 9)); - var cLength = parseFloat(line.substr(24, 9)); - var alpha = parseFloat(line.substr(33, 7)); - var beta = parseFloat(line.substr(40, 7)); - var gamma = parseFloat(line.substr(47, 7)); - var sGroup = line.substr(55, 11).trim(); - // const zValue = parseInt( line.substr( 66, 4 ) ); - var box = new Float32Array(9); - box[0] = aLength; - box[4] = bLength; - box[8] = cLength; - boxes.push(box); - if (modelIdx === 0) { - unitcellDict.a = aLength; - unitcellDict.b = bLength; - unitcellDict.c = cLength; - unitcellDict.alpha = alpha; - unitcellDict.beta = beta; - unitcellDict.gamma = gamma; - unitcellDict.spacegroup = sGroup; - } - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - // finalize ensures resname will be defined for all rp.resname - // (required in entity handling below) - sb.finalize(); - // - var en = entityDataList.length; - if (en) { - s.eachChain(function (cp) { - cp.entityIndex = en; - }); - entityDataList.forEach(function (e, i) { - var chainIndexList = e.chainList.map(function (chainname) { - return chainDict[chainname]; - }); - s.entityList.push(new Entity(s, i, e.name, 'polymer', chainIndexList)); - }); - var ei = entityDataList.length; - var rp = s.getResidueProxy(); - var residueDict = {}; - s.eachChain(function (cp) { - if (cp.entityIndex === en) { - rp.index = cp.residueOffset; - if (!residueDict[rp.resname]) { - residueDict[rp.resname] = []; - } - residueDict[rp.resname].push(cp.index); - } - }); - Object.keys(residueDict).forEach(function (resname) { - var chainList = residueDict[resname]; - var type = 'non-polymer'; - var name = hetnameDict[resname] || resname; - if (WaterNames.includes(resname)) { - name = 'water'; - type = 'water'; - } - s.entityList.push(new Entity(s, ei, name, type, chainList)); - ei += 1; - }); - } - // - if (unitcellDict.a !== undefined) { - s.unitcell = new Unitcell(unitcellDict); - } - else { - s.unitcell = undefined; - } - if (helices.length || sheets.length) { - assignSecondaryStructure(s, secStruct); - } - s.finalizeAtoms(); - if (!isLegacy) - { calculateChainnames(s); } - calculateBonds(s); - s.finalizeBonds(); - if (!helices.length && !sheets.length) { - calculateSecondaryStructure(s); - } - buildUnitcellAssembly(s); - if (Debug) - { Log.timeEnd('PdbParser._parse ' + this.name); } - }; - - Object.defineProperties( PdbParser.prototype, prototypeAccessors ); - - return PdbParser; -}(StructureParser)); -ParserRegistry$1.add('pdb', PdbParser); -ParserRegistry$1.add('pdb1', PdbParser); -ParserRegistry$1.add('ent', PdbParser); - -/** - * @file Cif Parser - * @author Alexander Rose - * @private - */ -var reWhitespace$1 = /\s+/; -var reQuotedWhitespace = /'((?:(?!'\s).)*)'|"((?:(?!"\s).)*)"|(\S+)/g; -var reDoubleQuote = /"/g; -var reTrimQuotes = /^['"]+|['"]+$/g; -function trimQuotes(str) { - if (str && str[0] === str[str.length - 1] && (str[0] === "'" || str[0] === '"')) { - return str.substring(1, str.length - 1); - } - else { - return str; - } -} -function ensureArray$1(dict, field) { - if (!Array.isArray(dict[field])) { - Object.keys(dict).forEach(function (key) { - dict[key] = [dict[key]]; - }); - } -} -function hasValue(d) { - return d !== '?'; -} -function cifDefaults(value, defaultValue) { - return hasValue(value) ? value : defaultValue; -} -function getBondOrder(valueOrder) { - switch (valueOrder.toLowerCase()) { - case '?': // assume single bond - case 'sing': - return 1; - case 'doub': - return 2; - case 'trip': - return 3; - case 'quad': - return 4; - } - return 0; -} -function parseChemComp(cif, structure, structureBuilder) { - var atomStore = structure.atomStore; - var atomMap = structure.atomMap; - var i, n; - var cc = cif.chem_comp; - var cca = cif.chem_comp_atom; - var ccb = cif.chem_comp_bond; - if (cc) { - if (cc.name) { - structure.title = cc.name.trim().replace(reTrimQuotes, ''); - } - if (cc.id) { - structure.id = cc.id.trim().replace(reTrimQuotes, ''); - } - } - var atomnameDict = {}; - if (cca) { - ensureArray$1(cca, 'comp_id'); - var atomname, element, resname, resno; - n = cca.comp_id.length; - for (i = 0; i < n; ++i) { - atomStore.growIfFull(); - atomname = cca.atom_id[i].replace(reDoubleQuote, ''); - element = cca.type_symbol[i]; - atomnameDict[atomname] = i; - atomStore.atomTypeId[i] = atomMap.add(atomname, element); - atomStore.x[i] = cca.model_Cartn_x[i]; - atomStore.y[i] = cca.model_Cartn_y[i]; - atomStore.z[i] = cca.model_Cartn_z[i]; - atomStore.serial[i] = i; - resname = cca.pdbx_component_comp_id[i]; - resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[i] : 1; - structureBuilder.addAtom(0, '', '', resname, resno, true); - } - for (i = 0; i < n; ++i) { - var j = i + n; - atomStore.growIfFull(); - atomname = cca.atom_id[i].replace(reDoubleQuote, ''); - element = cca.type_symbol[i]; - atomStore.atomTypeId[j] = atomMap.add(atomname, element); - atomStore.x[j] = cca.pdbx_model_Cartn_x_ideal[i]; - atomStore.y[j] = cca.pdbx_model_Cartn_y_ideal[i]; - atomStore.z[j] = cca.pdbx_model_Cartn_z_ideal[i]; - atomStore.serial[j] = j; - resname = cca.pdbx_component_comp_id[i]; - resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[i] : 1; - structureBuilder.addAtom(1, '', '', resname, resno, true); - } - } - if (cca && ccb) { - ensureArray$1(ccb, 'comp_id'); - var atomname1, atomname2, bondOrder; - n = ccb.comp_id.length; - var na = cca.comp_id.length; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - for (i = 0; i < n; ++i) { - atomname1 = ccb.atom_id_1[i].replace(reDoubleQuote, ''); - atomname2 = ccb.atom_id_2[i].replace(reDoubleQuote, ''); - bondOrder = getBondOrder(ccb.value_order[i]); - ap1.index = atomnameDict[atomname1]; - ap2.index = atomnameDict[atomname2]; - structure.bondStore.growIfFull(); - structure.bondStore.addBond(ap1, ap2, bondOrder); - ap1.index += na; - ap2.index += na; - structure.bondStore.growIfFull(); - structure.bondStore.addBond(ap1, ap2, bondOrder); - } - } -} -function parseCore(cif, structure, structureBuilder) { - var atomStore = structure.atomStore; - var atomMap = structure.atomMap; - if (cif.data) { - structure.id = cif.data; - structure.name = cif.data; - } - structure.unitcell = new Unitcell({ - a: parseFloat(cif.cell_length_a), - b: parseFloat(cif.cell_length_b), - c: parseFloat(cif.cell_length_c), - alpha: parseFloat(cif.cell_angle_alpha), - beta: parseFloat(cif.cell_angle_beta), - gamma: parseFloat(cif.cell_angle_gamma), - spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M']) - }); - var v = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var n = cif.atom_site_type_symbol.length; - for (var i = 0; i < n; ++i) { - atomStore.growIfFull(); - var atomname = cif.atom_site_label[i]; - var element = cif.atom_site_type_symbol[i]; - atomStore.atomTypeId[i] = atomMap.add(atomname, element); - v.set(cif.atom_site_fract_x[i], cif.atom_site_fract_y[i], cif.atom_site_fract_z[i]); - v.applyMatrix4(structure.unitcell.fracToCart); - c.add(v); - atomStore.x[i] = v.x; - atomStore.y[i] = v.y; - atomStore.z[i] = v.z; - if (cif.atom_site_occupancy) { - atomStore.occupancy[i] = parseFloat(cif.atom_site_occupancy[i]); - } - atomStore.serial[i] = i; - structureBuilder.addAtom(0, '', '', 'HET', 1, true); - } - c.divideScalar(n); - structure.center = c; - buildUnitcellAssembly(structure); - var v2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var v3 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var ml = structure.biomolDict.SUPERCELL.partList[0].matrixList; - var k = n; - function covalent(idx) { - return atomMap.get(atomStore.atomTypeId[idx]).covalent; - } - var identityMatrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - var loop = function ( i ) { - var covalentI = covalent(i); - v.set(atomStore.x[i], atomStore.y[i], atomStore.z[i]); - ml.forEach(function (m) { - if (identityMatrix.equals(m)) - { return; } - v2.copy(v); - v2.applyMatrix4(m); - for (var j = 0; j < n; ++j) { - v3.set(atomStore.x[j], atomStore.y[j], atomStore.z[j]); - var distSquared = v2.distanceToSquared(v3); - var d = covalent(j) + covalentI; - var d1 = d + 0.3; - var d2 = d - 0.5; - if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) { - atomStore.growIfFull(); - atomStore.atomTypeId[k] = atomStore.atomTypeId[i]; - atomStore.x[k] = v2.x; - atomStore.y[k] = v2.y; - atomStore.z[k] = v2.z; - atomStore.occupancy[k] = atomStore.occupancy[i]; - atomStore.serial[k] = k; - atomStore.altloc[k] = 'A'.charCodeAt(0); - structureBuilder.addAtom(0, '', '', 'HET', 1, true); - k += 1; - return; - } - } - }); - }; - - for (var i$1 = 0; i$1 < n; ++i$1) loop( i$1 ); -} -function processSecondaryStructure(cif, structure, asymIdDict) { - var helices = []; - var sheets = []; - var i, il, begIcode, endIcode; - // get helices - var sc = cif.struct_conf; - if (sc) { - ensureArray$1(sc, 'id'); - for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) { - var helixType = parseInt(sc.pdbx_PDB_helix_class[i]); - if (!Number.isNaN(helixType)) { - begIcode = sc.pdbx_beg_PDB_ins_code[i]; - endIcode = sc.pdbx_end_PDB_ins_code[i]; - helices.push([ - asymIdDict[sc.beg_label_asym_id[i]], - parseInt(sc.beg_auth_seq_id[i]), - cifDefaults(begIcode, ''), - asymIdDict[sc.end_label_asym_id[i]], - parseInt(sc.end_auth_seq_id[i]), - cifDefaults(endIcode, ''), - (HelixTypes[helixType] || HelixTypes[0]).charCodeAt(0) - ]); - } - } - } - // get sheets - var ssr = cif.struct_sheet_range; - if (ssr) { - ensureArray$1(ssr, 'id'); - for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) { - begIcode = ssr.pdbx_beg_PDB_ins_code[i]; - endIcode = ssr.pdbx_end_PDB_ins_code[i]; - sheets.push([ - asymIdDict[ssr.beg_label_asym_id[i]], - parseInt(ssr.beg_auth_seq_id[i]), - cifDefaults(begIcode, ''), - asymIdDict[ssr.end_label_asym_id[i]], - parseInt(ssr.end_auth_seq_id[i]), - cifDefaults(endIcode, '') - ]); - } - } - if (sc || ssr) { - return { - helices: helices, - sheets: sheets - }; - } - else { - return false; - } -} -function processSymmetry(cif, structure, asymIdDict) { - // biomol & ncs processing - var operDict = {}; - var biomolDict = structure.biomolDict; - if (cif.pdbx_struct_oper_list) { - var biomolOp = cif.pdbx_struct_oper_list; - ensureArray$1(biomolOp, 'id'); - biomolOp.id.forEach(function (id, i) { - var m = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - var elms = m.elements; - elms[0] = parseFloat(biomolOp['matrix[1][1]'][i]); - elms[1] = parseFloat(biomolOp['matrix[1][2]'][i]); - elms[2] = parseFloat(biomolOp['matrix[1][3]'][i]); - elms[4] = parseFloat(biomolOp['matrix[2][1]'][i]); - elms[5] = parseFloat(biomolOp['matrix[2][2]'][i]); - elms[6] = parseFloat(biomolOp['matrix[2][3]'][i]); - elms[8] = parseFloat(biomolOp['matrix[3][1]'][i]); - elms[9] = parseFloat(biomolOp['matrix[3][2]'][i]); - elms[10] = parseFloat(biomolOp['matrix[3][3]'][i]); - elms[3] = parseFloat(biomolOp['vector[1]'][i]); - elms[7] = parseFloat(biomolOp['vector[2]'][i]); - elms[11] = parseFloat(biomolOp['vector[3]'][i]); - m.transpose(); - operDict[id] = m; - }); - } - if (cif.pdbx_struct_assembly_gen) { - var gen = cif.pdbx_struct_assembly_gen; - ensureArray$1(gen, 'assembly_id'); - var getMatrixDict = function (expr) { - var matDict = {}; - var l = expr.replace(/[()']/g, '').split(','); - l.forEach(function (e) { - if (e.includes('-')) { - var es = e.split('-'); - var j = parseInt(es[0]); - var m = parseInt(es[1]); - for (; j <= m; ++j) { - matDict[j] = operDict[j]; - } - } - else { - matDict[e] = operDict[e]; - } - }); - return matDict; - }; - gen.assembly_id.forEach(function (id, i) { - var md = {}; - var oe = gen.oper_expression[i].replace(/['"]\(|['"]/g, ''); - if (oe.includes(')(') || oe.indexOf('(') > 0) { - oe = oe.split('('); - var md1 = getMatrixDict(oe[0]); - var md2 = getMatrixDict(oe[1]); - Object.keys(md1).forEach(function (k1) { - Object.keys(md2).forEach(function (k2) { - var mat = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - mat.multiplyMatrices(md1[k1], md2[k2]); - md[k1 + 'x' + k2] = mat; - }); - }); - } - else { - md = getMatrixDict(oe); - } - var matrixList = []; - for (var k in md) { - matrixList.push(md[k]); - } - var name = id; - if (/^(0|[1-9][0-9]*)$/.test(name)) - { name = 'BU' + name; } - var chainList = gen.asym_id_list[i].split(','); - for (var j = 0, jl = chainList.length; j < jl; ++j) { - chainList[j] = asymIdDict[chainList[j]]; - } - if (biomolDict[name] === undefined) { - biomolDict[name] = new Assembly(name); - } - biomolDict[name].addPart(matrixList, chainList); - }); - } - // non-crystallographic symmetry operations - if (cif.struct_ncs_oper) { - var ncsOp = cif.struct_ncs_oper; - ensureArray$1(ncsOp, 'id'); - var ncsName = 'NCS'; - biomolDict[ncsName] = new Assembly(ncsName); - var ncsPart = biomolDict[ncsName].addPart(); - ncsOp.id.forEach(function (id, i) { - // ignore 'given' operators - if (ncsOp.code[i] === 'given') - { return; } - var m = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - var elms = m.elements; - elms[0] = parseFloat(ncsOp['matrix[1][1]'][i]); - elms[1] = parseFloat(ncsOp['matrix[1][2]'][i]); - elms[2] = parseFloat(ncsOp['matrix[1][3]'][i]); - elms[4] = parseFloat(ncsOp['matrix[2][1]'][i]); - elms[5] = parseFloat(ncsOp['matrix[2][2]'][i]); - elms[6] = parseFloat(ncsOp['matrix[2][3]'][i]); - elms[8] = parseFloat(ncsOp['matrix[3][1]'][i]); - elms[9] = parseFloat(ncsOp['matrix[3][2]'][i]); - elms[10] = parseFloat(ncsOp['matrix[3][3]'][i]); - elms[3] = parseFloat(ncsOp['vector[1]'][i]); - elms[7] = parseFloat(ncsOp['vector[2]'][i]); - elms[11] = parseFloat(ncsOp['vector[3]'][i]); - m.transpose(); - ncsPart.matrixList.push(m); - }); - if (ncsPart.matrixList.length === 0) { - delete biomolDict[ncsName]; - } - } - // cell & symmetry - var unitcellDict = {}; - if (cif.cell) { - var cell = cif.cell; - var a = parseFloat(cell.length_a); - var b = parseFloat(cell.length_b); - var c = parseFloat(cell.length_c); - var box = new Float32Array(9); - box[0] = a; - box[4] = b; - box[8] = c; - structure.boxes.push(box); - unitcellDict.a = a; - unitcellDict.b = b; - unitcellDict.c = c; - unitcellDict.alpha = parseFloat(cell.angle_alpha); - unitcellDict.beta = parseFloat(cell.angle_beta); - unitcellDict.gamma = parseFloat(cell.angle_gamma); - } - if (cif.symmetry) { - unitcellDict.spacegroup = trimQuotes(cif.symmetry['space_group_name_H-M']); - } - // origx - var origx = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - if (cif.database_PDB_matrix) { - var origxMat = cif.database_PDB_matrix; - var origxElms = origx.elements; - origxElms[0] = parseFloat(origxMat['origx[1][1]']); - origxElms[1] = parseFloat(origxMat['origx[1][2]']); - origxElms[2] = parseFloat(origxMat['origx[1][3]']); - origxElms[4] = parseFloat(origxMat['origx[2][1]']); - origxElms[5] = parseFloat(origxMat['origx[2][2]']); - origxElms[6] = parseFloat(origxMat['origx[2][3]']); - origxElms[8] = parseFloat(origxMat['origx[3][1]']); - origxElms[9] = parseFloat(origxMat['origx[3][2]']); - origxElms[10] = parseFloat(origxMat['origx[3][3]']); - origxElms[3] = parseFloat(origxMat['origx_vector[1]']); - origxElms[7] = parseFloat(origxMat['origx_vector[2]']); - origxElms[11] = parseFloat(origxMat['origx_vector[3]']); - origx.transpose(); - unitcellDict.origx = origx; - } - // scale - var scale$$1 = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - if (cif.atom_sites) { - var scaleMat = cif.atom_sites; - var scaleElms = scale$$1.elements; - scaleElms[0] = parseFloat(scaleMat['fract_transf_matrix[1][1]']); - scaleElms[1] = parseFloat(scaleMat['fract_transf_matrix[1][2]']); - scaleElms[2] = parseFloat(scaleMat['fract_transf_matrix[1][3]']); - scaleElms[4] = parseFloat(scaleMat['fract_transf_matrix[2][1]']); - scaleElms[5] = parseFloat(scaleMat['fract_transf_matrix[2][2]']); - scaleElms[6] = parseFloat(scaleMat['fract_transf_matrix[2][3]']); - scaleElms[8] = parseFloat(scaleMat['fract_transf_matrix[3][1]']); - scaleElms[9] = parseFloat(scaleMat['fract_transf_matrix[3][2]']); - scaleElms[10] = parseFloat(scaleMat['fract_transf_matrix[3][3]']); - scaleElms[3] = parseFloat(scaleMat['fract_transf_vector[1]']); - scaleElms[7] = parseFloat(scaleMat['fract_transf_vector[2]']); - scaleElms[11] = parseFloat(scaleMat['fract_transf_vector[3]']); - scale$$1.transpose(); - unitcellDict.scale = scale$$1; - } - if (unitcellDict.a !== undefined) { - structure.unitcell = new Unitcell(unitcellDict); - } - else { - structure.unitcell = undefined; - } -} -function processConnections(cif, structure, asymIdDict) { - // add connections - var sc = cif.struct_conn; - if (sc) { - ensureArray$1(sc, 'id'); - var reDoubleQuote = /"/g; - var ap1 = structure.getAtomProxy(); - var ap2 = structure.getAtomProxy(); - var atomIndicesCache = {}; - for (var i = 0, il = sc.id.length; i < il; ++i) { - // ignore: - // hydrog - hydrogen bond - // mismat - mismatched base pairs - // saltbr - ionic interaction - var connTypeId = sc.conn_type_id[i]; - if (connTypeId === 'hydrog' || - connTypeId === 'mismat' || - connTypeId === 'saltbr') - { continue; } - // ignore bonds between symmetry mates - if (sc.ptnr1_symmetry[i] !== '1_555' || - sc.ptnr2_symmetry[i] !== '1_555') - { continue; } - // process: - // covale - covalent bond - // covale_base - - // covalent modification of a nucleotide base - // covale_phosphate - - // covalent modification of a nucleotide phosphate - // covale_sugar - - // covalent modification of a nucleotide sugar - // disulf - disulfide bridge - // metalc - metal coordination - // modres - covalent residue modification - var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[i]; - var altloc1 = sc.pdbx_ptnr1_label_alt_id[i]; - var sele1 = (sc.ptnr1_auth_seq_id[i] + - (hasValue(inscode1) ? ('^' + inscode1) : '') + - ':' + asymIdDict[sc.ptnr1_label_asym_id[i]] + - '.' + sc.ptnr1_label_atom_id[i].replace(reDoubleQuote, '') + - (hasValue(altloc1) ? ('%' + altloc1) : '')); - var atomIndices1 = atomIndicesCache[sele1]; - if (!atomIndices1) { - var selection1 = new Selection(sele1); - if (selection1.selection.error) { - if (Debug) - { Log.warn('invalid selection for connection', sele1); } - continue; - } - atomIndices1 = structure.getAtomIndices(selection1); - atomIndicesCache[sele1] = atomIndices1; - } - var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[i]; - var altloc2 = sc.pdbx_ptnr2_label_alt_id[i]; - var sele2 = (sc.ptnr2_auth_seq_id[i] + - (hasValue(inscode2) ? ('^' + inscode2) : '') + - ':' + asymIdDict[sc.ptnr2_label_asym_id[i]] + - '.' + sc.ptnr2_label_atom_id[i].replace(reDoubleQuote, '') + - (hasValue(altloc2) ? ('%' + altloc2) : '')); - var atomIndices2 = atomIndicesCache[sele2]; - if (!atomIndices2) { - var selection2 = new Selection(sele2); - if (selection2.selection.error) { - if (Debug) - { Log.warn('invalid selection for connection', sele2); } - continue; - } - atomIndices2 = structure.getAtomIndices(selection2); - atomIndicesCache[sele2] = atomIndices2; - } - // cases with more than one atom per selection - // - #altloc1 to #altloc2 - // - #model to #model - // - #altloc1 * #model to #altloc2 * #model - var k = atomIndices1.length; - var l = atomIndices2.length; - if (k > l) { - var tmpA = k; - k = l; - l = tmpA; - var tmpB = atomIndices1; - atomIndices1 = atomIndices2; - atomIndices2 = tmpB; - } - // console.log( k, l ); - if (k === 0 || l === 0) { - if (Debug) - { Log.warn('no atoms found for', sele1, sele2); } - continue; - } - for (var j = 0; j < l; ++j) { - ap1.index = atomIndices1[j % k]; - ap2.index = atomIndices2[j]; - if (ap1 && ap2) { - structure.bondStore.addBond(ap1, ap2, getBondOrder(sc.pdbx_value_order[i])); - } - else { - Log.log('atoms for connection not found'); - } - } - } - } -} -function processEntities(cif, structure, chainIndexDict) { - if (cif.entity) { - ensureArray$1(cif.entity, 'id'); - var e = cif.entity; - var n = e.id.length; - for (var i = 0; i < n; ++i) { - var description = e.pdbx_description[i]; - var type = e.type[i]; - var chainIndexList = Array.from(chainIndexDict[e.id[i]]); - structure.entityList[i] = new Entity(structure, i, description, type, chainIndexList); - } - } -} -// -var CifParser = /*@__PURE__*/(function (StructureParser$$1) { - function CifParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) CifParser.__proto__ = StructureParser$$1; - CifParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - CifParser.prototype.constructor = CifParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'cif'; }; - CifParser.prototype._parse = function _parse () { - // http://mmcif.wwpdb.org/ - Log.time('CifParser._parse ' + this.name); - var s = this.structure; - var sb = this.structureBuilder; - var firstModelOnly = this.firstModelOnly; - var asTrajectory = this.asTrajectory; - var cAlphaOnly = this.cAlphaOnly; - var frames = s.frames; - var currentFrame, currentCoord; - var rawline, line; - // - var cif = {}; - var asymIdDict = {}; - var chainIndexDict = {}; - var pendingString = false; - var currentString = null; - var pendingValue = false; - var pendingLoop = false; - var pendingName = false; - var loopPointers = []; - var currentLoopIndex = null; - var currentCategory = null; - var currentName = null; - var first = null; - var pointerNames = []; - var authAsymId, authSeqId, labelAtomId, labelCompId, labelAsymId, labelEntityId, labelAltId, groupPDB, id, typeSymbol, pdbxPDBmodelNum, pdbxPDBinsCode, CartnX, CartnY, CartnZ, bIsoOrEquiv, occupancy; - // - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.resize(this.streamer.data.length / 100); - var idx = 0; - var modelIdx = 0; - var modelNum; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - rawline = lines[i]; - line = rawline.trim(); - if ((!line && !pendingString && !pendingLoop) || line[0] === '#') { - // Log.log( "NEW BLOCK" ); - pendingString = false; - pendingLoop = false; - pendingValue = false; - loopPointers.length = 0; - currentLoopIndex = null; - currentCategory = null; - currentName = null; - first = null; - pointerNames.length = 0; - } - else if (line.substring(0, 5) === 'data_') { - cif.data = line.substring(5).trim(); - // Log.log( "DATA", data ); - } - else if (line[0] === ';') { - if (pendingString) { - // Log.log( "STRING END", currentString ); - if (pendingLoop) { - if (currentLoopIndex === loopPointers.length) { - currentLoopIndex = 0; - } - loopPointers[currentLoopIndex].push(currentString); - currentLoopIndex += 1; - } - else { - if (currentName === false) { - cif[currentCategory] = currentString; - } - else { - cif[currentCategory][currentName] = currentString; //TODO currentname can equals null - } - } - pendingString = false; - currentString = null; - } - else { - // Log.log( "STRING START" ); - pendingString = true; - currentString = line.substring(1); - } - } - else if (line === 'loop_') { - // Log.log( "LOOP START" ); - pendingLoop = true; - pendingName = true; - loopPointers.length = 0; - pointerNames.length = 0; - currentLoopIndex = 0; - } - else if (line[0] === '_') { - var keyParts, category, name; - if (pendingLoop && !pendingName) { - pendingLoop = false; - } - if (pendingLoop) { - // Log.log( "LOOP KEY", line ); - keyParts = line.split('.'); - category = keyParts[0].substring(1); - name = keyParts[1]; - if (keyParts.length === 1) { - name = false; - if (!cif[category]) - { cif[category] = []; } - loopPointers.push(cif[category]); - } - else { - if (!cif[category]) - { cif[category] = {}; } - if (cif[category][name]) { - if (Debug) - { Log.warn(category, name, 'already exists'); } - } - else { - cif[category][name] = []; - loopPointers.push(cif[category][name]); - pointerNames.push(name); - } - } - currentCategory = category; - currentName = name; - first = true; - } - else { - var keyValuePair = line.match(reQuotedWhitespace); - var key = keyValuePair[0]; - var value = keyValuePair[1]; - keyParts = key.split('.'); - category = keyParts[0].substring(1); - name = keyParts[1]; - if (keyParts.length === 1) { - name = false; - cif[category] = value; - } - else { - if (!cif[category]) - { cif[category] = {}; } - if (cif[category][name]) { - if (Debug) - { Log.warn(category, name, 'already exists'); } - } - else { - cif[category][name] = value; - } - } - if (!value) - { pendingValue = true; } - currentCategory = category; - currentName = name; - } - } - else { - if (pendingString) { - // Log.log( "STRING VALUE", line ); - currentString += rawline; - } - else if (pendingLoop) { - // Log.log( "LOOP VALUE", line ); - if (!line) { - continue; - } - else if (currentCategory === 'atom_site') { - var ls = line.split(reWhitespace$1); - if (first) { - authAsymId = pointerNames.indexOf('auth_asym_id'); - authSeqId = pointerNames.indexOf('auth_seq_id'); - labelAtomId = pointerNames.indexOf('label_atom_id'); - labelCompId = pointerNames.indexOf('label_comp_id'); - labelAsymId = pointerNames.indexOf('label_asym_id'); - labelEntityId = pointerNames.indexOf('label_entity_id'); - labelAltId = pointerNames.indexOf('label_alt_id'); - CartnX = pointerNames.indexOf('Cartn_x'); - CartnY = pointerNames.indexOf('Cartn_y'); - CartnZ = pointerNames.indexOf('Cartn_z'); - id = pointerNames.indexOf('id'); - typeSymbol = pointerNames.indexOf('type_symbol'); - groupPDB = pointerNames.indexOf('group_PDB'); - bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv'); - pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num'); - pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code'); - occupancy = pointerNames.indexOf('occupancy'); - first = false; - modelNum = parseInt(ls[pdbxPDBmodelNum]); - if (asTrajectory) { - currentFrame = []; - currentCoord = 0; - } - } - // - var _modelNum = parseInt(ls[pdbxPDBmodelNum]); - if (modelNum !== _modelNum) { - if (asTrajectory) { - if (modelIdx === 0) { - frames.push(new Float32Array(currentFrame)); - } - currentFrame = new Float32Array(atomStore.count * 3); - frames.push(currentFrame); - currentCoord = 0; - } - modelIdx += 1; - } - modelNum = _modelNum; - if (firstModelOnly && modelIdx > 0) - { continue; } - // - var atomname = ls[labelAtomId].replace(reDoubleQuote, ''); - if (cAlphaOnly && atomname !== 'CA') - { continue; } - var x = parseFloat(ls[CartnX]); - var y = parseFloat(ls[CartnY]); - var z = parseFloat(ls[CartnZ]); - if (asTrajectory) { - var frameOffset = currentCoord * 3; - currentFrame[frameOffset + 0] = x; - currentFrame[frameOffset + 1] = y; - currentFrame[frameOffset + 2] = z; - currentCoord += 1; - if (modelIdx > 0) - { continue; } - } - // - var resname = ls[labelCompId]; - var resno = parseInt(ls[authSeqId]); - var inscode = ls[pdbxPDBinsCode]; - inscode = (inscode === '?') ? '' : inscode; - var chainname = ls[authAsymId]; - var chainid = ls[labelAsymId]; - var hetero = (ls[groupPDB][0] === 'H') ? 1 : 0; - // - var element = ls[typeSymbol]; - var bfactor = parseFloat(ls[bIsoOrEquiv]); - var occ = parseFloat(ls[occupancy]); - var altloc = ls[labelAltId]; - altloc = (altloc === '.') ? '' : altloc; - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(atomname, element); - atomStore.x[idx] = x; - atomStore.y[idx] = y; - atomStore.z[idx] = z; - atomStore.serial[idx] = parseInt(ls[id]); - atomStore.bfactor[idx] = isNaN(bfactor) ? 0 : bfactor; - atomStore.occupancy[idx] = isNaN(occ) ? 0 : occ; - atomStore.altloc[idx] = altloc.charCodeAt(0); - sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode); - if (Debug) { - // check if one-to-many (chainname-asymId) relationship is - // actually a many-to-many mapping - var assignedChainname = asymIdDict[chainid]; - if (assignedChainname !== undefined && assignedChainname !== chainname) { - if (Debug) - { Log.warn(assignedChainname, chainname); } - } - } - // chainname mapping: label_asym_id -> auth_asym_id - asymIdDict[chainid] = chainname; - // entity mapping: chainIndex -> label_entity_id - var entityId = ls[labelEntityId]; - if (!chainIndexDict[entityId]) { - chainIndexDict[entityId] = new Set(); - } - chainIndexDict[entityId].add(s.chainStore.count - 1); - idx += 1; - } - else { - var ls$1 = line.match(reQuotedWhitespace); - var nn = ls$1.length; - if (currentLoopIndex === loopPointers.length) { - currentLoopIndex = 0; - } /* else if( currentLoopIndex + nn > loopPointers.length ){ - Log.warn( "cif parsing error, wrong number of loop data entries", nn, loopPointers.length ); - } */ - for (var j = 0; j < nn; ++j) { - loopPointers[currentLoopIndex + j].push(ls$1[j]); - } - currentLoopIndex += nn; - } - pendingName = false; - } - else if (line[0] === "'" && line[line.length - 1] === "'") { - // Log.log( "NEWLINE STRING", line ); - var str = line.substring(1, line.length - 1); - if (currentName === false) { - cif[currentCategory] = str; - } - else { - cif[currentCategory][currentName] = str; - } - } - else if (pendingValue) { - // Log.log( "NEWLINE VALUE", line ); - if (currentName === false) { - cif[currentCategory] = line; - } - else { - cif[currentCategory][currentName] = line; - } - } - else { - if (Debug) - { Log.log('CifParser._parse: unknown state', line); } - } - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - if (cif.chem_comp && cif.chem_comp_atom) { - parseChemComp(cif, s, sb); - sb.finalize(); - s.finalizeAtoms(); - s.finalizeBonds(); - assignResidueTypeBonds(s); - } - else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) { - parseCore(cif, s, sb); - sb.finalize(); - s.finalizeAtoms(); - calculateBonds(s); - s.finalizeBonds(); - // assignResidueTypeBonds( s ); - } - else { - var secStruct = processSecondaryStructure(cif, s, asymIdDict); - processSymmetry(cif, s, asymIdDict); - processConnections(cif, s, asymIdDict); - processEntities(cif, s, chainIndexDict); - if (cif.struct && cif.struct.title) { - s.title = cif.struct.title.trim().replace(reTrimQuotes, ''); - } - if (cif.entry && cif.entry.id) { - s.id = cif.entry.id.trim().replace(reTrimQuotes, ''); - } - // structure header (mimicking biojava) - if (cif.pdbx_audit_revision_history) { - if (cif.pdbx_audit_revision_history.revision_date) { - ensureArray$1(cif.pdbx_audit_revision_history, 'revision_date'); - var dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue); - if (dates.length) { - s.header.releaseDate = dates[0]; - } - } - if (cif.pdbx_database_status.recvd_initial_deposition_date) { - ensureArray$1(cif.pdbx_database_status, 'recvd_initial_deposition_date'); - var depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue); - if (depDates.length) { - s.header.depositionDate = depDates[0]; - } - } - } - else if (cif.database_PDB_rev) { - if (cif.database_PDB_rev.date) { - ensureArray$1(cif.database_PDB_rev, 'date'); - var dates$1 = cif.database_PDB_rev.date.filter(hasValue); - if (dates$1.length) { - s.header.releaseDate = dates$1[0]; - } - } - if (cif.database_PDB_rev.date_original) { - ensureArray$1(cif.database_PDB_rev, 'date_original'); - var depDates$1 = cif.database_PDB_rev.date_original.filter(hasValue); - if (depDates$1.length) { - s.header.depositionDate = depDates$1[0]; - } - } - } - if (cif.reflns && cif.reflns.d_resolution_high) { - if (hasValue(cif.reflns.d_resolution_high)) { - s.header.resolution = parseFloat(cif.reflns.d_resolution_high); - } - } - else if (cif.refine && cif.refine.ls_d_res_high) { - if (hasValue(cif.refine.ls_d_res_high)) { - s.header.resolution = parseFloat(cif.refine.ls_d_res_high); - } - } - if (cif.refine && cif.refine.ls_R_factor_R_free) { - if (hasValue(cif.refine.ls_R_factor_R_free)) { - s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free); - } - } - if (cif.refine && cif.refine.ls_R_factor_R_work) { - if (hasValue(cif.refine.ls_R_factor_R_work)) { - s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work); - } - } - if (cif.exptl && cif.exptl.method) { - ensureArray$1(cif.exptl, 'method'); - s.header.experimentalMethods = cif.exptl.method.map(function (m) { - return m.replace(reTrimQuotes, ''); - }); - } - sb.finalize(); - s.finalizeAtoms(); - calculateBonds(s); - s.finalizeBonds(); - if (!secStruct) { - calculateSecondaryStructure(s); - } - else { - assignSecondaryStructure(s, secStruct); - } - buildUnitcellAssembly(s); - s.extraData.cif = cif; - } - if (Debug) - { Log.timeEnd('CifParser._parse ' + this.name); } - }; - - Object.defineProperties( CifParser.prototype, prototypeAccessors ); - - return CifParser; -}(StructureParser)); -ParserRegistry$1.add('cif', CifParser); -ParserRegistry$1.add('mcif', CifParser); -ParserRegistry$1.add('mmcif', CifParser); - -/** - * @file Gro Parser - * @author Alexander Rose - * @private - */ -var GroParser = /*@__PURE__*/(function (StructureParser$$1) { - function GroParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) GroParser.__proto__ = StructureParser$$1; - GroParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - GroParser.prototype.constructor = GroParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'gro'; }; - GroParser.prototype._parse = function _parse () { - // http://manual.gromacs.org/current/online/gro.html - if (Debug) - { Log.time('GroParser._parse ' + this.name); } - var s = this.structure; - var sb = this.structureBuilder; - var firstModelOnly = this.firstModelOnly; - var asTrajectory = this.asTrajectory; - var cAlphaOnly = this.cAlphaOnly; - var frames = s.frames; - var boxes = s.boxes; - var currentFrame, currentCoord; - var firstLines = this.streamer.peekLines(3); - s.title = firstLines[0].trim(); - // determine number of decimal places - var ndec = firstLines[2].length - firstLines[2].lastIndexOf('.') - 1; - var lpos = 5 + ndec; - var xpos = 20; - var ypos = 20 + lpos; - var zpos = 20 + 2 * lpos; - // - var atomname, resname, resno, serial; - var atomCount = parseInt(firstLines[1]); - var modelLineCount = atomCount + 3; - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.resize(atomCount); - var idx = 0; - var modelIdx = 0; - var lineNo = 0; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - ++lineNo; - var l = lineNo - 1; - var line = lines[i]; - if (!line) - { continue; } - if (l % modelLineCount === 0) { - // Log.log( "title", line ) - if (asTrajectory) { - currentFrame = new Float32Array(atomCount * 3); - frames.push(currentFrame); - currentCoord = 0; - } - } - else if (l % modelLineCount === 1) ; - else if (l % modelLineCount === modelLineCount - 1) { - var str = line.trim().split(/\s+/); - var box = new Float32Array(9); - box[0] = parseFloat(str[0]) * 10; - box[4] = parseFloat(str[1]) * 10; - box[8] = parseFloat(str[2]) * 10; - boxes.push(box); - if (firstModelOnly) { - return true; - } - modelIdx += 1; - } - else { - atomname = line.substr(10, 5).trim(); - if (cAlphaOnly && atomname !== 'CA') - { continue; } - var x = parseFloat(line.substr(xpos, lpos)) * 10; - var y = parseFloat(line.substr(ypos, lpos)) * 10; - var z = parseFloat(line.substr(zpos, lpos)) * 10; - if (asTrajectory) { - var j = currentCoord * 3; - currentFrame[j + 0] = x; - currentFrame[j + 1] = y; - currentFrame[j + 2] = z; - currentCoord += 1; - if (l > modelLineCount) - { continue; } - } - resname = line.substr(5, 5).trim(); - resno = parseInt(line.substr(0, 5)); - serial = parseInt(line.substr(15, 5)); - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(atomname); - atomStore.x[idx] = x; - atomStore.y[idx] = y; - atomStore.z[idx] = z; - atomStore.serial[idx] = serial; - sb.addAtom(modelIdx, '', '', resname, resno, 0, 'l'); - idx += 1; - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - sb.finalize(); - s.finalizeAtoms(); - calculateChainnames(s); - calculateBonds(s); - s.finalizeBonds(); - calculateSecondaryStructure(s); - if (Debug) - { Log.timeEnd('GroParser._parse ' + this.name); } - }; - - Object.defineProperties( GroParser.prototype, prototypeAccessors ); - - return GroParser; -}(StructureParser)); -ParserRegistry$1.add('gro', GroParser); - -/** - * @file utf8-utils - * @private - * @author Alexander Rose - * mostly copied from https://github.com/creationix/msgpack-js-browser - * by Tim Caswell , MIT License, Copyright (c) 2013 - */ - -/** - * @file mmtf-constants - * @private - * @author Alexander Rose - */ - - -var PassThroughFields = [ - "mmtfVersion", "mmtfProducer", - "unitCell", "spaceGroup", "structureId", "title", - "depositionDate", "releaseDate", - "experimentalMethods", "resolution", "rFree", "rWork", - "bioAssemblyList", "ncsOperatorList", "entityList", "groupList", - "numBonds", "numAtoms", "numGroups", "numChains", "numModels", - "groupsPerChain", "chainsPerModel" ]; - -var EncodedFields = [ - // required - "xCoordList", "yCoordList", "zCoordList", - "groupIdList", "groupTypeList", - "chainIdList", - // optional - "bFactorList", "atomIdList", "altLocList", "occupancyList", - "secStructList", "insCodeList", "sequenceIndexList", - "chainNameList", - "bondAtomList", "bondOrderList" -]; - -var AllFields = PassThroughFields.concat( EncodedFields ); - -/** - * @file mmtf-utils - * @private - * @author Alexander Rose - */ - -/** - * mmtf utils module. - * @module MmtfUtils - */ - - -function getView( ctor, typedArray, elemSize ){ - return typedArray ? new ctor( - typedArray.buffer, - typedArray.byteOffset, - typedArray.byteLength / ( elemSize || 1 ) - ) : undefined; -} - -function getDataView( typedArray ){ - return getView( DataView, typedArray ); -} - -/** - * get an Uint8Array view on the input array memory - * @static - * @param {TypedArray} dataArray - input array - * @return {Uint8Array} new view on the input array memory - */ -function getUint8View( typedArray ){ - return getView( Uint8Array, typedArray ); -} - -/** - * get an Int8Array view on the input array memory - * @static - * @param {TypedArray} dataArray - input array - * @return {Int8Array} new view on the input array memory - */ -function getInt8View( typedArray ){ - return getView( Int8Array, typedArray ); -} - -/** - * get an Int32Array view on the input array memory - * @static - * @param {TypedArray} dataArray - input array - * @return {Int32Array} new view on the input array memory - */ -function getInt32View( typedArray ){ - return getView( Int32Array, typedArray, 4 ); -} - -function getFloat32View( typedArray ){ - return getView( Float32Array, typedArray, 4 ); -} - - -/** - * get an Int16Array copy of the the input array data - * @static - * @param {TypedArray} view - input data in big endian format - * @param {Int16Array} [dataArray] - pre-allocated output array - * @return {Int16Array} copy of the input array data - */ -function decodeInt16( bytes, output ){ - var n = bytes.length / 2; - if( !output ) { output = new Int16Array( n ); } - for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){ - output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0; - } - return output; -} - -/** - * get an Int32Array copy of the the input array data - * @static - * @param {TypedArray} view - input data in big endian format - * @param {Int32Array} [dataArray] - pre-allocated output array - * @return {Int32Array} copy of the input array data - */ -function decodeInt32( bytes, output ){ - var n = bytes.length / 4; - if( !output ) { output = new Int32Array( n ); } - for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){ - output[ i ] = ( - bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^ - bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0 - ); - } - return output; -} - -function decodeFloat32( bytes, output ){ - var n = bytes.length; - if( !output ) { output = new Float32Array( n / 4 ); } - var dvOut = getDataView( output ); - var dvIn = getDataView( bytes ); - for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){ - dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true ); - } - return output; -} - -/** - * decode integers into floats using given divisor - * example: - * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ] - * divisor: 100 - * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ] - * @static - * @param {TypedArray|Array} intArray - input array containing integers - * @param {Number} divisor - number to devide the integers to obtain floats - * @param {Float32Array} [dataArray] - pre-allocated output array - * @return {Float32Array} decoded array - */ -function decodeInteger( intArray, divisor, output ){ - var n = intArray.length; - var invDiv = 1/divisor; - if( !output ) { output = new Float32Array( n ); } - for( var i = 0; i < n; ++i ){ - // multiply by inverse of the divisor which is faster then division - output[ i ] = intArray[ i ] * invDiv; - } - return output; -} - - - -/** - * perform run-length decoding of input array - * example: - * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run - * return: [ 0, 0, 3, 3, 3, 3, 3 ] - * @static - * @param {TypedArray|Array} array - run-length encoded input array - * @param {TypedArray|Array} [dataArray] - pre-allocated output array - * @return {TypedArray|Array} decoded array - */ -function decodeRun( array, output ){ - var i, il; - if( !output ){ - // calculate the length the decoded array will have - var fullLength = 0; - for( i = 0, il = array.length; i < il; i+=2 ){ - fullLength += array[ i + 1 ]; - } - // create a new array of the same type of the input array - output = new array.constructor( fullLength ); - } - var dataOffset = 0; - for( i = 0, il = array.length; i < il; i+=2 ){ - var value = array[ i ]; // value to be repeated - var length = array[ i + 1 ]; // number of repeats - for( var j = 0; j < length; ++j ){ - output[ dataOffset ] = value; - ++dataOffset; - } - } - return output; -} - - - -/** - * perform delta decoding of the input array - * by iterativly adding the ith element's value to the i+1th - * example: - * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ] - * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ] - * @static - * @param {TypedArray|Array} dataArray - delta encoded input array - * @return {TypedArray|Array} decoded array - */ -function decodeDelta( array, output ){ - var n = array.length; - if( !output ) { output = new array.constructor( n ); } - if( n ) { output[ 0 ] = array[ 0 ]; } - for( var i = 1; i < n; ++i ){ - output[ i ] = array[ i ] + output[ i - 1 ]; - } - return output; -} - - - -/** - * [decodePacking description] - * @param {Int16Array|Int8Array} int16or8 [description] - * @param {Int32Array} output [description] - * @return {Int32Array} [description] - */ -function decodePacking( int16or8, output ){ - var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF; - var lowerLimit = -upperLimit - 1; - var n = int16or8.length; - var i, j; - if( !output ){ - var fullLength = 0; - for( i = 0; i < n; ++i ){ - if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){ - ++fullLength; - } - } - output = new Int32Array( fullLength ); - } - i = 0; - j = 0; - while( i < n ){ - var value = 0; - while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){ - value += int16or8[ i ]; - ++i; - } - value += int16or8[ i ]; - ++i; - output[ j ] = value; - ++j; - } - return output; -} - - - -function decodeDeltaRun( array, output ){ - return decodeDelta( decodeRun( array ), output ); -} - - - -/** - * perform run-length decoding followed (@see decodeRunLength) - * by decoding integers into floats using given divisor (@see decodeIntegerToFloat) - * example: - * array: [ 320, 3, 100, 2 ] - * divisor: 100 - * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ] - * @static - * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format - * @param {Integer} divisor - number to devide the integers to obtain floats - * @param {Float32Array} dataArray - pre-allocated output array - * @return {Float32Array} decoded array - */ -function decodeIntegerRun( intArray, divisor, output ){ - return decodeInteger( - decodeRun( intArray, getInt32View( output ) ), divisor, output - ); -} - - - -function decodeIntegerDelta( intArray, divisor, output ){ - return decodeInteger( - decodeDelta( intArray, getInt32View( output ) ), divisor, output - ); -} - - - -function decodeIntegerPacking( int16or8, divisor, output ){ - return decodeInteger( - decodePacking( int16or8, getInt32View( output ) ), divisor, output - ); -} - -function decodeIntegerDeltaPacking( int16or8, divisor, output ){ - var unpacked = decodePacking( int16or8, getInt32View( output ) ); - return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) ); -} - - - -function decodeBytes( bytes ){ - var dv = getDataView( bytes ); - var type = dv.getInt32( 0 ); - var size = dv.getInt32( 4 ); - var param = bytes.subarray( 8, 12 ); - var bytes = bytes.subarray( 12 ); - return [ type, bytes, size, param ]; -} - -/** - * @file msgpack-decode - * @private - * @author Alexander Rose - */ - -/** - * msgpack decode module. - * @module MsgpackDecode - */ - -/** - * decode binary encoded MessagePack v5 (http://msgpack.org/) data - * @static - * @param {Uint8Array} buffer - binary encoded MessagePack data - * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data - */ -function decodeMsgpack(buffer) { - // Loosely based on - // The MIT License (MIT) - // Copyright (c) 2013 Tim Caswell - // https://github.com/creationix/msgpack-js - var offset = 0; - var dataView = new DataView(buffer.buffer); - - /** - * decode all key-value pairs of a map into an object - * @param {Integer} length - number of key-value pairs - * @return {Object} decoded map - */ - function map(length) { - var value = {}; - for (var i = 0; i < length; i++) { - var key = parse(); - value[key] = parse(); - } - return value; - } - - /** - * decode binary array - * @param {Integer} length - number of elements in the array - * @return {Uint8Array} decoded array - */ - function bin(length) { - var value = buffer.subarray(offset, offset + length); - offset += length; - return value; - } - - /** - * decode string - * @param {Integer} length - number string characters - * @return {String} decoded string - */ - function str(length) { - var array = buffer.subarray(offset, offset + length); - offset += length; - // limit number of arguments to String.fromCharCode to something - // browsers can handle, see http://stackoverflow.com/a/22747272 - var chunkSize = 0xffff; - if(length > chunkSize){ - var c = []; - for(var i = 0; i < array.length; i += chunkSize) { - c.push(String.fromCharCode.apply( - null, array.subarray(i, i + chunkSize) - )); - } - return c.join(""); - }else{ - return String.fromCharCode.apply(null, array); - } - } - - /** - * decode array - * @param {Integer} length - number of array elements - * @return {Array} decoded array - */ - function array(length) { - var value = new Array(length); - for (var i = 0; i < length; i++) { - value[i] = parse(); - } - return value; - } - - /** - * recursively parse the MessagePack data - * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data - */ - function parse() { - var type = buffer[offset]; - var value, length; - // Positive FixInt - if ((type & 0x80) === 0x00) { - offset++; - return type; - } - // FixMap - if ((type & 0xf0) === 0x80) { - length = type & 0x0f; - offset++; - return map(length); - } - // FixArray - if ((type & 0xf0) === 0x90) { - length = type & 0x0f; - offset++; - return array(length); - } - // FixStr - if ((type & 0xe0) === 0xa0) { - length = type & 0x1f; - offset++; - return str(length); - } - // Negative FixInt - if ((type & 0xe0) === 0xe0) { - value = dataView.getInt8(offset); - offset++; - return value; - } - switch (type) { - // nil - case 0xc0: - offset++; - return null; - // 0xc1: (never used, could be employed for padding) - // false - case 0xc2: - offset++; - return false; - // true - case 0xc3: - offset++; - return true; - // bin 8 - case 0xc4: - length = dataView.getUint8(offset + 1); - offset += 2; - return bin(length); - // bin 16 - case 0xc5: - length = dataView.getUint16(offset + 1); - offset += 3; - return bin(length); - // bin 32 - case 0xc6: - length = dataView.getUint32(offset + 1); - offset += 5; - return bin(length); - // // ext 8 - // case 0xc7: - // length = dataView.getUint8(offset + 1); - // extType = dataView.getUint8(offset + 2); - // offset += 3; - // return [extType, bin(length)]; - // // ext 16 - // case 0xc8: - // length = dataView.getUint16(offset + 1); - // extType = dataView.getUint8(offset + 3); - // offset += 4; - // return [extType, bin(length)]; - // // ext 32 - // case 0xc9: - // length = dataView.getUint32(offset + 1); - // extType = dataView.getUint8(offset + 5); - // offset += 6; - // return [extType, bin(length)]; - // float 32 - case 0xca: - value = dataView.getFloat32(offset + 1); - offset += 5; - return value; - // float 64 - case 0xcb: - value = dataView.getFloat64(offset + 1); - offset += 9; - return value; - // uint8 - case 0xcc: - value = buffer[offset + 1]; - offset += 2; - return value; - // uint 16 - case 0xcd: - value = dataView.getUint16(offset + 1); - offset += 3; - return value; - // uint 32 - case 0xce: - value = dataView.getUint32(offset + 1); - offset += 5; - return value; - // // uint64 - // case 0xcf: - // // FIXME not available/representable in JS - // // largest possible int in JS is 2^53 - // // value = dataView.getUint64(offset + 1); - // offset += 9; - // return 0; - // int 8 - case 0xd0: - value = dataView.getInt8(offset + 1); - offset += 2; - return value; - // int 16 - case 0xd1: - value = dataView.getInt16(offset + 1); - offset += 3; - return value; - // int 32 - case 0xd2: - value = dataView.getInt32(offset + 1); - offset += 5; - return value; - // // int 64 - // case 0xd3: - // // FIXME not available/representable in JS - // // largest possible int in JS is 2^53 - // // value = dataView.getInt64(offset + 1); - // offset += 9; - // return 0; - - // // fixext 1 - // case 0xd4: - // extType = dataView.getUint8(offset + 1); - // offset += 2; - // return [extType, bin(1)]; - // // fixext 2 - // case 0xd5: - // extType = dataView.getUint8(offset + 1); - // offset += 2; - // return [extType, bin(2)]; - // // fixext 4 - // case 0xd6: - // extType = dataView.getUint8(offset + 1); - // offset += 2; - // return [extType, bin(4)]; - // // fixext 8 - // case 0xd7: - // extType = dataView.getUint8(offset + 1); - // offset += 2; - // return [extType, bin(8)]; - // // fixext 16 - // case 0xd8: - // extType = dataView.getUint8(offset + 1); - // offset += 2; - // return [extType, bin(16)]; - // str 8 - case 0xd9: - length = dataView.getUint8(offset + 1); - offset += 2; - return str(length); - // str 16 - case 0xda: - length = dataView.getUint16(offset + 1); - offset += 3; - return str(length); - // str 32 - case 0xdb: - length = dataView.getUint32(offset + 1); - offset += 5; - return str(length); - // array 16 - case 0xdc: - length = dataView.getUint16(offset + 1); - offset += 3; - return array(length); - // array 32 - case 0xdd: - length = dataView.getUint32(offset + 1); - offset += 5; - return array(length); - // map 16: - case 0xde: - length = dataView.getUint16(offset + 1); - offset += 3; - return map(length); - // map 32 - case 0xdf: - length = dataView.getUint32(offset + 1); - offset += 5; - return map(length); - } - - throw new Error("Unknown type 0x" + type.toString(16)); - } - - // start the recursive parsing - return parse(); -} - -/** - * Fields shared in encoded and decoded mmtf data objects. - * @typedef {Object} module:MmtfDecode.SharedMmtfData - * @property {String} mmtfVersion - MMTF specification version - * @property {String} mmtfProducer - Program that created the file - * @property {Float[]} [unitCell] - Crystallographic unit cell - * @property {Float} unitCell.0 - x length - * @property {Float} unitCell.1 - y length - * @property {Float} unitCell.2 - z length - * @property {Float} unitCell.3 - alpha angle - * @property {Float} unitCell.4 - beta angle - * @property {Float} unitCell.5 - gamma angle - * @property {String} [spaceGroup] - Hermann-Mauguin symbol - * @property {String} [structureId] - Some reference, e.g. a PDB ID - * @property {String} [title] - Short description - * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format - * @property {String} [releaseDate] - Release date in YYYY-MM-DD format - * @property {String[]} [experimentalMethods] - Structure determination methods - * @property {Float} [resolution] - Resolution in Å - * @property {Float} [rFree] - R-free value - * @property {Float} [rWork] - R-work value - * @property {Integer} numBonds - Number of bonds - * @property {Integer} numAtoms - Number of atoms - * @property {Integer} numGroups - Number of groups (residues) - * @property {Integer} numChains - Number of chains - * @property {Integer} numModels - Number of models - * @property {Integer[]} chainsPerModel - List of number of chains in each model - * @property {Integer[]} groupsPerChain - List of number of groups in each chain - * @property {Entity[]} [entityList] - List of entity objects - * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields - * @property {String} entityList.description - Description of the entity - * @property {String} entityList.type - Name of the entity type - * @property {String} entityList.sequence - One letter code sequence - * @property {Assembly[]} [bioAssemblyList] - List of assembly objects - * @property {Transform[]} bioAssemblyList.transformList - List of transform objects - * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields - * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix - * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices - * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix - * @property {GroupType[]} groupList - List of groupType objects - * @property {Integer[]} groupList.formalChargeList - List of atom formal charges - * @property {String[]} groupList.elementList - List of elements - * @property {String[]} groupList.atomNameList - List of atom names - * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices - * @property {Integer[]} groupList.bondOrderList - List of bond orders - * @property {String} groupList.groupName - The name of the group - * @property {String} groupList.singleLetterCode - The single letter code - * @property {String} groupList.chemCompType - The chemical component type - */ - -/** - * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded. - * @typedef {Object} module:MmtfDecode.EncodedMmtfData - * @mixes module:MmtfDecode.SharedMmtfData - * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices - * @property {Uint8Array} [bondOrderList] - Encoded bond orders - * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1 - * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2 - * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1 - * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2 - * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1 - * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2 - * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1 - * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2 - * @property {Uint8Array} [atomIdList] - Encoded atom ids - * @property {Uint8Array} [altLocList] - Encoded alternate location labels - * @property {Uint8Array} [occupancyList] - Encoded occupancies - * @property {Uint8Array} groupIdList - Encoded group ids - * @property {Uint8Array} groupTypeList - Encoded group types - * @property {Uint8Array} [secStructList] - Encoded secondary structure codes - * @property {Uint8Array} [insCodeList] - Encoded insertion codes - * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids - * @property {Uint8Array} chainIdList - Encoded chain ids - * @property {Uint8Array} [chainNameList] - Encoded chain names - */ - -/** - * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}. - * @typedef {Object} module:MmtfDecode.MmtfData - * @mixes module:MmtfDecode.SharedMmtfData - * @property {Int32Array} [bondAtomList] - List of bonded atom indices - * @property {Uint8Array} [bondOrderList] - List of bond orders - * @property {Float32Array} xCoordList - List of x coordinates in Å - * @property {Float32Array} yCoordList - List of y coordinates in Å - * @property {Float32Array} zCoordList - List of z coordinates in Å - * @property {Float32Array} [bFactorList] - List of B-factors in Å^2 - * @property {Int32Array} [atomIdList] - List of atom ids - * @property {Uint8Array} [altLocList] - List of alternate location labels - * @property {Float32Array} [occupancyList] - List of occupancies - * @property {Int32Array} groupIdList - List of group ids - * @property {Int32Array} groupTypeList - List of group types - * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding - * 0: pi helix, 1: bend, 2: alpha helix, 3: extended, - * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined - * @property {Uint8Array} [insCodeList] - List of insertion codes - * @property {Int32Array} [seuenceIdList] - List of sequence ids - * @property {Uint8Array} chainIdList - List of chain ids - * @property {Uint8Array} [chainNameList] - List of chain names - */ - - -/** - * [performDecoding description] - * @param {Integer} bytes [description] - * @param {Integer} size [description] - * @param {Uint8Array} param [description] - * @return {TypedArray} [description] - */ -function performDecoding( type, bytes, size, param ){ - - switch( type ){ - case 1: - return decodeFloat32( bytes ); - case 2: - return getInt8View( bytes ); - case 3: - return decodeInt16( bytes ); - case 4: - return decodeInt32( bytes ); - case 5: - // var length = decodeInt32( param )[ 0 ]; - return getUint8View( bytes ); // interpret as string array - case 6: - // interpret as char array - return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) ); - case 7: - return decodeRun( decodeInt32( bytes ) ) - case 8: - return decodeDeltaRun( decodeInt32( bytes ) ); - case 9: - return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] ); - case 10: - return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] ); - case 11: - return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] ); - case 12: - return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] ); - case 13: - return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] ); - case 14: - return decodePacking( decodeInt16( bytes ) ); - case 15: - return decodePacking( getInt8View( bytes ) ); - } - -} - -/** - * Decode MMTF fields - * @static - * @param {Object} inputDict - encoded MMTF data - * @param {Object} [params] - decoding parameters - * @param {String[]} params.ignoreFields - names of optional fields not to decode - * @return {module:MmtfDecode.MmtfData} mmtfData - */ -function decodeMmtf( inputDict, params ){ - - params = params || {}; - var ignoreFields = params.ignoreFields; - var outputDict = {}; - - AllFields.forEach( function( name ){ - var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false; - var data = inputDict[ name ]; - if( !ignore && data !== undefined ){ - if( data instanceof Uint8Array ){ - outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) ); - }else{ - outputDict[ name ] = data; - } - } - } ); - - return outputDict; - -} - -/** - * @file Mmtf Parser - * @author Alexander Rose - * @private - */ -var SstrucMap = { - '0': 'i'.charCodeAt(0), - '1': 's'.charCodeAt(0), - '2': 'h'.charCodeAt(0), - '3': 'e'.charCodeAt(0), - '4': 'g'.charCodeAt(0), - '5': 'b'.charCodeAt(0), - '6': 't'.charCodeAt(0), - '7': 'l'.charCodeAt(0), - '-1': ''.charCodeAt(0) // NA -}; -var MmtfParser = /*@__PURE__*/(function (StructureParser$$1) { - function MmtfParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) MmtfParser.__proto__ = StructureParser$$1; - MmtfParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - MmtfParser.prototype.constructor = MmtfParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'mmtf'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - MmtfParser.prototype._parse = function _parse () { - // https://github.com/rcsb/mmtf - if (Debug) - { Log.time('MmtfParser._parse ' + this.name); } - var i, il, j, jl, groupData; - var s = this.structure; - var sd = decodeMmtf(decodeMsgpack(this.streamer.data)); - // structure header - var headerFields = [ - 'depositionDate', 'releaseDate', 'resolution', - 'rFree', 'rWork', 'experimentalMethods' - ]; - headerFields.forEach(function (name) { - if (sd[name] !== undefined) { - s.header[name] = sd[name]; - } - }); - var numBonds, numAtoms, numGroups, numChains, numModels; - var chainsPerModel; - s.id = sd.structureId; - s.title = sd.title; - s.atomStore.addField('formalCharge', 1, 'int8'); - if (this.firstModelOnly || this.asTrajectory) { - numModels = 1; - numChains = sd.chainsPerModel[0]; - numGroups = 0; - for (i = 0, il = numChains; i < il; ++i) { - numGroups += sd.groupsPerChain[i]; - } - numAtoms = 0; - for (i = 0, il = numGroups; i < il; ++i) { - groupData = sd.groupList[sd.groupTypeList[i]]; - numAtoms += groupData.atomNameList.length; - } - numBonds = sd.numBonds; - chainsPerModel = [numChains]; - } - else { - numBonds = sd.numBonds; - numAtoms = sd.numAtoms; - numGroups = sd.numGroups; - numChains = sd.numChains; - numModels = sd.numModels; - chainsPerModel = sd.chainsPerModel; - } - numBonds += numGroups; // add numGroups to have space for polymer bonds - // - if (this.asTrajectory) { - for (i = 0, il = sd.numModels; i < il; ++i) { - var frame = new Float32Array(numAtoms * 3); - var frameAtomOffset = numAtoms * i; - for (j = 0; j < numAtoms; ++j) { - var j3 = j * 3; - var offset = j + frameAtomOffset; - frame[j3] = sd.xCoordList[offset]; - frame[j3 + 1] = sd.yCoordList[offset]; - frame[j3 + 2] = sd.zCoordList[offset]; - } - s.frames.push(frame); - } - } - // bondStore - var bAtomIndex1 = new Uint32Array(numBonds); - var bAtomIndex2 = new Uint32Array(numBonds); - var bBondOrder = new Uint8Array(numBonds); - var aGroupIndex = new Uint32Array(numAtoms); - var aFormalCharge = new Int8Array(numAtoms); - var gChainIndex = new Uint32Array(numGroups); - var gAtomOffset = new Uint32Array(numGroups); - var gAtomCount = new Uint16Array(numGroups); - var cModelIndex = new Uint16Array(numChains); - var cGroupOffset = new Uint32Array(numChains); - var cGroupCount = new Uint32Array(numChains); - var mChainOffset = new Uint32Array(numModels); - var mChainCount = new Uint32Array(numModels); - // set-up model-chain relations - var chainOffset = 0; - for (i = 0, il = numModels; i < il; ++i) { - var modelChainCount = chainsPerModel[i]; - mChainOffset[i] = chainOffset; - mChainCount[i] = modelChainCount; - for (j = 0; j < modelChainCount; ++j) { - cModelIndex[j + chainOffset] = i; - } - chainOffset += modelChainCount; - } - // set-up chain-residue relations - var groupsPerChain = sd.groupsPerChain; - var groupOffset = 0; - for (i = 0, il = numChains; i < il; ++i) { - var chainGroupCount = groupsPerChain[i]; - cGroupOffset[i] = groupOffset; - cGroupCount[i] = chainGroupCount; - for (j = 0; j < chainGroupCount; ++j) { - gChainIndex[j + groupOffset] = i; - } - groupOffset += chainGroupCount; - } - /// /// - // get data from group map - var atomOffset = 0; - var bondOffset = 0; - for (i = 0, il = numGroups; i < il; ++i) { - groupData = sd.groupList[sd.groupTypeList[i]]; - var groupAtomCount = groupData.atomNameList.length; - var groupFormalChargeList = groupData.formalChargeList; - var groupBondAtomList = groupData.bondAtomList; - var groupBondOrderList = groupData.bondOrderList; - for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) { - bAtomIndex1[bondOffset] = atomOffset + groupBondAtomList[j * 2]; - bAtomIndex2[bondOffset] = atomOffset + groupBondAtomList[j * 2 + 1]; - bBondOrder[bondOffset] = groupBondOrderList[j]; - bondOffset += 1; - } - // - gAtomOffset[i] = atomOffset; - gAtomCount[i] = groupAtomCount; - for (j = 0; j < groupAtomCount; ++j) { - aGroupIndex[atomOffset] = i; - aFormalCharge[atomOffset] = groupFormalChargeList[j]; - atomOffset += 1; - } - } - // extra bonds - var bondAtomList = sd.bondAtomList; - if (bondAtomList) { - if (sd.bondOrderList) { - bBondOrder.set(sd.bondOrderList, bondOffset); - } - for (i = 0, il = bondAtomList.length; i < il; i += 2) { - var atomIndex1 = bondAtomList[i]; - var atomIndex2 = bondAtomList[i + 1]; - if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) { - bAtomIndex1[bondOffset] = atomIndex1; - bAtomIndex2[bondOffset] = atomIndex2; - bondOffset += 1; - } - } - } - // - s.bondStore.length = bBondOrder.length; - s.bondStore.count = bondOffset; - s.bondStore.atomIndex1 = bAtomIndex1; - s.bondStore.atomIndex2 = bAtomIndex2; - s.bondStore.bondOrder = bBondOrder; - s.atomStore.length = numAtoms; - s.atomStore.count = numAtoms; - s.atomStore.residueIndex = aGroupIndex; - s.atomStore.atomTypeId = new Uint16Array(numAtoms); - s.atomStore.x = sd.xCoordList.subarray(0, numAtoms); - s.atomStore.y = sd.yCoordList.subarray(0, numAtoms); - s.atomStore.z = sd.zCoordList.subarray(0, numAtoms); - s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms); - s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms); - s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms); - s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms); - s.atomStore.formalCharge = aFormalCharge; - s.residueStore.length = numGroups; - s.residueStore.count = numGroups; - s.residueStore.chainIndex = gChainIndex; - s.residueStore.residueTypeId = sd.groupTypeList; - s.residueStore.atomOffset = gAtomOffset; - s.residueStore.atomCount = gAtomCount; - s.residueStore.resno = sd.groupIdList.subarray(0, numGroups); - s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups); - s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups); - s.chainStore.length = numChains; - s.chainStore.count = numChains; - s.chainStore.entityIndex = new Uint16Array(numChains); - s.chainStore.modelIndex = cModelIndex; - s.chainStore.residueOffset = cGroupOffset; - s.chainStore.residueCount = cGroupCount; - s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4); - s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4); - s.modelStore.length = numModels; - s.modelStore.count = numModels; - s.modelStore.chainOffset = mChainOffset; - s.modelStore.chainCount = mChainCount; - // - var groupTypeDict = {}; - for (i = 0, il = sd.groupList.length; i < il; ++i) { - var groupType = sd.groupList[i]; - var atomTypeIdList = []; - for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) { - var element = groupType.elementList[j].toUpperCase(); - var atomname = groupType.atomNameList[j]; - atomTypeIdList.push(s.atomMap.add(atomname, element)); - } - var chemCompType = groupType.chemCompType.toUpperCase(); - var hetFlag = ChemCompHetero.includes(chemCompType); - var numGroupBonds = groupType.bondOrderList.length; - var atomIndices1 = new Array(numGroupBonds); - var atomIndices2 = new Array(numGroupBonds); - for (j = 0; j < numGroupBonds; ++j) { - atomIndices1[j] = groupType.bondAtomList[j * 2]; - atomIndices2[j] = groupType.bondAtomList[j * 2 + 1]; - } - var bonds = { - atomIndices1: atomIndices1, - atomIndices2: atomIndices2, - bondOrders: groupType.bondOrderList - }; - groupTypeDict[i] = s.residueMap.add(groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds); - } - for (i = 0, il = numGroups; i < il; ++i) { - s.residueStore.residueTypeId[i] = groupTypeDict[s.residueStore.residueTypeId[i]]; - } - for (i = 0, il = s.atomStore.count; i < il; ++i) { - var residueIndex = s.atomStore.residueIndex[i]; - var residueType = s.residueMap.list[s.residueStore.residueTypeId[residueIndex]]; - var resAtomOffset = s.residueStore.atomOffset[residueIndex]; - s.atomStore.atomTypeId[i] = residueType.atomTypeIdList[i - resAtomOffset]; - } - if (sd.secStructList) { - var secStructLength = sd.secStructList.length; - for (i = 0, il = s.residueStore.count; i < il; ++i) { - // with ( i % secStructLength ) secStruct entries are reused - var sstruc = SstrucMap[s.residueStore.sstruc[i % secStructLength]]; - if (sstruc !== undefined) - { s.residueStore.sstruc[i] = sstruc; } - } - } - // - if (sd.entityList) { - sd.entityList.forEach(function (e, i) { - s.entityList[i] = new Entity(s, i, e.description, e.type, e.chainIndexList); - }); - } - if (sd.bioAssemblyList) { - sd.bioAssemblyList.forEach(function (_assembly, k) { - var id = k + 1; - var assembly = new Assembly('' + id); - s.biomolDict['BU' + id] = assembly; - var chainToPart = {}; - _assembly.transformList.forEach(function (_transform) { - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().fromArray(_transform.matrix).transpose(); - var chainList = _transform.chainIndexList.map(function (chainIndex) { - var chainname = ''; - for (var k = 0; k < 4; ++k) { - var code = sd.chainNameList[chainIndex * 4 + k]; - if (code) { - chainname += String.fromCharCode(code); - } - else { - break; - } - } - return chainname; - }); - var part = chainToPart[chainList.toString()]; - if (part) { - part.matrixList.push(matrix); - } - else { - chainToPart[chainList.toString()] = assembly.addPart([matrix], chainList); - } - }); - }); - } - if (sd.ncsOperatorList) { - var ncsName = 'NCS'; - var ncsAssembly = new Assembly(ncsName); - var ncsPart = ncsAssembly.addPart(); - sd.ncsOperatorList.forEach(function (_operator) { - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().fromArray(_operator).transpose(); - ncsPart.matrixList.push(matrix); - }); - if (ncsPart.matrixList.length > 0) { - s.biomolDict[ncsName] = ncsAssembly; - } - } - var uc = sd.unitCell; - if (uc && Array.isArray(uc) && uc[0]) { - s.unitcell = new Unitcell({ - a: uc[0], - b: uc[1], - c: uc[2], - alpha: uc[3], - beta: uc[4], - gamma: uc[5], - spacegroup: sd.spaceGroup - }); - } - else { - s.unitcell = undefined; - } - // calculate backbone bonds - calculateBondsBetween(s, true); - // calculate rung bonds - calculateBondsWithin(s, true); - s.finalizeAtoms(); - s.finalizeBonds(); - buildUnitcellAssembly(s); - if (Debug) - { Log.timeEnd('MmtfParser._parse ' + this.name); } - }; - - Object.defineProperties( MmtfParser.prototype, prototypeAccessors ); - - return MmtfParser; -}(StructureParser)); -ParserRegistry$1.add('mmtf', MmtfParser); - -/** - * @file Mol2 Parser - * @author Alexander Rose - * @private - */ -var reWhitespace$2 = /\s+/; -var bondTypes = { - '1': 1, - '2': 2, - '3': 3, - 'am': 1, - 'ar': 1, - 'du': 1, - 'un': 1, - 'nc': 0 // not connected -}; -var Mol2Parser = /*@__PURE__*/(function (StructureParser$$1) { - function Mol2Parser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) Mol2Parser.__proto__ = StructureParser$$1; - Mol2Parser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - Mol2Parser.prototype.constructor = Mol2Parser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'mol2'; }; - Mol2Parser.prototype._parse = function _parse () { - // http://paulbourke.net/dataformats/mol2/ - if (Debug) - { Log.time('Mol2Parser._parse ' + this.name); } - var s = this.structure; - var sb = this.structureBuilder; - var firstModelOnly = this.firstModelOnly; - var asTrajectory = this.asTrajectory; - var frames = s.frames; - var doFrames = false; - var currentFrame, currentCoord; - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.resize(Math.round(this.streamer.data.length / 60)); - atomStore.addField('partialCharge', 1, 'float32'); - var idx = 0; - var moleculeLineNo = 0; - var modelAtomIdxStart = 0; - var modelIdx = -1; - var numAtoms = 0; - var currentRecordType = 0; - var moleculeRecordType = 1; - var atomRecordType = 2; - var bondRecordType = 3; - var ap1 = s.getAtomProxy(); - var ap2 = s.getAtomProxy(); - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i].trim(); - if (line === '' || line[0] === '#') - { continue; } - if (line[0] === '@') { - if (line === '@MOLECULE') { - currentRecordType = moleculeRecordType; - moleculeLineNo = 0; - ++modelIdx; - } - else if (line === '@ATOM') { - currentRecordType = atomRecordType; - modelAtomIdxStart = atomStore.count; - if (asTrajectory) { - currentCoord = 0; - currentFrame = new Float32Array(numAtoms * 3); - frames.push(currentFrame); - if (modelIdx > 0) - { doFrames = true; } - } - } - else if (line === '@BOND') { - currentRecordType = bondRecordType; - } - else { - currentRecordType = 0; - } - } - else if (currentRecordType === moleculeRecordType) { - if (moleculeLineNo === 0) { - s.title = line; - s.id = line; - } - else if (moleculeLineNo === 1) { - var ls = line.split(reWhitespace$2); - numAtoms = parseInt(ls[0]); - // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]] - } - ++moleculeLineNo; - } - else if (currentRecordType === atomRecordType) { - var ls$1 = line.split(reWhitespace$2); - if (firstModelOnly && modelIdx > 0) - { continue; } - var x = parseFloat(ls$1[2]); - var y = parseFloat(ls$1[3]); - var z = parseFloat(ls$1[4]); - if (asTrajectory) { - var j = currentCoord * 3; - currentFrame[j + 0] = x; - currentFrame[j + 1] = y; - currentFrame[j + 2] = z; - currentCoord += 1; - if (doFrames) - { continue; } - } - var serial = ls$1[0]; - var atomname = ls$1[1]; - var element = ls$1[5].split('.')[0]; - var resno = ls$1[6] ? parseInt(ls$1[6]) : 1; - var resname = ls$1[7] ? ls$1[7] : ''; - var partialCharge = ls$1[8] ? parseFloat(ls$1[8]) : 0.0; - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(atomname, element); - atomStore.x[idx] = x; - atomStore.y[idx] = y; - atomStore.z[idx] = z; - atomStore.serial[idx] = serial; - atomStore.partialCharge[idx] = partialCharge; - sb.addAtom(modelIdx, '', '', resname, resno, 1); - idx += 1; - } - else if (currentRecordType === bondRecordType) { - if (firstModelOnly && modelIdx > 0) - { continue; } - if (asTrajectory && modelIdx > 0) - { continue; } - var ls$2 = line.split(reWhitespace$2); - // ls[ 0 ] is bond id - ap1.index = parseInt(ls$2[1]) - 1 + modelAtomIdxStart; - ap2.index = parseInt(ls$2[2]) - 1 + modelAtomIdxStart; - var order = bondTypes[ls$2[3]]; - s.bondStore.addBond(ap1, ap2, order); - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - sb.finalize(); - s.finalizeAtoms(); - calculateChainnames(s); - calculateBondsWithin(s, true); - calculateBondsBetween(s, true); - s.finalizeBonds(); - assignResidueTypeBonds(s); - calculateSecondaryStructure(s); - if (Debug) - { Log.timeEnd('Mol2Parser._parse ' + this.name); } - }; - - Object.defineProperties( Mol2Parser.prototype, prototypeAccessors ); - - return Mol2Parser; -}(StructureParser)); -ParserRegistry$1.add('mol2', Mol2Parser); - -/** - * @file Pdbqt Parser - * @author Alexander Rose - * @private - */ -// autodock variant of PDB format with -// - atom partial charges (empty column in pdb format) -// - atom types (bfactor column in pdb format) -// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file -var PdbqtParser = /*@__PURE__*/(function (PdbParser$$1) { - function PdbqtParser () { - PdbParser$$1.apply(this, arguments); - } - - if ( PdbParser$$1 ) PdbqtParser.__proto__ = PdbParser$$1; - PdbqtParser.prototype = Object.create( PdbParser$$1 && PdbParser$$1.prototype ); - PdbqtParser.prototype.constructor = PdbqtParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'pdbqt'; }; - - Object.defineProperties( PdbqtParser.prototype, prototypeAccessors ); - - return PdbqtParser; -}(PdbParser)); -ParserRegistry$1.add('pdbqt', PdbqtParser); - -/** - * @file Pqr Parser - * @author Alexander Rose - * @private - */ -// http://www.poissonboltzmann.org/docs/file-format-info/ -var PqrParser = /*@__PURE__*/(function (PdbParser$$1) { - function PqrParser () { - PdbParser$$1.apply(this, arguments); - } - - if ( PdbParser$$1 ) PqrParser.__proto__ = PdbParser$$1; - PqrParser.prototype = Object.create( PdbParser$$1 && PdbParser$$1.prototype ); - PqrParser.prototype.constructor = PqrParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'pqr'; }; - - Object.defineProperties( PqrParser.prototype, prototypeAccessors ); - - return PqrParser; -}(PdbParser)); -ParserRegistry$1.add('pqr', PqrParser); - -/** - * @file Sdf Parser - * @author Alexander Rose - * @private - */ -var reItem = /> +<(.+)>/; -var SdfParser = /*@__PURE__*/(function (StructureParser$$1) { - function SdfParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) SdfParser.__proto__ = StructureParser$$1; - SdfParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - SdfParser.prototype.constructor = SdfParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'sdf'; }; - SdfParser.prototype._parse = function _parse () { - // https://en.wikipedia.org/wiki/Chemical_table_file#SDF - // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip - if (Debug) - { Log.time('SdfParser._parse ' + this.name); } - var s = this.structure; - var sb = this.structureBuilder; - var firstModelOnly = this.firstModelOnly; - var asTrajectory = this.asTrajectory; - var headerLines = this.streamer.peekLines(2); - s.id = headerLines[0].trim(); - s.title = headerLines[1].trim(); - var frames = s.frames; - var doFrames = false; - var currentFrame, currentCoord; - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.resize(Math.round(this.streamer.data.length / 50)); - atomStore.addField('formalCharge', 1, 'int8'); - var ap1 = s.getAtomProxy(); - var ap2 = s.getAtomProxy(); - var idx = 0; - var lineNo = 0; - var modelIdx = 0; - var modelAtomIdxStart = 0; - var sdfData = []; - var currentItem = false; - var currentData = {}; - var mItem; - s.extraData.sdf = sdfData; - var atomCount, bondCount, atomStart, atomEnd, bondStart, bondEnd; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i]; - if (line.substr(0, 4) === '$$$$') { - lineNo = -1; - ++modelIdx; - modelAtomIdxStart = atomStore.count; - sdfData.push(currentData); - currentData = {}; - currentItem = false; - } - else if (lineNo === 3) { - atomCount = parseInt(line.substr(0, 3)); - bondCount = parseInt(line.substr(3, 3)); - atomStart = 4; - atomEnd = atomStart + atomCount; - bondStart = atomEnd; - bondEnd = bondStart + bondCount; - if (asTrajectory) { - currentCoord = 0; - currentFrame = new Float32Array(atomCount * 3); - frames.push(currentFrame); - if (modelIdx > 0) - { doFrames = true; } - } - } - else if (lineNo >= atomStart && lineNo < atomEnd) { - if (firstModelOnly && modelIdx > 0) - { continue; } - var x = parseFloat(line.substr(0, 10)); - var y = parseFloat(line.substr(10, 10)); - var z = parseFloat(line.substr(20, 10)); - if (asTrajectory) { - var j = currentCoord * 3; - currentFrame[j + 0] = x; - currentFrame[j + 1] = y; - currentFrame[j + 2] = z; - currentCoord += 1; - if (doFrames) - { continue; } - } - var element = line.substr(31, 3).trim(); - var atomname = element + (idx + 1); - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(atomname, element); - atomStore.x[idx] = x; - atomStore.y[idx] = y; - atomStore.z[idx] = z; - atomStore.serial[idx] = idx; - atomStore.formalCharge[idx] = 0; - sb.addAtom(modelIdx, '', '', 'HET', 1, 1); - idx += 1; - } - else if (lineNo >= bondStart && lineNo < bondEnd) { - if (firstModelOnly && modelIdx > 0) - { continue; } - if (asTrajectory && modelIdx > 0) - { continue; } - ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart; - ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart; - var order = parseInt(line.substr(6, 3)); - s.bondStore.addBond(ap1, ap2, order); - } - else if (line.match(/M {2}CHG/)) { - var chargeCount = parseInt(line.substr(6, 3)); - for (var ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) { - var aToken = parseInt(line.substr(coffset, 3)); - var atomIdx = aToken - 1 + modelAtomIdxStart; - var cToken = parseInt(line.substr(coffset + 4, 3)); - atomStore.formalCharge[atomIdx] = cToken; - } - // eslint-disable-next-line no-cond-assign - } - else if (mItem = line.match(reItem)) { - currentItem = mItem[1]; - currentData[currentItem] = []; - } - else if (currentItem !== false && line) { - currentData[currentItem].push(line); - } - ++lineNo; - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - sb.finalize(); - s.finalizeAtoms(); - s.finalizeBonds(); - assignResidueTypeBonds(s); - if (Debug) - { Log.timeEnd('SdfParser._parse ' + this.name); } - }; - SdfParser.prototype._postProcess = function _postProcess () { - assignResidueTypeBonds(this.structure); - }; - - Object.defineProperties( SdfParser.prototype, prototypeAccessors ); - - return SdfParser; -}(StructureParser)); -ParserRegistry$1.add('sdf', SdfParser); -ParserRegistry$1.add('sd', SdfParser); -ParserRegistry$1.add('mol', SdfParser); - -/** - * @file Prmtop Parser - * @author Alexander Rose - * @private - */ -var amberChargeUnitFactor = 18.2223; -function parseIntSubstr(line, start, length) { - return parseInt(line.substr(start, length).trim()); -} -var PrmtopParser = /*@__PURE__*/(function (StructureParser$$1) { - function PrmtopParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) PrmtopParser.__proto__ = StructureParser$$1; - PrmtopParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - PrmtopParser.prototype.constructor = PrmtopParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'prmtop'; }; - PrmtopParser.prototype._parse = function _parse () { - // http://ambermd.org/prmtop.pdf - // http://ambermd.org/formats.html#topology - if (Debug) - { Log.time('PrmtopParser._parse ' + this.name); } - var s = this.structure; - var sb = this.structureBuilder; - // - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.addField('partialCharge', 1, 'float32'); - atomStore.addField('radius', 1, 'float32'); - var title = []; - var pointersDict = {}; - var pointers = [ - 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA', - 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES', - 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA', - 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER', - 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP', - 'NUMEXTRA', 'NCOPY' - ]; - pointers.forEach(function (name) { pointersDict[name] = 0; }); - var atomNames; - var charges; - var radii; - var bAtomIndex1; - var bAtomIndex2; - var bBondOrder = new Uint8Array(0); - var residueLabels; - var residuePointers; - var mode; - // let currentFormat - var curIdx; - var bondIdx; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i]; - var lt = line.trim(); - if (!lt) { - continue; - } - else if (line.startsWith('%FORMAT')) ; - else if (line.startsWith('%FLAG')) { - var flag = line.substr(5).trim(); - curIdx = 0; - if (flag === 'TITLE') { - mode = 0 /* Title */; - } - else if (flag === 'POINTERS') { - mode = 1 /* Pointers */; - } - else if (flag === 'ATOM_NAME') { - mode = 2 /* AtomName */; - } - else if (flag === 'CHARGE') { - mode = 3 /* Charge */; - } - else if (flag === 'MASS') { - mode = 4 /* Mass */; - } - else if (flag === 'RESIDUE_LABEL') { - mode = 5 /* ResidueLabel */; - } - else if (flag === 'RESIDUE_POINTER') { - mode = 6 /* ResiduePointer */; - } - else if (flag === 'BONDS_INC_HYDROGEN') { - bondIdx = 0; - mode = 7 /* BondsIncHydrogen */; - } - else if (flag === 'BONDS_WITHOUT_HYDROGEN') { - bondIdx = pointersDict['NBONH']; - mode = 8 /* BondsWithoutHydrogen */; - } - else if (flag === 'RADII') { - mode = 9 /* Radii */; - } - else { - mode = undefined; - } - } - else if (mode === 0 /* Title */) { - title.push(lt); - } - else if (mode === 1 /* Pointers */) { - var n = Math.min(curIdx + 10, 32); - for (var i$1 = 0; curIdx < n; ++i$1, ++curIdx) { - pointersDict[pointers[curIdx]] = parseInt(line.substr(i$1 * 8, 8).trim()); - } - atomNames = new Array(pointersDict.NATOM); - charges = new Float32Array(pointersDict.NATOM); - radii = new Float32Array(pointersDict.NATOM); - atomStore.resize(pointersDict.NATOM); - var bondCount = pointersDict.NBONH + pointersDict.MBONA; - bAtomIndex1 = new Uint32Array(bondCount); - bAtomIndex2 = new Uint32Array(bondCount); - bBondOrder = new Uint8Array(bondCount); - residueLabels = new Array(pointersDict.NRES); - residuePointers = new Uint32Array(pointersDict.NRES); - } - else if (mode === 2 /* AtomName */) { - var n$1 = Math.min(curIdx + 20, pointersDict.NATOM); - for (var i$2 = 0; curIdx < n$1; ++i$2, ++curIdx) { - atomNames[curIdx] = line.substr(i$2 * 4, 4).trim(); - } - } - else if (mode === 3 /* Charge */) { - var n$2 = Math.min(curIdx + 5, pointersDict.NATOM); - for (var i$3 = 0; curIdx < n$2; ++i$3, ++curIdx) { - charges[curIdx] = parseFloat(line.substr(i$3 * 16, 16)) / amberChargeUnitFactor; - } - } - else if (mode === 4 /* Mass */) ; - else if (mode === 5 /* ResidueLabel */) { - var n$3 = Math.min(curIdx + 20, pointersDict.NRES); - for (var i$4 = 0; curIdx < n$3; ++i$4, ++curIdx) { - residueLabels[curIdx] = line.substr(i$4 * 4, 4).trim(); - } - } - else if (mode === 6 /* ResiduePointer */) { - var n$4 = Math.min(curIdx + 10, pointersDict.NRES); - for (var i$5 = 0; curIdx < n$4; ++i$5, ++curIdx) { - residuePointers[curIdx] = parseIntSubstr(line, i$5 * 8, 8); - } - } - else if (mode === 7 /* BondsIncHydrogen */) { - var n$5 = Math.min(curIdx + 10, pointersDict.NBONH * 3); - for (var i$6 = 0; curIdx < n$5; ++i$6, ++curIdx) { - var r = curIdx % 3; - if (r === 0) { - bAtomIndex1[bondIdx] = parseIntSubstr(line, i$6 * 8, 8) / 3; - } - if (r === 1) { - bAtomIndex2[bondIdx] = parseIntSubstr(line, i$6 * 8, 8) / 3; - bBondOrder[bondIdx] = 1; - ++bondIdx; - } - } - } - else if (mode === 8 /* BondsWithoutHydrogen */) { - var n$6 = Math.min(curIdx + 10, pointersDict.MBONA * 3); - for (var i$7 = 0; curIdx < n$6; ++i$7, ++curIdx) { - var r$1 = curIdx % 3; - if (r$1 === 0) { - bAtomIndex1[bondIdx] = parseIntSubstr(line, i$7 * 8, 8) / 3; - } - if (r$1 === 1) { - bAtomIndex2[bondIdx] = parseIntSubstr(line, i$7 * 8, 8) / 3; - bBondOrder[bondIdx] = 1; - ++bondIdx; - } - } - } - else if (mode === 9 /* Radii */) { - var n$7 = Math.min(curIdx + 5, pointersDict.NATOM); - for (var i$8 = 0; curIdx < n$7; ++i$8, ++curIdx) { - radii[curIdx] = parseFloat(line.substr(i$8 * 16, 16)); - } - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - s.title = title.join(' '); - var atomCount = pointersDict.NATOM; - var curResIdx = 0; - var curResname = residueLabels[0]; - var curResno = 1; - for (var i = 0; i < atomCount; ++i) { - if (i + 1 === residuePointers[curResIdx + 1]) { - ++curResIdx; - curResname = residueLabels[curResIdx]; - curResno = curResIdx + 1; - } - atomStore.atomTypeId[i] = atomMap.add(atomNames[i]); - atomStore.serial[i] = i + 1; - sb.addAtom(0, '', '', curResname, curResno); - } - atomStore.partialCharge.set(charges); - atomStore.radius.set(radii); - s.bondStore.length = bBondOrder.length; - s.bondStore.count = bBondOrder.length; - s.bondStore.atomIndex1 = bAtomIndex1; - s.bondStore.atomIndex2 = bAtomIndex2; - s.bondStore.bondOrder = bBondOrder; - sb.finalize(); - s.finalizeAtoms(); - s.finalizeBonds(); - calculateBondsWithin(s, true); - calculateBondsBetween(s, true, true); - calculateChainnames(s, true); - assignResidueTypeBonds(s); - if (Debug) - { Log.timeEnd('PrmtopParser._parse ' + this.name); } - }; - - Object.defineProperties( PrmtopParser.prototype, prototypeAccessors ); - - return PrmtopParser; -}(StructureParser)); -ParserRegistry$1.add('prmtop', PrmtopParser); -ParserRegistry$1.add('parm7', PrmtopParser); - -/** - * @file Psf Parser - * @author Alexander Rose - * @private - */ -var TitleMode = 1; -var AtomMode = 2; -var BondMode = 3; -var AngleMode = 4; -var DihedralMode = 5; -var ImproperMode = 6; -var reWhitespace$3 = /\s+/; -var reTitle = /(^\*|REMARK)*/; -var PsfParser = /*@__PURE__*/(function (StructureParser$$1) { - function PsfParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) PsfParser.__proto__ = StructureParser$$1; - PsfParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - PsfParser.prototype.constructor = PsfParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'psf'; }; - PsfParser.prototype._parse = function _parse () { - // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html - if (Debug) - { Log.time('PsfParser._parse ' + this.name); } - var s = this.structure; - var sb = this.structureBuilder; - // - var atomMap = s.atomMap; - var atomStore = s.atomStore; - atomStore.addField('partialCharge', 1, 'float32'); - var title = []; - var mode; - var chainid; - var lastSegid; - var idx = 0; - var chainIdx = 0; - var bondIdx = 0; - var bAtomIndex1, bAtomIndex2, bBondOrder; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i].trim(); - if (!line) { - mode = undefined; - continue; - } - if (mode === AtomMode) { - var ls = line.split(reWhitespace$3); - var serial = parseInt(ls[0]); - var segid = ls[1]; - var resno = parseInt(ls[2]); - var resname = ls[3]; - var atomname = ls[4]; - var charge = parseFloat(ls[6]); - if (segid !== lastSegid) { - chainid = getChainname(chainIdx); - ++chainIdx; - } - atomStore.growIfFull(); - atomStore.atomTypeId[idx] = atomMap.add(atomname); - atomStore.serial[idx] = serial; - atomStore.partialCharge[idx] = charge; - sb.addAtom(0, chainid, chainid, resname, resno); - idx += 1; - lastSegid = segid; - } - else if (mode === BondMode) { - var ls$1 = line.split(reWhitespace$3); - for (var j = 0, m = ls$1.length; j < m; j += 2) { - bAtomIndex1[bondIdx] = parseInt(ls$1[j]) - 1; - bAtomIndex2[bondIdx] = parseInt(ls$1[j + 1]) - 1; - bBondOrder[bondIdx] = 1; - bondIdx += 1; - } - } - else if (mode === TitleMode) { - title.push(line.replace(reTitle, '').trim()); - } - else if (mode === AngleMode) ; - else if (mode === DihedralMode) ; - else if (mode === ImproperMode) ; - else if (line.includes('!NATOM')) { - mode = AtomMode; - var numAtoms = parseInt(line.split(reWhitespace$3)[0]); - atomStore.resize(numAtoms); - } - else if (line.includes('!NBOND')) { - mode = BondMode; - var numBonds = parseInt(line.split(reWhitespace$3)[0]); - bAtomIndex1 = new Uint32Array(numBonds); - bAtomIndex2 = new Uint32Array(numBonds); - bBondOrder = new Uint8Array(numBonds); - } - else if (line.includes('!NTITLE')) { - mode = TitleMode; - } - else if (line.includes('!NTHETA')) { - mode = AngleMode; - } - else if (line.includes('!NPHI')) { - mode = DihedralMode; - } - else if (line.includes('!NIMPHI')) { - mode = ImproperMode; - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - s.title = title.join(' '); - s.bondStore.length = bBondOrder.length; - s.bondStore.count = bondIdx; - s.bondStore.atomIndex1 = bAtomIndex1; - s.bondStore.atomIndex2 = bAtomIndex2; - s.bondStore.bondOrder = bBondOrder; - sb.finalize(); - s.finalizeAtoms(); - s.finalizeBonds(); - calculateBondsWithin(s, true); - calculateBondsBetween(s, true, true); - assignResidueTypeBonds(s); - if (Debug) - { Log.timeEnd('PsfParser._parse ' + this.name); } - }; - - Object.defineProperties( PsfParser.prototype, prototypeAccessors ); - - return PsfParser; -}(StructureParser)); -ParserRegistry$1.add('psf', PsfParser); - -/** - * @file Top Parser - * @author Alexander Rose - * @private - */ -var reField = /\[ (.+) \]/; -var reWhitespace$4 = /\s+/; -var TopParser = /*@__PURE__*/(function (StructureParser$$1) { - function TopParser () { - StructureParser$$1.apply(this, arguments); - } - - if ( StructureParser$$1 ) TopParser.__proto__ = StructureParser$$1; - TopParser.prototype = Object.create( StructureParser$$1 && StructureParser$$1.prototype ); - TopParser.prototype.constructor = TopParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'top'; }; - TopParser.prototype._parse = function _parse () { - // http://manual.gromacs.org/online/top.html - if (Debug) - { Log.time('TopParser._parse ' + this.name); } - var s = this.structure; - var sb = this.structureBuilder; - // - var atomMap = s.atomMap; - var bondStore = s.bondStore; - var atomStore = s.atomStore; - atomStore.addField('partialCharge', 1, 'float32'); - var molecules = []; - var moleculetypeDict = {}; - var currentMoleculetype; - var mode; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i]; - var lt = line.trim(); - if (!lt || lt[0] === '*' || lt[0] === ';') { - continue; - } - if (lt.startsWith('#include')) { - throw new Error('TopParser: #include statements not allowed'); - } - var fieldMatch = line.match(reField); - if (fieldMatch !== null) { - var name = fieldMatch[1]; - if (name === 'moleculetype') { - mode = 2 /* Moleculetype */; - currentMoleculetype = { - atoms: [], - bonds: [] - }; - } - else if (name === 'atoms') { - mode = 3 /* Atoms */; - } - else if (name === 'bonds') { - mode = 4 /* Bonds */; - } - else if (name === 'system') { - mode = 0 /* System */; - } - else if (name === 'molecules') { - mode = 1 /* Molecules */; - } - else { - mode = undefined; - } - continue; - } - var cIdx = lt.indexOf(';'); - if (cIdx !== -1) { - lt = lt.substring(0, cIdx).trim(); - } - if (mode === 2 /* Moleculetype */) { - var molName = lt.split(reWhitespace$4)[0]; - moleculetypeDict[molName] = currentMoleculetype; - } - else if (mode === 3 /* Atoms */) { - var ls = lt.split(reWhitespace$4); - currentMoleculetype.atoms.push([ - parseInt(ls[2]), - ls[3], - ls[4], - parseFloat(ls[6]) // charge - ]); - } - else if (mode === 4 /* Bonds */) { - var ls$1 = lt.split(reWhitespace$4); - currentMoleculetype.bonds.push([ - parseInt(ls$1[0]), - parseInt(ls$1[1]) // aj - ]); - } - else if (mode === 0 /* System */) { - s.title = lt; - } - else if (mode === 1 /* Molecules */) { - var ls$2 = lt.split(reWhitespace$4); - molecules.push([ - ls$2[0], - parseInt(ls$2[1]) // count - ]); - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - var atomCount = 0; - var bondCount = 0; - molecules.forEach(function (val) { - var name = val[0]; - var molCount = val[1]; - var molType = moleculetypeDict[name]; - atomCount += molCount * molType.atoms.length; - bondCount += molCount * molType.bonds.length; - }); - atomStore.resize(atomCount); - bondStore.resize(bondCount); - var atomIdx = 0; - var resIdx = 0; - var chainidIdx = 0; - var chainnameIdx = 0; - var bondIdx = 0; - var atomOffset = 0; - var lastResno; - molecules.forEach(function (val) { - var name = val[0]; - var molCount = val[1]; - var molType = moleculetypeDict[name]; - var chainname = getChainname(chainnameIdx); - var loop = function ( i ) { - lastResno = -1; - var chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx); - molType.atoms.forEach(function (atomData) { - var resno = atomData[0]; - var resname = atomData[1]; - var atomname = atomData[2]; - var charge = atomData[3]; - if (resno !== lastResno) { - ++resIdx; - } - atomStore.atomTypeId[atomIdx] = atomMap.add(atomname); - atomStore.serial[atomIdx] = atomIdx + 1; - atomStore.partialCharge[atomIdx] = charge; - sb.addAtom(0, chainname, chainid, resname, resIdx + 1); - ++atomIdx; - lastResno = resno; - }); - molType.bonds.forEach(function (bondData) { - bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1; - bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1; - ++bondIdx; - }); - ++chainidIdx; - atomOffset += molType.atoms.length; - }; - - for (var i = 0; i < molCount; ++i) loop( i ); - ++chainnameIdx; - }); - bondStore.count = bondCount; - sb.finalize(); - s.finalizeAtoms(); - s.finalizeBonds(); - calculateBondsWithin(s, true); - calculateBondsBetween(s, true, true); - assignResidueTypeBonds(s); - if (Debug) - { Log.timeEnd('TopParser._parse ' + this.name); } - }; - - Object.defineProperties( TopParser.prototype, prototypeAccessors ); - - return TopParser; -}(StructureParser)); -ParserRegistry$1.add('top', TopParser); - -/** - * @file Trajectory Parser - * @author Alexander Rose - * @private - */ -var TrajectoryParser = /*@__PURE__*/(function (Parser$$1) { - function TrajectoryParser(streamer, params) { - Parser$$1.call(this, streamer, params); - this.frames = new Frames(this.name, this.path); - } - - if ( Parser$$1 ) TrajectoryParser.__proto__ = Parser$$1; - TrajectoryParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - TrajectoryParser.prototype.constructor = TrajectoryParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'trajectory'; }; - prototypeAccessors.__objName.get = function () { return 'frames'; }; - - Object.defineProperties( TrajectoryParser.prototype, prototypeAccessors ); - - return TrajectoryParser; -}(Parser)); - -/** - * @file Dcd Parser - * @author Alexander Rose - * @private - */ -var charmmTimeUnitFactor = 20.45482949774598; -var DcdParser = /*@__PURE__*/(function (TrajectoryParser$$1) { - function DcdParser () { - TrajectoryParser$$1.apply(this, arguments); - } - - if ( TrajectoryParser$$1 ) DcdParser.__proto__ = TrajectoryParser$$1; - DcdParser.prototype = Object.create( TrajectoryParser$$1 && TrajectoryParser$$1.prototype ); - DcdParser.prototype.constructor = DcdParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'dcd'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - DcdParser.prototype._parse = function _parse () { - // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html - // The DCD format is structured as follows - // (FORTRAN UNFORMATTED, with Fortran data type descriptions): - // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS - // `CORD' #files step 1 step zeroes (zero) timestep (zeroes) - // interval - // C*4 INT INT INT 5INT INT DOUBLE 9INT - // ========================================================================== - // NTITLE TITLE - // INT (=2) C*MAXTITL - // (=32) - // ========================================================================== - // NATOM - // #atoms - // INT - // ========================================================================== - // X(I), I=1,NATOM (DOUBLE) - // Y(I), I=1,NATOM - // Z(I), I=1,NATOM - // ========================================================================== - if (Debug) - { Log.time('DcdParser._parse ' + this.name); } - var bin = ensureBuffer(this.streamer.data); - var dv = new DataView(bin); - var f = this.frames; - var coordinates = f.coordinates; - var boxes = f.boxes; - var header = {}; - var nextPos = 0; - // header block - var intView = new Int32Array(bin, 0, 23); - var ef = intView[0] !== dv.getInt32(0); // endianess flag - // swap byte order when big endian (84 indicates little endian) - if (intView[0] !== 84) { - var n = bin.byteLength; - for (var i = 0; i < n; i += 4) { - dv.setFloat32(i, dv.getFloat32(i), true); - } - } - if (intView[0] !== 84) { - Log.error('dcd bad format, header block start'); - } - // format indicator, should read 'CORD' - var formatString = String.fromCharCode(dv.getUint8(4), dv.getUint8(5), dv.getUint8(6), dv.getUint8(7)); - if (formatString !== 'CORD') { - Log.error('dcd bad format, format string'); - } - var isCharmm = false; - var extraBlock = false; - var fourDims = false; - // version field in charmm, unused in X-PLOR - if (intView[22] !== 0) { - isCharmm = true; - if (intView[12] !== 0) - { extraBlock = true; } - if (intView[13] === 1) - { fourDims = true; } - } - header.NSET = intView[2]; - header.ISTART = intView[3]; - header.NSAVC = intView[4]; - header.NAMNF = intView[10]; - if (isCharmm) { - header.DELTA = dv.getFloat32(44, ef); - } - else { - header.DELTA = dv.getFloat64(44, ef); - } - if (intView[22] !== 84) { - Log.error('dcd bad format, header block end'); - } - nextPos = nextPos + 21 * 4 + 8; - // title block - var titleLength = dv.getInt32(nextPos, ef); - var titlePos = nextPos + 1; - if ((titleLength - 4) % 80 !== 0) { - Log.error('dcd bad format, title block start'); - } - header.TITLE = uint8ToString(new Uint8Array(bin, titlePos, titleLength)); - if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) { - Log.error('dcd bad format, title block end'); - } - nextPos = nextPos + titleLength + 8; - // natom block - if (dv.getInt32(nextPos, ef) !== 4) { - Log.error('dcd bad format, natom block start'); - } - header.NATOM = dv.getInt32(nextPos + 4, ef); - if (dv.getInt32(nextPos + 8, ef) !== 4) { - Log.error('dcd bad format, natom block end'); - } - nextPos = nextPos + 4 + 8; - // fixed atoms block - if (header.NAMNF > 0) { - // TODO read coordinates and indices of fixed atoms - Log.error('dcd format with fixed atoms unsupported, aborting'); - return; - } - // frames - var natom = header.NATOM; - var natom4 = natom * 4; - for (var i$1 = 0, n$1 = header.NSET; i$1 < n$1; ++i$1) { - if (extraBlock) { - nextPos += 4; // block start - // unitcell: A, alpha, B, beta, gamma, C (doubles) - var box = new Float32Array(9); - box[0] = dv.getFloat64(nextPos, ef); - box[4] = dv.getFloat64(nextPos + 2 * 8, ef); - box[8] = dv.getFloat64(nextPos + 5 * 8, ef); - boxes.push(box); - nextPos += 48; - nextPos += 4; // block end - } - // xyz coordinates - var coord = new Float32Array(natom * 3); - for (var j = 0; j < 3; ++j) { - if (dv.getInt32(nextPos, ef) !== natom4) { - Log.error('dcd bad format, coord block start', i$1, j); - } - nextPos += 4; // block start - var c = new Float32Array(bin, nextPos, natom); - for (var k = 0; k < natom; ++k) { - coord[3 * k + j] = c[k]; - } - nextPos += natom4; - if (dv.getInt32(nextPos, ef) !== natom4) { - Log.error('dcd bad format, coord block end', i$1, j); - } - nextPos += 4; // block end - } - coordinates.push(coord); - if (fourDims) { - var bytes = dv.getInt32(nextPos, ef); - nextPos += 4 + bytes + 4; // block start + skip + block end - } - } - if (header.DELTA) { - f.deltaTime = header.DELTA * charmmTimeUnitFactor; - } - if (header.ISTART >= 1) { - f.timeOffset = (header.ISTART - 1) * f.deltaTime; - } - // console.log(header) - // console.log(header.TITLE) - // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims) - if (Debug) - { Log.timeEnd('DcdParser._parse ' + this.name); } - }; - - Object.defineProperties( DcdParser.prototype, prototypeAccessors ); - - return DcdParser; -}(TrajectoryParser)); -ParserRegistry$1.add('dcd', DcdParser); - -/** - * @file Netcdf Reader - * @author Alexander Rose - * @private - * - * Adapted from https://github.com/cheminfo-js/netcdfjs - * MIT License, Copyright (c) 2016 cheminfo - */ -/** - * Throws a non-valid NetCDF exception if the statement it's true - * @ignore - * @param {boolean} statement - Throws if true - * @param {string} reason - Reason to throw - */ -function notNetcdf(statement, reason) { - if (statement) { - throw new TypeError('Not a valid NetCDF v3.x file: ' + reason); - } -} -/** - * Moves 1, 2, or 3 bytes to next 4-byte boundary - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - */ -function padding(buffer) { - if ((buffer.offset % 4) !== 0) { - buffer.skip(4 - (buffer.offset % 4)); - } -} -/** - * Reads the name - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @return {string} - Name - */ -function readName(buffer) { - // Read name - var nameLength = buffer.readUint32(); - var name = buffer.readChars(nameLength); - // validate name - // TODO - // Apply padding - padding(buffer); - return name; -} -var types = { - BYTE: 1, - CHAR: 2, - SHORT: 3, - INT: 4, - FLOAT: 5, - DOUBLE: 6 -}; -/** - * Parse a number into their respective type - * @ignore - * @param {number} type - integer that represents the type - * @return {string} - parsed value of the type - */ -function num2str(type) { - switch (Number(type)) { - case types.BYTE: - return 'byte'; - case types.CHAR: - return 'char'; - case types.SHORT: - return 'short'; - case types.INT: - return 'int'; - case types.FLOAT: - return 'float'; - case types.DOUBLE: - return 'double'; - default: - return 'undefined'; - } -} -/** - * Parse a number type identifier to his size in bytes - * @ignore - * @param {number} type - integer that represents the type - * @return {number} -size of the type - */ -function num2bytes(type) { - switch (Number(type)) { - case types.BYTE: - return 1; - case types.CHAR: - return 1; - case types.SHORT: - return 2; - case types.INT: - return 4; - case types.FLOAT: - return 4; - case types.DOUBLE: - return 8; - default: - return -1; - } -} -/** - * Reverse search of num2str - * @ignore - * @param {string} type - string that represents the type - * @return {number} - parsed value of the type - */ -function str2num(type) { - switch (String(type)) { - case 'byte': - return types.BYTE; - case 'char': - return types.CHAR; - case 'short': - return types.SHORT; - case 'int': - return types.INT; - case 'float': - return types.FLOAT; - case 'double': - return types.DOUBLE; - default: - return -1; - } -} -/** - * Auxiliary function to read numeric data - * @ignore - * @param {number} size - Size of the element to read - * @param {function} bufferReader - Function to read next value - * @return {Array|number} - */ -function readNumber(size, bufferReader) { - if (size !== 1) { - var numbers = new Array(size); - for (var i = 0; i < size; i++) { - numbers[i] = bufferReader(); - } - return numbers; - } - else { - return bufferReader(); - } -} -/** - * Given a type and a size reads the next element - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @param {number} type - Type of the data to read - * @param {number} size - Size of the element to read - * @return {string|Array|number} - */ -function readType(buffer, type, size) { - switch (type) { - case types.BYTE: - return buffer.readBytes(size); - case types.CHAR: - return trimNull(buffer.readChars(size)); - case types.SHORT: - return readNumber(size, buffer.readInt16.bind(buffer)); - case types.INT: - return readNumber(size, buffer.readInt32.bind(buffer)); - case types.FLOAT: - return readNumber(size, buffer.readFloat32.bind(buffer)); - case types.DOUBLE: - return readNumber(size, buffer.readFloat64.bind(buffer)); - default: - notNetcdf(true, 'non valid type ' + type); - return undefined; - } -} -/** - * Removes null terminate value - * @ignore - * @param {string} value - String to trim - * @return {string} - Trimmed string - */ -function trimNull(value) { - if (value.charCodeAt(value.length - 1) === 0) { - return value.substring(0, value.length - 1); - } - return value; -} -// const STREAMING = 4294967295; -/** - * Read data for the given non-record variable - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @param {object} variable - Variable metadata - * @return {Array} - Data of the element - */ -function nonRecord(buffer, variable) { - // variable type - var type = str2num(variable.type); - // size of the data - var size = variable.size / num2bytes(type); - // iterates over the data - var data = new Array(size); - for (var i = 0; i < size; i++) { - data[i] = readType(buffer, type, 1); - } - return data; -} -/** - * Read data for the given record variable - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @param {object} variable - Variable metadata - * @param {object} recordDimension - Record dimension metadata - * @return {Array} - Data of the element - */ -function record(buffer, variable, recordDimension) { - // variable type - var type = str2num(variable.type); - var width = variable.size ? variable.size / num2bytes(type) : 1; - // size of the data - // TODO streaming data - var size = recordDimension.length; - // iterates over the data - var data = new Array(size); - var step = recordDimension.recordStep; - for (var i = 0; i < size; i++) { - var currentOffset = buffer.offset; - data[i] = readType(buffer, type, width); - buffer.seek(currentOffset + step); - } - return data; -} -// Grammar constants -var ZERO = 0; -var NC_DIMENSION = 10; -var NC_VARIABLE = 11; -var NC_ATTRIBUTE = 12; -/** - * Read the header of the file - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @param {number} version - Version of the file - * @return {object} - Object with the fields: - * * `recordDimension`: Number with the length of record dimension - * * `dimensions`: List of dimensions - * * `globalAttributes`: List of global attributes - * * `variables`: List of variables - */ -function header(buffer, version) { - // Length of record dimension - // sum of the varSize's of all the record variables. - var header = { recordDimension: { length: buffer.readUint32() } }; - // Version - header.version = version; - // List of dimensions - var dimList = dimensionsList(buffer); - header.recordDimension.id = dimList.recordId; - header.recordDimension.name = dimList.recordName; - header.dimensions = dimList.dimensions; - // List of global attributes - header.globalAttributes = attributesList(buffer); - // List of variables - var variables = variablesList(buffer, dimList.recordId, version); - header.variables = variables.variables; - header.recordDimension.recordStep = variables.recordStep; - return header; -} -/** - * List of dimensions - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @return {object} - List of dimensions and record dimension with: - * * `name`: String with the name of the dimension - * * `size`: Number with the size of the dimension - */ -function dimensionsList(buffer) { - var dimensions, recordId, recordName; - var dimList = buffer.readUint32(); - if (dimList === ZERO) { - notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions'); - return []; - } - else { - notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions'); - // Length of dimensions - var dimensionSize = buffer.readUint32(); - dimensions = new Array(dimensionSize); - for (var dim = 0; dim < dimensionSize; dim++) { - // Read name - var name = readName(buffer); - // Read dimension size - var size = buffer.readUint32(); - if (size === 0) { - recordId = dim; - recordName = name; - } - dimensions[dim] = { - name: name, - size: size - }; - } - return { - dimensions: dimensions, - recordId: recordId, - recordName: recordName - }; - } -} -/** - * List of attributes - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @return {Array} - List of attributes with: - * * `name`: String with the name of the attribute - * * `type`: String with the type of the attribute - * * `value`: A number or string with the value of the attribute - */ -function attributesList(buffer) { - var attributes; - var gAttList = buffer.readUint32(); - if (gAttList === ZERO) { - notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes'); - return []; - } - else { - notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes'); - // Length of attributes - var attributeSize = buffer.readUint32(); - attributes = new Array(attributeSize); - for (var gAtt = 0; gAtt < attributeSize; gAtt++) { - // Read name - var name = readName(buffer); - // Read type - var type = buffer.readUint32(); - notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type); - // Read attribute - var size = buffer.readUint32(); - var value = readType(buffer, type, size); - // Apply padding - padding(buffer); - attributes[gAtt] = { - name: name, - type: num2str(type), - value: value - }; - } - } - return attributes; -} -/** - * List of variables - * @ignore - * @param {IOBuffer} buffer - Buffer for the file data - * @param {number} recordId - Id if the record dimension - * @param {number} version - Version of the file - * @return {object} - Number of recordStep and list of variables with: - * * `name`: String with the name of the variable - * * `dimensions`: Array with the dimension IDs of the variable - * * `attributes`: Array with the attributes of the variable - * * `type`: String with the type of the variable - * * `size`: Number with the size of the variable - * * `offset`: Number with the offset where of the variable begins - * * `record`: True if is a record variable, false otherwise - */ -function variablesList(buffer, recordId, version) { - var varList = buffer.readUint32(); - var recordStep = 0; - var variables; - if (varList === ZERO) { - notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of variables'); - return []; - } - else { - notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables'); - // Length of variables - var variableSize = buffer.readUint32(); - variables = new Array(variableSize); - for (var v = 0; v < variableSize; v++) { - // Read name - var name = readName(buffer); - // Read dimensionality of the variable - var dimensionality = buffer.readUint32(); - // Index into the list of dimensions - var dimensionsIds = new Array(dimensionality); - for (var dim = 0; dim < dimensionality; dim++) { - dimensionsIds[dim] = buffer.readUint32(); - } - // Read variables size - var attributes = attributesList(buffer); - // Read type - var type = buffer.readUint32(); - notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type); - // Read variable size - // The 32-bit varSize field is not large enough to contain the - // size of variables that require more than 2^32 - 4 bytes, - // so 2^32 - 1 is used in the varSize field for such variables. - var varSize = buffer.readUint32(); - // Read offset - var offset = buffer.readUint32(); - if (version === 2) { - notNetcdf((offset > 0), 'offsets larger than 4GB not supported'); - offset = buffer.readUint32(); - } - // Count amount of record variables - if (dimensionsIds[0] === recordId) { - recordStep += varSize; - } - variables[v] = { - name: name, - dimensions: dimensionsIds, - attributes: attributes, - type: num2str(type), - size: varSize, - offset: offset, - record: (dimensionsIds[0] === recordId) - }; - } - } - return { - variables: variables, - recordStep: recordStep - }; -} -/** - * Reads a NetCDF v3.x file - * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html - */ -var NetcdfReader = function NetcdfReader(data) { - var buffer = new IOBuffer(data); - buffer.setBigEndian(); - // Validate that it's a NetCDF file - notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF'); - // Check the NetCDF format - var version = buffer.readByte(); - notNetcdf((version > 2), 'unknown version'); - // Read the header - this.header = header(buffer, version); - this.buffer = buffer; -}; - -var prototypeAccessors$y = { version: { configurable: true },recordDimension: { configurable: true },dimensions: { configurable: true },globalAttributes: { configurable: true },variables: { configurable: true } }; -/** - * @return {string} - Version for the NetCDF format - */ -prototypeAccessors$y.version.get = function () { - if (this.header.version === 1) { - return 'classic format'; - } - else { - return '64-bit offset format'; - } -}; -/** - * @return {object} - Metadata for the record dimension - * * `length`: Number of elements in the record dimension - * * `id`: Id number in the list of dimensions for the record dimension - * * `name`: String with the name of the record dimension - * * `recordStep`: Number with the record variables step size - */ -prototypeAccessors$y.recordDimension.get = function () { - return this.header.recordDimension; -}; -/** - * @return {Array} - List of dimensions with: - * * `name`: String with the name of the dimension - * * `size`: Number with the size of the dimension - */ -prototypeAccessors$y.dimensions.get = function () { - return this.header.dimensions; -}; -/** - * @return {Array} - List of global attributes with: - * * `name`: String with the name of the attribute - * * `type`: String with the type of the attribute - * * `value`: A number or string with the value of the attribute - */ -prototypeAccessors$y.globalAttributes.get = function () { - return this.header.globalAttributes; -}; -/** - * @return {Array} - List of variables with: - * * `name`: String with the name of the variable - * * `dimensions`: Array with the dimension IDs of the variable - * * `attributes`: Array with the attributes of the variable - * * `type`: String with the type of the variable - * * `size`: Number with the size of the variable - * * `offset`: Number with the offset where of the variable begins - * * `record`: True if is a record variable, false otherwise - */ -prototypeAccessors$y.variables.get = function () { - return this.header.variables; -}; -/** - * Checks if a variable is available - * @param {string|object} variableName - Name of the variable to check - * @return {Boolean} - Variable existence - */ -NetcdfReader.prototype.hasDataVariable = function hasDataVariable (variableName) { - return this.header.variables.findIndex(function (val) { - return val.name === variableName; - }) !== -1; -}; -/** - * Retrieves the data for a given variable - * @param {string|object} variableName - Name of the variable to search or variable object - * @return {Array} - List with the variable values - */ -NetcdfReader.prototype.getDataVariable = function getDataVariable (variableName) { - var variable; - if (typeof variableName === 'string') { - // search the variable - variable = this.header.variables.find(function (val) { - return val.name === variableName; - }); - } - else { - variable = variableName; - } - // throws if variable not found - notNetcdf((variable === undefined), 'variable not found'); - // go to the offset position - this.buffer.seek(variable.offset); - if (variable.record) { - // record variable case - return record(this.buffer, variable, this.header.recordDimension); - } - else { - // non-record variable case - return nonRecord(this.buffer, variable); - } -}; - -Object.defineProperties( NetcdfReader.prototype, prototypeAccessors$y ); - -/** - * @file Nctraj Parser - * @author Alexander Rose - * @private - */ -var NctrajParser = /*@__PURE__*/(function (TrajectoryParser$$1) { - function NctrajParser () { - TrajectoryParser$$1.apply(this, arguments); - } - - if ( TrajectoryParser$$1 ) NctrajParser.__proto__ = TrajectoryParser$$1; - NctrajParser.prototype = Object.create( TrajectoryParser$$1 && TrajectoryParser$$1.prototype ); - NctrajParser.prototype.constructor = NctrajParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'nctraj'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - NctrajParser.prototype._parse = function _parse () { - // http://ambermd.org/netcdf/nctraj.xhtml - if (Debug) - { Log.time('NctrajParser._parse ' + this.name); } - var netcdfReader = new NetcdfReader(this.streamer.data); - var f = this.frames; - var coordinates = f.coordinates; - var boxes = f.boxes; - var times = f.times; - netcdfReader.getDataVariable('coordinates').forEach(function (c) { - coordinates.push(new Float32Array(c)); - }); - if (netcdfReader.hasDataVariable('cell_lengths')) { - netcdfReader.getDataVariable('cell_lengths').forEach(function (b) { - boxes.push(new Float32Array(b)); - }); - } - if (netcdfReader.hasDataVariable('time')) { - netcdfReader.getDataVariable('time').forEach(function (t) { - times.push(t); - }); - } - if (times.length >= 1) { - f.timeOffset = times[0]; - } - if (times.length >= 2) { - f.deltaTime = times[1] - times[0]; - } - if (Debug) - { Log.timeEnd('NctrajParser._parse ' + this.name); } - }; - - Object.defineProperties( NctrajParser.prototype, prototypeAccessors ); - - return NctrajParser; -}(TrajectoryParser)); -ParserRegistry$1.add('nctraj', NctrajParser); -ParserRegistry$1.add('ncdf', NctrajParser); -ParserRegistry$1.add('nc', NctrajParser); - -/** - * @file Trr Parser - * @author Alexander Rose - * @private - */ -var TrrParser = /*@__PURE__*/(function (TrajectoryParser$$1) { - function TrrParser () { - TrajectoryParser$$1.apply(this, arguments); - } - - if ( TrajectoryParser$$1 ) TrrParser.__proto__ = TrajectoryParser$$1; - TrrParser.prototype = Object.create( TrajectoryParser$$1 && TrajectoryParser$$1.prototype ); - TrrParser.prototype.constructor = TrrParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'trr'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - TrrParser.prototype._parse = function _parse () { - // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp - if (Debug) - { Log.time('TrrParser._parse ' + this.name); } - var bin = ensureBuffer(this.streamer.data); - var dv = new DataView(bin); - var f = this.frames; - var coordinates = f.coordinates; - var boxes = f.boxes; - var times = f.times; - var offset = 0; - while (true) { - // const magicnum = dv.getInt32(offset) - // const i1 = dv.getFloat32(offset + 4) - offset += 8; - var versionSize = dv.getInt32(offset); - offset += 4; - offset += versionSize; - // const irSize = dv.getInt32(offset) - // const eSize = dv.getInt32(offset + 4) - var boxSize = dv.getInt32(offset + 8); - var virSize = dv.getInt32(offset + 12); - var presSize = dv.getInt32(offset + 16); - // const topSize = dv.getInt32(offset + 20) - // const symSize = dv.getInt32(offset + 24) - var coordSize = dv.getInt32(offset + 28); - var velocitySize = dv.getInt32(offset + 32); - var forceSize = dv.getInt32(offset + 36); - var natoms = dv.getInt32(offset + 40); - // const step = dv.getInt32(offset + 44) - // const nre = dv.getInt32(offset + 48) - offset += 52; - var floatSize = boxSize / 9; - var natoms3 = natoms * 3; - // let lambda - if (floatSize === 8) { - times.push(dv.getFloat64(offset)); - // lambda = dv.getFloat64(offset + 8) - } - else { - times.push(dv.getFloat32(offset)); - // lambda = dv.getFloat32(offset + 4) - } - offset += 2 * floatSize; - if (boxSize) { - var box = new Float32Array(9); - if (floatSize === 8) { - for (var i = 0; i < 9; ++i) { - box[i] = dv.getFloat64(offset) * 10; - offset += 8; - } - } - else { - for (var i$1 = 0; i$1 < 9; ++i$1) { - box[i$1] = dv.getFloat32(offset) * 10; - offset += 4; - } - } - boxes.push(box); - } - // ignore, unused - offset += virSize; - // ignore, unused - offset += presSize; - if (coordSize) { - var frameCoords = (void 0); - if (floatSize === 8) { - frameCoords = new Float32Array(natoms3); - for (var i$2 = 0; i$2 < natoms3; ++i$2) { - frameCoords[i$2] = dv.getFloat64(offset) * 10; - offset += 8; - } - } - else { - var tmp = new Uint32Array(bin, offset, natoms3); - for (var i$3 = 0; i$3 < natoms3; ++i$3) { - var value = tmp[i$3]; - tmp[i$3] = (((value & 0xFF) << 24) | ((value & 0xFF00) << 8) | - ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)); - } - frameCoords = new Float32Array(bin, offset, natoms3); - for (var i$4 = 0; i$4 < natoms3; ++i$4) { - frameCoords[i$4] *= 10; - offset += 4; - } - } - coordinates.push(frameCoords); - } - // ignore, unused - offset += velocitySize; - // ignore, unused - offset += forceSize; - if (offset >= bin.byteLength) - { break; } - } - if (times.length >= 1) { - f.timeOffset = times[0]; - } - if (times.length >= 2) { - f.deltaTime = times[1] - times[0]; - } - if (Debug) - { Log.timeEnd('TrrParser._parse ' + this.name); } - }; - - Object.defineProperties( TrrParser.prototype, prototypeAccessors ); - - return TrrParser; -}(TrajectoryParser)); -ParserRegistry$1.add('trr', TrrParser); - -/** - * @file Xtc Parser - * @author Alexander Rose - * @private - */ -var MagicInts = new Uint32Array([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, - 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290, - 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003, - 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031, - 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561, - 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021, - 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216 -]); -var FirstIdx = 9; -// const LastIdx = MagicInts.length -function sizeOfInt(size) { - var num = 1; - var numOfBits = 0; - while (size >= num && numOfBits < 32) { - numOfBits++; - num <<= 1; - } - return numOfBits; -} -var _tmpBytes = new Uint8Array(32); -function sizeOfInts(numOfInts, sizes) { - var numOfBytes = 1; - var numOfBits = 0; - _tmpBytes[0] = 1; - for (var i = 0; i < numOfInts; i++) { - var bytecnt = (void 0); - var tmp = 0; - for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) { - tmp += _tmpBytes[bytecnt] * sizes[i]; - _tmpBytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp !== 0) { - _tmpBytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - numOfBytes = bytecnt; - } - var num = 1; - numOfBytes--; - while (_tmpBytes[numOfBytes] >= num) { - numOfBits++; - num *= 2; - } - return numOfBits + numOfBytes * 8; -} -function decodeBits(buf, cbuf, numOfBits, buf2) { - var mask = (1 << numOfBits) - 1; - var lastBB0 = buf2[1]; - var lastBB1 = buf2[2]; - var cnt = buf[0]; - var num = 0; - while (numOfBits >= 8) { - lastBB1 = (lastBB1 << 8) | cbuf[cnt++]; - num |= (lastBB1 >> lastBB0) << (numOfBits - 8); - numOfBits -= 8; - } - if (numOfBits > 0) { - if (lastBB0 < numOfBits) { - lastBB0 += 8; - lastBB1 = (lastBB1 << 8) | cbuf[cnt++]; - } - lastBB0 -= numOfBits; - num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1); - } - num &= mask; - buf[0] = cnt; - buf[1] = lastBB0; - buf[2] = lastBB1; - return num; -} -var _tmpIntBytes = new Int32Array(32); -function decodeInts(buf, cbuf, numOfInts, numOfBits, sizes, nums, buf2) { - var numOfBytes = 0; - _tmpIntBytes[1] = 0; - _tmpIntBytes[2] = 0; - _tmpIntBytes[3] = 0; - while (numOfBits > 8) { - // this is inversed??? why??? because of the endiannness??? - _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2); - numOfBits -= 8; - } - if (numOfBits > 0) { - _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2); - } - for (var i = numOfInts - 1; i > 0; i--) { - var num = 0; - for (var j = numOfBytes - 1; j >= 0; j--) { - num = (num << 8) | _tmpIntBytes[j]; - var p = (num / sizes[i]) | 0; - _tmpIntBytes[j] = p; - num = num - p * sizes[i]; - } - nums[i] = num; - } - nums[0] = (_tmpIntBytes[0] | - (_tmpIntBytes[1] << 8) | - (_tmpIntBytes[2] << 16) | - (_tmpIntBytes[3] << 24)); -} -var XtcParser = /*@__PURE__*/(function (TrajectoryParser$$1) { - function XtcParser () { - TrajectoryParser$$1.apply(this, arguments); - } - - if ( TrajectoryParser$$1 ) XtcParser.__proto__ = TrajectoryParser$$1; - XtcParser.prototype = Object.create( TrajectoryParser$$1 && TrajectoryParser$$1.prototype ); - XtcParser.prototype.constructor = XtcParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'xtc'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - XtcParser.prototype._parse = function _parse () { - // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp - // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp - if (Debug) - { Log.time('XtcParser._parse ' + this.name); } - var bin = ensureBuffer(this.streamer.data); - var dv = new DataView(bin); - var f = this.frames; - var coordinates = f.coordinates; - var boxes = f.boxes; - var times = f.times; - var minMaxInt = new Int32Array(6); - var sizeint = new Int32Array(3); - var bitsizeint = new Int32Array(3); - var sizesmall = new Uint32Array(3); - var thiscoord = new Float32Array(3); - var prevcoord = new Float32Array(3); - var offset = 0; - var buf = new Int32Array(3); - var buf2 = new Uint32Array(buf.buffer); - while (true) { - var frameCoords = (void 0); - // const magicnum = dv.getInt32(offset) - var natoms = dv.getInt32(offset + 4); - // const step = dv.getInt32(offset + 8) - offset += 12; - var natoms3 = natoms * 3; - times.push(dv.getFloat32(offset)); - offset += 4; - var box = new Float32Array(9); - for (var i = 0; i < 9; ++i) { - box[i] = dv.getFloat32(offset) * 10; - offset += 4; - } - boxes.push(box); - if (natoms <= 9) { // no compression - frameCoords = new Float32Array(natoms); - for (var i$1 = 0; i$1 < natoms; ++i$1) { - frameCoords[i$1] = dv.getFloat32(offset); - offset += 4; - } - } - else { - buf[0] = buf[1] = buf[2] = 0.0; - sizeint[0] = sizeint[1] = sizeint[2] = 0; - sizesmall[0] = sizesmall[1] = sizesmall[2] = 0; - bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0; - thiscoord[0] = thiscoord[1] = thiscoord[2] = 0; - prevcoord[0] = prevcoord[1] = prevcoord[2] = 0; - frameCoords = new Float32Array(natoms3); - var lfp = 0; - var lsize = dv.getInt32(offset); - offset += 4; - var precision = dv.getFloat32(offset); - offset += 4; - minMaxInt[0] = dv.getInt32(offset); - minMaxInt[1] = dv.getInt32(offset + 4); - minMaxInt[2] = dv.getInt32(offset + 8); - minMaxInt[3] = dv.getInt32(offset + 12); - minMaxInt[4] = dv.getInt32(offset + 16); - minMaxInt[5] = dv.getInt32(offset + 20); - sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1; - sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1; - sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1; - offset += 24; - var bitsize = (void 0); - if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) { - bitsizeint[0] = sizeOfInt(sizeint[0]); - bitsizeint[1] = sizeOfInt(sizeint[1]); - bitsizeint[2] = sizeOfInt(sizeint[2]); - bitsize = 0; // flag the use of large sizes - } - else { - bitsize = sizeOfInts(3, sizeint); - } - var smallidx = dv.getInt32(offset); - offset += 4; - // if (smallidx == 0) {alert("Undocumented error 1"); return;} - // let tmpIdx = smallidx + 8 - // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx - // const minidx = maxidx - 8 // often this equal smallidx - var tmpIdx = smallidx - 1; - tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx; - var smaller = (MagicInts[tmpIdx] / 2) | 0; - var smallnum = (MagicInts[smallidx] / 2) | 0; - sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]; - // larger = MagicInts[maxidx] - var adz = Math.ceil(dv.getInt32(offset) / 4) * 4; - offset += 4; - // if (tmpIdx == 0) {alert("Undocumented error 2"); return;} - // buf = new Int32Array(bin, offset); - // buf8 = new Uint8Array(bin, offset); - // tmpIdx += 3; rndup = tmpIdx%4; - // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0; - // now unpack buf2... - var invPrecision = 1.0 / precision; - var run = 0; - var i$2 = 0; - var buf8 = new Uint8Array(bin, offset); // 229... - thiscoord[0] = thiscoord[1] = thiscoord[2] = 0; - while (i$2 < lsize) { - if (bitsize === 0) { - thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2); - thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2); - thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2); - } - else { - decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2); - } - i$2++; - thiscoord[0] += minMaxInt[0]; - thiscoord[1] += minMaxInt[1]; - thiscoord[2] += minMaxInt[2]; - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - var flag = decodeBits(buf, buf8, 1, buf2); - var isSmaller = 0; - if (flag === 1) { - run = decodeBits(buf, buf8, 5, buf2); - isSmaller = run % 3; - run -= isSmaller; - isSmaller--; - } - // if ((lfp-ptrstart)+run > size3){ - // fprintf(stderr, "(xdrfile error) Buffer overrun during decompression.\n"); - // return 0; - // } - if (run > 0) { - thiscoord[0] = thiscoord[1] = thiscoord[2] = 0; - for (var k = 0; k < run; k += 3) { - decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2); - i$2++; - thiscoord[0] += prevcoord[0] - smallnum; - thiscoord[1] += prevcoord[1] - smallnum; - thiscoord[2] += prevcoord[2] - smallnum; - if (k === 0) { - // interchange first with second atom for - // better compression of water molecules - var tmpSwap = thiscoord[0]; - thiscoord[0] = prevcoord[0]; - prevcoord[0] = tmpSwap; - tmpSwap = thiscoord[1]; - thiscoord[1] = prevcoord[1]; - prevcoord[1] = tmpSwap; - tmpSwap = thiscoord[2]; - thiscoord[2] = prevcoord[2]; - prevcoord[2] = tmpSwap; - frameCoords[lfp++] = prevcoord[0] * invPrecision; - frameCoords[lfp++] = prevcoord[1] * invPrecision; - frameCoords[lfp++] = prevcoord[2] * invPrecision; - } - else { - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - } - frameCoords[lfp++] = thiscoord[0] * invPrecision; - frameCoords[lfp++] = thiscoord[1] * invPrecision; - frameCoords[lfp++] = thiscoord[2] * invPrecision; - } - } - else { - frameCoords[lfp++] = thiscoord[0] * invPrecision; - frameCoords[lfp++] = thiscoord[1] * invPrecision; - frameCoords[lfp++] = thiscoord[2] * invPrecision; - } - smallidx += isSmaller; - if (isSmaller < 0) { - smallnum = smaller; - if (smallidx > FirstIdx) { - smaller = (MagicInts[smallidx - 1] / 2) | 0; - } - else { - smaller = 0; - } - } - else if (isSmaller > 0) { - smaller = smallnum; - smallnum = (MagicInts[smallidx] / 2) | 0; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]; - if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) { - console.error('(xdrfile error) Undefined error.'); - return; - } - } - offset += adz; - } - for (var c = 0; c < natoms3; c++) { - frameCoords[c] *= 10; - } - coordinates.push(frameCoords); - if (offset >= bin.byteLength) - { break; } - } - if (times.length >= 1) { - f.timeOffset = times[0]; - } - if (times.length >= 2) { - f.deltaTime = times[1] - times[0]; - } - if (Debug) - { Log.timeEnd('XtcParser._parse ' + this.name); } - }; - - Object.defineProperties( XtcParser.prototype, prototypeAccessors ); - - return XtcParser; -}(TrajectoryParser)); -ParserRegistry$1.add('xtc', XtcParser); - -/** - * @file Volume Parser - * @author Alexander Rose - * @private - */ -var VolumeParser = /*@__PURE__*/(function (Parser$$1) { - function VolumeParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.volume = new Volume(this.name, this.path); - this.voxelSize = defaults(p.voxelSize, 1); - } - - if ( Parser$$1 ) VolumeParser.__proto__ = Parser$$1; - VolumeParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - VolumeParser.prototype.constructor = VolumeParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'volume'; }; - prototypeAccessors.__objName.get = function () { return 'volume'; }; - VolumeParser.prototype._afterParse = function _afterParse () { - this.volume.setMatrix(this.getMatrix()); - Parser$$1.prototype._afterParse.call(this); - }; - VolumeParser.prototype.getMatrix = function getMatrix () { - return new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - }; - - Object.defineProperties( VolumeParser.prototype, prototypeAccessors ); - - return VolumeParser; -}(Parser)); - -/** - * @file Cube Parser - * @author Alexander Rose - * @private - */ -// @author Johanna Tiemann -// @author Alexander Rose -var reWhitespace$5 = /\s+/; -var reScientificNotation = /-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g; -var bohrToAngstromFactor = 0.529177210859; -var CubeParser = /*@__PURE__*/(function (VolumeParser$$1) { - function CubeParser () { - VolumeParser$$1.apply(this, arguments); - } - - if ( VolumeParser$$1 ) CubeParser.__proto__ = VolumeParser$$1; - CubeParser.prototype = Object.create( VolumeParser$$1 && VolumeParser$$1.prototype ); - CubeParser.prototype.constructor = CubeParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'cube'; }; - CubeParser.prototype._parse = function _parse () { - // http://paulbourke.net/dataformats/cube/ - if (Debug) - { Log.time('CubeParser._parse ' + this.name); } - var v = this.volume; - var headerLines = this.streamer.peekLines(6); - var header = {}; - var scaleFactor = bohrToAngstromFactor * this.voxelSize; - function h(k, l) { - var field = headerLines[k].trim().split(reWhitespace$5)[l]; - return parseFloat(field); - } - header.atomCount = Math.abs(h(2, 0)); // Number of atoms - header.originX = h(2, 1) * bohrToAngstromFactor; // Position of origin of volumetric data - header.originY = h(2, 2) * bohrToAngstromFactor; - header.originZ = h(2, 3) * bohrToAngstromFactor; - header.NVX = h(3, 0); // Number of voxels - header.NVY = h(4, 0); - header.NVZ = h(5, 0); - header.basisX = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](h(3, 1), h(3, 2), h(3, 3)) - .multiplyScalar(scaleFactor); - header.basisY = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](h(4, 1), h(4, 2), h(4, 3)) - .multiplyScalar(scaleFactor); - header.basisZ = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](h(5, 1), h(5, 2), h(5, 3)) - .multiplyScalar(scaleFactor); - var data = new Float32Array(header.NVX * header.NVY * header.NVZ); - var count = 0; - var lineNo = 0; - var oribitalFlag = h(2, 0) > 0 ? 0 : 1; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i].trim(); - if (line !== '' && lineNo >= header.atomCount + 6 + oribitalFlag) { - var m = line.match(reScientificNotation); - for (var j = 0, lj = m.length; j < lj; ++j) { - data[count] = parseFloat(m[j]); - ++count; - } - } - ++lineNo; - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - v.header = header; - v.setData(data, header.NVZ, header.NVY, header.NVX); - if (Debug) - { Log.timeEnd('CubeParser._parse ' + this.name); } - }; - CubeParser.prototype.getMatrix = function getMatrix () { - var h = this.volume.header; - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeTranslation(h.originX, h.originY, h.originZ)); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeBasis(h.basisZ, h.basisY, h.basisX)); - return matrix; - }; - - Object.defineProperties( CubeParser.prototype, prototypeAccessors ); - - return CubeParser; -}(VolumeParser)); -ParserRegistry$1.add('cub', CubeParser); -ParserRegistry$1.add('cube', CubeParser); - -/** - * @file Dsn6 Parser - * @author Alexander Rose - * @private - */ -var Dsn6Parser = /*@__PURE__*/(function (VolumeParser$$1) { - function Dsn6Parser () { - VolumeParser$$1.apply(this, arguments); - } - - if ( VolumeParser$$1 ) Dsn6Parser.__proto__ = VolumeParser$$1; - Dsn6Parser.prototype = Object.create( VolumeParser$$1 && VolumeParser$$1.prototype ); - Dsn6Parser.prototype.constructor = Dsn6Parser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'dsn6'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - Dsn6Parser.prototype._parse = function _parse () { - // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html - // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html - if (Debug) - { Log.time('Dsn6Parser._parse ' + this.name); } - var v = this.volume; - var header = {}; - var divisor, summand; - var bin = ensureBuffer(this.streamer.data); - var intView = new Int16Array(bin); - var byteView = new Uint8Array(bin); - var brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512)); - if (brixStr.startsWith(':-)')) { - header.xStart = parseInt(brixStr.substr(10, 5)); // NXSTART - header.yStart = parseInt(brixStr.substr(15, 5)); - header.zStart = parseInt(brixStr.substr(20, 5)); - header.xExtent = parseInt(brixStr.substr(32, 5)); // NX - header.yExtent = parseInt(brixStr.substr(38, 5)); - header.zExtent = parseInt(brixStr.substr(42, 5)); - header.xRate = parseInt(brixStr.substr(52, 5)); // MX - header.yRate = parseInt(brixStr.substr(58, 5)); - header.zRate = parseInt(brixStr.substr(62, 5)); - header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize; - header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize; - header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize; - header.alpha = parseFloat(brixStr.substr(103, 10)); - header.beta = parseFloat(brixStr.substr(113, 10)); - header.gamma = parseFloat(brixStr.substr(123, 10)); - divisor = parseFloat(brixStr.substr(138, 12)) / 100; - summand = parseInt(brixStr.substr(155, 8)); - header.sigma = parseFloat(brixStr.substr(170, 12)) * 100; - } - else { - // swap byte order when big endian - if (intView[18] !== 100) { - for (var i$1 = 0, n = intView.length; i$1 < n; ++i$1) { - var val = intView[i$1]; - intView[i$1] = ((val & 0xff) << 8) | ((val >> 8) & 0xff); - } - } - header.xStart = intView[0]; // NXSTART - header.yStart = intView[1]; - header.zStart = intView[2]; - header.xExtent = intView[3]; // NX - header.yExtent = intView[4]; - header.zExtent = intView[5]; - header.xRate = intView[6]; // MX - header.yRate = intView[7]; - header.zRate = intView[8]; - var factor = 1 / intView[17]; - var scalingFactor = factor * this.voxelSize; - header.xlen = intView[9] * scalingFactor; - header.ylen = intView[10] * scalingFactor; - header.zlen = intView[11] * scalingFactor; - header.alpha = intView[12] * factor; - header.beta = intView[13] * factor; - header.gamma = intView[14] * factor; - divisor = intView[15] / 100; - summand = intView[16]; - header.gamma = intView[14] * factor; - } - v.header = header; - if (Debug) - { Log.log(header, divisor, summand); } - var data = new Float32Array(header.xExtent * header.yExtent * header.zExtent); - var offset = 512; - var xBlocks = Math.ceil(header.xExtent / 8); - var yBlocks = Math.ceil(header.yExtent / 8); - var zBlocks = Math.ceil(header.zExtent / 8); - // loop over blocks - for (var zz = 0; zz < zBlocks; ++zz) { - for (var yy = 0; yy < yBlocks; ++yy) { - for (var xx = 0; xx < xBlocks; ++xx) { - // loop inside block - for (var k = 0; k < 8; ++k) { - var z = 8 * zz + k; - for (var j = 0; j < 8; ++j) { - var y = 8 * yy + j; - for (var i = 0; i < 8; ++i) { - var x = 8 * xx + i; - // check if remaining slice-part contains data - if (x < header.xExtent && y < header.yExtent && z < header.zExtent) { - var idx = ((((x * header.yExtent) + y) * header.zExtent) + z); - data[idx] = (byteView[offset] - summand) / divisor; - ++offset; - } - else { - offset += 8 - i; - break; - } - } - } - } - } - } - } - v.setData(data, header.zExtent, header.yExtent, header.xExtent); - if (header.sigma) { - v.setStats(undefined, undefined, undefined, header.sigma); - } - if (Debug) - { Log.timeEnd('Dsn6Parser._parse ' + this.name); } - }; - Dsn6Parser.prototype.getMatrix = function getMatrix () { - var h = this.volume.header; - var basisX = [ - h.xlen, - 0, - 0 - ]; - var basisY = [ - h.ylen * Math.cos(Math.PI / 180.0 * h.gamma), - h.ylen * Math.sin(Math.PI / 180.0 * h.gamma), - 0 - ]; - var basisZ = [ - h.zlen * Math.cos(Math.PI / 180.0 * h.beta), - h.zlen * (Math.cos(Math.PI / 180.0 * h.alpha) - - Math.cos(Math.PI / 180.0 * h.gamma) * - Math.cos(Math.PI / 180.0 * h.beta)) / Math.sin(Math.PI / 180.0 * h.gamma), - 0 - ]; - basisZ[2] = Math.sqrt(h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) * - Math.sin(Math.PI / 180.0 * h.beta) - basisZ[1] * basisZ[1]); - var basis = [[], basisX, basisY, basisZ]; - var nxyz = [0, h.xRate, h.yRate, h.zRate]; - var mapcrs = [0, 1, 2, 3]; - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - matrix.set(basis[mapcrs[1]][0] / nxyz[mapcrs[1]], basis[mapcrs[2]][0] / nxyz[mapcrs[2]], basis[mapcrs[3]][0] / nxyz[mapcrs[3]], 0, basis[mapcrs[1]][1] / nxyz[mapcrs[1]], basis[mapcrs[2]][1] / nxyz[mapcrs[2]], basis[mapcrs[3]][1] / nxyz[mapcrs[3]], 0, basis[mapcrs[1]][2] / nxyz[mapcrs[1]], basis[mapcrs[2]][2] / nxyz[mapcrs[2]], basis[mapcrs[3]][2] / nxyz[mapcrs[3]], 0, 0, 0, 0, 1); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeRotationY(degToRad(90))); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeTranslation(-h.zStart, h.yStart, h.xStart)); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeScale(-1, 1, 1)); - return matrix; - }; - - Object.defineProperties( Dsn6Parser.prototype, prototypeAccessors ); - - return Dsn6Parser; -}(VolumeParser)); -ParserRegistry$1.add('dsn6', Dsn6Parser); -ParserRegistry$1.add('brix', Dsn6Parser); - -/** - * @file Dx Parser - * @author Alexander Rose - * @private - */ -var reWhitespace$6 = /\s+/; -var DxParser = /*@__PURE__*/(function (VolumeParser$$1) { - function DxParser () { - VolumeParser$$1.apply(this, arguments); - } - - if ( VolumeParser$$1 ) DxParser.__proto__ = VolumeParser$$1; - DxParser.prototype = Object.create( VolumeParser$$1 && VolumeParser$$1.prototype ); - DxParser.prototype.constructor = DxParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'dx'; }; - DxParser.prototype._parse = function _parse () { - // http://apbs-pdb2pqr.readthedocs.io/en/latest/formats/opendx.html - if (Debug) - { Log.time('DxParser._parse ' + this.name); } - var v = this.volume; - var headerLines = this.streamer.peekLines(30); - var headerInfo = this.parseHeaderLines(headerLines); - var header = this.volume.header; - var dataLineStart = headerInfo.dataLineStart; - var size = header.nx * header.ny * header.nz; - var data = new Float32Array(size); - var count = 0; - var lineNo = 0; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - if (count < size && lineNo > dataLineStart) { - var line = lines[i].trim(); - if (line !== '') { - var ls = line.split(reWhitespace$6); - for (var j = 0, lj = ls.length; j < lj; ++j) { - data[count] = parseFloat(ls[j]); - ++count; - } - } - } - ++lineNo; - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - v.setData(data, header.nz, header.ny, header.nx); - if (Debug) - { Log.timeEnd('DxParser._parse ' + this.name); } - }; - DxParser.prototype.parseHeaderLines = function parseHeaderLines (headerLines) { - var header = {}; - var n = headerLines.length; - var dataLineStart = 0; - var headerByteCount = 0; - var deltaLineCount = 0; - for (var i = 0; i < n; ++i) { - var ls = (void 0); - var line = headerLines[i]; - if (line.startsWith('object 1')) { - ls = line.split(reWhitespace$6); - header.nx = parseInt(ls[5]); - header.ny = parseInt(ls[6]); - header.nz = parseInt(ls[7]); - } - else if (line.startsWith('origin')) { - ls = line.split(reWhitespace$6); - header.xmin = parseFloat(ls[1]); - header.ymin = parseFloat(ls[2]); - header.zmin = parseFloat(ls[3]); - } - else if (line.startsWith('delta')) { - ls = line.split(reWhitespace$6); - if (deltaLineCount === 0) { - header.hx = parseFloat(ls[1]) * this.voxelSize; - } - else if (deltaLineCount === 1) { - header.hy = parseFloat(ls[2]) * this.voxelSize; - } - else if (deltaLineCount === 2) { - header.hz = parseFloat(ls[3]) * this.voxelSize; - } - deltaLineCount += 1; - } - else if (line.startsWith('object 3')) { - dataLineStart = i; - headerByteCount += line.length + 1; - break; - } - headerByteCount += line.length + 1; - } - this.volume.header = header; - return { - dataLineStart: dataLineStart, - headerByteCount: headerByteCount - }; - }; - DxParser.prototype.getMatrix = function getMatrix () { - var h = this.volume.header; - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeRotationY(degToRad(90))); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeTranslation(-h.zmin, h.ymin, h.xmin)); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeScale(-h.hz, h.hy, h.hx)); - return matrix; - }; - - Object.defineProperties( DxParser.prototype, prototypeAccessors ); - - return DxParser; -}(VolumeParser)); -ParserRegistry$1.add('dx', DxParser); - -/** - * @file Dxbin Parser - * @author Alexander Rose - * @private - */ -var DxbinParser = /*@__PURE__*/(function (DxParser$$1) { - function DxbinParser () { - DxParser$$1.apply(this, arguments); - } - - if ( DxParser$$1 ) DxbinParser.__proto__ = DxParser$$1; - DxbinParser.prototype = Object.create( DxParser$$1 && DxParser$$1.prototype ); - DxbinParser.prototype.constructor = DxbinParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'dxbin'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - DxbinParser.prototype._parse = function _parse () { - // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216 - if (Debug) - { Log.time('DxbinParser._parse ' + this.name); } - var bin = ensureBuffer(this.streamer.data); - var headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000)); - var headerInfo = this.parseHeaderLines(headerLines); - var header = this.volume.header; - var headerByteCount = headerInfo.headerByteCount; - var size = header.nx * header.ny * header.nz; - var dv = new DataView(bin); - var data = new Float32Array(size); - for (var i = 0; i < size; ++i) { - data[i] = dv.getFloat64(i * 8 + headerByteCount, true); - } - this.volume.setData(data, header.nz, header.ny, header.nx); - if (Debug) - { Log.timeEnd('DxbinParser._parse ' + this.name); } - }; - - Object.defineProperties( DxbinParser.prototype, prototypeAccessors ); - - return DxbinParser; -}(DxParser)); -ParserRegistry$1.add('dxbin', DxbinParser); - -/** - * @file Mrc Parser - * @author Alexander Rose - * @private - */ -var MrcParser = /*@__PURE__*/(function (VolumeParser$$1) { - function MrcParser () { - VolumeParser$$1.apply(this, arguments); - } - - if ( VolumeParser$$1 ) MrcParser.__proto__ = VolumeParser$$1; - MrcParser.prototype = Object.create( VolumeParser$$1 && VolumeParser$$1.prototype ); - MrcParser.prototype.constructor = MrcParser; - - var prototypeAccessors = { type: { configurable: true },isBinary: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'mrc'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - MrcParser.prototype._parse = function _parse () { - // MRC - // http://ami.scripps.edu/software/mrctools/mrc_specification.php - // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image - // http://bio3d.colorado.edu/imod/doc/mrc_format.txt - // CCP4 (MAP) - // http://www.ccp4.ac.uk/html/maplib.html - // MRC format does not use the skew transformation header records (words 25-37) - // CCP4 format does not use the ORIGIN header records (words 50-52) - if (Debug) - { Log.time('MrcParser._parse ' + this.name); } - var v = this.volume; - var header = {}; - var bin = ensureBuffer(this.streamer.data); - var intView = new Int32Array(bin, 0, 56); - var floatView = new Float32Array(bin, 0, 56); - var dv = new DataView(bin); - // 53 MAP Character string 'MAP ' to identify file type - header.MAP = String.fromCharCode(dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1), dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)); - // 54 MACHST Machine stamp indicating machine type which wrote file - // 17 and 17 for big-endian or 68 and 65 for little-endian - header.MACHST = [dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1)]; - // swap byte order when big endian - if (header.MACHST[0] === 17 && header.MACHST[1] === 17) { - var n = bin.byteLength; - for (var i = 0; i < n; i += 4) { - dv.setFloat32(i, dv.getFloat32(i), true); - } - } - header.NX = intView[0]; // NC - columns (fastest changing) - header.NY = intView[1]; // NR - rows - header.NZ = intView[2]; // NS - sections (slowest changing) - // mode - // 0 image : signed 8-bit bytes range -128 to 127 - // 1 image : 16-bit halfwords - // 2 image : 32-bit reals - // 3 transform : complex 16-bit integers - // 4 transform : complex 32-bit reals - // 6 image : unsigned 16-bit range 0 to 65535 - // 16 image: unsigned char * 3 (for rgb data, non-standard) - // - // Note: Mode 2 is the normal mode used in the CCP4 programs. - // Other modes than 2 and 0 may NOT WORK - header.MODE = intView[3]; - // start - header.NXSTART = intView[4]; // NCSTART - first column - header.NYSTART = intView[5]; // NRSTART - first row - header.NZSTART = intView[6]; // NSSTART - first section - // intervals - header.MX = intView[7]; // intervals along x - header.MY = intView[8]; // intervals along y - header.MZ = intView[9]; // intervals along z - // cell length (Angstroms in CCP4) - header.xlen = floatView[10] * this.voxelSize; - header.ylen = floatView[11] * this.voxelSize; - header.zlen = floatView[12] * this.voxelSize; - // cell angle (Degrees) - header.alpha = floatView[13]; - header.beta = floatView[14]; - header.gamma = floatView[15]; - // axis correspondence (1,2,3 for X,Y,Z) - header.MAPC = intView[16]; // column - header.MAPR = intView[17]; // row - header.MAPS = intView[18]; // section - // density statistics - header.DMIN = floatView[19]; - header.DMAX = floatView[20]; - header.DMEAN = floatView[21]; - // space group number 0 or 1 (default=0) - header.ISPG = intView[22]; - // number of bytes used for symmetry data (0 or 80) - header.NSYMBT = intView[23]; - // Flag for skew transformation, =0 none, =1 if foll - header.LSKFLG = intView[24]; - // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if - // LSKFLG .ne. 0. - // 35-37 SKWTRN Skew translation t if LSKFLG != 0. - // Skew transformation is from standard orthogonal - // coordinate frame (as used for atoms) to orthogonal - // map frame, as Xo(map) = S * (Xo(atoms) - t) - // 38 future use (some of these are used by the MSUBSX routines - // . " in MAPBRICK, MAPCONT and FRODO) - // . " (all set to zero by default) - // . " - // 52 " - // 50-52 origin in X,Y,Z used for transforms - header.originX = floatView[49]; - header.originY = floatView[50]; - header.originZ = floatView[51]; - // 53 MAP Character string 'MAP ' to identify file type - // => see top of this parser - // 54 MACHST Machine stamp indicating machine type which wrote file - // => see top of this parser - // Rms deviation of map from mean density - header.ARMS = floatView[54]; - // 56 NLABL Number of labels being used - // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format) - v.header = header; - // Log.log( header ); - var data; - if (header.MODE === 2) { - data = new Float32Array(bin, 256 * 4 + header.NSYMBT, header.NX * header.NY * header.NZ); - } - else if (header.MODE === 0) { - data = new Float32Array(new Int8Array(bin, 256 * 4 + header.NSYMBT, header.NX * header.NY * header.NZ)); - // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr) - // if the file was converted by mapmode2to0 - scale the data - if (intView[39] === -128 && intView[40] === 127) { - // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max - var b1 = (header.DMAX - header.DMIN) / 255.0; - var b0 = 0.5 * (header.DMIN + header.DMAX + b1); - for (var j = 0, jl = data.length; j < jl; ++j) { - data[j] = b1 * data[j] + b0; - } - } - } - else { - Log.error('MrcParser unknown mode', header.MODE); - } - v.setData(data, header.NX, header.NY, header.NZ); - if (header.ARMS !== 0) { - v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS); - } - if (Debug) - { Log.timeEnd('MrcParser._parse ' + this.name); } - }; - MrcParser.prototype.getMatrix = function getMatrix () { - var h = this.volume.header; - var basisX = [ - h.xlen, - 0, - 0 - ]; - var basisY = [ - h.ylen * Math.cos(Math.PI / 180.0 * h.gamma), - h.ylen * Math.sin(Math.PI / 180.0 * h.gamma), - 0 - ]; - var basisZ = [ - h.zlen * Math.cos(Math.PI / 180.0 * h.beta), - h.zlen * (Math.cos(Math.PI / 180.0 * h.alpha) - - Math.cos(Math.PI / 180.0 * h.gamma) * - Math.cos(Math.PI / 180.0 * h.beta)) / Math.sin(Math.PI / 180.0 * h.gamma), - 0 - ]; - basisZ[2] = Math.sqrt(h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) * - Math.sin(Math.PI / 180.0 * h.beta) - basisZ[1] * basisZ[1]); - var basis = [[], basisX, basisY, basisZ]; - var nxyz = [0, h.MX, h.MY, h.MZ]; - var mapcrs = [0, h.MAPC, h.MAPR, h.MAPS]; - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - matrix.set(basis[mapcrs[1]][0] / nxyz[mapcrs[1]], basis[mapcrs[2]][0] / nxyz[mapcrs[2]], basis[mapcrs[3]][0] / nxyz[mapcrs[3]], 0, basis[mapcrs[1]][1] / nxyz[mapcrs[1]], basis[mapcrs[2]][1] / nxyz[mapcrs[2]], basis[mapcrs[3]][1] / nxyz[mapcrs[3]], 0, basis[mapcrs[1]][2] / nxyz[mapcrs[1]], basis[mapcrs[2]][2] / nxyz[mapcrs[2]], basis[mapcrs[3]][2] / nxyz[mapcrs[3]], 0, 0, 0, 0, 1); - matrix.setPosition(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](h.originX, h.originY, h.originZ)); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeTranslation(h.NXSTART, h.NYSTART, h.NZSTART)); - return matrix; - }; - - Object.defineProperties( MrcParser.prototype, prototypeAccessors ); - - return MrcParser; -}(VolumeParser)); -ParserRegistry$1.add('mrc', MrcParser); -ParserRegistry$1.add('ccp4', MrcParser); -ParserRegistry$1.add('map', MrcParser); - -/** - * @file Xplor Parser - * @author Alexander Rose - * @private - */ -var reWhitespace$7 = /\s+/; -function parseNumberLine(line) { - return line.trim().split(reWhitespace$7).map(parseFloat); -} -var XplorParser = /*@__PURE__*/(function (VolumeParser$$1) { - function XplorParser () { - VolumeParser$$1.apply(this, arguments); - } - - if ( VolumeParser$$1 ) XplorParser.__proto__ = VolumeParser$$1; - XplorParser.prototype = Object.create( VolumeParser$$1 && VolumeParser$$1.prototype ); - XplorParser.prototype.constructor = XplorParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'xplor'; }; - XplorParser.prototype._parse = function _parse () { - // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html - // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html - if (Debug) - { Log.time('XplorParser._parse ' + this.name); } - var v = this.volume; - var headerLines = this.streamer.peekLines(8); - var header = {}; - var infoStart; - if (headerLines[2].startsWith('REMARKS')) { - infoStart = parseInt(headerLines[1].substring(0, 8)) + 2; - } - else { - infoStart = 5; - } - var dataStart = infoStart + 3; - var gridInfo = parseNumberLine(headerLines[infoStart]); - header.NA = gridInfo[0]; - header.AMIN = gridInfo[1]; - header.AMAX = gridInfo[2]; - header.NB = gridInfo[3]; - header.BMIN = gridInfo[4]; - header.BMAX = gridInfo[5]; - header.NC = gridInfo[6]; - header.CMIN = gridInfo[7]; - header.CMAX = gridInfo[8]; - var cellInfo = parseNumberLine(headerLines[infoStart + 1]); - header.a = cellInfo[0] * this.voxelSize; - header.b = cellInfo[1] * this.voxelSize; - header.c = cellInfo[2] * this.voxelSize; - header.alpha = cellInfo[3]; - header.beta = cellInfo[4]; - header.gamma = cellInfo[5]; - var na = header.AMAX - header.AMIN + 1; - var nb = header.BMAX - header.BMIN + 1; - var nc = header.CMAX - header.CMIN + 1; - var n = na * nb * nc; - var data = new Float32Array(n); - var lineSection = Math.ceil(1 + (na * nb) / 6); - var count = 0; - var lineNo = 0; - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i]; - if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) { - for (var j = 0, lj = 6; j < lj; ++j) { - var value = parseFloat(line.substr(12 * j, 12)); - if (isNaN(value)) { - break; - } // Last line of map section - data[count++] = value; - } - } - else if (count === n) { - var lt = line.trim(); - if (lt && lt !== '-9999') { - var ls = parseNumberLine(line); - header.RAVE = ls[0]; - header.RSIGMA = ls[1]; - } - } - ++lineNo; - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - v.header = header; - v.setData(data, na, nb, nc); - if (header.RAVE !== 0 && header.RSIGMA !== 1) { - v.setStats(undefined, undefined, header.RAVE, header.RSIGMA); - } - if (Debug) - { Log.timeEnd('XplorParser._parse ' + this.name); } - }; - XplorParser.prototype.getMatrix = function getMatrix () { - var h = this.volume.header; - var basisX = [ - h.a, - 0, - 0 - ]; - var basisY = [ - h.b * Math.cos(Math.PI / 180.0 * h.gamma), - h.b * Math.sin(Math.PI / 180.0 * h.gamma), - 0 - ]; - var basisZ = [ - h.c * Math.cos(Math.PI / 180.0 * h.beta), - h.c * (Math.cos(Math.PI / 180.0 * h.alpha) - - Math.cos(Math.PI / 180.0 * h.gamma) * - Math.cos(Math.PI / 180.0 * h.beta)) / Math.sin(Math.PI / 180.0 * h.gamma), - 0 - ]; - basisZ[2] = Math.sqrt(h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) * - Math.sin(Math.PI / 180.0 * h.beta) - basisZ[1] * basisZ[1]); - var basis = [[], basisX, basisY, basisZ]; - var nxyz = [0, h.NA, h.NB, h.NC]; - var mapcrs = [0, 1, 2, 3]; - var matrix = new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */](); - matrix.set(basis[mapcrs[1]][0] / nxyz[mapcrs[1]], basis[mapcrs[2]][0] / nxyz[mapcrs[2]], basis[mapcrs[3]][0] / nxyz[mapcrs[3]], 0, basis[mapcrs[1]][1] / nxyz[mapcrs[1]], basis[mapcrs[2]][1] / nxyz[mapcrs[2]], basis[mapcrs[3]][1] / nxyz[mapcrs[3]], 0, basis[mapcrs[1]][2] / nxyz[mapcrs[1]], basis[mapcrs[2]][2] / nxyz[mapcrs[2]], basis[mapcrs[3]][2] / nxyz[mapcrs[3]], 0, 0, 0, 0, 1); - matrix.multiply(new __WEBPACK_IMPORTED_MODULE_0_three__["y" /* Matrix4 */]().makeTranslation(h.AMIN, h.BMIN, h.CMIN)); - return matrix; - }; - - Object.defineProperties( XplorParser.prototype, prototypeAccessors ); - - return XplorParser; -}(VolumeParser)); -ParserRegistry$1.add('xplor', XplorParser); -ParserRegistry$1.add('cns', XplorParser); - -/** - * @file Kin Parser - * @author Alexander Rose - * @private - */ -function hsvToRgb(h, s, v) { - h /= 360; - s /= 100; - v /= 100; - var r, g, b; - var i = Math.floor(h * 6); - var f = h * 6 - i; - var p = v * (1 - s); - var q = v * (1 - f * s); - var t = v * (1 - (1 - f) * s); - switch (i % 6) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - case 5: - r = v; - g = p; - b = q; - break; - } - return [r, g, b]; -} -var ColorDict = { - red: hsvToRgb(0, 100, 100), - orange: hsvToRgb(20, 100, 100), - gold: hsvToRgb(40, 100, 100), - yellow: hsvToRgb(60, 100, 100), - lime: hsvToRgb(80, 100, 100), - green: hsvToRgb(120, 80, 100), - sea: hsvToRgb(150, 100, 100), - cyan: hsvToRgb(180, 100, 85), - sky: hsvToRgb(210, 75, 95), - blue: hsvToRgb(240, 70, 100), - purple: hsvToRgb(275, 75, 100), - magenta: hsvToRgb(300, 95, 100), - hotpink: hsvToRgb(335, 100, 100), - pink: hsvToRgb(350, 55, 100), - peach: hsvToRgb(25, 75, 100), - lilac: hsvToRgb(275, 55, 100), - pinktint: hsvToRgb(340, 30, 100), - peachtint: hsvToRgb(25, 50, 100), - yellowtint: hsvToRgb(60, 50, 100), - greentint: hsvToRgb(135, 40, 100), - bluetint: hsvToRgb(220, 40, 100), - lilactint: hsvToRgb(275, 35, 100), - white: hsvToRgb(0, 0, 100), - gray: hsvToRgb(0, 0, 50), - brown: hsvToRgb(20, 45, 75), - deadwhite: [1, 1, 1], - deadblack: [0, 0, 0], - invisible: [0, 0, 0] -}; -var reWhitespaceComma = /[\s,]+/; -var reCurlyWhitespace = /[^{}\s]*{[^{}]+}|[^{}\s]+/g; -var reTrimCurly = /^{+|}+$/g; -var reTrimQuotes$1 = /^['"]+|['"]+$/g; -var reCollapseEqual = /\s*=\s*/g; -function parseListDef(line) { - var name; - var defaultColor; - var master = []; - var width; - line = line.replace(reCollapseEqual, '='); - var lm = line.match(reCurlyWhitespace); - for (var j = 1; j < lm.length; ++j) { - var e = lm[j]; - if (e[0] === '{') { - name = e.substring(1, e.length - 1); - } - else { - var es = e.split('='); - if (es.length === 2) { - if (es[0] === 'color') { - defaultColor = ColorDict[es[1]]; - } - else if (es[0] === 'width') { - width = parseInt(es[1]); - } - else if (es[0] === 'master') { - master.push(es[1].replace(reTrimCurly, '')); - } - } - } - } - return { - listName: name, - listColor: defaultColor, - listMasters: master, - listWidth: width - }; -} -function parseListElm(line) { - line = line.trim(); - var idx1 = line.indexOf('{'); - var idx2 = line.indexOf('}'); - var ls = line.substr(idx2 + 1).split(reWhitespaceComma); - var label = line.substr(idx1 + 1, idx2 - 1); - var position = [ - parseFloat(ls[ls.length - 3]), - parseFloat(ls[ls.length - 2]), - parseFloat(ls[ls.length - 1]) - ]; - var color, width, radius; - var lineBreak = false; - var triangleBreak = false; - for (var lsindex = 4; lsindex <= ls.length; lsindex++) { - var literal = ls[ls.length - lsindex]; - if (literal in ColorDict) { - color = ColorDict[ls[ls.length - lsindex]]; - } - if (literal.startsWith('width')) { - width = parseInt(literal.substring(5)); - } - if (literal.startsWith('r=')) { - radius = parseFloat(literal.split('=')[1]); - } - if (literal.startsWith('P')) { - lineBreak = true; - } - if (literal.startsWith('X')) { - triangleBreak = true; - } - } - // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ] - return { - label: label, - position: position, - color: color, - radius: radius, - width: width, - isLineBreak: lineBreak, - isTriangleBreak: triangleBreak - }; -} -function parseStr(line) { - var start = line.indexOf('{'); - var end = line.indexOf('}'); - return line.substring(start !== -1 ? start + 1 : 0, end !== -1 ? end : undefined).trim(); -} -function parseFlag(line) { - var end = line.indexOf('}'); - return end === -1 ? undefined : line.substr(end + 1).trim(); -} -function parseGroup(line) { - var name = ''; - var master = []; - var flags = {}; - line = line.replace(reCollapseEqual, '='); - var lm = line.match(reCurlyWhitespace); - for (var j = 1; j < lm.length; ++j) { - var e = lm[j]; - if (e[0] === '{') { - name = e.substring(1, e.length - 1); - } - else { - var es = e.split('='); - if (es.length === 2) { - if (es[0] === 'master') { - master.push(es[1].replace(reTrimCurly, '')); - } - else { - flags[es[0]] = es[1].replace(reTrimCurly, ''); - } - } - else { - flags[es[0]] = true; - } - } - } - return { groupName: name, - groupFlags: flags, - groupMasters: master - }; -} -function convertKinTriangleArrays(ribbonObject) { - // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode - // index [ 0 1 2 3 4 5 6 7 8 91011 ] - // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ] - // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ] - // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ] - // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ] - var labelArray = ribbonObject.labelArray; - var positionArray = ribbonObject.positionArray; - var colorArray = ribbonObject.colorArray; - var breakArray = ribbonObject.breakArray; - var convertedLabels = []; - for (var i = 0; i < (labelArray.length - 2) * 3; ++i) { - convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]; - } - var convertedBreaks = []; - for (var i$1 = 0; i$1 < (breakArray.length - 2) * 3; ++i$1) { - convertedBreaks[i$1] = breakArray[i$1 - Math.floor(i$1 / 3) * 2]; - } - var convertedPositions = []; - for (var i$2 = 0; i$2 < (positionArray.length / 3 - 2) * 9; ++i$2) { - convertedPositions[i$2] = positionArray[i$2 - Math.floor(i$2 / 9) * 6]; - } - var convertedColors = []; - for (var i$3 = 0; i$3 < (colorArray.length / 3 - 2) * 9; ++i$3) { - convertedColors[i$3] = colorArray[i$3 - Math.floor(i$3 / 9) * 6]; - } - var vector3Positions = []; - for (var i$4 = 0; i$4 < (convertedPositions.length) / 3; ++i$4) { - vector3Positions.push(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](convertedPositions[i$4 * 3], convertedPositions[i$4 * 3] + 1, convertedPositions[i$4 * 3] + 2)); - } - //let normals = [] - //for (let i = 0; i < vector3Positions.length - 1; ++i) { - // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1]) - // normals.push(normalVec3.x) - // normals.push(normalVec3.y) - // normals.push(normalVec3.z) - //} - return { - name: ribbonObject.name, - masterArray: ribbonObject.masterArray, - labelArray: convertedLabels, - positionArray: convertedPositions, - breakArray: convertedBreaks, - colorArray: convertedColors - }; -} -function removePointBreaksTriangleArrays(convertedRibbonObject) { - // after converting ribbon/triangle arrys to drawmode, removed point break triangles - // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ] - // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ] - var labelArray = convertedRibbonObject.labelArray; - var positionArray = convertedRibbonObject.positionArray; - var colorArray = convertedRibbonObject.colorArray; - var breakArray = convertedRibbonObject.breakArray; - var editedLabels = []; - var editedPositions = []; - var editedColors = []; - var editedBreaks = []; - for (var i = 0; i < breakArray.length / 3; i++) { - var breakPointer = i * 3; - var positionPointer = i * 9; - if (!breakArray[breakPointer + 1] && !breakArray[breakPointer + 2]) { - editedLabels.push(labelArray[breakPointer]); - editedLabels.push(labelArray[breakPointer + 1]); - editedLabels.push(labelArray[breakPointer + 2]); - editedBreaks.push(breakArray[breakPointer]); - editedBreaks.push(breakArray[breakPointer + 1]); - editedBreaks.push(breakArray[breakPointer + 2]); - editedPositions.push(positionArray[positionPointer]); - editedPositions.push(positionArray[positionPointer + 1]); - editedPositions.push(positionArray[positionPointer + 2]); - editedPositions.push(positionArray[positionPointer + 3]); - editedPositions.push(positionArray[positionPointer + 4]); - editedPositions.push(positionArray[positionPointer + 5]); - editedPositions.push(positionArray[positionPointer + 6]); - editedPositions.push(positionArray[positionPointer + 7]); - editedPositions.push(positionArray[positionPointer + 8]); - editedColors.push(colorArray[positionPointer]); - editedColors.push(colorArray[positionPointer + 1]); - editedColors.push(colorArray[positionPointer + 2]); - editedColors.push(colorArray[positionPointer + 3]); - editedColors.push(colorArray[positionPointer + 4]); - editedColors.push(colorArray[positionPointer + 5]); - editedColors.push(colorArray[positionPointer + 6]); - editedColors.push(colorArray[positionPointer + 7]); - editedColors.push(colorArray[positionPointer + 8]); - } - } - return { - name: convertedRibbonObject.name, - masterArray: convertedRibbonObject.masterArray, - labelArray: editedLabels, - positionArray: editedPositions, - breakArray: editedBreaks, - colorArray: editedColors - }; -} -var KinParser = /*@__PURE__*/(function (Parser$$1) { - function KinParser () { - Parser$$1.apply(this, arguments); - } - - if ( Parser$$1 ) KinParser.__proto__ = Parser$$1; - KinParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - KinParser.prototype.constructor = KinParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'kin'; }; - prototypeAccessors.__objName.get = function () { return 'kinemage'; }; - KinParser.prototype._parse = function _parse () { - // http://kinemage.biochem.duke.edu/software/king.php - if (Debug) - { Log.time(("KinParser._parse " + (this.name))); } - var kinemage = { - kinemage: undefined, - onewidth: undefined, - '1viewid': undefined, - pdbfile: undefined, - texts: [], - text: '', - captions: [], - caption: '', - groupDict: {}, - subgroupDict: {}, - masterDict: {}, - pointmasterDict: {}, - dotLists: [], - vectorLists: [], - ballLists: [], - ribbonLists: [] - }; - this.kinemage = kinemage; - var currentGroupMasters; - var currentSubgroupMasters; - var isDotList = false; - var prevDotLabel = ''; - var dotDefaultColor; - var dotLabel, dotPosition, dotColor; - var isVectorList = false; - var prevVecLabel = ''; - var prevVecPosition = null; - var prevVecColor = null; - var vecDefaultColor, vecDefaultWidth; - var vecLabel1, vecLabel2, vecPosition1, vecPosition2, vecColor1, vecColor2; - var isBallList = false; - var prevBallLabel = ''; - var ballRadius, ballDefaultColor; - var ballLabel, ballPosition, ballColor; - var isRibbonList = false; - var prevRibbonPointLabel = ''; - var ribbonListDefaultColor; - var ribbonPointLabelArray, ribbonPointPositionArray, ribbonPointBreakArray, ribbonPointColorArray; - var isText = false; - var isCaption = false; - // @vectorlist {mc} color= white master= {mainchain} - // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625 - // @dotlist {x} color=white master={vdw contact} master={dots} - // { CB THR 1 A}sky 'P' 18.915,14.199,5.024 - function _parseChunkOfLines(_i, _n, lines) { - for (var i = _i; i < _n; ++i) { - var line = lines[i]; - if (line[0] === '@') { - isDotList = false; - isVectorList = false; - isBallList = false; - isRibbonList = false; - isText = false; - isCaption = false; - } - if (!line) { - isDotList = false; - isVectorList = false; - isBallList = false; - isRibbonList = false; - } - else if (line.startsWith('@dotlist')) { - // @dotlist {x} color=white master={vdw contact} master={dots} - var ref = parseListDef(line); - var listColor = ref.listColor; - var listName = ref.listName; - var listMasters = ref.listMasters; - isDotList = true; - prevDotLabel = ''; - dotLabel = []; - dotPosition = []; - dotColor = []; - dotDefaultColor = listColor; - if (currentGroupMasters) { - listMasters = listMasters.concat(currentGroupMasters); - } - if (currentSubgroupMasters) { - listMasters = listMasters.concat(currentSubgroupMasters); - } - kinemage.dotLists.push({ - name: listName, - masterArray: listMasters, - labelArray: dotLabel, - positionArray: dotPosition, - colorArray: dotColor - }); - } - else if (line.startsWith('@vectorlist')) { - // @vectorlist {x} color=white master={small overlap} master={dots} - var ref$1 = parseListDef(line); - var listMasters$1 = ref$1.listMasters; - var listName$1 = ref$1.listName; - var listWidth = ref$1.listWidth; - var listColor$1 = ref$1.listColor; - if (listMasters$1) { - listMasters$1.forEach(function (name) { - if (!kinemage.masterDict[name]) { - kinemage.masterDict[name] = { - indent: false, - visible: false - }; - } - }); - } - isVectorList = true; - prevVecLabel = ''; - prevVecPosition = null; - prevVecColor = null; - vecLabel1 = []; - vecLabel2 = []; - vecPosition1 = []; - vecPosition2 = []; - vecColor1 = []; - vecColor2 = []; - vecDefaultColor = listColor$1; - vecDefaultWidth = []; - if (listWidth) { - vecDefaultWidth.push(listWidth); - } - if (currentGroupMasters) { - listMasters$1 = listMasters$1.concat(currentGroupMasters); - } - if (currentSubgroupMasters) { - listMasters$1 = listMasters$1.concat(currentSubgroupMasters); - } - kinemage.vectorLists.push({ - name: listName$1, - masterArray: listMasters$1, - label1Array: vecLabel1, - label2Array: vecLabel2, - position1Array: vecPosition1, - position2Array: vecPosition2, - color1Array: vecColor1, - color2Array: vecColor2, - width: vecDefaultWidth - }); - } - else if (line.startsWith('@balllist')) { - var ref$2 = parseListDef(line); - var listName$2 = ref$2.listName; - var listColor$2 = ref$2.listColor; - var listMasters$2 = ref$2.listMasters; - if (listMasters$2) { - listMasters$2.forEach(function (name) { - if (!kinemage.masterDict[name]) { - kinemage.masterDict[name] = { - indent: false, - visible: false - }; - } - }); - } - isBallList = true; - prevBallLabel = ''; - ballLabel = []; - ballRadius = []; - ballPosition = []; - ballColor = []; - ballDefaultColor = listColor$2; - if (currentGroupMasters) { - listMasters$2 = listMasters$2.concat(currentGroupMasters); - } - if (currentSubgroupMasters) { - listMasters$2 = listMasters$2.concat(currentSubgroupMasters); - } - kinemage.ballLists.push({ - name: listName$2, - masterArray: listMasters$2, - labelArray: ballLabel, - radiusArray: ballRadius, - positionArray: ballPosition, - colorArray: ballColor - }); - } - else if (line.startsWith('@ribbonlist') || line.startsWith('@trianglelist')) { - var ref$3 = parseListDef(line); - var listMasters$3 = ref$3.listMasters; - var listName$3 = ref$3.listName; - var listColor$3 = ref$3.listColor; - if (listMasters$3) { - listMasters$3.forEach(function (name) { - if (!kinemage.masterDict[name]) { - kinemage.masterDict[name] = { - indent: false, - visible: false - }; - } - }); - } - isRibbonList = true; - prevRibbonPointLabel = ''; - ribbonPointLabelArray = []; - ribbonPointPositionArray = []; - ribbonPointBreakArray = []; - ribbonPointColorArray = []; - ribbonListDefaultColor = listColor$3; - if (currentGroupMasters) { - listMasters$3 = listMasters$3.concat(currentGroupMasters); - } - if (currentSubgroupMasters) { - listMasters$3 = listMasters$3.concat(currentSubgroupMasters); - } - kinemage.ribbonLists.push({ - name: listName$3, - masterArray: listMasters$3, - labelArray: ribbonPointLabelArray, - positionArray: ribbonPointPositionArray, - breakArray: ribbonPointBreakArray, - colorArray: ribbonPointColorArray - }); - } - else if (line.startsWith('@text')) { - isText = true; - kinemage.texts.push(line.substr(5)); - } - else if (line.startsWith('@caption')) { - isCaption = true; - kinemage.captions.push(line.substr(8)); - } - else if (isDotList) { - // { CB THR 1 A}sky 'P' 18.915,14.199,5.024 - var ref$4 = parseListElm(line); - var label = ref$4.label; - var color = ref$4.color; - var position = ref$4.position; - if (label === '"') { - label = prevDotLabel; - } - else { - prevDotLabel = label; - } - if (color === undefined) { - color = dotDefaultColor; - } - dotLabel.push(label); - dotPosition.push.apply(dotPosition, position); - dotColor.push.apply(dotColor, color); - } - else if (isVectorList) { - // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625 - var doubleLine = line.replace(/(?!^){/g, '\n{'); - var splitLine = doubleLine.split(/\n/); - for (var i2 = 0; i2 < splitLine.length; i2++) { - var singlePointLine = splitLine[i2]; - var ref$5 = parseListElm(singlePointLine); - var label$1 = ref$5.label; - var color$1 = ref$5.color; - var width = ref$5.width; - var position$1 = ref$5.position; - var isLineBreak = ref$5.isLineBreak; - if (label$1 === '"') { - label$1 = prevVecLabel; - } - else { - prevVecLabel = label$1; - } - if (color$1 === undefined) { - color$1 = vecDefaultColor; - } - if (!isLineBreak) { - if (prevVecPosition !== null) { - if (width) { - vecDefaultWidth.push(width); - } - vecLabel1.push(prevVecLabel); - vecPosition1.push.apply(vecPosition1, prevVecPosition); - vecColor1.push.apply(vecColor1, prevVecColor); - vecLabel2.push(label$1); - vecPosition2.push.apply(vecPosition2, position$1); - vecColor2.push.apply(vecColor2, color$1); - } - } - prevVecLabel = label$1; - prevVecPosition = position$1; - prevVecColor = color$1; - } - } - else if (isBallList) { - // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182 - var ref$6 = parseListElm(line); - var label$2 = ref$6.label; - var radius = ref$6.radius; - var color$2 = ref$6.color; - var position$2 = ref$6.position; - if (label$2 === '"') { - label$2 = prevBallLabel; - } - else { - prevBallLabel = label$2; - } - if (radius === undefined) { - radius = 1; // temporary default radius - } - if (color$2 === undefined) { - color$2 = ballDefaultColor; - } - ballLabel.push(label$2); - ballRadius.push(radius); - ballPosition.push.apply(ballPosition, position$2); - ballColor.push.apply(ballColor, color$2); - } - else if (isRibbonList) { - var ref$7 = parseListElm(line); - var label$3 = ref$7.label; - var color$3 = ref$7.color; - var position$3 = ref$7.position; - var isTriangleBreak = ref$7.isTriangleBreak; - if (label$3 === '"') { - label$3 = prevRibbonPointLabel; - } - else { - prevRibbonPointLabel = label$3; - } - if (color$3 === undefined) { - color$3 = ribbonListDefaultColor; - } - ribbonPointLabelArray.push(label$3); - ribbonPointPositionArray.push.apply(ribbonPointPositionArray, position$3); - ribbonPointBreakArray.push(isTriangleBreak); - ribbonPointColorArray.push.apply(ribbonPointColorArray, color$3); - } - else if (isText) { - kinemage.texts.push(line); - } - else if (isCaption) { - kinemage.captions.push(line); - } - else if (line.startsWith('@kinemage')) { - kinemage.kinemage = parseInt(line.substr(9).trim()); - } - else if (line.startsWith('@onewidth')) { - kinemage.onewidth = true; - } - else if (line.startsWith('@1viewid')) { - kinemage['1viewid'] = parseStr(line); - } - else if (line.startsWith('@pdbfile')) { - kinemage.pdbfile = parseStr(line); - } - else if (line.startsWith('@group')) { - var ref$8 = parseGroup(line); - var groupName = ref$8.groupName; - var groupFlags = ref$8.groupFlags; - var groupMasters = ref$8.groupMasters; - if (!kinemage.groupDict[groupName]) { - kinemage.groupDict[groupName] = { - dominant: false, - animate: false - }; - currentGroupMasters = groupMasters; - } - if (currentGroupMasters) { - currentGroupMasters.forEach(function (master) { - if (!kinemage.masterDict[master]) { - kinemage.masterDict[master] = { - indent: false, - visible: false - }; - } - }); - } - for (var key in groupFlags) { - kinemage.groupDict[groupName][key] = groupFlags[key]; - } - } - else if (line.startsWith('@subgroup')) { - var ref$9 = parseGroup(line); - var groupName$1 = ref$9.groupName; - var groupFlags$1 = ref$9.groupFlags; - var groupMasters$1 = ref$9.groupMasters; - if (!kinemage.subgroupDict[groupName$1]) { - kinemage.subgroupDict[groupName$1] = { - dominant: false, - animate: false - }; - currentSubgroupMasters = groupMasters$1; - } - if (currentSubgroupMasters) { - currentSubgroupMasters.forEach(function (master) { - if (!kinemage.masterDict[master]) { - kinemage.masterDict[master] = { - indent: false, - visible: false - }; - } - }); - } - for (var key$1 in groupFlags$1) { - kinemage.subgroupDict[groupName$1][key$1] = groupFlags$1[key$1]; - } - } - else if (line.startsWith('@master')) { - var name = parseStr(line); - var flag = parseFlag(line); - if (!kinemage.masterDict[name]) { - kinemage.masterDict[name] = { - indent: false, - visible: false - }; - } - if (flag === 'on') { - kinemage.masterDict[name].visible = true; - } - else if (flag === 'off') { - kinemage.masterDict[name].visible = false; - } - else if (flag === 'indent') { - kinemage.masterDict[name].indent = true; - } - } - else if (line.startsWith('@pointmaster')) { - var ref$10 = parseGroup(line); - var groupName$2 = ref$10.groupName; - var groupFlags$2 = ref$10.groupFlags; - kinemage.pointmasterDict[groupName$2] = { - id: Object.keys(groupFlags$2)[0].replace(reTrimQuotes$1, '') - }; - } - else { - console.log(line); - } - } - } - this.streamer.eachChunkOfLines(function (lines /*, chunkNo, chunkCount */) { - _parseChunkOfLines(0, lines.length, lines); - }); - kinemage.text = kinemage.texts.join('\n').trim(); - kinemage.caption = kinemage.captions.join('\n').trim(); - if (kinemage.ribbonLists) { - var convertedLists = []; - kinemage.ribbonLists.forEach(function (listObject) { - convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject))); - }); - kinemage.ribbonLists = convertedLists; - } - if (Debug) - { Log.timeEnd(("KinParser._parse " + (this.name))); } - }; - - Object.defineProperties( KinParser.prototype, prototypeAccessors ); - - return KinParser; -}(Parser)); -ParserRegistry$1.add('kin', KinParser); - -/** - * @file Surface Parser - * @author Alexander Rose - * @private - */ -var SurfaceParser = /*@__PURE__*/(function (Parser$$1) { - function SurfaceParser(streamer, params) { - Parser$$1.call(this, streamer, params); - this.loader = this.getLoader(); - this.surface = new Surface(this.name, this.path); - } - - if ( Parser$$1 ) SurfaceParser.__proto__ = Parser$$1; - SurfaceParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - SurfaceParser.prototype.constructor = SurfaceParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'surface'; }; - prototypeAccessors.__objName.get = function () { return 'surface'; }; - SurfaceParser.prototype._parse = function _parse () { - var geometry = this.loader.parse(this.streamer.asText()); - this.surface.fromGeometry(geometry); - }; - - Object.defineProperties( SurfaceParser.prototype, prototypeAccessors ); - - return SurfaceParser; -}(Parser)); - -/** - * @file Obj Parser - * @author Alexander Rose - * @private - */ -/** - * OBJLoader - * @class - * @private - * @author mrdoob / http://mrdoob.com/ - */ -var OBJLoader = (function OBJLoader() { - this.regexp = { - // v float float float - vertex_pattern: /^v\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/, - // vn float float float - normal_pattern: /^vn\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/, - // vt float float - uv_pattern: /^vt\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/, - // f vertex vertex vertex - face_vertex: /^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/, - // f vertex/uv vertex/uv vertex/uv - face_vertex_uv: /^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/, - // f vertex/uv/normal vertex/uv/normal vertex/uv/normal - face_vertex_uv_normal: /^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/, - // f vertex//normal vertex//normal vertex//normal - face_vertex_normal: /^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/, - // o object_name | g group_name - object_pattern: /^[og]\s*(.+)?/, - // s boolean - smoothing_pattern: /^s\s+(\d+|on|off)/, - // mtllib file_reference - material_library_pattern: /^mtllib /, - // usemtl material_name - material_use_pattern: /^usemtl / - }; -}); -OBJLoader.prototype = { - constructor: OBJLoader, - setPath: function (value) { - this.path = value; - }, - _createParserState: function () { - var state = { - objects: [], - object: {}, - vertices: [], - normals: [], - startObject: function (name, fromDeclaration) { - // If the current object (initial from reset) is not from a g/o declaration in the parsed - // file. We need to use it for the first parsed g/o to keep things in sync. - if (this.object && this.object.fromDeclaration === false) { - this.object.name = name; - this.object.fromDeclaration = (fromDeclaration !== false); - return; - } - this.object = { - name: name || '', - geometry: { - vertices: [], - normals: [] - }, - fromDeclaration: (fromDeclaration !== false) - }; - this.objects.push(this.object); - }, - parseVertexIndex: function (value, len) { - var index = parseInt(value, 10); - return (index >= 0 ? index - 1 : index + len / 3) * 3; - }, - parseNormalIndex: function (value, len) { - var index = parseInt(value, 10); - return (index >= 0 ? index - 1 : index + len / 3) * 3; - }, - addVertex: function (a, b, c) { - var src = this.vertices; - var dst = this.object.geometry.vertices; - dst.push(src[a + 0]); - dst.push(src[a + 1]); - dst.push(src[a + 2]); - dst.push(src[b + 0]); - dst.push(src[b + 1]); - dst.push(src[b + 2]); - dst.push(src[c + 0]); - dst.push(src[c + 1]); - dst.push(src[c + 2]); - }, - addVertexLine: function (a) { - var src = this.vertices; - var dst = this.object.geometry.vertices; - dst.push(src[a + 0]); - dst.push(src[a + 1]); - dst.push(src[a + 2]); - }, - addNormal: function (a, b, c) { - var src = this.normals; - var dst = this.object.geometry.normals; - dst.push(src[a + 0]); - dst.push(src[a + 1]); - dst.push(src[a + 2]); - dst.push(src[b + 0]); - dst.push(src[b + 1]); - dst.push(src[b + 2]); - dst.push(src[c + 0]); - dst.push(src[c + 1]); - dst.push(src[c + 2]); - }, - addFace: function (a, b, c, d, na, nb, nc, nd) { - var vLen = this.vertices.length; - var ia = this.parseVertexIndex(a, vLen); - var ib = this.parseVertexIndex(b, vLen); - var ic = this.parseVertexIndex(c, vLen); - var id; - if (d === undefined) { - this.addVertex(ia, ib, ic); - } - else { - id = this.parseVertexIndex(d, vLen); - this.addVertex(ia, ib, id); - this.addVertex(ib, ic, id); - } - if (na !== undefined) { - // Normals are many times the same. If so, skip function call and parseInt. - var nLen = this.normals.length; - ia = this.parseNormalIndex(na, nLen); - ib = na === nb ? ia : this.parseNormalIndex(nb, nLen); - ic = na === nc ? ia : this.parseNormalIndex(nc, nLen); - if (d === undefined) { - this.addNormal(ia, ib, ic); - } - else { - id = this.parseNormalIndex(nd, nLen); - this.addNormal(ia, ib, id); - this.addNormal(ib, ic, id); - } - } - }, - addLineGeometry: function (vertices) { - this.object.geometry.type = 'Line'; - var vLen = this.vertices.length; - for (var vi = 0, l = vertices.length; vi < l; vi++) { - this.addVertexLine(this.parseVertexIndex(vertices[vi], vLen)); - } - } - }; - state.startObject('', false); - return state; - }, - parse: function (text) { - var state = this._createParserState(); - if (text.indexOf('\r\n') !== -1) { - // This is faster than String.split with regex that splits on both - text = text.replace(/\r\n/g, '\n'); - } - if (text.indexOf('\\\n') !== -1) { - // join lines separated by a line continuation character (\) - text = text.replace(/\\\n/g, ''); - } - var i, l; - var lines = text.split('\n'); - var line = ''; - var lineFirstChar = ''; - var lineSecondChar = ''; - var lineLength = 0; - var result = []; - // Faster to just trim left side of the line. Use if available. - var trimLeft = (typeof ''.trimLeft === 'function'); - for (i = 0, l = lines.length; i < l; i++) { - line = lines[i]; - line = trimLeft ? line.trimLeft() : line.trim(); - lineLength = line.length; - if (lineLength === 0) - { continue; } - lineFirstChar = line.charAt(0); - // @todo invoke passed in handler if any - if (lineFirstChar === '#') - { continue; } - if (lineFirstChar === 'v') { - lineSecondChar = line.charAt(1); - if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) { - // 0 1 2 3 - // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"] - state.vertices.push(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])); - } - else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) { - // 0 1 2 3 - // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"] - state.normals.push(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])); - } - else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) ; - else { - throw new Error("Unexpected vertex/normal/uv line: '" + line + "'"); - } - } - else if (lineFirstChar === 'f') { - if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) { - // f vertex/uv/normal vertex/uv/normal vertex/uv/normal - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - // ["f 1/1/1 2/2/2 3/3/3", "1", "1", "1", "2", "2", "2", "3", "3", "3", undefined, undefined, undefined] - state.addFace(result[1], result[4], result[7], result[10], - // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part - result[3], result[6], result[9], result[12]); - } - else if (this.regexp.face_vertex_uv.exec(line) !== null) ; - else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) { - // f vertex//normal vertex//normal vertex//normal - // 0 1 2 3 4 5 6 7 8 - // ["f 1//1 2//2 3//3", "1", "1", "2", "2", "3", "3", undefined, undefined] - state.addFace(result[1], result[3], result[5], result[7], result[2], result[4], result[6], result[8]); - } - else if ((result = this.regexp.face_vertex.exec(line)) !== null) { - // f vertex vertex vertex - // 0 1 2 3 4 - // ["f 1 2 3", "1", "2", "3", undefined] - state.addFace(result[1], result[2], result[3], result[4]); - } - else { - throw new Error("Unexpected face line: '" + line + "'"); - } - } - else if (lineFirstChar === 'l') { - var lineParts = line.substring(1).trim().split(' '); - var lineVertices = []; - var lineUVs = []; - if (line.indexOf('/') === -1) { - lineVertices = lineParts; - } - else { - for (var li = 0, llen = lineParts.length; li < llen; li++) { - var parts = lineParts[li].split('/'); - if (parts[0] !== '') - { lineVertices.push(parts[0]); } - if (parts[1] !== '') - { lineUVs.push(parts[1]); } - } - } - state.addLineGeometry(lineVertices, lineUVs); - } - else if ((result = this.regexp.object_pattern.exec(line)) !== null) { - // o object_name - // or - // g group_name - var name = result[0].substr(1).trim(); - state.startObject(name); - // ignore material related lines - // eslint-disable-next-line no-empty - } - else if (this.regexp.material_use_pattern.test(line)) ; - else if (this.regexp.material_library_pattern.test(line)) ; - else if (this.regexp.smoothing_pattern.exec(line) !== null) ; - else { - // Handle null terminated files without exception - if (line === '\0') - { continue; } - throw new Error("Unexpected line: '" + line + "'"); - } - } - var container = []; - for (i = 0, l = state.objects.length; i < l; i++) { - var object = state.objects[i]; - var geometry = object.geometry; - // Skip o/g line declarations that did not follow with any faces - if (geometry.vertices.length === 0) - { continue; } - var buffergeometry = new __WEBPACK_IMPORTED_MODULE_0_three__["g" /* BufferGeometry */](); - buffergeometry.setAttribute('position', new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](new Float32Array(geometry.vertices), 3)); - if (geometry.normals.length > 0) { - buffergeometry.setAttribute('normal', new __WEBPACK_IMPORTED_MODULE_0_three__["f" /* BufferAttribute */](new Float32Array(geometry.normals), 3)); - } - else { - buffergeometry.computeVertexNormals(); - } - container.push(buffergeometry); - } - return container; - } -}; -var ObjParser = /*@__PURE__*/(function (SurfaceParser$$1) { - function ObjParser () { - SurfaceParser$$1.apply(this, arguments); - } - - if ( SurfaceParser$$1 ) ObjParser.__proto__ = SurfaceParser$$1; - ObjParser.prototype = Object.create( SurfaceParser$$1 && SurfaceParser$$1.prototype ); - ObjParser.prototype.constructor = ObjParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'obj'; }; - ObjParser.prototype.getLoader = function getLoader () { - return new OBJLoader(); - }; - - Object.defineProperties( ObjParser.prototype, prototypeAccessors ); - - return ObjParser; -}(SurfaceParser)); -ParserRegistry$1.add('obj', ObjParser); - -/** - * @file Ply Parser - * @author Alexander Rose - * @private - */ -var PLYLoader = (function PLYLoader() { - this.propertyNameMapping = {}; -}); -PLYLoader.prototype = { - constructor: PLYLoader, - setPropertyNameMapping: function (mapping) { - this.propertyNameMapping = mapping; - }, - bin2str: function (buf) { - var arrayBuffer = new Uint8Array(buf); - var str = ''; - for (var i = 0; i < buf.byteLength; i++) { - str += String.fromCharCode(arrayBuffer[i]); // implicitly assumes little-endian - } - return str; - }, - isASCII: function (data) { - var header = this.parseHeader(this.bin2str(data)); - return header.format === 'ascii'; - }, - parse: function (data) { - if (data instanceof ArrayBuffer) { - return (this.isASCII(data) - ? this.parseASCII(this.bin2str(data)) - : this.parseBinary(data)); - } - else { - return this.parseASCII(data); - } - }, - parseHeader: function (data) { - var patternHeader = /ply([\s\S]*)end_header\s/; - var headerText = ''; - var headerLength = 0; - var result = patternHeader.exec(data); - if (result !== null) { - headerText = result[1]; - headerLength = result[0].length; - } - var header = { - comments: [], - elements: [], - headerLength: headerLength - }; - var lines = headerText.split('\n'); - var currentElement, lineType, lineValues; - function makePlyElementProperty(propertValues, propertyNameMapping) { - var property = { - type: propertValues[0] - }; - if (property.type === 'list') { - property.name = propertValues[3]; - property.countType = propertValues[1]; - property.itemType = propertValues[2]; - } - else { - property.name = propertValues[1]; - } - if (property.name in propertyNameMapping) { - property.name = propertyNameMapping[property.name]; - } - return property; - } - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; - line = line.trim(); - if (line === '') { - continue; - } - lineValues = line.split(/\s+/); - lineType = lineValues.shift(); - line = lineValues.join(' '); - switch (lineType) { - case 'format': - header.format = lineValues[0]; - header.version = lineValues[1]; - break; - case 'comment': - header.comments.push(line); - break; - case 'element': - if (currentElement !== undefined) { - header.elements.push(currentElement); - } - currentElement = {}; - currentElement.name = lineValues[0]; - currentElement.count = parseInt(lineValues[1]); - currentElement.properties = []; - break; - case 'property': - currentElement.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping)); - break; - default: - console.log('unhandled', lineType, lineValues); - } - } - if (currentElement !== undefined) { - header.elements.push(currentElement); - } - return header; - }, - parseASCIINumber: function (n, type) { - switch (type) { - case 'char': - case 'uchar': - case 'short': - case 'ushort': - case 'int': - case 'uint': - case 'int8': - case 'uint8': - case 'int16': - case 'uint16': - case 'int32': - case 'uint32': - return parseInt(n); - case 'float': - case 'double': - case 'float32': - case 'float64': - return parseFloat(n); - } - }, - parseASCIIElement: function (properties, line) { - var values = line.split(/\s+/); - var element = {}; - for (var i = 0; i < properties.length; i++) { - if (properties[i].type === 'list') { - var list = []; - var n = this.parseASCIINumber(values.shift(), properties[i].countType); - for (var j = 0; j < n; j++) { - list.push(this.parseASCIINumber(values.shift(), properties[i].itemType)); - } - element[properties[i].name] = list; - } - else { - element[properties[i].name] = this.parseASCIINumber(values.shift(), properties[i].type); - } - } - return element; - }, - parseASCII: function (data) { - // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format) - var geometry = new __WEBPACK_IMPORTED_MODULE_0_three__["s" /* Geometry */](); - var result; - var header = this.parseHeader(data); - var patternBody = /end_header\s([\s\S]*)$/; - var body = ''; - if ((result = patternBody.exec(data)) !== null) { - body = result[1]; - } - var lines = body.split('\n'); - var currentElement = 0; - var currentElementCount = 0; - geometry.useColor = false; - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; - line = line.trim(); - if (line === '') { - continue; - } - if (currentElementCount >= header.elements[currentElement].count) { - currentElement++; - currentElementCount = 0; - } - var element = this.parseASCIIElement(header.elements[currentElement].properties, line); - this.handleElement(geometry, header.elements[currentElement].name, element); - currentElementCount++; - } - return this.postProcess(geometry); - }, - postProcess: function (geometry) { - if (geometry.useColor) { - for (var i = 0; i < geometry.faces.length; i++) { - geometry.faces[i].vertexColors = [ - geometry.colors[geometry.faces[i].a], - geometry.colors[geometry.faces[i].b], - geometry.colors[geometry.faces[i].c] - ]; - } - geometry.elementsNeedUpdate = true; - } - geometry.computeBoundingSphere(); - return geometry; - }, - handleElement: function (geometry, elementName, element) { - if (elementName === 'vertex') { - geometry.vertices.push(new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](element.x, element.y, element.z)); - if ('red' in element && 'green' in element && 'blue' in element) { - geometry.useColor = true; - var color = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](); - color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0); - geometry.colors.push(color); - } - } - else if (elementName === 'face') { - var vertexIndices = element.vertex_indices; - if (vertexIndices.length === 3) { - geometry.faces.push(new __WEBPACK_IMPORTED_MODULE_0_three__["o" /* Face3 */](vertexIndices[0], vertexIndices[1], vertexIndices[2])); - } - else if (vertexIndices.length === 4) { - geometry.faces.push(new __WEBPACK_IMPORTED_MODULE_0_three__["o" /* Face3 */](vertexIndices[0], vertexIndices[1], vertexIndices[3]), new __WEBPACK_IMPORTED_MODULE_0_three__["o" /* Face3 */](vertexIndices[1], vertexIndices[2], vertexIndices[3])); - } - } - }, - binaryRead: function (dataview, at, type, littleEndian) { - switch (type) { - // corespondences for non-specific length types here match rply: - case 'int8': - case 'char': return [dataview.getInt8(at), 1]; - case 'uint8': - case 'uchar': return [dataview.getUint8(at), 1]; - case 'int16': - case 'short': return [dataview.getInt16(at, littleEndian), 2]; - case 'uint16': - case 'ushort': return [dataview.getUint16(at, littleEndian), 2]; - case 'int32': - case 'int': return [dataview.getInt32(at, littleEndian), 4]; - case 'uint32': - case 'uint': return [dataview.getUint32(at, littleEndian), 4]; - case 'float32': - case 'float': return [dataview.getFloat32(at, littleEndian), 4]; - case 'float64': - case 'double': return [dataview.getFloat64(at, littleEndian), 8]; - } - }, - binaryReadElement: function (dataview, at, properties, littleEndian) { - var element = {}; - var result; - var read = 0; - for (var i = 0; i < properties.length; i++) { - if (properties[i].type === 'list') { - var list = []; - result = this.binaryRead(dataview, at + read, properties[i].countType, littleEndian); - var n = result[0]; - read += result[1]; - for (var j = 0; j < n; j++) { - result = this.binaryRead(dataview, at + read, properties[i].itemType, littleEndian); - list.push(result[0]); - read += result[1]; - } - element[properties[i].name] = list; - } - else { - result = this.binaryRead(dataview, at + read, properties[i].type, littleEndian); - element[properties[i].name] = result[0]; - read += result[1]; - } - } - return [element, read]; - }, - parseBinary: function (data) { - var geometry = new __WEBPACK_IMPORTED_MODULE_0_three__["s" /* Geometry */](); - var header = this.parseHeader(this.bin2str(data)); - var littleEndian = (header.format === 'binary_little_endian'); - var body = new DataView(data, header.headerLength); - var result; - var loc = 0; - for (var currentElement = 0; currentElement < header.elements.length; currentElement++) { - for (var currentElementCount = 0; currentElementCount < header.elements[currentElement].count; currentElementCount++) { - result = this.binaryReadElement(body, loc, header.elements[currentElement].properties, littleEndian); - loc += result[1]; - var element = result[0]; - this.handleElement(geometry, header.elements[currentElement].name, element); - } - } - return this.postProcess(geometry); - } -}; -var PlyParser = /*@__PURE__*/(function (SurfaceParser$$1) { - function PlyParser () { - SurfaceParser$$1.apply(this, arguments); - } - - if ( SurfaceParser$$1 ) PlyParser.__proto__ = SurfaceParser$$1; - PlyParser.prototype = Object.create( SurfaceParser$$1 && SurfaceParser$$1.prototype ); - PlyParser.prototype.constructor = PlyParser; - - var prototypeAccessors = { type: { configurable: true } }; - - prototypeAccessors.type.get = function () { return 'ply'; }; - PlyParser.prototype.getLoader = function getLoader () { - return new PLYLoader(); - }; - - Object.defineProperties( PlyParser.prototype, prototypeAccessors ); - - return PlyParser; -}(SurfaceParser)); -ParserRegistry$1.add('ply', PlyParser); - -/** - * @file Csv Parser - * @author Alexander Rose - * @private - */ -/** - * CSV parser - */ -var CsvParser = /*@__PURE__*/(function (Parser$$1) { - function CsvParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.delimiter = defaults(p.delimiter, ','); - this.comment = defaults(p.comment, '#'); - this.columnNames = defaults(p.columnNames, false); - this.table = { - name: this.name, - path: this.path, - columnNames: [], - data: [] - }; - } - - if ( Parser$$1 ) CsvParser.__proto__ = Parser$$1; - CsvParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - CsvParser.prototype.constructor = CsvParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'csv'; }; - prototypeAccessors.__objName.get = function () { return 'table'; }; - CsvParser.prototype._parse = function _parse () { - var this$1 = this; - - var data = this.table.data; - var reDelimiter = new RegExp('\\s*' + this.delimiter + '\\s*'); - var j = 0; - this.streamer.eachChunkOfLines(function (chunk) { - var n = chunk.length; - for (var i = 0; i < n; ++i) { - var line = chunk[i].trim(); - if (line.startsWith(this$1.comment)) - { continue; } - var values = line.split(reDelimiter); - if (j === 0) { - this$1.table.columnNames = values; - } - else if (line) { - data.push(values); - } - ++j; - } - }); - }; - - Object.defineProperties( CsvParser.prototype, prototypeAccessors ); - - return CsvParser; -}(Parser)); -ParserRegistry$1.add('csv', CsvParser); - -/** - * @file Json Parser - * @author Alexander Rose - * @private - */ -var JsonParser = /*@__PURE__*/(function (Parser$$1) { - function JsonParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.string = defaults(p.string, false); - this.json = { - name: this.name, - path: this.path, - data: {} - }; - } - - if ( Parser$$1 ) JsonParser.__proto__ = Parser$$1; - JsonParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - JsonParser.prototype.constructor = JsonParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true },isJson: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'json'; }; - prototypeAccessors.__objName.get = function () { return 'json'; }; - prototypeAccessors.isJson.get = function () { return true; }; - JsonParser.prototype._parse = function _parse () { - if (this.streamer.isBinary() || this.string) { - this.json.data = JSON.parse(this.streamer.asText()); - } - else { - this.json.data = this.streamer.data; - } - }; - - Object.defineProperties( JsonParser.prototype, prototypeAccessors ); - - return JsonParser; -}(Parser)); -ParserRegistry$1.add('json', JsonParser); - -/** - * @file Msgpack Parser - * @author Alexander Rose - * @private - */ -var MsgpackParser = /*@__PURE__*/(function (Parser$$1) { - function MsgpackParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.msgpack = { - name: this.name, - path: this.path, - data: undefined - }; - } - - if ( Parser$$1 ) MsgpackParser.__proto__ = Parser$$1; - MsgpackParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - MsgpackParser.prototype.constructor = MsgpackParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true },isBinary: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'msgpack'; }; - prototypeAccessors.__objName.get = function () { return 'msgpack'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - MsgpackParser.prototype._parse = function _parse () { - if (Debug) - { Log.time('MsgpackParser._parse ' + this.name); } - this.msgpack.data = decodeMsgpack(this.streamer.data); - if (Debug) - { Log.timeEnd('MsgpackParser._parse ' + this.name); } - }; - - Object.defineProperties( MsgpackParser.prototype, prototypeAccessors ); - - return MsgpackParser; -}(Parser)); -ParserRegistry$1.add('msgpack', MsgpackParser); - -/** - * @file Netcdf Parser - * @author Alexander Rose - * @private - */ -var NetcdfParser = /*@__PURE__*/(function (Parser$$1) { - function NetcdfParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.netcdf = { - name: this.name, - path: this.path, - data: undefined - }; - } - - if ( Parser$$1 ) NetcdfParser.__proto__ = Parser$$1; - NetcdfParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - NetcdfParser.prototype.constructor = NetcdfParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true },isBinary: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'netcdf'; }; - prototypeAccessors.__objName.get = function () { return 'netcdf'; }; - prototypeAccessors.isBinary.get = function () { return true; }; - NetcdfParser.prototype._parse = function _parse () { - if (Debug) - { Log.time('NetcdfParser._parse ' + this.name); } - this.netcdf.data = new NetcdfReader(this.streamer.data); - if (Debug) - { Log.timeEnd('NetcdfParser._parse ' + this.name); } - }; - - Object.defineProperties( NetcdfParser.prototype, prototypeAccessors ); - - return NetcdfParser; -}(Parser)); -ParserRegistry$1.add('netcdf', NetcdfParser); - -/** - * @file Text Parser - * @author Alexander Rose - * @private - */ -var TextParser = /*@__PURE__*/(function (Parser$$1) { - function TextParser(streamer, params) { - Parser$$1.call(this, streamer, params); - this.text = { - name: this.name, - path: this.path, - data: '' - }; - } - - if ( Parser$$1 ) TextParser.__proto__ = Parser$$1; - TextParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - TextParser.prototype.constructor = TextParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'text'; }; - prototypeAccessors.__objName.get = function () { return 'text'; }; - TextParser.prototype._parse = function _parse () { - this.text.data = this.streamer.asText(); - }; - - Object.defineProperties( TextParser.prototype, prototypeAccessors ); - - return TextParser; -}(Parser)); -ParserRegistry$1.add('txt', TextParser); -ParserRegistry$1.add('text', TextParser); - -/** - * @file Parse Xml - * @author Alexander Rose - * @private - */ -var reStrip = /^['"]|['"]$/g; -var reTag = /^<([\w-:.]+)\s*/; -var reContent = /^([^<]*)/; -var reAttr = /([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/; -function strip(val) { - return val.replace(reStrip, ''); -} -function parseXml(xml) { - // trim and strip comments - xml = xml.trim().replace(//g, ''); - return document(); - function document() { - return { - declaration: declaration(), - root: tag() - }; - } - function declaration() { - var m = match(/^<\?xml\s*/); - if (!m) - { return; } - // tag - var node = { - attributes: {} - }; - // attributes - while (!(eos() || is('?>'))) { - var attr = attribute(); - if (!attr) - { return node; } - node.attributes[attr.name] = attr.value; - } - match(/\?>\s*/); - return node; - } - function tag() { - var m = match(reTag); - if (!m) - { return; } - // name - var node = { - name: m[1], - attributes: {}, - children: [] - }; - // attributes - while (!(eos() || is('>') || is('?>') || is('/>'))) { - var attr = attribute(); - if (!attr) - { return node; } - node.attributes[attr.name] = attr.value; - } - // self closing tag - if (match(/^\s*\/>\s*/)) { - return node; - } - match(/\??>\s*/); - // content - node.content = content(); - // children - var child; - while ((child = tag())) { - node.children.push(child); - } - // closing - match(/^<\/[\w-:.]+>\s*/); - return node; - } - function content() { - var m = match(reContent); - if (m) - { return m[1]; } - return ''; - } - function attribute() { - var m = match(reAttr); - if (!m) - { return; } - return { name: m[1], value: strip(m[2]) }; - } - function match(re) { - var m = xml.match(re); - if (!m) - { return; } - xml = xml.slice(m[0].length); - return m; - } - function eos() { - return xml.length === 0; - } - function is(prefix) { - return xml.indexOf(prefix) === 0; - } -} - -/** - * @file Xml Parser - * @author Alexander Rose - * @private - */ -var XmlParser = /*@__PURE__*/(function (Parser$$1) { - function XmlParser(streamer, params) { - var p = params || {}; - Parser$$1.call(this, streamer, p); - this.useDomParser = defaults(p.useDomParser, false); - this.xml = { - name: this.name, - path: this.path, - data: {} - }; - } - - if ( Parser$$1 ) XmlParser.__proto__ = Parser$$1; - XmlParser.prototype = Object.create( Parser$$1 && Parser$$1.prototype ); - XmlParser.prototype.constructor = XmlParser; - - var prototypeAccessors = { type: { configurable: true },__objName: { configurable: true },isXml: { configurable: true } }; - prototypeAccessors.type.get = function () { return 'xml'; }; - prototypeAccessors.__objName.get = function () { return 'xml'; }; - prototypeAccessors.isXml.get = function () { return true; }; - XmlParser.prototype.__xmlParser = function __xmlParser (xml) { - return parseXml(xml); - }; - XmlParser.prototype.__domParser = function __domParser (xml) { - var domParser = new window.DOMParser(); - return domParser.parseFromString(xml, 'text/xml'); - }; - XmlParser.prototype._parse = function _parse () { - if (Debug) - { Log.time('XmlParser._parse ' + this.name); } - if (this.useDomParser) { - if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document - this.xml.data = this.streamer.data; - } - else { - this.xml.data = this.__domParser(this.streamer.asText()); - } - } - else { - this.xml.data = this.__xmlParser(this.streamer.asText()); - } - if (Debug) - { Log.timeEnd('XmlParser._parse ' + this.name); } - }; - - Object.defineProperties( XmlParser.prototype, prototypeAccessors ); - - return XmlParser; -}(Parser)); -ParserRegistry$1.add('xml', XmlParser); - -/** - * @file Validation - * @author Alexander Rose - * @private - */ -function getNamedItem(a, name) { - var item = a.getNamedItem(name); - return item !== null ? item.value : ''; -} -function getSele(a, atomname, useAltcode) { - if ( useAltcode === void 0 ) useAltcode = false; - - var icode = getNamedItem(a, 'icode').trim(); - var chain = getNamedItem(a, 'chain').trim(); - var altcode = getNamedItem(a, 'altcode'); - var sele = getNamedItem(a, 'resnum'); - if (icode) - { sele += '^' + icode; } - if (chain) - { sele += ':' + chain; } - if (atomname) - { sele += '.' + atomname; } - if (useAltcode && altcode.trim()) - { sele += '%' + altcode; } - sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1); - return sele; -} -function getResSele(a) { - var chain = getNamedItem(a, 'chain').trim(); - var rescode = getNamedItem(a, 'rescode'); - var resnum = getNamedItem(a, 'resnum'); - var sele = "[" + rescode + "]" + resnum; - if (chain) - { sele += ":" + chain; } - return sele; -} -function setBitDict(dict, key, bit) { - if (dict[key] === undefined) { - dict[key] = bit; - } - else { - dict[key] |= bit; - } -} -function hasAttrValue(attr, value) { - return attr !== null && attr.value === value; -} -function getAtomSele(ap) { - var icode = ap.inscode; - var chain = ap.chainname; - var atomname = ap.atomname; - var altcode = ap.altloc; - var sele = ap.resno + ''; - if (icode) - { sele += '^' + icode; } - if (chain) - { sele += ':' + chain; } - if (atomname) - { sele += '.' + atomname; } - if (altcode) - { sele += '%' + altcode; } - sele += '/' + ap.modelIndex; - return sele; -} -function getProblemCount(clashDict, g, ga) { - var geoProblemCount = 0; - var clashes = g.getElementsByTagName('clash'); - for (var j = 0, jl = clashes.length; j < jl; ++j) { - if (clashDict[getNamedItem(clashes[j].attributes, 'cid')]) { - geoProblemCount += 1; - break; - } - } - var angleOutliers = g.getElementsByTagName('angle-outlier'); - if (angleOutliers.length > 0) { - geoProblemCount += 1; - } - var bondOutliers = g.getElementsByTagName('bond-outlier'); - if (bondOutliers.length > 0) { - geoProblemCount += 1; - } - var planeOutliers = g.getElementsByTagName('plane-outlier'); - if (planeOutliers.length > 0) { - geoProblemCount += 1; - } - if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) { - geoProblemCount += 1; - } - if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) { - geoProblemCount += 1; - } - if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) { - geoProblemCount += 1; - } - return geoProblemCount; -} -var Validation = function Validation(name, path) { - this.name = name; - this.path = path; - this.rsrzDict = {}; - this.rsccDict = {}; - /** - * Random Coil Index (RCI) - evaluates the proximity of residue structural - * and dynamic properties to the properties of flexible random coil regions - * from NMR chemical shifts. - * - * Mark V. Berjanskii and David S. Wishart (2005) - * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts - * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971 - * http://pubs.acs.org/doi/abs/10.1021/ja054842f - * - * Mark V. Berjanskii and David S. Wishart (2008) - * Application of the random coil index to studying protein flexibility. - * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6. - * http://www.springerlink.com/content/2966482w10306126/ - */ - this.rciDict = {}; - this.clashDict = {}; - this.clashArray = []; - this.geoDict = {}; - this.geoAtomDict = {}; - this.atomDict = {}; - this.clashSele = 'NONE'; -}; - -var prototypeAccessors$z = { type: { configurable: true } }; -prototypeAccessors$z.type.get = function () { return 'validation'; }; -Validation.prototype.fromXml = function fromXml (xml) { - if (Debug) - { Log.time('Validation.fromXml'); } - var rsrzDict = this.rsrzDict; - var rsccDict = this.rsccDict; - var rciDict = this.rciDict; - var clashDict = this.clashDict; - var clashArray = this.clashArray; - var geoDict = this.geoDict; - var geoAtomDict = this.geoAtomDict; - var atomDict = this.atomDict; - var entries = xml.getElementsByTagName('Entry'); - if (entries.length === 1) { - var chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list'); - if (chemicalShiftLists.length === 1) { - var randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index'); - for (var j = 0, jl = randomCoilIndices.length; j < jl; ++j) { - var rcia = randomCoilIndices[j].attributes; - var sele = getResSele(rcia); - rciDict[sele] = parseFloat(getNamedItem(rcia, 'value')); - } - } - } - var groups = xml.getElementsByTagName('ModelledSubgroup'); - var _clashDict = {}; - var clashList = []; - if (Debug) - { Log.time('Validation.fromXml#clashDict'); } - for (var i = 0, il = groups.length; i < il; ++i) { - var g = groups[i]; - var ga = g.attributes; - var sele$1 = getSele(ga); - if (ga.getNamedItem('rsrz') !== null) { - rsrzDict[sele$1] = parseFloat(getNamedItem(ga, 'rsrz')); - } - if (ga.getNamedItem('rscc') !== null) { - rsccDict[sele$1] = parseFloat(getNamedItem(ga, 'rscc')); - } - var seleAttr = xml.createAttribute('sele'); - seleAttr.value = sele$1; - ga.setNamedItem(seleAttr); - var clashes = g.getElementsByTagName('clash'); - for (var j$1 = 0, jl$1 = clashes.length; j$1 < jl$1; ++j$1) { - var ca = clashes[j$1].attributes; - var atom = getNamedItem(ca, 'atom'); - if (guessElement(atom) !== 'H') { - var cid = getNamedItem(ca, 'cid'); - var atomSele = getSele(ga, atom, true); - atomDict[atomSele] = true; - if (_clashDict[cid] === undefined) { - _clashDict[cid] = { - sele1: atomSele, - res1: sele$1 - }; - } - else { - var c = _clashDict[cid]; - if (c.res1 !== sele$1) { - c.sele2 = atomSele; - c.res2 = sele$1; - clashList.push(c.res1, sele$1); - clashDict[cid] = c; - clashArray.push(c); - } - } - } - } - } - if (Debug) - { Log.timeEnd('Validation.fromXml#clashDict'); } - for (var i$1 = 0, il$1 = groups.length; i$1 < il$1; ++i$1) { - var g$1 = groups[i$1]; - var ga$1 = g$1.attributes; - var sele$2 = getNamedItem(ga$1, 'sele'); - var isPolymer = getNamedItem(ga$1, 'seq') !== '.'; - if (isPolymer) { - var geoProblemCount = getProblemCount(clashDict, g$1, ga$1); - if (geoProblemCount > 0) { - geoDict[sele$2] = geoProblemCount; - } - } - else { - var clashes$1 = g$1.getElementsByTagName('clash'); - var mogBondOutliers = g$1.getElementsByTagName('mog-bond-outlier'); - var mogAngleOutliers = g$1.getElementsByTagName('mog-angle-outlier'); - if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes$1.length > 0) { - var atomDict$1 = {}; - geoAtomDict[sele$2] = atomDict$1; - for (var j$2 = 0, jl$2 = clashes$1.length; j$2 < jl$2; ++j$2) { - var ca$1 = clashes$1[j$2].attributes; - if (clashDict[getNamedItem(ca$1, 'cid')]) { - setBitDict(atomDict$1, getNamedItem(ca$1, 'atom'), 1); - } - } - for (var j$3 = 0, jl$3 = mogBondOutliers.length; j$3 < jl$3; ++j$3) { - var mbo = mogBondOutliers[j$3].attributes; - getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) { - setBitDict(atomDict$1, atomname, 2); - }); - } - for (var j$4 = 0, jl$4 = mogAngleOutliers.length; j$4 < jl$4; ++j$4) { - var mao = mogAngleOutliers[j$4].attributes; - getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) { - setBitDict(atomDict$1, atomname, 4); - }); - } - } - } - } - this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'; - if (Debug) - { Log.timeEnd('Validation.fromXml'); } -}; -Validation.prototype.getClashData = function getClashData (params) { - if (Debug) - { Log.time('Validation.getClashData'); } - var p = params || {}; - var s = p.structure; - var atomSet = s.atomSet; // TODO - var c = new __WEBPACK_IMPORTED_MODULE_0_three__["i" /* Color */](defaults(p.color, '#f0027f')); - var ap1 = s.getAtomProxy(); - var ap2 = s.getAtomProxy(); - var vDir = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vPos1 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var vPos2 = new __WEBPACK_IMPORTED_MODULE_0_three__["X" /* Vector3 */](); - var clashArray = this.clashArray; - var n = clashArray.length; - var position1 = new Float32Array(n * 3); - var position2 = new Float32Array(n * 3); - var color = uniformArray3(n, c.r, c.g, c.b); - var radius = new Float32Array(n); - var picking = new Float32Array(n); - if (Debug) - { Log.time('Validation.getClashData#atomDict'); } - var atomDict = this.atomDict; - s.eachAtom(function (ap) { - var sele = getAtomSele(ap); - if (atomDict[sele] === true) { - atomDict[sele] = ap.index; - } - }); - if (Debug) - { Log.timeEnd('Validation.getClashData#atomDict'); } - var i = 0; - clashArray.forEach(function (c, idx) { - ap1.index = atomDict[c.sele1]; // TODO - ap2.index = atomDict[c.sele2]; // TODO - if (ap1.index === undefined || ap2.index === undefined || - !atomSet.isSet(ap1.index, ap2.index)) - { return; } - vDir.subVectors(ap2, ap1).setLength(ap1.vdw); // TODO - vPos1.copy(ap1).add(vDir); // TODO - vDir.subVectors(ap1, ap2).setLength(ap2.vdw); // TODO - vPos2.copy(ap2).add(vDir); // TODO - var dHalf = ap1.distanceTo(ap2) / 2; - var r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf); - var r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf); - vPos1.toArray(position1, i * 3); // TODO - vPos2.toArray(position2, i * 3); - radius[i] = (r1 + r2) / 2; - picking[i] = idx; - ++i; - }); - if (Debug) - { Log.timeEnd('Validation.getClashData'); } - return { - position1: position1.subarray(0, i * 3), - position2: position2.subarray(0, i * 3), - color: color.subarray(0, i * 3), - color2: color.subarray(0, i * 3), - radius: radius.subarray(0, i), - picking: new ClashPicker(picking.subarray(0, i), this, s) - }; -}; - -Object.defineProperties( Validation.prototype, prototypeAccessors$z ); - -/** - * @file Validation Parser - * @author Alexander Rose - * @private - */ -var ValidationParser = /*@__PURE__*/(function (XmlParser$$1) { - function ValidationParser(streamer, params) { - var p = params || {}; - XmlParser$$1.call(this, streamer, p); - this.useDomParser = true; - this.validation = new Validation(this.name, this.path); - } - - if ( XmlParser$$1 ) ValidationParser.__proto__ = XmlParser$$1; - ValidationParser.prototype = Object.create( XmlParser$$1 && XmlParser$$1.prototype ); - ValidationParser.prototype.constructor = ValidationParser; - - var prototypeAccessors = { __objName: { configurable: true },isXml: { configurable: true } }; - prototypeAccessors.__objName.get = function () { return 'validation'; }; - prototypeAccessors.isXml.get = function () { return true; }; - ValidationParser.prototype._parse = function _parse () { - XmlParser$$1.prototype._parse.call(this); - if (Debug) - { Log.time('ValidationParser._parse ' + this.name); } - this.validation.fromXml(this.xml.data); - if (Debug) - { Log.timeEnd('ValidationParser._parse ' + this.name); } - }; - - Object.defineProperties( ValidationParser.prototype, prototypeAccessors ); - - return ValidationParser; -}(XmlParser)); -ParserRegistry$1.add('validation', ValidationParser); - -// https://github.com/nodeca/pako -// MIT License, Copyright (c) 2014 by Vitaly Puzrin - - -// 'use strict'; - - -// var TYPED_OK = (typeof Uint8Array !== 'undefined') && -// (typeof Uint16Array !== 'undefined') && -// (typeof Int32Array !== 'undefined'); - - -function assign(obj /*from1, from2, from3, ...*/) { - var sources = Array.prototype.slice.call(arguments, 1); - while (sources.length) { - var source = sources.shift(); - if (!source) { continue; } - - if (typeof source !== 'object') { - throw new TypeError(source + 'must be non-object'); - } - - for (var p in source) { - if (source.hasOwnProperty(p)) { - obj[p] = source[p]; - } - } - } - - return obj; -} - - -// reduce buffer size, avoiding mem copy -function shrinkBuf(buf, size) { - if (buf.length === size) { return buf; } - if (buf.subarray) { return buf.subarray(0, size); } - buf.length = size; - return buf; -} - - -function arraySet(dest, src, src_offs, len, dest_offs) { - if (src.subarray && dest.subarray) { - dest.set(src.subarray(src_offs, src_offs + len), dest_offs); - return; - } - // Fallback to ordinary array - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } -} - -// Join array of chunks to single array. -function flattenChunks(chunks) { - var i, l, len, pos, chunk, result; - - // calculate data length - len = 0; - for (i = 0, l = chunks.length; i < l; i++) { - len += chunks[i].length; - } - - // join chunks - result = new Uint8Array(len); - pos = 0; - for (i = 0, l = chunks.length; i < l; i++) { - chunk = chunks[i]; - result.set(chunk, pos); - pos += chunk.length; - } - - return result; -} - -// 'use strict'; - -// Note: adler32 takes 12% for level 0 and 2% for level 6. -// It doesn't worth to make additional optimizationa as in original. -// Small size is preferable. - -function adler32(adler, buf, len, pos) { - var s1 = (adler & 0xffff) |0, - s2 = ((adler >>> 16) & 0xffff) |0, - n = 0; - - while (len !== 0) { - // Set limit ~ twice less than 5552, to keep - // s2 in 31-bits, because we force signed ints. - // in other case %= will fail. - n = len > 2000 ? 2000 : len; - len -= n; - - do { - s1 = (s1 + buf[pos++]) |0; - s2 = (s2 + s1) |0; - } while (--n); - - s1 %= 65521; - s2 %= 65521; - } - - return (s1 | (s2 << 16)) |0; -} - -// 'use strict'; - -// Note: we can't get significant speed boost here. -// So write code to minimize size - no pregenerated tables -// and array tools dependencies. - - -// Use ordinary array, since untyped makes no boost here -function makeTable() { - var c, table = []; - - for (var n = 0; n < 256; n++) { - c = n; - for (var k = 0; k < 8; k++) { - c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); - } - table[n] = c; - } - - return table; -} - -// Create table on load. Just 255 signed longs. Not a problem. -var crcTable = makeTable(); - - -function crc32(crc, buf, len, pos) { - var t = crcTable, - end = pos + len; - - crc ^= -1; - - for (var i = pos; i < end; i++) { - crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; - } - - return (crc ^ (-1)); // >>> 0; -} - -// 'use strict'; - -// See state defs from inflate.js -var BAD$1 = 30; /* got a data error -- remain here until reset */ -var TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */ - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state.mode === LEN - strm.avail_in >= 6 - strm.avail_out >= 258 - start >= strm.avail_out - state.bits < 8 - - On return, state.mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm.avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm.avail_out >= 258 for each loop to avoid checking for - output space. - */ -// module.exports = -function inflate_fast(strm, start) { - var state; - var _in; /* local strm.input */ - var last; /* have enough input while in < last */ - var _out; /* local strm.output */ - var beg; /* inflate()'s initial strm.output */ - var end; /* while out < end, enough space available */ -//#ifdef INFLATE_STRICT - var dmax; /* maximum distance from zlib header */ -//#endif - var wsize; /* window size or zero if not using window */ - var whave; /* valid bytes in the window */ - var wnext; /* window write index */ - // Use `s_window` instead `window`, avoid conflict with instrumentation tools - var s_window; /* allocated sliding window, if wsize != 0 */ - var hold; /* local strm.hold */ - var bits; /* local strm.bits */ - var lcode; /* local strm.lencode */ - var dcode; /* local strm.distcode */ - var lmask; /* mask for first level of length codes */ - var dmask; /* mask for first level of distance codes */ - var here; /* retrieved table entry */ - var op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - var len; /* match length, unused bytes */ - var dist; /* match distance */ - var from; /* where to copy match from */ - var from_source; - - - var input, output; // JS specific, because we have no pointers - - /* copy state to local variables */ - state = strm.state; - //here = state.here; - _in = strm.next_in; - input = strm.input; - last = _in + (strm.avail_in - 5); - _out = strm.next_out; - output = strm.output; - beg = _out - (start - strm.avail_out); - end = _out + (strm.avail_out - 257); -//#ifdef INFLATE_STRICT - dmax = state.dmax; -//#endif - wsize = state.wsize; - whave = state.whave; - wnext = state.wnext; - s_window = state.window; - hold = state.hold; - bits = state.bits; - lcode = state.lencode; - dcode = state.distcode; - lmask = (1 << state.lenbits) - 1; - dmask = (1 << state.distbits) - 1; - - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - - top: - do { - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - - here = lcode[hold & lmask]; - - dolen: - for (;;) { // Goto emulation - op = here >>> 24/*here.bits*/; - hold >>>= op; - bits -= op; - op = (here >>> 16) & 0xff/*here.op*/; - if (op === 0) { /* literal */ - //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - // "inflate: literal '%c'\n" : - // "inflate: literal 0x%02x\n", here.val)); - output[_out++] = here & 0xffff/*here.val*/; - } - else if (op & 16) { /* length base */ - len = here & 0xffff/*here.val*/; - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - len += hold & ((1 << op) - 1); - hold >>>= op; - bits -= op; - } - //Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - here = dcode[hold & dmask]; - - dodist: - for (;;) { // goto emulation - op = here >>> 24/*here.bits*/; - hold >>>= op; - bits -= op; - op = (here >>> 16) & 0xff/*here.op*/; - - if (op & 16) { /* distance base */ - dist = here & 0xffff/*here.val*/; - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - } - dist += hold & ((1 << op) - 1); -//#ifdef INFLATE_STRICT - if (dist > dmax) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD$1; - break top; - } -//#endif - hold >>>= op; - bits -= op; - //Tracevv((stderr, "inflate: distance %u\n", dist)); - op = _out - beg; /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - if (state.sane) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD$1; - break top; - } - -// (!) This block is disabled in zlib defailts, -// don't enable it for binary compatibility -//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR -// if (len <= op - whave) { -// do { -// output[_out++] = 0; -// } while (--len); -// continue top; -// } -// len -= op - whave; -// do { -// output[_out++] = 0; -// } while (--op > whave); -// if (op === 0) { -// from = _out - dist; -// do { -// output[_out++] = output[from++]; -// } while (--len); -// continue top; -// } -//#endif - } - from = 0; // window index - from_source = s_window; - if (wnext === 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; /* rest from output */ - from_source = output; - } - } - else if (wnext < op) { /* wrap around window */ - from += wsize + wnext - op; - op -= wnext; - if (op < len) { /* some from end of window */ - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = 0; - if (wnext < len) { /* some from start of window */ - op = wnext; - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; /* rest from output */ - from_source = output; - } - } - } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; /* rest from output */ - from_source = output; - } - } - while (len > 2) { - output[_out++] = from_source[from++]; - output[_out++] = from_source[from++]; - output[_out++] = from_source[from++]; - len -= 3; - } - if (len) { - output[_out++] = from_source[from++]; - if (len > 1) { - output[_out++] = from_source[from++]; - } - } - } - else { - from = _out - dist; /* copy direct from output */ - do { /* minimum length is three */ - output[_out++] = output[from++]; - output[_out++] = output[from++]; - output[_out++] = output[from++]; - len -= 3; - } while (len > 2); - if (len) { - output[_out++] = output[from++]; - if (len > 1) { - output[_out++] = output[from++]; - } - } - } - } - else if ((op & 64) === 0) { /* 2nd level distance code */ - here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; - continue dodist; - } - else { - strm.msg = 'invalid distance code'; - state.mode = BAD$1; - break top; - } - - break; // need to emulate goto via "continue" - } - } - else if ((op & 64) === 0) { /* 2nd level length code */ - here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))]; - continue dolen; - } - else if (op & 32) { /* end-of-block */ - //Tracevv((stderr, "inflate: end of block\n")); - state.mode = TYPE$1; - break top; - } - else { - strm.msg = 'invalid literal/length code'; - state.mode = BAD$1; - break top; - } - - break; // need to emulate goto via "continue" - } - } while (_in < last && _out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - _in -= len; - bits -= len << 3; - hold &= (1 << bits) - 1; - - /* update state and return */ - strm.next_in = _in; - strm.next_out = _out; - strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last)); - strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end)); - state.hold = hold; - state.bits = bits; - return; -} -// 'use strict'; - - -// var utils = require('../utils/common'); - -var MAXBITS = 15; -var ENOUGH_LENS$1 = 852; -var ENOUGH_DISTS$1 = 592; -//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); - -var CODES$1 = 0; -var LENS$1 = 1; -var DISTS$1 = 2; - -var lbase = [ /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 -]; - -var lext = [ /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78 -]; - -var dbase = [ /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0 -]; - -var dext = [ /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64 -]; - -// module.exports = -function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) -{ - var bits = opts.bits; - //here = opts.here; /* table entry for duplication */ - - var len = 0; /* a code's length in bits */ - var sym = 0; /* index of code symbols */ - var min = 0, max = 0; /* minimum and maximum code lengths */ - var root = 0; /* number of index bits for root table */ - var curr = 0; /* number of index bits for current table */ - var drop = 0; /* code bits to drop for sub-table */ - var left = 0; /* number of prefix codes available */ - var used = 0; /* code entries in table used */ - var huff = 0; /* Huffman code */ - var incr; /* for incrementing code, index */ - var fill; /* index for replicating entries */ - var low; /* low bits for current root entry */ - var mask; /* mask for low root bits */ - var next; /* next available space in table */ - var base = null; /* base value table to use */ - var base_index = 0; -// var shoextra; /* extra bits table to use */ - var end; /* use base and extra for symbol > end */ - var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */ - var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */ - var extra = null; - var extra_index = 0; - - var here_bits, here_op, here_val; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) { - count[len] = 0; - } - for (sym = 0; sym < codes; sym++) { - count[lens[lens_index + sym]]++; - } - - /* bound code lengths, force root to be within code lengths */ - root = bits; - for (max = MAXBITS; max >= 1; max--) { - if (count[max] !== 0) { break; } - } - if (root > max) { - root = max; - } - if (max === 0) { /* no symbols to code at all */ - //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */ - //table.bits[opts.table_index] = 1; //here.bits = (var char)1; - //table.val[opts.table_index++] = 0; //here.val = (var short)0; - table[table_index++] = (1 << 24) | (64 << 16) | 0; - - - //table.op[opts.table_index] = 64; - //table.bits[opts.table_index] = 1; - //table.val[opts.table_index++] = 0; - table[table_index++] = (1 << 24) | (64 << 16) | 0; - - opts.bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min < max; min++) { - if (count[min] !== 0) { break; } - } - if (root < min) { - root = min; - } - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) { - return -1; - } /* over-subscribed */ - } - if (left > 0 && (type === CODES$1 || max !== 1)) { - return -1; /* incomplete set */ - } - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) { - offs[len + 1] = offs[len] + count[len]; - } - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) { - if (lens[lens_index + sym] !== 0) { - work[offs[lens[lens_index + sym]]++] = sym; - } - } - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftrees.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - // poor man optimization - use if-else instead of switch, - // to avoid deopts in old v8 - if (type === CODES$1) { - base = extra = work; /* dummy value--not used */ - end = 19; - - } else if (type === LENS$1) { - base = lbase; - base_index -= 257; - extra = lext; - extra_index -= 257; - end = 256; - - } else { /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize opts for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = table_index; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = -1; /* trigger new sub-table when len > root */ - used = 1 << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type === LENS$1 && used > ENOUGH_LENS$1) || - (type === DISTS$1 && used > ENOUGH_DISTS$1)) { - return 1; - } - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - here_bits = len - drop; - if (work[sym] < end) { - here_op = 0; - here_val = work[sym]; - } - else if (work[sym] > end) { - here_op = extra[extra_index + work[sym]]; - here_val = base[base_index + work[sym]]; - } - else { - here_op = 32 + 64; /* end of block */ - here_val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1 << (len - drop); - fill = 1 << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0; - } while (fill !== 0); - - /* backwards increment the len-bit code huff */ - incr = 1 << (len - 1); - while (huff & incr) { - incr >>= 1; - } - if (incr !== 0) { - huff &= incr - 1; - huff += incr; - } else { - huff = 0; - } - - /* go to next symbol, update count, len */ - sym++; - if (--count[len] === 0) { - if (len === max) { break; } - len = lens[lens_index + work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) !== low) { - /* if first time, transition to sub-tables */ - if (drop === 0) { - drop = root; - } - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = 1 << curr; - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) { break; } - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1 << curr; - if ((type === LENS$1 && used > ENOUGH_LENS$1) || - (type === DISTS$1 && used > ENOUGH_DISTS$1)) { - return 1; - } - - /* point entry in root table to sub-table */ - low = huff & mask; - /*table.op[low] = curr; - table.bits[low] = root; - table.val[low] = next - opts.table_index;*/ - table[low] = (root << 24) | (curr << 16) | (next - table_index) |0; - } - } - - /* fill in remaining table entry if code is incomplete (guaranteed to have - at most one remaining entry, since if the code is incomplete, the - maximum code length that was allowed to get this far is one bit) */ - if (huff !== 0) { - //table.op[next + huff] = 64; /* invalid code marker */ - //table.bits[next + huff] = len - drop; - //table.val[next + huff] = 0; - table[next + huff] = ((len - drop) << 24) | (64 << 16) |0; - } - - /* set return parameters */ - //opts.table_index += used; - opts.bits = root; - return 0; -} -// 'use strict'; - - -// var utils = require('../utils/common'); -// var adler32 = require('./adler32'); -// var crc32 = require('./crc32'); -// var inflate_fast = require('./inffast'); -// var inflate_table = require('./inftrees'); - -var CODES = 0; -var LENS = 1; -var DISTS = 2; - -/* Public constants ==========================================================*/ -/* ===========================================================================*/ - - -/* Allowed flush values; see deflate() and inflate() below for details */ -//var Z_NO_FLUSH = 0; -//var Z_PARTIAL_FLUSH = 1; -//var Z_SYNC_FLUSH = 2; -//var Z_FULL_FLUSH = 3; -var Z_FINISH = 4; -var Z_BLOCK = 5; -var Z_TREES = 6; - - -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ -var Z_OK = 0; -var Z_STREAM_END = 1; -var Z_NEED_DICT = 2; -//var Z_ERRNO = -1; -var Z_STREAM_ERROR = -2; -var Z_DATA_ERROR = -3; -var Z_MEM_ERROR = -4; -var Z_BUF_ERROR = -5; -//var Z_VERSION_ERROR = -6; - -/* The deflate compression method */ -var Z_DEFLATED = 8; - - -/* STATES ====================================================================*/ -/* ===========================================================================*/ - - -var HEAD = 1; /* i: waiting for magic header */ -var FLAGS = 2; /* i: waiting for method and flags (gzip) */ -var TIME = 3; /* i: waiting for modification time (gzip) */ -var OS = 4; /* i: waiting for extra flags and operating system (gzip) */ -var EXLEN = 5; /* i: waiting for extra length (gzip) */ -var EXTRA = 6; /* i: waiting for extra bytes (gzip) */ -var NAME = 7; /* i: waiting for end of file name (gzip) */ -var COMMENT = 8; /* i: waiting for end of comment (gzip) */ -var HCRC = 9; /* i: waiting for header crc (gzip) */ -var DICTID = 10; /* i: waiting for dictionary check value */ -var DICT = 11; /* waiting for inflateSetDictionary() call */ -var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ -var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */ -var STORED = 14; /* i: waiting for stored size (length and complement) */ -var COPY_ = 15; /* i/o: same as COPY below, but only first time in */ -var COPY = 16; /* i/o: waiting for input or output to copy stored block */ -var TABLE = 17; /* i: waiting for dynamic block table lengths */ -var LENLENS = 18; /* i: waiting for code length code lengths */ -var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */ -var LEN_ = 20; /* i: same as LEN below, but only first time in */ -var LEN = 21; /* i: waiting for length/lit/eob code */ -var LENEXT = 22; /* i: waiting for length extra bits */ -var DIST = 23; /* i: waiting for distance code */ -var DISTEXT = 24; /* i: waiting for distance extra bits */ -var MATCH = 25; /* o: waiting for output space to copy string */ -var LIT = 26; /* o: waiting for output space to write literal */ -var CHECK = 27; /* i: waiting for 32-bit check value */ -var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */ -var DONE = 29; /* finished check, done -- remain here until reset */ -var BAD = 30; /* got a data error -- remain here until reset */ -var MEM = 31; /* got an inflate() memory error -- remain here until reset */ -var SYNC = 32; /* looking for synchronization bytes to restart inflate() */ - -/* ===========================================================================*/ - - - -var ENOUGH_LENS = 852; -var ENOUGH_DISTS = 592; -function zswap32(q) { - return (((q >>> 24) & 0xff) + - ((q >>> 8) & 0xff00) + - ((q & 0xff00) << 8) + - ((q & 0xff) << 24)); -} - - -function InflateState() { - this.mode = 0; /* current inflate mode */ - this.last = false; /* true if processing last block */ - this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ - this.havedict = false; /* true if dictionary provided */ - this.flags = 0; /* gzip header method and flags (0 if zlib) */ - this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */ - this.check = 0; /* protected copy of check value */ - this.total = 0; /* protected copy of output count */ - // TODO: may be {} - this.head = null; /* where to save gzip header information */ - - /* sliding window */ - this.wbits = 0; /* log base 2 of requested window size */ - this.wsize = 0; /* window size or zero if not using window */ - this.whave = 0; /* valid bytes in the window */ - this.wnext = 0; /* window write index */ - this.window = null; /* allocated sliding window, if needed */ - - /* bit accumulator */ - this.hold = 0; /* input bit accumulator */ - this.bits = 0; /* number of bits in "in" */ - - /* for string and stored block copying */ - this.length = 0; /* literal or length of data to copy */ - this.offset = 0; /* distance back to copy string from */ - - /* for table and code decoding */ - this.extra = 0; /* extra bits needed */ - - /* fixed and dynamic code tables */ - this.lencode = null; /* starting table for length/literal codes */ - this.distcode = null; /* starting table for distance codes */ - this.lenbits = 0; /* index bits for lencode */ - this.distbits = 0; /* index bits for distcode */ - - /* dynamic table building */ - this.ncode = 0; /* number of code length code lengths */ - this.nlen = 0; /* number of length code lengths */ - this.ndist = 0; /* number of distance code lengths */ - this.have = 0; /* number of code lengths in lens[] */ - this.next = null; /* next available space in codes[] */ - - this.lens = new Uint16Array(320); /* temporary storage for code lengths */ - this.work = new Uint16Array(288); /* work area for code table building */ - - /* - because we don't have pointers in js, we use lencode and distcode directly - as buffers so we don't need codes - */ - //this.codes = new Buf32(ENOUGH); /* space for code tables */ - this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */ - this.distdyn = null; /* dynamic table for distance codes (JS specific) */ - this.sane = 0; /* if false, allow invalid distance too far */ - this.back = 0; /* bits back of last unprocessed length/lit */ - this.was = 0; /* initial length of match */ -} - -function inflateResetKeep(strm) { - var state; - - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - strm.total_in = strm.total_out = state.total = 0; - strm.msg = ''; /*Z_NULL*/ - if (state.wrap) { /* to support ill-conceived Java test suite */ - strm.adler = state.wrap & 1; - } - state.mode = HEAD; - state.last = 0; - state.havedict = 0; - state.dmax = 32768; - state.head = null/*Z_NULL*/; - state.hold = 0; - state.bits = 0; - //state.lencode = state.distcode = state.next = state.codes; - state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS); - state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS); - - state.sane = 1; - state.back = -1; - //Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -function inflateReset(strm) { - var state; - - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - state.wsize = 0; - state.whave = 0; - state.wnext = 0; - return inflateResetKeep(strm); - -} - -function inflateReset2(strm, windowBits) { - var wrap; - var state; - - /* get the state */ - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - - /* extract wrap request from windowBits parameter */ - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } - else { - wrap = (windowBits >> 4) + 1; - if (windowBits < 48) { - windowBits &= 15; - } - } - - /* set number of window bits, free window if different */ - if (windowBits && (windowBits < 8 || windowBits > 15)) { - return Z_STREAM_ERROR; - } - if (state.window !== null && state.wbits !== windowBits) { - state.window = null; - } - - /* update state and reset the rest of it */ - state.wrap = wrap; - state.wbits = windowBits; - return inflateReset(strm); -} - -function inflateInit2(strm, windowBits) { - var ret; - var state; - - if (!strm) { return Z_STREAM_ERROR; } - //strm.msg = Z_NULL; /* in case we return an error */ - - state = new InflateState(); - - //if (state === Z_NULL) return Z_MEM_ERROR; - //Tracev((stderr, "inflate: allocated\n")); - strm.state = state; - state.window = null/*Z_NULL*/; - ret = inflateReset2(strm, windowBits); - if (ret !== Z_OK) { - strm.state = null/*Z_NULL*/; - } - return ret; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -var virgin = true; - -var lenfix; -var distfix; -// We have no pointers in JS, so keep tables separate - -function fixedtables(state) { - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - var sym; - - lenfix = new Int32Array(512); - distfix = new Int32Array(32); - - /* literal/length table */ - sym = 0; - while (sym < 144) { state.lens[sym++] = 8; } - while (sym < 256) { state.lens[sym++] = 9; } - while (sym < 280) { state.lens[sym++] = 7; } - while (sym < 288) { state.lens[sym++] = 8; } - - inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); - - /* distance table */ - sym = 0; - while (sym < 32) { state.lens[sym++] = 5; } - - inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); - - /* do this just once */ - virgin = false; - } - - state.lencode = lenfix; - state.lenbits = 9; - state.distcode = distfix; - state.distbits = 5; -} - - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -function updatewindow(strm, src, end, copy) { - var dist; - var state = strm.state; - - /* if it hasn't been done already, allocate space for the window */ - if (state.window === null) { - state.wsize = 1 << state.wbits; - state.wnext = 0; - state.whave = 0; - - state.window = new Uint8Array(state.wsize); - } - - /* copy state->wsize or less output bytes into the circular window */ - if (copy >= state.wsize) { - arraySet(state.window, src, end - state.wsize, state.wsize, 0); - state.wnext = 0; - state.whave = state.wsize; - } - else { - dist = state.wsize - state.wnext; - if (dist > copy) { - dist = copy; - } - //zmemcpy(state->window + state->wnext, end - copy, dist); - arraySet(state.window, src, end - copy, dist, state.wnext); - copy -= dist; - if (copy) { - //zmemcpy(state->window, end - copy, copy); - arraySet(state.window, src, end - copy, copy, 0); - state.wnext = copy; - state.whave = state.wsize; - } - else { - state.wnext += dist; - if (state.wnext === state.wsize) { state.wnext = 0; } - if (state.whave < state.wsize) { state.whave += dist; } - } - } - return 0; -} - -function inflate(strm, flush) { - var state; - var input, output; // input/output buffers - var next; /* next input INDEX */ - var put; /* next output INDEX */ - var have, left; /* available input and output */ - var hold; /* bit buffer */ - var bits; /* bits in bit buffer */ - var _in, _out; /* save starting available input and output */ - var copy; /* number of stored or match bytes to copy */ - var from; /* where to copy match bytes from */ - var from_source; - var here = 0; /* current decoding table entry */ - var here_bits, here_op, here_val; // paked "here" denormalized (JS specific) - //var last; /* parent table entry */ - var last_bits, last_op, last_val; // paked "last" denormalized (JS specific) - var len; /* length to copy for repeats, bits to drop */ - var ret; /* return code */ - var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */ - var opts; - - var n; // temporary var for NEED_BITS - - var order = /* permutation of code lengths */ - [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; - - - if (!strm || !strm.state || !strm.output || - (!strm.input && strm.avail_in !== 0)) { - return Z_STREAM_ERROR; - } - - state = strm.state; - if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */ - - - //--- LOAD() --- - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - //--- - - _in = have; - _out = left; - ret = Z_OK; - - inf_leave: // goto emulation - for (;;) { - switch (state.mode) { - case HEAD: - if (state.wrap === 0) { - state.mode = TYPEDO; - break; - } - //=== NEEDBITS(16); - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */ - state.check = 0/*crc32(0L, Z_NULL, 0)*/; - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = FLAGS; - break; - } - state.flags = 0; /* expect zlib header */ - if (state.head) { - state.head.done = false; - } - if (!(state.wrap & 1) || /* check if zlib header allowed */ - (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) { - strm.msg = 'incorrect header check'; - state.mode = BAD; - break; - } - if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) { - strm.msg = 'unknown compression method'; - state.mode = BAD; - break; - } - //--- DROPBITS(4) ---// - hold >>>= 4; - bits -= 4; - //---// - len = (hold & 0x0f)/*BITS(4)*/ + 8; - if (state.wbits === 0) { - state.wbits = len; - } - else if (len > state.wbits) { - strm.msg = 'invalid window size'; - state.mode = BAD; - break; - } - state.dmax = 1 << len; - //Tracev((stderr, "inflate: zlib header ok\n")); - strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; - state.mode = hold & 0x200 ? DICTID : TYPE; - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - break; - case FLAGS: - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.flags = hold; - if ((state.flags & 0xff) !== Z_DEFLATED) { - strm.msg = 'unknown compression method'; - state.mode = BAD; - break; - } - if (state.flags & 0xe000) { - strm.msg = 'unknown header flags set'; - state.mode = BAD; - break; - } - if (state.head) { - state.head.text = ((hold >> 8) & 1); - } - if (state.flags & 0x0200) { - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = TIME; - /* falls through */ - case TIME: - //=== NEEDBITS(32); */ - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (state.head) { - state.head.time = hold; - } - if (state.flags & 0x0200) { - //=== CRC4(state.check, hold) - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - hbuf[2] = (hold >>> 16) & 0xff; - hbuf[3] = (hold >>> 24) & 0xff; - state.check = crc32(state.check, hbuf, 4, 0); - //=== - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = OS; - /* falls through */ - case OS: - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (state.head) { - state.head.xflags = (hold & 0xff); - state.head.os = (hold >> 8); - } - if (state.flags & 0x0200) { - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = EXLEN; - /* falls through */ - case EXLEN: - if (state.flags & 0x0400) { - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.length = hold; - if (state.head) { - state.head.extra_len = hold; - } - if (state.flags & 0x0200) { - //=== CRC2(state.check, hold); - hbuf[0] = hold & 0xff; - hbuf[1] = (hold >>> 8) & 0xff; - state.check = crc32(state.check, hbuf, 2, 0); - //===// - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - } - else if (state.head) { - state.head.extra = null/*Z_NULL*/; - } - state.mode = EXTRA; - /* falls through */ - case EXTRA: - if (state.flags & 0x0400) { - copy = state.length; - if (copy > have) { copy = have; } - if (copy) { - if (state.head) { - len = state.head.extra_len - state.length; - if (!state.head.extra) { - // Use untyped array for more conveniend processing later - state.head.extra = new Array(state.head.extra_len); - } - arraySet( - state.head.extra, - input, - next, - // extra field is limited to 65536 bytes - // - no need for additional size check - copy, - /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ - len - ); - //zmemcpy(state.head.extra + len, next, - // len + copy > state.head.extra_max ? - // state.head.extra_max - len : copy); - } - if (state.flags & 0x0200) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - state.length -= copy; - } - if (state.length) { break inf_leave; } - } - state.length = 0; - state.mode = NAME; - /* falls through */ - case NAME: - if (state.flags & 0x0800) { - if (have === 0) { break inf_leave; } - copy = 0; - do { - // TODO: 2 or 1 bytes? - len = input[next + copy++]; - /* use constant limit because in js we should not preallocate memory */ - if (state.head && len && - (state.length < 65536 /*state.head.name_max*/)) { - state.head.name += String.fromCharCode(len); - } - } while (len && copy < have); - - if (state.flags & 0x0200) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { break inf_leave; } - } - else if (state.head) { - state.head.name = null; - } - state.length = 0; - state.mode = COMMENT; - /* falls through */ - case COMMENT: - if (state.flags & 0x1000) { - if (have === 0) { break inf_leave; } - copy = 0; - do { - len = input[next + copy++]; - /* use constant limit because in js we should not preallocate memory */ - if (state.head && len && - (state.length < 65536 /*state.head.comm_max*/)) { - state.head.comment += String.fromCharCode(len); - } - } while (len && copy < have); - if (state.flags & 0x0200) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { break inf_leave; } - } - else if (state.head) { - state.head.comment = null; - } - state.mode = HCRC; - /* falls through */ - case HCRC: - if (state.flags & 0x0200) { - //=== NEEDBITS(16); */ - while (bits < 16) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (hold !== (state.check & 0xffff)) { - strm.msg = 'header crc mismatch'; - state.mode = BAD; - break; - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - } - if (state.head) { - state.head.hcrc = ((state.flags >> 9) & 1); - state.head.done = true; - } - strm.adler = state.check = 0; - state.mode = TYPE; - break; - case DICTID: - //=== NEEDBITS(32); */ - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - strm.adler = state.check = zswap32(hold); - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = DICT; - /* falls through */ - case DICT: - if (state.havedict === 0) { - //--- RESTORE() --- - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - //--- - return Z_NEED_DICT; - } - strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; - state.mode = TYPE; - /* falls through */ - case TYPE: - if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; } - /* falls through */ - case TYPEDO: - if (state.last) { - //--- BYTEBITS() ---// - hold >>>= bits & 7; - bits -= bits & 7; - //---// - state.mode = CHECK; - break; - } - //=== NEEDBITS(3); */ - while (bits < 3) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.last = (hold & 0x01)/*BITS(1)*/; - //--- DROPBITS(1) ---// - hold >>>= 1; - bits -= 1; - //---// - - switch ((hold & 0x03)/*BITS(2)*/) { - case 0: /* stored block */ - //Tracev((stderr, "inflate: stored block%s\n", - // state.last ? " (last)" : "")); - state.mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - //Tracev((stderr, "inflate: fixed codes block%s\n", - // state.last ? " (last)" : "")); - state.mode = LEN_; /* decode codes */ - if (flush === Z_TREES) { - //--- DROPBITS(2) ---// - hold >>>= 2; - bits -= 2; - //---// - break inf_leave; - } - break; - case 2: /* dynamic block */ - //Tracev((stderr, "inflate: dynamic codes block%s\n", - // state.last ? " (last)" : "")); - state.mode = TABLE; - break; - case 3: - strm.msg = 'invalid block type'; - state.mode = BAD; - } - //--- DROPBITS(2) ---// - hold >>>= 2; - bits -= 2; - //---// - break; - case STORED: - //--- BYTEBITS() ---// /* go to byte boundary */ - hold >>>= bits & 7; - bits -= bits & 7; - //---// - //=== NEEDBITS(32); */ - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) { - strm.msg = 'invalid stored block lengths'; - state.mode = BAD; - break; - } - state.length = hold & 0xffff; - //Tracev((stderr, "inflate: stored length %u\n", - // state.length)); - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - state.mode = COPY_; - if (flush === Z_TREES) { break inf_leave; } - /* falls through */ - case COPY_: - state.mode = COPY; - /* falls through */ - case COPY: - copy = state.length; - if (copy) { - if (copy > have) { copy = have; } - if (copy > left) { copy = left; } - if (copy === 0) { break inf_leave; } - //--- zmemcpy(put, next, copy); --- - arraySet(output, input, next, copy, put); - //---// - have -= copy; - next += copy; - left -= copy; - put += copy; - state.length -= copy; - break; - } - //Tracev((stderr, "inflate: stored end\n")); - state.mode = TYPE; - break; - case TABLE: - //=== NEEDBITS(14); */ - while (bits < 14) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257; - //--- DROPBITS(5) ---// - hold >>>= 5; - bits -= 5; - //---// - state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1; - //--- DROPBITS(5) ---// - hold >>>= 5; - bits -= 5; - //---// - state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4; - //--- DROPBITS(4) ---// - hold >>>= 4; - bits -= 4; - //---// -//#ifndef PKZIP_BUG_WORKAROUND - if (state.nlen > 286 || state.ndist > 30) { - strm.msg = 'too many length or distance symbols'; - state.mode = BAD; - break; - } -//#endif - //Tracev((stderr, "inflate: table sizes ok\n")); - state.have = 0; - state.mode = LENLENS; - /* falls through */ - case LENLENS: - while (state.have < state.ncode) { - //=== NEEDBITS(3); - while (bits < 3) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.lens[order[state.have++]] = (hold & 0x07);//BITS(3); - //--- DROPBITS(3) ---// - hold >>>= 3; - bits -= 3; - //---// - } - while (state.have < 19) { - state.lens[order[state.have++]] = 0; - } - // We have separate tables & no pointers. 2 commented lines below not needed. - //state.next = state.codes; - //state.lencode = state.next; - // Switch to use dynamic table - state.lencode = state.lendyn; - state.lenbits = 7; - - opts = { bits: state.lenbits }; - ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); - state.lenbits = opts.bits; - - if (ret) { - strm.msg = 'invalid code lengths set'; - state.mode = BAD; - break; - } - //Tracev((stderr, "inflate: code lengths ok\n")); - state.have = 0; - state.mode = CODELENS; - /* falls through */ - case CODELENS: - while (state.have < state.nlen + state.ndist) { - for (;;) { - here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/ - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - if (here_val < 16) { - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - state.lens[state.have++] = here_val; - } - else { - if (here_val === 16) { - //=== NEEDBITS(here.bits + 2); - n = here_bits + 2; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - if (state.have === 0) { - strm.msg = 'invalid bit length repeat'; - state.mode = BAD; - break; - } - len = state.lens[state.have - 1]; - copy = 3 + (hold & 0x03);//BITS(2); - //--- DROPBITS(2) ---// - hold >>>= 2; - bits -= 2; - //---// - } - else if (here_val === 17) { - //=== NEEDBITS(here.bits + 3); - n = here_bits + 3; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - len = 0; - copy = 3 + (hold & 0x07);//BITS(3); - //--- DROPBITS(3) ---// - hold >>>= 3; - bits -= 3; - //---// - } - else { - //=== NEEDBITS(here.bits + 7); - n = here_bits + 7; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - len = 0; - copy = 11 + (hold & 0x7f);//BITS(7); - //--- DROPBITS(7) ---// - hold >>>= 7; - bits -= 7; - //---// - } - if (state.have + copy > state.nlen + state.ndist) { - strm.msg = 'invalid bit length repeat'; - state.mode = BAD; - break; - } - while (copy--) { - state.lens[state.have++] = len; - } - } - } - - /* handle error breaks in while */ - if (state.mode === BAD) { break; } - - /* check for end-of-block code (better have one) */ - if (state.lens[256] === 0) { - strm.msg = 'invalid code -- missing end-of-block'; - state.mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state.lenbits = 9; - - opts = { bits: state.lenbits }; - ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); - // We have separate tables & no pointers. 2 commented lines below not needed. - // state.next_index = opts.table_index; - state.lenbits = opts.bits; - // state.lencode = state.next; - - if (ret) { - strm.msg = 'invalid literal/lengths set'; - state.mode = BAD; - break; - } - - state.distbits = 6; - //state.distcode.copy(state.codes); - // Switch to use dynamic table - state.distcode = state.distdyn; - opts = { bits: state.distbits }; - ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); - // We have separate tables & no pointers. 2 commented lines below not needed. - // state.next_index = opts.table_index; - state.distbits = opts.bits; - // state.distcode = state.next; - - if (ret) { - strm.msg = 'invalid distances set'; - state.mode = BAD; - break; - } - //Tracev((stderr, 'inflate: codes ok\n')); - state.mode = LEN_; - if (flush === Z_TREES) { break inf_leave; } - /* falls through */ - case LEN_: - state.mode = LEN; - /* falls through */ - case LEN: - if (have >= 6 && left >= 258) { - //--- RESTORE() --- - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - //--- - inflate_fast(strm, _out); - //--- LOAD() --- - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - //--- - - if (state.mode === TYPE) { - state.back = -1; - } - break; - } - state.back = 0; - for (;;) { - here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/ - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if (here_bits <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - if (here_op && (here_op & 0xf0) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (;;) { - here = state.lencode[last_val + - ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((last_bits + here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - //--- DROPBITS(last.bits) ---// - hold >>>= last_bits; - bits -= last_bits; - //---// - state.back += last_bits; - } - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - state.back += here_bits; - state.length = here_val; - if (here_op === 0) { - //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - // "inflate: literal '%c'\n" : - // "inflate: literal 0x%02x\n", here.val)); - state.mode = LIT; - break; - } - if (here_op & 32) { - //Tracevv((stderr, "inflate: end of block\n")); - state.back = -1; - state.mode = TYPE; - break; - } - if (here_op & 64) { - strm.msg = 'invalid literal/length code'; - state.mode = BAD; - break; - } - state.extra = here_op & 15; - state.mode = LENEXT; - /* falls through */ - case LENEXT: - if (state.extra) { - //=== NEEDBITS(state.extra); - n = state.extra; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; - //--- DROPBITS(state.extra) ---// - hold >>>= state.extra; - bits -= state.extra; - //---// - state.back += state.extra; - } - //Tracevv((stderr, "inflate: length %u\n", state.length)); - state.was = state.length; - state.mode = DIST; - /* falls through */ - case DIST: - for (;;) { - here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/ - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - if ((here_op & 0xf0) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (;;) { - here = state.distcode[last_val + - ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)]; - here_bits = here >>> 24; - here_op = (here >>> 16) & 0xff; - here_val = here & 0xffff; - - if ((last_bits + here_bits) <= bits) { break; } - //--- PULLBYTE() ---// - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - //---// - } - //--- DROPBITS(last.bits) ---// - hold >>>= last_bits; - bits -= last_bits; - //---// - state.back += last_bits; - } - //--- DROPBITS(here.bits) ---// - hold >>>= here_bits; - bits -= here_bits; - //---// - state.back += here_bits; - if (here_op & 64) { - strm.msg = 'invalid distance code'; - state.mode = BAD; - break; - } - state.offset = here_val; - state.extra = (here_op) & 15; - state.mode = DISTEXT; - /* falls through */ - case DISTEXT: - if (state.extra) { - //=== NEEDBITS(state.extra); - n = state.extra; - while (bits < n) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/; - //--- DROPBITS(state.extra) ---// - hold >>>= state.extra; - bits -= state.extra; - //---// - state.back += state.extra; - } -//#ifdef INFLATE_STRICT - if (state.offset > state.dmax) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD; - break; - } -//#endif - //Tracevv((stderr, "inflate: distance %u\n", state.offset)); - state.mode = MATCH; - /* falls through */ - case MATCH: - if (left === 0) { break inf_leave; } - copy = _out - left; - if (state.offset > copy) { /* copy from window */ - copy = state.offset - copy; - if (copy > state.whave) { - if (state.sane) { - strm.msg = 'invalid distance too far back'; - state.mode = BAD; - break; - } -// (!) This block is disabled in zlib defailts, -// don't enable it for binary compatibility -//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR -// Trace((stderr, "inflate.c too far\n")); -// copy -= state.whave; -// if (copy > state.length) { copy = state.length; } -// if (copy > left) { copy = left; } -// left -= copy; -// state.length -= copy; -// do { -// output[put++] = 0; -// } while (--copy); -// if (state.length === 0) { state.mode = LEN; } -// break; -//#endif - } - if (copy > state.wnext) { - copy -= state.wnext; - from = state.wsize - copy; - } - else { - from = state.wnext - copy; - } - if (copy > state.length) { copy = state.length; } - from_source = state.window; - } - else { /* copy from output */ - from_source = output; - from = put - state.offset; - copy = state.length; - } - if (copy > left) { copy = left; } - left -= copy; - state.length -= copy; - do { - output[put++] = from_source[from++]; - } while (--copy); - if (state.length === 0) { state.mode = LEN; } - break; - case LIT: - if (left === 0) { break inf_leave; } - output[put++] = state.length; - left--; - state.mode = LEN; - break; - case CHECK: - if (state.wrap) { - //=== NEEDBITS(32); - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - // Use '|' insdead of '+' to make sure that result is signed - hold |= input[next++] << bits; - bits += 8; - } - //===// - _out -= left; - strm.total_out += _out; - state.total += _out; - if (_out) { - strm.adler = state.check = - /*UPDATE(state.check, put - _out, _out);*/ - (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out)); - - } - _out = left; - // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too - if ((state.flags ? hold : zswap32(hold)) !== state.check) { - strm.msg = 'incorrect data check'; - state.mode = BAD; - break; - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - //Tracev((stderr, "inflate: check matches trailer\n")); - } - state.mode = LENGTH; - /* falls through */ - case LENGTH: - if (state.wrap && state.flags) { - //=== NEEDBITS(32); - while (bits < 32) { - if (have === 0) { break inf_leave; } - have--; - hold += input[next++] << bits; - bits += 8; - } - //===// - if (hold !== (state.total & 0xffffffff)) { - strm.msg = 'incorrect length check'; - state.mode = BAD; - break; - } - //=== INITBITS(); - hold = 0; - bits = 0; - //===// - //Tracev((stderr, "inflate: length matches trailer\n")); - } - state.mode = DONE; - /* falls through */ - case DONE: - ret = Z_STREAM_END; - break inf_leave; - case BAD: - ret = Z_DATA_ERROR; - break inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - /* falls through */ - default: - return Z_STREAM_ERROR; - } - } - - // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave" - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - - //--- RESTORE() --- - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - //--- - - if (state.wsize || (_out !== strm.avail_out && state.mode < BAD && - (state.mode < CHECK || flush !== Z_FINISH))) { - if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ; - } - _in -= strm.avail_in; - _out -= strm.avail_out; - strm.total_in += _in; - strm.total_out += _out; - state.total += _out; - if (state.wrap && _out) { - strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ - (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out)); - } - strm.data_type = state.bits + (state.last ? 64 : 0) + - (state.mode === TYPE ? 128 : 0) + - (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); - if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) { - ret = Z_BUF_ERROR; - } - return ret; -} - -function inflateEnd(strm) { - - if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) { - return Z_STREAM_ERROR; - } - - var state = strm.state; - if (state.window) { - state.window = null; - } - strm.state = null; - return Z_OK; -} - -function inflateGetHeader(strm, head) { - var state; - - /* check state */ - if (!strm || !strm.state) { return Z_STREAM_ERROR; } - state = strm.state; - if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; } - - /* save header structure */ - state.head = head; - head.done = false; - return Z_OK; -} - -function inflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - - var state; - var dictid; - var ret; - - /* check state */ - if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; } - state = strm.state; - - if (state.wrap !== 0 && state.mode !== DICT) { - return Z_STREAM_ERROR; - } - - /* check for correct dictionary identifier */ - if (state.mode === DICT) { - dictid = 1; /* adler32(0, null, 0)*/ - /* dictid = adler32(dictid, dictionary, dictLength); */ - dictid = adler32(dictid, dictionary, dictLength, 0); - if (dictid !== state.check) { - return Z_DATA_ERROR; - } - } - /* copy dictionary to window using updatewindow(), which will amend the - existing dictionary if appropriate */ - ret = updatewindow(strm, dictionary, dictLength, dictLength); - if (ret) { - state.mode = MEM; - return Z_MEM_ERROR; - } - state.havedict = 1; - // Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -// String encode/decode helpers -// 'use strict'; - - -// var utils = require('./common'); - - -// Quick check if we can use fast array to bin string conversion -// -// - apply(Array) can fail on Android 2.2 -// - apply(Uint8Array) can fail on iOS 5.1 Safary -// -var STR_APPLY_OK = true; -var STR_APPLY_UIA_OK = true; - -try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; } -try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; } - - -// Table with utf8 lengths (calculated by first byte of sequence) -// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, -// because max possible codepoint is 0x10ffff -var _utf8len = new Uint8Array(256); -for (var q = 0; q < 256; q++) { - _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1); -} -_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start - - -// convert string to array (typed, when possible) -function string2buf(str) { - var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; - - // count binary size - for (m_pos = 0; m_pos < str_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 0xfc00) === 0xdc00) { - c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); - m_pos++; - } - } - buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; - } - - // allocate buffer - buf = new Uint8Array(buf_len); - - // convert - for (i = 0, m_pos = 0; i < buf_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 0xfc00) === 0xdc00) { - c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); - m_pos++; - } - } - if (c < 0x80) { - /* one byte */ - buf[i++] = c; - } else if (c < 0x800) { - /* two bytes */ - buf[i++] = 0xC0 | (c >>> 6); - buf[i++] = 0x80 | (c & 0x3f); - } else if (c < 0x10000) { - /* three bytes */ - buf[i++] = 0xE0 | (c >>> 12); - buf[i++] = 0x80 | (c >>> 6 & 0x3f); - buf[i++] = 0x80 | (c & 0x3f); - } else { - /* four bytes */ - buf[i++] = 0xf0 | (c >>> 18); - buf[i++] = 0x80 | (c >>> 12 & 0x3f); - buf[i++] = 0x80 | (c >>> 6 & 0x3f); - buf[i++] = 0x80 | (c & 0x3f); - } - } - - return buf; -} - -// Helper (used in 2 places) -function _buf2binstring(buf, len) { - // use fallback for big arrays to avoid stack overflow - if (len < 65537) { - if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) { - return String.fromCharCode.apply(null, shrinkBuf(buf, len)); - } - } - - var result = ''; - for (var i = 0; i < len; i++) { - result += String.fromCharCode(buf[i]); - } - return result; -} - - -// Convert binary string (typed, when possible) -function binstring2buf(str) { - var buf = new Uint8Array(str.length); - for (var i = 0, len = buf.length; i < len; i++) { - buf[i] = str.charCodeAt(i); - } - return buf; -} - - -// convert array to string -function buf2string(buf, max) { - var i, out, c, c_len; - var len = max || buf.length; - - // Reserve max possible length (2 words per char) - // NB: by unknown reasons, Array is significantly faster for - // String.fromCharCode.apply than Uint16Array. - var utf16buf = new Array(len * 2); - - for (out = 0, i = 0; i < len;) { - c = buf[i++]; - // quick process ascii - if (c < 0x80) { utf16buf[out++] = c; continue; } - - c_len = _utf8len[c]; - // skip 5 & 6 byte codes - if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; } - - // apply mask on first byte - c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; - // join the rest - while (c_len > 1 && i < len) { - c = (c << 6) | (buf[i++] & 0x3f); - c_len--; - } - - // terminated by end of string? - if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; } - - if (c < 0x10000) { - utf16buf[out++] = c; - } else { - c -= 0x10000; - utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff); - utf16buf[out++] = 0xdc00 | (c & 0x3ff); - } - } - - return _buf2binstring(utf16buf, out); -} - - -// Calculate max possible position in utf8 buffer, -// that will not break sequence. If that's not possible -// - (very small limits) return max size as is. -// -// buf[] - utf8 bytes array -// max - length limit (mandatory); -function utf8border(buf, max) { - var pos; - - max = max || buf.length; - if (max > buf.length) { max = buf.length; } - - // go back from last position, until start of sequence found - pos = max - 1; - while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } - - // Fuckup - very small and broken sequence, - // return max, because we should return something anyway. - if (pos < 0) { return max; } - - // If we came to start of buffer - that means vuffer is too small, - // return max too. - if (pos === 0) { return max; } - - return (pos + _utf8len[buf[pos]] > max) ? pos : max; -} - -/* Allowed flush values; see deflate() and inflate() below for details */ -var Z_NO_FLUSH = 0; -var Z_SYNC_FLUSH = 2; -var Z_FINISH$1 = 4; -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ -var Z_OK$1 = 0; -var Z_STREAM_END$1 = 1; -var Z_NEED_DICT$1 = 2; -//export var Z_MEM_ERROR = -4; -var Z_BUF_ERROR$1 = -5; - -// 'use strict'; - -var messages = { - 2: 'need dictionary', /* Z_NEED_DICT 2 */ - 1: 'stream end', /* Z_STREAM_END 1 */ - 0: '', /* Z_OK 0 */ - '-1': 'file error', /* Z_ERRNO (-1) */ - '-2': 'stream error', /* Z_STREAM_ERROR (-2) */ - '-3': 'data error', /* Z_DATA_ERROR (-3) */ - '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */ - '-5': 'buffer error', /* Z_BUF_ERROR (-5) */ - '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ -}; - -// 'use strict'; - - -function ZStream() { - /* next input byte */ - this.input = null; // JS specific, because we have no pointers - this.next_in = 0; - /* number of bytes available at input */ - this.avail_in = 0; - /* total number of input bytes read so far */ - this.total_in = 0; - /* next output byte should be put there */ - this.output = null; // JS specific, because we have no pointers - this.next_out = 0; - /* remaining free space at output */ - this.avail_out = 0; - /* total number of bytes output so far */ - this.total_out = 0; - /* last error message, NULL if no error */ - this.msg = ''/*Z_NULL*/; - /* not visible by applications */ - this.state = null; - /* best guess about the data type: binary or text */ - this.data_type = 2/*Z_UNKNOWN*/; - /* adler32 value of the uncompressed data */ - this.adler = 0; -} - -// 'use strict'; - - -function GZheader() { - /* true if compressed data believed to be text */ - this.text = 0; - /* modification time */ - this.time = 0; - /* extra flags (not used when writing a gzip file) */ - this.xflags = 0; - /* operating system */ - this.os = 0; - /* pointer to extra field or Z_NULL if none */ - this.extra = null; - /* extra field length (valid if extra != Z_NULL) */ - this.extra_len = 0; // Actually, we don't need it in JS, - // but leave for few code modifications - - // - // Setup limits is not necessary because in js we should not preallocate memory - // for inflate use constant limit in 65536 bytes - // - - /* space at extra (only when reading header) */ - // this.extra_max = 0; - /* pointer to zero-terminated file name or Z_NULL */ - this.name = ''; - /* space at name (only when reading header) */ - // this.name_max = 0; - /* pointer to zero-terminated comment or Z_NULL */ - this.comment = ''; - /* space at comment (only when reading header) */ - // this.comm_max = 0; - /* true if there was or will be a header crc */ - this.hcrc = 0; - /* true when done reading gzip header (not used when writing a gzip file) */ - this.done = false; -} - -// 'use strict'; - - -// var zlib_inflate = require('./zlib/inflate'); -// var utils = require('./utils/common'); -// var strings = require('./utils/strings'); -// var c = require('./zlib/constants'); -// var msg = require('./zlib/messages'); -// var ZStream = require('./zlib/zstream'); -// var GZheader = require('./zlib/gzheader'); - -var toString = Object.prototype.toString; - -/** - * class Inflate - * - * Generic JS-style wrapper for zlib calls. If you don't need - * streaming behaviour - use more simple functions: [[inflate]] - * and [[inflateRaw]]. - **/ - -/* internal - * inflate.chunks -> Array - * - * Chunks of output data, if [[Inflate#onData]] not overriden. - **/ - -/** - * Inflate.result -> Uint8Array|Array|String - * - * Uncompressed result, generated by default [[Inflate#onData]] - * and [[Inflate#onEnd]] handlers. Filled after you push last chunk - * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you - * push a chunk with explicit flush (call [[Inflate#push]] with - * `Z_SYNC_FLUSH` param). - **/ - -/** - * Inflate.err -> Number - * - * Error code after inflate finished. 0 (Z_OK) on success. - * Should be checked if broken data possible. - **/ - -/** - * Inflate.msg -> String - * - * Error message, if [[Inflate.err]] != 0 - **/ - - -/** - * new Inflate(options) - * - options (Object): zlib inflate options. - * - * Creates new inflator instance with specified params. Throws exception - * on bad params. Supported options: - * - * - `windowBits` - * - `dictionary` - * - * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) - * for more information on these. - * - * Additional options, for internal needs: - * - * - `chunkSize` - size of generated data chunks (16K by default) - * - `raw` (Boolean) - do raw inflate - * - `to` (String) - if equal to 'string', then result will be converted - * from utf8 to utf16 (javascript) string. When string output requested, - * chunk length can differ from `chunkSize`, depending on content. - * - * By default, when no options set, autodetect deflate/gzip data format via - * wrapper header. - * - * ##### Example: - * - * ```javascript - * var pako = require('pako') - * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9]) - * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]); - * - * var inflate = new pako.Inflate({ level: 3}); - * - * inflate.push(chunk1, false); - * inflate.push(chunk2, true); // true -> last chunk - * - * if (inflate.err) { throw new Error(inflate.err); } - * - * console.log(inflate.result); - * ``` - **/ -function Inflate(options) { - if (!(this instanceof Inflate)) { return new Inflate(options); } - - this.options = assign({ - chunkSize: 16384, - windowBits: 0, - to: '' - }, options || {}); - - var opt = this.options; - - // Force window size for `raw` data, if not set directly, - // because we have no header for autodetect. - if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) { - opt.windowBits = -opt.windowBits; - if (opt.windowBits === 0) { opt.windowBits = -15; } - } - - // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate - if ((opt.windowBits >= 0) && (opt.windowBits < 16) && - !(options && options.windowBits)) { - opt.windowBits += 32; - } - - // Gzip header has no info about windows size, we can do autodetect only - // for deflate. So, if window size not set, force it to max when gzip possible - if ((opt.windowBits > 15) && (opt.windowBits < 48)) { - // bit 3 (16) -> gzipped data - // bit 4 (32) -> autodetect gzip/deflate - if ((opt.windowBits & 15) === 0) { - opt.windowBits |= 15; - } - } - - this.err = 0; // error code, if happens (0 = Z_OK) - this.msg = ''; // error message - this.ended = false; // used to avoid multiple onEnd() calls - this.chunks = []; // chunks of compressed data - - this.strm = new ZStream(); - this.strm.avail_out = 0; - - var status = inflateInit2( - this.strm, - opt.windowBits - ); - - if (status !== Z_OK$1) { - throw new Error(messages[status]); - } - - this.header = new GZheader(); - - inflateGetHeader(this.strm, this.header); -} - -/** - * Inflate#push(data[, mode]) -> Boolean - * - data (Uint8Array|Array|ArrayBuffer|String): input data - * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes. - * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH. - * - * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with - * new output chunks. Returns `true` on success. The last data block must have - * mode Z_FINISH (or `true`). That will flush internal pending buffers and call - * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you - * can use mode Z_SYNC_FLUSH, keeping the decompression context. - * - * On fail call [[Inflate#onEnd]] with error code and return false. - * - * We strongly recommend to use `Uint8Array` on input for best speed (output - * format is detected automatically). Also, don't skip last param and always - * use the same type in your code (boolean or number). That will improve JS speed. - * - * For regular `Array`-s make sure all elements are [0..255]. - * - * ##### Example - * - * ```javascript - * push(chunk, false); // push one of data chunks - * ... - * push(chunk, true); // push last chunk - * ``` - **/ -Inflate.prototype.push = function (data, mode) { - var strm = this.strm; - var chunkSize = this.options.chunkSize; - var dictionary = this.options.dictionary; - var status, _mode; - var next_out_utf8, tail, utf8str; - var dict; - - // Flag to properly process Z_BUF_ERROR on testing inflate call - // when we check that all output data was flushed. - var allowBufError = false; - - if (this.ended) { return false; } - _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH); - - // Convert data if needed - if (typeof data === 'string') { - // Only binary strings can be decompressed on practice - strm.input = binstring2buf(data); - } else if (toString.call(data) === '[object ArrayBuffer]') { - strm.input = new Uint8Array(data); - } else { - strm.input = data; - } - - strm.next_in = 0; - strm.avail_in = strm.input.length; - - do { - if (strm.avail_out === 0) { - strm.output = new Uint8Array(chunkSize); - strm.next_out = 0; - strm.avail_out = chunkSize; - } - - status = inflate(strm, Z_NO_FLUSH); /* no bad return value */ - - if (status === Z_NEED_DICT$1 && dictionary) { - // Convert data if needed - if (typeof dictionary === 'string') { - dict = string2buf(dictionary); - } else if (toString.call(dictionary) === '[object ArrayBuffer]') { - dict = new Uint8Array(dictionary); - } else { - dict = dictionary; - } - - status = inflateSetDictionary(this.strm, dict); - - } - - if (status === Z_BUF_ERROR$1 && allowBufError === true) { - status = Z_OK$1; - allowBufError = false; - } - - if (status !== Z_STREAM_END$1 && status !== Z_OK$1) { - this.onEnd(status); - this.ended = true; - return false; - } - - if (strm.next_out) { - if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) { - - if (this.options.to === 'string') { - - next_out_utf8 = utf8border(strm.output, strm.next_out); - - tail = strm.next_out - next_out_utf8; - utf8str = buf2string(strm.output, next_out_utf8); - - // move tail - strm.next_out = tail; - strm.avail_out = chunkSize - tail; - if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); } - - this.onData(utf8str); - - } else { - this.onData(shrinkBuf(strm.output, strm.next_out)); - } - } - } - - // When no more input data, we should check that internal inflate buffers - // are flushed. The only way to do it when avail_out = 0 - run one more - // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR. - // Here we set flag to process this error properly. - // - // NOTE. Deflate does not return error in this case and does not needs such - // logic. - if (strm.avail_in === 0 && strm.avail_out === 0) { - allowBufError = true; - } - - } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1); - - if (status === Z_STREAM_END$1) { - _mode = Z_FINISH$1; - } - - // Finalize on the last chunk. - if (_mode === Z_FINISH$1) { - status = inflateEnd(this.strm); - this.onEnd(status); - this.ended = true; - return status === Z_OK$1; - } - - // callback interim results if Z_SYNC_FLUSH. - if (_mode === Z_SYNC_FLUSH) { - this.onEnd(Z_OK$1); - strm.avail_out = 0; - return true; - } - - return true; -}; - - -/** - * Inflate#onData(chunk) -> Void - * - chunk (Uint8Array|Array|String): ouput data. Type of array depends - * on js engine support. When string output requested, each chunk - * will be string. - * - * By default, stores data blocks in `chunks[]` property and glue - * those in `onEnd`. Override this handler, if you need another behaviour. - **/ -Inflate.prototype.onData = function (chunk) { - this.chunks.push(chunk); -}; - - -/** - * Inflate#onEnd(status) -> Void - * - status (Number): inflate status. 0 (Z_OK) on success, - * other if not. - * - * Called either after you tell inflate that the input stream is - * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH) - * or if an error happened. By default - join collected chunks, - * free memory and fill `results` / `err` properties. - **/ -Inflate.prototype.onEnd = function (status) { - // On success - join - if (status === Z_OK$1) { - if (this.options.to === 'string') { - // Glue & convert here, until we teach pako to send - // utf8 alligned strings to onData - this.result = this.chunks.join(''); - } else { - this.result = flattenChunks(this.chunks); - } - } - this.chunks = []; - this.err = status; - this.msg = this.strm.msg; -}; - - -/** - * inflate(data[, options]) -> Uint8Array|Array|String - * - data (Uint8Array|Array|String): input data to decompress. - * - options (Object): zlib inflate options. - * - * Decompress `data` with inflate/ungzip and `options`. Autodetect - * format via wrapper header by default. That's why we don't provide - * separate `ungzip` method. - * - * Supported options are: - * - * - windowBits - * - * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) - * for more information. - * - * Sugar (options): - * - * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify - * negative windowBits implicitly. - * - `to` (String) - if equal to 'string', then result will be converted - * from utf8 to utf16 (javascript) string. When string output requested, - * chunk length can differ from `chunkSize`, depending on content. - * - * - * ##### Example: - * - * ```javascript - * var pako = require('pako') - * , input = pako.deflate([1,2,3,4,5,6,7,8,9]) - * , output; - * - * try { - * output = pako.inflate(input); - * } catch (err) - * console.log(err); - * } - * ``` - **/ -function doInflate(input, options) { - var inflator = new Inflate(options); - - inflator.push(input, true); - - // That will never happens, if you don't cheat with options :) - if (inflator.err) { throw inflator.msg; } - - return inflator.result; -} - -/** - * @file Gzip Decompressor - * @author Alexander Rose - * @private - */ -function gzipDecompress(data) { - var decompressedData; - if (data instanceof ArrayBuffer) { - data = new Uint8Array(data); - } - try { - decompressedData = doInflate(data); - } - catch (e) { - decompressedData = data; // assume it is already uncompressed - } - return decompressedData; -} -DecompressorRegistry.add('gz', gzipDecompress); - -/** - * @file Datasource - * @author Alexander Rose - * @private - */ -/** - * Datasource base class - * @interface - */ -var Datasource = function Datasource () {}; - -/** - * @file RCSB Datasource - * @author Alexander Rose - * @private - */ -var baseUrl$1 = '//files.rcsb.org/download/'; -var mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'; -var mmtfFullUrl = mmtfBaseUrl + 'full/'; -var mmtfReducedUrl = mmtfBaseUrl + 'reduced/'; -var RcsbDatasource = /*@__PURE__*/(function (Datasource$$1) { - function RcsbDatasource () { - Datasource$$1.apply(this, arguments); - } - - if ( Datasource$$1 ) RcsbDatasource.__proto__ = Datasource$$1; - RcsbDatasource.prototype = Object.create( Datasource$$1 && Datasource$$1.prototype ); - RcsbDatasource.prototype.constructor = RcsbDatasource; - - RcsbDatasource.prototype.getUrl = function getUrl (src) { - // valid path are - // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf - // XXXX defaults to XXXX.cif - var info = getFileInfo(src); - var pdbid = info.name.substr(0, 4); - var url; - if (['pdb', 'cif'].includes(info.ext) && - (info.compressed === false || info.compressed === 'gz')) { - url = baseUrl$1 + info.path; - } - else if (info.ext === 'mmtf') { - if (info.base.endsWith('.bb')) { - url = mmtfReducedUrl + pdbid; - } - else { - url = mmtfFullUrl + pdbid; - } - } - else if (!info.ext) { - url = mmtfFullUrl + pdbid; - } - else { - Log.warn('unsupported ext', info.ext); - url = mmtfFullUrl + pdbid; - } - return getProtocol() + url; - }; - RcsbDatasource.prototype.getExt = function getExt (src) { - var ext = getFileInfo(src).ext; - return ext ? ext : 'mmtf'; - }; - - return RcsbDatasource; -}(Datasource)); -DatasourceRegistry.add('rcsb', new RcsbDatasource()); - -/** - * @file PubChem Datasource - * @author Alexander Rose - * @private - */ -var baseUrl$2 = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'; -var suffixUrl = '/SDF?record_type=3d'; -var PubchemDatasource = /*@__PURE__*/(function (Datasource$$1) { - function PubchemDatasource () { - Datasource$$1.apply(this, arguments); - } - - if ( Datasource$$1 ) PubchemDatasource.__proto__ = Datasource$$1; - PubchemDatasource.prototype = Object.create( Datasource$$1 && Datasource$$1.prototype ); - PubchemDatasource.prototype.constructor = PubchemDatasource; - - PubchemDatasource.prototype.getUrl = function getUrl (src) { - var info = getFileInfo(src); - var cid = info.name; - var url; - if (!info.ext || info.ext === 'sdf') { - url = baseUrl$2 + cid + suffixUrl; - } - else { - Log.warn('unsupported ext', info.ext); - url = baseUrl$2 + cid + suffixUrl; - } - return getProtocol() + url; - }; - PubchemDatasource.prototype.getExt = function getExt (src) { - var ext = getFileInfo(src).ext; - return ext ? ext : 'sdf'; - }; - - return PubchemDatasource; -}(Datasource)); -DatasourceRegistry.add('pubchem', new PubchemDatasource()); - -/** - * @file Pass Through Datasource - * @author Alexander Rose - * @private - */ -var PassThroughDatasource = /*@__PURE__*/(function (Datasource$$1) { - function PassThroughDatasource () { - Datasource$$1.apply(this, arguments); - } - - if ( Datasource$$1 ) PassThroughDatasource.__proto__ = Datasource$$1; - PassThroughDatasource.prototype = Object.create( Datasource$$1 && Datasource$$1.prototype ); - PassThroughDatasource.prototype.constructor = PassThroughDatasource; - - PassThroughDatasource.prototype.getUrl = function getUrl (path) { - return path; - }; - PassThroughDatasource.prototype.getExt = function getExt (path) { - return getFileInfo(path).ext; - }; - - return PassThroughDatasource; -}(Datasource)); -DatasourceRegistry.add('ftp', new PassThroughDatasource()); -DatasourceRegistry.add('http', new PassThroughDatasource()); -DatasourceRegistry.add('https', new PassThroughDatasource()); - -/** - * @file Static Datasource - * @author Alexander Rose - * @private - */ -var reProtocol = /^((http|https|ftp):)*\/\//; -var StaticDatasource = /*@__PURE__*/(function (Datasource$$1) { - function StaticDatasource(baseUrl) { - if ( baseUrl === void 0 ) baseUrl = ''; - - Datasource$$1.call(this); - this.baseUrl = baseUrl; - } +"use strict"; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__restArguments_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__executeBound_js__ = __webpack_require__(79); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__underscore_js__ = __webpack_require__(8); - if ( Datasource$$1 ) StaticDatasource.__proto__ = Datasource$$1; - StaticDatasource.prototype = Object.create( Datasource$$1 && Datasource$$1.prototype ); - StaticDatasource.prototype.constructor = StaticDatasource; - StaticDatasource.prototype.getUrl = function getUrl (src) { - var info = getFileInfo(src); - var url = this.baseUrl + info.path; - if (!reProtocol.test(this.baseUrl)) { - url = getAbsolutePath(url); - } - return url; - }; - StaticDatasource.prototype.getExt = function getExt (src) { - return getFileInfo(src).ext; - }; - return StaticDatasource; -}(Datasource)); -/** - * @file MDsrv Datasource - * @author Alexander Rose - * @private - */ -var MdsrvDatasource = /*@__PURE__*/(function (Datasource$$1) { - function MdsrvDatasource(baseUrl) { - if ( baseUrl === void 0 ) baseUrl = ''; - Datasource$$1.call(this); - this.baseUrl = baseUrl; +// Partially apply a function by creating a version that has had some of its +// arguments pre-filled, without changing its dynamic `this` context. `_` acts +// as a placeholder by default, allowing any combination of arguments to be +// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. +var partial = Object(__WEBPACK_IMPORTED_MODULE_0__restArguments_js__["a" /* default */])(function(func, boundArgs) { + var placeholder = partial.placeholder; + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; } + while (position < arguments.length) args.push(arguments[position++]); + return Object(__WEBPACK_IMPORTED_MODULE_1__executeBound_js__["a" /* default */])(func, bound, this, this, args); + }; + return bound; +}); - if ( Datasource$$1 ) MdsrvDatasource.__proto__ = Datasource$$1; - MdsrvDatasource.prototype = Object.create( Datasource$$1 && Datasource$$1.prototype ); - MdsrvDatasource.prototype.constructor = MdsrvDatasource; - MdsrvDatasource.prototype.getListing = function getListing (path) { - if ( path === void 0 ) path = ''; - - var url = (this.baseUrl) + "dir/" + path; - if (url[url.length - 1] !== '/') - { url += '/'; } - return autoLoad(url, { - ext: 'json' - }).then(function (jsonData) { return ({ - path: path, - data: jsonData.data - }); }); - }; - MdsrvDatasource.prototype.getUrl = function getUrl (src) { - var info = getFileInfo(src); - return ((this.baseUrl) + "file/" + (info.path) + (info.query)); - }; - MdsrvDatasource.prototype.getCountUrl = function getCountUrl (src) { - var info = getFileInfo(src); - return ((this.baseUrl) + "traj/numframes/" + (info.path) + (info.query)); - }; - MdsrvDatasource.prototype.getFrameUrl = function getFrameUrl (src, frameIndex) { - var info = getFileInfo(src); - return ((this.baseUrl) + "traj/frame/" + frameIndex + "/" + (info.path) + (info.query)); - }; - MdsrvDatasource.prototype.getFrameParams = function getFrameParams (src, atomIndices) { - return ("atomIndices=" + (atomIndices.join(';'))); - }; - MdsrvDatasource.prototype.getPathUrl = function getPathUrl (src, atomIndex) { - var info = getFileInfo(src); - return ((this.baseUrl) + "traj/path/" + atomIndex + "/" + (info.path) + (info.query)); - }; - MdsrvDatasource.prototype.getExt = function getExt (src) { - return getFileInfo(src).ext; - }; - - return MdsrvDatasource; -}(Datasource)); - -/** - * @file UI Parameters - * @author Alexander Rose - */ -function BooleanParam() { return { type: 'boolean' }; } -function ColorParam() { return { type: 'color' }; } -function IntegerParam(max, min) { - return { type: 'integer', max: max, min: min }; -} -function NumberParam(precision, max, min) { - return { type: 'number', precision: precision, max: max, min: min }; -} -function RangeParam(step, max, min) { - return { type: 'range', step: step, max: max, min: min }; -} -function SelectParam() { - var options = [], len = arguments.length; - while ( len-- ) options[ len ] = arguments[ len ]; - - return { type: 'select', options: options.reduce(function (o, k) { - var obj; - - return (Object.assign(Object.assign({}, o), ( obj = {}, obj[k] = k, obj ))); - }, {}) }; -} -var UIStageParameters = { - backgroundColor: ColorParam(), - quality: SelectParam('auto', 'low', 'medium', 'high'), - sampleLevel: RangeParam(1, 5, -1), - impostor: BooleanParam(), - workerDefault: BooleanParam(), - rotateSpeed: NumberParam(1, 10, 0), - zoomSpeed: NumberParam(1, 10, 0), - panSpeed: NumberParam(1, 10, 0), - clipNear: RangeParam(1, 100, 0), - clipFar: RangeParam(1, 100, 0), - clipDist: IntegerParam(200, 0), - clipMode: SelectParam('scene', 'camera'), - clipScale: SelectParam('relative', 'absolute'), - fogNear: RangeParam(1, 100, 0), - fogFar: RangeParam(1, 100, 0), - cameraType: SelectParam('perspective', 'orthographic', 'stereo'), - cameraEyeSep: NumberParam(3, 1.0, 0.01), - cameraFov: RangeParam(1, 120, 15), - lightColor: ColorParam(), - lightIntensity: NumberParam(2, 10, 0), - ambientColor: ColorParam(), - ambientIntensity: NumberParam(2, 10, 0), - hoverTimeout: IntegerParam(10000, -1), - tooltip: BooleanParam(), - mousePreset: SelectParam.apply(void 0, Object.keys(MouseActionPresets)) -}; - -var version$1 = "2.0.0-dev.39"; - -/** - * @file Version - * @private - * @author Alexander Rose - */ -/** - * Version name - * @type {String} - */ -var Version = version$1; - -/** - * @file ngl - * @private - * @author Alexander Rose - */ -if (!window.Promise) { - window.Promise = __WEBPACK_IMPORTED_MODULE_4_promise_polyfill__["a" /* default */]; -} - - -//# sourceMappingURL=ngl.esm.js.map - - -/***/ }), -/* 19 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = values; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__keys_js__ = __webpack_require__(4); - - -// Retrieve the values of an object's properties. -function values(obj) { - var _keys = Object(__WEBPACK_IMPORTED_MODULE_0__keys_js__["a" /* default */])(obj); - var length = _keys.length; - var values = Array(length); - for (var i = 0; i < length; i++) { - values[i] = obj[_keys[i]]; - } - return values; -} +partial.placeholder = __WEBPACK_IMPORTED_MODULE_2__underscore_js__["a" /* default */]; +/* harmony default export */ __webpack_exports__["a"] = (partial); /***/ }), -/* 20 */ +/* 32 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = flatten; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__getLength_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isArray_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__isArguments_js__ = __webpack_require__(38); - - +/* harmony export (immutable) */ __webpack_exports__["a"] = group; +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cb_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each_js__ = __webpack_require__(16); -// Internal implementation of a recursive `flatten` function. -function flatten(input, depth, strict, output) { - output = output || []; - if (!depth && depth !== 0) { - depth = Infinity; - } else if (depth <= 0) { - return output.concat(input); - } - var idx = output.length; - for (var i = 0, length = Object(__WEBPACK_IMPORTED_MODULE_0__getLength_js__["a" /* default */])(input); i < length; i++) { - var value = input[i]; - if (Object(__WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__["a" /* default */])(value) && (Object(__WEBPACK_IMPORTED_MODULE_2__isArray_js__["a" /* default */])(value) || Object(__WEBPACK_IMPORTED_MODULE_3__isArguments_js__["a" /* default */])(value))) { - // Flatten current level of array or arguments object. - if (depth > 1) { - flatten(value, depth - 1, strict, output); - idx = output.length; - } else { - var j = 0, len = value.length; - while (j < len) output[idx++] = value[j++]; - } - } else if (!strict) { - output[idx++] = value; - } - } - return output; +// An internal function used for aggregate "group by" operations. +function group(behavior, partition) { + return function(obj, iteratee, context) { + var result = partition ? [[], []] : {}; + iteratee = Object(__WEBPACK_IMPORTED_MODULE_0__cb_js__["a" /* default */])(iteratee, context); + Object(__WEBPACK_IMPORTED_MODULE_1__each_js__["a" /* default */])(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; } /***/ }), -/* 21 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = map; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cb_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__keys_js__ = __webpack_require__(4); - +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { +var __WEBPACK_AMD_DEFINE_RESULT__;/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */ +/*global define:false, require:false, exports:false, module:false, signals:false */ +/** @license + * JS Signals + * Released under the MIT license + * Author: Miller Medeiros + * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM) + */ -// Return the results of applying the iteratee to each element. -function map(obj, iteratee, context) { - iteratee = Object(__WEBPACK_IMPORTED_MODULE_0__cb_js__["a" /* default */])(iteratee, context); - var _keys = !Object(__WEBPACK_IMPORTED_MODULE_1__isArrayLike_js__["a" /* default */])(obj) && Object(__WEBPACK_IMPORTED_MODULE_2__keys_js__["a" /* default */])(obj), - length = (_keys || obj).length, - results = Array(length); - for (var index = 0; index < length; index++) { - var currentKey = _keys ? _keys[index] : index; - results[index] = iteratee(obj[currentKey], currentKey, obj); - } - return results; -} +(function(global){ + // SignalBinding ------------------------------------------------- + //================================================================ -/***/ }), -/* 22 */ -/***/ (function(module, exports) { + /** + * Object that represents a binding between a Signal and a listener function. + *
- This is an internal constructor and shouldn't be called by regular users. + *
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. + * @author Miller Medeiros + * @constructor + * @internal + * @name SignalBinding + * @param {Signal} signal Reference to Signal object that listener is currently bound to. + * @param {Function} listener Handler function bound to the signal. + * @param {boolean} isOnce If binding should be executed just once. + * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {Number} [priority] The priority level of the event listener. (default = 0). + */ + function SignalBinding(signal, listener, isOnce, listenerContext, priority) { -module.exports = __WEBPACK_EXTERNAL_MODULE_22__; + /** + * Handler function bound to the signal. + * @type Function + * @private + */ + this._listener = listener; -/***/ }), -/* 23 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /** + * If binding should be executed just once. + * @type boolean + * @private + */ + this._isOnce = isOnce; -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return hasStringTagBug; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isIE11; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__setup_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__hasObjectTag_js__ = __webpack_require__(128); + /** + * Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @memberOf SignalBinding.prototype + * @name context + * @type Object|undefined|null + */ + this.context = listenerContext; + /** + * Reference to Signal object that listener is currently bound to. + * @type Signal + * @private + */ + this._signal = signal; + /** + * Listener priority + * @type Number + * @private + */ + this._priority = priority || 0; + } -// In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. -// In IE 11, the most common among them, this problem also applies to -// `Map`, `WeakMap` and `Set`. -var hasStringTagBug = ( - __WEBPACK_IMPORTED_MODULE_0__setup_js__["s" /* supportsDataView */] && Object(__WEBPACK_IMPORTED_MODULE_1__hasObjectTag_js__["a" /* default */])(new DataView(new ArrayBuffer(8))) - ), - isIE11 = (typeof Map !== 'undefined' && Object(__WEBPACK_IMPORTED_MODULE_1__hasObjectTag_js__["a" /* default */])(new Map)); + SignalBinding.prototype = { + /** + * If binding is active and should be executed. + * @type boolean + */ + active : true, -/***/ }), -/* 24 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /** + * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters) + * @type Array|null + */ + params : null, -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = allKeys; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isObject_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__setup_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__collectNonEnumProps_js__ = __webpack_require__(64); + /** + * Call listener passing arbitrary parameters. + *

If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

+ * @param {Array} [paramsArr] Array of parameters that should be passed to the listener + * @return {*} Value returned by the listener. + */ + execute : function (paramsArr) { + var handlerReturn, params; + if (this.active && !!this._listener) { + params = this.params? this.params.concat(paramsArr) : paramsArr; + handlerReturn = this._listener.apply(this.context, params); + if (this._isOnce) { + this.detach(); + } + } + return handlerReturn; + }, + /** + * Detach binding from signal. + * - alias to: mySignal.remove(myBinding.getListener()); + * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached. + */ + detach : function () { + return this.isBound()? this._signal.remove(this._listener, this.context) : null; + }, + /** + * @return {Boolean} `true` if binding is still bound to the signal and have a listener. + */ + isBound : function () { + return (!!this._signal && !!this._listener); + }, + /** + * @return {boolean} If SignalBinding will only be executed once. + */ + isOnce : function () { + return this._isOnce; + }, -// Retrieve all the enumerable property names of an object. -function allKeys(obj) { - if (!Object(__WEBPACK_IMPORTED_MODULE_0__isObject_js__["a" /* default */])(obj)) return []; - var keys = []; - for (var key in obj) keys.push(key); - // Ahem, IE < 9. - if (__WEBPACK_IMPORTED_MODULE_1__setup_js__["h" /* hasEnumBug */]) Object(__WEBPACK_IMPORTED_MODULE_2__collectNonEnumProps_js__["a" /* default */])(obj, keys); - return keys; -} + /** + * @return {Function} Handler function bound to the signal. + */ + getListener : function () { + return this._listener; + }, + /** + * @return {Signal} Signal that listener is currently bound to. + */ + getSignal : function () { + return this._signal; + }, -/***/ }), -/* 25 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + /** + * Delete instance properties + * @private + */ + _destroy : function () { + delete this._signal; + delete this._listener; + delete this.context; + }, -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = toPath; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__underscore_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__toPath_js__ = __webpack_require__(72); + /** + * @return {string} String representation of the object. + */ + toString : function () { + return '[SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']'; + } + }; -// Internal wrapper for `_.toPath` to enable minification. -// Similar to `cb` for `_.iteratee`. -function toPath(path) { - return __WEBPACK_IMPORTED_MODULE_0__underscore_js__["a" /* default */].toPath(path); -} +/*global SignalBinding:false*/ + // Signal -------------------------------------------------------- + //================================================================ -/***/ }), -/* 26 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + function validateListener(listener, fnName) { + if (typeof listener !== 'function') { + throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) ); + } + } -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = optimizeCb; -// Internal function that returns an efficient (for current engines) version -// of the passed-in callback, to be repeatedly applied in other Underscore -// functions. -function optimizeCb(func, context, argCount) { - if (context === void 0) return func; - switch (argCount == null ? 3 : argCount) { - case 1: return function(value) { - return func.call(context, value); - }; - // The 2-argument case is omitted because we’re not using it. - case 3: return function(value, index, collection) { - return func.call(context, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(context, accumulator, value, index, collection); - }; - } - return function() { - return func.apply(context, arguments); - }; -} + /** + * Custom event broadcaster + *
- inspired by Robert Penner's AS3 Signals. + * @name Signal + * @author Miller Medeiros + * @constructor + */ + function Signal() { + /** + * @type Array. + * @private + */ + this._bindings = []; + this._prevParams = null; + // enforce dispatch to aways work on same context (#47) + var self = this; + this.dispatch = function(){ + Signal.prototype.dispatch.apply(self, arguments); + }; + } -/***/ }), -/* 27 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + Signal.prototype = { -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = filter; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cb_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each_js__ = __webpack_require__(16); + /** + * Signals Version Number + * @type String + * @const + */ + VERSION : '1.0.0', + /** + * If Signal should keep record of previously dispatched parameters and + * automatically execute listener during `add()`/`addOnce()` if Signal was + * already dispatched before. + * @type boolean + */ + memorize : false, + /** + * @type boolean + * @private + */ + _shouldPropagate : true, -// Return all the elements that pass a truth test. -function filter(obj, predicate, context) { - var results = []; - predicate = Object(__WEBPACK_IMPORTED_MODULE_0__cb_js__["a" /* default */])(predicate, context); - Object(__WEBPACK_IMPORTED_MODULE_1__each_js__["a" /* default */])(obj, function(value, index, list) { - if (predicate(value, index, list)) results.push(value); - }); - return results; -} + /** + * If Signal is active and should broadcast events. + *

IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

+ * @type boolean + */ + active : true, + /** + * @param {Function} listener + * @param {boolean} isOnce + * @param {Object} [listenerContext] + * @param {Number} [priority] + * @return {SignalBinding} + * @private + */ + _registerListener : function (listener, isOnce, listenerContext, priority) { -/***/ }), -/* 28 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var prevIndex = this._indexOfListener(listener, listenerContext), + binding; -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = contains; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isArrayLike_js__ = __webpack_require__(9); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__values_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__indexOf_js__ = __webpack_require__(88); + if (prevIndex !== -1) { + binding = this._bindings[prevIndex]; + if (binding.isOnce() !== isOnce) { + throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.'); + } + } else { + binding = new SignalBinding(this, listener, isOnce, listenerContext, priority); + this._addBinding(binding); + } + if(this.memorize && this._prevParams){ + binding.execute(this._prevParams); + } + return binding; + }, + /** + * @param {SignalBinding} binding + * @private + */ + _addBinding : function (binding) { + //simplified insertion sort + var n = this._bindings.length; + do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority); + this._bindings.splice(n + 1, 0, binding); + }, -// Determine if the array or object contains a given item (using `===`). -function contains(obj, item, fromIndex, guard) { - if (!Object(__WEBPACK_IMPORTED_MODULE_0__isArrayLike_js__["a" /* default */])(obj)) obj = Object(__WEBPACK_IMPORTED_MODULE_1__values_js__["a" /* default */])(obj); - if (typeof fromIndex != 'number' || guard) fromIndex = 0; - return Object(__WEBPACK_IMPORTED_MODULE_2__indexOf_js__["a" /* default */])(obj, item, fromIndex) >= 0; -} + /** + * @param {Function} listener + * @return {number} + * @private + */ + _indexOfListener : function (listener, context) { + var n = this._bindings.length, + cur; + while (n--) { + cur = this._bindings[n]; + if (cur._listener === listener && cur.context === context) { + return n; + } + } + return -1; + }, + /** + * Check if listener was attached to Signal. + * @param {Function} listener + * @param {Object} [context] + * @return {boolean} if Signal has the specified listener. + */ + has : function (listener, context) { + return this._indexOfListener(listener, context) !== -1; + }, -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { + /** + * Add a listener to the signal. + * @param {Function} listener Signal handler function. + * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) + * @return {SignalBinding} An Object representing the binding between the Signal and listener. + */ + add : function (listener, listenerContext, priority) { + validateListener(listener, 'add'); + return this._registerListener(listener, false, listenerContext, priority); + }, -"use strict"; + /** + * Add listener to the signal that should be removed after first execution (will be executed only once). + * @param {Function} listener Signal handler function. + * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) + * @return {SignalBinding} An Object representing the binding between the Signal and listener. + */ + addOnce : function (listener, listenerContext, priority) { + validateListener(listener, 'addOnce'); + return this._registerListener(listener, true, listenerContext, priority); + }, -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BaseView = void 0; -const widgets = __webpack_require__(22); -var NGL = __webpack_require__(18); // not sure why I can not import it -class BaseView extends widgets.DOMWidgetView { - render() { - if (this.isEmbeded()) { - // embed mode: let NGLView call the handleEmbed directly - return; - } - this.handleMessage(); - this.displayed.then(() => { - this.model.set("_ready", true); - this.touch(); - }); - } - executeCode(code) { - eval(code); - } - handleMessage() { - this.model.on("msg:custom", function (msg) { - this.on_msg(msg); - }.bind(this)); - } - on_msg(msg) { - if (msg.type == 'callMethod') { - console.log("from BaseView", msg); - this[msg.methodName].apply(this, msg.args, msg.kwargs); - } - } - isEmbeded() { - return (this.model.comm == undefined); - } -} -exports.BaseView = BaseView; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9iYXNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlEQUFnRDtBQUNoRCxJQUFJLEdBQUcsR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUEsQ0FBQyxtQ0FBbUM7QUFHNUQsTUFDTSxRQUFTLFNBQVEsT0FBTyxDQUFDLGFBQWE7SUFFeEMsTUFBTTtRQUNOLElBQUksSUFBSSxDQUFDLFNBQVMsRUFBRSxFQUFDO1lBQ2Isd0RBQXdEO1lBQ3hELE9BQU07U0FDVDtRQUNELElBQUksQ0FBQyxhQUFhLEVBQUUsQ0FBQztRQUNyQixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUU7WUFDckIsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFBO1lBQzlCLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNoQixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUM7SUFFRCxXQUFXLENBQUMsSUFBSTtRQUNaLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNmLENBQUM7SUFFRCxhQUFhO1FBQ1QsSUFBSSxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsWUFBWSxFQUFFLFVBQVMsR0FBRztZQUNwQyxJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ3BCLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQTtJQUNqQixDQUFDO0lBRUQsTUFBTSxDQUFDLEdBQUc7UUFDTixJQUFJLEdBQUcsQ0FBQyxJQUFJLElBQUksWUFBWSxFQUFDO1lBQ3pCLE9BQU8sQ0FBQyxHQUFHLENBQUMsZUFBZSxFQUFFLEdBQUcsQ0FBQyxDQUFBO1lBQ2pDLElBQUksQ0FBQyxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUMsS0FBSyxDQUFDLElBQUksRUFBRSxHQUFHLENBQUMsSUFBSSxFQUFFLEdBQUcsQ0FBQyxNQUFNLENBQUMsQ0FBQTtTQUN6RDtJQUNMLENBQUM7SUFFRCxTQUFTO1FBQ0wsT0FBTyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxJQUFJLFNBQVMsQ0FBQyxDQUFBO0lBQ3pDLENBQUM7Q0FDSjtBQW5DRCw0QkFtQ0MifQ== + /** + * Remove a single listener from the dispatch queue. + * @param {Function} listener Handler function that should be removed. + * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). + * @return {Function} Listener handler function. + */ + remove : function (listener, context) { + validateListener(listener, 'remove'); -/***/ }), -/* 30 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + var i = this._indexOfListener(listener, context); + if (i !== -1) { + this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal + this._bindings.splice(i, 1); + } + return listener; + }, -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = matcher; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__extendOwn_js__ = __webpack_require__(42); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isMatch_js__ = __webpack_require__(65); + /** + * Remove all listeners from the Signal. + */ + removeAll : function () { + var n = this._bindings.length; + while (n--) { + this._bindings[n]._destroy(); + } + this._bindings.length = 0; + }, + /** + * @return {number} Number of listeners attached to the Signal. + */ + getNumListeners : function () { + return this._bindings.length; + }, + /** + * Stop propagation of the event, blocking the dispatch to next listeners on the queue. + *

IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

+ * @see Signal.prototype.disable + */ + halt : function () { + this._shouldPropagate = false; + }, -// Returns a predicate for checking whether an object has a given set of -// `key:value` pairs. -function matcher(attrs) { - attrs = Object(__WEBPACK_IMPORTED_MODULE_0__extendOwn_js__["a" /* default */])({}, attrs); - return function(obj) { - return Object(__WEBPACK_IMPORTED_MODULE_1__isMatch_js__["a" /* default */])(obj, attrs); - }; -} + /** + * Dispatch/Broadcast Signal to all listeners added to the queue. + * @param {...*} [params] Parameters that should be passed to each handler. + */ + dispatch : function (params) { + if (! this.active) { + return; + } + var paramsArr = Array.prototype.slice.call(arguments), + n = this._bindings.length, + bindings; -/***/ }), -/* 31 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { + if (this.memorize) { + this._prevParams = paramsArr; + } -"use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__restArguments_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__executeBound_js__ = __webpack_require__(80); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__underscore_js__ = __webpack_require__(8); + if (! n) { + //should come after memorize + return; + } + bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch + this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch. + //execute all callbacks until end of the list or until a callback returns `false` or stops propagation + //reverse loop since listeners with higher priority will be added at the end of the list + do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); + }, + /** + * Forget memorized arguments. + * @see Signal.memorize + */ + forget : function(){ + this._prevParams = null; + }, -// Partially apply a function by creating a version that has had some of its -// arguments pre-filled, without changing its dynamic `this` context. `_` acts -// as a placeholder by default, allowing any combination of arguments to be -// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. -var partial = Object(__WEBPACK_IMPORTED_MODULE_0__restArguments_js__["a" /* default */])(function(func, boundArgs) { - var placeholder = partial.placeholder; - var bound = function() { - var position = 0, length = boundArgs.length; - var args = Array(length); - for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; - } - while (position < arguments.length) args.push(arguments[position++]); - return Object(__WEBPACK_IMPORTED_MODULE_1__executeBound_js__["a" /* default */])(func, bound, this, this, args); - }; - return bound; -}); + /** + * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). + *

IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

+ */ + dispose : function () { + this.removeAll(); + delete this._bindings; + delete this._prevParams; + }, -partial.placeholder = __WEBPACK_IMPORTED_MODULE_2__underscore_js__["a" /* default */]; -/* harmony default export */ __webpack_exports__["a"] = (partial); + /** + * @return {string} String representation of the object. + */ + toString : function () { + return '[Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']'; + } + }; -/***/ }), -/* 32 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { -"use strict"; -/* harmony export (immutable) */ __webpack_exports__["a"] = group; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__cb_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__each_js__ = __webpack_require__(16); + // Namespace ----------------------------------------------------- + //================================================================ + /** + * Signals namespace + * @namespace + * @name signals + */ + var signals = Signal; + /** + * Custom event broadcaster + * @see Signal + */ + // alias for backwards compatibility (see #gh-44) + signals.Signal = Signal; -// An internal function used for aggregate "group by" operations. -function group(behavior, partition) { - return function(obj, iteratee, context) { - var result = partition ? [[], []] : {}; - iteratee = Object(__WEBPACK_IMPORTED_MODULE_0__cb_js__["a" /* default */])(iteratee, context); - Object(__WEBPACK_IMPORTED_MODULE_1__each_js__["a" /* default */])(obj, function(value, index) { - var key = iteratee(value, index, obj); - behavior(result, value, key); - }); - return result; - }; -} -/***/ }), -/* 33 */ -/***/ (function(module, exports) { + //exports to multiple environments + if(true){ //AMD + !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return signals; }).call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof module !== 'undefined' && module.exports){ //node + module.exports = signals; + } else { //browser + //use string because of Google closure compiler ADVANCED_MODE + /*jslint sub:true */ + global['signals'] = signals; + } -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; +}(this)); /***/ }), @@ -63741,7 +12949,7 @@ module.exports = g; "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_default_js__ = __webpack_require__(122); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_default_js__ = __webpack_require__(114); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__index_default_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index_js__ = __webpack_require__(35); /* harmony namespace reexport (by provided) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return __WEBPACK_IMPORTED_MODULE_1__index_js__["VERSION"]; }); @@ -63921,27 +13129,27 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "restArguments", function() { return __WEBPACK_IMPORTED_MODULE_1__restArguments_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isObject_js__ = __webpack_require__(14); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isObject", function() { return __WEBPACK_IMPORTED_MODULE_2__isObject_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__isNull_js__ = __webpack_require__(123); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__isNull_js__ = __webpack_require__(116); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNull", function() { return __WEBPACK_IMPORTED_MODULE_3__isNull_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__isUndefined_js__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__isUndefined_js__ = __webpack_require__(53); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isUndefined", function() { return __WEBPACK_IMPORTED_MODULE_4__isUndefined_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__isBoolean_js__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__isBoolean_js__ = __webpack_require__(54); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isBoolean", function() { return __WEBPACK_IMPORTED_MODULE_5__isBoolean_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__isElement_js__ = __webpack_require__(124); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__isElement_js__ = __webpack_require__(117); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isElement", function() { return __WEBPACK_IMPORTED_MODULE_6__isElement_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__isString_js__ = __webpack_require__(36); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isString", function() { return __WEBPACK_IMPORTED_MODULE_7__isString_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__isNumber_js__ = __webpack_require__(56); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__isNumber_js__ = __webpack_require__(55); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNumber", function() { return __WEBPACK_IMPORTED_MODULE_8__isNumber_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__isDate_js__ = __webpack_require__(125); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__isDate_js__ = __webpack_require__(118); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isDate", function() { return __WEBPACK_IMPORTED_MODULE_9__isDate_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__isRegExp_js__ = __webpack_require__(126); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__isRegExp_js__ = __webpack_require__(119); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isRegExp", function() { return __WEBPACK_IMPORTED_MODULE_10__isRegExp_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__isError_js__ = __webpack_require__(127); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__isError_js__ = __webpack_require__(120); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isError", function() { return __WEBPACK_IMPORTED_MODULE_11__isError_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__isSymbol_js__ = __webpack_require__(57); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__isSymbol_js__ = __webpack_require__(56); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isSymbol", function() { return __WEBPACK_IMPORTED_MODULE_12__isSymbol_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__isArrayBuffer_js__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__isArrayBuffer_js__ = __webpack_require__(57); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArrayBuffer", function() { return __WEBPACK_IMPORTED_MODULE_13__isArrayBuffer_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__isDataView_js__ = __webpack_require__(37); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isDataView", function() { return __WEBPACK_IMPORTED_MODULE_14__isDataView_js__["a"]; }); @@ -63951,25 +13159,25 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isFunction", function() { return __WEBPACK_IMPORTED_MODULE_16__isFunction_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__isArguments_js__ = __webpack_require__(38); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isArguments", function() { return __WEBPACK_IMPORTED_MODULE_17__isArguments_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__isFinite_js__ = __webpack_require__(129); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__isFinite_js__ = __webpack_require__(122); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isFinite", function() { return __WEBPACK_IMPORTED_MODULE_18__isFinite_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__isNaN_js__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__isNaN_js__ = __webpack_require__(58); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isNaN", function() { return __WEBPACK_IMPORTED_MODULE_19__isNaN_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__isTypedArray_js__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__isTypedArray_js__ = __webpack_require__(59); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isTypedArray", function() { return __WEBPACK_IMPORTED_MODULE_20__isTypedArray_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__isEmpty_js__ = __webpack_require__(131); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__isEmpty_js__ = __webpack_require__(124); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return __WEBPACK_IMPORTED_MODULE_21__isEmpty_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__isMatch_js__ = __webpack_require__(65); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__isMatch_js__ = __webpack_require__(64); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isMatch", function() { return __WEBPACK_IMPORTED_MODULE_22__isMatch_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__isEqual_js__ = __webpack_require__(132); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__isEqual_js__ = __webpack_require__(125); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isEqual", function() { return __WEBPACK_IMPORTED_MODULE_23__isEqual_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__isMap_js__ = __webpack_require__(134); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__isMap_js__ = __webpack_require__(127); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isMap", function() { return __WEBPACK_IMPORTED_MODULE_24__isMap_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__isWeakMap_js__ = __webpack_require__(135); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__isWeakMap_js__ = __webpack_require__(128); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isWeakMap", function() { return __WEBPACK_IMPORTED_MODULE_25__isWeakMap_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__isSet_js__ = __webpack_require__(136); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__isSet_js__ = __webpack_require__(129); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isSet", function() { return __WEBPACK_IMPORTED_MODULE_26__isSet_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__isWeakSet_js__ = __webpack_require__(137); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__isWeakSet_js__ = __webpack_require__(130); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "isWeakSet", function() { return __WEBPACK_IMPORTED_MODULE_27__isWeakSet_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__keys_js__ = __webpack_require__(4); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "keys", function() { return __WEBPACK_IMPORTED_MODULE_28__keys_js__["a"]; }); @@ -63977,113 +13185,113 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "allKeys", function() { return __WEBPACK_IMPORTED_MODULE_29__allKeys_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__values_js__ = __webpack_require__(19); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "values", function() { return __WEBPACK_IMPORTED_MODULE_30__values_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__pairs_js__ = __webpack_require__(138); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__pairs_js__ = __webpack_require__(131); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pairs", function() { return __WEBPACK_IMPORTED_MODULE_31__pairs_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__invert_js__ = __webpack_require__(66); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__invert_js__ = __webpack_require__(65); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "invert", function() { return __WEBPACK_IMPORTED_MODULE_32__invert_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__functions_js__ = __webpack_require__(67); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__functions_js__ = __webpack_require__(66); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "functions", function() { return __WEBPACK_IMPORTED_MODULE_33__functions_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "methods", function() { return __WEBPACK_IMPORTED_MODULE_33__functions_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__extend_js__ = __webpack_require__(68); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__extend_js__ = __webpack_require__(67); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "extend", function() { return __WEBPACK_IMPORTED_MODULE_34__extend_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_35__extendOwn_js__ = __webpack_require__(42); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "extendOwn", function() { return __WEBPACK_IMPORTED_MODULE_35__extendOwn_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "assign", function() { return __WEBPACK_IMPORTED_MODULE_35__extendOwn_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_36__defaults_js__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_36__defaults_js__ = __webpack_require__(68); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "defaults", function() { return __WEBPACK_IMPORTED_MODULE_36__defaults_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_37__create_js__ = __webpack_require__(139); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_37__create_js__ = __webpack_require__(132); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return __WEBPACK_IMPORTED_MODULE_37__create_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__clone_js__ = __webpack_require__(140); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__clone_js__ = __webpack_require__(133); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "clone", function() { return __WEBPACK_IMPORTED_MODULE_38__clone_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_39__tap_js__ = __webpack_require__(141); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_39__tap_js__ = __webpack_require__(134); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "tap", function() { return __WEBPACK_IMPORTED_MODULE_39__tap_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_40__get_js__ = __webpack_require__(71); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_40__get_js__ = __webpack_require__(70); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "get", function() { return __WEBPACK_IMPORTED_MODULE_40__get_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__has_js__ = __webpack_require__(142); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__has_js__ = __webpack_require__(135); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "has", function() { return __WEBPACK_IMPORTED_MODULE_41__has_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__mapObject_js__ = __webpack_require__(143); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__mapObject_js__ = __webpack_require__(136); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mapObject", function() { return __WEBPACK_IMPORTED_MODULE_42__mapObject_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__identity_js__ = __webpack_require__(44); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return __WEBPACK_IMPORTED_MODULE_43__identity_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__constant_js__ = __webpack_require__(61); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__constant_js__ = __webpack_require__(60); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "constant", function() { return __WEBPACK_IMPORTED_MODULE_44__constant_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__noop_js__ = __webpack_require__(75); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__noop_js__ = __webpack_require__(74); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "noop", function() { return __WEBPACK_IMPORTED_MODULE_45__noop_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__toPath_js__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__toPath_js__ = __webpack_require__(71); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toPath", function() { return __WEBPACK_IMPORTED_MODULE_46__toPath_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_47__property_js__ = __webpack_require__(45); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "property", function() { return __WEBPACK_IMPORTED_MODULE_47__property_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_48__propertyOf_js__ = __webpack_require__(144); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_48__propertyOf_js__ = __webpack_require__(137); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "propertyOf", function() { return __WEBPACK_IMPORTED_MODULE_48__propertyOf_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_49__matcher_js__ = __webpack_require__(30); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "matcher", function() { return __WEBPACK_IMPORTED_MODULE_49__matcher_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "matches", function() { return __WEBPACK_IMPORTED_MODULE_49__matcher_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_50__times_js__ = __webpack_require__(145); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_50__times_js__ = __webpack_require__(138); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "times", function() { return __WEBPACK_IMPORTED_MODULE_50__times_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_51__random_js__ = __webpack_require__(76); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_51__random_js__ = __webpack_require__(75); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "random", function() { return __WEBPACK_IMPORTED_MODULE_51__random_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_52__now_js__ = __webpack_require__(46); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "now", function() { return __WEBPACK_IMPORTED_MODULE_52__now_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_53__escape_js__ = __webpack_require__(146); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_53__escape_js__ = __webpack_require__(139); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "escape", function() { return __WEBPACK_IMPORTED_MODULE_53__escape_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_54__unescape_js__ = __webpack_require__(147); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_54__unescape_js__ = __webpack_require__(140); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "unescape", function() { return __WEBPACK_IMPORTED_MODULE_54__unescape_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_55__templateSettings_js__ = __webpack_require__(79); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_55__templateSettings_js__ = __webpack_require__(78); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "templateSettings", function() { return __WEBPACK_IMPORTED_MODULE_55__templateSettings_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_56__template_js__ = __webpack_require__(149); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_56__template_js__ = __webpack_require__(142); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "template", function() { return __WEBPACK_IMPORTED_MODULE_56__template_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_57__result_js__ = __webpack_require__(150); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_57__result_js__ = __webpack_require__(143); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "result", function() { return __WEBPACK_IMPORTED_MODULE_57__result_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_58__uniqueId_js__ = __webpack_require__(151); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_58__uniqueId_js__ = __webpack_require__(144); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "uniqueId", function() { return __WEBPACK_IMPORTED_MODULE_58__uniqueId_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_59__chain_js__ = __webpack_require__(152); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_59__chain_js__ = __webpack_require__(145); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "chain", function() { return __WEBPACK_IMPORTED_MODULE_59__chain_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_60__iteratee_js__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_60__iteratee_js__ = __webpack_require__(73); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "iteratee", function() { return __WEBPACK_IMPORTED_MODULE_60__iteratee_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_61__partial_js__ = __webpack_require__(31); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "partial", function() { return __WEBPACK_IMPORTED_MODULE_61__partial_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_62__bind_js__ = __webpack_require__(81); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_62__bind_js__ = __webpack_require__(80); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "bind", function() { return __WEBPACK_IMPORTED_MODULE_62__bind_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_63__bindAll_js__ = __webpack_require__(153); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_63__bindAll_js__ = __webpack_require__(146); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "bindAll", function() { return __WEBPACK_IMPORTED_MODULE_63__bindAll_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_64__memoize_js__ = __webpack_require__(154); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_64__memoize_js__ = __webpack_require__(147); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "memoize", function() { return __WEBPACK_IMPORTED_MODULE_64__memoize_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_65__delay_js__ = __webpack_require__(82); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_65__delay_js__ = __webpack_require__(81); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "delay", function() { return __WEBPACK_IMPORTED_MODULE_65__delay_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_66__defer_js__ = __webpack_require__(155); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_66__defer_js__ = __webpack_require__(148); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "defer", function() { return __WEBPACK_IMPORTED_MODULE_66__defer_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_67__throttle_js__ = __webpack_require__(156); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_67__throttle_js__ = __webpack_require__(149); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return __WEBPACK_IMPORTED_MODULE_67__throttle_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_68__debounce_js__ = __webpack_require__(157); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_68__debounce_js__ = __webpack_require__(150); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return __WEBPACK_IMPORTED_MODULE_68__debounce_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_69__wrap_js__ = __webpack_require__(158); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_69__wrap_js__ = __webpack_require__(151); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "wrap", function() { return __WEBPACK_IMPORTED_MODULE_69__wrap_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_70__negate_js__ = __webpack_require__(47); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "negate", function() { return __WEBPACK_IMPORTED_MODULE_70__negate_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_71__compose_js__ = __webpack_require__(159); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_71__compose_js__ = __webpack_require__(152); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "compose", function() { return __WEBPACK_IMPORTED_MODULE_71__compose_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_72__after_js__ = __webpack_require__(160); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_72__after_js__ = __webpack_require__(153); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "after", function() { return __WEBPACK_IMPORTED_MODULE_72__after_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__before_js__ = __webpack_require__(83); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_73__before_js__ = __webpack_require__(82); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "before", function() { return __WEBPACK_IMPORTED_MODULE_73__before_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_74__once_js__ = __webpack_require__(161); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_74__once_js__ = __webpack_require__(154); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "once", function() { return __WEBPACK_IMPORTED_MODULE_74__once_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_75__findKey_js__ = __webpack_require__(84); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_75__findKey_js__ = __webpack_require__(83); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "findKey", function() { return __WEBPACK_IMPORTED_MODULE_75__findKey_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_76__findIndex_js__ = __webpack_require__(48); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "findIndex", function() { return __WEBPACK_IMPORTED_MODULE_76__findIndex_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_77__findLastIndex_js__ = __webpack_require__(86); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_77__findLastIndex_js__ = __webpack_require__(85); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "findLastIndex", function() { return __WEBPACK_IMPORTED_MODULE_77__findLastIndex_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_78__sortedIndex_js__ = __webpack_require__(87); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_78__sortedIndex_js__ = __webpack_require__(86); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "sortedIndex", function() { return __WEBPACK_IMPORTED_MODULE_78__sortedIndex_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_79__indexOf_js__ = __webpack_require__(88); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_79__indexOf_js__ = __webpack_require__(87); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "indexOf", function() { return __WEBPACK_IMPORTED_MODULE_79__indexOf_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_80__lastIndexOf_js__ = __webpack_require__(162); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_80__lastIndexOf_js__ = __webpack_require__(155); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "lastIndexOf", function() { return __WEBPACK_IMPORTED_MODULE_80__lastIndexOf_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_81__find_js__ = __webpack_require__(90); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_81__find_js__ = __webpack_require__(89); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "find", function() { return __WEBPACK_IMPORTED_MODULE_81__find_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "detect", function() { return __WEBPACK_IMPORTED_MODULE_81__find_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_82__findWhere_js__ = __webpack_require__(163); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_82__findWhere_js__ = __webpack_require__(156); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "findWhere", function() { return __WEBPACK_IMPORTED_MODULE_82__findWhere_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_83__each_js__ = __webpack_require__(16); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "each", function() { return __WEBPACK_IMPORTED_MODULE_83__each_js__["a"]; }); @@ -64091,101 +13299,101 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_84__map_js__ = __webpack_require__(21); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "map", function() { return __WEBPACK_IMPORTED_MODULE_84__map_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "collect", function() { return __WEBPACK_IMPORTED_MODULE_84__map_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_85__reduce_js__ = __webpack_require__(164); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_85__reduce_js__ = __webpack_require__(157); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "reduce", function() { return __WEBPACK_IMPORTED_MODULE_85__reduce_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "foldl", function() { return __WEBPACK_IMPORTED_MODULE_85__reduce_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "inject", function() { return __WEBPACK_IMPORTED_MODULE_85__reduce_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_86__reduceRight_js__ = __webpack_require__(165); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_86__reduceRight_js__ = __webpack_require__(158); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "reduceRight", function() { return __WEBPACK_IMPORTED_MODULE_86__reduceRight_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "foldr", function() { return __WEBPACK_IMPORTED_MODULE_86__reduceRight_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_87__filter_js__ = __webpack_require__(27); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "filter", function() { return __WEBPACK_IMPORTED_MODULE_87__filter_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "select", function() { return __WEBPACK_IMPORTED_MODULE_87__filter_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_88__reject_js__ = __webpack_require__(166); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_88__reject_js__ = __webpack_require__(159); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "reject", function() { return __WEBPACK_IMPORTED_MODULE_88__reject_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_89__every_js__ = __webpack_require__(167); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_89__every_js__ = __webpack_require__(160); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "every", function() { return __WEBPACK_IMPORTED_MODULE_89__every_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "all", function() { return __WEBPACK_IMPORTED_MODULE_89__every_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_90__some_js__ = __webpack_require__(168); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_90__some_js__ = __webpack_require__(161); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "some", function() { return __WEBPACK_IMPORTED_MODULE_90__some_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "any", function() { return __WEBPACK_IMPORTED_MODULE_90__some_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_91__contains_js__ = __webpack_require__(28); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "contains", function() { return __WEBPACK_IMPORTED_MODULE_91__contains_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "includes", function() { return __WEBPACK_IMPORTED_MODULE_91__contains_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "include", function() { return __WEBPACK_IMPORTED_MODULE_91__contains_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_92__invoke_js__ = __webpack_require__(169); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_92__invoke_js__ = __webpack_require__(162); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "invoke", function() { return __WEBPACK_IMPORTED_MODULE_92__invoke_js__["a"]; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_93__pluck_js__ = __webpack_require__(49); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pluck", function() { return __WEBPACK_IMPORTED_MODULE_93__pluck_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_94__where_js__ = __webpack_require__(170); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_94__where_js__ = __webpack_require__(163); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "where", function() { return __WEBPACK_IMPORTED_MODULE_94__where_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_95__max_js__ = __webpack_require__(92); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_95__max_js__ = __webpack_require__(91); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return __WEBPACK_IMPORTED_MODULE_95__max_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_96__min_js__ = __webpack_require__(171); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_96__min_js__ = __webpack_require__(164); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return __WEBPACK_IMPORTED_MODULE_96__min_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_97__shuffle_js__ = __webpack_require__(172); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_97__shuffle_js__ = __webpack_require__(165); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "shuffle", function() { return __WEBPACK_IMPORTED_MODULE_97__shuffle_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_98__sample_js__ = __webpack_require__(93); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_98__sample_js__ = __webpack_require__(92); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "sample", function() { return __WEBPACK_IMPORTED_MODULE_98__sample_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_99__sortBy_js__ = __webpack_require__(173); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_99__sortBy_js__ = __webpack_require__(166); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "sortBy", function() { return __WEBPACK_IMPORTED_MODULE_99__sortBy_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_100__groupBy_js__ = __webpack_require__(174); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_100__groupBy_js__ = __webpack_require__(167); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "groupBy", function() { return __WEBPACK_IMPORTED_MODULE_100__groupBy_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_101__indexBy_js__ = __webpack_require__(175); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_101__indexBy_js__ = __webpack_require__(168); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "indexBy", function() { return __WEBPACK_IMPORTED_MODULE_101__indexBy_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_102__countBy_js__ = __webpack_require__(176); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_102__countBy_js__ = __webpack_require__(169); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "countBy", function() { return __WEBPACK_IMPORTED_MODULE_102__countBy_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_103__partition_js__ = __webpack_require__(177); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_103__partition_js__ = __webpack_require__(170); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "partition", function() { return __WEBPACK_IMPORTED_MODULE_103__partition_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_104__toArray_js__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_104__toArray_js__ = __webpack_require__(93); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "toArray", function() { return __WEBPACK_IMPORTED_MODULE_104__toArray_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_105__size_js__ = __webpack_require__(178); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_105__size_js__ = __webpack_require__(171); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "size", function() { return __WEBPACK_IMPORTED_MODULE_105__size_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_106__pick_js__ = __webpack_require__(95); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_106__pick_js__ = __webpack_require__(94); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "pick", function() { return __WEBPACK_IMPORTED_MODULE_106__pick_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_107__omit_js__ = __webpack_require__(180); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_107__omit_js__ = __webpack_require__(173); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "omit", function() { return __WEBPACK_IMPORTED_MODULE_107__omit_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_108__first_js__ = __webpack_require__(181); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_108__first_js__ = __webpack_require__(174); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "first", function() { return __WEBPACK_IMPORTED_MODULE_108__first_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "head", function() { return __WEBPACK_IMPORTED_MODULE_108__first_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "take", function() { return __WEBPACK_IMPORTED_MODULE_108__first_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_109__initial_js__ = __webpack_require__(96); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_109__initial_js__ = __webpack_require__(95); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "initial", function() { return __WEBPACK_IMPORTED_MODULE_109__initial_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_110__last_js__ = __webpack_require__(182); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_110__last_js__ = __webpack_require__(175); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "last", function() { return __WEBPACK_IMPORTED_MODULE_110__last_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_111__rest_js__ = __webpack_require__(97); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_111__rest_js__ = __webpack_require__(96); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "rest", function() { return __WEBPACK_IMPORTED_MODULE_111__rest_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "tail", function() { return __WEBPACK_IMPORTED_MODULE_111__rest_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "drop", function() { return __WEBPACK_IMPORTED_MODULE_111__rest_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_112__compact_js__ = __webpack_require__(183); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_112__compact_js__ = __webpack_require__(176); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "compact", function() { return __WEBPACK_IMPORTED_MODULE_112__compact_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_113__flatten_js__ = __webpack_require__(184); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_113__flatten_js__ = __webpack_require__(177); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "flatten", function() { return __WEBPACK_IMPORTED_MODULE_113__flatten_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_114__without_js__ = __webpack_require__(185); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_114__without_js__ = __webpack_require__(178); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "without", function() { return __WEBPACK_IMPORTED_MODULE_114__without_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_115__uniq_js__ = __webpack_require__(99); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_115__uniq_js__ = __webpack_require__(98); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "uniq", function() { return __WEBPACK_IMPORTED_MODULE_115__uniq_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "unique", function() { return __WEBPACK_IMPORTED_MODULE_115__uniq_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_116__union_js__ = __webpack_require__(186); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_116__union_js__ = __webpack_require__(179); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "union", function() { return __WEBPACK_IMPORTED_MODULE_116__union_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_117__intersection_js__ = __webpack_require__(187); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_117__intersection_js__ = __webpack_require__(180); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "intersection", function() { return __WEBPACK_IMPORTED_MODULE_117__intersection_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_118__difference_js__ = __webpack_require__(98); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_118__difference_js__ = __webpack_require__(97); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "difference", function() { return __WEBPACK_IMPORTED_MODULE_118__difference_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_119__unzip_js__ = __webpack_require__(100); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_119__unzip_js__ = __webpack_require__(99); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "unzip", function() { return __WEBPACK_IMPORTED_MODULE_119__unzip_js__["a"]; }); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "transpose", function() { return __WEBPACK_IMPORTED_MODULE_119__unzip_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_120__zip_js__ = __webpack_require__(188); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_120__zip_js__ = __webpack_require__(181); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "zip", function() { return __WEBPACK_IMPORTED_MODULE_120__zip_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_121__object_js__ = __webpack_require__(189); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_121__object_js__ = __webpack_require__(182); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "object", function() { return __WEBPACK_IMPORTED_MODULE_121__object_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_122__range_js__ = __webpack_require__(190); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_122__range_js__ = __webpack_require__(183); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "range", function() { return __WEBPACK_IMPORTED_MODULE_122__range_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_123__chunk_js__ = __webpack_require__(191); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_123__chunk_js__ = __webpack_require__(184); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "chunk", function() { return __WEBPACK_IMPORTED_MODULE_123__chunk_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_124__mixin_js__ = __webpack_require__(192); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_124__mixin_js__ = __webpack_require__(185); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mixin", function() { return __WEBPACK_IMPORTED_MODULE_124__mixin_js__["a"]; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_125__underscore_array_methods_js__ = __webpack_require__(193); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_125__underscore_array_methods_js__ = __webpack_require__(186); /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return __WEBPACK_IMPORTED_MODULE_125__underscore_array_methods_js__["a"]; }); // Named Exports // ============= @@ -64387,7 +13595,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__tagTester_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isFunction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isArrayBuffer_js__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isArrayBuffer_js__ = __webpack_require__(57); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__stringTagBug_js__ = __webpack_require__(23); @@ -64435,7 +13643,7 @@ var isArguments = Object(__WEBPACK_IMPORTED_MODULE_0__tagTester_js__["a" /* defa /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__shallowProperty_js__ = __webpack_require__(63); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__shallowProperty_js__ = __webpack_require__(62); // Internal helper to obtain the `byteLength` property of an object. @@ -64615,7 +13823,7 @@ function negate(predicate) { /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createPredicateIndexFinder_js__ = __webpack_require__(85); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createPredicateIndexFinder_js__ = __webpack_require__(84); // Returns the first index on an array-like that passes a truth test. @@ -65421,7 +14629,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ // AMD. Register as an anonymous module. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(0), - __webpack_require__(204), + __webpack_require__(197), __webpack_require__(3), __webpack_require__(17) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), @@ -65844,8 +15052,8 @@ return $.widget( "ui.mouse", { /* unused harmony export LinePieces */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return LineSegments; }); /* unused harmony export LineStrip */ -/* unused harmony export LinearEncoding */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return LinearFilter; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return LinearEncoding; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return LinearFilter; }); /* unused harmony export LinearInterpolant */ /* unused harmony export LinearMipMapLinearFilter */ /* unused harmony export LinearMipMapNearestFilter */ @@ -65866,10 +15074,10 @@ return $.widget( "ui.mouse", { /* unused harmony export MaterialLoader */ /* unused harmony export Math */ /* unused harmony export MathUtils */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return Matrix3; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return Matrix4; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return Matrix3; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return Matrix4; }); /* unused harmony export MaxEquation */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return Mesh; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return Mesh; }); /* unused harmony export MeshBasicMaterial */ /* unused harmony export MeshDepthMaterial */ /* unused harmony export MeshDistanceMaterial */ @@ -65887,32 +15095,32 @@ return $.widget( "ui.mouse", { /* unused harmony export MultiMaterial */ /* unused harmony export MultiplyBlending */ /* unused harmony export MultiplyOperation */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return NearestFilter; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return NearestFilter; }); /* unused harmony export NearestMipMapLinearFilter */ /* unused harmony export NearestMipMapNearestFilter */ /* unused harmony export NearestMipmapLinearFilter */ /* unused harmony export NearestMipmapNearestFilter */ /* unused harmony export NeverDepth */ /* unused harmony export NeverStencilFunc */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return NoBlending; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return NoBlending; }); /* unused harmony export NoColors */ /* unused harmony export NoToneMapping */ /* unused harmony export NormalAnimationBlendMode */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return NormalBlending; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return NormalBlending; }); /* unused harmony export NotEqualDepth */ /* unused harmony export NotEqualStencilFunc */ /* unused harmony export NumberKeyframeTrack */ /* unused harmony export Object3D */ /* unused harmony export ObjectLoader */ /* unused harmony export ObjectSpaceNormalMap */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return OctahedronBufferGeometry; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return OctahedronBufferGeometry; }); /* unused harmony export OctahedronGeometry */ /* unused harmony export OneFactor */ /* unused harmony export OneMinusDstAlphaFactor */ /* unused harmony export OneMinusDstColorFactor */ /* unused harmony export OneMinusSrcAlphaFactor */ /* unused harmony export OneMinusSrcColorFactor */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return OrthographicCamera; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return OrthographicCamera; }); /* unused harmony export PCFShadowMap */ /* unused harmony export PCFSoftShadowMap */ /* unused harmony export PMREMGenerator */ @@ -65923,16 +15131,16 @@ return $.widget( "ui.mouse", { /* unused harmony export ParticleSystem */ /* unused harmony export ParticleSystemMaterial */ /* unused harmony export Path */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return PerspectiveCamera; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return Plane; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return PerspectiveCamera; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return Plane; }); /* unused harmony export PlaneBufferGeometry */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return PlaneGeometry; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return PlaneGeometry; }); /* unused harmony export PlaneHelper */ /* unused harmony export PointCloud */ /* unused harmony export PointCloudMaterial */ /* unused harmony export PointLight */ /* unused harmony export PointLightHelper */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return Points; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return Points; }); /* unused harmony export PointsMaterial */ /* unused harmony export PolarGridHelper */ /* unused harmony export PolyhedronBufferGeometry */ @@ -65942,12 +15150,12 @@ return $.widget( "ui.mouse", { /* unused harmony export PropertyMixer */ /* unused harmony export QuadraticBezierCurve */ /* unused harmony export QuadraticBezierCurve3 */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return Quaternion; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return Quaternion; }); /* unused harmony export QuaternionKeyframeTrack */ /* unused harmony export QuaternionLinearInterpolant */ /* unused harmony export REVISION */ /* unused harmony export RGBADepthPacking */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return RGBAFormat; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return RGBAFormat; }); /* unused harmony export RGBAIntegerFormat */ /* unused harmony export RGBA_ASTC_10x10_Format */ /* unused harmony export RGBA_ASTC_10x5_Format */ @@ -66010,11 +15218,11 @@ return $.widget( "ui.mouse", { /* unused harmony export SRGB8_ALPHA8_ASTC_8x5_Format */ /* unused harmony export SRGB8_ALPHA8_ASTC_8x6_Format */ /* unused harmony export SRGB8_ALPHA8_ASTC_8x8_Format */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return Scene; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return Scene; }); /* unused harmony export SceneUtils */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return ShaderChunk; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return ShaderChunk; }); /* unused harmony export ShaderLib */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return ShaderMaterial; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return ShaderMaterial; }); /* unused harmony export ShadowMaterial */ /* unused harmony export Shape */ /* unused harmony export ShapeBufferGeometry */ @@ -66034,7 +15242,7 @@ return $.widget( "ui.mouse", { /* unused harmony export Spline */ /* unused harmony export SplineCurve */ /* unused harmony export SplineCurve3 */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return SpotLight; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return SpotLight; }); /* unused harmony export SpotLightHelper */ /* unused harmony export SpotLightShadow */ /* unused harmony export Sprite */ @@ -66045,7 +15253,7 @@ return $.widget( "ui.mouse", { /* unused harmony export StaticCopyUsage */ /* unused harmony export StaticDrawUsage */ /* unused harmony export StaticReadUsage */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return StereoCamera; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return StereoCamera; }); /* unused harmony export StreamCopyUsage */ /* unused harmony export StreamDrawUsage */ /* unused harmony export StreamReadUsage */ @@ -66054,13 +15262,13 @@ return $.widget( "ui.mouse", { /* unused harmony export SubtractiveBlending */ /* unused harmony export TOUCH */ /* unused harmony export TangentSpaceNormalMap */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return TetrahedronBufferGeometry; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return TetrahedronBufferGeometry; }); /* unused harmony export TetrahedronGeometry */ /* unused harmony export TextBufferGeometry */ /* unused harmony export TextGeometry */ /* unused harmony export Texture */ /* unused harmony export TextureLoader */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return TorusBufferGeometry; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return TorusBufferGeometry; }); /* unused harmony export TorusGeometry */ /* unused harmony export TorusKnotBufferGeometry */ /* unused harmony export TorusKnotGeometry */ @@ -66079,10 +15287,10 @@ return $.widget( "ui.mouse", { /* unused harmony export Uint8BufferAttribute */ /* unused harmony export Uint8ClampedAttribute */ /* unused harmony export Uint8ClampedBufferAttribute */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return Uniform; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return UniformsLib; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return UniformsUtils; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return UnsignedByteType; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return Uniform; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return UniformsLib; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return UniformsUtils; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return UnsignedByteType; }); /* unused harmony export UnsignedInt248Type */ /* unused harmony export UnsignedIntType */ /* unused harmony export UnsignedShort4444Type */ @@ -66090,8 +15298,8 @@ return $.widget( "ui.mouse", { /* unused harmony export UnsignedShort565Type */ /* unused harmony export UnsignedShortType */ /* unused harmony export VSMShadowMap */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return Vector2; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return Vector3; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return Vector2; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return Vector3; }); /* unused harmony export Vector4 */ /* unused harmony export VectorKeyframeTrack */ /* unused harmony export Vertex */ @@ -66100,9 +15308,9 @@ return $.widget( "ui.mouse", { /* unused harmony export WebGL1Renderer */ /* unused harmony export WebGLCubeRenderTarget */ /* unused harmony export WebGLMultisampleRenderTarget */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return WebGLRenderTarget; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return WebGLRenderTarget; }); /* unused harmony export WebGLRenderTargetCube */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return WebGLRenderer; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_0", function() { return WebGLRenderer; }); /* unused harmony export WebGLUtils */ /* unused harmony export WireframeGeometry */ /* unused harmony export WireframeHelper */ @@ -66112,7 +15320,7 @@ return $.widget( "ui.mouse", { /* unused harmony export ZeroFactor */ /* unused harmony export ZeroSlopeEnding */ /* unused harmony export ZeroStencilOp */ -/* unused harmony export sRGBEncoding */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_1", function() { return sRGBEncoding; }); // Polyfills if ( Number.EPSILON === undefined ) { @@ -117531,580 +66739,128 @@ const GeometryUtils = { matrix = geometry2.matrix; geometry2 = geometry2.geometry; - } - - geometry1.merge( geometry2, matrix, materialIndexOffset ); - - }, - - center: function ( geometry ) { - - console.warn( 'THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.' ); - return geometry.center(); - - } - -}; - -ImageUtils.crossOrigin = undefined; - -ImageUtils.loadTexture = function ( url, mapping, onLoad, onError ) { - - console.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' ); - - const loader = new TextureLoader(); - loader.setCrossOrigin( this.crossOrigin ); - - const texture = loader.load( url, onLoad, undefined, onError ); - - if ( mapping ) texture.mapping = mapping; - - return texture; - -}; - -ImageUtils.loadTextureCube = function ( urls, mapping, onLoad, onError ) { - - console.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' ); - - const loader = new CubeTextureLoader(); - loader.setCrossOrigin( this.crossOrigin ); - - const texture = loader.load( urls, onLoad, undefined, onError ); - - if ( mapping ) texture.mapping = mapping; - - return texture; - -}; - -ImageUtils.loadCompressedTexture = function () { - - console.error( 'THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.' ); - -}; - -ImageUtils.loadCompressedTextureCube = function () { - - console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' ); - -}; - -// - -function CanvasRenderer() { - - console.error( 'THREE.CanvasRenderer has been removed' ); - -} - -// - -function JSONLoader() { - - console.error( 'THREE.JSONLoader has been removed.' ); - -} - -// - -const SceneUtils = { - - createMultiMaterialObject: function ( /* geometry, materials */ ) { - - console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); - - }, - - detach: function ( /* child, parent, scene */ ) { - - console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); - - }, - - attach: function ( /* child, scene, parent */ ) { - - console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); - - } - -}; - -// - -function LensFlare() { - - console.error( 'THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js' ); - -} - -if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { - - /* eslint-disable no-undef */ - __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: { - revision: REVISION, - } } ) ); - /* eslint-enable no-undef */ - -} - - - - -/***/ }), -/* 53 */ -/***/ (function(module, exports, __webpack_require__) { - -var __WEBPACK_AMD_DEFINE_RESULT__;/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */ -/*global define:false, require:false, exports:false, module:false, signals:false */ - -/** @license - * JS Signals - * Released under the MIT license - * Author: Miller Medeiros - * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM) - */ - -(function(global){ - - // SignalBinding ------------------------------------------------- - //================================================================ - - /** - * Object that represents a binding between a Signal and a listener function. - *
- This is an internal constructor and shouldn't be called by regular users. - *
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. - * @author Miller Medeiros - * @constructor - * @internal - * @name SignalBinding - * @param {Signal} signal Reference to Signal object that listener is currently bound to. - * @param {Function} listener Handler function bound to the signal. - * @param {boolean} isOnce If binding should be executed just once. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. (default = 0). - */ - function SignalBinding(signal, listener, isOnce, listenerContext, priority) { - - /** - * Handler function bound to the signal. - * @type Function - * @private - */ - this._listener = listener; - - /** - * If binding should be executed just once. - * @type boolean - * @private - */ - this._isOnce = isOnce; - - /** - * Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @memberOf SignalBinding.prototype - * @name context - * @type Object|undefined|null - */ - this.context = listenerContext; - - /** - * Reference to Signal object that listener is currently bound to. - * @type Signal - * @private - */ - this._signal = signal; - - /** - * Listener priority - * @type Number - * @private - */ - this._priority = priority || 0; - } + } - SignalBinding.prototype = { + geometry1.merge( geometry2, matrix, materialIndexOffset ); - /** - * If binding is active and should be executed. - * @type boolean - */ - active : true, + }, - /** - * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters) - * @type Array|null - */ - params : null, + center: function ( geometry ) { - /** - * Call listener passing arbitrary parameters. - *

If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

- * @param {Array} [paramsArr] Array of parameters that should be passed to the listener - * @return {*} Value returned by the listener. - */ - execute : function (paramsArr) { - var handlerReturn, params; - if (this.active && !!this._listener) { - params = this.params? this.params.concat(paramsArr) : paramsArr; - handlerReturn = this._listener.apply(this.context, params); - if (this._isOnce) { - this.detach(); - } - } - return handlerReturn; - }, + console.warn( 'THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.' ); + return geometry.center(); - /** - * Detach binding from signal. - * - alias to: mySignal.remove(myBinding.getListener()); - * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached. - */ - detach : function () { - return this.isBound()? this._signal.remove(this._listener, this.context) : null; - }, + } - /** - * @return {Boolean} `true` if binding is still bound to the signal and have a listener. - */ - isBound : function () { - return (!!this._signal && !!this._listener); - }, +}; - /** - * @return {boolean} If SignalBinding will only be executed once. - */ - isOnce : function () { - return this._isOnce; - }, +ImageUtils.crossOrigin = undefined; - /** - * @return {Function} Handler function bound to the signal. - */ - getListener : function () { - return this._listener; - }, +ImageUtils.loadTexture = function ( url, mapping, onLoad, onError ) { - /** - * @return {Signal} Signal that listener is currently bound to. - */ - getSignal : function () { - return this._signal; - }, + console.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' ); - /** - * Delete instance properties - * @private - */ - _destroy : function () { - delete this._signal; - delete this._listener; - delete this.context; - }, + const loader = new TextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); - /** - * @return {string} String representation of the object. - */ - toString : function () { - return '[SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']'; - } + const texture = loader.load( url, onLoad, undefined, onError ); - }; + if ( mapping ) texture.mapping = mapping; + return texture; -/*global SignalBinding:false*/ +}; - // Signal -------------------------------------------------------- - //================================================================ +ImageUtils.loadTextureCube = function ( urls, mapping, onLoad, onError ) { - function validateListener(listener, fnName) { - if (typeof listener !== 'function') { - throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) ); - } - } + console.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' ); - /** - * Custom event broadcaster - *
- inspired by Robert Penner's AS3 Signals. - * @name Signal - * @author Miller Medeiros - * @constructor - */ - function Signal() { - /** - * @type Array. - * @private - */ - this._bindings = []; - this._prevParams = null; + const loader = new CubeTextureLoader(); + loader.setCrossOrigin( this.crossOrigin ); - // enforce dispatch to aways work on same context (#47) - var self = this; - this.dispatch = function(){ - Signal.prototype.dispatch.apply(self, arguments); - }; - } + const texture = loader.load( urls, onLoad, undefined, onError ); - Signal.prototype = { + if ( mapping ) texture.mapping = mapping; - /** - * Signals Version Number - * @type String - * @const - */ - VERSION : '1.0.0', + return texture; - /** - * If Signal should keep record of previously dispatched parameters and - * automatically execute listener during `add()`/`addOnce()` if Signal was - * already dispatched before. - * @type boolean - */ - memorize : false, +}; - /** - * @type boolean - * @private - */ - _shouldPropagate : true, +ImageUtils.loadCompressedTexture = function () { - /** - * If Signal is active and should broadcast events. - *

IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

- * @type boolean - */ - active : true, + console.error( 'THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.' ); - /** - * @param {Function} listener - * @param {boolean} isOnce - * @param {Object} [listenerContext] - * @param {Number} [priority] - * @return {SignalBinding} - * @private - */ - _registerListener : function (listener, isOnce, listenerContext, priority) { +}; - var prevIndex = this._indexOfListener(listener, listenerContext), - binding; +ImageUtils.loadCompressedTextureCube = function () { - if (prevIndex !== -1) { - binding = this._bindings[prevIndex]; - if (binding.isOnce() !== isOnce) { - throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.'); - } - } else { - binding = new SignalBinding(this, listener, isOnce, listenerContext, priority); - this._addBinding(binding); - } + console.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' ); - if(this.memorize && this._prevParams){ - binding.execute(this._prevParams); - } +}; - return binding; - }, +// - /** - * @param {SignalBinding} binding - * @private - */ - _addBinding : function (binding) { - //simplified insertion sort - var n = this._bindings.length; - do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority); - this._bindings.splice(n + 1, 0, binding); - }, +function CanvasRenderer() { - /** - * @param {Function} listener - * @return {number} - * @private - */ - _indexOfListener : function (listener, context) { - var n = this._bindings.length, - cur; - while (n--) { - cur = this._bindings[n]; - if (cur._listener === listener && cur.context === context) { - return n; - } - } - return -1; - }, + console.error( 'THREE.CanvasRenderer has been removed' ); - /** - * Check if listener was attached to Signal. - * @param {Function} listener - * @param {Object} [context] - * @return {boolean} if Signal has the specified listener. - */ - has : function (listener, context) { - return this._indexOfListener(listener, context) !== -1; - }, +} - /** - * Add a listener to the signal. - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) - * @return {SignalBinding} An Object representing the binding between the Signal and listener. - */ - add : function (listener, listenerContext, priority) { - validateListener(listener, 'add'); - return this._registerListener(listener, false, listenerContext, priority); - }, +// - /** - * Add listener to the signal that should be removed after first execution (will be executed only once). - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) - * @return {SignalBinding} An Object representing the binding between the Signal and listener. - */ - addOnce : function (listener, listenerContext, priority) { - validateListener(listener, 'addOnce'); - return this._registerListener(listener, true, listenerContext, priority); - }, +function JSONLoader() { - /** - * Remove a single listener from the dispatch queue. - * @param {Function} listener Handler function that should be removed. - * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). - * @return {Function} Listener handler function. - */ - remove : function (listener, context) { - validateListener(listener, 'remove'); + console.error( 'THREE.JSONLoader has been removed.' ); - var i = this._indexOfListener(listener, context); - if (i !== -1) { - this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal - this._bindings.splice(i, 1); - } - return listener; - }, +} - /** - * Remove all listeners from the Signal. - */ - removeAll : function () { - var n = this._bindings.length; - while (n--) { - this._bindings[n]._destroy(); - } - this._bindings.length = 0; - }, +// - /** - * @return {number} Number of listeners attached to the Signal. - */ - getNumListeners : function () { - return this._bindings.length; - }, +const SceneUtils = { - /** - * Stop propagation of the event, blocking the dispatch to next listeners on the queue. - *

IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

- * @see Signal.prototype.disable - */ - halt : function () { - this._shouldPropagate = false; - }, + createMultiMaterialObject: function ( /* geometry, materials */ ) { - /** - * Dispatch/Broadcast Signal to all listeners added to the queue. - * @param {...*} [params] Parameters that should be passed to each handler. - */ - dispatch : function (params) { - if (! this.active) { - return; - } + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); - var paramsArr = Array.prototype.slice.call(arguments), - n = this._bindings.length, - bindings; + }, - if (this.memorize) { - this._prevParams = paramsArr; - } + detach: function ( /* child, parent, scene */ ) { - if (! n) { - //should come after memorize - return; - } + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); - bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch - this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch. + }, - //execute all callbacks until end of the list or until a callback returns `false` or stops propagation - //reverse loop since listeners with higher priority will be added at the end of the list - do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false); - }, + attach: function ( /* child, scene, parent */ ) { - /** - * Forget memorized arguments. - * @see Signal.memorize - */ - forget : function(){ - this._prevParams = null; - }, + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); - /** - * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). - *

IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

- */ - dispose : function () { - this.removeAll(); - delete this._bindings; - delete this._prevParams; - }, + } - /** - * @return {string} String representation of the object. - */ - toString : function () { - return '[Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']'; - } +}; - }; +// +function LensFlare() { - // Namespace ----------------------------------------------------- - //================================================================ + console.error( 'THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js' ); - /** - * Signals namespace - * @namespace - * @name signals - */ - var signals = Signal; +} - /** - * Custom event broadcaster - * @see Signal - */ - // alias for backwards compatibility (see #gh-44) - signals.Signal = Signal; +if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { + /* eslint-disable no-undef */ + __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: { + revision: REVISION, + } } ) ); + /* eslint-enable no-undef */ +} - //exports to multiple environments - if(true){ //AMD - !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return signals; }).call(exports, __webpack_require__, exports, module), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof module !== 'undefined' && module.exports){ //node - module.exports = signals; - } else { //browser - //use string because of Google closure compiler ADVANCED_MODE - /*jslint sub:true */ - global['signals'] = signals; - } -}(this)); /***/ }), -/* 54 */ +/* 53 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118116,7 +66872,7 @@ function isUndefined(obj) { /***/ }), -/* 55 */ +/* 54 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118131,7 +66887,7 @@ function isBoolean(obj) { /***/ }), -/* 56 */ +/* 55 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118142,7 +66898,7 @@ function isBoolean(obj) { /***/ }), -/* 57 */ +/* 56 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118153,7 +66909,7 @@ function isBoolean(obj) { /***/ }), -/* 58 */ +/* 57 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118164,13 +66920,13 @@ function isBoolean(obj) { /***/ }), -/* 59 */ +/* 58 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = isNaN; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__setup_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isNumber_js__ = __webpack_require__(56); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isNumber_js__ = __webpack_require__(55); @@ -118181,14 +66937,14 @@ function isNaN(obj) { /***/ }), -/* 60 */ +/* 59 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__setup_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isDataView_js__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constant_js__ = __webpack_require__(61); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__isBufferLike_js__ = __webpack_require__(130); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constant_js__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__isBufferLike_js__ = __webpack_require__(123); @@ -118207,7 +66963,7 @@ function isTypedArray(obj) { /***/ }), -/* 61 */ +/* 60 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118221,7 +66977,7 @@ function constant(value) { /***/ }), -/* 62 */ +/* 61 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118239,7 +66995,7 @@ function createSizePropertyCheck(getSizeProperty) { /***/ }), -/* 63 */ +/* 62 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118253,7 +67009,7 @@ function shallowProperty(key) { /***/ }), -/* 64 */ +/* 63 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118304,7 +67060,7 @@ function collectNonEnumProps(obj, keys) { /***/ }), -/* 65 */ +/* 64 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118326,7 +67082,7 @@ function isMatch(object, attrs) { /***/ }), -/* 66 */ +/* 65 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118346,7 +67102,7 @@ function invert(obj) { /***/ }), -/* 67 */ +/* 66 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118365,7 +67121,7 @@ function functions(obj) { /***/ }), -/* 68 */ +/* 67 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118379,7 +67135,7 @@ function functions(obj) { /***/ }), -/* 69 */ +/* 68 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118393,7 +67149,7 @@ function functions(obj) { /***/ }), -/* 70 */ +/* 69 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118421,14 +67177,14 @@ function baseCreate(prototype) { /***/ }), -/* 71 */ +/* 70 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = get; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__toPath_js__ = __webpack_require__(25); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__deepGet_js__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isUndefined_js__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isUndefined_js__ = __webpack_require__(53); @@ -118444,7 +67200,7 @@ function get(object, path, defaultValue) { /***/ }), -/* 72 */ +/* 71 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118463,7 +67219,7 @@ __WEBPACK_IMPORTED_MODULE_0__underscore_js__["a" /* default */].toPath = toPath; /***/ }), -/* 73 */ +/* 72 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118495,13 +67251,13 @@ function baseIteratee(value, context, argCount) { /***/ }), -/* 74 */ +/* 73 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = iteratee; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__underscore_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__baseIteratee_js__ = __webpack_require__(73); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__baseIteratee_js__ = __webpack_require__(72); @@ -118515,7 +67271,7 @@ __WEBPACK_IMPORTED_MODULE_0__underscore_js__["a" /* default */].iteratee = itera /***/ }), -/* 75 */ +/* 74 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118525,7 +67281,7 @@ function noop(){} /***/ }), -/* 76 */ +/* 75 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118541,7 +67297,7 @@ function random(min, max) { /***/ }), -/* 77 */ +/* 76 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118567,7 +67323,7 @@ function createEscaper(map) { /***/ }), -/* 78 */ +/* 77 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118583,7 +67339,7 @@ function createEscaper(map) { /***/ }), -/* 79 */ +/* 78 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118600,12 +67356,12 @@ function createEscaper(map) { /***/ }), -/* 80 */ +/* 79 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = executeBound; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__baseCreate_js__ = __webpack_require__(70); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__baseCreate_js__ = __webpack_require__(69); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isObject_js__ = __webpack_require__(14); @@ -118623,13 +67379,13 @@ function executeBound(sourceFunc, boundFunc, context, callingContext, args) { /***/ }), -/* 81 */ +/* 80 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__restArguments_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isFunction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__executeBound_js__ = __webpack_require__(80); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__executeBound_js__ = __webpack_require__(79); @@ -118646,7 +67402,7 @@ function executeBound(sourceFunc, boundFunc, context, callingContext, args) { /***/ }), -/* 82 */ +/* 81 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118663,7 +67419,7 @@ function executeBound(sourceFunc, boundFunc, context, callingContext, args) { /***/ }), -/* 83 */ +/* 82 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118683,7 +67439,7 @@ function before(times, func) { /***/ }), -/* 84 */ +/* 83 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118705,7 +67461,7 @@ function findKey(obj, predicate, context) { /***/ }), -/* 85 */ +/* 84 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118730,11 +67486,11 @@ function createPredicateIndexFinder(dir) { /***/ }), -/* 86 */ +/* 85 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createPredicateIndexFinder_js__ = __webpack_require__(85); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createPredicateIndexFinder_js__ = __webpack_require__(84); // Returns the last index on an array-like that passes a truth test. @@ -118742,7 +67498,7 @@ function createPredicateIndexFinder(dir) { /***/ }), -/* 87 */ +/* 86 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118767,13 +67523,13 @@ function sortedIndex(array, obj, iteratee, context) { /***/ }), -/* 88 */ +/* 87 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sortedIndex_js__ = __webpack_require__(87); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__sortedIndex_js__ = __webpack_require__(86); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__findIndex_js__ = __webpack_require__(48); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__createIndexFinder_js__ = __webpack_require__(89); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__createIndexFinder_js__ = __webpack_require__(88); @@ -118786,14 +67542,14 @@ function sortedIndex(array, obj, iteratee, context) { /***/ }), -/* 89 */ +/* 88 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = createIndexFinder; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__getLength_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__setup_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isNaN_js__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__isNaN_js__ = __webpack_require__(58); @@ -118825,14 +67581,14 @@ function createIndexFinder(dir, predicateFind, sortedIndex) { /***/ }), -/* 90 */ +/* 89 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = find; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isArrayLike_js__ = __webpack_require__(9); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__findIndex_js__ = __webpack_require__(48); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__findKey_js__ = __webpack_require__(84); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__findKey_js__ = __webpack_require__(83); @@ -118846,7 +67602,7 @@ function find(obj, predicate, context) { /***/ }), -/* 91 */ +/* 90 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118885,7 +67641,7 @@ function createReduce(dir) { /***/ }), -/* 92 */ +/* 91 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118926,7 +67682,7 @@ function max(obj, iteratee, context) { /***/ }), -/* 93 */ +/* 92 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -118934,8 +67690,8 @@ function max(obj, iteratee, context) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isArrayLike_js__ = __webpack_require__(9); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__values_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__getLength_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__random_js__ = __webpack_require__(76); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__toArray_js__ = __webpack_require__(94); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__random_js__ = __webpack_require__(75); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__toArray_js__ = __webpack_require__(93); @@ -118966,7 +67722,7 @@ function sample(obj, n, guard) { /***/ }), -/* 94 */ +/* 93 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -119001,7 +67757,7 @@ function toArray(obj) { /***/ }), -/* 95 */ +/* 94 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -119009,7 +67765,7 @@ function toArray(obj) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__isFunction_js__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__optimizeCb_js__ = __webpack_require__(26); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__allKeys_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__keyInObj_js__ = __webpack_require__(179); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__keyInObj_js__ = __webpack_require__(172); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__flatten_js__ = __webpack_require__(20); @@ -119040,7 +67796,7 @@ function toArray(obj) { /***/ }), -/* 96 */ +/* 95 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -119057,7 +67813,7 @@ function initial(array, n, guard) { /***/ }), -/* 97 */ +/* 96 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -119074,7 +67830,7 @@ function rest(array, n, guard) { /***/ }), -/* 98 */ +/* 97 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -119098,12 +67854,12 @@ function rest(array, n, guard) { /***/ }), -/* 99 */ +/* 98 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = uniq; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isBoolean_js__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__isBoolean_js__ = __webpack_require__(54); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__cb_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__getLength_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__contains_js__ = __webpack_require__(28); @@ -119146,12 +67902,12 @@ function uniq(array, isSorted, iteratee, context) { /***/ }), -/* 100 */ +/* 99 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = unzip; -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__max_js__ = __webpack_require__(92); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__max_js__ = __webpack_require__(91); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__getLength_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__pluck_js__ = __webpack_require__(49); @@ -119172,7 +67928,7 @@ function unzip(array) { /***/ }), -/* 101 */ +/* 100 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -119187,7 +67943,7 @@ function chainResult(instance, obj) { /***/ }), -/* 102 */ +/* 101 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* @@ -119249,7 +68005,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/* //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmFscy5taW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3NpZ25hbHMubWluLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7RUFNRTtBQUNGLENBQUMsVUFBUyxDQUFDO0lBQUUsU0FBUyxDQUFDLENBQUMsQ0FBQyxFQUFDLENBQUMsRUFBQyxDQUFDLEVBQUMsQ0FBQyxFQUFDLENBQUMsSUFBRSxJQUFJLENBQUMsU0FBUyxHQUFDLENBQUMsQ0FBQyxDQUFBLElBQUksQ0FBQyxPQUFPLEdBQUMsQ0FBQyxDQUFDLENBQUEsSUFBSSxDQUFDLE9BQU8sR0FBQyxDQUFDLENBQUMsQ0FBQSxJQUFJLENBQUMsT0FBTyxHQUFDLENBQUMsQ0FBQyxDQUFBLElBQUksQ0FBQyxTQUFTLEdBQUMsQ0FBQyxJQUFFLENBQUMsQ0FBQSxDQUFBLENBQUM7SUFBQSxTQUFTLENBQUMsQ0FBQyxDQUFDLEVBQUMsQ0FBQyxJQUFFLElBQUcsT0FBTyxDQUFDLEtBQUcsVUFBVTtRQUFDLE1BQU0sS0FBSyxDQUFDLGtFQUFrRSxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFBLENBQUM7SUFBQSxTQUFTLENBQUMsS0FBRyxJQUFJLENBQUMsU0FBUyxHQUFDLEVBQUUsQ0FBQyxDQUFBLElBQUksQ0FBQyxXQUFXLEdBQUMsSUFBSSxDQUFDLENBQUEsSUFBSSxDQUFDLEdBQUMsSUFBSSxDQUFDLENBQUEsSUFBSSxDQUFDLFFBQVEsR0FBQyxjQUFXLENBQUMsQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBQyxDQUFDLEVBQUMsU0FBUyxDQUFDLENBQUEsQ0FBQSxDQUFDLENBQUEsQ0FBQSxDQUFDO0lBQUEsQ0FBQyxDQUFDLFNBQVMsR0FBQyxFQUFDLE1BQU0sRUFBQyxDQUFDLENBQUMsRUFBQyxNQUFNLEVBQUMsSUFBSSxFQUFDLE9BQU8sRUFBQyxVQUFTLENBQUM7WUFBRSxJQUFJ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Q0FBQSxDQUFBLENBQUM7UUFDdGYsV0FBVyxFQUFDLFVBQVMsQ0FBQyxJQUFFLElBQUksQ0FBQyxHQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUE7WUFBRSxFQUFFLENBQUMsQ0FBQztlQUFNLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLElBQUUsQ0FBQyxDQUFDLFNBQVMsSUFBRSxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLFNBQVMsRUFBRSxDQUFBLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUMsR0FBQyxDQUFDLEVBQUMsQ0FBQyxFQUFDLENBQUMsQ0FBQyxDQUFBLENBQUEsQ0FBQyxFQUFDLGdCQUFnQixFQUFDLFVBQVMsQ0FBQyxFQUFDLENBQUMsSUFBRSxLQUFJLElBQUksQ0FBQyxHQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxFQUFDLENBQUMsRUFBQyxDQUFDLEVBQUU7WUFBRSxJQUFHLENBQUMsR0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxFQUFDLENBQUMsQ0FBQyxTQUFTLEtBQUcsQ0FBQyxJQUFFLENBQUMsQ0FBQyxPQUFPLEtBQUcsQ0FBQztnQkFBQyxPQUFPLENBQUMsQ0FBQyxDQUFBLE9BQU0sQ0FBQyxDQUFDLENBQUEsQ0FBQSxDQUFDLEVBQUMsR0FBRyxFQUFDLFVBQVMsQ0FBQyxFQUFDLENBQUMsSUFBRSxPQUFPLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDLEVBQUMsQ0FBQyxDQUFDLEtBQUcsQ0FBQyxDQUFDLENBQUEsQ0FBQSxDQUFDLEVBQUMsR0FBRyxFQUFDLFVBQVMsQ0FBQyxFQUFDLENBQUMsRUFBQyxDQUFDLElBQUUsQ0FBQyxDQUFDLENBQUMsRUFBQyxLQUFLLENBQUMsQ0FBQyxDQUFBLE9BQU8sSUFBSSxDQUFDLGlCQUFpQixDQUFDLENBQUMsRUFBQyxDQUFDLENBQUMsRUFBQyxDQUFDLEVBQUMsQ0FBQyxDQUFDLENBQUEsQ0FBQSxDQUFDLEVBQUMsT0FBTyxFQUFDLFVB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 /***/ }), -/* 103 */ +/* 102 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -120070,7 +68826,7 @@ module.exports = { //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidWkuZXh0cmEuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdWkvdWkuZXh0cmEuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxPQUFPO0FBRVAsSUFBSSxFQUFFLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDLEVBQUUsQ0FBQztBQUUvQixFQUFFLENBQUMsSUFBSSxHQUFHLFVBQVUsSUFBSTtJQUN0QixFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUVyQixJQUFJLEdBQUcsR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3hDLEdBQUcsQ0FBQyxTQUFTLEdBQUcsTUFBTSxDQUFBO0lBQ3RCLEdBQUcsQ0FBQyxLQUFLLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQTtJQUM1QixHQUFHLENBQUMsS0FBSyxDQUFDLE9BQU8sR0FBRyxjQUFjLENBQUE7SUFDbEMsR0FBRyxDQUFDLEtBQUssQ0FBQyxhQUFhLEdBQUcsUUFBUSxDQUFBO0lBRWxDLElBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFBO0lBQ2QsSUFBSSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUVuQixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUV2RCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQzFDLElBQUksS0FBSyxLQUFLLFNBQVMsRUFBRTtRQUN2QixJQUFJLENBQUMsR0FBRyxDQUFDLFNBQVMsR0FBRyxLQUFLLENBQUE7S0FDM0I7SUFFRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELE9BQU87QUFFUCxFQUFFLENBQUMsSUFBSSxHQUFHO0lBQ1IsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFbkIsSUFBSSxHQUFHLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUN4QyxHQUFHLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQTtJQUN0QixHQUFHLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQTtJQUNuQixHQUFHLENBQUMsTUFBTSxHQUFHLEVBQUUsQ0FBQTtJQUNmLEdBQUcsQ0FBQyxNQUFNLEdBQUcsUUFBUSxDQUFBO0lBQ3JCLEdBQUcsQ0FBQyxPQUFPLEdBQUcscUJBQXFCLENBQUE7SUFFbkMsSUFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUE7SUFFZCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUVyRCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxTQUFTLEdBQUcsVUFBVSxLQUFLO0lBQzNDLElBQUksQ0FBQyxHQUFHLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQTtJQUV2QixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLFNBQVMsR0FBRyxVQUFVLEtBQUs7SUFDM0MsSUFBSSxDQUFDLEdBQUcsQ0FBQyxNQUFNLEdBQUcsS0FBSyxDQUFBO0lBRXZCLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxHQUFHLFVBQVUsS0FBSztJQUMzQyxJQUFJLENBQUMsR0FBRyxDQUFDLE1BQU0sR0FBRyxLQUFLLENBQUE7SUFFdkIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLEdBQUcsVUFBVSxLQUFLO0lBQzVDLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxHQUFHLEtBQUssQ0FBQTtJQUV4QixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELE9BQU87QUFFUCxFQUFFLENBQUMsSUFBSSxHQUFHO0lBQ1IsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFbkIsSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLEdBQUcsTUFBTSxDQUFBO0lBQzNCLElBQUksQ0FBQyxHQUFHLENBQUMsSUFBSSxHQUFHLE1BQU0sQ0FBQTtJQUN0QixJQUFJLENBQUMsR0FBRyxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUE7SUFFekIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFckQsRUFBRSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsV0FBVyxHQUFHLFVBQVUsS0FBSztJQUM3QyxJQUFJLENBQUMsR0FBRyxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUE7SUFFekIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQzFDLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQsU0FBUztBQUVULEVBQUUsQ0FBQyxNQUFNLEdBQUc7SUFDVixFQUFFLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUVuQixJQUFJLENBQUMsR0FBRyxDQUFDLElBQUksR0FBRyxRQUFRLENBQUE7SUFFeEIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsTUFBTSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFdkQsZ0JBQWdCO0FBRWhCLEVBQUUsQ0FBQyxZQUFZLEdBQUcsVUFBVSxNQUFNLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxTQUFTO0lBQzlELEVBQUUsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxNQUFNLENBQUMsQ0FBQTtJQUU1QixJQUFJLElBQUksR0FBRyxJQUFJLENBQUE7SUFFZixJQUFJLENBQUMsT0FBTyxDQUFDO1FBQ1gsSUFBSSxJQUFJLEVBQUU7WUFDUixJQUFJLEdBQUcsS0FBSyxDQUFBO1lBQ1osSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQTtZQUNyQixTQUFTLEVBQUUsQ0FBQTtTQUNaO2FBQU07WUFDTCxJQUFJLEdBQUcsSUFBSSxDQUFBO1lBQ1gsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQTtZQUNyQixTQUFTLEVBQUUsQ0FBQTtTQUNaO0lBQ0gsQ0FBQyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFBO0lBRWIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFOUQsZ0JBQWdCO0FBRWhCLEVBQUUsQ0FBQyxZQUFZLEdBQUcsVUFBVSxJQUFJO0lBQzlCLEVBQUUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQTtJQUV4QixJQUFJLENBQUMsYUFBYSxDQUFDLFFBQVEsQ0FBQyxDQUFBO0lBQzVCLElBQUksQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUE7SUFDMUIsSUFBSSxDQUFDLGVBQWUsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUVoQyxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxZQUFZLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUU1RCxFQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQ2xELElBQUksS0FBSyxLQUFLLFNBQVMsRUFBRTtRQUN2QixJQUFJLENBQUMsR0FBRyxDQUFDLFdBQVcsR0FBRyxLQUFLLENBQUE7UUFDNUIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLENBQUMsQ0FBQTtLQUNyQjtJQUVELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsMEJBQTBCO0FBRTFCLEVBQUUsQ0FBQyxxQkFBcUIsR0FBRyxVQUFVLElBQUk7SUFDdkMsNkRBQTZEO0lBRTdELEVBQUUsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBRXJCLElBQUksR0FBRyxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsTUFBTSxDQUFDLENBQUE7SUFDeEMsR0FBRyxDQUFDLFNBQVMsR0FBRyx1QkFBdUIsQ0FBQTtJQUN2QyxHQUFHLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxTQUFTLENBQUE7SUFDNUIsR0FBRyxDQUFDLEtBQUssQ0FBQyxPQUFPLEdBQUcsY0FBYyxDQUFBO0lBQ2xDLEdBQUcsQ0FBQyxLQUFLLENBQUMsYUFBYSxHQUFHLFFBQVEsQ0FBQTtJQUVsQyxJQUFJLE9BQU8sR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQ3pDLEdBQUcsQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLENBQUE7SUFFeEIsSUFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUE7SUFDZCxJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQTtJQUV0QixJQUFJLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBRW5CLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLHFCQUFxQixDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFeEUsRUFBRSxDQUFDLHFCQUFxQixDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQzNELElBQUksS0FBSyxLQUFLLFNBQVMsRUFBRTtRQUN2QixJQUFJLENBQUMsT0FBTyxDQUFDLFdBQVcsR0FBRyxLQUFLLENBQUE7UUFDaEMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLENBQUMsQ0FBQTtLQUNyQjtJQUVELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsZ0JBQWdCO0FBRWhCLEVBQUUsQ0FBQyxZQUFZLEdBQUc7SUFDaEIsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFbkIsSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLEdBQUcsb0JBQW9CLENBQUE7SUFDekMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFBO0lBQ3hCLElBQUksQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLE9BQU8sR0FBRyxNQUFNLENBQUE7SUFFL0IsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFN0QsRUFBRSxDQUFDLFlBQVksQ0FBQyxTQUFTLENBQUMsTUFBTSxHQUFHLFVBQVUsSUFBSTtJQUMvQyxJQUFJLEdBQUcsSUFBSSxJQUFJLFFBQVEsQ0FBQyxJQUFJLENBQUE7SUFFNUIsSUFBSSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUE7SUFFMUIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCwrQkFBK0I7QUFFL0IsRUFBRSxDQUFDLElBQUksR0FBRyxVQUFVLEtBQUs7SUFDdkIsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFbkIsSUFBSSxHQUFHLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUN4QyxHQUFHLENBQUMsU0FBUyxHQUFHLFNBQVMsQ0FBQTtJQUV6QixJQUFJLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQTtJQUVkLElBQUksS0FBSztRQUFFLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLElBQUksRUFBRSxTQUFTLENBQUMsQ0FBQTtJQUUvQyxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUVyRCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQzFDLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsUUFBUSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUMsQ0FBQTtBQUNuRCxDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQzFDLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO1FBQ3pDLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLLEdBQUcsU0FBUyxDQUFFLENBQUMsQ0FBRSxDQUFDLENBQUE7S0FDL0M7SUFFRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLFFBQVEsR0FBRyxVQUFVLEtBQUs7SUFDMUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLEdBQUcsU0FBUyxDQUFBO0lBRTlCLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO1FBQ3pDLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLLEdBQUcsU0FBUyxDQUFFLENBQUMsQ0FBRSxDQUFDLENBQUE7S0FDL0M7SUFFRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLFdBQVcsR0FBRyxVQUFVLEtBQUs7SUFDN0MsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLFNBQVMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxFQUFFLEVBQUU7UUFDekMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLEtBQUssR0FBRyxTQUFTLENBQUUsQ0FBQyxDQUFFLENBQUMsQ0FBQTtLQUNsRDtJQUVELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsV0FBVyxHQUFHLFVBQVUsUUFBUSxFQUFFLFFBQVE7SUFDMUQsSUFBSSxDQUFDLFdBQVcsQ0FBQyxRQUFRLEVBQUUsUUFBUSxDQUFDLENBQUE7SUFDcEMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUV2QixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELGNBQWM7QUFFZCxFQUFFLENBQUMsVUFBVSxHQUFHLFVBQVUsS0FBSyxFQUFFLFNBQVMsRUFBRSxVQUFVO0lBQ3BELEVBQUUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksRUFBRSxLQUFLLENBQUMsQ0FBQyxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsVUFBVSxDQUFDLENBQUE7SUFFbEQsSUFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUE7SUFDbEIsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUE7SUFDMUIsSUFBSSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUE7SUFFNUIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsVUFBVSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFMUQsRUFBRSxDQUFDLFVBQVUsQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHLFVBQVUsS0FBSztJQUNoRCxJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQTtJQUVsQixJQUFJLEtBQUssRUFBRTtRQUNULElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7S0FDbEQ7U0FBTTtRQUNMLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUE7S0FDbEQ7SUFFRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLFFBQVEsR0FBRztJQUNqQyxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUE7QUFDbkIsQ0FBQyxDQUFBO0FBRUQsZUFBZTtBQUVmLEVBQUUsQ0FBQyxXQUFXLEdBQUc7SUFDZixFQUFFLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsU0FBUyxDQUFDLENBQUE7SUFFN0IsSUFBSSxJQUFJLEdBQUcsS0FBSyxDQUFBO0lBQ2hCLElBQUksS0FBSyxHQUFHLElBQUksQ0FBQTtJQUVoQixJQUFJLENBQUMsUUFBUSxDQUFDLFFBQVEsQ0FBQyxDQUFBO0lBQ3ZCLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUE7SUFFekIsSUFBSSxDQUFDLE9BQU8sQ0FBQztRQUNYLElBQUksSUFBSSxLQUFLLElBQUksRUFBRTtZQUNqQixJQUFJLE9BQU8sS0FBSyxDQUFDLGVBQWUsS0FBSyxVQUFVLEVBQUU7Z0JBQy9DLEtBQUssQ0FBQyxlQUFlLEVBQUUsQ0FBQTthQUN4QjtTQUNGO2FBQU07WUFDTCxLQUFLLENBQUMsUUFBUSxDQUFDLGtCQUFrQixDQUFDLENBQUE7WUFDbEMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLFlBQVksQ0FBQyxDQUFBO1lBQ3JDLElBQUksR0FBRyxJQUFJLENBQUE7WUFFWCxVQUFVLENBQUM7Z0JBQ1QsS0FBSyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQTtnQkFDdEIsS0FBSyxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLFlBQVksQ0FBQyxDQUFBO2dCQUN4QyxJQUFJLEdBQUcsS0FBSyxDQUFBO1lBQ2QsQ0FBQyxFQUFFLElBQUksQ0FBQyxDQUFBO1NBQ1Q7SUFDSCxDQUFDLENBQUMsQ0FBQTtJQUVGLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLFdBQVcsQ0FBQyxTQUFTLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBRTNELEVBQUUsQ0FBQyxXQUFXLENBQUMsU0FBUyxDQUFDLGtCQUFrQixHQUFHLFVBQVUsRUFBRTtJQUN4RCxJQUFJLENBQUMsZUFBZSxHQUFHLEVBQUUsQ0FBQTtJQUV6QixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELFdBQVc7QUFFWCxFQUFFLENBQUMsUUFBUSxHQUFHLFVBQVUsR0FBRyxFQUFFLEtBQUs7SUFDaEMsRUFBRSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFckIsSUFBSSxHQUFHLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUM1QyxHQUFHLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQTtJQUUxQixHQUFHLENBQUMsR0FBRyxHQUFHLEdBQUcsSUFBSSxHQUFHLENBQUE7SUFDcEIsSUFBSSxLQUFLLEtBQUssU0FBUztRQUFFLEdBQUcsQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFBO0lBRTFDLElBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFBO0lBRWQsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsUUFBUSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFM0QsRUFBRSxDQUFDLFFBQVEsQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHO0lBQy9CLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxLQUFLLENBQUE7QUFDdkIsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLFFBQVEsQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHLFVBQVUsS0FBSztJQUM5QyxJQUFJLENBQUMsR0FBRyxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUE7SUFFdEIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsUUFBUSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsVUFBVSxLQUFLO0lBQzVDLElBQUksQ0FBQyxHQUFHLENBQUMsR0FBRyxHQUFHLEtBQUssQ0FBQTtJQUVwQixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxRQUFRLENBQUMsU0FBUyxDQUFDLGdCQUFnQixHQUFHO0lBQ3ZDLElBQUksQ0FBQyxHQUFHLENBQUMsZUFBZSxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBRWpDLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsUUFBUTtBQUVSLEVBQUUsQ0FBQyxLQUFLLEdBQUcsVUFBVSxHQUFHLEVBQUUsR0FBRyxFQUFFLEtBQUssRUFBRSxJQUFJO0lBQ3hDLEVBQUUsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBRXJCLElBQUksR0FBRyxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDekMsR0FBRyxDQUFDLFNBQVMsR0FBRyxPQUFPLENBQUE7SUFDdkIsR0FBRyxDQUFDLElBQUksR0FBRyxPQUFPLENBQUE7SUFFbEIsR0FBRyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzVCLEdBQUcsQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUM1QixHQUFHLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFDaEMsR0FBRyxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBRTlCLElBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFBO0lBRWQsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsS0FBSyxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFeEQsRUFBRSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHO0lBQzVCLE9BQU8sVUFBVSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLENBQUE7QUFDbkMsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHLFVBQVUsR0FBRyxFQUFFLEdBQUc7SUFDOUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFBO0lBQ2xCLElBQUksQ0FBQyxHQUFHLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQTtJQUVsQixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLFFBQVEsR0FBRyxVQUFVLEtBQUs7SUFDM0MsSUFBSSxDQUFDLEdBQUcsQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFBO0lBRXRCLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsT0FBTyxHQUFHLFVBQVUsS0FBSztJQUMxQyxJQUFJLENBQUMsR0FBRyxDQUFDLElBQUksR0FBRyxLQUFLLENBQUE7SUFFckIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxtQkFBbUI7QUFFbkIsRUFBRSxDQUFDLGdCQUFnQixHQUFHO0lBQ3BCLCtFQUErRTtJQUUvRSxFQUFFLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUVyQixJQUFJLFNBQVMsR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQzdDLFNBQVMsQ0FBQyxTQUFTLEdBQUcsMkJBQTJCLENBQUE7SUFFakQsSUFBSSxRQUFRLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUNqRCxRQUFRLENBQUMsU0FBUyxHQUFHLGtCQUFrQixDQUFBO0lBRXZDLElBQUksSUFBSSxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLENBQUE7SUFDeEMsSUFBSSxDQUFDLFNBQVMsR0FBRyxzQkFBc0IsQ0FBQTtJQUV2QyxTQUFTLENBQUMsV0FBVyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0lBQy9CLFNBQVMsQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFM0IsUUFBUSxDQUFDLGdCQUFnQixDQUFDLE9BQU8sRUFBRSxVQUFVLEtBQUs7UUFDaEQsSUFBSSxDQUFDLFNBQVMsR0FBRyxRQUFRLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQTtJQUN4QyxDQUFDLEVBQUUsS0FBSyxDQUFDLENBQUE7SUFFVCxJQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQTtJQUN4QixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQTtJQUNoQixJQUFJLENBQUMsR0FBRyxHQUFHLFNBQVMsQ0FBQTtJQUVwQixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBRW5FLEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHO0lBQ3ZDLE9BQU8sSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLENBQUE7QUFDNUIsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLGdCQUFnQixDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO0lBQ3RELElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQTtJQUMzQixJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsR0FBRyxLQUFLLEdBQUcsSUFBSSxDQUFBO0lBRWxDLE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLGdCQUFnQixDQUFDLFNBQVMsQ0FBQyxhQUFhLEdBQUcsVUFBVSxLQUFLO0lBQzNELElBQUksQ0FBQyxRQUFRLENBQUMsVUFBVSxHQUFHLEtBQUssQ0FBQTtJQUVoQyxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsa0JBQWtCLEdBQUcsVUFBVSxLQUFLO0lBQ2hFLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLGVBQWUsR0FBRyxLQUFLLENBQUE7SUFFM0MsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxlQUFlO0FBRWYsRUFBRSxDQUFDLFdBQVcsR0FBRyxVQUFVLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLFdBQVc7SUFDL0QsNEJBQTRCO0lBQzVCLHdDQUF3QztJQUN4Qyx3QkFBd0I7SUFDeEIsb0NBQW9DO0lBRXBDLEVBQUUsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBRXJCLEtBQUssR0FBRyxLQUFLLElBQUksRUFBRSxDQUFBO0lBQ25CLFVBQVUsR0FBRyxVQUFVLElBQUksRUFBRSxDQUFBO0lBQzdCLE1BQU0sR0FBRyxNQUFNLElBQUksR0FBRyxDQUFBO0lBQ3RCLFdBQVcsR0FBRyxXQUFXLElBQUksY0FBYSxDQUFDLENBQUE7SUFFM0MsSUFBSSxHQUFHLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUN2QyxHQUFHLENBQUMsU0FBUyxHQUFHLGFBQWEsQ0FBQTtJQUM3QixHQUFHLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxNQUFNLEdBQUcsSUFBSSxDQUFBO0lBRWhDLElBQUksU0FBUyxHQUFHLEtBQUssQ0FBQyxNQUFNLENBQUE7SUFDNUIsSUFBSSxnQkFBZ0IsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxVQUFVLENBQUMsQ0FBQTtJQUNyRCxJQUFJLGdCQUFnQixHQUFHLGdCQUFnQixHQUFHLENBQUMsQ0FBQTtJQUMzQyxJQUFJLFlBQVksQ0FBQTtJQUNoQixJQUFJLFNBQVMsR0FBRyxnQkFBZ0IsR0FBRyxVQUFVLENBQUE7SUFDN0MsSUFBSSxZQUFZLEdBQUcsQ0FBQyxDQUFBO0lBQ3BCLElBQUksbUJBQW1CLEdBQUcsY0FBYSxDQUFDLENBQUE7SUFFeEMsSUFBSSxJQUFJLEdBQUcsUUFBUSxDQUFDLGFBQWEsQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUN4QyxJQUFJLENBQUMsS0FBSyxDQUFDLEtBQUssR0FBRyxNQUFNLENBQUE7SUFDekIsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsTUFBTSxHQUFHLElBQUksQ0FBQTtJQUNqQyxJQUFJLENBQUMsS0FBSyxDQUFFLFlBQVksQ0FBRSxHQUFHLE1BQU0sQ0FBQTtJQUNuQyxJQUFJLENBQUMsS0FBSyxDQUFDLFFBQVEsR0FBRyxVQUFVLENBQUE7SUFDaEMsSUFBSSxDQUFDLEtBQUssQ0FBQyxPQUFPLEdBQUcsQ0FBQyxDQUFBO0lBRXRCLElBQUksUUFBUSxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLENBQUE7SUFDNUMsUUFBUSxDQUFDLEtBQUssQ0FBQyxPQUFPLEdBQUcsQ0FBQyxDQUFBO0lBQzFCLFFBQVEsQ0FBQyxLQUFLLENBQUMsUUFBUSxHQUFHLFVBQVUsQ0FBQTtJQUNwQyxRQUFRLENBQUMsS0FBSyxDQUFDLEdBQUcsR0FBRyxDQUFDLENBQUE7SUFDdEIsUUFBUSxDQUFDLEtBQUssQ0FBQyxJQUFJLEdBQUcsQ0FBQyxDQUFBO0lBQ3ZCLFFBQVEsQ0FBQyxLQUFLLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQTtJQUM1QixRQUFRLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLFVBQVUsR0FBRyxTQUFTLENBQUMsR0FBRyxJQUFJLENBQUE7SUFFdkQsU0FBUyxTQUFTLENBQUUsQ0FBQztRQUNuQixJQUFJLElBQUksR0FBRyxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDekIsSUFBSSxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsZ0JBQWdCLENBQUMsQ0FBQTtRQUNwQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxVQUFVLEdBQUcsSUFBSSxDQUFBO1FBQ3JDLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxHQUFHLENBQUMsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxHQUFHLElBQUksQ0FBQTtRQUN4QyxPQUFPLElBQUksQ0FBQTtJQUNiLENBQUM7SUFFRCxTQUFTLFdBQVcsQ0FBRSxJQUFJO1FBQ3hCLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxFQUFFLElBQUksR0FBRyxnQkFBZ0IsQ0FBQyxDQUFBO1FBQzVELG1CQUFtQixDQUFDLElBQUksRUFBRSxTQUFTLENBQUMsQ0FBQTtRQUNwQyxpREFBaUQ7UUFDakQsK0NBQStDO1FBQy9DLElBQUksUUFBUSxHQUFHLFFBQVEsQ0FBQyxzQkFBc0IsRUFBRSxDQUFBO1FBQ2hELEtBQUssSUFBSSxDQUFDLEdBQUcsSUFBSSxFQUFFLENBQUMsR0FBRyxTQUFTLEVBQUUsQ0FBQyxFQUFFLEVBQUU7WUFDckMsUUFBUSxDQUFDLFdBQVcsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQTtTQUNuQztRQUNELDZDQUE2QztRQUM3QyxLQUFLLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEVBQUUsRUFBRTtZQUN0RCxJQUFJLENBQUMsVUFBVSxDQUFFLENBQUMsQ0FBRSxDQUFDLEtBQUssQ0FBQyxPQUFPLEdBQUcsTUFBTSxDQUFBO1lBQzNDLElBQUksQ0FBQyxVQUFVLENBQUUsQ0FBQyxDQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsRUFBRSxHQUFHLENBQUMsQ0FBQTtTQUNsRDtRQUNELElBQUksQ0FBQyxXQUFXLENBQUMsUUFBUSxDQUFDLENBQUE7SUFDNUIsQ0FBQztJQUFBLENBQUM7SUFFRixpRUFBaUU7SUFDakUsa0RBQWtEO0lBQ2xELElBQUksY0FBYyxHQUFHLFdBQVcsQ0FBQztRQUMvQix5Q0FBeUM7UUFDekMsSUFBSSxPQUFPLEdBQUcsR0FBRyxDQUFBO1FBQ2pCLE9BQU8sT0FBTyxLQUFLLFFBQVEsSUFBSSxPQUFPLENBQUMsVUFBVSxFQUFFO1lBQ2pELE9BQU8sR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFBO1NBQzdCO1FBQ0QsOENBQThDO1FBQzlDLElBQUksT0FBTyxLQUFLLFFBQVEsRUFBRTtZQUN4QixhQUFhLENBQUMsY0FBYyxDQUFDLENBQUE7U0FDOUI7UUFDRCxzQkFBc0I7UUFDdEIsSUFBSSxJQUFJLENBQUMsR0FBRyxFQUFFLEdBQUcsWUFBWSxHQUFHLEdBQUcsRUFBRTtZQUNuQyxJQUFJLFFBQVEsR0FBRyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsZUFBZSxDQUFDLENBQUE7WUFDckQsS0FBSyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxHQUFHLFFBQVEsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEVBQUUsRUFBRTtnQkFDL0MsSUFBSSxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUUsQ0FBQyxDQUFFLENBQUMsQ0FBQTthQUNoQztTQUNGO0lBQ0gsQ0FBQyxFQUFFLEdBQUcsQ0FBQyxDQUFBO0lBRVAsU0FBUyxRQUFRLENBQUUsQ0FBQztRQUNsQixJQUFJLFNBQVMsR0FBRyxDQUFDLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQSxDQUFDLGtCQUFrQjtRQUNyRCxJQUFJLENBQUMsWUFBWSxJQUFJLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxHQUFHLFlBQVksQ0FBQyxHQUFHLFNBQVMsRUFBRTtZQUNuRSxJQUFJLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLFNBQVMsR0FBRyxVQUFVLENBQUMsQ0FBQTtZQUM5QyxXQUFXLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQUUsS0FBSyxHQUFHLGdCQUFnQixDQUFDLENBQUMsQ0FBQTtZQUNsRCxZQUFZLEdBQUcsU0FBUyxDQUFBO1NBQ3pCO1FBQ0QsWUFBWSxHQUFHLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtRQUN6QixDQUFDLENBQUMsY0FBYyxJQUFJLENBQUMsQ0FBQyxjQUFjLEVBQUUsQ0FBQTtJQUN4QyxDQUFDO0lBRUQsTUFBTTtJQUVOLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLO1FBQzdCLEtBQUssR0FBRyxLQUFLLENBQUE7UUFDYixTQUFTLEdBQUcsS0FBSyxDQUFDLE1BQU0sQ0FBQTtRQUN4QixRQUFRLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLFVBQVUsR0FBRyxTQUFTLENBQUMsR0FBRyxJQUFJLENBQUE7UUFDdkQsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQ2QsT0FBTyxJQUFJLENBQUE7SUFDYixDQUFDLENBQUE7SUFFRCxJQUFJLENBQUMsYUFBYSxHQUFHLFVBQVUsS0FBSztRQUNsQyxVQUFVLEdBQUcsS0FBSyxDQUFBO1FBQ2xCLGdCQUFnQixHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxHQUFHLFVBQVUsQ0FBQyxDQUFBO1FBQ2pELGdCQUFnQixHQUFHLGdCQUFnQixHQUFHLENBQUMsQ0FBQTtRQUN2QyxTQUFTLEdBQUcsZ0JBQWdCLEdBQUcsVUFBVSxDQUFBO1FBQ3pDLFFBQVEsQ0FBQyxLQUFLLENBQUMsTUFBTSxHQUFHLENBQUMsVUFBVSxHQUFHLFNBQVMsQ0FBQyxHQUFHLElBQUksQ0FBQTtRQUN2RCxXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDZCxPQUFPLElBQUksQ0FBQTtJQUNiLENBQUMsQ0FBQTtJQUVELElBQUksQ0FBQyxTQUFTLEdBQUcsVUFBVSxLQUFLO1FBQzlCLEVBQUUsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLEtBQUssR0FBRyxJQUFJLENBQUMsQ0FBQTtRQUN2RCxNQUFNLEdBQUcsS0FBSyxDQUFBO1FBQ2QsZ0JBQWdCLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEdBQUcsVUFBVSxDQUFDLENBQUE7UUFDakQsZ0JBQWdCLEdBQUcsZ0JBQWdCLEdBQUcsQ0FBQyxDQUFBO1FBQ3ZDLFNBQVMsR0FBRyxnQkFBZ0IsR0FBRyxVQUFVLENBQUE7UUFDekMsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsTUFBTSxHQUFHLElBQUksQ0FBQTtRQUNqQyxRQUFRLENBQUMsS0FBSyxDQUFDLE1BQU0sR0FBRyxNQUFNLEdBQUcsSUFBSSxDQUFBO1FBQ3JDLFdBQVcsQ0FBQyxDQUFDLENBQUMsQ0FBQTtRQUNkLE9BQU8sSUFBSSxDQUFBO0lBQ2IsQ0FBQyxDQUFBO0lBRUQsSUFBSSxDQUFDLGNBQWMsR0FBRyxVQUFVLEtBQUs7UUFDbkMsV0FBVyxHQUFHLEtBQUssQ0FBQTtRQUNuQixXQUFXLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDZCxPQUFPLElBQUksQ0FBQTtJQUNiLENBQUMsQ0FBQTtJQUVELElBQUksQ0FBQyxzQkFBc0IsR0FBRyxVQUFVLEtBQUs7UUFDM0MsbUJBQW1CLEdBQUcsS0FBSyxDQUFBO0lBQzdCLENBQUMsQ0FBQTtJQUVELElBQUksQ0FBQyxNQUFNLEdBQUc7UUFDWixJQUFJLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxTQUFTLEdBQUcsVUFBVSxDQUFDLENBQUE7UUFDbkQsV0FBVyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFLEtBQUssR0FBRyxnQkFBZ0IsQ0FBQyxDQUFDLENBQUE7UUFDbEQsWUFBWSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUE7UUFDN0IsT0FBTyxJQUFJLENBQUE7SUFDYixDQUFDLENBQUE7SUFFRCxFQUFFO0lBRUYsSUFBSSxDQUFDLFdBQVcsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUMxQixHQUFHLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQ3JCLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxRQUFRLEVBQUUsUUFBUSxDQUFDLENBQUE7SUFDekMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBRWQsSUFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUE7SUFFZCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxXQUFXLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUU5RCxnQkFBZ0I7QUFFaEIsRUFBRSxDQUFDLFlBQVksR0FBRyxVQUFVLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNO0lBQ3BFLElBQUksQ0FBQyxHQUFHLE1BQU0sSUFBSSxFQUFFLENBQUE7SUFFcEIsRUFBRSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFbkIsZ0NBQWdDO0lBRWhDLElBQUksWUFBWSxHQUFHLENBQUMsQ0FBQyxZQUFZLEtBQUssU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUE7SUFDckUsSUFBSSxhQUFhLEdBQUcsQ0FBQyxDQUFDLGFBQWEsS0FBSyxTQUFTLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUN2RSxJQUFJLFlBQVksR0FBRyxDQUFDLENBQUMsWUFBWSxLQUFLLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFBO0lBQ3pFLElBQUksV0FBVyxHQUFHLENBQUMsQ0FBQyxXQUFXLENBQUE7SUFFL0IsU0FBUztJQUVULElBQUksTUFBTSxHQUFHLElBQUksRUFBRSxDQUFDLEtBQUssRUFBRTtTQUN4QixhQUFhLENBQUMsUUFBUSxDQUFDO1NBQ3ZCLFVBQVUsQ0FBQyxjQUFjLENBQUM7U0FDMUIsV0FBVyxDQUFDLEVBQUUsQ0FBQztTQUNmLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUVuQixJQUFJLFNBQVMsR0FBRyxDQUFDLENBQUE7SUFFakIsSUFBSSxRQUFRLEdBQUcsRUFBRSxDQUFBO0lBRWpCLElBQUksYUFBYSxHQUFHLFVBQVUsQ0FBQyxFQUFFLENBQUM7UUFDaEMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQ2QsQ0FBQyxDQUFBO0lBRUQsSUFBSSxXQUFXLEdBQUcsVUFBVSxDQUFDLEVBQUUsQ0FBQztRQUM5QixPQUFPLENBQUMsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFDM0IsQ0FBQyxDQUFBO0lBRUQsSUFBSSxVQUFVLEdBQUcsVUFBVSxHQUFHLEVBQUUsSUFBSTtRQUNsQyxJQUFJLElBQUksQ0FBQTtRQUNSLElBQUksT0FBTyxLQUFLLENBQUUsQ0FBQyxDQUFFLENBQUUsR0FBRyxDQUFFLEtBQUssUUFBUSxFQUFFO1lBQ3pDLElBQUksR0FBRyxXQUFXLENBQUE7U0FDbkI7YUFBTTtZQUNMLElBQUksR0FBRyxhQUFhLENBQUE7U0FDckI7UUFDRCxLQUFLLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUM7WUFDdkIsSUFBSSxJQUFJLEVBQUU7Z0JBQ1IsT0FBTyxJQUFJLENBQUMsQ0FBQyxDQUFFLEdBQUcsQ0FBRSxFQUFFLENBQUMsQ0FBRSxHQUFHLENBQUUsQ0FBQyxDQUFBO2FBQ2hDO2lCQUFNO2dCQUNMLE9BQU8sSUFBSSxDQUFDLENBQUMsQ0FBRSxHQUFHLENBQUUsRUFBRSxDQUFDLENBQUUsR0FBRyxDQUFFLENBQUMsQ0FBQTthQUNoQztRQUNILENBQUMsQ0FBQyxDQUFBO1FBQ0YsV0FBVyxDQUFDLE1BQU0sRUFBRSxDQUFBO1FBQ3BCLE9BQU8sSUFBSSxDQUFBO0lBQ2IsQ0FBQyxDQUFBO0lBRUQsSUFBSSxTQUFTLEdBQUcsVUFBVSxLQUFLLEVBQUUsR0FBRztRQUNsQyxRQUFRLENBQUMsTUFBTSxHQUFHLENBQUMsQ0FBQTtRQUNuQixJQUFJLFdBQVc7WUFBRSxXQUFXLENBQUMsS0FBSyxFQUFFLEdBQUcsQ0FBQyxDQUFBO1FBQ3hDLElBQUksR0FBRyxLQUFLLFNBQVMsRUFBRTtZQUNyQixRQUFRLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBRSxHQUFHLENBQUUsQ0FBRSxDQUFDLENBQUUsQ0FBQyxDQUFBO1NBQ2pDO1FBQ0QsV0FBVyxDQUFDLE1BQU0sRUFBRSxDQUFBO1FBQ3BCLE9BQU8sSUFBSSxDQUFBO0lBQ2IsQ0FBQyxDQUFBO0lBRUQsT0FBTyxDQUFDLE9BQU8sQ0FBQyxVQUFVLEdBQUc7UUFDM0IsSUFBSSxLQUFLLEdBQUcsR0FBRyxDQUFDLEtBQUssSUFBSSxZQUFZLENBQUE7UUFDckMsSUFBSSxNQUFNLEdBQUcsR0FBRyxDQUFDLE1BQU0sSUFBSSxhQUFhLENBQUE7UUFFeEMsSUFBSSxJQUFJLEdBQUcsSUFBSSxFQUFFLENBQUMsWUFBWSxFQUFFO2FBQzdCLFFBQVEsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDO2FBQ2xCLFFBQVEsQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDO2FBQ3RCLFlBQVksQ0FBQyxHQUFHLENBQUMsS0FBSyxJQUFJLFlBQVksQ0FBQzthQUN2QyxhQUFhLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQzthQUM1QixjQUFjLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQzthQUM3QixTQUFTLENBQUMsU0FBUyxDQUFDO2FBQ3BCLE9BQU8sQ0FBQyxVQUFVLENBQUM7WUFDbEIsSUFBSSxJQUFJLEdBQUcsR0FBRyxDQUFDLFVBQVUsS0FBSyxLQUFLLENBQUE7WUFDbkMsVUFBVSxDQUFDLEdBQUcsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLENBQUE7WUFDM0IsSUFBSSxJQUFJLEVBQUU7Z0JBQ1IsR0FBRyxDQUFDLFVBQVUsR0FBRyxNQUFNLENBQUE7YUFDeEI7aUJBQU07Z0JBQ0wsR0FBRyxDQUFDLFVBQVUsR0FBRyxLQUFLLENBQUE7YUFDdkI7UUFDSCxDQUFDLENBQUMsQ0FBQTtRQUVKLE1BQU0sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUE7UUFFaEIsU0FBUyxJQUFJLEtBQUssR0FBRyxDQUFDLEdBQUcsTUFBTSxDQUFBO0lBQ2pDLENBQUMsQ0FBQyxDQUFBO0lBRUYsT0FBTztJQUVQLElBQUksV0FBVyxHQUFHLFVBQVUsS0FBSztRQUMvQixJQUFJLEtBQUssR0FBRyxJQUFJLEVBQUUsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUUxQixPQUFPLENBQUMsT0FBTyxDQUFDLFVBQVUsR0FBRztZQUMzQixJQUFJLEtBQUssR0FBRyxLQUFLLENBQUUsS0FBSyxDQUFFLENBQUUsR0FBRyxDQUFDLEtBQUssQ0FBRSxDQUFBO1lBQ3ZDLElBQUksR0FBRyxDQUFDLE1BQU07Z0JBQUUsS0FBSyxHQUFHLEdBQUcsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUE7WUFFekMsSUFBSSxLQUFLLEdBQUcsR0FBRyxDQUFDLEtBQUssSUFBSSxZQUFZLENBQUE7WUFDckMsSUFBSSxNQUFNLEdBQUcsR0FBRyxDQUFDLE1BQU0sSUFBSSxhQUFhLENBQUE7WUFFeEMsSUFBSSxPQUFPLENBQUE7WUFDWCxJQUFJLE9BQU8sS0FBSyxLQUFLLFFBQVEsRUFBRTtnQkFDN0IsT0FBTyxHQUFHLEtBQUssQ0FBQTthQUNoQjtpQkFBTTtnQkFDTCxPQUFPLEdBQUcsSUFBSSxFQUFFLENBQUMsSUFBSSxFQUFFO3FCQUNwQixRQUFRLENBQUMsS0FBSyxDQUFDLENBQUE7YUFDbkI7WUFFRCxPQUFPO2lCQUNKLFFBQVEsQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFDO2lCQUN0QixZQUFZLENBQUMsR0FBRyxDQUFDLEtBQUssSUFBSSxZQUFZLENBQUM7aUJBQ3ZDLGFBQWEsQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDO2lCQUM1QixjQUFjLENBQUMsTUFBTSxHQUFHLElBQUksQ0FBQztpQkFDN0IsT0FBTyxDQUFDLFVBQVUsS0FBSztnQkFDdEIsSUFBSSxPQUFPLEdBQUcsQ0FBQyxPQUFPLEtBQUssVUFBVSxFQUFFO29CQUNyQyxHQUFHLENBQUMsT0FBTyxDQUFDLEtBQUssRUFBRSxLQUFLLEVBQUUsS0FBSyxDQUFDLENBQUE7aUJBQ2pDO1lBQ0gsQ0FBQyxDQUFDO2lCQUNELFdBQVcsQ0FBQyxVQUFVLEtBQUs7Z0JBQzFCLElBQUksT0FBTyxHQUFHLENBQUMsV0FBVyxLQUFLLFVBQVUsRUFBRTtvQkFDekMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxLQUFLLEVBQUUsS0FBSyxFQUFFLEtBQUssQ0FBQyxDQUFBO2lCQUNyQztZQUNILENBQUMsQ0FBQztpQkFDRCxVQUFVLENBQUMsVUFBVSxLQUFLO2dCQUN6QixJQUFJLE9BQU8sR0FBRyxDQUFDLFVBQVUsS0FBSyxVQUFVLEVBQUU7b0JBQ3hDLEdBQUcsQ0FBQyxVQUFVLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxLQUFLLENBQUMsQ0FBQTtpQkFDcEM7WUFDSCxDQUFDLENBQUMsQ0FBQTtZQUVKLEtBQUssQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUE7UUFDcEIsQ0FBQyxDQUFDLENBQUE7UUFFRixLQUFLO2FBQ0YsU0FBUyxDQUFDLFNBQVMsQ0FBQzthQUNwQixPQUFPLENBQUMsVUFBVSxLQUFLO1lBQ3RCLFNBQVMsQ0FBQyxLQUFLLEVBQUUsS0FBSyxDQUFDLENBQUE7UUFDekIsQ0FBQyxDQUFDLENBQUE7UUFFSixJQUFJLFFBQVEsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFFLEtBQUssQ0FBRSxDQUFFLENBQUMsQ0FBRSxDQUFDLEtBQUssQ0FBQyxDQUFDLEVBQUU7WUFDaEQsS0FBSyxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxDQUFBO1NBQ3JDO1FBRUQsT0FBTyxLQUFLLENBQUMsR0FBRyxDQUFBO0lBQ2xCLENBQUMsQ0FBQTtJQUVELElBQUksV0FBVyxHQUFHLElBQUksRUFBRSxDQUFDLFdBQVcsQ0FDbEMsS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLEVBQUUsV0FBVyxDQUN2QyxDQUFDLFFBQVEsQ0FBQyxDQUFDLFNBQVMsR0FBRyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsQ0FBQTtJQUVuQyxFQUFFO0lBRUYsSUFBSSxDQUFDLEdBQUcsQ0FBQyxNQUFNLEVBQUUsV0FBVyxDQUFDLENBQUE7SUFFN0IsTUFBTTtJQUVOLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFBO0lBQ3BCLElBQUksQ0FBQyxJQUFJLEdBQUcsV0FBVyxDQUFBO0lBQ3ZCLElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFBO0lBQzVCLElBQUksQ0FBQyxTQUFTLEdBQUcsVUFBVSxHQUFHO1FBQzVCLFNBQVMsQ0FBQyxTQUFTLEVBQUUsR0FBRyxDQUFDLENBQUE7SUFDM0IsQ0FBQyxDQUFBO0lBRUQsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFN0QsRUFBRSxDQUFDLFNBQVMsR0FBRyxVQUFVLFNBQVMsRUFBRSxPQUFPLEVBQUUsWUFBWTtJQUN2RCxZQUFZLEdBQUcsWUFBWSxJQUFJLGNBQWMsQ0FBQTtJQUU3QyxFQUFFLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUVuQixJQUFJLGVBQWUsR0FBRyxPQUFPLENBQUE7SUFFN0IsSUFBSSxJQUFJLEdBQUcsSUFBSSxFQUFFLENBQUMsSUFBSSxDQUFDLFNBQVMsSUFBSSxNQUFNLENBQUMsQ0FBQTtJQUUzQyxJQUFJLEtBQUssR0FBRyxJQUFJLEVBQUUsQ0FBQyxZQUFZLEVBQUU7U0FDOUIsVUFBVSxDQUFDLE1BQU0sQ0FBQztTQUNsQixNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBRW5CLElBQUksT0FBTyxHQUFHLENBQUMsQ0FBQTtJQUNmLElBQUksT0FBTyxHQUFHLENBQUMsQ0FBQTtJQUVmLElBQUksS0FBSyxHQUFHLENBQUMsQ0FBQTtJQUNiLElBQUksS0FBSyxHQUFHLENBQUMsQ0FBQTtJQUViLFNBQVMsV0FBVyxDQUFFLENBQUM7UUFDckIsSUFBSSxLQUFLLEtBQUssQ0FBQyxFQUFFO1lBQ2YsS0FBSyxHQUFHLENBQUMsQ0FBQyxPQUFPLENBQUE7WUFDakIsS0FBSyxHQUFHLENBQUMsQ0FBQyxPQUFPLENBQUE7U0FDbEI7UUFDRCxPQUFPLElBQUksS0FBSyxHQUFHLENBQUMsQ0FBQyxPQUFPLENBQUE7UUFDNUIsT0FBTyxJQUFJLEtBQUssR0FBRyxDQUFDLENBQUMsT0FBTyxDQUFBO1FBQzVCLEtBQUssR0FBRyxDQUFDLENBQUMsT0FBTyxDQUFBO1FBQ2pCLEtBQUssR0FBRyxDQUFDLENBQUMsT0FBTyxDQUFBO0lBQ25CLENBQUM7SUFFRCxJQUFJLFlBQVksR0FBRyxJQUFJLEVBQUUsQ0FBQyxLQUFLLEVBQUU7U0FDOUIsZUFBZSxDQUFDLGdCQUFnQixDQUFDO1NBQ2pDLGVBQWUsQ0FBQyxNQUFNLENBQUM7U0FDdkIsU0FBUyxDQUFDLE1BQU0sQ0FBQztTQUNqQixTQUFTLENBQUMsTUFBTSxDQUFDO1NBQ2pCLFdBQVcsQ0FBQyxVQUFVLENBQUM7UUFDdEIsSUFBSSxDQUFDLENBQUMsS0FBSyxLQUFLLENBQUMsRUFBRTtZQUNqQixRQUFRLENBQUMsZ0JBQWdCLENBQUMsV0FBVyxFQUFFLFdBQVcsQ0FBQyxDQUFBO1NBQ3BEO1FBQ0QsUUFBUSxDQUFDLGdCQUFnQixDQUFDLFNBQVMsRUFBRSxVQUFVLENBQUM7WUFDOUMsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFdBQVcsRUFBRSxXQUFXLENBQUMsQ0FBQTtRQUN4RCxDQUFDLENBQUMsQ0FBQTtJQUNKLENBQUMsQ0FBQyxDQUFBO0lBRUosWUFBWTtTQUNULEdBQUcsQ0FDRixJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO1NBQ2pCLFFBQVEsQ0FBQyxPQUFPLENBQUM7U0FDakIsU0FBUyxDQUFDLFNBQVMsQ0FBQztTQUNwQixPQUFPLENBQUM7UUFDUCxJQUFJLENBQUMsY0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQzdCLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FDaEI7U0FDQSxHQUFHLENBQ0YsSUFBSSxFQUFFLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUNyQixDQUFBO0lBRUgsS0FBSyxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQTtJQUV2QixJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3JCLElBQUksQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDekIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUM7UUFDdEIsSUFBSSxLQUFLLENBQUMsVUFBVSxFQUFFLEtBQUssT0FBTyxFQUFFO1lBQ2xDLElBQUksQ0FBQyxjQUFjLENBQUMsTUFBTSxDQUFDLENBQUE7WUFDM0IsT0FBTTtTQUNQO1FBRUQsS0FBSyxDQUFDLFlBQVksQ0FBQyxDQUFDLE1BQU0sQ0FBQyxXQUFXLEdBQUcsR0FBRyxDQUFDLEdBQUcsSUFBSSxDQUFDLENBQUE7UUFDckQsSUFBSSxDQUFDLGNBQWMsQ0FBQyxPQUFPLENBQUMsQ0FBQTtRQUU1QixPQUFPLEdBQUcsQ0FBQyxDQUFBO1FBQ1gsT0FBTyxHQUFHLENBQUMsQ0FBQTtJQUViLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQTtJQUViLElBQUksQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUE7SUFFZCxJQUFJLENBQUMsUUFBUSxDQUFDLEVBQUUsQ0FBQztTQUNkLFVBQVUsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUV2QixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQTtJQUNoQixJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQTtJQUNsQixJQUFJLENBQUMsZUFBZSxHQUFHLGVBQWUsQ0FBQTtJQUV0QyxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxTQUFTLENBQUMsU0FBUyxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUUxRCxFQUFFLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxRQUFRLEdBQUcsVUFBVSxLQUFLLEVBQUUsS0FBSztJQUN0RCxJQUFJLENBQUMsS0FBSztTQUNQLEdBQUcsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDO1FBQ3JCLDZCQUE2QjtTQUM1QixRQUFRLENBQUMsSUFBSSxDQUFDLGVBQWUsQ0FBQyxDQUFDO1NBQ2pDLEdBQUcsQ0FBQyxLQUFLLElBQUksSUFBSSxFQUFFLENBQUMsS0FBSyxFQUFFLENBQUM7U0FDNUIsR0FBRyxDQUFDLElBQUksRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFDLENBQUE7SUFFdEIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxrQkFBa0IsR0FBRyxVQUFVLEtBQUs7SUFDekQsSUFBSSxDQUFDLGVBQWUsR0FBRyxLQUFLLENBQUE7SUFFNUIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEdBQUcsVUFBVSxLQUFLO0lBQ3JELElBQUksQ0FBQyxLQUFLLENBQUMsVUFBVSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBRTVCLElBQUksS0FBSyxLQUFLLE1BQU07UUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUU1QyxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLFlBQVksR0FBRyxVQUFVLEtBQUs7SUFDbkQsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLENBQUE7SUFFekIsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDLENBQUE7QUFFRCxFQUFFLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxPQUFPLEdBQUc7SUFDL0IsSUFBSSxDQUFDLEtBQUssQ0FBQyxPQUFPLEVBQUUsQ0FBQTtJQUVwQixFQUFFLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0FBQ3pDLENBQUMsQ0FBQTtBQUVELHlCQUF5QjtBQUV6QixFQUFFLENBQUMsb0JBQW9CLEdBQUcsVUFBVSxVQUFVLEVBQUUsVUFBVTtJQUN4RCxFQUFFLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUVuQixJQUFJLENBQUMsR0FBRyxDQUFDLFNBQVMsR0FBRyx3QkFBd0IsQ0FBQTtJQUU3QyxJQUFJLFVBQVUsS0FBSyxTQUFTLEVBQUU7UUFDNUIsNENBQTRDO1FBQzVDLDZDQUE2QztRQUU3QyxVQUFVLEdBQUcsVUFBVSxJQUFJLGNBQWMsQ0FBQTtRQUN6QyxVQUFVLEdBQUcsVUFBVSxJQUFJLGVBQWUsQ0FBQTtLQUMzQztJQUVELElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxFQUFFLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQztTQUNsQyxRQUFRLENBQUMsaUJBQWlCLENBQUM7U0FDM0IsU0FBUyxDQUFDLFNBQVMsQ0FBQztTQUNwQixRQUFRLENBQUMsTUFBTSxDQUFDO1NBQ2hCLGNBQWMsQ0FBQyxLQUFLLENBQUMsQ0FBQTtJQUN4QixJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUUzQixJQUFJLEtBQUssR0FBRyxJQUFJLENBQUE7SUFDaEIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxFQUFFLFVBQVUsS0FBSztRQUN2RCxLQUFLLENBQUMsTUFBTSxFQUFFLENBQUE7SUFDaEIsQ0FBQyxFQUFFLEtBQUssQ0FBQyxDQUFBO0lBRVQsSUFBSSxDQUFDLE9BQU8sR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQzVDLElBQUksQ0FBQyxPQUFPLENBQUMsU0FBUyxHQUFHLG9CQUFvQixDQUFBO0lBQzdDLElBQUksQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQTtJQUVsQyxJQUFJLENBQUMsV0FBVyxHQUFHLEtBQUssQ0FBQTtJQUV4QixJQUFJLENBQUMsVUFBVSxHQUFHLFVBQVUsQ0FBQTtJQUM1QixJQUFJLENBQUMsVUFBVSxHQUFHLFVBQVUsQ0FBQTtJQUU1QixPQUFPLElBQUksQ0FBQTtBQUNiLENBQUMsQ0FBQTtBQUVELEVBQUUsQ0FBQyxvQkFBb0IsQ0FBQyxTQUFTLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsZ0JBQWdCLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFaEYsRUFBRSxDQUFDLG9CQUFvQixDQUFDLFNBQVMsQ0FBQyxZQUFZLEdBQUcsVUFBVSxZQUFZO0lBQ3JFLElBQUksWUFBWSxFQUFFO1FBQ2hCLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUVuQyxJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUU7WUFDbkIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7U0FDMUQ7YUFBTTtZQUNMLElBQUksQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLFdBQVcsQ0FBQyxDQUFBO1NBQ2xDO0tBQ0Y7U0FBTTtRQUNMLElBQUksQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUV0QyxJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUU7WUFDbkIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7U0FDMUQ7YUFBTTtZQUNMLElBQUksQ0FBQyxNQUFNLENBQUMsV0FBVyxDQUFDLFdBQVcsQ0FBQyxDQUFBO1NBQ3JDO0tBQ0Y7SUFFRCxJQUFJLENBQUMsV0FBVyxHQUFHLFlBQVksQ0FBQTtBQUNqQyxDQUFDLENBQUE7QUFFRCwyQ0FBMkM7QUFDM0Msa0RBQWtEO0FBQ2xELDJDQUEyQztBQUUzQyxFQUFFLENBQUMsV0FBVyxHQUFHO0lBQ2YsSUFBSSxLQUFLLEdBQUcsSUFBSSxDQUFBO0lBRWhCLEVBQUUsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBRW5CLFNBQVM7SUFFVCxJQUFJLENBQUMsWUFBWSxHQUFHLElBQUksRUFBRSxDQUFDLEtBQUssRUFBRTtTQUMvQixRQUFRLENBQUMsZUFBZSxDQUFDLENBQUE7SUFFNUIsSUFBSSxDQUFDLGVBQWUsR0FBRyxJQUFJLEVBQUUsQ0FBQyxLQUFLLEVBQUU7U0FDbEMsUUFBUSxDQUFDLGlCQUFpQixDQUFDLENBQUE7SUFFOUIsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLEVBQUUsQ0FBQyxLQUFLLEVBQUU7U0FDekIsUUFBUSxDQUFDLE9BQU8sQ0FBQztTQUNqQixRQUFRLENBQUMsTUFBTSxDQUFDO1NBQ2hCLFNBQVMsQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUVwQixJQUFJLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FDbkIsSUFBSSxDQUFDLE1BQU0sRUFDWCxJQUFJLENBQUMsZUFBZSxDQUNyQixDQUFBO0lBRUQsU0FBUztJQUVULElBQUksQ0FBQyxhQUFhLEdBQUcsSUFBSSxFQUFFLENBQUMsS0FBSyxFQUFFO1NBQ2hDLFFBQVEsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFBO0lBRTdCLElBQUksQ0FBQyxlQUFlLEdBQUcsSUFBSSxFQUFFLENBQUMsS0FBSyxFQUFFO1NBQ2xDLFFBQVEsQ0FBQyxrQkFBa0IsQ0FBQyxDQUFBO0lBRS9CLElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxFQUFFLENBQUMsS0FBSyxFQUFFO1NBQ3pCLFFBQVEsQ0FBQyxRQUFRLENBQUM7U0FDbEIsUUFBUSxDQUFDLE9BQU8sQ0FBQztTQUNqQixTQUFTLENBQUMsTUFBTSxDQUFDLENBQUE7SUFFcEIsSUFBSSxDQUFDLGFBQWEsQ0FBQyxHQUFHLENBQ3BCLElBQUksQ0FBQyxNQUFNLEVBQ1gsSUFBSSxDQUFDLGVBQWUsQ0FDckIsQ0FBQTtJQUVELFFBQVE7SUFFUixJQUFJLFdBQVcsR0FBRyxRQUFRLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQy9DLFdBQVcsQ0FBQyxTQUFTLENBQUMsUUFBUSxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQTtJQUUzQyxXQUFXO0lBRVgsSUFBSSxDQUFDLEdBQUcsQ0FDTixJQUFJLENBQUMsYUFBYSxFQUNsQixJQUFJLENBQUMsWUFBWSxDQUNsQixDQUFBO0lBRUQsSUFBSSxDQUFDLFdBQVcsR0FBRyxXQUFXLENBRTVCLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxFQUNmLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxFQUVmLFVBQVUsR0FBRyxFQUFFLEdBQUcsRUFBRSxHQUFHLEVBQUUsZ0JBQWdCLEVBQUUsZ0JBQWdCO1FBQ3pELElBQUksQ0FBQyxnQkFBZ0IsSUFBSSxnQkFBZ0IsSUFBSSxHQUFHLENBQUMsQ0FBQyxHQUFHLElBQUksRUFBRTtZQUN6RCxHQUFHLENBQUMsQ0FBQyxHQUFHLEdBQUcsQ0FBQTtZQUNYLEdBQUcsQ0FBQyxDQUFDLEdBQUcsR0FBRyxDQUFBO1lBQ1gsS0FBSyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUE7WUFFN0IsT0FBTTtTQUNQO1FBRUQsV0FBVyxDQUFDLGtCQUFrQixDQUM1QixLQUFLLENBQUMsZUFBZSxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsZUFBZSxDQUFDLEdBQUcsRUFDcEQsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQ25DLENBQUE7UUFFRCxLQUFLLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQTtRQUNmLEtBQUssQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFBO1FBQ2YsS0FBSyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUE7UUFFZixJQUFJLENBQUMsS0FBSyxDQUFDLGFBQWEsRUFBRTtZQUN4QixLQUFLLENBQUMsR0FBRyxDQUFDLGFBQWEsQ0FBQyxXQUFXLENBQUMsQ0FBQTtTQUNyQztJQUNILENBQUMsQ0FFRixDQUFBO0lBRUQsSUFBSSxDQUFDLFdBQVcsQ0FBQyxhQUFhLENBQzVCLElBQUksQ0FBQyxlQUFlLENBQUMsR0FBRyxFQUN4QixJQUFJLENBQUMsZUFBZSxDQUFDLEdBQUcsQ0FDekIsQ0FBQTtJQUVELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLFdBQVcsQ0FBQyxTQUFTLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBRTVELEVBQUUsQ0FBQyxXQUFXLENBQUMsU0FBUyxDQUFDLFFBQVEsR0FBRyxVQUFVLEtBQUs7SUFDakQsSUFBSSxLQUFLLEtBQUssSUFBSSxDQUFDLEdBQUcsRUFBRTtRQUN0QixJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQTtRQUN6QixJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQTtRQUM5QixJQUFJLENBQUMsYUFBYSxHQUFHLEtBQUssQ0FBQTtLQUMzQjtJQUVELE9BQU8sSUFBSSxDQUFBO0FBQ2IsQ0FBQyxDQUFBO0FBRUQsRUFBRSxDQUFDLFdBQVcsQ0FBQyxTQUFTLENBQUMsUUFBUSxHQUFHO0lBQ2xDLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQTtBQUNqQixDQUFDLENBQUE7QUFFRCxNQUFNLENBQUMsT0FBTyxHQUFHO0lBQ2IsSUFBSSxFQUFFLEVBQUU7Q0FDWCxDQUFBIn0= /***/ }), -/* 104 */ +/* 103 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -120128,7 +68884,7 @@ return $.ui.keyCode = { /***/ }), -/* 105 */ +/* 104 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { @@ -120184,7 +68940,7 @@ return $.ui.plugin = { /***/ }), -/* 106 */ +/* 105 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { @@ -120237,7 +68993,7 @@ return $.ui.safeActiveElement = function( document ) { /***/ }), -/* 107 */ +/* 106 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { @@ -120271,7 +69027,7 @@ return $.ui.safeBlur = function( element ) { /***/ }), -/* 108 */ +/* 107 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -120367,18 +69123,18 @@ return $.ui.focusable; /***/ }), -/* 109 */ +/* 108 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__.p + "f83a8b8886694eaef4505dd80af7a430.png"; /***/ }), -/* 110 */ +/* 109 */ /***/ (function(module, exports, __webpack_require__) { module.exports = {}; var loadedModules = [ - __webpack_require__(111), + __webpack_require__(110), ]; for (var i in loadedModules) { if (loadedModules && Object.prototype.hasOwnProperty.call(loadedModules, i)) { @@ -120394,7 +69150,7 @@ module.exports['version'] = __webpack_require__(12).version; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFDLE9BQU8sR0FBRyxFQUFFLENBQUM7QUFFcEIsSUFBSSxhQUFhLEdBQUc7SUFDaEIsT0FBTyxDQUFDLGlCQUFpQixDQUFDO0NBQzdCLENBQUE7QUFFRCxLQUFLLElBQUksQ0FBQyxJQUFJLGFBQWEsRUFBRTtJQUN6QixJQUFJLGFBQWEsSUFBSSxNQUFNLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUMsQ0FBQyxFQUFFO1FBQ3pFLElBQUksWUFBWSxHQUFHLGFBQWEsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNwQyxLQUFLLElBQUksV0FBVyxJQUFJLFlBQVksRUFBRTtZQUNsQyxJQUFJLFlBQVksSUFBSSxNQUFNLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsWUFBWSxFQUFFLFdBQVcsQ0FBQyxFQUFFO2dCQUNqRixNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxHQUFHLFlBQVksQ0FBQyxXQUFXLENBQUMsQ0FBQzthQUMzRDtTQUNKO0tBQ0o7Q0FDSjtBQUVELE1BQU0sQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsT0FBTyxDQUFDLGlCQUFpQixDQUFDLENBQUMsT0FBTyxDQUFDIn0= /***/ }), -/* 111 */ +/* 110 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -120416,17 +69172,17 @@ var NGL = __webpack_require__(18); var BaseView = __webpack_require__(29).BaseView; const $ = __webpack_require__(0); const _ = __webpack_require__(34); -__webpack_require__(102); -__webpack_require__(194); +__webpack_require__(101); +__webpack_require__(187); __webpack_require__(50); -__webpack_require__(103); -__webpack_require__(195); -__webpack_require__(196); // FIXME: remove? -__webpack_require__(212); // FIXME: remove? -const gui_1 = __webpack_require__(241); -const fullscreen_1 = __webpack_require__(242); -const color_1 = __webpack_require__(243); -const theme_1 = __webpack_require__(244); +__webpack_require__(102); +__webpack_require__(188); +__webpack_require__(189); // FIXME: remove? +__webpack_require__(205); // FIXME: remove? +const gui_1 = __webpack_require__(234); +const fullscreen_1 = __webpack_require__(235); +const color_1 = __webpack_require__(236); +const theme_1 = __webpack_require__(237); NGL.nglview_debug = false; // From NGL // http://www.broofa.com/Tools/Math.uuid.htm @@ -121546,7 +70302,7 @@ module.exports = { //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2lkZ2V0X25nbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy93aWRnZXRfbmdsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQUFBLElBQUksT0FBTyxDQUFBO0FBQ1gsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLHVCQUF1QixDQUFDLENBQUE7QUFDOUMsSUFBSSxHQUFHLEdBQUcsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0FBQ3hCLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQyxRQUFRLENBQUE7QUFDekMsNEJBQTJCO0FBQzNCLGdDQUErQjtBQUMvQixnQ0FBNkI7QUFDN0Isb0NBQWlDO0FBQ2pDLHNCQUFtQjtBQUNuQiw0QkFBeUI7QUFDekIsMEJBQXVCO0FBQ3ZCLHVDQUFvQyxDQUFDLGlCQUFpQjtBQUN0RCx5Q0FBc0MsQ0FBQyxpQkFBaUI7QUFFeEQsK0JBQW1DO0FBQ25DLDZDQUE4RDtBQUM5RCxtQ0FBeUU7QUFDekUsbUNBQTREO0FBRTVELEdBQUcsQ0FBQyxhQUFhLEdBQUcsS0FBSyxDQUFBO0FBRXpCLFdBQVc7QUFDWCw0Q0FBNEM7QUFDNUMsTUFBTSxLQUFLLEdBQUcsZ0VBQWdFLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxDQUFBO0FBQ3hGLE1BQU0sSUFBSSxHQUFHLElBQUksS0FBSyxDQUFDLEVBQUUsQ0FBQyxDQUFBO0FBRTFCLFNBQVMsWUFBWTtJQUNuQixJQUFJLEdBQUcsR0FBRyxDQUFDLENBQUE7SUFDWCxJQUFJLENBQUMsQ0FBQTtJQUVMLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxFQUFFLEVBQUUsQ0FBQyxFQUFFLEVBQUU7UUFDM0IsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLEtBQUssRUFBRSxFQUFFO1lBQy9DLElBQUksQ0FBRSxDQUFD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 /***/ }), -/* 112 */ +/* 111 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__; @@ -124292,10 +73048,10 @@ module.exports = { }).call(this); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(113)(module))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(112)(module))) /***/ }), -/* 113 */ +/* 112 */ /***/ (function(module, exports) { module.exports = function(module) { @@ -124323,7 +73079,7 @@ module.exports = function(module) { /***/ }), -/* 114 */ +/* 113 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ @@ -124561,865 +73317,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ /***/ }), -/* 115 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(setImmediate) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__finally__ = __webpack_require__(119); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__allSettled__ = __webpack_require__(120); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__any__ = __webpack_require__(121); - - - - -// Store setTimeout reference so promise-polyfill will be unaffected by -// other code modifying setTimeout (like sinon.useFakeTimers()) -var setTimeoutFunc = setTimeout; - -function isArray(x) { - return Boolean(x && typeof x.length !== 'undefined'); -} - -function noop() {} - -// Polyfill for Function.prototype.bind -function bind(fn, thisArg) { - return function() { - fn.apply(thisArg, arguments); - }; -} - -/** - * @constructor - * @param {Function} fn - */ -function Promise(fn) { - if (!(this instanceof Promise)) - throw new TypeError('Promises must be constructed via new'); - if (typeof fn !== 'function') throw new TypeError('not a function'); - /** @type {!number} */ - this._state = 0; - /** @type {!boolean} */ - this._handled = false; - /** @type {Promise|undefined} */ - this._value = undefined; - /** @type {!Array} */ - this._deferreds = []; - - doResolve(fn, this); -} - -function handle(self, deferred) { - while (self._state === 3) { - self = self._value; - } - if (self._state === 0) { - self._deferreds.push(deferred); - return; - } - self._handled = true; - Promise._immediateFn(function() { - var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; - if (cb === null) { - (self._state === 1 ? resolve : reject)(deferred.promise, self._value); - return; - } - var ret; - try { - ret = cb(self._value); - } catch (e) { - reject(deferred.promise, e); - return; - } - resolve(deferred.promise, ret); - }); -} - -function resolve(self, newValue) { - try { - // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === self) - throw new TypeError('A promise cannot be resolved with itself.'); - if ( - newValue && - (typeof newValue === 'object' || typeof newValue === 'function') - ) { - var then = newValue.then; - if (newValue instanceof Promise) { - self._state = 3; - self._value = newValue; - finale(self); - return; - } else if (typeof then === 'function') { - doResolve(bind(then, newValue), self); - return; - } - } - self._state = 1; - self._value = newValue; - finale(self); - } catch (e) { - reject(self, e); - } -} - -function reject(self, newValue) { - self._state = 2; - self._value = newValue; - finale(self); -} - -function finale(self) { - if (self._state === 2 && self._deferreds.length === 0) { - Promise._immediateFn(function() { - if (!self._handled) { - Promise._unhandledRejectionFn(self._value); - } - }); - } - - for (var i = 0, len = self._deferreds.length; i < len; i++) { - handle(self, self._deferreds[i]); - } - self._deferreds = null; -} - -/** - * @constructor - */ -function Handler(onFulfilled, onRejected, promise) { - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; - this.onRejected = typeof onRejected === 'function' ? onRejected : null; - this.promise = promise; -} - -/** - * Take a potentially misbehaving resolver function and make sure - * onFulfilled and onRejected are only called once. - * - * Makes no guarantees about asynchrony. - */ -function doResolve(fn, self) { - var done = false; - try { - fn( - function(value) { - if (done) return; - done = true; - resolve(self, value); - }, - function(reason) { - if (done) return; - done = true; - reject(self, reason); - } - ); - } catch (ex) { - if (done) return; - done = true; - reject(self, ex); - } -} - -Promise.prototype['catch'] = function(onRejected) { - return this.then(null, onRejected); -}; - -Promise.prototype.then = function(onFulfilled, onRejected) { - // @ts-ignore - var prom = new this.constructor(noop); - - handle(this, new Handler(onFulfilled, onRejected, prom)); - return prom; -}; - -Promise.prototype['finally'] = __WEBPACK_IMPORTED_MODULE_0__finally__["a" /* default */]; - -Promise.all = function(arr) { - return new Promise(function(resolve, reject) { - if (!isArray(arr)) { - return reject(new TypeError('Promise.all accepts an array')); - } - - var args = Array.prototype.slice.call(arr); - if (args.length === 0) return resolve([]); - var remaining = args.length; - - function res(i, val) { - try { - if (val && (typeof val === 'object' || typeof val === 'function')) { - var then = val.then; - if (typeof then === 'function') { - then.call( - val, - function(val) { - res(i, val); - }, - reject - ); - return; - } - } - args[i] = val; - if (--remaining === 0) { - resolve(args); - } - } catch (ex) { - reject(ex); - } - } - - for (var i = 0; i < args.length; i++) { - res(i, args[i]); - } - }); -}; - -Promise.any = __WEBPACK_IMPORTED_MODULE_2__any__["a" /* default */]; - -Promise.allSettled = __WEBPACK_IMPORTED_MODULE_1__allSettled__["a" /* default */]; - -Promise.resolve = function(value) { - if (value && typeof value === 'object' && value.constructor === Promise) { - return value; - } - - return new Promise(function(resolve) { - resolve(value); - }); -}; - -Promise.reject = function(value) { - return new Promise(function(resolve, reject) { - reject(value); - }); -}; - -Promise.race = function(arr) { - return new Promise(function(resolve, reject) { - if (!isArray(arr)) { - return reject(new TypeError('Promise.race accepts an array')); - } - - for (var i = 0, len = arr.length; i < len; i++) { - Promise.resolve(arr[i]).then(resolve, reject); - } - }); -}; - -// Use polyfill for setImmediate for performance gains -Promise._immediateFn = - // @ts-ignore - (typeof setImmediate === 'function' && - function(fn) { - // @ts-ignore - setImmediate(fn); - }) || - function(fn) { - setTimeoutFunc(fn, 0); - }; - -Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { - if (typeof console !== 'undefined' && console) { - console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console - } -}; - -/* harmony default export */ __webpack_exports__["a"] = (Promise); - -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(116).setImmediate)) - -/***/ }), -/* 116 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) || - (typeof self !== "undefined" && self) || - window; -var apply = Function.prototype.apply; - -// DOM APIs, for completeness - -exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout); -}; -exports.setInterval = function() { - return new Timeout(apply.call(setInterval, scope, arguments), clearInterval); -}; -exports.clearTimeout = -exports.clearInterval = function(timeout) { - if (timeout) { - timeout.close(); - } -}; - -function Timeout(id, clearFn) { - this._id = id; - this._clearFn = clearFn; -} -Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -Timeout.prototype.close = function() { - this._clearFn.call(scope, this._id); -}; - -// Does not start the time, just sets up the members needed. -exports.enroll = function(item, msecs) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = msecs; -}; - -exports.unenroll = function(item) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = -1; -}; - -exports._unrefActive = exports.active = function(item) { - clearTimeout(item._idleTimeoutId); - - var msecs = item._idleTimeout; - if (msecs >= 0) { - item._idleTimeoutId = setTimeout(function onTimeout() { - if (item._onTimeout) - item._onTimeout(); - }, msecs); - } -}; - -// setimmediate attaches itself to the global object -__webpack_require__(117); -// On some exotic environments, it's not clear which object `setimmediate` was -// able to install onto. Search each possibility in the same order as the -// `setimmediate` library. -exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) || - (typeof global !== "undefined" && global.setImmediate) || - (this && this.setImmediate); -exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || - (typeof global !== "undefined" && global.clearImmediate) || - (this && this.clearImmediate); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(33))) - -/***/ }), -/* 117 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { - "use strict"; - - if (global.setImmediate) { - return; - } - - var nextHandle = 1; // Spec says greater than zero - var tasksByHandle = {}; - var currentlyRunningATask = false; - var doc = global.document; - var registerImmediate; - - function setImmediate(callback) { - // Callback can either be a function or a string - if (typeof callback !== "function") { - callback = new Function("" + callback); - } - // Copy function arguments - var args = new Array(arguments.length - 1); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i + 1]; - } - // Store and register the task - var task = { callback: callback, args: args }; - tasksByHandle[nextHandle] = task; - registerImmediate(nextHandle); - return nextHandle++; - } - - function clearImmediate(handle) { - delete tasksByHandle[handle]; - } - - function run(task) { - var callback = task.callback; - var args = task.args; - switch (args.length) { - case 0: - callback(); - break; - case 1: - callback(args[0]); - break; - case 2: - callback(args[0], args[1]); - break; - case 3: - callback(args[0], args[1], args[2]); - break; - default: - callback.apply(undefined, args); - break; - } - } - - function runIfPresent(handle) { - // From the spec: "Wait until any invocations of this algorithm started before this one have completed." - // So if we're currently running a task, we'll need to delay this invocation. - if (currentlyRunningATask) { - // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a - // "too much recursion" error. - setTimeout(runIfPresent, 0, handle); - } else { - var task = tasksByHandle[handle]; - if (task) { - currentlyRunningATask = true; - try { - run(task); - } finally { - clearImmediate(handle); - currentlyRunningATask = false; - } - } - } - } - - function installNextTickImplementation() { - registerImmediate = function(handle) { - process.nextTick(function () { runIfPresent(handle); }); - }; - } - - function canUsePostMessage() { - // The test against `importScripts` prevents this implementation from being installed inside a web worker, - // where `global.postMessage` means something completely different and can't be used for this purpose. - if (global.postMessage && !global.importScripts) { - var postMessageIsAsynchronous = true; - var oldOnMessage = global.onmessage; - global.onmessage = function() { - postMessageIsAsynchronous = false; - }; - global.postMessage("", "*"); - global.onmessage = oldOnMessage; - return postMessageIsAsynchronous; - } - } - - function installPostMessageImplementation() { - // Installs an event handler on `global` for the `message` event: see - // * https://developer.mozilla.org/en/DOM/window.postMessage - // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages - - var messagePrefix = "setImmediate$" + Math.random() + "$"; - var onGlobalMessage = function(event) { - if (event.source === global && - typeof event.data === "string" && - event.data.indexOf(messagePrefix) === 0) { - runIfPresent(+event.data.slice(messagePrefix.length)); - } - }; - - if (global.addEventListener) { - global.addEventListener("message", onGlobalMessage, false); - } else { - global.attachEvent("onmessage", onGlobalMessage); - } - - registerImmediate = function(handle) { - global.postMessage(messagePrefix + handle, "*"); - }; - } - - function installMessageChannelImplementation() { - var channel = new MessageChannel(); - channel.port1.onmessage = function(event) { - var handle = event.data; - runIfPresent(handle); - }; - - registerImmediate = function(handle) { - channel.port2.postMessage(handle); - }; - } - - function installReadyStateChangeImplementation() { - var html = doc.documentElement; - registerImmediate = function(handle) { - // Create a