diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 07ffa2acbd592d5617b7f3e21e66c4f10f23acb7..af178c68f23a413c3a3521aa7f389e5572532122 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,6 +18,7 @@ test-ansible:
       - pip3.5 install ansible
       - cd ansible
       - whoami
+      - ansible-galaxy collection install ansible.posix
       - ansible-playbook system.yaml --syntax-check 
       - ansible-playbook deploy.yaml --syntax-check 
 
@@ -98,6 +99,7 @@ deploy-webserver-targetcentric:
     - pip3.5 install ansible
     - cd ansible
     - whoami
+    - ansible-galaxy collection install ansible.posix
     - ansible-playbook -vvv -i ./hosts_master deploy.yaml 
       --extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_targetcentric galaxy_base_url=$GALAXY_BASE_URL_targetcentric galaxy_apikey=$GALAXY_APIKEY_targetcentric galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_targetcentric secret_key=$SECRET_KEY_targetcentric dbname=$DBNAME_targetcentric dbuser=$DBUSER_targetcentric dbpassword=$DBPASSWORD_targetcentric dbhost=$DBHOST_targetcentric dbport=$DBPORT_targetcentric http_port=$HTTP_PORT_targetcentric branch=$CI_COMMIT_REF_NAME gacode=$GACODE_targetcentric ippidb_media=$IPPIDB_MEDIA_targetcentric"
   only:
@@ -121,6 +123,7 @@ deploy-webserver-test:
     - pip3.5 install ansible
     - cd ansible
     - whoami
+    - ansible-galaxy collection install ansible.posix
     - ansible-playbook -vvv -i ./hosts_master deploy.yaml 
       --extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_master galaxy_base_url=$GALAXY_BASE_URL_master galaxy_apikey=$GALAXY_APIKEY_master galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_master secret_key=$SECRET_KEY_master dbname=$DBNAME_master dbuser=$DBUSER_master dbpassword=$DBPASSWORD_master dbhost=$DBHOST_master dbport=$DBPORT_master http_port=$HTTP_PORT_master branch=$CI_COMMIT_REF_NAME gacode=$GACODE_master ippidb_media=$IPPIDB_MEDIA_master"
   only:
@@ -144,6 +147,7 @@ deploy-webserver-production:
     - pip3.5 install ansible
     - cd ansible
     - whoami
+    - ansible-galaxy collection install ansible.posix
     - ansible-playbook -vvv -i ./hosts_release deploy.yaml 
       --extra-vars "deploy_user_name=ippidb repo_api_token=JZS-4cH7bWkFkHa2rAVf marvinjs_apikey=$MARVINJS_APIKEY_release galaxy_base_url=$GALAXY_BASE_URL_release galaxy_apikey=$GALAXY_APIKEY_release galaxy_compoundproperties_workflowid=$GALAXY_COMPOUNDPROPERTIES_WORKFLOWID_release secret_key=$SECRET_KEY_release dbname=$DBNAME_release dbuser=$DBUSER_release dbpassword=$DBPASSWORD_release dbhost=$DBHOST_release dbport=$DBPORT_release http_port=$HTTP_PORT_release branch=$CI_COMMIT_REF_NAME  gacode=$GACODE_release ippidb_media=$IPPIDB_MEDIA_release"
   only:
diff --git a/ansible/deploy.yaml b/ansible/deploy.yaml
index 75355b76d492c29cfc9d7d4e2a2725cce6676603..e7d5a59ad699c367f49765075af95906965c8f0e 100644
--- a/ansible/deploy.yaml
+++ b/ansible/deploy.yaml
@@ -7,7 +7,7 @@
   gather_facts: yes
   tasks:
     - name: Disable SELinux
-      selinux:
+      ansible.posix.selinux:
         state: disabled
     - name: Create celery user
       user: name=celery-{{ http_port }} groups={{ deploy_user_name }} append=yes state=present createhome=yes 
@@ -350,14 +350,14 @@
     - name: Enable firewalld
       service: name=firewalld state=started enabled=yes
     - name: open http firewall service
-      firewalld:
+      ansible.posix.firewalld:
         service: http
         zone: public
         immediate: yes
         permanent: true
         state: enabled
     - name: open http firewall port
-      firewalld:
+      ansible.posix.firewalld:
         port: "{{ http_port }}/tcp"
         zone: public
         permanent: true
diff --git a/ansible/system.yaml b/ansible/system.yaml
index 55381566073c4641e71d3b40bef65bbaece0e258..079f1278a2fccbf47eb3d4c12438d2e1b56bbe9b 100644
--- a/ansible/system.yaml
+++ b/ansible/system.yaml
@@ -42,16 +42,16 @@
     # disable SELinux, and open firewall to incoming http 
     - name: disable SELinux
       become: true
-      selinux:
+      ansible.posix.selinux:
         state: disabled
     - name: Open firewall to HTTP traffic
-      firewalld:
+      ansible.posix.firewalld:
         service: http
         permanent: true
         state: enabled
       become: true
     - name: Open firwall to port 80 81 traffic
-      firewalld:
+      ansible.posix.firewalld:
         port: "{{ http_port }}/tcp"
         permanent: true
         state: enabled
diff --git a/ippisite/ippidb/management/commands/update_mrc_files.py b/ippisite/ippidb/management/commands/update_mrc_files.py
index ec853aec7d9cbc437970025c5924abfe77904ba0..be8c4b759b60585642ce457f994dfd72ef68865c 100644
--- a/ippisite/ippidb/management/commands/update_mrc_files.py
+++ b/ippisite/ippidb/management/commands/update_mrc_files.py
@@ -18,6 +18,17 @@ def dir_path(string):
         raise NotADirectoryError(string)
 
 
+def isolevel_float(arg):
+    """ Type function for argparse - a float within some predefined bounds """
+    try:
+        f = float(arg)
+    except ValueError:
+        raise CommandError("Must be a floating point number")
+    if f < 0 or f > 1.0:
+        raise CommandError("Argument must be < 1.0 and > 0")
+    return f
+
+
 class Command(AppCommand):
     """
     Command to update mrc files
@@ -26,7 +37,12 @@ class Command(AppCommand):
     help = "liste all mrc files in a directory and update files in the database"
 
     def __init__(
-        self, stdout=None, stderr=None, no_color=False, force_color=False, task=None,
+        self,
+        stdout=None,
+        stderr=None,
+        no_color=False,
+        force_color=False,
+        task=None,
     ):
         super(Command, self).__init__(
             stdout=stdout, stderr=stderr, no_color=no_color, force_color=force_color
@@ -38,7 +54,10 @@ class Command(AppCommand):
 
     def add_arguments(self, parser):
         parser.add_argument(
-            "-mp", "--mrcpath", type=dir_path, help="root directory with all mrc files",
+            "-mp",
+            "--mrcpath",
+            type=dir_path,
+            help="root directory with all mrc files",
         )
         parser.add_argument(
             "-pa",
@@ -61,6 +80,14 @@ class Command(AppCommand):
             dest="label",
             help="label for files, used as label in the interface",
         )
+        parser.add_argument(
+            "-di",
+            "--default_isolevel",
+            dest="default_isolevel",
+            help="isolevel default value",
+            default=0.7,
+            type=isolevel_float,
+        )
 
     def handle(self, *args, **options):
         """
@@ -75,7 +102,9 @@ class Command(AppCommand):
         if typefile == "druggability":
             storage_path = Chain.mrc_file.field.storage.path("content/mrc_files")
         else:
-            storage_path = InteractFile.interact_file.field.storage.path("content/interact_files")
+            storage_path = InteractFile.interact_file.field.storage.path(
+                "content/interact_files"
+            )
         if not os.path.exists(storage_path):
             os.makedirs(storage_path)
         list_files = glob.glob(os.path.join(mrcpath, pattern))
@@ -108,13 +137,18 @@ class Command(AppCommand):
                     with open(data, "rb") as f:
                         dbchains[0].mrc_file.delete()
                         dbchains[0].mrc_file.save(os.path.basename(data), File(f))
+                        dbchains[0].default_isolevel = options["default_isolevel"]
+                        dbchains[0].save()
                 else:
                     interactfile, created = InteractFile.objects.get_or_create(
-                        chain=dbchains[0], label=label
+                        chain=dbchains[0],
+                        label=label,
                     )
                     with open(data, "rb") as f:
                         interactfile.interact_file.delete()
                         interactfile.interact_file.save(os.path.basename(data), File(f))
+                    interactfile.default_isolevel = options["default_isolevel"]
+                    interactfile.save()
                 self.stdout.write(
                     self.style.SUCCESS(
                         "File mrc {}, have been saved in Chain, pdb: {}, chain: {}".format(
@@ -126,7 +160,8 @@ class Command(AppCommand):
                 self.stdout.write(
                     self.style.WARNING(
                         "WARNING: Chain, pdb: {}, chain: {} doesn't exist".format(
-                            pdb, chain,
+                            pdb,
+                            chain,
                         )
                     )
                 )
diff --git a/ippisite/ippidb/migrations/0068_auto_20210310_1052.py b/ippisite/ippidb/migrations/0068_auto_20210310_1052.py
new file mode 100644
index 0000000000000000000000000000000000000000..f4870c5618cb8f444fb6edb6dc9349fc5a3f5204
--- /dev/null
+++ b/ippisite/ippidb/migrations/0068_auto_20210310_1052.py
@@ -0,0 +1,39 @@
+# Generated by Django 2.2.1 on 2021-03-10 10:52
+
+from django.db import migrations, models
+
+
+def init_isolevel(apps, schema_editor):
+    Chain = apps.get_model("ippidb", "Chain")
+    InteractFile = apps.get_model("ippidb", "InteractFile")
+    Chain.objects.all().update(default_isolevel=0.5)
+
+    InteractFile.objects.filter(label="all").update(default_isolevel=0.7)
+    InteractFile.objects.filter(label="hydrophobic").update(default_isolevel=0.3)
+    InteractFile.objects.filter(label="hbond donor-acceptor").update(
+        default_isolevel=0.3
+    )
+    InteractFile.objects.filter(label="negative").update(default_isolevel=0.08)
+    InteractFile.objects.filter(label="positive").update(default_isolevel=0.05)
+    InteractFile.objects.filter(label="backbone").update(default_isolevel=0.18)
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("ippidb", "0067_metainformation_normalize_factor"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="chain",
+            name="default_isolevel",
+            field=models.FloatField(default=0.7, verbose_name="Default isolevel value"),
+        ),
+        migrations.AddField(
+            model_name="interactfile",
+            name="default_isolevel",
+            field=models.FloatField(default=0.7, verbose_name="Default isolevel value"),
+        ),
+        migrations.RunPython(init_isolevel, reverse_code=migrations.RunPython.noop),
+    ]
diff --git a/ippisite/ippidb/models/targetcentric.py b/ippisite/ippidb/models/targetcentric.py
index aaefeb9b68465b836ca10714595f6126c498d7af..37d9366bdeb6cfe6ba335b2f1777140355629cb0 100644
--- a/ippisite/ippidb/models/targetcentric.py
+++ b/ippisite/ippidb/models/targetcentric.py
@@ -132,9 +132,13 @@ class Chain(models.Model):
         verbose_name="pdb file content with only one chain", default="no pdb file"
     )
     mrc_file = models.FileField(upload_to=content, blank=True)
+    default_isolevel = models.FloatField(
+        default=0.7, verbose_name="Default isolevel value"
+    )
 
     class Meta:
         unique_together = ("pdb", "pdb_chain_id")
+        ordering = ["pdb", "pdb_chain_id"]
 
     def is_partner(self):
         return self.partner_set.count()
@@ -156,6 +160,9 @@ class InteractFile(models.Model):
     chain = models.ForeignKey(Chain, on_delete=models.CASCADE)
     label = models.CharField(max_length=250, blank=False, null=False)
     interact_file = models.FileField(upload_to=contentinteract, blank=True)
+    default_isolevel = models.FloatField(
+        default=0.7, verbose_name="Default isolevel value"
+    )
 
     def __unicode__(self):
         return "{}".format(self.interact_file)
@@ -356,6 +363,7 @@ class Cavity(models.Model):
     class Meta:
         unique_together = ("full_name", "chain", "cavity_number", "partner")
         verbose_name_plural = "Cavities"
+        ordering = ["chain", "cavity_number"]
 
     @property
     def near_cavities(self):
@@ -415,22 +423,35 @@ class MetaInformation(models.Model):
     """
 
     average = models.DecimalField(
-        verbose_name="Average", max_digits=11, decimal_places=8
+        verbose_name="Average",
+        max_digits=11,
+        decimal_places=8,
+        help_text="partial matrix mean value",
     )
     std = models.DecimalField(
-        verbose_name="Standard Deviation", max_digits=11, decimal_places=8
+        verbose_name="Standard Deviation",
+        max_digits=11,
+        decimal_places=8,
+        help_text="partial matrix standard deviation",
     )
     maximum = models.DecimalField(
-        verbose_name="Maximum", max_digits=11, decimal_places=8
+        verbose_name="Maximum",
+        max_digits=11,
+        decimal_places=8,
+        help_text="partial matrix maximum value",
     )
     minimum = models.DecimalField(
-        verbose_name="Minimum", max_digits=11, decimal_places=8
+        verbose_name="Minimum",
+        max_digits=11,
+        decimal_places=8,
+        help_text="partial matrix minimum value",
     )
     normalize_factor = models.DecimalField(
         blank=True,
         null=True,
         default=4.58599730,
         verbose_name="Normalize Factor",
+        help_text="complet matrix standard deviation",
         max_digits=11,
         decimal_places=8,
     )
diff --git a/ippisite/ippidb/serializer.py b/ippisite/ippidb/serializer.py
index 62ff01b92ec08fc93c449f304ccbce384c121721..e81cd57c40cc324205f00c7fc5940f1b5458da2e 100644
--- a/ippisite/ippidb/serializer.py
+++ b/ippisite/ippidb/serializer.py
@@ -57,7 +57,7 @@ class ChainDistanceSerializer(serializers.ModelSerializer):
 
     class Meta:
         model = Chain
-        fields = ("id", "pdb_chain_id", "protein", "pdb")
+        fields = ("id", "pdb_chain_id", "protein", "pdb", "default_isolevel")
 
 
 class PartnerDistanceSerializer(serializers.ModelSerializer):
@@ -121,6 +121,7 @@ class ChainSerializer(serializers.ModelSerializer):
             "cavity_set",
             "partner_set",
             "mrc_file",
+            "default_isolevel",
             "interactfile_set",
         )
 
diff --git a/ippisite/ippidb/static/css/main.css b/ippisite/ippidb/static/css/main.css
index d7fdcbb8e7be243efef16d633e3f05d120465656..874b916252ef500a5d33de14f06e022d1b869457 100644
--- a/ippisite/ippidb/static/css/main.css
+++ b/ippisite/ippidb/static/css/main.css
@@ -356,10 +356,47 @@ div.hidden {
 
 /* -- Home page choices -- */
 
-.background_choices {
-    margin: 40px;
+.compound_choices {
     position: relative;
-    background: #e3e9eb url(/static/images/Other/cross.png) 50px 100px no-repeat;
+    background: #E3E9EB url(/static/images/Other/cross.png) 50px 100px no-repeat;
+    text-align: center;
+    height: fit-content;
+    box-shadow:  0 3px 11px 0 rgb(0 0 0 / 20%);
+}
+
+.compound_background {
+    position: relative;
+    background: #E3E9EB url(/static/images/Other/cross.png) 50px 100px no-repeat;
+    text-align: center;
+    height: fit-content;
+}
+
+.compound_choices:hover{
+    background: #D1DBDE url(/static/images/Other/cross.png) 50px 100px no-repeat;
+}
+
+.pocket_choices {
+    position: relative;
+    background: #AABDC3 url(/static/images/Other/cross.png) 50px 100px no-repeat;
+    text-align: center;
+    height: fit-content;
+    box-shadow:  0 3px 11px 0 rgb(0 0 0 / 20%);
+}
+
+.pocket_choices:hover {
+    background: #97ADB5 url(/static/images/Other/cross.png) 50px 100px no-repeat;
+}
+
+.pocket_background {
+    position: relative;
+    background: #AABDC3 url(/static/images/Other/cross.png) 50px 100px no-repeat;
+    text-align: center;
+    height: fit-content;
+}
+
+.icons {
+    padding: 10%;
+    font-size: 1.5em;
 }
 
 .choices_background {
@@ -448,6 +485,15 @@ div.hidden {
     display:block;
   }
 
+  .front-vertical-align {
+      padding-top: 80px;
+  }
+
+  .back-vertical-align {
+      padding-top: 25px;
+  }
+
+
 /* -- Breadcrumb -- */
 
 .breadNav {
@@ -1220,4 +1266,48 @@ div.hidden {
 
 .btn.float-right+.btn.float-right {
     margin-right: 5px
-}
\ No newline at end of file
+}
+
+/* Modal */
+
+.modal-xl {
+    width:  100%;
+    max-width:1200px;
+    height: fit-content;
+    max-height: 1200px;
+}
+
+.close_choices_modal {
+    margin: 0px !important;
+    right: 32px !important;
+    top: 32px !important;
+    width: 32px !important;
+    height: 32px !important;
+    opacity: 0.5;
+    border: none !important;
+    color: #495057 !important;
+    cursor: pointer;
+    float: right;
+    text-align: right;
+    font-size: 2em;
+    background-color: white !important;
+}
+
+.close_choices_modal:hover {
+    opacity: 1;
+}
+
+.align_modal {
+    display: inline-block;
+}
+
+.modal_choices_title {
+    float: left;
+    text-align: right;
+    font-family: "PlayfairDisplayReg";
+    font-size: 2em;
+}
+
+.fade_index {
+    transition: opacity 1s linear;
+  }
\ No newline at end of file
diff --git a/ippisite/ippidb/static/css/targetcentric.css b/ippisite/ippidb/static/css/targetcentric.css
index 0c0cf389f6bef19b043fa1afc32f249d7c9431f5..83ee1214d5166b132603fcfa6ad1338848f63d11 100644
--- a/ippisite/ippidb/static/css/targetcentric.css
+++ b/ippisite/ippidb/static/css/targetcentric.css
@@ -134,7 +134,18 @@ Description: IPPI-DB targetcentric Theme
 
 .dropbtn {
   font-size: 14px;
-  color: #007bff
+  color: #2D96FA;
+  border-radius: 5px;
+  border-color: #97ADB5;
+  background-color: #eff3f5;
+  padding-right: 3px;
+  padding-left: 3px;
+  padding-bottom: 1px;
+  padding-top: 1px;
+  border-style: solid;
+  border-width: 2px;
+  min-width: 25px;
+  text-align: center;
 }
 
 .dropdown {
@@ -145,12 +156,16 @@ Description: IPPI-DB targetcentric Theme
 .dropdown-content {
   display: none;
   position: absolute;
-  bottom: 24px; 
-  left: 14px;
-  background-color: #f1f1f1;
+  bottom: 22px; 
+  left: 12px;
+  background-color: #eff3f5;
   min-width: 100px;
-  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
+  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4);
   z-index: 3;
+  border-radius: 5px;
+  border-color: #97adb5 !important;
+  border: 2px;
+  border-style: solid;
 }
 
 .dropdown-content a {
@@ -161,25 +176,28 @@ Description: IPPI-DB targetcentric Theme
   display: block;
 }
 
-.dropdown-content a:hover {background-color: #ddd;}
+.dropdown-content a:hover {
+  background-color: #d3dee2; 
+  color: black;
+  border-radius: 5px;
+}
 
 .dropdown:hover .dropdown-content {display: block;}
 
-.dropdown:hover .dropbtn {background-color: #ddd;}
-
-a.infobulle{
-  color:#ccc;               
+.dropdown:hover .dropbtn {
+  background-color: #d3dee2; 
+  color: black;
 }
 
-a.infobulle:hover, a.infobulle:focus{
-  color:#17a2b8;
+
+.infobulle svg{
+  color: rgb(45, 150, 250);
 }
 
-a.infobulle span{
+.infobulle span{
   position:absolute;
-  color:white;                
-  margin-top:23px;
-  margin-left:0px;
+  color:white;
+  bottom: 100%;
   background:rgba(0,0,0,.9);
   padding:15px;
   border-radius:3px;
@@ -190,7 +208,7 @@ a.infobulle span{
   z-index: 3;
 }
 
-a.infobulle:hover span, a.infobulle:focus span{
+.infobulle:hover span, .infobulle:focus span{
   transform:scale(1) rotate(0);
   opacity:1;
 }
@@ -206,4 +224,13 @@ table.gradiant td{
   border-right: none;
   white-space: nowrap;
   text-align: left;
+}
+
+.fa-plus-square {
+  box-shadow: 0 0 2px rgba(0,0,0,.5);
+}
+
+th .fa-plus-square:hover {
+  background-color: black;
+  color: rgb(255, 255, 255);
 }
\ No newline at end of file
diff --git a/ippisite/ippidb/static/js/ippidb.js b/ippisite/ippidb/static/js/ippidb.js
index a8d3a4050bfc7231f04aacc9541fb56eda13f253..92952f7faadf3247cb36f6ef747b84edf0023059 100644
--- a/ippisite/ippidb/static/js/ippidb.js
+++ b/ippisite/ippidb/static/js/ippidb.js
@@ -277,4 +277,11 @@ var toggleCheckBox = function (id) {
     } else {
         queryUrl.changeSelection(id, null);
     }
-}
\ No newline at end of file
+}
+
+$(document).ready(function () {
+    $(".modalhref").click(function(e){
+        $(".modal").modal('hide');
+        window.open($(this).find("a").last()[0].href, '_self');
+    });
+});
\ No newline at end of file
diff --git a/ippisite/ippidb/static/js/ngl.js b/ippisite/ippidb/static/js/ngl.js
index d79a089d94104f57201397dd49cb416f75c66ef7..c7bce1822351021a47dc3144901a7c0915905eb0 100644
--- a/ippisite/ippidb/static/js/ngl.js
+++ b/ippisite/ippidb/static/js/ngl.js
@@ -1 +1 @@
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.NGL=t.NGL||{})}(this,function(t){"use strict";function e(){}function i(t,e){return function(){t.apply(e,arguments)}}function r(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(t,this)}function n(t,e){for(;3===t._state;)t=t._value;if(0===t._state)return void t._deferreds.push(e);t._handled=!0,mu(function(){var i=1===t._state?e.onFulfilled:e.onRejected;if(null===i)return void(1===t._state?o:a)(e.promise,t._value);var r;try{r=i(t._value)}catch(t){return void a(e.promise,t)}o(e.promise,r)})}function o(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof r)return t._state=3,t._value=e,void s(t);if("function"==typeof n)return void u(i(n,e),t)}t._state=1,t._value=e,s(t)}catch(e){a(t,e)}}function a(t,e){t._state=2,t._value=e,s(t)}function s(t){2===t._state&&0===t._deferreds.length&&mu(function(){t._handled||gu(t._value)});for(var e=0,i=t._deferreds.length;e<i;e++)n(t,t._deferreds[e]);t._deferreds=null}function c(t,e,i){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=i}function u(t,e){var i=!1;try{t(function(t){i||(i=!0,o(e,t))},function(t){i||(i=!0,a(e,t))})}catch(t){if(i)return;i=!0,a(e,t)}}function h(){}function l(t,e){this.x=t||0,this.y=e||0}function p(t,e,i,r,n,o,a,s,c,u){Object.defineProperty(this,"id",{value:_l++}),this.uuid=xl.generateUUID(),this.name="",this.image=void 0!==t?t:p.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:p.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:Ah,this.wrapT=void 0!==r?r:Ah,this.magFilter=void 0!==n?n:Ch,this.minFilter=void 0!==o?o:Rh,this.anisotropy=void 0!==c?c:1,this.format=void 0!==a?a:Wh,this.type=void 0!==s?s:Lh,this.offset=new l(0,0),this.repeat=new l(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:ll,this.version=0,this.onUpdate=null}function d(t,e,i,r){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==r?r:1}function f(t,e,i){this.uuid=xl.generateUUID(),this.width=t,this.height=e,this.scissor=new d(0,0,t,e),this.scissorTest=!1,this.viewport=new d(0,0,t,e),void 0===(i=i||{}).minFilter&&(i.minFilter=Ch),this.texture=new p(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function m(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==r?r:1}function g(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}function v(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function y(t,e,i,r,n,o,a,s,c,u,h,l){p.call(this,null,o,a,s,c,u,r,n,h,l),this.image={data:t,width:e,height:i},this.magFilter=void 0!==c?c:Ph,this.minFilter=void 0!==u?u:Ph,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function b(t,e,i,r,n,o,a,s,c,u){t=void 0!==t?t:[],e=void 0!==e?e:gh,p.call(this,t,e,i,r,n,o,a,s,c,u),this.flipY=!1}function x(){this.seq=[],this.map={}}function _(t,e,i){var r=t[0];if(r<=0||r>0)return t;var n=e*i,o=Al[n];if(void 0===o&&(o=new Float32Array(n),Al[n]=o),0!==e){r.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=i,t[a].toArray(o,s)}return o}function w(t,e){var i=Ml[e];void 0===i&&(i=new Int32Array(e),Ml[e]=i);for(var r=0;r!==e;++r)i[r]=t.allocTextureUnit();return i}function S(t,e){t.uniform1f(this.addr,e)}function A(t,e){t.uniform1i(this.addr,e)}function M(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function P(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function T(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function E(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function C(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Tl.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Tl))}function I(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Pl.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Pl))}function R(t,e,i){var r=i.allocTextureUnit();t.uniform1i(this.addr,r),i.setTexture2D(e||wl,r)}function L(t,e,i){var r=i.allocTextureUnit();t.uniform1i(this.addr,r),i.setTextureCube(e||Sl,r)}function O(t,e){t.uniform2iv(this.addr,e)}function D(t,e){t.uniform3iv(this.addr,e)}function N(t,e){t.uniform4iv(this.addr,e)}function k(t){switch(t){case 5126:return S;case 35664:return M;case 35665:return P;case 35666:return T;case 35674:return E;case 35675:return C;case 35676:return I;case 35678:case 36198:return R;case 35680:return L;case 5124:case 35670:return A;case 35667:case 35671:return O;case 35668:case 35672:return D;case 35669:case 35673:return N}}function F(t,e){t.uniform1fv(this.addr,e)}function B(t,e){t.uniform1iv(this.addr,e)}function z(t,e){t.uniform2fv(this.addr,_(e,this.size,2))}function U(t,e){t.uniform3fv(this.addr,_(e,this.size,3))}function j(t,e){t.uniform4fv(this.addr,_(e,this.size,4))}function G(t,e){t.uniformMatrix2fv(this.addr,!1,_(e,this.size,4))}function V(t,e){t.uniformMatrix3fv(this.addr,!1,_(e,this.size,9))}function $(t,e){t.uniformMatrix4fv(this.addr,!1,_(e,this.size,16))}function H(t,e,i){var r=e.length,n=w(i,r);t.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTexture2D(e[o]||wl,n[o])}function W(t,e,i){var r=e.length,n=w(i,r);t.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTextureCube(e[o]||Sl,n[o])}function X(t){switch(t){case 5126:return F;case 35664:return z;case 35665:return U;case 35666:return j;case 35674:return G;case 35675:return V;case 35676:return $;case 35678:return H;case 35680:return W;case 5124:case 35670:return B;case 35667:case 35671:return O;case 35668:case 35672:return D;case 35669:case 35673:return N}}function q(t,e,i){this.id=t,this.addr=i,this.setValue=k(e.type)}function Y(t,e,i){this.id=t,this.addr=i,this.size=e.size,this.setValue=X(e.type)}function Z(t){this.id=t,x.call(this)}function K(t,e){t.seq.push(e),t.map[e.id]=e}function Q(t,e,i){var r=t.name,n=r.length;for(El.lastIndex=0;;){var o=El.exec(r),a=El.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===n){K(i,void 0===u?new q(s,t,e):new Y(s,t,e));break}var h=i.map[s];void 0===h&&K(i,h=new Z(s)),i=h}}function J(t,e,i){var r=this;x.call(this),this.renderer=i;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),o=0;o<n;++o){var a=t.getActiveUniform(e,o),s=a.name;Q(a,t.getUniformLocation(e,s),r)}}function tt(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}function et(t,e){this.min=void 0!==t?t:new l(1/0,1/0),this.max=void 0!==e?e:new l(-1/0,-1/0)}function it(t,e){function i(){var t=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),e=new Uint16Array([0,1,2,0,2,3]);n=d.createBuffer(),o=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,n),d.bufferData(d.ARRAY_BUFFER,t,d.STATIC_DRAW),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o),d.bufferData(d.ELEMENT_ARRAY_BUFFER,e,d.STATIC_DRAW),h=d.createTexture(),p=d.createTexture(),f.bindTexture(d.TEXTURE_2D,h),d.texImage2D(d.TEXTURE_2D,0,d.RGB,16,16,0,d.RGB,d.UNSIGNED_BYTE,null),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST),f.bindTexture(d.TEXTURE_2D,p),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,16,16,0,d.RGBA,d.UNSIGNED_BYTE,null),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST),a={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility =        visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *=       visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},s=r(a),c={vertex:d.getAttribLocation(s,"position"),uv:d.getAttribLocation(s,"uv")},u={renderType:d.getUniformLocation(s,"renderType"),map:d.getUniformLocation(s,"map"),occlusionMap:d.getUniformLocation(s,"occlusionMap"),opacity:d.getUniformLocation(s,"opacity"),color:d.getUniformLocation(s,"color"),scale:d.getUniformLocation(s,"scale"),rotation:d.getUniformLocation(s,"rotation"),screenPosition:d.getUniformLocation(s,"screenPosition")}}function r(e){var i=d.createProgram(),r=d.createShader(d.FRAGMENT_SHADER),n=d.createShader(d.VERTEX_SHADER),o="precision "+t.getPrecision()+" float;\n";return d.shaderSource(r,o+e.fragmentShader),d.shaderSource(n,o+e.vertexShader),d.compileShader(r),d.compileShader(n),d.attachShader(i,r),d.attachShader(i,n),d.linkProgram(i),i}var n,o,a,s,c,u,h,p,d=t.context,f=t.state;this.render=function(r,a,m){if(0!==e.length){var v=new g,y=m.w/m.z,b=.5*m.z,x=.5*m.w,_=16/m.w,w=new l(_*y,_),S=new g(1,1,0),A=new l(1,1),M=new et;M.min.set(m.x,m.y),M.max.set(m.x+(m.z-16),m.y+(m.w-16)),void 0===s&&i(),d.useProgram(s),f.initAttributes(),f.enableAttribute(c.vertex),f.enableAttribute(c.uv),f.disableUnusedAttributes(),d.uniform1i(u.occlusionMap,0),d.uniform1i(u.map,1),d.bindBuffer(d.ARRAY_BUFFER,n),d.vertexAttribPointer(c.vertex,2,d.FLOAT,!1,16,0),d.vertexAttribPointer(c.uv,2,d.FLOAT,!1,16,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o),f.disable(d.CULL_FACE),f.buffers.depth.setMask(!1);for(var P=0,T=e.length;P<T;P++){_=16/m.w,w.set(_*y,_);var E=e[P];if(v.set(E.matrixWorld.elements[12],E.matrixWorld.elements[13],E.matrixWorld.elements[14]),v.applyMatrix4(a.matrixWorldInverse),v.applyMatrix4(a.projectionMatrix),S.copy(v),A.x=m.x+S.x*b+b-8,A.y=m.y+S.y*x+x-8,!0===M.containsPoint(A)){f.activeTexture(d.TEXTURE0),f.bindTexture(d.TEXTURE_2D,null),f.activeTexture(d.TEXTURE1),f.bindTexture(d.TEXTURE_2D,h),d.copyTexImage2D(d.TEXTURE_2D,0,d.RGB,A.x,A.y,16,16,0),d.uniform1i(u.renderType,0),d.uniform2f(u.scale,w.x,w.y),d.uniform3f(u.screenPosition,S.x,S.y,S.z),f.disable(d.BLEND),f.enable(d.DEPTH_TEST),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0),f.activeTexture(d.TEXTURE0),f.bindTexture(d.TEXTURE_2D,p),d.copyTexImage2D(d.TEXTURE_2D,0,d.RGBA,A.x,A.y,16,16,0),d.uniform1i(u.renderType,1),f.disable(d.DEPTH_TEST),f.activeTexture(d.TEXTURE1),f.bindTexture(d.TEXTURE_2D,h),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0),E.positionScreen.copy(S),E.customUpdateCallback?E.customUpdateCallback(E):E.updateLensFlares(),d.uniform1i(u.renderType,2),f.enable(d.BLEND);for(var C=0,I=E.lensFlares.length;C<I;C++){var R=E.lensFlares[C];R.opacity>.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,_=R.size*R.scale/m.w,w.x=_*y,w.y=_,d.uniform3f(u.screenPosition,S.x,S.y,S.z),d.uniform2f(u.scale,w.x,w.y),d.uniform1f(u.rotation,R.rotation),d.uniform1f(u.opacity,R.opacity),d.uniform3f(u.color,R.color.r,R.color.g,R.color.b),f.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),t.setTexture2D(R.texture,1),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0))}}}f.enable(d.CULL_FACE),f.enable(d.DEPTH_TEST),f.buffers.depth.setMask(!0),t.resetGLState()}}}function rt(t,e){function i(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),e=new Uint16Array([0,1,2,0,2,3]);o=l.createBuffer(),a=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,o),l.bufferData(l.ARRAY_BUFFER,t,l.STATIC_DRAW),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,a),l.bufferData(l.ELEMENT_ARRAY_BUFFER,e,l.STATIC_DRAW),s=r(),c={position:l.getAttribLocation(s,"position"),uv:l.getAttribLocation(s,"uv")},u={uvOffset:l.getUniformLocation(s,"uvOffset"),uvScale:l.getUniformLocation(s,"uvScale"),rotation:l.getUniformLocation(s,"rotation"),scale:l.getUniformLocation(s,"scale"),color:l.getUniformLocation(s,"color"),map:l.getUniformLocation(s,"map"),opacity:l.getUniformLocation(s,"opacity"),modelViewMatrix:l.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:l.getUniformLocation(s,"projectionMatrix"),fogType:l.getUniformLocation(s,"fogType"),fogDensity:l.getUniformLocation(s,"fogDensity"),fogNear:l.getUniformLocation(s,"fogNear"),fogFar:l.getUniformLocation(s,"fogFar"),fogColor:l.getUniformLocation(s,"fogColor"),alphaTest:l.getUniformLocation(s,"alphaTest")};var i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var n=i.getContext("2d");n.fillStyle="white",n.fillRect(0,0,8,8),(h=new p(i)).needsUpdate=!0}function r(){var e=l.createProgram(),i=l.createShader(l.VERTEX_SHADER),r=l.createShader(l.FRAGMENT_SHADER);return l.shaderSource(i,["precision "+t.getPrecision()+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),l.shaderSource(r,["precision "+t.getPrecision()+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),l.compileShader(i),l.compileShader(r),l.attachShader(e,i),l.attachShader(e,r),l.linkProgram(e),e}function n(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var o,a,s,c,u,h,l=t.context,d=t.state,f=new g,v=new m,y=new g;this.render=function(r,p){if(0!==e.length){void 0===s&&i(),l.useProgram(s),d.initAttributes(),d.enableAttribute(c.position),d.enableAttribute(c.uv),d.disableUnusedAttributes(),d.disable(l.CULL_FACE),d.enable(l.BLEND),l.bindBuffer(l.ARRAY_BUFFER,o),l.vertexAttribPointer(c.position,2,l.FLOAT,!1,16,0),l.vertexAttribPointer(c.uv,2,l.FLOAT,!1,16,8),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,a),l.uniformMatrix4fv(u.projectionMatrix,!1,p.projectionMatrix.elements),d.activeTexture(l.TEXTURE0),l.uniform1i(u.map,0);var m=0,g=0,b=r.fog;b?(l.uniform3f(u.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(l.uniform1f(u.fogNear,b.near),l.uniform1f(u.fogFar,b.far),l.uniform1i(u.fogType,1),m=1,g=1):b.isFogExp2&&(l.uniform1f(u.fogDensity,b.density),l.uniform1i(u.fogType,2),m=2,g=2)):(l.uniform1i(u.fogType,0),m=0,g=0);for(var x=0,_=e.length;x<_;x++)(S=e[x]).modelViewMatrix.multiplyMatrices(p.matrixWorldInverse,S.matrixWorld),S.z=-S.modelViewMatrix.elements[14];e.sort(n);for(var w=[],x=0,_=e.length;x<_;x++){var S=e[x],A=S.material;if(!1!==A.visible){S.onBeforeRender(t,r,p,void 0,A,void 0),l.uniform1f(u.alphaTest,A.alphaTest),l.uniformMatrix4fv(u.modelViewMatrix,!1,S.modelViewMatrix.elements),S.matrixWorld.decompose(f,v,y),w[0]=y.x,w[1]=y.y;var M=0;r.fog&&A.fog&&(M=g),m!==M&&(l.uniform1i(u.fogType,M),m=M),null!==A.map?(l.uniform2f(u.uvOffset,A.map.offset.x,A.map.offset.y),l.uniform2f(u.uvScale,A.map.repeat.x,A.map.repeat.y)):(l.uniform2f(u.uvOffset,0,0),l.uniform2f(u.uvScale,1,1)),l.uniform1f(u.opacity,A.opacity),l.uniform3f(u.color,A.color.r,A.color.g,A.color.b),l.uniform1f(u.rotation,A.rotation),l.uniform2fv(u.scale,w),d.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst,A.blendEquationAlpha,A.blendSrcAlpha,A.blendDstAlpha,A.premultipliedAlpha),d.buffers.depth.setTest(A.depthTest),d.buffers.depth.setMask(A.depthWrite),A.map?t.setTexture2D(A.map,0):t.setTexture2D(h,0),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0),S.onAfterRender(t,r,p,void 0,A,void 0)}}d.enable(l.CULL_FACE),t.resetGLState()}}}function nt(){Object.defineProperty(this,"id",{value:Dl++}),this.uuid=xl.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Ou,this.side=Au,this.shading=Eu,this.vertexColors=Cu,this.opacity=1,this.transparent=!1,this.blendSrc=Xu,this.blendDst=qu,this.blendEquation=Bu,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=rh,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.needsUpdate=!0}function ot(t){nt.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function at(t){nt.call(this),this.type="MeshDepthMaterial",this.depthPacking=yl,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function st(t,e){this.min=void 0!==t?t:new g(1/0,1/0,1/0),this.max=void 0!==e?e:new g(-1/0,-1/0,-1/0)}function ct(t,e){this.center=void 0!==t?t:new g,this.radius=void 0!==e?e:0}function ut(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function ht(t,e){this.normal=void 0!==t?t:new g(1,0,0),this.constant=void 0!==e?e:0}function lt(t,e,i,r,n,o){this.planes=[void 0!==t?t:new ht,void 0!==e?e:new ht,void 0!==i?i:new ht,void 0!==r?r:new ht,void 0!==n?n:new ht,void 0!==o?o:new ht]}function pt(t,e,i,r){function n(e,i,r,n){var o=e.geometry,a=null,s=S,c=e.customDepthMaterial;if(r&&(s=A,c=e.customDistanceMaterial),c)a=c;else{var u=!1;i.morphTargets&&(o&&o.isBufferGeometry?u=o.morphAttributes&&o.morphAttributes.position&&o.morphAttributes.position.length>0:o&&o.isGeometry&&(u=o.morphTargets&&o.morphTargets.length>0)),e.isSkinnedMesh&&!1===i.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var h=e.isSkinnedMesh&&i.skinning,l=0;u&&(l|=x),h&&(l|=_),a=s[l]}if(t.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var p=a.uuid,d=i.uuid,f=M[p];void 0===f&&(f={},M[p]=f);var m=f[d];void 0===m&&(m=a.clone(),f[d]=m),a=m}a.visible=i.visible,a.wireframe=i.wireframe;var g=i.side;return F.renderSingleSided&&g==Pu&&(g=Au),F.renderReverseSided&&(g===Au?g=Mu:g===Mu&&(g=Au)),a.side=g,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,r&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(n),a}function o(e,r,a,s){if(!1!==e.visible){if(e.layers.test(r.layers)&&(e.isMesh||e.isLine||e.isPoints)&&e.castShadow&&(!e.frustumCulled||c.intersectsObject(e))){e.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,e.matrixWorld);var u=i.update(e),h=e.material;if(Array.isArray(h))for(var l=u.groups,p=0,d=l.length;p<d;p++){var f=l[p],m=h[f.materialIndex];if(m&&m.visible){g=n(e,m,s,b);t.renderBufferDirect(a,null,u,g,e,f)}}else if(h.visible){var g=n(e,h,s,b);t.renderBufferDirect(a,null,u,g,e,null)}}for(var v=e.children,y=0,x=v.length;y<x;y++)o(v[y],r,a,s)}}var a=t.context,s=t.state,c=new lt,u=new v,h=e.shadows,p=new l,m=new l(r.maxTextureSize,r.maxTextureSize),y=new g,b=new g,x=1,_=2,w=1+(x|_),S=new Array(w),A=new Array(w),M={},P=[new g(1,0,0),new g(-1,0,0),new g(0,0,1),new g(0,0,-1),new g(0,1,0),new g(0,-1,0)],T=[new g(0,1,0),new g(0,1,0),new g(0,1,0),new g(0,1,0),new g(0,0,1),new g(0,0,-1)],E=[new d,new d,new d,new d,new d,new d],C=new at;C.depthPacking=bl,C.clipping=!0;for(var I=Ol.distanceRGBA,R=Rl.clone(I.uniforms),L=0;L!==w;++L){var O=0!=(L&x),D=0!=(L&_),N=C.clone();N.morphTargets=O,N.skinning=D,S[L]=N;var k=new ot({defines:{USE_SHADOWMAP:""},uniforms:R,vertexShader:I.vertexShader,fragmentShader:I.fragmentShader,morphTargets:O,skinning:D,clipping:!0});A[L]=k}var F=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=wu,this.renderReverseSided=!0,this.renderSingleSided=!0,this.render=function(e,i){if(!1!==F.enabled&&(!1!==F.autoUpdate||!1!==F.needsUpdate)&&0!==h.length){s.disable(a.BLEND),s.buffers.color.setClear(1,1,1,1),s.buffers.depth.setTest(!0),s.setScissorTest(!1);for(var r,n=0,l=h.length;n<l;n++){var d=h[n],g=d.shadow,v=d&&d.isPointLight;if(void 0!==g){var x=g.camera;if(p.copy(g.mapSize),p.min(m),v){var _=p.x,w=p.y;E[0].set(2*_,w,_,w),E[1].set(0,w,_,w),E[2].set(3*_,w,_,w),E[3].set(_,w,_,w),E[4].set(3*_,0,_,w),E[5].set(_,0,_,w),p.x*=4,p.y*=2}if(null===g.map){var S={minFilter:Ph,magFilter:Ph,format:Wh};g.map=new f(p.x,p.y,S),g.map.texture.name=d.name+".shadowMap",x.updateProjectionMatrix()}g.isSpotLightShadow&&g.update(d);var A=g.map,M=g.matrix;b.setFromMatrixPosition(d.matrixWorld),x.position.copy(b),v?(r=6,M.makeTranslation(-b.x,-b.y,-b.z)):(r=1,y.setFromMatrixPosition(d.target.matrixWorld),x.lookAt(y),x.updateMatrixWorld(),M.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),M.multiply(x.projectionMatrix),M.multiply(x.matrixWorldInverse)),t.setRenderTarget(A),t.clear();for(var C=0;C<r;C++){if(v){y.copy(x.position),y.add(P[C]),x.up.copy(T[C]),x.lookAt(y),x.updateMatrixWorld();var I=E[C];s.viewport(I)}u.multiplyMatrices(x.projectionMatrix,x.matrixWorldInverse),c.setFromMatrix(u),o(e,i,x,v)}}else console.warn("THREE.WebGLShadowMap:",d,"has no shadow.")}var R=t.getClearColor(),L=t.getClearAlpha();t.setClearColor(R,L),F.needsUpdate=!1}}}function dt(t){function e(e,i){var r=e.array,n=e.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW,o=t.createBuffer();t.bindBuffer(i,o),t.bufferData(i,r,n),e.onUploadCallback();var a=t.FLOAT;return r instanceof Float32Array?a=t.FLOAT:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?a=t.UNSIGNED_SHORT:r instanceof Int16Array?a=t.SHORT:r instanceof Uint32Array?a=t.UNSIGNED_INT:r instanceof Int32Array?a=t.INT:r instanceof Int8Array?a=t.BYTE:r instanceof Uint8Array&&(a=t.UNSIGNED_BYTE),{buffer:o,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}function i(e,i,r){var n=i.array,o=i.updateRange;t.bindBuffer(r,e),!1===i.dynamic?t.bufferData(r,n,t.STATIC_DRAW):-1===o.count?t.bufferSubData(r,0,n):0===o.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(t.bufferSubData(r,o.offset*n.BYTES_PER_ELEMENT,n.subarray(o.offset,o.offset+o.count)),o.count=-1)}function r(t){return t.isInterleavedBufferAttribute&&(t=t.data),a[t.uuid]}function n(e){e.isInterleavedBufferAttribute&&(e=e.data);var i=a[e.uuid];i&&(t.deleteBuffer(i.buffer),delete a[e.uuid])}function o(t,r){t.isInterleavedBufferAttribute&&(t=t.data);var n=a[t.uuid];void 0===n?a[t.uuid]=e(t,r):n.version<t.version&&(i(n.buffer,t,r),n.version=t.version)}var a={};return{get:r,remove:n,update:o}}function ft(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._order=r||ft.DefaultOrder}function mt(){this.mask=1}function gt(){function t(){n.setFromEuler(r,!1)}function e(){r.setFromQuaternion(n,void 0,!1)}Object.defineProperty(this,"id",{value:Nl++}),this.uuid=xl.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DefaultUp.clone();var i=new g,r=new ft,n=new m,o=new g(1,1,1);r.onChange(t),n.onChange(e),Object.defineProperties(this,{position:{enumerable:!0,value:i},rotation:{enumerable:!0,value:r},quaternion:{enumerable:!0,value:n},scale:{enumerable:!0,value:o},modelViewMatrix:{value:new v},normalMatrix:{value:new ut}}),this.matrix=new v,this.matrixWorld=new v,this.matrixAutoUpdate=gt.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new mt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function vt(){gt.call(this),this.type="Camera",this.matrixWorldInverse=new v,this.projectionMatrix=new v}function yt(t,e,i,r,n,o){vt.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=r,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function bt(t,e,i,r){vt.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function xt(t,e,i,r,n,o){this.a=t,this.b=e,this.c=i,this.normal=r&&r.isVector3?r:new g,this.vertexNormals=Array.isArray(r)?r:[],this.color=n&&n.isColor?n:new tt,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=void 0!==o?o:0}function _t(){return kl++}function wt(){Object.defineProperty(this,"id",{value:_t()}),this.uuid=xl.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function St(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=xl.generateUUID(),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function At(t,e){St.call(this,new Uint16Array(t),e)}function Mt(t,e){St.call(this,new Uint32Array(t),e)}function Pt(t,e){St.call(this,new Float32Array(t),e)}function Tt(){this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Et(t){if(0===t.length)return-1/0;for(var e=t[0],i=1,r=t.length;i<r;++i)t[i]>e&&(e=t[i]);return e}function Ct(){Object.defineProperty(this,"id",{value:_t()}),this.uuid=xl.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function It(t,e,i,r,n,o){wt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new Rt(t,e,i,r,n,o)),this.mergeVertices()}function Rt(t,e,i,r,n,o){function a(t,e,i,r,n,o,a,f,m,v,y){var b,x,_=o/m,w=a/v,S=o/2,A=a/2,M=f/2,P=m+1,T=v+1,E=0,C=0,I=new g;for(x=0;x<T;x++){var R=x*w-A;for(b=0;b<P;b++){var L=b*_-S;I[t]=L*r,I[e]=R*n,I[i]=M,u.push(I.x,I.y,I.z),I[t]=0,I[e]=0,I[i]=f>0?1:-1,h.push(I.x,I.y,I.z),l.push(b/m),l.push(1-x/v),E+=1}}for(x=0;x<v;x++)for(b=0;b<m;b++){var O=p+b+P*x,D=p+b+P*(x+1),N=p+(b+1)+P*(x+1),k=p+(b+1)+P*x;c.push(O,D,k),c.push(D,N,k),C+=6}s.addGroup(d,C,y),d+=C,p+=E}Ct.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:n,depthSegments:o};var s=this;r=Math.floor(r)||1,n=Math.floor(n)||1;var c=[],u=[],h=[],l=[],p=0,d=0;a("z","y","x",-1,-1,i,e,t,o=Math.floor(o)||1,n,0),a("z","y","x",1,-1,i,e,-t,o,n,1),a("x","z","y",1,1,t,i,e,r,o,2),a("x","z","y",1,-1,t,i,-e,r,o,3),a("x","y","z",1,-1,t,e,i,r,n,4),a("x","y","z",-1,-1,t,e,-i,r,n,5),this.setIndex(c),this.addAttribute("position",new Pt(u,3)),this.addAttribute("normal",new Pt(h,3)),this.addAttribute("uv",new Pt(l,2))}function Lt(t,e,i,r){wt.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new Ot(t,e,i,r)),this.mergeVertices()}function Ot(t,e,i,r){Ct.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r};var n,o,a=t/2,s=e/2,c=Math.floor(i)||1,u=Math.floor(r)||1,h=c+1,l=u+1,p=t/c,d=e/u,f=[],m=[],g=[],v=[];for(o=0;o<l;o++){var y=o*d-s;for(n=0;n<h;n++){var b=n*p-a;m.push(b,-y,0),g.push(0,0,1),v.push(n/c),v.push(1-o/u)}}for(o=0;o<u;o++)for(n=0;n<c;n++){var x=n+h*o,_=n+h*(o+1),w=n+1+h*(o+1),S=n+1+h*o;f.push(x,_,S),f.push(_,w,S)}this.setIndex(f),this.addAttribute("position",new Pt(m,3)),this.addAttribute("normal",new Pt(g,3)),this.addAttribute("uv",new Pt(v,2))}function Dt(t){nt.call(this),this.type="MeshBasicMaterial",this.color=new tt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ch,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function Nt(t,e){this.origin=void 0!==t?t:new g,this.direction=void 0!==e?e:new g}function kt(t,e){this.start=void 0!==t?t:new g,this.end=void 0!==e?e:new g}function Ft(t,e,i){this.a=void 0!==t?t:new g,this.b=void 0!==e?e:new g,this.c=void 0!==i?i:new g}function Bt(t,e){gt.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Ct,this.material=void 0!==e?e:new Dt({color:16777215*Math.random()}),this.drawMode=cl,this.updateMorphTargets()}function zt(t,e,i,r){function n(e,r,n){var p=e.background;null===p?o(h,l):p&&p.isColor&&(o(p,1),n=!0),(t.autoClear||n)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),p&&p.isCubeTexture?(void 0===c&&(c=new bt,u=new Bt(new Rt(5,5,5),new ot({uniforms:Ol.cube.uniforms,vertexShader:Ol.cube.vertexShader,fragmentShader:Ol.cube.fragmentShader,side:Mu,depthTest:!1,depthWrite:!1,fog:!1}))),c.projectionMatrix.copy(r.projectionMatrix),c.matrixWorld.extractRotation(r.matrixWorld),c.matrixWorldInverse.getInverse(c.matrixWorld),u.material.uniforms.tCube.value=p,u.modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,u.matrixWorld),i.update(u),t.renderBufferDirect(c,null,u.geometry,u.material,u,null)):p&&p.isTexture&&(void 0===a&&(a=new yt(-1,1,1,-1,0,1),s=new Bt(new Ot(2,2),new Dt({depthTest:!1,depthWrite:!1,fog:!1}))),s.material.map=p,i.update(s),t.renderBufferDirect(a,null,s.geometry,s.material,s,null))}function o(t,i){e.buffers.color.setClear(t.r,t.g,t.b,i,r)}var a,s,c,u,h=new tt(0),l=0;return{getClearColor:function(){return h},setClearColor:function(t,e){h.set(t),o(h,l=void 0!==e?e:1)},getClearAlpha:function(){return l},setClearAlpha:function(t){o(h,l=t)},render:n}}function Ut(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program&&e.program&&t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function jt(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Gt(){function t(){o=-1,s=-1}function e(t,e,i,r,c){var u,h;i.transparent?(u=a,h=++s):(u=n,h=++o);var l=u[h];l?(l.id=t.id,l.object=t,l.geometry=e,l.material=i,l.program=i.program,l.renderOrder=t.renderOrder,l.z=r,l.group=c):(l={id:t.id,object:t,geometry:e,material:i,program:i.program,renderOrder:t.renderOrder,z:r,group:c},u.push(l))}function i(){n.length=o+1,a.length=s+1}function r(){n.sort(Ut),a.sort(jt)}var n=[],o=-1,a=[],s=-1;return{opaque:n,transparent:a,init:t,push:e,finish:i,sort:r}}function Vt(){function t(t,e){var r=t.id+","+e.id,n=i[r];return void 0===n&&(n=new Gt,i[r]=n),n}function e(){i={}}var i={};return{get:t,dispose:e}}function $t(t,e,i){function r(t){s=t}function n(t){c=t.type,u=t.bytesPerElement}function o(e,r){t.drawElements(s,r,c,e*u),i.calls++,i.vertices+=r,s===t.TRIANGLES&&(i.faces+=r/3)}function a(r,n,o){var a=e.get("ANGLE_instanced_arrays");if(null===a)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");a.drawElementsInstancedANGLE(s,o,c,n*u,r.maxInstancedCount),i.calls++,i.vertices+=o*r.maxInstancedCount,s===t.TRIANGLES&&(i.faces+=r.maxInstancedCount*o/3)}var s,c,u;this.setMode=r,this.setIndex=n,this.render=o,this.renderInstances=a}function Ht(t,e,i){function r(t){a=t}function n(e,r){t.drawArrays(a,e,r),i.calls++,i.vertices+=r,a===t.TRIANGLES&&(i.faces+=r/3)}function o(r,n,o){var s=e.get("ANGLE_instanced_arrays");if(null===s)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");var c=r.attributes.position;c.isInterleavedBufferAttribute?(o=c.data.count,s.drawArraysInstancedANGLE(a,0,o,r.maxInstancedCount)):s.drawArraysInstancedANGLE(a,n,o,r.maxInstancedCount),i.calls++,i.vertices+=o*r.maxInstancedCount,a===t.TRIANGLES&&(i.faces+=r.maxInstancedCount*o/3)}var a;this.setMode=r,this.render=n,this.renderInstances=o}function Wt(t,e,i){function r(t){var n=t.target,o=s[n.id];null!==o.index&&e.remove(o.index);for(var a in o.attributes)e.remove(o.attributes[a]);n.removeEventListener("dispose",r),delete s[n.id];var u=c[n.id];u&&(e.remove(u),delete c[n.id]),(u=c[o.id])&&(e.remove(u),delete c[o.id]),i.geometries--}function n(t,e){var n=s[e.id];return n||(e.addEventListener("dispose",r),e.isBufferGeometry?n=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new Ct).setFromObject(t)),n=e._bufferGeometry),s[e.id]=n,i.geometries++,n)}function o(i){var r=i.index,n=i.attributes;null!==r&&e.update(r,t.ELEMENT_ARRAY_BUFFER);for(var o in n)e.update(n[o],t.ARRAY_BUFFER);var a=i.morphAttributes;for(var o in a)for(var s=a[o],c=0,u=s.length;c<u;c++)e.update(s[c],t.ARRAY_BUFFER)}function a(i){var r=c[i.id];if(r)return r;var n=[],o=i.index,a=i.attributes;if(null!==o)for(var s=0,u=(d=o.array).length;s<u;s+=3){var h=d[s+0],l=d[s+1],p=d[s+2];n.push(h,l,l,p,p,h)}else for(var d=a.position.array,s=0,u=d.length/3-1;s<u;s+=3){var h=s+0,l=s+1,p=s+2;n.push(h,l,l,p,p,h)}return r=new(Et(n)>65535?Mt:At)(n,1),e.update(r,t.ELEMENT_ARRAY_BUFFER),c[i.id]=r,r}var s={},c={};return{get:n,update:o,getWireframeAttribute:a}}function Xt(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var i;switch(e.type){case"DirectionalLight":i={direction:new g,color:new tt,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new l};break;case"SpotLight":i={position:new g,direction:new g,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new l};break;case"PointLight":i={position:new g,color:new tt,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new l};break;case"HemisphereLight":i={direction:new g,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":i={color:new tt,position:new g,halfWidth:new g,halfHeight:new g}}return t[e.id]=i,i}}}function qt(t,e,i){function r(t){var r=i.frame,n=t.geometry,a=e.get(t,n);return o[a.id]!==r&&(n.isGeometry&&a.updateFromObject(t),e.update(a),o[a.id]=r),a}function n(){o={}}var o={};return{update:r,clear:n}}function Yt(t){for(var e=t.split("\n"),i=0;i<e.length;i++)e[i]=i+1+": "+e[i];return e.join("\n")}function Zt(t,e,i){var r=t.createShader(e);return t.shaderSource(r,i),t.compileShader(r),!1===t.getShaderParameter(r,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(r)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(r),Yt(i)),r}function Kt(t){switch(t){case ll:return["Linear","( value )"];case pl:return["sRGB","( value )"];case fl:return["RGBE","( value )"];case ml:return["RGBM","( value, 7.0 )"];case gl:return["RGBM","( value, 16.0 )"];case vl:return["RGBD","( value, 256.0 )"];case dl:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function Qt(t,e){var i=Kt(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function Jt(t,e){var i=Kt(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function te(t,e){var i;switch(e){case ph:i="Linear";break;case dh:i="Reinhard";break;case fh:i="Uncharted2";break;case mh:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function ee(t,e,i){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ne).join("\n")}function ie(t){var e=[];for(var i in t){var r=t[i];!1!==r&&e.push("#define "+i+" "+r)}return e.join("\n")}function re(t,e,i){for(var r={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o<n;o++){var a=t.getActiveAttrib(e,o).name;r[a]=t.getAttribLocation(e,a)}return r}function ne(t){return""!==t}function oe(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function ae(t){function e(t,e){var i=Ll[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return ae(i)}return t.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,e)}function se(t){function e(t,e,i,r){for(var n="",o=parseInt(e);o<parseInt(i);o++)n+=r.replace(/\[ i \]/g,"[ "+o+" ]");return n}return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,e)}function ce(t,e,i,r,n){var o=t.context,a=i.extensions,s=i.defines,c=r.vertexShader,u=r.fragmentShader,h="SHADOWMAP_TYPE_BASIC";n.shadowMapType===wu?h="SHADOWMAP_TYPE_PCF":n.shadowMapType===Su&&(h="SHADOWMAP_TYPE_PCF_SOFT");var l="ENVMAP_TYPE_CUBE",p="ENVMAP_MODE_REFLECTION",d="ENVMAP_BLENDING_MULTIPLY";if(n.envMap){switch(i.envMap.mapping){case gh:case vh:l="ENVMAP_TYPE_CUBE";break;case _h:case wh:l="ENVMAP_TYPE_CUBE_UV";break;case yh:case bh:l="ENVMAP_TYPE_EQUIREC";break;case xh:l="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case vh:case bh:p="ENVMAP_MODE_REFRACTION"}switch(i.combine){case ch:d="ENVMAP_BLENDING_MULTIPLY";break;case uh:d="ENVMAP_BLENDING_MIX";break;case hh:d="ENVMAP_BLENDING_ADD"}}var f,m,g=t.gammaFactor>0?t.gammaFactor:1,v=ee(a,n,t.extensions),y=ie(s),b=o.createProgram();i.isRawShaderMaterial?(f=[y,"\n"].filter(ne).join("\n"),m=[v,y,"\n"].filter(ne).join("\n")):(f=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.name,y,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ne).join("\n"),m=[v,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.name,y,n.alphaTest?"#define ALPHATEST "+n.alphaTest:"","#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+p:"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(n.numClippingPlanes-n.numClipIntersection),n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+h:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",n.envMap&&t.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",n.toneMapping!==lh?"#define TONE_MAPPING":"",n.toneMapping!==lh?Ll.tonemapping_pars_fragment:"",n.toneMapping!==lh?te("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?Ll.encodings_pars_fragment:"",n.mapEncoding?Qt("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?Qt("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?Qt("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?Jt("linearToOutputTexel",n.outputEncoding):"",n.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ne).join("\n")),c=oe(c=ae(c),n),u=oe(u=ae(u),n),i.isShaderMaterial||(c=se(c),u=se(u));var x=f+c,_=m+u,w=Zt(o,o.VERTEX_SHADER,x),S=Zt(o,o.FRAGMENT_SHADER,_);o.attachShader(b,w),o.attachShader(b,S),void 0!==i.index0AttributeName?o.bindAttribLocation(b,0,i.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(b,0,"position"),o.linkProgram(b);var A=o.getProgramInfoLog(b),M=o.getShaderInfoLog(w),P=o.getShaderInfoLog(S),T=!0,E=!0;!1===o.getProgramParameter(b,o.LINK_STATUS)?(T=!1,console.error("THREE.WebGLProgram: shader error: ",o.getError(),"gl.VALIDATE_STATUS",o.getProgramParameter(b,o.VALIDATE_STATUS),"gl.getProgramInfoLog",A,M,P)):""!==A?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",A):""!==M&&""!==P||(E=!1),E&&(this.diagnostics={runnable:T,material:i,programLog:A,vertexShader:{log:M,prefix:f},fragmentShader:{log:P,prefix:m}}),o.deleteShader(w),o.deleteShader(S);var C;this.getUniforms=function(){return void 0===C&&(C=new J(o,b,t)),C};var I;return this.getAttributes=function(){return void 0===I&&(I=re(o,b)),I},this.destroy=function(){o.deleteProgram(b),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=Fl++,this.code=e,this.usedTimes=1,this.program=b,this.vertexShader=w,this.fragmentShader=S,this}function ue(t,e){function i(t){var i=t.skeleton.bones;if(e.floatVertexTextures)return 1024;var r=e.maxVertexUniforms,n=Math.floor((r-20)/4),o=Math.min(n,i.length);return o<i.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+i.length+" bones. This GPU supports "+o+"."),0):o}function r(t,e){var i;return t?t.isTexture?i=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),i=t.texture.encoding):i=ll,i===ll&&e&&(i=dl),i}var n=[],o={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},a=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];this.getParameters=function(n,a,s,c,u,h){var l=o[n.type],p=h.isSkinnedMesh?i(h):0,d=t.getPrecision();null!==n.precision&&(d=e.getMaxPrecision(n.precision))!==n.precision&&console.warn("THREE.WebGLProgram.getParameters:",n.precision,"not supported, using",d,"instead.");var f=t.getRenderTarget();return{shaderID:l,precision:d,supportsVertexTextures:e.vertexTextures,outputEncoding:r(f?f.texture:null,t.gammaOutput),map:!!n.map,mapEncoding:r(n.map,t.gammaInput),envMap:!!n.envMap,envMapMode:n.envMap&&n.envMap.mapping,envMapEncoding:r(n.envMap,t.gammaInput),envMapCubeUV:!!n.envMap&&(n.envMap.mapping===_h||n.envMap.mapping===wh),lightMap:!!n.lightMap,aoMap:!!n.aoMap,emissiveMap:!!n.emissiveMap,emissiveMapEncoding:r(n.emissiveMap,t.gammaInput),bumpMap:!!n.bumpMap,normalMap:!!n.normalMap,displacementMap:!!n.displacementMap,roughnessMap:!!n.roughnessMap,metalnessMap:!!n.metalnessMap,specularMap:!!n.specularMap,alphaMap:!!n.alphaMap,gradientMap:!!n.gradientMap,combine:n.combine,vertexColors:n.vertexColors,fog:!!s,useFog:n.fog,fogExp:s&&s.isFogExp2,flatShading:n.shading===Tu,sizeAttenuation:n.sizeAttenuation,logarithmicDepthBuffer:e.logarithmicDepthBuffer,skinning:n.skinning&&p>0,maxBones:p,useVertexTexture:e.floatVertexTextures,morphTargets:n.morphTargets,morphNormals:n.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:c,numClipIntersection:u,dithering:n.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.receiveShadow&&a.shadows.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:n.premultipliedAlpha,alphaTest:n.alphaTest,doubleSided:n.side===Pu,flipSided:n.side===Mu,depthPacking:void 0!==n.depthPacking&&n.depthPacking}},this.getProgramCode=function(e,i){var r=[];if(i.shaderID?r.push(i.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var n in e.defines)r.push(n),r.push(e.defines[n]);for(var o=0;o<a.length;o++)r.push(i[a[o]]);return r.push(e.onBeforeCompile.toString()),r.push(t.gammaOutput),r.join()},this.acquireProgram=function(e,i,r,o){for(var a,s=0,c=n.length;s<c;s++){var u=n[s];if(u.code===o){++(a=u).usedTimes;break}}return void 0===a&&(a=new ce(t,o,e,i,r),n.push(a)),a},this.releaseProgram=function(t){if(0==--t.usedTimes){var e=n.indexOf(t);n[e]=n[n.length-1],n.pop(),t.destroy()}},this.programs=n}function he(t,e,i,r,n,o,a){function s(t,e){if(t.width>e||t.height>e){var i=e/Math.max(t.width,t.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(t.width*i),r.height=Math.floor(t.height*i),r.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+r.width+"x"+r.height,t),r}return t}function c(t){return xl.isPowerOfTwo(t.width)&&xl.isPowerOfTwo(t.height)}function u(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=xl.nearestPowerOfTwo(t.width),e.height=xl.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function h(t){return t.wrapS!==Ah||t.wrapT!==Ah||t.minFilter!==Ph&&t.minFilter!==Ch}function l(t,e){return t.generateMipmaps&&e&&t.minFilter!==Ph&&t.minFilter!==Ch}function p(e){return e===Ph||e===Th||e===Eh?t.NEAREST:t.LINEAR}function d(t){var e=t.target;e.removeEventListener("dispose",d),m(e),a.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),g(e),a.textures--}function m(e){var i=r.get(e);if(e.image&&i.__image__webglTextureCube)t.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture)}r.remove(e)}function g(e){var i=r.get(e),n=r.get(e.texture);if(e){if(void 0!==n.__webglTexture&&t.deleteTexture(n.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(i.__webglFramebuffer[o]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[o]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer);r.remove(e.texture),r.remove(e)}}function v(e,n){var o=r.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==a.complete)return void _(o,e,n);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}i.activeTexture(t.TEXTURE0+n),i.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function y(e,u){var h=r.get(e);if(6===e.image.length)if(e.version>0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",d),h.__image__webglTextureCube=t.createTexture(),a.textures++),i.activeTexture(t.TEXTURE0+u),i.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var p=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,m=[],g=0;g<6;g++)m[g]=p||f?f?e.image[g].image:e.image[g]:s(e.image[g],n.maxCubemapSize);var v=c(m[0]),y=o(e.format),b=o(e.type);x(t.TEXTURE_CUBE_MAP,e,v);for(g=0;g<6;g++)if(p)for(var _,w=m[g].mipmaps,S=0,A=w.length;S<A;S++)_=w[S],e.format!==Wh&&e.format!==Hh?i.getCompressedTextureFormats().indexOf(y)>-1?i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,S,y,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,S,y,_.width,_.height,0,y,b,_.data);else f?i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,y,m[g].width,m[g].height,0,y,b,m[g].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,y,y,b,m[g]);l(e,v)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else i.activeTexture(t.TEXTURE0+u),i.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)}function b(e,n){i.activeTexture(t.TEXTURE0+n),i.bindTexture(t.TEXTURE_CUBE_MAP,r.get(e).__webglTexture)}function x(i,a,s){var c;if(s?(t.texParameteri(i,t.TEXTURE_WRAP_S,o(a.wrapS)),t.texParameteri(i,t.TEXTURE_WRAP_T,o(a.wrapT)),t.texParameteri(i,t.TEXTURE_MAG_FILTER,o(a.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,o(a.minFilter))):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS===Ah&&a.wrapT===Ah||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),t.texParameteri(i,t.TEXTURE_MAG_FILTER,p(a.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,p(a.minFilter)),a.minFilter!==Ph&&a.minFilter!==Ch&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===Bh&&null===e.get("OES_texture_float_linear"))return;if(a.type===zh&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(t.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function _(e,r,p){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",d),e.__webglTexture=t.createTexture(),a.textures++),i.activeTexture(t.TEXTURE0+p),i.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment);var f=s(r.image,n.maxTextureSize);h(r)&&!1===c(f)&&(f=u(f));var m=c(f),g=o(r.format),v=o(r.type);x(t.TEXTURE_2D,r,m);var y,b=r.mipmaps;if(r.isDepthTexture){var _=t.DEPTH_COMPONENT;if(r.type===Bh){if(!E)throw new Error("Float Depth Texture only supported in WebGL2.0");_=t.DEPTH_COMPONENT32F}else E&&(_=t.DEPTH_COMPONENT16);r.format===Yh&&_===t.DEPTH_COMPONENT&&r.type!==Nh&&r.type!==Fh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Nh,v=o(r.type)),r.format===Zh&&(_=t.DEPTH_STENCIL,r.type!==Vh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Vh,v=o(r.type))),i.texImage2D(t.TEXTURE_2D,0,_,f.width,f.height,0,g,v,null)}else if(r.isDataTexture)if(b.length>0&&m){for(var w=0,S=b.length;w<S;w++)y=b[w],i.texImage2D(t.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);r.generateMipmaps=!1}else i.texImage2D(t.TEXTURE_2D,0,g,f.width,f.height,0,g,v,f.data);else if(r.isCompressedTexture)for(var w=0,S=b.length;w<S;w++)y=b[w],r.format!==Wh&&r.format!==Hh?i.getCompressedTextureFormats().indexOf(g)>-1?i.compressedTexImage2D(t.TEXTURE_2D,w,g,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(t.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);else if(b.length>0&&m){for(var w=0,S=b.length;w<S;w++)y=b[w],i.texImage2D(t.TEXTURE_2D,w,g,g,v,y);r.generateMipmaps=!1}else i.texImage2D(t.TEXTURE_2D,0,g,g,v,f);l(r,m)&&t.generateMipmap(t.TEXTURE_2D),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}function w(e,n,a,s){var c=o(n.texture.format),u=o(n.texture.type);i.texImage2D(s,0,c,n.width,n.height,0,c,u,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,r.get(n.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function S(e,i){t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):i.depthBuffer&&i.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,i.width,i.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function A(e,i){if(i&&i.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),v(i.depthTexture,0);var n=r.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===Yh)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,n,0);else{if(i.depthTexture.format!==Zh)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,n,0)}}function M(e){var i=r.get(e),n=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");A(i.__webglFramebuffer,e)}else if(n){i.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer[o]),i.__webglDepthbuffer[o]=t.createRenderbuffer(),S(i.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),S(i.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}function P(e){var n=r.get(e),o=r.get(e.texture);e.addEventListener("dispose",f),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,u=c(e);if(s){n.__webglFramebuffer=[];for(h=0;h<6;h++)n.__webglFramebuffer[h]=t.createFramebuffer()}else n.__webglFramebuffer=t.createFramebuffer();if(s){i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),x(t.TEXTURE_CUBE_MAP,e.texture,u);for(var h=0;h<6;h++)w(n.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);l(e.texture,u)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),i.bindTexture(t.TEXTURE_CUBE_MAP,null)}else i.bindTexture(t.TEXTURE_2D,o.__webglTexture),x(t.TEXTURE_2D,e.texture,u),w(n.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),l(e.texture,u)&&t.generateMipmap(t.TEXTURE_2D),i.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&M(e)}function T(e){var n=e.texture;if(l(n,c(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=r.get(n).__webglTexture;i.bindTexture(o,a),t.generateMipmap(o),i.bindTexture(o,null)}}var E="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=v,this.setTextureCube=y,this.setTextureCubeDynamic=b,this.setupRenderTarget=P,this.updateRenderTargetMipmap=T}function le(){function t(t){var e=t.uuid,i=r[e];return void 0===i&&(i={},r[e]=i),i}function e(t){delete r[t.uuid]}function i(){r={}}var r={};return{get:t,remove:e,clear:i}}function pe(t,e,i){function r(){var e=!1,i=new d,r=null,n=new d;return{setMask:function(i){r===i||e||(t.colorMask(i,i,i,i),r=i)},setLocked:function(t){e=t},setClear:function(e,r,o,a,s){!0===s&&(e*=a,r*=a,o*=a),i.set(e,r,o,a),!1===n.equals(i)&&(t.clearColor(e,r,o,a),n.copy(i))},reset:function(){e=!1,r=null,n.set(0,0,0,1)}}}function n(){var e=!1,i=null,r=null,n=null;return{setTest:function(e){e?p(t.DEPTH_TEST):f(t.DEPTH_TEST)},setMask:function(r){i===r||e||(t.depthMask(r),i=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case th:t.depthFunc(t.NEVER);break;case eh:t.depthFunc(t.ALWAYS);break;case ih:t.depthFunc(t.LESS);break;case rh:t.depthFunc(t.LEQUAL);break;case nh:t.depthFunc(t.EQUAL);break;case oh:t.depthFunc(t.GEQUAL);break;case ah:t.depthFunc(t.GREATER);break;case sh:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);r=e}},setLocked:function(t){e=t},setClear:function(e){n!==e&&(t.clearDepth(e),n=e)},reset:function(){e=!1,i=null,r=null,n=null}}}function o(){var e=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,u=null;return{setTest:function(e){e?p(t.STENCIL_TEST):f(t.STENCIL_TEST)},setMask:function(r){i===r||e||(t.stencilMask(r),i=r)},setFunc:function(e,i,a){r===e&&n===i&&o===a||(t.stencilFunc(e,i,a),r=e,n=i,o=a)},setOp:function(e,i,r){a===e&&s===i&&c===r||(t.stencilOp(e,i,r),a=e,s=i,c=r)},setLocked:function(t){e=t},setClear:function(e){u!==e&&(t.clearStencil(e),u=e)},reset:function(){e=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,u=null}}}function a(e,i,r){var n=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a<r;a++)t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,n);return o}function s(){R.setClear(0,0,0,1),L.setClear(1),O.setClear(0),p(t.DEPTH_TEST),L.setFunc(rh),y(!1),b(bu),p(t.CULL_FACE),p(t.BLEND),g(Ou)}function c(){for(var t=0,e=N.length;t<e;t++)N[t]=0}function u(i){N[i]=1,0===k[i]&&(t.enableVertexAttribArray(i),k[i]=1),0!==F[i]&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(i,0),F[i]=0)}function h(i,r){N[i]=1,0===k[i]&&(t.enableVertexAttribArray(i),k[i]=1),F[i]!==r&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(i,r),F[i]=r)}function l(){for(var e=0,i=k.length;e!==i;++e)k[e]!==N[e]&&(t.disableVertexAttribArray(e),k[e]=0)}function p(e){!0!==B[e]&&(t.enable(e),B[e]=!0)}function f(e){!1!==B[e]&&(t.disable(e),B[e]=!1)}function m(){if(null===z&&(z=[],e.get("WEBGL_compressed_texture_pvrtc")||e.get("WEBGL_compressed_texture_s3tc")||e.get("WEBGL_compressed_texture_etc1")))for(var i=t.getParameter(t.COMPRESSED_TEXTURE_FORMATS),r=0;r<i.length;r++)z.push(i[r]);return z}function g(e,r,n,o,a,s,c,u){e!==Lu?p(t.BLEND):f(t.BLEND),e===Fu||e===U&&u===X||(e===Du?u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE)):e===Nu?u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_COLOR)):e===ku?u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.SRC_COLOR)):u?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)),U=e,X=u),e===Fu?(a=a||r,s=s||n,c=c||o,r===j&&a===$||(t.blendEquationSeparate(i(r),i(a)),j=r,$=a),n===G&&o===V&&s===H&&c===W||(t.blendFuncSeparate(i(n),i(o),i(s),i(c)),G=n,V=o,H=s,W=c)):(j=null,G=null,V=null,$=null,H=null,W=null)}function v(e){e.side===Pu?f(t.CULL_FACE):p(t.CULL_FACE),y(e.side===Mu),!0===e.transparent?g(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):g(Lu),L.setFunc(e.depthFunc),L.setTest(e.depthTest),L.setMask(e.depthWrite),R.setMask(e.colorWrite),_(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function y(e){q!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),q=e)}function b(e){e!==yu?(p(t.CULL_FACE),e!==Y&&(e===bu?t.cullFace(t.BACK):e===xu?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):f(t.CULL_FACE),Y=e}function x(e){e!==Z&&(it&&t.lineWidth(e),Z=e)}function _(e,i,r){e?(p(t.POLYGON_OFFSET_FILL),K===i&&Q===r||(t.polygonOffset(i,r),K=i,Q=r)):f(t.POLYGON_OFFSET_FILL)}function w(){return J}function S(e){J=e,e?p(t.SCISSOR_TEST):f(t.SCISSOR_TEST)}function A(e){void 0===e&&(e=t.TEXTURE0+tt-1),rt!==e&&(t.activeTexture(e),rt=e)}function M(e,i){null===rt&&A();var r=nt[rt];void 0===r&&(r={type:void 0,texture:void 0},nt[rt]=r),r.type===e&&r.texture===i||(t.bindTexture(e,i||st[e]),r.type=e,r.texture=i)}function P(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}}function T(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}}function E(e){!1===ot.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),ot.copy(e))}function C(e){!1===at.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),at.copy(e))}function I(){for(var e=0;e<k.length;e++)1===k[e]&&(t.disableVertexAttribArray(e),k[e]=0);B={},z=null,rt=null,nt={},U=null,q=null,Y=null,R.reset(),L.reset(),O.reset()}var R=new r,L=new n,O=new o,D=t.getParameter(t.MAX_VERTEX_ATTRIBS),N=new Uint8Array(D),k=new Uint8Array(D),F=new Uint8Array(D),B={},z=null,U=null,j=null,G=null,V=null,$=null,H=null,W=null,X=!1,q=null,Y=null,Z=null,K=null,Q=null,J=null,tt=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),et=parseFloat(/^WebGL\ ([0-9])/.exec(t.getParameter(t.VERSION))[1]),it=parseFloat(et)>=1,rt=null,nt={},ot=new d,at=new d,st={};return st[t.TEXTURE_2D]=a(t.TEXTURE_2D,t.TEXTURE_2D,1),st[t.TEXTURE_CUBE_MAP]=a(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:R,depth:L,stencil:O},init:s,initAttributes:c,enableAttribute:u,enableAttributeAndDivisor:h,disableUnusedAttributes:l,enable:p,disable:f,getCompressedTextureFormats:m,setBlending:g,setMaterial:v,setFlipSided:y,setCullFace:b,setLineWidth:x,setPolygonOffset:_,getScissorTest:w,setScissorTest:S,activeTexture:A,bindTexture:M,compressedTexImage2D:P,texImage2D:T,scissor:E,viewport:C,reset:I}}function de(t,e,i){function r(){if(void 0!==o)return o;var i=e.get("EXT_texture_filter_anisotropic");return o=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}function n(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o,a=void 0!==i.precision?i.precision:"highp",s=n(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);var c=!0===i.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_TEXTURE_SIZE),p=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),d=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),m=t.getParameter(t.MAX_VARYING_VECTORS),g=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,y=!!e.get("OES_texture_float");return{getMaxAnisotropy:r,getMaxPrecision:n,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y}}function fe(t){bt.call(this),this.cameras=t||[]}function me(t){function e(){if(r.isPresenting){var e=r.getEyeParameters("left"),n=e.renderWidth,o=e.renderHeight;p=t.getPixelRatio(),l=t.getSize(),t.setDrawingBufferSize(2*n,o,1)}else i.enabled&&t.setDrawingBufferSize(l.width,l.height,p)}var i=this,r=null,n=null;"VRFrameData"in window&&(n=new window.VRFrameData);var o=new v,a=new v,s=new v,c=new bt;c.bounds=new d(0,0,.5,1),c.layers.enable(1);var u=new bt;u.bounds=new d(.5,0,.5,1),u.layers.enable(2);var h=new fe([c,u]);h.layers.enable(1),h.layers.enable(2);var l,p;window.addEventListener("vrdisplaypresentchange",e,!1),this.enabled=!1,this.standing=!1,this.getDevice=function(){return r},this.setDevice=function(t){void 0!==t&&(r=t)},this.getCamera=function(t){if(null===r)return t;r.depthNear=t.near,r.depthFar=t.far,r.getFrameData(n);var e=n.pose;null!==e.position?t.position.fromArray(e.position):t.position.set(0,0,0),null!==e.orientation&&t.quaternion.fromArray(e.orientation),t.updateMatrixWorld();var i=r.stageParameters;if(this.standing&&i&&(a.fromArray(i.sittingToStandingTransform),s.getInverse(a),t.matrixWorld.multiply(a),t.matrixWorldInverse.multiply(s)),!1===r.isPresenting)return t;h.matrixWorld.copy(t.matrixWorld),h.matrixWorldInverse.copy(t.matrixWorldInverse),c.matrixWorldInverse.fromArray(n.leftViewMatrix),u.matrixWorldInverse.fromArray(n.rightViewMatrix),this.standing&&i&&(c.matrixWorldInverse.multiply(s),u.matrixWorldInverse.multiply(s));var l=t.parent;null!==l&&(o.getInverse(l.matrixWorld),c.matrixWorldInverse.multiply(o),u.matrixWorldInverse.multiply(o)),c.matrixWorld.getInverse(c.matrixWorldInverse),u.matrixWorld.getInverse(u.matrixWorldInverse),c.projectionMatrix.fromArray(n.leftProjectionMatrix),u.projectionMatrix.fromArray(n.rightProjectionMatrix),h.projectionMatrix.copy(c.projectionMatrix);var p=r.getLayers();if(p.length){var d=p[0];null!==d.leftBounds&&4===d.leftBounds.length&&c.bounds.fromArray(d.leftBounds),null!==d.rightBounds&&4===d.rightBounds.length&&u.bounds.fromArray(d.rightBounds)}return h},this.getStandingMatrix=function(){return a},this.submitFrame=function(){r&&r.isPresenting&&r.submitFrame()}}function ge(t){var e={};return{get:function(i){if(void 0!==e[i])return e[i];var r;switch(i){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":r=t.getExtension("WEBGL_compressed_texture_etc1");break;default:r=t.getExtension(i)}return null===r&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),e[i]=r,r}}}function ve(){function t(){u.value!==r&&(u.value=r,u.needsUpdate=n>0),i.numPlanes=n,i.numIntersection=0}function e(t,e,r,n){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=u.value,!0!==n||null===a){var h=r+4*o,l=e.matrixWorldInverse;c.getNormalMatrix(l),(null===a||a.length<h)&&(a=new Float32Array(h));for(var p=0,d=r;p!==o;++p,d+=4)s.copy(t[p]).applyMatrix4(l,c),s.normal.toArray(a,d),a[d+3]=s.constant}u.value=a,u.needsUpdate=!0}return i.numPlanes=o,a}var i=this,r=null,n=0,o=!1,a=!1,s=new ht,c=new ut,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(t,i,a){var s=0!==t.length||i||0!==n||o;return o=i,r=e(t,a,0),n=t.length,s},this.beginShadows=function(){a=!0,e(null)},this.endShadows=function(){a=!1,t()},this.setState=function(i,s,c,h,l,p){if(!o||null===i||0===i.length||a&&!c)a?e(null):t();else{var d=a?0:n,f=4*d,m=l.clippingState||null;u.value=m,m=e(i,h,f,p);for(var g=0;g!==f;++g)m[g]=r[g];l.clippingState=m,this.numIntersection=s?this.numPlanes:0,this.numPlanes+=d}}}function ye(t){function e(){return null===K?mt:1}function i(){Nt.init(),Nt.scissor(at.copy(gt).multiplyScalar(mt)),Nt.viewport(ct.copy(yt).multiplyScalar(mt))}function r(){Z=null,nt=null,et="",tt=-1,Nt.reset()}function n(t){t.preventDefault(),r(),i(),kt.clear(),jt.clear()}function o(t){var e=t.target;e.removeEventListener("dispose",o),a(e)}function a(t){s(t),kt.remove(t)}function s(t){var e=kt.get(t).program;t.program=void 0,void 0!==e&&Gt.releaseProgram(e)}function c(t,e,i){t.render(function(t){Y.renderBufferImmediate(t,e,i)})}function u(t,e){return Math.abs(e[0])-Math.abs(t[0])}function h(t,e,i,r){if(i&&i.isInstancedBufferGeometry&&null===Ot.get("ANGLE_instanced_arrays"))return void console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");void 0===r&&(r=0),Nt.initAttributes();var n=i.attributes,o=e.getAttributes(),a=t.defaultAttributeValues;for(var s in o){var c=o[s];if(c>=0){var u=n[s];if(void 0!==u){var h=u.normalized,l=u.itemSize,p=Bt.get(u),d=p.buffer,f=p.type,m=p.bytesPerElement;if(u.isInterleavedBufferAttribute){var g=u.data,v=g.stride,y=u.offset;g&&g.isInstancedInterleavedBuffer?(Nt.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=g.meshPerAttribute*g.count)):Nt.enableAttribute(c),Rt.bindBuffer(Rt.ARRAY_BUFFER,d),Rt.vertexAttribPointer(c,l,f,h,v*m,(r*v+y)*m)}else u.isInstancedBufferAttribute?(Nt.enableAttributeAndDivisor(c,u.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=u.meshPerAttribute*u.count)):Nt.enableAttribute(c),Rt.bindBuffer(Rt.ARRAY_BUFFER,d),Rt.vertexAttribPointer(c,l,f,h,0,r*l*m)}else if(void 0!==a){var b=a[s];if(void 0!==b)switch(b.length){case 2:Rt.vertexAttrib2fv(c,b);break;case 3:Rt.vertexAttrib3fv(c,b);break;case 4:Rt.vertexAttrib4fv(c,b);break;default:Rt.vertexAttrib1fv(c,b)}}}}Nt.disableUnusedAttributes()}function l(t,e,i){if(t.visible){if(t.layers.test(e.layers))if(t.isLight)$.push(t);else if(t.isSprite)t.frustumCulled&&!bt.intersectsSprite(t)||X.push(t);else if(t.isLensFlare)q.push(t);else if(t.isImmediateRenderObject)i&&At.setFromMatrixPosition(t.matrixWorld).applyMatrix4(St),H.push(t,null,t.material,At.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||bt.intersectsObject(t))){i&&At.setFromMatrixPosition(t.matrixWorld).applyMatrix4(St);var r=jt.update(t),n=t.material;if(Array.isArray(n))for(var o=r.groups,a=0,s=o.length;a<s;a++){var c=o[a],u=n[c.materialIndex];u&&u.visible&&H.push(t,r,u,At.z,c)}else n.visible&&H.push(t,r,n,At.z,null)}for(var h=t.children,a=0,s=h.length;a<s;a++)l(h[a],e,i)}}function p(t,e,i,r){for(var n=0,o=t.length;n<o;n++){var a=t[n],s=a.object,c=a.geometry,u=void 0===r?a.material:r,h=a.group;if(i.isArrayCamera){ot=i;for(var l=i.cameras,p=0,d=l.length;p<d;p++){var m=l[p];if(s.layers.test(m.layers)){var g=m.bounds,v=g.x*ht,y=g.y*ft,b=g.z*ht,x=g.w*ft;Y.setViewport(v,y,b,x),Y.setScissor(v,y,b,x),Y.setScissorTest(!0),f(s,e,m,c,u,h)}}}else ot=null,f(s,e,i,c,u,h)}}function f(t,e,i,r,n,o){if(t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.onBeforeRender(Y,e,i,r,n,o),t.isImmediateRenderObject){Nt.setMaterial(n);var a=b(i,e.fog,n,t);et="",c(t,a,n)}else Y.renderBufferDirect(i,e.fog,r,n,t,o);t.onAfterRender(Y,e,i,r,n,o)}function m(t,e,i){var r=kt.get(t),n=Gt.getParameters(t,Tt,e,xt.numPlanes,xt.numIntersection,i),a=Gt.getProgramCode(t,n),c=r.program,u=!0;if(void 0===c)t.addEventListener("dispose",o);else if(c.code!==a)s(t);else{if(void 0!==n.shaderID)return;u=!1}if(u){if(n.shaderID){var h=Ol[n.shaderID];r.shader={name:t.type,uniforms:Rl.clone(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader}}else r.shader={name:t.type,uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};t.onBeforeCompile(r.shader),c=Gt.acquireProgram(t,r.shader,n,a),r.program=c,t.program=c}var l=c.getAttributes();if(t.morphTargets){t.numSupportedMorphTargets=0;for(p=0;p<Y.maxMorphTargets;p++)l["morphTarget"+p]>=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p<Y.maxMorphNormals;p++)l["morphNormal"+p]>=0&&t.numSupportedMorphNormals++}var d=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=xt.numPlanes,r.numIntersection=xt.numIntersection,d.clippingPlanes=xt.uniform),r.fog=e,r.lightsHash=Tt.hash,t.lights&&(d.ambientLightColor.value=Tt.ambient,d.directionalLights.value=Tt.directional,d.spotLights.value=Tt.spot,d.rectAreaLights.value=Tt.rectArea,d.pointLights.value=Tt.point,d.hemisphereLights.value=Tt.hemi,d.directionalShadowMap.value=Tt.directionalShadowMap,d.directionalShadowMatrix.value=Tt.directionalShadowMatrix,d.spotShadowMap.value=Tt.spotShadowMap,d.spotShadowMatrix.value=Tt.spotShadowMatrix,d.pointShadowMap.value=Tt.pointShadowMap,d.pointShadowMatrix.value=Tt.pointShadowMatrix);var f=r.program.getUniforms(),m=J.seqWithValue(f.seq,d);r.uniformsList=m}function b(t,e,i,r){ut=0;var n=kt.get(i);if(_t&&(wt||t!==nt)){var o=t===nt&&i.id===tt;xt.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,t,n,o)}!1===i.needsUpdate&&(void 0===n.program?i.needsUpdate=!0:i.fog&&n.fog!==e?i.needsUpdate=!0:i.lights&&n.lightsHash!==Tt.hash?i.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===xt.numPlanes&&n.numIntersection===xt.numIntersection||(i.needsUpdate=!0)),i.needsUpdate&&(m(i,e,r),i.needsUpdate=!1);var a=!1,s=!1,c=!1,u=n.program,h=u.getUniforms(),l=n.shader.uniforms;if(u.id!==Z&&(Rt.useProgram(u.program),Z=u.id,a=!0,s=!0,c=!0),i.id!==tt&&(tt=i.id,s=!0),a||t!==nt){if(h.setValue(Rt,"projectionMatrix",t.projectionMatrix),Dt.logarithmicDepthBuffer&&h.setValue(Rt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),nt!==(ot||t)&&(nt=ot||t,s=!0,c=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var p=h.map.cameraPosition;void 0!==p&&p.setValue(Rt,At.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&h.setValue(Rt,"viewMatrix",t.matrixWorldInverse)}if(i.skinning){h.setOptional(Rt,r,"bindMatrix"),h.setOptional(Rt,r,"bindMatrixInverse");var d=r.skeleton;if(d){var f=d.bones;if(Dt.floatVertexTextures){if(void 0===d.boneTexture){var g=Math.sqrt(4*f.length);g=xl.nextPowerOfTwo(Math.ceil(g)),g=Math.max(g,4);var v=new Float32Array(g*g*4);v.set(d.boneMatrices);var b=new y(v,g,g,Wh,Bh);d.boneMatrices=v,d.boneTexture=b,d.boneTextureSize=g}h.setValue(Rt,"boneTexture",d.boneTexture),h.setValue(Rt,"boneTextureSize",d.boneTextureSize)}else h.setOptional(Rt,d,"boneMatrices")}}return s&&(h.setValue(Rt,"toneMappingExposure",Y.toneMappingExposure),h.setValue(Rt,"toneMappingWhitePoint",Y.toneMappingWhitePoint),i.lights&&R(l,c),e&&i.fog&&A(l,e),(i.isMeshBasicMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshNormalMaterial||i.isMeshDepthMaterial)&&x(l,i),i.isLineBasicMaterial?_(l,i):i.isLineDashedMaterial?(_(l,i),w(l,i)):i.isPointsMaterial?S(l,i):i.isMeshLambertMaterial?M(l,i):i.isMeshToonMaterial?T(l,i):i.isMeshPhongMaterial?P(l,i):i.isMeshPhysicalMaterial?C(l,i):i.isMeshStandardMaterial?E(l,i):i.isMeshDepthMaterial?i.displacementMap&&(l.displacementMap.value=i.displacementMap,l.displacementScale.value=i.displacementScale,l.displacementBias.value=i.displacementBias):i.isMeshNormalMaterial&&I(l,i),void 0!==l.ltcMat&&(l.ltcMat.value=Il.LTC_MAT_TEXTURE),void 0!==l.ltcMag&&(l.ltcMag.value=Il.LTC_MAG_TEXTURE),J.upload(Rt,n.uniformsList,l,Y)),h.setValue(Rt,"modelViewMatrix",r.modelViewMatrix),h.setValue(Rt,"normalMatrix",r.normalMatrix),h.setValue(Rt,"modelMatrix",r.matrixWorld),u}function x(t,e){t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var i;if(e.map?i=e.map:e.specularMap?i=e.specularMap:e.displacementMap?i=e.displacementMap:e.normalMap?i=e.normalMap:e.bumpMap?i=e.bumpMap:e.roughnessMap?i=e.roughnessMap:e.metalnessMap?i=e.metalnessMap:e.alphaMap?i=e.alphaMap:e.emissiveMap&&(i=e.emissiveMap),void 0!==i){i.isWebGLRenderTarget&&(i=i.texture);var r=i.offset,n=i.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}function _(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function w(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function S(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*mt,t.scale.value=.5*ft,t.map.value=e.map,null!==e.map){var i=e.map.offset,r=e.map.repeat;t.offsetRepeat.value.set(i.x,i.y,r.x,r.y)}}function A(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function M(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function P(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function T(t,e){P(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function E(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function C(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,E(t,e)}function I(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function R(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}function L(t){for(var e=0,i=0,r=t.length;i<r;i++){var n=t[i];n.castShadow&&(Tt.shadows[e]=n,e++)}Tt.shadows.length=e}function O(t,e){var i,r,n,o,a,s,c,u,h=0,l=0,p=0,d=e.matrixWorldInverse,f=0,m=0,g=0,v=0,y=0;for(i=0,r=t.length;i<r;i++)if(n=t[i],a=n.color,s=n.intensity,c=n.distance,u=n.shadow&&n.shadow.map?n.shadow.map.texture:null,n.isAmbientLight)h+=a.r*s,l+=a.g*s,p+=a.b*s;else if(n.isDirectionalLight)(b=Yt.get(n)).color.copy(n.color).multiplyScalar(n.intensity),b.direction.setFromMatrixPosition(n.matrixWorld),At.setFromMatrixPosition(n.target.matrixWorld),b.direction.sub(At),b.direction.transformDirection(d),b.shadow=n.castShadow,n.castShadow&&(o=n.shadow,b.shadowBias=o.bias,b.shadowRadius=o.radius,b.shadowMapSize=o.mapSize),Tt.directionalShadowMap[f]=u,Tt.directionalShadowMatrix[f]=n.shadow.matrix,Tt.directional[f]=b,f++;else if(n.isSpotLight)(b=Yt.get(n)).position.setFromMatrixPosition(n.matrixWorld),b.position.applyMatrix4(d),b.color.copy(a).multiplyScalar(s),b.distance=c,b.direction.setFromMatrixPosition(n.matrixWorld),At.setFromMatrixPosition(n.target.matrixWorld),b.direction.sub(At),b.direction.transformDirection(d),b.coneCos=Math.cos(n.angle),b.penumbraCos=Math.cos(n.angle*(1-n.penumbra)),b.decay=0===n.distance?0:n.decay,b.shadow=n.castShadow,n.castShadow&&(o=n.shadow,b.shadowBias=o.bias,b.shadowRadius=o.radius,b.shadowMapSize=o.mapSize),Tt.spotShadowMap[g]=u,Tt.spotShadowMatrix[g]=n.shadow.matrix,Tt.spot[g]=b,g++;else if(n.isRectAreaLight)(b=Yt.get(n)).color.copy(a).multiplyScalar(s/(n.width*n.height)),b.position.setFromMatrixPosition(n.matrixWorld),b.position.applyMatrix4(d),Pt.identity(),Mt.copy(n.matrixWorld),Mt.premultiply(d),Pt.extractRotation(Mt),b.halfWidth.set(.5*n.width,0,0),b.halfHeight.set(0,.5*n.height,0),b.halfWidth.applyMatrix4(Pt),b.halfHeight.applyMatrix4(Pt),Tt.rectArea[v]=b,v++;else if(n.isPointLight)(b=Yt.get(n)).position.setFromMatrixPosition(n.matrixWorld),b.position.applyMatrix4(d),b.color.copy(n.color).multiplyScalar(n.intensity),b.distance=n.distance,b.decay=0===n.distance?0:n.decay,b.shadow=n.castShadow,n.castShadow&&(o=n.shadow,b.shadowBias=o.bias,b.shadowRadius=o.radius,b.shadowMapSize=o.mapSize),Tt.pointShadowMap[m]=u,Tt.pointShadowMatrix[m]=n.shadow.matrix,Tt.point[m]=b,m++;else if(n.isHemisphereLight){var b=Yt.get(n);b.direction.setFromMatrixPosition(n.matrixWorld),b.direction.transformDirection(d),b.direction.normalize(),b.skyColor.copy(n.color).multiplyScalar(s),b.groundColor.copy(n.groundColor).multiplyScalar(s),Tt.hemi[y]=b,y++}Tt.ambient[0]=h,Tt.ambient[1]=l,Tt.ambient[2]=p,Tt.directional.length=f,Tt.spot.length=g,Tt.rectArea.length=v,Tt.point.length=m,Tt.hemi.length=y,Tt.hash=f+","+m+","+g+","+v+","+y+","+Tt.shadows.length}function D(){var t=ut;return t>=Dt.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+Dt.maxTextures),ut+=1,t}function N(t){var e;if(t===Sh)return Rt.REPEAT;if(t===Ah)return Rt.CLAMP_TO_EDGE;if(t===Mh)return Rt.MIRRORED_REPEAT;if(t===Ph)return Rt.NEAREST;if(t===Th)return Rt.NEAREST_MIPMAP_NEAREST;if(t===Eh)return Rt.NEAREST_MIPMAP_LINEAR;if(t===Ch)return Rt.LINEAR;if(t===Ih)return Rt.LINEAR_MIPMAP_NEAREST;if(t===Rh)return Rt.LINEAR_MIPMAP_LINEAR;if(t===Lh)return Rt.UNSIGNED_BYTE;if(t===Uh)return Rt.UNSIGNED_SHORT_4_4_4_4;if(t===jh)return Rt.UNSIGNED_SHORT_5_5_5_1;if(t===Gh)return Rt.UNSIGNED_SHORT_5_6_5;if(t===Oh)return Rt.BYTE;if(t===Dh)return Rt.SHORT;if(t===Nh)return Rt.UNSIGNED_SHORT;if(t===kh)return Rt.INT;if(t===Fh)return Rt.UNSIGNED_INT;if(t===Bh)return Rt.FLOAT;if(t===zh&&null!==(e=Ot.get("OES_texture_half_float")))return e.HALF_FLOAT_OES;if(t===$h)return Rt.ALPHA;if(t===Hh)return Rt.RGB;if(t===Wh)return Rt.RGBA;if(t===Xh)return Rt.LUMINANCE;if(t===qh)return Rt.LUMINANCE_ALPHA;if(t===Yh)return Rt.DEPTH_COMPONENT;if(t===Zh)return Rt.DEPTH_STENCIL;if(t===Bu)return Rt.FUNC_ADD;if(t===zu)return Rt.FUNC_SUBTRACT;if(t===Uu)return Rt.FUNC_REVERSE_SUBTRACT;if(t===Vu)return Rt.ZERO;if(t===$u)return Rt.ONE;if(t===Hu)return Rt.SRC_COLOR;if(t===Wu)return Rt.ONE_MINUS_SRC_COLOR;if(t===Xu)return Rt.SRC_ALPHA;if(t===qu)return Rt.ONE_MINUS_SRC_ALPHA;if(t===Yu)return Rt.DST_ALPHA;if(t===Zu)return Rt.ONE_MINUS_DST_ALPHA;if(t===Ku)return Rt.DST_COLOR;if(t===Qu)return Rt.ONE_MINUS_DST_COLOR;if(t===Ju)return Rt.SRC_ALPHA_SATURATE;if((t===Kh||t===Qh||t===Jh||t===tl)&&null!==(e=Ot.get("WEBGL_compressed_texture_s3tc"))){if(t===Kh)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===Qh)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===Jh)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===tl)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===el||t===il||t===rl||t===nl)&&null!==(e=Ot.get("WEBGL_compressed_texture_pvrtc"))){if(t===el)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===il)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===rl)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===nl)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===ol&&null!==(e=Ot.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((t===ju||t===Gu)&&null!==(e=Ot.get("EXT_blend_minmax"))){if(t===ju)return e.MIN_EXT;if(t===Gu)return e.MAX_EXT}return t===Vh&&null!==(e=Ot.get("WEBGL_depth_texture"))?e.UNSIGNED_INT_24_8_WEBGL:0}console.log("THREE.WebGLRenderer",vu);var k=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),F=void 0!==t.context?t.context:null,B=void 0!==t.alpha&&t.alpha,z=void 0===t.depth||t.depth,U=void 0===t.stencil||t.stencil,j=void 0!==t.antialias&&t.antialias,G=void 0===t.premultipliedAlpha||t.premultipliedAlpha,V=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,$=[],H=null,W=new Float32Array(8),X=[],q=[];this.domElement=k,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=ph,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var Y=this,Z=null,K=null,Q=null,tt=-1,et="",nt=null,ot=null,at=new d,st=null,ct=new d,ut=0,ht=k.width,ft=k.height,mt=1,gt=new d(0,0,ht,ft),vt=!1,yt=new d(0,0,ht,ft),bt=new lt,xt=new ve,_t=!1,wt=!1,St=new v,At=new g,Mt=new v,Pt=new v,Tt={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},Et={geometries:0,textures:0},It={frame:0,calls:0,vertices:0,faces:0,points:0};this.info={render:It,memory:Et,programs:null};var Rt;try{var Lt={alpha:B,depth:z,stencil:U,antialias:j,premultipliedAlpha:G,preserveDrawingBuffer:V};if(null===(Rt=F||k.getContext("webgl",Lt)||k.getContext("experimental-webgl",Lt)))throw null!==k.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Rt.getShaderPrecisionFormat&&(Rt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),k.addEventListener("webglcontextlost",n,!1)}catch(t){console.error("THREE.WebGLRenderer: "+t)}var Ot=new ge(Rt);Ot.get("WEBGL_depth_texture"),Ot.get("OES_texture_float"),Ot.get("OES_texture_float_linear"),Ot.get("OES_texture_half_float"),Ot.get("OES_texture_half_float_linear"),Ot.get("OES_standard_derivatives"),Ot.get("ANGLE_instanced_arrays"),Ot.get("OES_element_index_uint")&&(Ct.MaxIndex=4294967296);var Dt=new de(Rt,Ot,t),Nt=new pe(Rt,Ot,N),kt=new le,Ft=new he(Rt,Ot,Nt,kt,Dt,N,Et),Bt=new dt(Rt),Ut=new Wt(Rt,Bt,Et),jt=new qt(Rt,Ut,It),Gt=new ue(this,Dt),Yt=new Xt,Zt=new Vt,Kt=new zt(this,Nt,jt,G),Qt=new me(this);this.info.programs=Gt.programs;var Jt=new Ht(Rt,Ot,It),te=new $t(Rt,Ot,It);i(),this.context=Rt,this.capabilities=Dt,this.extensions=Ot,this.properties=kt,this.renderLists=Zt,this.state=Nt,this.vr=Qt;var ee=new pt(this,Tt,jt,Dt);this.shadowMap=ee;var ie=new rt(this,X),re=new it(this,q);this.getContext=function(){return Rt},this.getContextAttributes=function(){return Rt.getContextAttributes()},this.forceContextLoss=function(){var t=Ot.get("WEBGL_lose_context");t&&t.loseContext()},this.getMaxAnisotropy=function(){return Dt.getMaxAnisotropy()},this.getPrecision=function(){return Dt.precision},this.getPixelRatio=function(){return mt},this.setPixelRatio=function(t){void 0!==t&&(mt=t,this.setSize(ht,ft,!1))},this.getSize=function(){return{width:ht,height:ft}},this.setSize=function(t,e,i){var r=Qt.getDevice();if(r&&r.isPresenting)return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");ht=t,ft=e,k.width=t*mt,k.height=e*mt,!1!==i&&(k.style.width=t+"px",k.style.height=e+"px"),this.setViewport(0,0,t,e)},this.getDrawingBufferSize=function(){return{width:ht*mt,height:ft*mt}},this.setDrawingBufferSize=function(t,e,i){ht=t,ft=e,mt=i,k.width=t*i,k.height=e*i,this.setViewport(0,0,t,e)},this.setViewport=function(t,e,i,r){yt.set(t,ft-e-r,i,r),Nt.viewport(ct.copy(yt).multiplyScalar(mt))},this.setScissor=function(t,e,i,r){gt.set(t,ft-e-r,i,r),Nt.scissor(at.copy(gt).multiplyScalar(mt))},this.setScissorTest=function(t){Nt.setScissorTest(vt=t)},this.getClearColor=Kt.getClearColor,this.setClearColor=Kt.setClearColor,this.getClearAlpha=Kt.getClearAlpha,this.setClearAlpha=Kt.setClearAlpha,this.clear=function(t,e,i){var r=0;(void 0===t||t)&&(r|=Rt.COLOR_BUFFER_BIT),(void 0===e||e)&&(r|=Rt.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=Rt.STENCIL_BUFFER_BIT),Rt.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,i,r){this.setRenderTarget(t),this.clear(e,i,r)},this.resetGLState=r,this.dispose=function(){k.removeEventListener("webglcontextlost",n,!1),Zt.dispose()},this.renderBufferImmediate=function(t,e,i){Nt.initAttributes();var r=kt.get(t);t.hasPositions&&!r.position&&(r.position=Rt.createBuffer()),t.hasNormals&&!r.normal&&(r.normal=Rt.createBuffer()),t.hasUvs&&!r.uv&&(r.uv=Rt.createBuffer()),t.hasColors&&!r.color&&(r.color=Rt.createBuffer());var n=e.getAttributes();if(t.hasPositions&&(Rt.bindBuffer(Rt.ARRAY_BUFFER,r.position),Rt.bufferData(Rt.ARRAY_BUFFER,t.positionArray,Rt.DYNAMIC_DRAW),Nt.enableAttribute(n.position),Rt.vertexAttribPointer(n.position,3,Rt.FLOAT,!1,0,0)),t.hasNormals){if(Rt.bindBuffer(Rt.ARRAY_BUFFER,r.normal),!i.isMeshPhongMaterial&&!i.isMeshStandardMaterial&&!i.isMeshNormalMaterial&&i.shading===Tu)for(var o=0,a=3*t.count;o<a;o+=9){var s=t.normalArray,c=(s[o+0]+s[o+3]+s[o+6])/3,u=(s[o+1]+s[o+4]+s[o+7])/3,h=(s[o+2]+s[o+5]+s[o+8])/3;s[o+0]=c,s[o+1]=u,s[o+2]=h,s[o+3]=c,s[o+4]=u,s[o+5]=h,s[o+6]=c,s[o+7]=u,s[o+8]=h}Rt.bufferData(Rt.ARRAY_BUFFER,t.normalArray,Rt.DYNAMIC_DRAW),Nt.enableAttribute(n.normal),Rt.vertexAttribPointer(n.normal,3,Rt.FLOAT,!1,0,0)}t.hasUvs&&i.map&&(Rt.bindBuffer(Rt.ARRAY_BUFFER,r.uv),Rt.bufferData(Rt.ARRAY_BUFFER,t.uvArray,Rt.DYNAMIC_DRAW),Nt.enableAttribute(n.uv),Rt.vertexAttribPointer(Bt.uv,2,Rt.FLOAT,!1,0,0)),t.hasColors&&i.vertexColors!==Cu&&(Rt.bindBuffer(Rt.ARRAY_BUFFER,r.color),Rt.bufferData(Rt.ARRAY_BUFFER,t.colorArray,Rt.DYNAMIC_DRAW),Nt.enableAttribute(n.color),Rt.vertexAttribPointer(n.color,3,Rt.FLOAT,!1,0,0)),Nt.disableUnusedAttributes(),Rt.drawArrays(Rt.TRIANGLES,0,t.count),t.count=0},this.renderBufferDirect=function(t,i,r,n,o,a){Nt.setMaterial(n);var s=b(t,i,n,o),c=r.id+"_"+s.id+"_"+(!0===n.wireframe),l=!1;c!==et&&(et=c,l=!0);var p=o.morphTargetInfluences;if(void 0!==p){for(var d=[],f=0,m=p.length;f<m;f++){v=p[f];d.push([v,f])}d.sort(u),d.length>8&&(d.length=8);for(var g=r.morphAttributes,f=0,m=d.length;f<m;f++){var v=d[f];if(W[f]=v[0],0!==v[0]){x=v[1];!0===n.morphTargets&&g.position&&r.addAttribute("morphTarget"+f,g.position[x]),!0===n.morphNormals&&g.normal&&r.addAttribute("morphNormal"+f,g.normal[x])}else!0===n.morphTargets&&r.removeAttribute("morphTarget"+f),!0===n.morphNormals&&r.removeAttribute("morphNormal"+f)}for(var f=d.length,y=W.length;f<y;f++)W[f]=0;s.getUniforms().setValue(Rt,"morphTargetInfluences",W),l=!0}var x=r.index,_=r.attributes.position,w=1;!0===n.wireframe&&(x=Ut.getWireframeAttribute(r),w=2);var S,A=Jt;null!==x&&(S=Bt.get(x),(A=te).setIndex(S)),l&&(h(n,s,r),null!==x&&Rt.bindBuffer(Rt.ELEMENT_ARRAY_BUFFER,S.buffer));var M=0;null!==x?M=x.count:void 0!==_&&(M=_.count);var P=r.drawRange.start*w,T=r.drawRange.count*w,E=null!==a?a.start*w:0,C=null!==a?a.count*w:1/0,I=Math.max(P,E),R=Math.min(M,P+T,E+C)-1,L=Math.max(0,R-I+1);if(0!==L){if(o.isMesh)if(!0===n.wireframe)Nt.setLineWidth(n.wireframeLinewidth*e()),A.setMode(Rt.LINES);else switch(o.drawMode){case cl:A.setMode(Rt.TRIANGLES);break;case ul:A.setMode(Rt.TRIANGLE_STRIP);break;case hl:A.setMode(Rt.TRIANGLE_FAN)}else if(o.isLine){var O=n.linewidth;void 0===O&&(O=1),Nt.setLineWidth(O*e()),o.isLineSegments?A.setMode(Rt.LINES):o.isLineLoop?A.setMode(Rt.LINE_LOOP):A.setMode(Rt.LINE_STRIP)}else o.isPoints&&A.setMode(Rt.POINTS);r&&r.isInstancedBufferGeometry?r.maxInstancedCount>0&&A.renderInstances(r,I,L):A.render(I,L)}},this.compile=function(t,e){$=[],t.traverse(function(t){t.isLight&&$.push(t)}),O($,e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var i=0;i<e.material.length;i++)m(e.material[i],t.fog,e);else m(e.material,t.fog,e)})},this.animate=function(t){function e(){t(),(Qt.getDevice()||window).requestAnimationFrame(e)}(Qt.getDevice()||window).requestAnimationFrame(e)},this.render=function(t,e,i,r){if(!e||!e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");et="",tt=-1,nt=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),Qt.enabled&&(e=Qt.getCamera(e)),St.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),bt.setFromMatrix(St),$.length=0,X.length=0,q.length=0,wt=this.localClippingEnabled,_t=xt.init(this.clippingPlanes,wt,e),(H=Zt.get(t,e)).init(),l(t,e,Y.sortObjects),H.finish(),!0===Y.sortObjects&&H.sort(),_t&&xt.beginShadows(),L($),ee.render(t,e),O($,e),_t&&xt.endShadows(),It.frame++,It.calls=0,It.vertices=0,It.faces=0,It.points=0,void 0===i&&(i=null),this.setRenderTarget(i),Kt.render(t,e,r);var n=H.opaque,o=H.transparent;if(t.overrideMaterial){var a=t.overrideMaterial;n.length&&p(n,t,e,a),o.length&&p(o,t,e,a)}else n.length&&p(n,t,e),o.length&&p(o,t,e);ie.render(t,e),re.render(t,e,ct),i&&Ft.updateRenderTargetMipmap(i),Nt.buffers.depth.setTest(!0),Nt.buffers.depth.setMask(!0),Nt.buffers.color.setMask(!0),e.isArrayCamera&&Y.setScissorTest(!1),Qt.enabled&&Qt.submitFrame()},this.setFaceCulling=function(t,e){Nt.setCullFace(t),Nt.setFlipSided(e===_u)},this.allocTextureUnit=D,this.setTexture2D=function(){var t=!1;return function(e,i){e&&e.isWebGLRenderTarget&&(t||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),Ft.setTexture2D(e,i)}}(),this.setTexture=function(){var t=!1;return function(e,i){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),Ft.setTexture2D(e,i)}}(),this.setTextureCube=function(){var t=!1;return function(e,i){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?Ft.setTextureCube(e,i):Ft.setTextureCubeDynamic(e,i)}}(),this.getRenderTarget=function(){return K},this.setRenderTarget=function(t){K=t,t&&void 0===kt.get(t).__webglFramebuffer&&Ft.setupRenderTarget(t);var e,i=t&&t.isWebGLRenderTargetCube;if(t){var r=kt.get(t);e=i?r.__webglFramebuffer[t.activeCubeFace]:r.__webglFramebuffer,at.copy(t.scissor),st=t.scissorTest,ct.copy(t.viewport)}else e=null,at.copy(gt).multiplyScalar(mt),st=vt,ct.copy(yt).multiplyScalar(mt);if(Q!==e&&(Rt.bindFramebuffer(Rt.FRAMEBUFFER,e),Q=e),Nt.scissor(at),Nt.setScissorTest(st),Nt.viewport(ct),i){var n=kt.get(t.texture);Rt.framebufferTexture2D(Rt.FRAMEBUFFER,Rt.COLOR_ATTACHMENT0,Rt.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,n.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,i,r,n,o){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var a=kt.get(t).__webglFramebuffer;if(a){var s=!1;a!==Q&&(Rt.bindFramebuffer(Rt.FRAMEBUFFER,a),s=!0);try{var c=t.texture,u=c.format,h=c.type;if(u!==Wh&&N(u)!==Rt.getParameter(Rt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Lh||N(h)===Rt.getParameter(Rt.IMPLEMENTATION_COLOR_READ_TYPE)||h===Bh&&(Ot.get("OES_texture_float")||Ot.get("WEBGL_color_buffer_float"))||h===zh&&Ot.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");Rt.checkFramebufferStatus(Rt.FRAMEBUFFER)===Rt.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-r&&i>=0&&i<=t.height-n&&Rt.readPixels(e,i,r,n,N(u),N(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&Rt.bindFramebuffer(Rt.FRAMEBUFFER,Q)}}}}function be(t,e){this.name="",this.color=new tt(t),this.density=void 0!==e?e:25e-5}function xe(t,e,i){this.name="",this.color=new tt(t),this.near=void 0!==e?e:1,this.far=void 0!==i?i:1e3}function _e(){gt.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function we(t,e,i,r,n){gt.call(this),this.lensFlares=[],this.positionScreen=new g,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,i,r,n)}function Se(t){nt.call(this),this.type="SpriteMaterial",this.color=new tt(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function Ae(t){gt.call(this),this.type="Sprite",this.material=void 0!==t?t:new Se}function Me(){gt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Pe(t,e){var i=this;if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var r=0,n=this.bones.length;r<n;r++)i.boneInverses.push(new v)}}function Te(){gt.call(this),this.type="Bone"}function Ee(t,e){Bt.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new v,this.bindMatrixInverse=new v;var i=new Pe(this.initBones());this.bind(i,this.matrixWorld),this.normalizeSkinWeights()}function Ce(t){nt.call(this),this.type="LineBasicMaterial",this.color=new tt(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(t)}function Ie(t,e,i){if(1===i)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new Re(t,e);gt.call(this),this.type="Line",this.geometry=void 0!==t?t:new Ct,this.material=void 0!==e?e:new Ce({color:16777215*Math.random()})}function Re(t,e){Ie.call(this,t,e),this.type="LineSegments"}function Le(t,e){Ie.call(this,t,e),this.type="LineLoop"}function Oe(t){nt.call(this),this.type="PointsMaterial",this.color=new tt(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.lights=!1,this.setValues(t)}function De(t,e){gt.call(this),this.type="Points",this.geometry=void 0!==t?t:new Ct,this.material=void 0!==e?e:new Oe({color:16777215*Math.random()})}function Ne(){gt.call(this),this.type="Group"}function ke(t,e,i,r,n,o,a,s,c,u,h,l){p.call(this,null,o,a,s,c,u,r,n,h,l),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Fe(t,e,i,r,n,o,a,s,c){p.call(this,t,e,i,r,n,o,a,s,c),this.needsUpdate=!0}function Be(t){Ct.call(this),this.type="WireframeGeometry";var e,i,r,n,o,a,s,c,u,h,l=[],p=[0,0],d={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e<r;e++){var v=m[e];for(i=0;i<3;i++)s=v[f[i]],c=v[f[(i+1)%3]],p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[u=p[0]+","+p[1]]&&(d[u]={index1:p[0],index2:p[1]})}for(u in d)a=d[u],h=t.vertices[a.index1],l.push(h.x,h.y,h.z),h=t.vertices[a.index2],l.push(h.x,h.y,h.z)}else if(t&&t.isBufferGeometry){var y,b,x,_,w,S,A;if(h=new g,null!==t.index){for(y=t.attributes.position,b=t.index,0===(x=t.groups).length&&(x=[{start:0,count:b.count,materialIndex:0}]),n=0,o=x.length;n<o;++n)for(e=w=(_=x[n]).start,r=w+_.count;e<r;e+=3)for(i=0;i<3;i++)s=b.getX(e+i),c=b.getX(e+(i+1)%3),p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[u=p[0]+","+p[1]]&&(d[u]={index1:p[0],index2:p[1]});for(u in d)a=d[u],h.fromBufferAttribute(y,a.index1),l.push(h.x,h.y,h.z),h.fromBufferAttribute(y,a.index2),l.push(h.x,h.y,h.z)}else for(e=0,r=(y=t.attributes.position).count/3;e<r;e++)for(i=0;i<3;i++)S=3*e+i,h.fromBufferAttribute(y,S),l.push(h.x,h.y,h.z),A=3*e+(i+1)%3,h.fromBufferAttribute(y,A),l.push(h.x,h.y,h.z)}this.addAttribute("position",new Pt(l,3))}function ze(t,e,i){wt.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i},this.fromBufferGeometry(new Ue(t,e,i)),this.mergeVertices()}function Ue(t,e,i){Ct.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:i};var r,n,o=[],a=[],s=[],c=[],u=new g,h=new g,l=new g,p=new g,d=new g,f=e+1;for(r=0;r<=i;r++){var m=r/i;for(n=0;n<=e;n++){var v=n/e;h=t(v,m,h),a.push(h.x,h.y,h.z),v-1e-5>=0?(l=t(v-1e-5,m,l),p.subVectors(h,l)):(l=t(v+1e-5,m,l),p.subVectors(l,h)),m-1e-5>=0?(l=t(v,m-1e-5,l),d.subVectors(h,l)):(l=t(v,m+1e-5,l),d.subVectors(l,h)),u.crossVectors(p,d).normalize(),s.push(u.x,u.y,u.z),c.push(v,m)}}for(r=0;r<i;r++)for(n=0;n<e;n++){var y=r*f+n,b=r*f+n+1,x=(r+1)*f+n+1,_=(r+1)*f+n;o.push(y,b,_),o.push(b,x,_)}this.setIndex(o),this.addAttribute("position",new Pt(a,3)),this.addAttribute("normal",new Pt(s,3)),this.addAttribute("uv",new Pt(c,2))}function je(t,e,i,r){wt.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},this.fromBufferGeometry(new Ge(t,e,i,r)),this.mergeVertices()}function Ge(t,e,i,r){function n(t,e,i,r){var n,o,s=Math.pow(2,r),c=[];for(n=0;n<=s;n++){c[n]=[];var u=t.clone().lerp(i,n/s),h=e.clone().lerp(i,n/s),l=s-n;for(o=0;o<=l;o++)c[n][o]=0===o&&n===s?u:u.clone().lerp(h,o/l)}for(n=0;n<s;n++)for(o=0;o<2*(s-n)-1;o++){var p=Math.floor(o/2);o%2==0?(a(c[n][p+1]),a(c[n+1][p]),a(c[n][p])):(a(c[n][p+1]),a(c[n+1][p+1]),a(c[n+1][p]))}}function o(){for(var t=0;t<f.length;t+=6){var e=f[t+0],i=f[t+2],r=f[t+4],n=Math.max(e,i,r),o=Math.min(e,i,r);n>.9&&o<.1&&(e<.2&&(f[t+0]+=1),i<.2&&(f[t+2]+=1),r<.2&&(f[t+4]+=1))}}function a(t){d.push(t.x,t.y,t.z)}function s(e,i){var r=3*e;i.x=t[r+0],i.y=t[r+1],i.z=t[r+2]}function c(){for(var t=new g,e=new g,i=new g,r=new g,n=new l,o=new l,a=new l,s=0,c=0;s<d.length;s+=9,c+=6){t.set(d[s+0],d[s+1],d[s+2]),e.set(d[s+3],d[s+4],d[s+5]),i.set(d[s+6],d[s+7],d[s+8]),n.set(f[c+0],f[c+1]),o.set(f[c+2],f[c+3]),a.set(f[c+4],f[c+5]),r.copy(t).add(e).add(i).divideScalar(3);var p=h(r);u(n,c+0,t,p),u(o,c+2,e,p),u(a,c+4,i,p)}}function u(t,e,i,r){r<0&&1===t.x&&(f[e]=t.x-1),0===i.x&&0===i.z&&(f[e]=r/2/Math.PI+.5)}function h(t){return Math.atan2(t.z,-t.x)}function p(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}Ct.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},i=i||1;var d=[],f=[];!function(t){for(var i=new g,r=new g,o=new g,a=0;a<e.length;a+=3)s(e[a+0],i),s(e[a+1],r),s(e[a+2],o),n(i,r,o,t)}(r=r||0),function(t){for(var e=new g,i=0;i<d.length;i+=3)e.x=d[i+0],e.y=d[i+1],e.z=d[i+2],e.normalize().multiplyScalar(t),d[i+0]=e.x,d[i+1]=e.y,d[i+2]=e.z}(i),function(){for(var t=new g,e=0;e<d.length;e+=3){t.x=d[e+0],t.y=d[e+1],t.z=d[e+2];var i=h(t)/2/Math.PI+.5,r=p(t)/Math.PI+.5;f.push(i,1-r)}c(),o()}(),this.addAttribute("position",new Pt(d,3)),this.addAttribute("normal",new Pt(d.slice(),3)),this.addAttribute("uv",new Pt(f,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Ve(t,e){wt.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new $e(t,e)),this.mergeVertices()}function $e(t,e){var i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];Ge.call(this,i,r,t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function He(t,e){wt.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new We(t,e)),this.mergeVertices()}function We(t,e){var i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];Ge.call(this,i,r,t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Xe(t,e){wt.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new qe(t,e)),this.mergeVertices()}function qe(t,e){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];Ge.call(this,r,n,t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ye(t,e){wt.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ze(t,e)),this.mergeVertices()}function Ze(t,e){var i=(1+Math.sqrt(5))/2,r=1/i,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];Ge.call(this,n,o,t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ke(t,e,i,r,n,o){wt.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new Qe(t,e,i,r,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function Qe(t,e,i,r,n){function o(n){var o=t.getPointAt(n/e),a=c.normals[n],s=c.binormals[n];for(h=0;h<=r;h++){var u=h/r*Math.PI*2,l=Math.sin(u),f=-Math.cos(u);d.x=f*a.x+l*s.x,d.y=f*a.y+l*s.y,d.z=f*a.z+l*s.z,d.normalize(),v.push(d.x,d.y,d.z),p.x=o.x+i*d.x,p.y=o.y+i*d.y,p.z=o.z+i*d.z,m.push(p.x,p.y,p.z)}}function a(){for(h=1;h<=e;h++)for(u=1;u<=r;u++){var t=(r+1)*(h-1)+(u-1),i=(r+1)*h+(u-1),n=(r+1)*h+u,o=(r+1)*(h-1)+u;b.push(t,i,o),b.push(i,n,o)}}function s(){for(u=0;u<=e;u++)for(h=0;h<=r;h++)f.x=u/e,f.y=h/r,y.push(f.x,f.y)}Ct.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:n},e=e||64,i=i||1,r=r||8,n=n||!1;var c=t.computeFrenetFrames(e,n);this.tangents=c.tangents,this.normals=c.normals,this.binormals=c.binormals;var u,h,p=new g,d=new g,f=new l,m=[],v=[],y=[],b=[];!function(){for(u=0;u<e;u++)o(u);o(!1===n?e:0),s(),a()}(),this.setIndex(b),this.addAttribute("position",new Pt(m,3)),this.addAttribute("normal",new Pt(v,3)),this.addAttribute("uv",new Pt(y,2))}function Je(t,e,i,r,n,o,a){wt.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:n,q:o},void 0!==a&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new ti(t,e,i,r,n,o)),this.mergeVertices()}function ti(t,e,i,r,n,o){function a(t,e,i,r,n){var o=Math.cos(t),a=Math.sin(t),s=i/e*t,c=Math.cos(s);n.x=r*(2+c)*.5*o,n.y=r*(2+c)*a*.5,n.z=r*Math.sin(s)*.5}Ct.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:n,q:o},t=t||100,e=e||40,i=Math.floor(i)||64,r=Math.floor(r)||8,n=n||2,o=o||3;var s,c,u=[],h=[],l=[],p=[],d=new g,f=new g,m=new g,v=new g,y=new g,b=new g,x=new g;for(s=0;s<=i;++s){var _=s/i*n*Math.PI*2;for(a(_,n,o,t,m),a(_+.01,n,o,t,v),b.subVectors(v,m),x.addVectors(v,m),y.crossVectors(b,x),x.crossVectors(y,b),y.normalize(),x.normalize(),c=0;c<=r;++c){var w=c/r*Math.PI*2,S=-e*Math.cos(w),A=e*Math.sin(w);d.x=m.x+(S*x.x+A*y.x),d.y=m.y+(S*x.y+A*y.y),d.z=m.z+(S*x.z+A*y.z),h.push(d.x,d.y,d.z),f.subVectors(d,m).normalize(),l.push(f.x,f.y,f.z),p.push(s/i),p.push(c/r)}}for(c=1;c<=i;c++)for(s=1;s<=r;s++){var M=(r+1)*(c-1)+(s-1),P=(r+1)*c+(s-1),T=(r+1)*c+s,E=(r+1)*(c-1)+s;u.push(M,P,E),u.push(P,T,E)}this.setIndex(u),this.addAttribute("position",new Pt(h,3)),this.addAttribute("normal",new Pt(l,3)),this.addAttribute("uv",new Pt(p,2))}function ei(t,e,i,r,n){wt.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:n},this.fromBufferGeometry(new ii(t,e,i,r,n)),this.mergeVertices()}function ii(t,e,i,r,n){Ct.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:n},t=t||100,e=e||40,i=Math.floor(i)||8,r=Math.floor(r)||6,n=n||2*Math.PI;var o,a,s=[],c=[],u=[],h=[],l=new g,p=new g,d=new g;for(o=0;o<=i;o++)for(a=0;a<=r;a++){var f=a/r*n,m=o/i*Math.PI*2;p.x=(t+e*Math.cos(m))*Math.cos(f),p.y=(t+e*Math.cos(m))*Math.sin(f),p.z=e*Math.sin(m),c.push(p.x,p.y,p.z),l.x=t*Math.cos(f),l.y=t*Math.sin(f),d.subVectors(p,l).normalize(),u.push(d.x,d.y,d.z),h.push(a/r),h.push(o/i)}for(o=1;o<=i;o++)for(a=1;a<=r;a++){var v=(r+1)*o+a-1,y=(r+1)*(o-1)+a-1,b=(r+1)*(o-1)+a,x=(r+1)*o+a;s.push(v,y,x),s.push(y,b,x)}this.setIndex(s),this.addAttribute("position",new Pt(c,3)),this.addAttribute("normal",new Pt(u,3)),this.addAttribute("uv",new Pt(h,2))}function ri(t,e){wt.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new ni(t,e)),this.mergeVertices()}function ni(t,e){void 0!==t&&(Ct.call(this),this.type="ExtrudeBufferGeometry",t=Array.isArray(t)?t:[t],this.addShapeList(t,e),this.computeVertexNormals())}function oi(t,e){wt.call(this),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new ai(t,e)),this.mergeVertices()}function ai(t,e){var i=(e=e||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new wt;var r=i.generateShapes(t,e.size,e.curveSegments);e.amount=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),ni.call(this,r,e),this.type="TextBufferGeometry"}function si(t,e,i,r,n,o,a){wt.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new ci(t,e,i,r,n,o,a)),this.mergeVertices()}function ci(t,e,i,r,n,o,a){Ct.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:a},t=t||50,e=Math.max(3,Math.floor(e)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var s,c,u=(o=void 0!==o?o:0)+(a=void 0!==a?a:Math.PI),h=0,l=[],p=new g,d=new g,f=[],m=[],v=[],y=[];for(c=0;c<=i;c++){var b=[],x=c/i;for(s=0;s<=e;s++){var _=s/e;p.x=-t*Math.cos(r+_*n)*Math.sin(o+x*a),p.y=t*Math.cos(o+x*a),p.z=t*Math.sin(r+_*n)*Math.sin(o+x*a),m.push(p.x,p.y,p.z),d.set(p.x,p.y,p.z).normalize(),v.push(d.x,d.y,d.z),y.push(_,1-x),b.push(h++)}l.push(b)}for(c=0;c<i;c++)for(s=0;s<e;s++){var w=l[c][s+1],S=l[c][s],A=l[c+1][s],M=l[c+1][s+1];(0!==c||o>0)&&f.push(w,S,M),(c!==i-1||u<Math.PI)&&f.push(S,A,M)}this.setIndex(f),this.addAttribute("position",new Pt(m,3)),this.addAttribute("normal",new Pt(v,3)),this.addAttribute("uv",new Pt(y,2))}function ui(t,e,i,r,n,o){wt.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},this.fromBufferGeometry(new hi(t,e,i,r,n,o)),this.mergeVertices()}function hi(t,e,i,r,n,o){Ct.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},t=t||20,e=e||50,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,i=void 0!==i?Math.max(3,i):8;var a,s,c,u=[],h=[],p=[],d=[],f=t,m=(e-t)/(r=void 0!==r?Math.max(1,r):1),v=new g,y=new l;for(s=0;s<=r;s++){for(c=0;c<=i;c++)a=n+c/i*o,v.x=f*Math.cos(a),v.y=f*Math.sin(a),h.push(v.x,v.y,v.z),p.push(0,0,1),y.x=(v.x/e+1)/2,y.y=(v.y/e+1)/2,d.push(y.x,y.y);f+=m}for(s=0;s<r;s++){var b=s*(i+1);for(c=0;c<i;c++){var x=a=c+b,_=a+i+1,w=a+i+2,S=a+1;u.push(x,_,S),u.push(_,w,S)}}this.setIndex(u),this.addAttribute("position",new Pt(h,3)),this.addAttribute("normal",new Pt(p,3)),this.addAttribute("uv",new Pt(d,2))}function li(t,e,i,r){wt.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},this.fromBufferGeometry(new pi(t,e,i,r)),this.mergeVertices()}function pi(t,e,i,r){Ct.call(this),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},e=Math.floor(e)||12,i=i||0,r=r||2*Math.PI,r=xl.clamp(r,0,2*Math.PI);var n,o,a,s=[],c=[],u=[],h=1/e,p=new g,d=new l;for(o=0;o<=e;o++){var f=i+o*h*r,m=Math.sin(f),v=Math.cos(f);for(a=0;a<=t.length-1;a++)p.x=t[a].x*m,p.y=t[a].y,p.z=t[a].x*v,c.push(p.x,p.y,p.z),d.x=o/e,d.y=a/(t.length-1),u.push(d.x,d.y)}for(o=0;o<e;o++)for(a=0;a<t.length-1;a++){var y=n=a+o*t.length,b=n+t.length,x=n+t.length+1,_=n+1;s.push(y,b,_),s.push(b,x,_)}if(this.setIndex(s),this.addAttribute("position",new Pt(c,3)),this.addAttribute("uv",new Pt(u,2)),this.computeVertexNormals(),r===2*Math.PI){var w=this.attributes.normal.array,S=new g,A=new g,M=new g;for(n=e*t.length*3,o=0,a=0;o<t.length;o++,a+=3)S.x=w[a+0],S.y=w[a+1],S.z=w[a+2],A.x=w[n+a+0],A.y=w[n+a+1],A.z=w[n+a+2],M.addVectors(S,A).normalize(),w[a+0]=w[n+a+0]=M.x,w[a+1]=w[n+a+1]=M.y,w[a+2]=w[n+a+2]=M.z}}function di(t,e){wt.call(this),this.type="ShapeGeometry","object"==typeof e&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new fi(t,e)),this.mergeVertices()}function fi(t,e){function i(t){var i,r,c,h=o.length/3,l=t.extractPoints(e),p=l.shape,d=l.holes;if(!1===Bl.isClockWise(p))for(p=p.reverse(),i=0,r=d.length;i<r;i++)c=d[i],!0===Bl.isClockWise(c)&&(d[i]=c.reverse());var f=Bl.triangulateShape(p,d);for(i=0,r=d.length;i<r;i++)c=d[i],p=p.concat(c);for(i=0,r=p.length;i<r;i++){var m=p[i];o.push(m.x,m.y,0),a.push(0,0,1),s.push(m.x,m.y)}for(i=0,r=f.length;i<r;i++){var g=f[i],v=g[0]+h,y=g[1]+h,b=g[2]+h;n.push(v,y,b),u+=3}}var r=this;Ct.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:e},e=e||12;var n=[],o=[],a=[],s=[],c=0,u=0;if(!1===Array.isArray(t))i(t);else for(var h=0;h<t.length;h++)i(t[h]),r.addGroup(c,u,h),c+=u,u=0;this.setIndex(n),this.addAttribute("position",new Pt(o,3)),this.addAttribute("normal",new Pt(a,3)),this.addAttribute("uv",new Pt(s,2))}function mi(t,e){Ct.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1;var i,r,n,o,a=[],s=Math.cos(xl.DEG2RAD*e),c=[0,0],u={},h=["a","b","c"];t.isBufferGeometry?(o=new wt).fromBufferGeometry(t):o=t.clone(),o.mergeVertices(),o.computeFaceNormals();for(var l=o.vertices,p=o.faces,d=0,f=p.length;d<f;d++)for(var m=p[d],g=0;g<3;g++)i=m[h[g]],r=m[h[(g+1)%3]],c[0]=Math.min(i,r),c[1]=Math.max(i,r),void 0===u[n=c[0]+","+c[1]]?u[n]={index1:c[0],index2:c[1],face1:d,face2:void 0}:u[n].face2=d;for(n in u){var v=u[n];if(void 0===v.face2||p[v.face1].normal.dot(p[v.face2].normal)<=s){var y=l[v.index1];a.push(y.x,y.y,y.z),y=l[v.index2],a.push(y.x,y.y,y.z)}}this.addAttribute("position",new Pt(a,3))}function gi(t,e,i,r,n,o,a,s){wt.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new vi(t,e,i,r,n,o,a,s)),this.mergeVertices()}function vi(t,e,i,r,n,o,a,s){function c(i){var n,o,c,v=new l,x=new g,_=0,w=!0===i?t:e,S=!0===i?1:-1;for(o=m,n=1;n<=r;n++)p.push(0,y*S,0),d.push(0,S,0),f.push(.5,.5),m++;for(c=m,n=0;n<=r;n++){var A=n/r*s+a,M=Math.cos(A),P=Math.sin(A);x.x=w*P,x.y=y*S,x.z=w*M,p.push(x.x,x.y,x.z),d.push(0,S,0),v.x=.5*M+.5,v.y=.5*P*S+.5,f.push(v.x,v.y),m++}for(n=0;n<r;n++){var T=o+n,E=c+n;!0===i?h.push(E,E+1,T):h.push(E+1,E,T),_+=3}u.addGroup(b,_,!0===i?1:2),b+=_}Ct.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s};var u=this;t=void 0!==t?t:20,e=void 0!==e?e:20,i=void 0!==i?i:100,r=Math.floor(r)||8,n=Math.floor(n)||1,o=void 0!==o&&o,a=void 0!==a?a:0,s=void 0!==s?s:2*Math.PI;var h=[],p=[],d=[],f=[],m=0,v=[],y=i/2,b=0;!function(){var o,c,l=new g,x=new g,_=0,w=(e-t)/i;for(c=0;c<=n;c++){var S=[],A=c/n,M=A*(e-t)+t;for(o=0;o<=r;o++){var P=o/r,T=P*s+a,E=Math.sin(T),C=Math.cos(T);x.x=M*E,x.y=-A*i+y,x.z=M*C,p.push(x.x,x.y,x.z),l.set(E,w,C).normalize(),d.push(l.x,l.y,l.z),f.push(P,1-A),S.push(m++)}v.push(S)}for(o=0;o<r;o++)for(c=0;c<n;c++){var I=v[c][o],R=v[c+1][o],L=v[c+1][o+1],O=v[c][o+1];h.push(I,R,O),h.push(R,L,O),_+=6}u.addGroup(b,_,0),b+=_}(),!1===o&&(t>0&&c(!0),e>0&&c(!1)),this.setIndex(h),this.addAttribute("position",new Pt(p,3)),this.addAttribute("normal",new Pt(d,3)),this.addAttribute("uv",new Pt(f,2))}function yi(t,e,i,r,n,o,a){gi.call(this,0,t,e,i,r,n,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function bi(t,e,i,r,n,o,a){vi.call(this,0,t,e,i,r,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function xi(t,e,i,r){wt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new _i(t,e,i,r)),this.mergeVertices()}function _i(t,e,i,r){Ct.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},t=t||50,e=void 0!==e?Math.max(3,e):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,o,a=[],s=[],c=[],u=[],h=new g,p=new l;for(s.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,n=3;o<=e;o++,n+=3){var d=i+o/e*r;h.x=t*Math.cos(d),h.y=t*Math.sin(d),s.push(h.x,h.y,h.z),c.push(0,0,1),p.x=(s[n]/t+1)/2,p.y=(s[n+1]/t+1)/2,u.push(p.x,p.y)}for(n=1;n<=e;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new Pt(s,3)),this.addAttribute("normal",new Pt(c,3)),this.addAttribute("uv",new Pt(u,2))}function wi(t){ot.call(this,{uniforms:Rl.merge([Il.lights,{opacity:{value:1}}]),vertexShader:Ll.shadow_vert,fragmentShader:Ll.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}}}),this.setValues(t)}function Si(t){ot.call(this,t),this.type="RawShaderMaterial"}function Ai(t){nt.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new tt(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new l(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Mi(t){Ai.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function Pi(t){nt.call(this),this.type="MeshPhongMaterial",this.color=new tt(16777215),this.specular=new tt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new l(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ch,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ti(t){Pi.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Ei(t){nt.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new l(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ci(t){nt.call(this),this.type="MeshLambertMaterial",this.color=new tt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ch,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ii(t){nt.call(this),this.type="LineDashedMaterial",this.color=new tt(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(t)}function Ri(t,e,i){var r=this,n=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){a++,!1===n&&void 0!==r.onStart&&r.onStart(t,o,a),n=!0},this.itemEnd=function(t){o++,void 0!==r.onProgress&&r.onProgress(t,o,a),o===a&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)}}function Li(t){this.manager=void 0!==t?t:Gl}function Oi(t){this.manager=void 0!==t?t:Gl,this._parser=null}function Di(t){this.manager=void 0!==t?t:Gl,this._parser=null}function Ni(t){this.manager=void 0!==t?t:Gl}function ki(t){this.manager=void 0!==t?t:Gl}function Fi(t){this.manager=void 0!==t?t:Gl}function Bi(t,e){gt.call(this),this.type="Light",this.color=new tt(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function zi(t,e,i){Bi.call(this,t,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(gt.DefaultUp),this.updateMatrix(),this.groundColor=new tt(e)}function Ui(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new l(512,512),this.map=null,this.matrix=new v}function ji(){Ui.call(this,new bt(50,1,.5,500))}function Gi(t,e,i,r,n,o){Bi.call(this,t,e),this.type="SpotLight",this.position.copy(gt.DefaultUp),this.updateMatrix(),this.target=new gt,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new ji}function Vi(t,e,i,r){Bi.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==r?r:1,this.shadow=new Ui(new bt(90,1,.5,500))}function $i(){Ui.call(this,new yt(-5,5,5,-5,.5,500))}function Hi(t,e){Bi.call(this,t,e),this.type="DirectionalLight",this.position.copy(gt.DefaultUp),this.updateMatrix(),this.target=new gt,this.shadow=new $i}function Wi(t,e){Bi.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Xi(t,e,i,r){Bi.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==i?i:10,this.height=void 0!==r?r:10}function qi(t,e,i,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function Yi(t,e,i,r){qi.call(this,t,e,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Zi(t,e,i,r){qi.call(this,t,e,i,r)}function Ki(t,e,i,r){qi.call(this,t,e,i,r)}function Qi(t,e,i,r){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=Vl.convertArray(e,this.TimeBufferType),this.values=Vl.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()}function Ji(t,e,i,r){Qi.call(this,t,e,i,r)}function tr(t,e,i,r){qi.call(this,t,e,i,r)}function er(t,e,i,r){Qi.call(this,t,e,i,r)}function ir(t,e,i,r){Qi.call(this,t,e,i,r)}function rr(t,e,i,r){Qi.call(this,t,e,i,r)}function nr(t,e,i){Qi.call(this,t,e,i)}function or(t,e,i,r){Qi.call(this,t,e,i,r)}function ar(t,e,i,r){Qi.apply(this,arguments)}function sr(t,e,i){this.name=t,this.tracks=i,this.duration=void 0!==e?e:-1,this.uuid=xl.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function cr(t){this.manager=void 0!==t?t:Gl,this.textures={}}function ur(t){this.manager=void 0!==t?t:Gl}function hr(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function lr(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:Gl,this.withCredentials=!1}function pr(t){this.manager=void 0!==t?t:Gl,this.texturePath=""}function dr(t,e,i,r,n){var o=.5*(r-e),a=.5*(n-i),s=t*t;return(2*i-2*r+o+a)*(t*s)+(-3*i+3*r-2*o-a)*s+o*t+i}function fr(t,e){var i=1-t;return i*i*e}function mr(t,e){return 2*(1-t)*t*e}function gr(t,e){return t*t*e}function vr(t,e,i,r){return fr(t,e)+mr(t,i)+gr(t,r)}function yr(t,e){var i=1-t;return i*i*i*e}function br(t,e){var i=1-t;return 3*i*i*t*e}function xr(t,e){return 3*(1-t)*t*t*e}function _r(t,e){return t*t*t*e}function wr(t,e,i,r,n){return yr(t,e)+br(t,i)+xr(t,r)+_r(t,n)}function Sr(){this.arcLengthDivisions=200}function Ar(t,e){Sr.call(this),this.v1=t,this.v2=e}function Mr(){Sr.call(this),this.curves=[],this.autoClose=!1}function Pr(t,e,i,r,n,o,a,s){Sr.call(this),this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function Tr(t){Sr.call(this),this.points=void 0===t?[]:t}function Er(t,e,i,r){Sr.call(this),this.v0=t,this.v1=e,this.v2=i,this.v3=r}function Cr(t,e,i){Sr.call(this),this.v0=t,this.v1=e,this.v2=i}function Ir(t){Mr.call(this),this.currentPoint=new l,t&&this.fromPoints(t)}function Rr(){Ir.apply(this,arguments),this.holes=[]}function Lr(){this.subPaths=[],this.currentPath=null}function Or(t){this.data=t}function Dr(t){this.manager=void 0!==t?t:Gl}function Nr(t){this.manager=void 0!==t?t:Gl}function kr(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new bt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new bt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Fr(){gt.call(this),this.type="AudioListener",this.context=Kl.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Br(t){gt.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function zr(t){Br.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Ur(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function jr(t,e,i){this.binding=t,this.valueSize=i;var r,n=Float64Array;switch(e){case"quaternion":r=this._slerp;break;case"string":case"bool":n=Array,r=this._select;break;default:r=this._lerp}this.buffer=new n(4*i),this._mixBufferRegion=r,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function Gr(t,e,i){var r=i||Vr.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function Vr(t,e,i){this.path=e,this.parsedPath=i||Vr.parseTrackName(e),this.node=Vr.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function $r(t){var e=arguments;this.uuid=xl.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var i={};this._indicesByUUID=i;for(var r=0,n=arguments.length;r!==n;++r)i[e[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var o=this;this.stats={objects:{get total(){return o._objects.length},get inUse(){return this.total-o.nCachedObjects_}},get bindingsPerObject(){return o._bindings.length}}}function Hr(t,e,i){this._mixer=t,this._clip=e,this._localRoot=i||null;for(var r=e.tracks,n=r.length,o=new Array(n),a={endingStart:sl,endingEnd:sl},s=0;s!==n;++s){var c=r[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=al,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Wr(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Xr(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function qr(){Ct.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Yr(t,e,i,r){this.uuid=xl.generateUUID(),this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===r}function Zr(t,e){this.uuid=xl.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Kr(t,e,i){Zr.call(this,t,e),this.meshPerAttribute=i||1}function Qr(t,e,i){St.call(this,t,e),this.meshPerAttribute=i||1}function Jr(t,e,i,r){this.ray=new Nt(t,e),this.near=i||0,this.far=r||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function tn(t,e){return t.distance-e.distance}function en(t,e,i,r){if(!1!==t.visible&&(t.raycast(e,i),!0===r))for(var n=t.children,o=0,a=n.length;o<a;o++)en(n[o],e,i,!0)}function rn(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}function nn(t,e,i){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==i?i:0,this}function on(t,e,i){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==i?i:0,this}function an(t,e,i,r){this.object=t,this.size=void 0!==e?e:1;var n=void 0!==i?i:16711680,o=void 0!==r?r:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=3*s.faces.length:s&&s.isBufferGeometry&&(a=s.attributes.normal.count);var c=new Ct,u=new Pt(2*a*3,3);c.addAttribute("position",u),Re.call(this,c,new Ce({color:n,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function sn(t){var e=[];t&&t.isBone&&e.push(t);for(var i=0;i<t.children.length;i++)e.push.apply(e,sn(t.children[i]));return e}function cn(t){for(var e=sn(t),i=new Ct,r=[],n=[],o=new tt(0,0,1),a=new tt(0,1,0),s=0;s<e.length;s++){var c=e[s];c.parent&&c.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(o.r,o.g,o.b),n.push(a.r,a.g,a.b))}i.addAttribute("position",new Pt(r,3)),i.addAttribute("color",new Pt(n,3));var u=new Ce({vertexColors:Ru,depthTest:!1,depthWrite:!1,transparent:!0});Re.call(this,i,u),this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.onBeforeRender()}function un(t,e){gt.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;var i=new We(e);i.rotateY(.5*Math.PI);var r=new Dt({vertexColors:Ru,wireframe:!0}),n=i.getAttribute("position"),o=new Float32Array(3*n.count);i.addAttribute("color",new St(o,3)),this.add(new Bt(i,r)),this.update()}function hn(t,e,i,r){this.object=t,this.size=void 0!==e?e:1;var n=void 0!==i?i:16776960,o=void 0!==r?r:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=s.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var c=new Ct,u=new Pt(2*a*3,3);c.addAttribute("position",u),Re.call(this,c,new Ce({color:n,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function ln(t){function e(t,e,r){i(t,r),i(e,r)}function i(t,e){o.push(0,0,0),a.push(e.r,e.g,e.b),void 0===s[t]&&(s[t]=[]),s[t].push(o.length/3-1)}var r=new Ct,n=new Ce({color:16777215,vertexColors:Iu}),o=[],a=[],s={},c=new tt(16755200),u=new tt(16711680),h=new tt(43775),l=new tt(16777215),p=new tt(3355443);e("n1","n2",c),e("n2","n4",c),e("n4","n3",c),e("n3","n1",c),e("f1","f2",c),e("f2","f4",c),e("f4","f3",c),e("f3","f1",c),e("n1","f1",c),e("n2","f2",c),e("n3","f3",c),e("n4","f4",c),e("p","n1",u),e("p","n2",u),e("p","n3",u),e("p","n4",u),e("u1","u2",h),e("u2","u3",h),e("u3","u1",h),e("c","t",l),e("p","c",p),e("cn1","cn2",p),e("cn3","cn4",p),e("cf1","cf2",p),e("cf3","cf4",p),r.addAttribute("position",new Pt(o,3)),r.addAttribute("color",new Pt(a,3)),Re.call(this,r,n),this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}function pn(){function t(t,o,a,s){e=t,i=a,r=-3*t+3*o-2*a-s,n=2*t-2*o+a+s}var e=0,i=0,r=0,n=0;return{initCatmullRom:function(e,i,r,n,o){t(i,r,o*(r-e),o*(n-i))},initNonuniformCatmullRom:function(e,i,r,n,o,a,s){var c=(i-e)/o-(r-e)/(o+a)+(r-i)/a,u=(r-i)/a-(n-i)/(a+s)+(n-r)/s;t(i,r,c*=a,u*=a)},calc:function(t){var o=t*t;return e+i*t+r*o+n*(o*t)}}}function dn(t){Sr.call(this),t.length<2&&console.warn("THREE.CatmullRomCurve3: Points array needs at least two entries."),this.points=t||[],this.closed=!1}function fn(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),dn.call(this,t),this.type="catmullrom"}function mn(t){if("undefined"!=typeof window){var e=new RegExp(t+"=([^&#=]*)").exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}}function gn(t,e){return void 0!==t?t:e}function vn(){var t=window.location.protocol;return null===t.match(/http(s)?:/gi)?"http:":t}function yn(){if("undefined"==typeof window)return!1;var t=window.navigator.userAgent;return/Opera|OPR/.test(t)?"Opera":/Chrome/i.test(t)?"Chrome":/Firefox/i.test(t)?"Firefox":/Mobile(\/.*)? Safari/i.test(t)?"Mobile Safari":/MSIE/i.test(t)?"Internet Explorer":!!/Safari/i.test(t)&&"Safari"}function bn(t){var e=window.location,i=e.pathname,r=i.substring(0,i.lastIndexOf("/")+1);return e.origin+r+t}function xn(t,e){function i(t){window.open(t,"_blank")||(window.location.href=t)}function r(t){i(o?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"))}if(t){e=e||"download";var n="Safari"===yn(),o=/CriOS\/[\d]+/.test(window.navigator.userAgent),a=document.createElement("a");if("undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(t,e);else if((n||o)&&window.FileReader)if(t instanceof window.Blob){var s=new window.FileReader;s.onloadend=function(){r(s.result)},s.readAsDataURL(t)}else r(t);else t instanceof window.Blob&&(t=window.URL.createObjectURL(t)),"download"in a?(a.style.display="hidden",document.body.appendChild(a),a.href=t,a.download=e,a.target="_blank",a.click(),document.body.removeChild(a)):i(t),t instanceof window.Blob&&window.URL.revokeObjectURL(t)}}function _n(t){var e,i,r,n=["gz"],o=(e="undefined"!=typeof window&&t instanceof window.File||"undefined"!=typeof window&&t instanceof window.Blob?t.name||"":t).lastIndexOf("?"),a=(e=e.substring(0,-1===o?e.length:o)).replace(/^.*[\\/]/,""),s=a.substring(0,a.lastIndexOf(".")),c=a.split("."),u=c.length>1?c.pop().toLowerCase():"",h=e.match(/^(.+):\/\/(.+)$/);h&&(r=h[1].toLowerCase(),e=h[2]);var l=e.substring(0,e.lastIndexOf("/")+1);if(n.includes(u)){i=u;var p=e.length-u.length-1;u=e.substr(0,p).split(".").pop().toLowerCase();var d=s.length-u.length-1;s=s.substr(0,d)}else i=!1;return{path:e,name:a,ext:u,base:s,dir:l,compressed:i,protocol:r,src:t}}function wn(t,e,i){var r,n,o,a=null,s=0;i||(i={});var c=function(){s=!1===i.leading?0:Date.now(),a=null,o=t.apply(r,n),a||(r=n=null)};return function(){var u=Date.now();s||!1!==i.leading||(s=u);var h=e-(u-s);return r=this,n=arguments,h<=0||h>e?(a&&(clearTimeout(a),a=null),s=u,o=t.apply(r,n),a||(r=n=null)):a||!1===i.trailing||(a=setTimeout(c,h)),o}}function Sn(t,e){return t<e?-1:t>e?1:0}function An(t,e,i){void 0===i&&(i=Sn);for(var r=0,n=t.length-1;r<=n;){var o=r+n>>1,a=i(e,t[o]);if(a>0)r=o+1;else{if(!(a<0))return o;n=o-1}}return-r-1}function Mn(t,e){var i=t.length-1;if(t[i]<e)return-1;for(var r=0;r<=i;){var n=r+i>>1;t[n]>=e?i=n-1:r=n+1}return i+1}function Pn(t,e){if(t[0]>e)return-1;for(var i=0,r=t.length-1;i<=r;){var n=i+r>>1;t[n]>e?r=n-1:i=n+1}return i-1}function Tn(t,e,i){var r=Mn(t,e),n=Pn(t,i);return-1===r||-1===n||r>n?0:n-r+1}function En(t){return t.sort().filter(function(t,e,i){return 0===e||t!==i[e-1]})}function Cn(t){if(t.length>28672){for(var e=[],i=0;i<t.length;i+=28672)e.push(String.fromCharCode.apply(null,t.subarray(i,i+28672)));return e.join("")}return String.fromCharCode.apply(null,t)}function In(t,e,i){e=void 0!==e?e:10485760,i=void 0!==i?i:"\n";for(var r="",n=[],o=0;o<t.length;o+=e){var a=Cn(t.subarray(o,o+e)),s=a.lastIndexOf(i);if(-1===s)r+=a;else{var c=r+a.substr(0,s);n=n.concat(c.split(i)),r=s===a.length-i.length?"":a.substr(s+i.length)}}return""!==r&&n.push(r),n}function Rn(t,e){switch(t){case"int8":return new Int8Array(e);case"int16":return new Int16Array(e);case"int32":return new Int32Array(e);case"uint8":return new Uint8Array(e);case"uint16":return new Uint16Array(e);case"uint32":return new Uint32Array(e);case"float32":return new Float32Array(e);default:throw new Error("arrayType unknown: "+t)}}function Ln(t,e){return new(e>65535?Uint32Array:Uint16Array)(t)}function On(t,e){return t instanceof e?t:new e(t)}function Dn(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function Nn(t){return Dn(t,l)}function kn(t){return Dn(t,g)}function Fn(t){return Dn(t,v)}function Bn(t){return Dn(t,m)}function zn(t){return On(t,Float32Array)}function Un(t){return gn(t,"").toString().toLowerCase()}function jn(t){var e=t;return t.forEach(function(t){t.__deps&&Array.prototype.push.apply(e,jn(t.__deps))}),e}function Gn(t){return En(jn(t)).map(function(t){return t.toString()}).join("\n\n\n")}function Vn(t){var e=t.data.__name,i=t.data.__postId;if(void 0===e)console.error("message __name undefined");else if(void 0===self.func)console.error("worker func undefined",e);else{var r=function(t,e){t=t||{},void 0!==i&&(t.__postId=i);try{self.postMessage(t,e)}catch(e){console.error("self.postMessage:",e),self.postMessage(t)}};self.func(t,r)}}function $n(t,e){var i="'use strict';\n\n"+Gn(e);return i+="\n\n\nself.func = "+t.toString()+";",i+="\n\n\nself.onmessage = "+Vn.toString()+";",new window.Blob([i],{type:"application/javascript"})}function Hn(t){return.01745*t}function Wn(t){return 57.29578*t}function Xn(){for(var t,e=0,i=0;i<36;i++)8===i||13===i||18===i||23===i?Rd[i]="-":14===i?Rd[i]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Rd[i]=Id[19===i?3&t|8:t]);return Rd.join("")}function qn(t){return t-=t>>1&1431655765,16843009*((t=(858993459&t)+(t>>2&858993459))+(t>>4)&252645135)>>24}function Yn(t,e,i){return(t-e)/(i-e)}function Zn(t,e,i){return Math.max(e,Math.min(i,t))}function Kn(t){return Zn(t,0,100)}function Qn(t){return Zn(t,0,1)}function Jn(t,e,i){return t+(e-t)*i}function to(t,e,i,r,n,o){var a=(i-t)*o,s=(r-e)*o,c=n*n;return(2*e-2*i+a+s)*(n*c)+(-3*e+3*i-2*a-s)*c+a*n+e}function eo(t,e,i){return(i=Qn(Yn(i,t,e)))*i*(3-2*i)}function io(t,e,i){if(t>e)return t;var r=t/e;return((2*i-e)*r+(2*e-3*i))*r*r+i}function ro(t,e,i,r,n){this._listener=e,this._isOnce=i,this.context=r,this._signal=t,this._priority=n||0}function no(t,e){if("function"!=typeof t)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}function oo(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){oo.prototype.dispatch.apply(t,arguments)}}function ao(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===Nd.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===Nd.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===Nd.BONDED&&!t.isBonded())return!1;if(e.keyword===Nd.RING&&!t.isRing())return!1;if(e.keyword===Nd.HETERO&&!t.isHetero())return!1;if(e.keyword===Nd.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Nd.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Nd.RNA&&!t.isRna())return!1;if(e.keyword===Nd.DNA&&!t.isDna())return!1;if(e.keyword===Nd.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Nd.WATER&&!t.isWater())return!1;if(e.keyword===Nd.HELIX&&!t.isHelix())return!1;if(e.keyword===Nd.SHEET&&!t.isSheet())return!1;if(e.keyword===Nd.TURN&&!t.isTurn())return!1;if(e.keyword===Nd.ION&&!t.isIon())return!1;if(e.keyword===Nd.SACCHARIDE&&!t.isSaccharide())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&&An(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)return!1}else if(e.resno!==t.resno)return!1;return(void 0===e.inscode||e.inscode===t.inscode)&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function so(t,e){if(void 0===e.resname&&void 0===e.resno&&void 0===e.inscode&&void 0===e.sstruc&&void 0===e.model&&void 0===e.chainname&&void 0===e.atomindex&&(void 0===e.keyword||Fd.includes(e.keyword)))return-1;if(void 0!==e.keyword){if(e.keyword===Nd.HETERO&&!t.isHetero())return!1;if(e.keyword===Nd.PROTEIN&&!t.isProtein())return!1;if(e.keyword===Nd.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===Nd.RNA&&!t.isRna())return!1;if(e.keyword===Nd.DNA&&!t.isDna())return!1;if(e.keyword===Nd.POLYMER&&!t.isPolymer())return!1;if(e.keyword===Nd.WATER&&!t.isWater())return!1;if(e.keyword===Nd.HELIX&&!t.isHelix())return!1;if(e.keyword===Nd.SHEET&&!t.isSheet())return!1;if(e.keyword===Nd.TURN&&!t.isTurn())return!1;if(e.keyword===Nd.ION&&!t.isIon())return!1;if(e.keyword===Nd.SACCHARIDE&&!t.isSaccharide())return!1}if(void 0!==e.atomindex&&0===Tn(e.atomindex,t.atomOffset,t.atomEnd))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)return!1}else if(e.resno!==t.resno)return!1;return(void 0===e.inscode||e.inscode===t.inscode)&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function co(t,e){if(!(void 0!==e.chainname||void 0!==e.model||void 0!==e.atomindex||void 0!==e.keyword&&Bd.includes(e.keyword)&&t.entity))return-1;if(void 0!==e.keyword){if(e.keyword===Nd.POLYMER&&!t.entity.isPolymer())return!1;if(e.keyword===Nd.WATER&&!t.entity.isWater())return!1}return(void 0===e.atomindex||0!==Tn(e.atomindex,t.atomOffset,t.atomEnd))&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function uo(t,e){return void 0===e.model&&void 0===e.atomindex?-1:(void 0===e.atomindex||0!==Tn(e.atomindex,t.atomOffset,t.atomEnd))&&(void 0===e.model||e.model===t.index)}function ho(t){af=t}function lo(t){sf=t}function po(e){t.Debug=e}function fo(t){var e=_n(t),i=pf.get(e.protocol);return i&&!(e=_n(i.getUrl(e.src))).ext&&i.getExt&&(e.ext=i.getExt(t)),e}function mo(t,e){var i,r=Object.assign(fo(t),e);return ff.names.includes(r.ext)?i=Pf:["ngl","js"].includes(r.ext)?i=Cf:"plugin"===r.ext&&(i=If),i?new i(r.src,r).load():Promise.reject(new Error("autoLoad: ext '"+r.ext+"' unknown"))}function go(){var t=arguments[0],e=go.cache;return e[t]&&e.hasOwnProperty(t)||(e[t]=go.parse(t)),go.format.call(null,e[t],arguments)}function vo(t){return"number"==typeof t?"number":"string"==typeof t?"string":Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function yo(t,e){return e>=0&&e<=7&&Lf[t]?Lf[t][e]:Array(e+1).join(t)}function bo(t,e){function i(){d=[],n(),o(),a()}function r(t,e){return void 0!==t?t:e}function n(){d.push(go("TITEL %-74s",t.name))}function o(){p.forEach(function(t){d.push(go("REMARK %-73s",t))}),t.trajectory&&(d.push(go("REMARK %-73s","Trajectory '"+t.trajectory.name+"'")),d.push(go("REMARK %-73s","Frame "+t.trajectory.frame)))}function a(){var e=1,i=1;t.eachModel(function(t){d.push(go("MODEL %-74d",i++)),t.eachAtom(function(t){var i=t.hetero?m:f,n=l?e:t.serial,o=t.atomname;1===o.length&&(o=" "+o),d.push(go(i,n,o,t.resname,r(t.chainname," "),t.resno,t.x,t.y,t.z,r(t.occurence,1),r(t.bfactor,0),r(t.segid,""),r(t.element,""))),e+=1}),d.push(go("%-80s","ENDMDL")),i+=1}),d.push(go("%-80s","END"))}function s(){return i(),d.join("\n")}function c(){return new window.Blob([s()],{type:"text/plain"})}function u(t,e){var i=(t=t||"structure")+"."+(e=e||"pdb");xn(c(),i)}var h=Object.assign({},e),l=void 0===h.renumberSerial||h.renumberSerial,p=h.remarks||[];Array.isArray(p)||(p=[p]);var d,f="ATOM  %5d %-4s %3s %1s%4d    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s",m="HETATM%5d %-4s %3s %1s%4d    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s";this.getString=s,this.getBlob=c,this.download=u}function xo(){this.signals={updated:new oo},this.begin(),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}function _o(t){if(void 0===t)return"";var e=[];for(var i in t){var r=t[i];!1!==r&&e.push("#define "+i+" "+r)}return e.join("\n")+"\n"}function wo(t,e){e=e||{};var i=t+"|";for(var r in e)i+=r+":"+e[r];if(!Nf[i]){var n=_o(e),o=mf.get("shader/"+t);if(!o)throw new Error("empty shader, '"+t+"'");o=o.replace(Df,function(t,e){var i="shader/chunk/"+e+".glsl";return mf.get(i)||Ll[e]||""}),Nf[i]=n+o}return Nf[i]}function So(t,e,i,r){function n(e){var r=e%u,n=Math.floor(e/u),o=r*m,a=n*g;i.camera.setViewOffset(m*u,g*u,o,a,m,g),i.render(),h?v.drawImage(t.domElement,Math.floor(o/2),Math.floor(a/2),Math.ceil(m/2),Math.ceil(g/2)):v.drawImage(t.domElement,Math.floor(o),Math.floor(a),Math.ceil(m),Math.ceil(g)),"function"==typeof l&&l(e+1,d,!1)}function o(){i.setSampling(y),i.camera.view=null,"function"==typeof p&&p(d+1,d,!1)}function a(){for(var t=0;t<=d;++t)t===d?o():n(t)}function s(){function t(){e===d?o():n(e),e+=1}for(var e=0,i=0;i<=d;++i)setTimeout(t,0,i)}var c=r||{},u=void 0!==c.factor?c.factor:2,h=void 0!==c.antialias&&c.antialias,l=c.onProgress,p=c.onFinish;h&&(u*=2);var d=u*u,f=document.createElement("canvas"),m=i.width,g=i.height;h?(f.width=m*u/2,f.height=g*u/2):(f.width=m*u,f.height=g*u);var v=f.getContext("2d"),y=i.sampleLevel;i.setSampling(-1),this.render=a,this.renderAsync=s,this.canvas=f}function Ao(t,e,i,r,n){i=i||1,r=r||0;var o,a,s=n?n.length:t.length/i,c=0,u=0;if(n)for(a=0;a<s;++a)o=(t[n[a]*i+r]+e)%e/e*Gf-Math.PI,c+=Math.cos(o),u+=Math.sin(o);else for(a=r;a<s;a+=i)o=(t[a]+e)%e/e*Gf-Math.PI,c+=Math.cos(o),u+=Math.sin(o);return c/=s,u/=s,(Math.atan2(u,c)+Math.PI)/Gf*e}function Mo(t,e,i,r){var n=t.length;i=i||new Float32Array(n),r=r||0;for(var o=0;o<n;o+=3)i[r+o+0]=(t[o+0]+e[o+0])/2,i[r+o+1]=(t[o+1]+e[o+1])/2,i[r+o+2]=(t[o+2]+e[o+2])/2;return i}function Po(t,e,i){for(var r=i||new Float32Array(t),n=0;n<t;++n)r[n]=e;return r}function To(t,e,i,r,n){for(var o,a=n||new Float32Array(3*t),s=0;s<t;++s)a[(o=3*s)+0]=e,a[o+1]=i,a[o+2]=r;return a}function Eo(t,e){var i=t.length;e=e||new g;for(var r=0;r<i;r+=3)e.x+=t[r],e.y+=t[r+1],e.z+=t[r+2];return e.divideScalar(i/3),e}function Co(t){for(var e=new Float32Array(t),i=0;i<t;++i)e[i]=i;return e}function Io(t,e,i,r){void 0===i&&(i=0);for(var n=r||new Float32Array(t*e),o=0;o<t;++o)for(var a=i+o*e,s=0;s<e;++s)n[a+s]=o;return n}function Ro(t,e){for(var i=t.length,r=new Float32Array(i),n=0;n<i;n++)r[n]=Math.min(t[n],e[n]);return r}function Lo(t,e,i,r,n){for(var o=0;o<n;++o)e[r+o]=t[i+o]}function Oo(t,e,i,r){Lo(t,t,e,i,r)}function Do(t,e,i,r){function n(e,i){p=t[e],t[e]=t[i],t[i]=p}e=e||function(t,e){return t>e?1:t<e?-1:0};for(var o,a,s=[],c=-1,u=i=i||0,h=r=(r||t.length)-1,l=0,p=0;;)if(h-u<=25){for(a=u+1;a<=h;++a){for(l=t[a],o=a-1;o>=u&&e(t[o],l)>0;)t[o+1]=t[o],--o;t[o+1]=l}if(-1===c)break;h=s[c--],u=s[c--]}else{for(a=h,n(u+h>>1,o=u+1),e(t[u],t[h])>0&&n(u,h),e(t[o],t[h])>0&&n(o,h),e(t[u],t[o])>0&&n(u,o),l=t[o];;){do{o++}while(e(t[o],l)<0);do{a--}while(e(t[a],l)>0);if(a<o)break;n(o,a)}t[u+1]=t[a],t[a]=l,h-o+1>=a-u?(s[++c]=o,s[++c]=h,h=a-1):(s[++c]=u,s[++c]=a-1,u=o)}return t}function No(t){for(var e=-1/0,i=0,r=t.length;i<r;++i)t[i]>e&&(e=t[i]);return e}function ko(t){for(var e=1/0,i=0,r=t.length;i<r;++i)t[i]<e&&(e=t[i]);return e}function Fo(t){for(var e=t.length,i=0,r=0;r<e;++r)i+=t[r];return i}function Bo(t){return Fo(t)/t.length}function zo(t){for(var e=t.length,i=0,r=0;r<e;++r){var n=t[r];i+=n*n}return Math.sqrt(i/e)}function Uo(t,e,i,r,n){var o,a,s,c,u=t.height,h=t.width,l=t.getContext("2d").getImageData(0,0,h,u).data;for(s=!1,a=0;a<u;a++){for(o=0;o<h;o++)if(c=4*(a*h+o),l[c]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var p=a;for(s=!1,o=0;o<h;o++){for(a=0;a<u;a++)if(c=4*(a*h+o),l[c]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var d=o;for(s=!1,a=u-1;a>=0;a--){for(o=h-1;o>=0;o--)if(c=4*(a*h+o),l[c]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var f=a;for(s=!1,o=h-1;o>=0;o--){for(a=u-1;a>=0;a--)if(c=4*(a*h+o),l[c]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var m=o,g=document.createElement("canvas");return g.width=m-d,g.height=f-p,g.getContext("2d").drawImage(t,d,p,g.width,g.height,0,0,g.width,g.height),g}function jo(t,e){function i(e){var i=s;c&&(i*=2),e&&(i=1/i),t.scene.traverse(function(t){var e=t.material;e&&e.linewidth&&(e.linewidth*=i),e&&e.uniforms&&e.uniforms.size&&void 0===e.uniforms.size.__seen&&(e.uniforms.size.value*=i,e.uniforms.size.__seen=!0)}),t.scene.traverse(function(t){var e=t.material;e&&e.uniforms&&e.uniforms.size&&delete e.uniforms.size.__seen})}function r(t){if(a){var e=d;return Uo(t,u?0:255*e.r,u?0:255*e.g,u?0:255*e.b,u?0:255)}return t}function n(t,e,i){"function"==typeof o.onProgress&&o.onProgress(t,e,i)}var o=e||{},a=gn(o.trim,!1),s=gn(o.factor,1),c=gn(o.antialias,!1),u=gn(o.transparent,!1),h=t.renderer,l=t.camera,p=h.getClearAlpha(),d=h.getClearColor();return new Promise(function(e){function o(o,s){r(a.canvas).toBlob(function(r){h.setClearAlpha(p),i(!0),t.requestRender(),n(s,s,!0),e(r)},"image/png")}var a=new So(h,l,t,{factor:s,antialias:c,onProgress:n,onFinish:o});h.setClearAlpha(u?0:1),i(),a.renderAsync()})}function Go(t,e){t.traverseVisible(function(t){if(t instanceof De&&t.sortParticles){var i=t.geometry.attributes,r=i.position.count;if(0!==r){$f.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),Hf.multiplyMatrices(e.projectionMatrix,$f);var n,o,a,s;t.userData.sortData?(n=t.userData.sortData,a=n.__zArray,o=n.__sortArray,s=n.__cmpFn):(a=new Float32Array(r),o=new Uint32Array(r),n={__zArray:a,__sortArray:o,__cmpFn:s=function(t,e){var i=a[t],r=a[e];return i>r?1:i<r?-1:0}},t.userData.sortData=n);for(var c=0;c<r;++c)Vf.fromArray(i.position.array,3*c),Vf.applyMatrix4(Hf),a[c]=-Vf.z,o[c]=c;Do(o,s);var u,h,l;for(var p in i){var d=i[p],f=d.array,m=d.itemSize;n[p]||(n[p]=new Float32Array(m*r)),l=n[p],n[p]=f;for(var g=0;g<r;++g){u=o[g];for(var v=0;v<m;++v)h=u*m+v,l[g*m+v]=f[h]}i[p].array=l,i[p].needsUpdate=!0}}}})}function Vo(t,e,i,r,n){var o=i.getSize().height,a=i.getPixelRatio(),s="OrthographicCamera"===e.type;Wf.getInverse(e.projectionMatrix),Xf.copy(e.projectionMatrix).transpose(),t.traverse(function(t){var e=t.material;if(e){var i=t.material.uniforms;if(i){if(e.clipNear){var c=(50-e.clipNear)/50,u=r-n*c;i.nearClip.value=u}i.canvasHeight&&(i.canvasHeight.value=o),i.pixelRatio&&(i.pixelRatio.value=a),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Wf),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(Xf),i.ortho&&(i.ortho.value=s)}}})}function $o(t,e,i,r,n){var o=n.uniforms,a=[];if(o.objectId&&(o.objectId.value=af?this.id:this.id/255,a.push("objectId")),(o.modelViewMatrixInverse||o.modelViewMatrixInverseTranspose||o.modelViewProjectionMatrix||o.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),o.modelViewMatrixInverse&&(o.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),a.push("modelViewMatrixInverse")),o.modelViewMatrixInverseTranspose&&(o.modelViewMatrixInverse?o.modelViewMatrixInverseTranspose.value.copy(o.modelViewMatrixInverse.value).transpose():o.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),a.push("modelViewMatrixInverseTranspose")),o.modelViewProjectionMatrix&&(i.updateProjectionMatrix(),o.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),a.push("modelViewProjectionMatrix")),o.modelViewProjectionMatrixInverse&&(o.modelViewProjectionMatrix?(Zf.copy(o.modelViewProjectionMatrix.value),o.modelViewProjectionMatrixInverse.value.getInverse(Zf)):(i.updateProjectionMatrix(),Zf.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.modelViewProjectionMatrixInverse.value.getInverse(Zf)),a.push("modelViewProjectionMatrixInverse")),a.length){var s=t.properties.get(n);if(s.program){var c=t.getContext(),u=s.program;c.useProgram(u.program);var h=u.getUniforms();a.forEach(function(t){h.setValue(c,t,o[t].value)})}}}function Ho(e){function i(){Q||(Q=new _e),(it=new Ne).name="rotationGroup",Q.add(it),(rt=new Ne).name="translationGroup",it.add(rt),(nt=new Ne).name="modelGroup",rt.add(nt),(at=new Ne).name="pickingGroup",rt.add(at),(ct=new Ne).name="backgroundGroup",rt.add(ct),(ut=new Ne).name="helperGroup",rt.add(ut),Q.fog=new xe,J=new Gi(X.lightColor,X.lightIntensity),Q.add(J),et=new Wi(X.ambientLight,X.ambientIntensity),Q.add(et)}function r(){var t=_t.geometry.attributes.position,e=t.array,i=wt.min,r=wt.max;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,wt.isEmpty()||_t.geometry.computeBoundingSphere()}function n(e,i){i?i.forEach(function(t){o(e,t)}):o(e),e.background?(ct.add(e.group),ct.add(e.wireframeGroup)):(nt.add(e.group),nt.add(e.wireframeGroup)),e.pickable&&at.add(e.pickingGroup),t.Debug&&r()}function o(t,e){function i(r){r instanceof Ne?r.children.forEach(i):(r.userData.buffer=t,r.userData.instance=e,r.onBeforeRender=$o)}var r=t.getMesh();e&&r.applyMatrix(e.matrix),i(r),t.group.add(r);var n=t.getWireframeMesh();if(e&&(n.matrix.copy(r.matrix),n.position.copy(r.position),n.quaternion.copy(r.quaternion),n.scale.copy(r.scale)),i(n),t.wireframeGroup.add(n),t.pickable){var o=t.getPickingMesh();e&&(o.matrix.copy(r.matrix),o.position.copy(r.position),o.quaternion.copy(r.quaternion),o.scale.copy(r.scale)),i(o),t.pickingGroup.add(o)}e?s(t.geometry,t.matrix,e.matrix):s(t.geometry,t.matrix)}function a(e){rt.children.forEach(function(t){t.remove(e.group),t.remove(e.wireframeGroup)}),e.pickable&&at.remove(e.pickingGroup),s(),t.Debug&&r()}function s(t,e,i){function r(t,e,i){t.boundingBox||t.computeBoundingBox();var r=t.boundingBox.clone();e&&r.applyMatrix4(e),i&&r.applyMatrix4(i),r.min.equals(r.max)&&r.expandByScalar(5),wt.union(r)}function n(t){if(void 0!==t.geometry){var e,i;t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(i=t.userData.instance.matrix),r(t.geometry,e,i)}}t?r(t,e,i):(wt.makeEmpty(),nt.traverse(n),ct.traverse(n)),wt.getSize(At),Mt=At.length()}function c(){var t=k*F*4,e=af?new Float32Array(t):new Uint8Array(t);return O(!0),ht.readRenderTargetPixels(pt,0,0,k,F,e),e}function u(t){return new Promise(function(e){if(t){var i=k*F*4,r=c();if(af){for(var n=new Uint8Array(i),o=0;o<i;++o)n[o]=Math.round(255*r[o]);r=n}var a=document.createElement("canvas");a.width=k,a.height=F;var s=a.getContext("2d"),u=s.getImageData(0,0,k,F);u.data.set(r),s.putImageData(u,0,0),a.toBlob(e,"image/png")}else ht.domElement.toBlob(e,"image/png")})}function h(t){return jo(this,t)}function l(t,e,i,r){var n=X;void 0!==t&&n.lightColor.set(t),void 0!==e&&(n.lightIntensity=e),void 0!==i&&n.ambientColor.set(i),void 0!==r&&(n.ambientIntensity=r),A()}function p(t,e,i){var r=X;void 0!==t&&r.fogColor.set(t),void 0!==e&&(r.fogNear=e),void 0!==i&&(r.fogFar=i),A()}function d(t){var e=X;t&&e.backgroundColor.set(t),p(e.backgroundColor),ht.setClearColor(e.backgroundColor,0),ht.domElement.style.backgroundColor=e.backgroundColor.getStyle(),A()}function m(t){void 0!==t&&(X.sampleLevel=t,$=t),A()}function v(t,e){var i=X;t&&(i.cameraType=t),e&&(i.cameraFov=e),"orthographic"===i.cameraType?K!==Z&&((K=Z).position.copy(Y.position),K.up.copy(Y.up),M()):K!==Y&&((K=Y).position.copy(Z.position),K.up.copy(Z.up)),Y.fov=i.cameraFov,K.updateProjectionMatrix(),A()}function y(t,e,i){var r=X;void 0!==t&&(r.clipNear=t),void 0!==e&&(r.clipFar=e),void 0!==i&&(r.clipDist=i),A()}function b(t,e){k=t||1,F=e||1,Y.aspect=k/F,Z.left=-k/2,Z.right=k/2,Z.top=F/2,Z.bottom=-F/2,K.updateProjectionMatrix();var i=window.devicePixelRatio;ht.setPixelRatio(i),ht.setSize(k,F);var r=k*i,n=F*i;pt.setSize(r,n),dt.setSize(r,n),ft.setSize(r,n),A()}function x(){if(N===document.body)b(window.innerWidth,window.innerHeight);else{var t=N.getBoundingClientRect();b(t.width,t.height)}}function _(t){var e=Tt.memory,i=Tt.render;if(t)e.programs=0,e.geometries=0,e.textures=0,i.calls=0,i.vertices=0,i.faces=0,i.points=0;else{var r=ht.info,n=r.memory,o=r.render;e.programs=n.programs,e.geometries=n.geometries,e.textures=n.textures,i.calls+=o.calls,i.vertices+=o.vertices,i.faces+=o.faces,i.points+=o.points}}function w(){if(B.ticked.dispatch(q),window.performance.now()-q.startTime>500&&!V&&$<3&&-1!==$){var e=$;$=3,j=!0,O(),V=!0,$=e,t.Debug&&cf.log("rendered still frame")}window.requestAnimationFrame(w)}function S(t,e){t*=window.devicePixelRatio,e*=window.devicePixelRatio;var i,r,n,o=af?qf:Yf;O(!0),ht.readRenderTargetPixels(pt,t,e,1,1,o),i=af?Math.round(255*o[0])<<16&16711680|Math.round(255*o[1])<<8&65280|255&Math.round(255*o[2]):o[0]<<16|o[1]<<8|o[2];var a=Math.round(o[3]),s=at.getObjectById(a);return s&&(r=s.userData.instance,n=s.userData.buffer.picking),{pid:i,instance:r,picker:n}}function A(){j||(window.performance.now()-q.startTime>22&&(q.begin(),V=!1),j=!0,window.requestAnimationFrame(function(){O(),q.update()}))}function M(){var t=Hn(Y.fov),e=2*Math.tan(t/2)*-K.position.z;Z.zoom=F/e}function P(){var t=X;(H=Pt.copy(K.position).length())||(K.position.set(0,0,t.cameraZ),H=Math.abs(t.cameraZ)),W=Math.max(10,.5*Mt),((W+=wt.getCenter(Pt).length())===1/0||W===-1/0||isNaN(W))&&(W=50);var e=(50-t.clipNear)/50,i=-(50-t.clipFar)/50;K.near=H-W*e,K.far=H+W*i;var r=(50-t.fogNear)/50,n=-(50-t.fogFar)/50,o=Q.fog;o.color.set(t.fogColor),o.near=H-W*r,o.far=H+W*n,"PerspectiveCamera"===K.type?(K.near=Math.max(.1,t.clipDist,K.near),K.far=Math.max(1,K.far),o.near=Math.max(.1,o.near),o.far=Math.max(1,o.far)):"OrthographicCamera"===K.type&&0===t.clipNear&&t.clipDist>0&&H+K.zoom>2*-t.clipDist&&(K.near+=K.zoom+t.clipDist)}function T(){K.updateMatrix(),K.updateMatrixWorld(!0),K.matrixWorldInverse.getInverse(K.matrixWorld),K.updateProjectionMatrix(),Vo(Q,K,ht,H,W),Go(Q,K)}function E(t,e,i,r){nt.visible=t,at.visible=e,ct.visible=i,ut.visible=r}function C(){Pt.copy(K.position).setLength(100*Mt),J.position.copy(K.position).add(Pt),J.color.set(X.lightColor),J.intensity=X.lightIntensity,et.color.set(X.ambientColor),et.intensity=X.ambientIntensity}function I(){ht.clearTarget(pt),E(!1,!0,!1,!1),ht.render(Q,K,pt),_(),ht.setRenderTarget(null)}function R(e){e?ht.clearTarget(e):ht.clear(),E(!1,!1,!0,!1),ht.render(Q,K,e),e?ht.clearTarget(e,!1,!0,!1):ht.clearDepth(),_(),E(!0,!1,!1,t.Debug),ht.render(Q,K,e),_()}function L(){var t=jf[Math.max(0,Math.min($,5))],e=1/t.length;mt.tForeground.value=dt.texture;for(var i=dt.width,r=dt.height,n=0;n<t.length;++n){var o=t[n];K.setViewOffset(i,r,o[0],o[1],i,r),T();var a=e;a+=1/32*((n+.5)/t.length-.5),mt.scale.value=a,R(dt),ht.render(xt,vt,ft,0===n)}mt.scale.value=1,mt.tForeground.value=ft.texture,ht.render(xt,vt,null,!0),K.view=null}function O(t){if(U)return void cf.warn("tried to call 'render' from within 'render'");U=!0,P(),T(),C(),_(!0),t?G||I():$>0?L():R(),G=t,U=!1,j=!1}function D(){cf.log("scene cleared"),Q.remove(it),i(),ht.clear()}var N,k,F,B={ticked:new oo};if((N="string"==typeof e?document.getElementById(e):e instanceof window.Element?e:document.createElement("div"))===document.body)k=window.innerWidth||1,F=window.innerHeight||1;else{var z=N.getBoundingClientRect();k=z.width||1,F=z.height||1}var U,j,G,V,$,H,W,X;!function(){X={fogColor:new tt(0),fogNear:50,fogFar:100,backgroundColor:new tt(0),cameraType:"perspective",cameraFov:40,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,lightColor:new tt(14540253),lightIntensity:1,ambientColor:new tt(14540253),ambientIntensity:.2,sampleLevel:0}}();var q;!function(){q=new xo}();var Y,Z,K;!function(){var t=new g(0,0,0);(Y=new bt(X.cameraFov,k/F)).position.z=X.cameraZ,Y.lookAt(t),(Z=new yt(k/-2,k/2,F/2,F/-2)).position.z=X.cameraZ,Z.lookAt(t),(K="orthographic"===X.cameraType?Z:Y).updateProjectionMatrix()}();var Q,J,et,it,rt,nt,at,ct,ut;i();var ht,lt,pt,dt,ft,mt,gt,vt,xt;if(!1===function(){var t=window.devicePixelRatio;try{ht=new ye({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return N.innerHTML=uf,!1}ht.setPixelRatio(t),ht.setSize(k,F),ht.autoClear=!1,ht.sortObjects=!0,lo(ht.extensions.get("EXT_frag_depth")),ht.extensions.get("OES_element_index_uint"),ho(ht.extensions.get("OES_texture_float")&&ht.extensions.get("WEBGL_color_buffer_float")||"Chrome"===nf&&ht.extensions.get("OES_texture_float")),N.appendChild(ht.domElement);var e=k*t,i=F*t;ht.extensions.get("OES_texture_float"),lt=ht.extensions.get("OES_texture_half_float"),ht.extensions.get("WEBGL_color_buffer_float"),(pt=new f(e,i,{minFilter:Ph,magFilter:Ph,stencilBuffer:!1,format:Wh,type:af?Bh:Lh})).texture.generateMipmaps=!1,dt=new f(e,i,{minFilter:Ch,magFilter:Ch,format:Wh}),ft=new f(e,i,{minFilter:Ph,magFilter:Ph,format:Wh,type:of?Lh:lt?zh:af?Bh:Lh}),gt=new ot({uniforms:mt={tForeground:{type:"t",value:null},scale:{type:"f",value:1}},vertexShader:wo("Quad.vert"),fragmentShader:wo("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:Du,depthTest:!1,depthWrite:!1}),vt=new yt(-1,1,1,-1,0,1),xt=(new _e).add(new Bt(new Lt(2,2),gt))}())return this.container=N,void cf.error("Viewer: could not initialize renderer");var _t,wt=new st,At=new g,Mt=0;!function(){var 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 Ct;i.setIndex(new St(t,1)),i.addAttribute("position",new St(e,3));var r=new ot({uniforms:{uColor:{value:new tt("skyblue")}},vertexShader:wo("BasicLine.vert"),fragmentShader:wo("BasicLine.frag"),linewidth:2});_t=new Re(i,r),ut.add(_t)}(),d(),p();var Pt=new g,Tt={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};this.container=N,this.stats=q,this.signals=B,this.rotationGroup=it,this.translationGroup=rt,this.add=n,this.remove=a,this.clear=D,this.getPickingPixels=c,this.getImage=u,this.makeImage=h,this.setLight=l,this.setFog=p,this.setBackground=d,this.setSampling=m,this.setCamera=v,this.setClip=y,this.setSize=b,this.handleResize=x,this.pick=S,this.requestRender=A,this.render=O,this.animate=w,this.updateZoom=M,this.updateHelper=r,this.renderer=ht,this.scene=Q,this.perspectiveCamera=Y,this.boundingBox=wt,this.updateBoundingBox=function(){s(),t.Debug&&r()},Object.defineProperties(this,{camera:{get:function(){return K}},width:{get:function(){return k}},height:{get:function(){return F}},sampleLevel:{get:function(){return $}}})}function Wo(t){var 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)}function Xo(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<<e-1}else if("button"in t){var i=t.button;if(1===i)return 4;if(2===i)return 2;if(i>=0)return 1<<i}}return 0}function qo(t,e,i){return t.distanceTo(e)<t.distanceTo(i)}function Yo(t){var e=t.split(/[-+]/),i="";e.includes("scroll")&&(i="scroll"),e.includes("drag")&&(i="drag"),e.includes("click")&&(i="click"),e.includes("hover")&&(i="hover"),e.includes("clickPick")&&(i="clickPick"),e.includes("hoverPick")&&(i="hoverPick");var r=0;e.includes("alt")&&(r+=1),e.includes("ctrl")&&(r+=2),e.includes("meta")&&(r+=4),e.includes("shift")&&(r+=8);var n=0;return e.includes("left")&&(n+=1),e.includes("right")&&(n+=2),e.includes("middle")&&(n+=4),[i,r,n]}function Zo(t){var e,i=t.length,r=t.length/3,n=0,o=0,a=0;for(e=0;e<i;e+=3)n+=t[e+0],o+=t[e+1],a+=t[e+2];return new g(n/r,o/r,a/r)}function Ko(t,e,i){return i?t.sub(i).projectOnVector(e).add(i):t.projectOnVector(e),t}function Qo(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],h=t[s+1],l=t[s+2];u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),u>n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return[ia([e,i,r]),ia([n,o,a])]}function Jo(t,e){for(var i=0,r=e.length;i<r;i+=3){var n=e[i],o=e[i+1],a=e[i+2];e[i]=t[0]*n+t[4]*o+t[8]*a+t[12],e[i+1]=t[1]*n+t[5]*o+t[9]*a+t[13],e[i+2]=t[2]*n+t[6]*o+t[10]*a+t[14]}}function ta(t,e){for(var i=0,r=e.length;i<r;i+=3){var n=e[i],o=e[i+1],a=e[i+2];e[i]=t[0]*n+t[3]*o+t[6]*a,e[i+1]=t[1]*n+t[4]*o+t[7]*a,e[i+2]=t[2]*n+t[5]*o+t[8]*a}}function ea(t){for(var e=0,i=t.length;e<i;e+=3){var r=t[e],n=t[e+1],o=t[e+2],a=1/Math.sqrt(r*r+n*n+o*o);t[e]=r*a,t[e+1]=n*a,t[e+2]=o*a}}function ia(t){return new Float32Array(t||3)}function ra(t,e,i){var r=e[0],n=e[1],o=e[2],a=i[0],s=i[1],c=i[2];t[0]=n*c-o*s,t[1]=o*a-r*c,t[2]=r*s-n*a}function na(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2]}function oa(t,e,i){t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2]}function aa(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function sa(t,e,i){ca(t,e,1/i)}function ca(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}function ua(t,e){ca(t,e,1/aa(e))}function ha(t,e,i){t[0]=e[0]-i,t[1]=e[1]-i,t[2]=e[2]-i}function la(t,e,i){t[0]=e[0]+i,t[1]=e[1]+i,t[2]=e[2]+i}function pa(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function da(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function fa(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}function ma(t){return t-=t>>>1&1431655765,16843009*((t=(858993459&t)+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function ga(t,e){this.type=t,this.scale=e||1,this.max=10}function va(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)}function ya(t,e){for(var i=0,r=0,n=e.rows,o=e.cols,a=0,s=0,c=0,u=e.data,h=t.data;i<n;s+=1,a+=o,i++)for(c=s,r=0;r<o;c+=n,r++)h[c]=u[a+r]}function ba(t,e,i){for(var r=0,n=0,o=0,a=0,s=0,c=0,u=0,h=e.cols,l=e.rows,p=i.rows,d=e.data,f=i.data,m=t.data,g=0;r<l;a+=h,r++)for(c=0,n=0;n<p;u++,n++){for(s=a,g=0,o=0;o<h;s++,c++,o++)g+=d[s]*f[c];m[u]=g}}function xa(t,e){var i=t.data,r=e.data,n=i[4],o=i[8],a=i[5],s=i[7],c=i[0],u=c*n,h=c*a,l=i[3],p=i[1],d=l*p,f=i[2],m=l*f,g=i[6],v=g*p,y=g*f,b=1/(u*o-h*s-d*o+m*s+v*a-y*n);r[0]=(n*o-a*s)*b,r[1]=-(p*o-f*s)*b,r[2]=-(-p*a+f*n)*b,r[3]=-(l*o-a*g)*b,r[4]=(c*o-y)*b,r[5]=-(h-m)*b,r[6]=-(-l*s+n*g)*b,r[7]=-(c*s-v)*b,r[8]=(u-d)*b}function _a(t){var 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]}function wa(t,e,i){var r=t.data,n=e.data,o=i.data,a=n[0],s=n[1],c=n[2],u=n[3],h=n[4],l=n[5],p=n[6],d=n[7],f=n[8],m=o[0],g=o[1],v=o[2],y=o[3],b=o[4],x=o[5],_=o[6],w=o[7],S=o[8];r[0]=a*m+s*y+c*_,r[1]=a*g+s*b+c*w,r[2]=a*v+s*x+c*S,r[3]=u*m+h*y+l*_,r[4]=u*g+h*b+l*w,r[5]=u*v+h*x+l*S,r[6]=p*m+d*y+f*_,r[7]=p*g+d*b+f*w,r[8]=p*v+d*x+f*S}function Sa(t){var e,i,r=0,n=t.rows,o=t.cols,a=t.data,s=new Array(o);for(i=0;i<o;++i)s[i]=0;for(e=0;e<n;++e)for(i=0;i<o;++i,++r)s[i]+=a[r];for(i=0;i<o;++i)s[i]/=n;return s}function Aa(t,e){var i,r,n=0,o=t.rows,a=t.cols,s=t.data;for(i=0;i<o;++i)for(r=0;r<a;++r,++n)s[n]-=e[r]}function Ma(t,e){var i,r,n=0,o=t.rows,a=t.cols,s=t.data;for(i=0;i<o;++i)for(r=0;r<a;++r,++n)s[n]+=e[r]}function Pa(t,e,i,r){r=t[e],t[e]=t[i],t[i]=r}function Ta(t,e){return t=Math.abs(t),e=Math.abs(e),t>e?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}function Ea(t,e,i,r,n,o,a,s){for(var c=2*Vg,u=$g,h=0,l=0,p=0,d=0,f=Math.max(o,30),m=0,g=0,v=0,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,P=0,T=0,E=0,C=0,I=0,R=0,L=4660,O=0,D=0,N=0,k=new Float64Array(a<<3);h<a;h++){for(p=0,M=0;p<o;p++)M+=(w=t[h*e+p])*w;if(k[h]=M,r){for(p=0;p<a;p++)r[h*n+p]=0;r[h*n+h]=1}}for(;d<f;d++){for(b=0,h=0;h<a-1;h++)for(l=h+1;l<a;l++){for(m=h*e|0,g=l*e|0,C=k[h],I=0,R=k[l],p=2,I+=t[m]*t[g],I+=t[m+1]*t[g+1];p<o;p++)I+=t[m+p]*t[g+p];if(!(Math.abs(I)<=c*Math.sqrt(C*R))){for(T=Ta(I*=2,P=C-R),P<0?(E=.5*(T-P),x=I/(T*(_=Math.sqrt(E/T))*2)):_=I/(T*(x=Math.sqrt((T+P)/(2*T)))*2),C=0,R=0,p=2,S=x*t[m]+_*t[g],A=-_*t[m]+x*t[g],t[m]=S,t[g]=A,C+=S*S,R+=A*A,S=x*t[m+1]+_*t[g+1],A=-_*t[m+1]+x*t[g+1],t[m+1]=S,t[g+1]=A,C+=S*S,R+=A*A;p<o;p++)S=x*t[m+p]+_*t[g+p],A=-_*t[m+p]+x*t[g+p],t[m+p]=S,t[g+p]=A,C+=S*S,R+=A*A;if(k[h]=C,k[l]=R,b=1,r)for(y=l*n|0,p=2,S=x*r[v=h*n|0]+_*r[y],A=-_*r[v]+x*r[y],r[v]=S,r[y]=A,S=x*r[v+1]+_*r[y+1],A=-_*r[v+1]+x*r[y+1],r[v+1]=S,r[y+1]=A;p<a;p++)S=x*r[v+p]+_*r[y+p],A=-_*r[v+p]+x*r[y+p],r[v+p]=S,r[y+p]=A}}if(0===b)break}for(h=0;h<a;h++){for(p=0,M=0;p<o;p++)M+=(w=t[h*e+p])*w;k[h]=Math.sqrt(M)}for(h=0;h<a-1;h++){for(l=h,p=h+1;p<a;p++)k[l]<k[p]&&(l=p);if(h!==l&&(Pa(k,h,l,M),r)){for(p=0;p<o;p++)Pa(t,h*e+p,l*e+p,w);for(p=0;p<a;p++)Pa(r,h*n+p,l*n+p,w)}}for(h=0;h<a;h++)i[h]=k[h];if(r)for(h=0;h<s;h++){for(M=h<a?k[h]:0;M<=u;){for(D=1/o,p=0;p<o;p++)O=0!=(256&(L=214013*L+2531011)>>16)?D:-D,t[h*e+p]=O;for(d=0;d<2;d++)for(l=0;l<h;l++){for(M=0,p=0;p<o;p++)M+=t[h*e+p]*t[l*e+p];for(N=0,p=0;p<o;p++)w=t[h*e+p]-M*t[l*e+p],t[h*e+p]=w,N+=Math.abs(w);for(N=N?1/N:0,p=0;p<o;p++)t[h*e+p]*=N}for(M=0,p=0;p<o;p++)M+=(w=t[h*e+p])*w;M=Math.sqrt(M)}for(_=1/M,p=0;p<o;p++)t[h*e+p]*=_}}function Ca(t,e,i,r){var n=0,o=0,a=t.rows,s=t.cols,c=a,u=s;c<u&&(n=1,o=c,c=u,u=o);var h=new va(c,c),l=new va(1,u),p=new va(u,u);if(0===n)ya(h,t);else{for(o=0;o<s*a;o++)h.data[o]=t.data[o];for(;o<u*c;o++)h.data[o]=0}if(Ea(h.data,c,l.data,p.data,u,c,u,c),e){for(o=0;o<u;o++)e.data[o]=l.data[o];for(;o<s;o++)e.data[o]=0}0===n?(i&&ya(i,h),r&&ya(r,p)):(i&&ya(i,p),r&&ya(r,h))}function Ia(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ra(t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g){t[0]=e,t[4]=i,t[8]=r,t[12]=n,t[1]=o,t[5]=a,t[9]=s,t[13]=c,t[2]=u,t[6]=h,t[10]=l,t[14]=p,t[3]=d,t[7]=f,t[11]=m,t[15]=g}function La(t,e,i){var r=e[0],n=e[4],o=e[8],a=e[12],s=e[1],c=e[5],u=e[9],h=e[13],l=e[2],p=e[6],d=e[10],f=e[14],m=e[3],g=e[7],v=e[11],y=e[15],b=i[0],x=i[4],_=i[8],w=i[12],S=i[1],A=i[5],M=i[9],P=i[13],T=i[2],E=i[6],C=i[10],I=i[14],R=i[3],L=i[7],O=i[11],D=i[15];t[0]=r*b+n*S+o*T+a*R,t[4]=r*x+n*A+o*E+a*L,t[8]=r*_+n*M+o*C+a*O,t[12]=r*w+n*P+o*I+a*D,t[1]=s*b+c*S+u*T+h*R,t[5]=s*x+c*A+u*E+h*L,t[9]=s*_+c*M+u*C+h*O,t[13]=s*w+c*P+u*I+h*D,t[2]=l*b+p*S+d*T+f*R,t[6]=l*x+p*A+d*E+f*L,t[10]=l*_+p*M+d*C+f*O,t[14]=l*w+p*P+d*I+f*D,t[3]=m*b+g*S+v*T+y*R,t[7]=m*x+g*A+v*E+y*L,t[11]=m*_+g*M+v*C+y*O,t[15]=m*w+g*P+v*I+y*D}function Oa(t,e,i,r){Ra(t,e,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1)}function Da(t,e,i,r){Ra(t,1,0,0,e,0,1,0,i,0,0,1,r,0,0,0,1)}function Na(t,e){var i=Math.cos(e),r=Math.sin(e);Ra(t,i,0,r,0,0,1,0,0,-r,0,i,0,0,0,0,1)}function ka(){return new Float32Array([1,0,0,0,1,0,0,0,1])}function Fa(t,e){var i=ia([e[0],e[1],e[2]]),r=ia([e[4],e[5],e[6]]),n=ia([e[8],e[9],e[10]]),o=ia();ra(o,r,n),t[0]=o[0],t[1]=o[1],t[2]=o[2],ra(o,n,i),t[3]=o[0],t[4]=o[1],t[5]=o[2],ra(o,i,r),t[6]=o[0],t[7]=o[1],t[8]=o[2]}function Ba(t,e){function i(t,e,i,r){for(var n=r*r,a=Math.max(0,t-r-s>>o),d=Math.max(0,e-r-c>>o),f=Math.max(0,i-r-u>>o),y=Math.min(h,t+r-s>>o),x=Math.min(l,e+r-c>>o),_=Math.min(p,i+r-u>>o),w=[],S=a;S<=y;++S)for(var A=d;A<=x;++A)for(var P=f;P<=_;++P){var E=b[(S*l+A)*p+P];if(E>0)for(var I=E-1,R=T[I],L=R+M[I],O=R;O<L;++O){var D=C[O],N=m[D]-t,k=g[D]-e,F=v[D]-i;N*N+k*k+F*F<=n&&w.push(D)}}return w}var r,n,o=3,a=e,s=a.min.x,c=a.min.y,u=a.min.z,h=1+(a.max.x-s>>o),l=1+(a.max.y-c>>o),p=1+(a.max.z-u>>o),d=h*l*p,f=t.count,m=t.x,g=t.y,v=t.z,y=0,b=new Uint32Array(d),x=new Int32Array(f);for(r=0;r<f;++r){var _=m[r]-s>>o,w=g[r]-c>>o,S=v[r]-u>>o,A=(_*l+w)*p+S;1===(b[A]+=1)&&(y+=1),x[r]=A}var M=new Uint16Array(y);for(r=0,n=0;r<d;++r){var P=b[r];P>0&&(b[r]=n+1,M[n]=P,n+=1)}var T=new Uint32Array(y);for(r=1;r<y;++r)T[r]+=T[r-1]+M[r-1];var E=new Uint16Array(y),C=new Int32Array(f);for(r=0;r<f;++r){var I=b[x[r]];if(I>0){var R=I-1;C[T[R]+E[R]]=r,E[R]+=1}}this.within=i}function za(e){var i=0,r=0,n={},o={},a=window.URL.createObjectURL(hf.get(e)),s=new window.Worker(a);hf.activeWorkerCount+=1,s.onmessage=function(r){i-=1;var a=r.data.__postId;t.Debug&&cf.timeEnd("Worker.postMessage "+e+" #"+a),n[a]&&n[a].call(s,r),delete n[a],delete o[a]},s.onerror=function(t){if(i-=1,t.data){var r=t.data.__postId;o[r]?o[r].call(s,t):cf.error("Worker.onerror",r,e,t),delete n[r],delete o[r]}else cf.error("Worker.onerror",e,t)},this.name=e,this.post=function(a,c,u,h){n[r]=u,o[r]=h,(a=a||{}).__name=e,a.__postId=r,a.__debug=t.Debug,t.Debug&&cf.time("Worker.postMessage "+e+" #"+r);try{s.postMessage(a,c)}catch(t){cf.error("worker.post:",t),s.postMessage(a)}return i+=1,r+=1,this},this.terminate=function(){s?(s.terminate(),window.URL.revokeObjectURL(a),hf.activeWorkerCount-=1):cf.log("no worker to terminate")},Object.defineProperties(this,{postCount:{get:function(){return r}},pending:{get:function(){return i}}})}function Ua(t,e){e=Math.min(8,e||2);var i=[],r=0;this.name=t,this.maxCount=e,this.post=function(t,e,i,r){return this.getNextWorker().post(t,e,i,r),this},this.terminate=function(){i.forEach(function(t){t.terminate()})},this.getNextWorker=function(){for(var n,o=1/0,a=0;a<e;++a){if(a>=r){n=new za(t),i.push(n),r+=1;break}var s=i[a];if(0===s.pending){n=s;break}s.pending<o&&(o=s.pending,n=s)}return n},Object.defineProperties(this,{count:{get:function(){return r}}})}function ja(){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 Ga(){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 Va(){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 $a(t,e,i,r,n){function o(t,e,i){return t+(e-t)*i}function a(t,n,o){return t=(t+v)%e,n=(n+y)%i,o=(o+b)%r,P*o+M*n+t}function s(t,e,i,r,a,s,c){var u=w?3*t:t;if(f[u]<0){var h=(x-s)/(c-s),l=d,p=3*m;if(E[p+0]=i+h,E[p+1]=r,E[p+2]=a,!_){var g=3*t;C[p]=-o(l[g],l[g+3],h),C[p+1]=-o(l[g+1],l[g+4],h),C[p+2]=-o(l[g+2],l[g+5],h)}n&&(R[m]=n[t+Math.round(h)]),f[u]=m,T[e]=m,m+=1}else T[e]=f[u]}function c(t,e,i,r,a,s,c){var u=w?3*t+1:t;if(f[u]<0){var h=(x-s)/(c-s),l=d,p=3*m;if(E[p]=i,E[p+1]=r+h,E[p+2]=a,!_){var g=3*t,v=g+3*M;C[p]=-o(l[g],l[v],h),C[p+1]=-o(l[g+1],l[v+1],h),C[p+2]=-o(l[g+2],l[v+2],h)}n&&(R[m]=n[t+Math.round(h)*M]),f[u]=m,T[e]=m,m+=1}else T[e]=f[u]}function u(t,e,i,r,a,s,c){var u=w?3*t+2:t;if(f[u]<0){var h=(x-s)/(c-s),l=d,p=3*m;if(E[p]=i,E[p+1]=r,E[p+2]=a+h,!_){var g=3*t,v=g+3*P;C[p]=-o(l[g],l[v],h),C[p+1]=-o(l[g+1],l[v+1],h),C[p+2]=-o(l[g+2],l[v+2],h)}n&&(R[m]=n[t+Math.round(h)*P]),f[u]=m,T[e]=m,m+=1}else T[e]=f[u]}function h(e){var i=3*e;0===d[i]&&(d[i]=t[(e-1+A)%A]-t[(e+1)%A],d[i+1]=t[(e-M+A)%A]-t[(e+M)%A],d[i+2]=t[(e-P+A)%A]-t[(e+P)%A])}function l(e,i,r,n,o){var l,p,d,f,m,v,y;S?(n=a(e,i,r),l=a(e+1,i,r),p=a(e,i+1,r),d=a(e,i,r+1),f=a(e+1,i+1,r),m=a(e+1,i,r+1),v=a(e,i+1,r+1),y=a(e+1,i+1,r+1)):(l=n+1,f=(p=n+M)+1,m=(d=n+P)+1,y=(v=p+P)+1);var b=0,A=t[n],E=t[l],C=t[p],R=t[f],N=t[d],k=t[m],F=t[v],B=t[y];A<x&&(b|=1),E<x&&(b|=2),C<x&&(b|=8),R<x&&(b|=4),N<x&&(b|=16),k<x&&(b|=32),F<x&&(b|=128),B<x&&(b|=64);var z=L[b];if(0===z)return 0;var U=e+1,j=i+1,G=r+1;1&z&&(_||(h(n),h(l)),s(n,0,e,i,r,A,E)),2&z&&(_||(h(l),h(f)),c(l,1,U,i,r,E,R)),4&z&&(_||(h(p),h(f)),s(p,2,e,j,r,C,R)),8&z&&(_||(h(n),h(p)),c(n,3,e,i,r,A,C)),16&z&&(_||(h(d),h(m)),s(d,4,e,i,G,N,k)),32&z&&(_||(h(m),h(y)),c(m,5,U,i,G,k,B)),64&z&&(_||(h(v),h(y)),s(v,6,e,j,G,F,B)),128&z&&(_||(h(d),h(v)),c(d,7,e,i,G,N,F)),256&z&&(_||(h(n),h(d)),u(n,8,e,i,r,A,N)),512&z&&(_||(h(l),h(m)),u(l,9,U,i,r,E,k)),1024&z&&(_||(h(f),h(y)),u(f,10,U,j,r,R,B)),2048&z&&(_||(h(p),h(v)),u(p,11,e,j,r,C,F));for(var V,$,H,W=b<<4,X=0;-1!==O[W+X];)V=O[W+X],$=O[W+X+1],H=O[W+X+2],w?(D[V][$]&o&&(I[g++]=T[V],I[g++]=T[$]),D[$][H]&o&&(I[g++]=T[$],I[g++]=T[H]),D[V][H]&o&&(I[g++]=T[V],I[g++]=T[H])):(I[g++]=T[$],I[g++]=T[V],I[g++]=T[H]),X+=3}function p(n,o,s,c,u,h){var p,d,m,g,v,y,b;n=void 0!==n?n:0,o=void 0!==o?o:0,s=void 0!==s?s:0,c=void 0!==c?c:e-1,u=void 0!==u?u:i-1,h=void 0!==h?h:r-1,S||(_?(n=Math.max(0,n),o=Math.max(0,o),s=Math.max(0,s),c=Math.min(e-1,c),u=Math.min(i-1,u),h=Math.min(r-1,h)):(n=Math.max(1,n),o=Math.max(1,o),s=Math.max(1,s),c=Math.min(e-2,c),u=Math.min(i-2,u),h=Math.min(r-2,h)));var A,T,E,C,I,R;if(S)for(A=n-2,T=o-2,C=c+2,I=u+2,R=h+2,v=E=s-2;v<R;++v)for(g=T;g<I;++g)for(m=A;m<C;++m)w?(d=3*a(m,g,v),f[d]=-1,f[d+1]=-1,f[d+2]=-1):(p=a(m,g,v),f[p]=-1);else for(A=Math.max(0,n-2),T=Math.max(0,o-2),E=Math.max(0,s-2),C=Math.min(e,c+2),I=Math.min(i,u+2),R=Math.min(r,h+2),v=E;v<R;++v)for(b=P*v,g=T;g<I;++g)for(y=b+M*g,m=A;m<C;++m)w?(f[p=3*(y+m)]=-1,f[p+1]=-1,f[p+2]=-1):f[p=y+m]=-1;if(!S){var L,O=n,D=o,N=s,k=c,F=u,B=h;for(L=!1,v=s;v<h;++v){for(g=o;g<u;++g){for(m=n;m<c;++m)if(p=e*i*v+e*g+m,t[p]>=x){N=v,L=!0;break}if(L)break}if(L)break}for(L=!1,g=o;g<u;++g){for(v=N;v<h;++v){for(m=n;m<c;++m)if(p=e*i*v+e*g+m,t[p]>=x){D=g,L=!0;break}if(L)break}if(L)break}for(L=!1,m=n;m<c;++m){for(g=D;g<u;++g){for(v=N;v<h;++v)if(p=e*i*v+e*g+m,t[p]>=x){O=m,L=!0;break}if(L)break}if(L)break}for(L=!1,v=h;v>=s;--v){for(g=u;g>=o;--g){for(m=c;m>=n;--m)if(p=e*i*v+e*g+m,t[p]>=x){B=v,L=!0;break}if(L)break}if(L)break}for(L=!1,g=u;g>=o;--g){for(v=B;v>=s;--v){for(m=c;m>=n;--m)if(p=e*i*v+e*g+m,t[p]>=x){F=g,L=!0;break}if(L)break}if(L)break}for(L=!1,m=c;m>=n;--m){for(g=F;g>=o;--g){for(v=B;v>=s;--v)if(p=e*i*v+e*g+m,t[p]>=x){k=m,L=!0;break}if(L)break}if(L)break}_?(n=Math.max(0,O-1),o=Math.max(0,D-1),s=Math.max(0,N-1),c=Math.min(e-1,k+1),u=Math.min(i-1,F+1),h=Math.min(r-1,B+1)):(n=Math.max(1,O-1),o=Math.max(1,D-1),s=Math.max(1,N-1),c=Math.min(e-2,k+1),u=Math.min(i-2,F+1),h=Math.min(r-2,B+1))}var z=15;for(v=s;v<h;++v,z&=-5)for(b=P*v,z|=2,g=o;g<u;++g,z&=-3)for(y=b+M*g,z|=1,m=n;m<c;++m,z&=-2)l(m,g,v,p=y+m,z)}var d,f,m,g,v,y,b,x=0,_=!1,w=!1,S=!1,A=e*i*r,M=e,P=e*i,T=new Int32Array(12),E=[],C=[],I=[],R=[],L=ja(),O=Ga(),D=Va();this.triangulate=function(t,o,a,s,c){x=t,w=s,S=c,(_=o||w)||d||(d=new Float32Array(3*A));var u=w?3*A:A;if(f&&f.length===u||(f=new Int32Array(u)),m=0,g=0,void 0!==a){var h=a[0].map(Math.round),l=a[1].map(Math.round);v=e*Math.ceil(Math.abs(h[0])/e),y=i*Math.ceil(Math.abs(h[1])/i),b=r*Math.ceil(Math.abs(h[2])/r),p(h[0],h[1],h[2],l[0],l[1],l[2])}else v=y=b=0,p();return E.length=3*m,_||(C.length=3*m),I.length=g,n&&(R.length=m),{position:new Float32Array(E),normal:_?void 0:new Float32Array(C),index:Ln(I,E.length/3),atomindex:n?new Int32Array(R):void 0,contour:w}}}function Ha(t,e,i,r){i=i||1,r=r||!0;var n,o=t.length/3,a=e.length/3;r&&(n=new Float32Array(3*o));var s,c=new Float32Array(3*o),u=new Array(20);for(s=0;s<20;++s)u[s]=new Uint32Array(o);for(s=0;s<o;++s)u[0][s]=0;var h,l,p;for(s=0;s<a;++s){var d=3*s,f=3*s+1,m=3*s+2;for(p=!0,h=0,l=u[0][e[d]];h<l;++h)if(e[f]===u[h+1][e[d]]){p=!1;break}for(p&&(u[++u[0][e[d]]][e[d]]=e[f]),p=!0,h=0,l=u[0][e[d]];h<l;++h)if(e[m]===u[h+1][e[d]]){p=!1;break}for(p&&(u[++u[0][e[d]]][e[d]]=e[m]),p=!0,h=0,l=u[0][e[f]];h<l;++h)if(e[d]===u[h+1][e[f]]){p=!1;break}for(p&&(u[++u[0][e[f]]][e[f]]=e[d]),p=!0,h=0,l=u[0][e[f]];h<l;++h)if(e[m]===u[h+1][e[f]]){p=!1;break}for(p&&(u[++u[0][e[f]]][e[f]]=e[m]),p=!0,h=0;h<u[0][e[m]];++h)if(e[d]===u[h+1][e[m]]){p=!1;break}for(p&&(u[++u[0][e[m]]][e[m]]=e[d]),p=!0,h=0,l=u[0][e[m]];h<l;++h)if(e[f]===u[h+1][e[m]]){p=!1;break}p&&(u[++u[0][e[m]]][e[m]]=e[f])}for(var g,v,y,b,x,_=0;_<i;++_){for(s=0;s<o;++s)if(g=3*s,(y=u[0][s])<3)c[g]=t[g],c[g+1]=t[g+1],c[g+2]=t[g+2];else if(3===y||4===y){for(c[g]=0,c[g+1]=0,c[g+2]=0,h=0;h<y;++h)v=3*u[h+1][s],c[g]+=t[v],c[g+1]+=t[v+1],c[g+2]+=t[v+2];c[g]+=.5*t[g],c[g+1]+=.5*t[g+1],c[g+2]+=.5*t[g+2],x=.5+y,c[g]/=x,c[g+1]/=x,c[g+2]/=x}else{for(c[g]=0,c[g+1]=0,c[g+2]=0,h=0;h<y;++h)v=3*u[h+1][s],c[g]+=t[v],c[g+1]+=t[v+1],c[g+2]+=t[v+2];c[g]+=1*t[g],c[g+1]+=1*t[g+1],c[g+2]+=1*t[g+2],b=1+y,c[g]/=b,c[g+1]/=b,c[g+2]/=b}if(t.set(c),r){Wa(t,e,n);var w=3*o;for(g=0;g<w;g+=3)t[g]+=.75/4.5*-1*n[g],t[g+1]+=.75/4.5*-1*n[g+1],t[g+2]+=.75/4.5*-1*n[g+2]}}}function Wa(t,e,i){var r,n;if(void 0===i)i=new Float32Array(t.length);else for(r=0,n=i.length;r<n;r++)i[r]=0;var o=new Float32Array(3),a=new Float32Array(3),s=new Float32Array(3),c=new Float32Array(3),u=new Float32Array(3);if(e)for(r=0,n=e.length;r<n;r+=3){var h=3*e[r],l=3*e[r+1],p=3*e[r+2];oa(o,t,h),oa(a,t,l),oa(s,t,p),na(c,s,a),na(u,o,a),ra(c,c,u),i[h]+=c[0],i[h+1]+=c[1],i[h+2]+=c[2],i[l]+=c[0],i[l+1]+=c[1],i[l+2]+=c[2],i[p]+=c[0],i[p+1]+=c[1],i[p+2]+=c[2]}else for(r=0,n=t.length;r<n;r+=9)oa(o,t,r),oa(a,t,r+3),oa(s,t,r+6),na(c,s,a),na(u,o,a),ra(c,c,u),i[r]=c[0],i[r+1]=c[1],i[r+2]=c[2],i[r+3]=c[0],i[r+4]=c[1],i[r+5]=c[2],i[r+6]=c[0],i[r+7]=c[1],i[r+8]=c[2];return ea(i),i}function Xa(t){for(var e={},i=0,r=t.length;i<r;++i)e[t[i]]=!0;return e}function qa(t,e,i,r,n){var o=1/r*3;ha(t,t,n+(o+=i)),la(e,e,n+o),ca(t,t,r),pa(t,t),sa(t,t,r),ca(e,e,r),da(e,e),sa(e,e,r);var a=new Float32Array(3);na(a,e,t),ca(a,a,r),da(a,a),la(a,a,1);var s=256*Math.pow(10,6),c=a[0]*a[1]*a[2]*3;s<=c&&(ca(t,t,r*=Math.pow(s/c,1/3)),pa(t,t),sa(t,t,r),ca(e,e,r),da(e,e),sa(e,e,r),na(a,e,t),ca(a,a,r),da(a,a),la(a,a,1));var u=new Float32Array(t);fa(u,u);var h=Ia(),l=Ia();Na(l,Hn(90)),La(h,h,l);var p=Ia();Oa(p,-1/r,1/r,1/r),La(h,h,p);var d=Ia();return Da(d,-r*u[2],-r*u[1],-r*u[0]),La(h,h,d),{dim:a,tran:u,matrix:h,scaleFactor:r}}function Ya(t,e,i,r,n){function o(t,e,i,r,n,o){var s=a.triangulate(t,e,i,n,o);if(e&&!n&&(Ha(s.position,s.index,e,!0),s.normal=Wa(s.position,s.index)),r&&(Jo(r,s.position),s.normal)){var c=ka();Fa(c,r),ta(c,s.normal)}return s}var a=new $a(t,e,i,r,n);this.getSurface=o}function Za(t){this.polymer=t,this.size=t.residueCount}function Ka(t){this.polymer=t,this.helixorient=new Za(t),this.position=this.helixorient.getPosition()}function Qa(t){this.content=[],this.scoreFunction=t}function Ja(t,e){function i(e,r,n,o){e>s&&(s=e);var a=o-n;if(0===a)return-1;var u=4*l;if(l+=1,1===a)return h[u]=n,h[u+1]=-1,h[u+2]=-1,h[u+3]=r,u;var d=n+Math.floor(a/2);p=e%3;for(var f,m,g,v,y,b=n,x=o-1;x>b;){for(v=t[3*c[g=b+x>>1]+p],m=c[g],c[g]=c[x],c[x]=m,y=b,f=b;f<x;++f)t[3*c[f]+p]<v&&(m=c[y],c[y]=c[f],c[f]=m,++y);if(m=c[x],c[x]=c[y],c[y]=m,g=y,d===g)break;d<g?x=g-1:b=g+1}return h[u]=d,h[u+1]=i(e+1,u,n,d),h[u+2]=i(e+1,u,d+1,o),h[u+3]=r,u}function r(t){var e=h[t+3];return-1===e?0:r(e)+1}function n(i,n,o){function a(u){function l(t,e){s.push([t,e]),s.size()>n&&s.pop()}var p,d,f=r(u)%3,m=3*c[h[u]],g=[t[m+0],t[m+1],t[m+2]],v=e(i,g),y=h[u+1],b=h[u+2];if(-1===b&&-1===y)return void((s.size()<n||v<s.peek()[1])&&v<=o&&l(u,v));a(p=-1===b?y:-1===y?b:i[f]<=t[m+f]?y:b),(s.size()<n||v<s.peek()[1])&&v<=o&&l(u,v);for(var x=[],_=0;_<3;_+=1)x[_]=_===f?i[_]:t[m+_];var w=e(x,g);(s.size()<n||Math.abs(w)<s.peek()[1])&&Math.abs(w)<=o&&-1!==(d=p===y?b:y)&&a(d)}var s=new Qa(function(t){return-t[1]});a(d);for(var u=[],l=0,p=Math.min(s.size(),n);l<p;l+=1)u.push(s.content[l]);return u}function o(e,i){var r=1;if(void 0===e&&(e=d,i=0),-1===e)throw new Error("node is null");var n=i%3,a=h[e+1],s=h[e+2];if(-1!==a){if(t[3*c[h[a]]+n]>t[3*c[h[e]]+n])throw new Error("left child is > parent!");r+=o(a,i+1)}if(-1!==s){if(t[3*c[h[s]]+n]<t[3*c[h[e]]+n])throw new Error("right child is < parent!");r+=o(s,i+1)}return r}for(var a=t.length/3,s=0,c=new Uint32Array(a),u=0;u<a;++u)c[u]=u;var h=new Int32Array(4*a),l=0,p=0,d=i(0,-1,0,a);this.rootIndex=d,this.maxDepth=s,this.nearest=n,this.indices=c,this.nodes=h,this.verify=o}function ts(e,i){t.Debug&&cf.time("Kdtree build");var r;r=i?function(t,e){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}:function(t,e){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(i*i+r*r+n*n)};var n=new Float32Array(3*e.atomCount),o=new Uint32Array(e.atomCount),a=0;e.eachAtom(function(t){n[a+0]=t.x,n[a+1]=t.y,n[a+2]=t.z,o[a/3]=t.index,a+=3}),this.atomIndices=o,this.points=n,this.kdtree=new Ja(n,r),t.Debug&&cf.timeEnd("Kdtree build")}function es(t){var e=cv[t],i={};if(void 0===e)return console.warn("getSymmetryOperations: spacegroup '"+t+"' not found in symop library"),i;for(var r=[],n=0,o=e.length;n<o;n+=3){for(var a=[],s=0;s<3;++s)a.push(sv[e[n+s]]);r.push(a)}var c=/^[1-9]$/;return r.forEach(function(t){var e=0,r=(new v).set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1),n=r.elements;i[t]=r,t.forEach(function(t){for(var i=!1,r=!1,o=0,a=t.length;o<a;++o){var s=t[o];if("-"===s)i=!0;else if("+"===s)i=!1;else if("/"===s)r=!0;else if("X"===s)n[0+e]=i?-1:1;else if("Y"===s)n[4+e]=i?-1:1;else if("Z"===s)n[8+e]=i?-1:1;else if(c.test(s)){var u=parseInt(s);r?n[12+e]/=u:n[12+e]=u}else cf.warn('getSymmetryOperations: unknown token "'+s+'"')}e+=1})}),i}function is(t){var e="";return t.length>0&&(e=":"+En(t).join(" OR :")),new Kd(e)}function rs(e,i){if(i){t.Debug&&cf.time("assignSecondaryStructure");var r=[];e.eachModel(function(t){t.eachChain(function(t){r.push(t.chainname)})});var n=r.slice().sort(),o=[];n.forEach(function(t){o.push(r.indexOf(t))});var a=i.helices;(a=a.filter(function(t){return An(n,t[0])>=0})).sort(function(t,e){var i=t[0],r=e[0],a=t[1],s=e[1];if(i===r)return a===s?0:a<s?-1:1;var c=An(n,i),u=An(n,r);return o[c]<o[u]?-1:1});var s=e.residueStore;e.eachModel(function(t){var e=0,i=a.length;if(0!==i){var r=a[e],n=!1,o=!1;t.eachChain(function(t){var c=!1;if(t.chainname===r[0])for(var u=t.residueCount,h=t.residueOffset,l=h+u,p=h;p<l;++p)if(s.resno[p]===r[1]&&s.getInscode(p)===r[2]&&(n=!0),n&&(s.sstruc[p]=r[6],s.resno[p]===r[4]&&s.getInscode(p)===r[5]&&(n=!1,(e+=1)<i?(p=h-1,r=a[e],c=t.chainname!==r[0]):o=!0)),c||o)return})}});var c=i.sheets;(c=c.filter(function(t){return An(n,t[0])>=0})).sort(function(t,e){var i=t[0],r=e[0];if(i===r)return 0;var a=An(n,i),s=An(n,r);return o[a]<o[s]?-1:1});var u="e".charCodeAt(0);e.eachModel(function(t){var e=0,i=c.length;if(0!==i){var r=c[e],n=!1,o=!1;t.eachChain(function(t){var a=!1;if(t.chainname===r[0])for(var h=t.residueCount,l=t.residueOffset,p=l+h,d=l;d<p;++d)if(s.resno[d]===r[1]&&s.getInscode(d)===r[2]&&(n=!0),n&&(s.sstruc[d]=u,s.resno[d]===r[4]&&s.getInscode(d)===r[5]&&(n=!1,(e+=1)<i?(d=l-1,r=c[e],a=t.chainname!==r[0]):o=!0)),a||o)return})}}),t.Debug&&cf.timeEnd("assignSecondaryStructure")}}function ns(e){t.Debug&&cf.time("calculateChainnames");var i=!0;if(e.eachChain(function(t){t.chainname&&(i=!1)}),i){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n=r.length,o=e.modelStore,a=e.chainStore,s=e.residueStore,c=function(t,e,i,r){for(var n=a.count,c=0;c<r;++c)s.chainIndex[i+c]=n;a.growIfFull(),a.modelIndex[n]=t,a.setChainname(n,e),a.setChainid(n,e),a.residueOffset[n]=i,a.residueCount[n]=r,a.count+=1,o.chainCount[t]+=1},u=function(t){for(var e=t,i=0,o=r[e%n];e>=n;)e=Math.floor(e/n),o+=r[e%n],i+=1;return i>=5&&cf.warn("chainname overflow"),o},h=e.getAtomProxy(),l=e.getAtomProxy(),p=0,d=0,f=0,m=0,g=[];1===s.count?g.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):e.eachResidueN(2,function(t,e){var i=!1,r=t.backboneType,n=e.backboneType,o=yg;m=t.index,t.modelIndex!==e.modelIndex?i=!0:t.moleculeType!==e.moleculeType?i=!0:r!==o&&r===n&&(h.index=t.backboneEndAtomIndex,l.index=e.backboneStartAtomIndex,h.connectedTo(l)||(i=!0)),i||e.index!==s.count-1||(i=!0,m=e.index),i&&(g.push({mIndex:d,chainname:u(p),rStart:f,rCount:m-f+1}),p+=1,t.modelIndex!==e.modelIndex&&(p=0,d+=1),e.index===s.count-1&&m!==e.index&&g.push({mIndex:d,chainname:u(p),rStart:s.count-1,rCount:1}),f=e.index,m=e.index)}),a.count=0,g.forEach(function(t){c(t.mIndex,t.chainname,t.rStart,t.rCount)});var v=0;e.eachModel(function(t){o.chainOffset[t.index]=v,o.chainCount[t.index]-=1,v+=o.chainCount[t.index]})}t.Debug&&cf.timeEnd("calculateChainnames")}function os(e){t.Debug&&cf.time("calculateBonds"),cs(e),us(e),t.Debug&&cf.timeEnd("calculateBonds")}function as(e){var i=e.structure,r=i.getAtomProxy(),n=i.getAtomProxy(),o=e.atomCount,a=e.atomOffset,s=a+o-1;if(o>500)return void(t.Debug&&cf.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName()));var c,u,h=[],l=[],p=[];if(o>50){var d=new ts(e,!0),f=e.isCg()?1.2:2.3;for(c=a;c<s;++c){r.index=c;var m=r.covalent+f+.3,g=d.nearest(r,1/0,m*m),v=g.length;for(u=0;u<v;++u)n.index=g[u].index,r.index<n.index&&r.connectedTo(n)&&(h.push(r.index-a),l.push(n.index-a),p.push(1))}}else for(c=a;c<s;++c)for(r.index=c,u=c+1;u<=s;++u)n.index=u,r.connectedTo(n)&&(h.push(c-a),l.push(u-a),p.push(1));return{atomIndices1:h,atomIndices2:l,bondOrders:p}}function ss(e){t.Debug&&cf.time("calculateAtomBondMap");var i=[];return e.eachBond(function(t){var e=t.atomIndex1,r=t.atomIndex2;void 0===i[e]&&(i[e]=[]),i[e][r]=t.index}),t.Debug&&cf.timeEnd("calculateAtomBondMap"),i}function cs(e,i){t.Debug&&cf.time("calculateBondsWithin");var r=e.bondStore,n=e.rungBondStore,o=e.getAtomSet(!1),a=e.getAtomProxy(),s=e.getAtomProxy(),c=e.getBondProxy(),u=i?null:ss(e);e.eachResidue(function(t){if(!i){var e=t.atomCount,h=t.atomOffset;if(e>500)return void cf.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var l=t.getBonds(),p=l.atomIndices1,d=l.atomIndices2,f=l.bondOrders,m=p.length,g=0;g<m;++g){var v=p[g]+h,y=d[g]+h,b=u[v];void 0!==b&&void 0!==(b=b[y])?(c.index=b,f[t.residueType.getBondIndex(v,y)]=c.bondOrder):(a.index=v,s.index=y,r.addBond(a,s,f[g]))}}var x=t.residueType.traceAtomIndex,_=t.residueType.rungEndAtomIndex;-1!==x&&-1!==_&&(a.index=t.traceAtomIndex,s.index=t.rungEndAtomIndex,n.addBond(a,s),o.set(a.index),o.set(s.index))}),e.atomSetDict.rung=o,t.Debug&&cf.timeEnd("calculateBondsWithin")}function us(e,i){function r(t,e){var r=t.backboneType,u=e.backboneType;r!==yg&&r===u&&(s.index=t.backboneEndAtomIndex,c.index=e.backboneStartAtomIndex,s.connectedTo(c)&&(i||n.addBond(s,c,1),s.index=t.traceAtomIndex,c.index=e.traceAtomIndex,o.addBond(s,c),a.set(s.index),a.set(c.index)))}t.Debug&&cf.time("calculateBondsBetween");var n=e.bondStore,o=e.backboneBondStore,a=e.getAtomSet(!1),s=e.getAtomProxy(),c=e.getAtomProxy();0===o.count&&o.resize(e.residueStore.count),e.eachResidueN(2,r);var u=e.getResidueProxy(),h=e.getResidueProxy();e.eachChain(function(t){0!==t.residueCount&&(u.index=t.residueOffset,h.index=t.residueOffset+t.residueCount-1,r(h,u))}),e.atomSetDict.backbone=a,t.Debug&&cf.timeEnd("calculateBondsBetween")}function hs(e){function i(t){var e=[];return Object.keys(o).forEach(function(i){var u=o[i].clone();s.copy(n).applyMatrix4(u),c.setFromMatrixPosition(u),c.sub(a),s.x>1&&(c.x-=1),s.x<0&&(c.x+=1),s.y>1&&(c.y-=1),s.y<0&&(c.y+=1),s.z>1&&(c.z-=1),s.z<0&&(c.z+=1),t&&c.add(t),u.setPosition(c),u.multiplyMatrices(r.fracToCart,u),u.multiply(r.cartToFrac),e.push(u)}),e}if(e.unitcell){t.Debug&&cf.time("buildUnitcellAssembly");var r=e.unitcell,n=e.center.clone().applyMatrix4(r.cartToFrac),o=es(r.spacegroup),a=new g,s=new g,c=new g;n.x>1&&(a.x-=1),n.x<0&&(a.x+=1),n.y>1&&(a.y-=1),n.y<0&&(a.y+=1),n.z>1&&(a.z-=1),n.z<0&&(a.z+=1);var u,h=new uv("UNITCELL"),l=i();if(e.biomolDict.NCS){u=[new v].concat(e.biomolDict.NCS.partList[0].matrixList);var p=[];l.forEach(function(t){u.forEach(function(e){p.push(t.clone().multiply(e))})}),h.addPart(p)}else h.addPart(l);var d=new g,f=new uv("SUPERCELL"),m=Array.prototype.concat.call(i(d.set(1,0,0)),i(d.set(0,1,0)),i(d.set(0,0,1)),i(d.set(-1,0,0)),i(d.set(0,-1,0)),i(d.set(0,0,-1)),i(d.set(1,1,0)),i(d.set(1,0,1)),i(d.set(0,1,1)),i(d.set(-1,-1,0)),i(d.set(-1,0,-1)),i(d.set(0,-1,-1)),i(d.set(1,-1,-1)),i(d.set(1,1,-1)),i(d.set(1,-1,1)),i(d.set(-1,1,1)),i(d.set(-1,-1,1)),i(d.set(-1,1,-1)),i(d.set(0,1,-1)),i(d.set(0,-1,1)),i(d.set(1,0,-1)),i(d.set(-1,0,1)),i(d.set(1,-1,0)),i(d.set(-1,1,0)),i(),i(d.set(1,1,1)),i(d.set(-1,-1,-1)));if(e.biomolDict.NCS){var y=[];m.forEach(function(t){u.forEach(function(e){y.push(t.clone().multiply(e))})}),f.addPart(y)}else f.addPart(m);e.biomolDict.UNITCELL=h,e.biomolDict.SUPERCELL=f,t.Debug&&cf.timeEnd("buildUnitcellAssembly")}}function ls(t){var e=t.trim().toUpperCase();parseInt(e.charAt(0))&&(e=e.substr(1)),parseInt(e.charAt(0))&&(e=e.substr(1));var i=e.length;if(0===i)return"";if(1===i)return e;if(2===i){if(-1!==mv.indexOf(e))return e;if(-1!==fv.indexOf(e[0]))return e[0]}return i>=3&&-1!==fv.indexOf(e[0])?e[0]:""}function ps(t){var e=t.bondHash,i=e.countArray,r=e.offsetArray,n=e.indexArray,o=t.getBondProxy();t.eachResidue(function(t){var e=t.residueType;if(void 0===e.bonds){var a=t.atomOffset,s=[],c=[],u=[],h={};t.eachAtom(function(t){for(var e=t.index,l=r[e],p=0,d=i[e];p<d;++p){o.index=n[l+p];var f=o.atomIndex1,m=o.atomIndex2;if(f>m){var g=m;m=f,f=g}var v=f+"|"+m;void 0===h[v]&&(h[v]=!0,s.push(f-a),c.push(m-a),u.push(o.bondOrder))}}),e.bonds={atomIndices1:s,atomIndices2:c,bondOrders:u}}})}function ds(t,e){return t+"|"+e}function fs(t,e,i,r){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+(r||"")}function ms(t,e){function i(e){t(e,r)}function r(){var t=n.shift();void 0!==t?(o=!0,setTimeout(function(){i(t)})):o=!1}var n=[],o=!1;if(e){for(var a=0,s=e.length;a<s;++a)n.push(e[a]);r()}this.push=function(t){n.push(t),o||r()},this.kill=function(){n.length=0},this.length=function(){return n.length}}function gs(t,e,i){if(0!==i[0]&&0!==i[8]&&0!==i[4]){var r,n=t.length,o=i[0],a=i[1],s=i[2],c=-e[0]+o+o/2,u=-e[1]+a+a/2,h=-e[2]+s+s/2;for(r=0;r<n;r+=3)t[r+0]=(t[r+0]+c)%o,t[r+1]=(t[r+1]+u)%a,t[r+2]=(t[r+2]+h)%s}}function vs(t,e){if(0!==e[0]&&0!==e[8]&&0!==e[4]){var i,r,n,o,a=t.length;for(i=3;i<a;i+=3)for(r=0;r<3;++r)if(o=t[i+r]-t[i-3+r],Math.abs(o)>.9*e[3*r+r])if(o>0)for(n=0;n<3;++n)t[i+n]-=e[3*r+n];else for(n=0;n<3;++n)t[i+n]+=e[3*r+n];return t}}function ys(t){return"front"===t?Au:"back"===t?Mu:Pu}function bs(t,e){t.matrix.copy(e),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixWorldNeedsUpdate=!0}function xs(t){var e=JSON.stringify(t);return void 0===wy[e]&&(wy[e]=new Sy(t)),wy[e]}function _s(t,e){void 0!==t.toArray?t=t.toArray():void 0!==t.x?t=[t.x,t.y,t.z]:void 0!==t.r&&(t=[t.r,t.g,t.b]),e.push.apply(e,t)}function ws(t){t.visible=!0}function Ss(t){t.visible=!1}function As(t,e,i,r){var n=i-t,o=r-e;return Math.sqrt(n*n+o*o)}function Ms(t){for(var e=t||{},i=gn(e.width,256),r=gn(e.height,256),n=[i/2,r/2],o=Math.min(i/2,r/2),a=gn(e.delta,1/(o+1))*o,s=0,c=0,u=new Uint8Array(i*r*4),h=0,l=u.length;h<l;h+=4){var p=1-eo(o-a,o,As(s,c,n[0],n[1]));u[h]=255*p,u[h+1]=255*p,u[h+2]=255*p,u[h+3]=255*p,++s===i&&(s=0,c++)}var d=new y(u,i,r);return d.needsUpdate=!0,d}function Ps(t){cf.error("makeRepresentation: representation type "+t+" unknown")}function Ts(e,i,r,n){t.Debug&&cf.time("makeRepresentation "+e);var o;if(i instanceof Lv){if(!(o=df.get(e)))return void Ps(e)}else if(i instanceof qg)if("surface"===e)o=Ny;else{if("dot"!==e)return void Ps(e);o=Fy}else if(i instanceof Zg)if("surface"===e)o=Ny;else if("dot"===e)o=Fy;else{if("slice"!==e)return void Ps(e);o=Gy}else if(i instanceof kv)o=Hy;else if(i instanceof Ty)o=Iy,i=i.getBufferList();else{if("buffer"!==e)return void cf.error("makeRepresentation: object "+i+" unknown");o=Iy}var a=new o(i,r,n);return t.Debug&&cf.timeEnd("makeRepresentation "+e),a}function Es(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}function Cs(t,e){var i,r=0,n={};return e.forEach(function(e){i=0;var o={};e.forEach(function(e){o[t[i++]]=e}),n[t[r++]]=o}),n}function Is(t,e,i,r,n){i=gn(i,!1),r=gn(r,""),n=gn(n,"");var o,a,s,c,u;if(i){var h=t,l=e;r&&n&&(h=t.getView(new Kd(r)),l=e.getView(new Kd(n)));var p=h.getSequence(),d=l.getSequence(),f=new ab(p.join(""),d.join(""));f.calc(),f.trace();var m,g,v,y,b;o=0,a=0,s=f.ali1.length;var x=[],_=[];for(m=0;m<s;++m)y=f.ali1[m],b=f.ali2[m],g=0,v=0,"-"===y?_[a]=!1:(_[a]=!0,g=1),"-"===b?x[o]=!1:(x[o]=!0,v=1),o+=g,a+=v;var w=[],S=[],A=h.getAtomProxy(),M=l.getAtomProxy();o=0,h.eachResidue(function(t){void 0!==t.traceAtomIndex&&t.traceAtomIndex===t.getAtomIndexByName("CA")&&(x[o]&&(A.index=t.getAtomIndexByName("CA"),w.push(A.x,A.y,A.z)),o+=1)}),o=0,l.eachResidue(function(t){void 0!==t.traceAtomIndex&&t.traceAtomIndex===t.getAtomIndexByName("CA")&&(_[o]&&(M.index=t.getAtomIndexByName("CA"),S.push(M.x,M.y,M.z)),o+=1)}),c=new Float32Array(w),u=new Float32Array(S)}else c=t.getView(new Kd(r+" and .CA")),u=e.getView(new Kd(n+" and .CA"));new Dv(c,u).transform(t),t.refreshPosition()}function Rs(t,e){var i=!1,r=!1,n=!1;return(e=e||new g).set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom(function(t){if(!i)return"H"===t.atomname?(e.set(t),void(i=!0)):void(r||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,e.sub(t)):(e.sub(t),r=!0))}),i?e:r&&n?(e.normalize(),e.multiplyScalar(mb),e.add(t),e):void 0}function Ls(t){for(var e=t.length,i=new Float32Array(e),r=new Float32Array(e),n=new Float32Array(e),o=0;o<t.length;o++){var a=t[o];i[o]=a.x,r[o]=a.y,n[o]=a.z}return{x:i,y:r,z:n,count:e}}function Os(){return 16777215*Math.random()}function Ds(t,e,i){return t&&"Frames"===t.type?new zb(t,e,i):!t&&e.frames?new Ub(t,e,i):new jb(t,e,i)}function Ns(t,e){function i(t,i,r,n,o,a,s){a[s+0]=to(t.x,i.x,r.x,n.x,o,e),a[s+1]=to(t.y,i.y,r.y,n.y,o,e),a[s+2]=to(t.z,i.z,r.z,n.z,o,e)}function r(t,i,r,n,o,a){a.x=to(t.x,i.x,r.x,n.x,o,e),a.y=to(t.y,i.y,r.y,n.y,o,e),a.z=to(t.z,i.z,r.z,n.z,o,e)}function n(e,r,n,o,a,s){for(var c=0;c<t;++c)i(e,r,n,o,p*c,a,s+3*c)}function o(e,i,n,o,a,s){for(var c=0;c<t;++c){var u=p*c,h=u-d,l=u+d,g=s+3*c;h<0&&(h=0),l>1&&(l=1),r(e,i,n,o,h,f),r(e,i,n,o,l,m),m.sub(f).normalize(),m.toArray(a,g)}}function a(e,i,r,n,o){for(var a=i.next(),s=i.next(),c=i.next(),u=i.size,h=u-1,l=n||0,p=0;p<h;++p)e(a,a=s,s=c,c=i.next(),r,l),l+=3*t;o&&(e(i.get(u-2),a=i.get(u-1),s=i.get(0),c=i.get(1),r,l),l+=3*t)}function s(e,i,n,o,a,s,c,u,h,l,d,g,w){for(var S=0;S<t;++S){var A=g+3*S;w&&(A+=3*_);var M=p*S;r(e,i,n,o,M,f),r(a,s,c,u,M,m),v.subVectors(m,f).normalize(),y.fromArray(h,A),x.crossVectors(v,y).normalize(),x.toArray(d,A),b.crossVectors(y,x).normalize(),b.toArray(l,A)}}function c(e,i,r,n,o){for(var a=0;a<t;++a){var s=o+3*a;e.copy(b),y.fromArray(i,s),x.crossVectors(e,y).normalize(),x.toArray(n,s),b.crossVectors(y,x).normalize(),b.toArray(r,s)}}function u(e,i,r,n,o){var a;for(a=0;a<_;++a)r(e,n,o+3*a);for(a=_;a<t;++a)r(i,n,o+3*a)}function h(e,i,r,n,o){var a;for(a=0;a<_;++a)n[o+a]=r(e);for(a=_;a<t;++a)n[o+a]=r(i)}function l(e,i,r,n,o){for(var a=r(e),s=r(i),c=0;c<t;++c){var u=c/t;n[o+c]=(1-u)*a+u*s}}var p=1/t,d=1e-4,f=new g,m=new g;this.getPosition=function(e,i,r,o){e.reset(),a(n,e,i,r,o);var s=e.size-1,c=s*t*3;o&&(c+=3*t);var u=e.get(o?0:s);i[c]=u.x,i[c+1]=u.y,i[c+2]=u.z},this.getTangent=function(e,i,r,n){e.reset(),a(o,e,i,r,n);var s=(e.size-1)*t*3;n&&(s+=3*t),Lo(i,i,s-3,s,3)};var v=new g,y=new g,b=new g,x=new g,_=Math.ceil(t/2);this.getNormal=function(e,i,r,n,o,a){b.set(0,0,1);for(var s=e-1,u=o||0,h=0;h<s;++h)c(v,i,r,n,u),u+=3*t;a&&(c(v,i,r,n,u),u+=3*t),x.toArray(n,u),b.toArray(r,u)},this.getNormalDir=function(e,i,r,n,o,a,c,u){e.reset(),i.reset();var h=new g,l=new g,p=new g,d=new g,f=new g,m=(new g).copy(e.next()),v=(new g).copy(e.next()),y=(new g).copy(e.next()),w=new g,S=(new g).copy(i.next()),A=(new g).copy(i.next()),M=(new g).copy(i.next());b.set(0,0,1);for(var P=e.size,T=P-1,E=a||0,C=0;C<T;++C)f.copy(m),m.copy(v),v.copy(y),y.copy(e.next()),w.copy(S),S.copy(A),A.copy(M),M.copy(i.next()),0===C?(h.subVectors(w,f),l.subVectors(S,m),h.dot(l)<0&&(l.multiplyScalar(-1),S.addVectors(m,l)),p.subVectors(A,v),l.dot(p)<0&&(p.multiplyScalar(-1),A.addVectors(v,p))):p.copy(d),d.subVectors(M,y),p.dot(d)<0&&(d.multiplyScalar(-1),M.addVectors(y,d)),s(f,m,v,y,w,S,A,M,r,n,o,E,u),E+=3*t;if(c&&(f.copy(e.get(P-2)),m.copy(e.get(P-1)),v.copy(e.get(0)),y.copy(e.get(1)),w.copy(i.get(P-2)),S.copy(i.get(P-1)),A.copy(i.get(0)),M.copy(i.get(1)),p.copy(d),d.subVectors(M,y),p.dot(d)<0&&(d.multiplyScalar(-1),M.addVectors(y,d)),s(f,m,v,y,w,S,A,M,r,n,o,E,u),E+=3*t),u){x.fromArray(o,3*_),b.fromArray(n,3*_);for(var I=0;I<_;++I)x.toArray(o,3*I),b.toArray(n,3*I)}else x.toArray(o,E),b.toArray(n,E)},this.getColor=function(e,i,r,n,o){e.reset(),e.next();for(var a=e.next(),s=e.size,c=s-1,h=n||0,l=0;l<c;++l)u(a,a=e.next(),i,r,h),h+=3*t;o&&(u(e.get(s-1),a=e.get(0),i,r,h),h+=3*t),r[h]=r[h-3],r[h+1]=r[h-2],r[h+2]=r[h-1]},this.getPicking=function(e,i,r,n,o){e.reset(),e.next();for(var a=e.next(),s=e.size,c=s-1,u=n||0,l=0;l<c;++l)h(a,a=e.next(),i,r,u),u+=t;o&&(h(e.get(s-1),a=e.get(0),i,r,u),u+=t),r[u]=r[u-1]},this.getSize=function(e,i,r,n,o){e.reset(),e.next();for(var a=e.next(),s=e.size,c=s-1,u=n||0,h=0;h<c;++h)l(a,a=e.next(),i,r,u),u+=t;o&&(l(e.get(s-1),a=e.get(0),i,r,u),u+=t),r[u]=r[u-1]}}function ks(t,e){this.polymer=t,this.size=t.residueCount;var i=e||{};this.directional=i.directional||!1,this.positionIterator=i.positionIterator||!1,this.subdiv=i.subdiv||1,this.smoothSheet=i.smoothSheet||!1,isNaN(i.tension)?this.tension=this.polymer.isNucleic()?.5:.9:this.tension=i.tension||.5,this.interpolator=new Ns(this.subdiv,this.tension)}function Fs(t,e,i){e=e||3.5,i=i||40;for(var r=new Kd("( ARG and ( .NE or .NH1 or .NH2 ) ) or ( ASP and .ND2 ) or ( GLN and .NE2 ) or ( HIS and ( .ND1 or .NE2 ) ) or ( LYS and .NZ ) or ( SER and .OG ) or ( THR and .OG1 ) or ( TRP and .NE1 ) or ( TYR and .OH ) or ( PROTEIN and .N )"),n=new Kd("( ASN and .OD1 ) or ( ASP and ( OD1 or .OD2 ) ) or ( GLN and .OE1 ) or ( GLU and ( .OE1 or .OE2 ) ) or ( HIS and ( .ND1 or .NE2 ) ) or ( SER and .OG ) or ( THR and .OG1 ) or ( TYR and .OH ) or ( PROTEIN and .O )"),o=t.getView(r),a=t.getView(n),s=new tx(o,a).within(e),c=s.bondStore,u=t.getAtomProxy(),h=t.getAtomProxy(),l=t.getAtomProxy(),p=t.getAtomProxy(),d=t.getResidueProxy(),f=t.getResidueProxy(),m=new g,v=new g,y=0,b=c.count;y<b;++y)if(u.index=c.atomIndex1[y],h.index=c.atomIndex2[y],"O"===u.atomname&&"N"===h.atomname||"N"===u.atomname&&"O"===h.atomname)s.bondSet.clear(y);else if("N"===u.atomname||"N"===h.atomname){var x,_;if("N"===u.atomname?(x=u,_=h):(x=h,_=u),d.index=x.residueIndex,l.index=d.getAtomIndexByName("CA"),void 0===l.index)continue;var w=d.getPreviousConnectedResidue(f);if(void 0===w)continue;if(p.index=w.getAtomIndexByName("C"),void 0===p.index)continue;m.subVectors(x,p),v.subVectors(x,l),m.add(v).multiplyScalar(.5),v.subVectors(_,x),Wn(m.angleTo(v))>i&&s.bondSet.clear(y)}else("OH"===u.atomname&&"TYR"===u.resname||"OH"===h.atomname&&"TYR"===h.resname)&&(function(t,e,r,n){var o,a;t.atomname===r?(o=t,a=e):(o=e,a=t),d.index=o.residueIndex;var s=d.getAtomIndexByName(n);return m.subVectors(s,o),v.subVectors(s,a),Wn(m.angleTo(v))<i}(u,h,"OH","CZ")||s.bondSet.clear(y));return{atomSet:s.atomSet,bondSet:s.bondSet,bondStore:s.bondStore}}function Bs(t,e,i){e=e||3.5,i=i||40;for(var r=new Kd("( PROTEIN and .N )"),n=new Kd("( PROTEIN and .O )"),o=t.getView(r),a=t.getView(n),s=new tx(o,a).within(e),c=s.bondStore,u=t.getAtomProxy(),h=t.getAtomProxy(),l=t.getAtomProxy(),p=t.getAtomProxy(),d=t.getResidueProxy(),f=t.getResidueProxy(),m=new g,v=new g,y=0,b=c.count;y<b;++y){u.index=c.atomIndex1[y],h.index=c.atomIndex2[y];var x,_;if("N"===u.atomname?(x=u,_=h):(x=h,_=u),d.index=x.residueIndex,l.index=d.getAtomIndexByName("CA"),void 0!==l.index){var w=d.getPreviousConnectedResidue(f);void 0!==w&&(p.index=w.getAtomIndexByName("C"),void 0!==p.index&&(m.subVectors(x,p),v.subVectors(x,l),m.add(v).multiplyScalar(.5),v.subVectors(_,x),Wn(m.angleTo(v))>i&&s.bondSet.clear(y)))}}return{atomSet:s.atomSet,bondSet:s.bondSet,bondStore:s.bondStore}}function zs(t,e){this.type=t,this.text=e||{}}function Us(t,e,i,r,n){function o(t,r,o){return((t*e+r)*i+o)*n}var a,s=new(r=r||Int32Array)(t*e*i*(n=n||1));this.data=s,this.index=o,this.set=function(t,e,i){var r=arguments,c=o(t,e,i);for(a=0;a<n;++a)s[c+a]=r[3+a]},this.toArray=function(t,e,i,r,c){var u=o(t,e,i);for(void 0===r&&(r=[]),void 0===c&&(c=0),a=0;a<n;++a)r[c+a]=s[u+a]},this.fromArray=function(t,e,i,r,c){var u=o(t,e,i);for(void 0===c&&(c=0),a=0;a<n;++a)s[u+a]=r[c+a]},this.copy=function(t){this.data.set(t.data)},this.clone=function(){return new Us(t,e,i,r,n).copy(this)}}function js(t,e,i){function r(t,e,i,r,o){m=e||1.4,g=i||2,P=o||!0;var a=0;for(var s in d)a=Math.max(a,s);var c=qa(I,R,a,g,t?m:0);y=c.dim[0],b=c.dim[1],x=c.dim[2],_=c.matrix,w=c.tran,g=c.scaleFactor,S={},A={},n(t),M=m*g,v=r||m/g,T=new Uint8Array(y*b*x),t&&(E=new Float64Array(y*b*x)),P&&(C=new Int32Array(y*b*x))}function n(t){var e,i,r,n,o,a,s,c,u,h;for(var l in d)if(e=d[l],!S[l]){for(a=(s=t?(e+m)*g+.5:e*g+.5)*s,c=Math.floor(s)+1,u=new Int32Array(c*c),h=0,i=0;i<c;++i)for(r=0;r<c;++r)(n=i*i+r*r)>a?u[h]=-1:(o=Math.sqrt(a-n),u[h]=Math.floor(o)),++h;A[l]=c,S[l]=u}}function o(i){var r,n,o,a,s,c,u,h,l,p,d,f,m,v,_,M,E,I,R=3*i,O=i;r=Math.floor(.5+g*(t[R]+w[0])),n=Math.floor(.5+g*(t[R+1]+w[1])),o=Math.floor(.5+g*(t[R+2]+w[2]));var D,N=e[O],k=S[N],F=0,B=b*x,z=A[N];for(p=0;p<z;++p)for(d=0;d<z;++d){if(-1!==(D=k[F]))for(M=-1;M<2;++M)for(E=-1;E<2;++E)for(I=-1;I<2;++I)if(0!==M&&0!==E&&0!==I)for(u=M*p,l=I*d,f=0;f<=D;++f)if(h=f*E,m=r+u,v=n+h,_=o+l,!(m<0||v<0||_<0||m>=y||v>=b||_>=x)){var U=m*B+v*x+_;if(P)if(T[U]&L){if(T[U]&L){var j=C[U];j!==R&&u*u+h*h+l*l<(a=r+u-Math.floor(.5+g*(t[j]+w[0])))*a+(s=n+h-Math.floor(.5+g*(t[j+1]+w[1])))*s+(c=o+l-Math.floor(.5+g*(t[j+2]+w[2])))*c&&(C[U]=i)}}else T[U]|=L,C[U]=i;else T[U]|=L}F++}}function a(e){console.time("EDTSurface fillvoxels");var i,r;for(i=0,r=T.length;i<r;++i)T[i]=0,e&&(E[i]=-1),P&&(C[i]=-1);for(i=0,r=t.length/3;i<r;++i)o(i);for(i=0,r=T.length;i<r;++i)T[i]&L&&(T[i]|=O);console.timeEnd("EDTSurface fillvoxels")}function s(i){var r,n,o,a,s,c,u,h,l,p,d,f,m,v,_,M,E,I,R,L=3*i,D=i,N=0;r=Math.floor(.5+g*(t[L]+w[0])),n=Math.floor(.5+g*(t[L+1]+w[1])),o=Math.floor(.5+g*(t[L+2]+w[2]));var k=e[D],F=b*x;for(m=0,R=A[k];m<R;++m)for(v=0;v<R;++v){if(-1!==S[k][N])for(M=-1;M<2;++M)for(E=-1;E<2;++E)for(I=-1;I<2;++I)if(0!==M&&0!==E&&0!==I)for(u=M*m,l=I*v,_=0;_<=S[k][N];++_)if(h=_*E,p=r+u,d=n+h,f=o+l,!(p<0||d<0||f<0||p>=y||d>=b||f>=x)){var B=p*F+d*x+f;if(T[B]&O){if(P){var z=C[B];u*u+h*h+l*l<(a=Math.floor(.5+g*(t[z]+w[0])))*a+(s=Math.floor(.5+g*(t[z+1]+w[1])))*s+(c=Math.floor(.5+g*(t[z+2]+w[2])))*c&&(C[B]=i)}}else T[B]|=O,P&&(C[B]=i)}N++}}function c(){var e,i;for(e=0,i=T.length;e<i;++e)T[e]&=~O;for(e=0,i=t.length/3;e<i;++e)s(e)}function u(){var t,e,i,r=b*x;for(t=0;t<y;++t)for(e=0;e<x;++e)for(i=0;i<b;++i){var n=t*r+i*x+e;if(T[n]&L)for(var o=0;o<26;){var a=t+N[o][0],s=e+N[o][2],c=i+N[o][1];if(a>-1&&a<y&&c>-1&&c<b&&s>-1&&s<x&&!(T[a*r+c*x+s]&L)){T[n]|=D;break}o++}}}function h(){console.time("EDTSurface fastdistancemap");var t,e,i,r,n,o=new Us(y,b,x,Uint16Array,3),a=b*x,s=M*M,c=0;for(t=0;t<y;++t)for(e=0;e<b;++e)for(i=0;i<x;++i)T[n=t*a+e*x+i]&=~O,T[n]&L&&T[n]&D&&(o.set(t,e,i,t,e,i),E[n]=0,T[n]|=O,c+=1);var u=new Int32Array(3*c),h=0,p=new Int32Array(3*c),d=0;for(t=0;t<y;++t)for(e=0;e<b;++e)for(i=0;i<x;++i)T[n=t*a+e*x+i]&D&&(u[h]=t,u[h+1]=e,u[h+2]=i,h+=3,T[n]&=~D);do{for(d=l(u,o,h,p),h=0,t=0,r=d;t<r;t+=3)n=a*p[t]+x*p[t+1]+p[t+2],T[n]&=~D,E[n]<=1.0404*s&&(u[h]=p[t],u[h+1]=p[t+1],u[h+2]=p[t+2],h+=3)}while(h>0);var f,m=v*v,g=new Uint16Array(3);for(t=0;t<y;++t)for(e=0;e<b;++e)for(i=0;i<x;++i)T[n=t*a+e*x+i]&=~D,T[n]&L&&(T[n]&O&&!(T[n]&O&&E[n]>=m)||(T[n]|=D,P&&T[n]&O&&(o.toArray(t,e,i,g),f=g[0]*a+g[1]*x+g[2],C[n]=C[f])));console.timeEnd("EDTSurface fastdistancemap")}function l(t,e,i,r){var n,o,a,s,c,u,h,l,p,d,f,m,g=new Uint16Array(3),v=0;if(0===i)return v;var _=-1,w=-1,S=-1,A=b*x;for(h=0,p=i;h<p;h+=3)for(n=t[h],o=t[h+1],a=t[h+2],e.toArray(n,o,a,g),l=0;l<6;++l)_=n+(m=N[l])[0],w=o+m[1],S=a+m[2],_<y&&_>-1&&w<b&&w>-1&&S<x&&S>-1&&(T[f=_*A+x*w+S]&L&&!(T[f]&O)?(e.fromArray(_,w,S,g),d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u,E[f]=d,T[f]|=O,T[f]|=D,r[v]=_,r[v+1]=w,r[v+2]=S,v+=3):T[f]&L&&T[f]&O&&(d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u)<E[f]&&(e.fromArray(_,w,S,g),E[f]=d,T[f]&D||(T[f]|=D,r[v]=_,r[v+1]=w,r[v+2]=S,v+=3)));for(h=0,p=i;h<p;h+=3)for(n=t[h],o=t[h+1],a=t[h+2],e.toArray(n,o,a,g),l=6;l<18;l++)_=n+(m=N[l])[0],w=o+m[1],S=a+m[2],_<y&&_>-1&&w<b&&w>-1&&S<x&&S>-1&&(T[f=_*A+x*w+S]&L&&!(T[f]&O)?(e.fromArray(_,w,S,g),d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u,E[f]=d,T[f]|=O,T[f]|=D,r[v]=_,r[v+1]=w,r[v+2]=S,v+=3):T[f]&L&&T[f]&O&&(d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u)<E[f]&&(e.fromArray(_,w,S,g),E[f]=d,T[f]&D||(T[f]|=D,r[v]=_,r[v+1]=w,r[v+2]=S,v+=3)));for(h=0,p=i;h<p;h+=3)for(n=t[h],o=t[h+1],a=t[h+2],e.toArray(n,o,a,g),l=18;l<26;l++)_=n+(m=N[l])[0],w=o+m[1],S=a+m[2],_<y&&_>-1&&w<b&&w>-1&&S<x&&S>-1&&(T[f=_*A+x*w+S]&L&&!(T[f]&O)?(e.fromArray(_,w,S,g),d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u,E[f]=d,T[f]|=O,T[f]|=D,r[v]=_,r[v+1]=w,r[v+2]=S,v+=3):T[f]&L&&T[f]&O&&(d=(s=_-g[0])*s+(c=w-g[1])*c+(u=S-g[2])*u)<E[f]&&(e.fromArray(_,w,S,g),E[f]=d,T[f]&D||(T[f]|=D,r[v]=_,r[v+1]=w,r[v+2]=S,v+=3)));return v}function p(t){var e,i=T.length;if("vws"===t)for(e=0;e<i;++e)T[e]&=~D,T[e]=T[e]&O?1:0;else if("ms"===t)for(e=0;e<i;++e)T[e]&=~O,T[e]&D&&(T[e]|=O),T[e]&=~D,T[e]=T[e]&O?1:0;else if("ses"===t)for(e=0;e<i;++e)T[e]&D&&T[e]&O?T[e]&=~D:T[e]&D&&!(T[e]&O)&&(T[e]|=O),T[e]=T[e]&O?1:0;else if("sas"===t)for(e=0;e<i;++e)T[e]&=~D,T[e]=T[e]&O?1:0}var d=Xa(e),f=Qo(t);0===t.length&&(f[0].set([0,0,0]),f[1].set([0,0,0]));var m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I=f[0],R=f[1],L=1,O=2,D=4,N=[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(t,e,o,s,l){console.time("EDTSurface.getVolume");var d="vws"!==t;r(d,e,o,s,l),a(d),u(),"ms"!==t&&"ses"!==t||h(),"ses"===t&&(n(!1),c()),p(t);for(var f=0,m=C.length;f<m;++f)C[f]=i[C[f]];return console.timeEnd("EDTSurface.getVolume"),{data:T,nx:x,ny:b,nz:y,atomindex:C}},this.getSurface=function(t,e,i,r,n,o,a){var s=this.getVolume(t,e,i,r,n);return new Ya(s.data,s.nx,s.ny,s.nz,s.atomindex).getSurface(1,o,void 0,_,a)}}function Gs(t,e,i,r,n,o,a){function s(t,e){return Math.floor((t-e)/a)}for(var c=t.length,u=n[0],h=n[1],l=n[2],p=o[0],d=o[1],f=o[2],m=s(p,u)+1,g=s(d,h)+1,v=s(f,l)+1,y=m*g*v,b=g*v,x=[],_=0;_<c;_++){var w=function(t,e,i){return(s(t,u)*g+s(e,h))*v+s(i,l)}(t[_],e[_],i[_]);void 0===x[w]?x[w]=[_]:x[w].push(_)}var S=new Uint32Array(y),A=new Uint16Array(y),M=new Uint32Array(c),P=0,T=0;for(_=0;_<y;_++){var E=S[_]=P,C=x[_];if(void 0!==C)for(var I=0;I<C.length;I++)M[P]=C[I],P++;var R=P-E;A[_]=R,R>T&&(T=R)}this.neighbourListLength=27*T+1,this.withinRadii=function(n,o,a,c,p){for(var d=0,f=s(n,u),y=s(o,h),x=s(a,l),_=Math.max(0,f-1),w=Math.max(0,y-1),P=Math.max(0,x-1),T=Math.min(m,f+1),E=Math.min(g,y+1),C=Math.min(v,x+1),I=_;I<=T;++I)for(var R=I*b,L=w;L<=E;++L)for(var O=L*v,D=P;D<=C;++D)for(var N=R+O+D,k=S[N],F=k+A[N],B=k;B<F;B++){var z=M[B],U=t[z]-n,j=e[z]-o,G=i[z]-a,V=r[z]+c;U*U+j*j+G*G<=V*V&&(p[d++]=M[B])}p[d]=-1}}function Vs(t,e,i){function r(t,i,r,n){T=gn(t,1.4),E=gn(i,2),C=gn(r,!0),I=gn(n,30),A=new Float32Array(v),M=new Float32Array(v);for(var c=0;c<A.length;++c){var u=e[c]+T;A[c]=u,M[c]=u*u}P=0;for(var h=0;h<A.length;++h)A[h]>P&&(P=A[h]);o(),a(),s(),H=-1}function n(t,e,i){for(var r=0;r<t.length;r++)t[r]=e+i*r}function o(){var t=qa(V,$,P,E,0);E=t.scaleFactor,R=t.dim,L=t.matrix,G=Math.min(5,2+Math.floor(T*E)),O=Po(R[0]*R[1]*R[2],-1001),D=new Int32Array(O.length),N=new Float32Array(R[0]),k=new Float32Array(R[1]),F=new Float32Array(R[2]),n(N,V[0],1/E),n(k,V[1],1/E),n(F,V[2],1/E)}function a(){var t=0,e=2*Math.PI/I;z=new Float32Array(I),B=new Float32Array(I);for(var i=0;i<I;i++)z[i]=Math.cos(t),B[i]=Math.sin(t),t+=e}function s(){U=new Gs(y,b,x,A,V,$,2.01*P),j=new Int32Array(U.neighbourListLength)}function c(t,e,i,r,n){var o;if(-1!==H){if((o=H)!==r&&o!==n&&u(o,t,e,i))return o;H=-1}var a=0;for(o=j[a];o>=0;){if(o!==r&&o!==n&&u(o,t,e,i))return H=o,o;o=j[++a]}return H=-1,-1}function u(e,i,r,n){var o=3*e,a=M[e],s=t[o]-i,c=t[o+1]-r,u=t[o+2]-n;return s*s+c*c+u*u<a}function h(){for(var t=0;t<v;t++){var e=y[t],i=b[t],r=x[t],n=A[t],o=M[t];U.withinRadii(e,i,r,n,j);for(var a=Math.ceil(n*E),s=Math.floor(E*(e-V[0])),u=Math.floor(E*(i-V[1])),h=Math.floor(E*(r-V[2])),l=Math.max(0,s-a),p=Math.max(0,u-a),d=Math.max(0,h-a),f=Math.min(R[0],s+a+2),m=Math.min(R[1],u+a+2),g=Math.min(R[2],h+a+2),_=l;_<f;_++)for(var w=N[_]-e,S=R[1]*R[2]*_,P=p;P<m;P++)for(var T=k[P]-i,I=w*w+T*T,L=S+R[2]*P,B=d;B<g;B++){var z=F[B]-r,G=I+z*z;if(G<o){var $=B+L;O[$]<0&&(O[$]=-O[$]);var H=Math.sqrt(G),W=n/H,X=w*W,q=T*W,Y=z*W;if(X+=e,q+=i,Y+=r,-1===c(X,q,Y,t,-1)){var Z=n-H;Z<O[$]&&(O[$]=Z,C&&(D[$]=t))}}}}}function l(){for(var t=0;t<v;t++){U.withinRadii(y[t],b[t],x[t],A[t],j);for(var e=0,i=j[e];i>=0;)t<i&&p(t,i),i=j[++e]}}function p(t,e){var i=A[t],r=A[e],n=W[0]=y[e]-y[t],o=W[1]=b[e]-b[t],a=W[2]=x[e]-x[t],s=n*n+o*o+a*a,u=Math.sqrt(s),h=i*((i*i+u*u-r*r)/(2*i*u));ua(W,W),d(X,W),ua(X,X),ra(q,W,X),ua(q,q);var l=Math.sqrt(i*i-h*h);ca(X,X,l),ca(q,q,l),ca(W,W,h),W[0]+=y[t],W[1]+=b[t],W[2]+=x[t],H=-1;for(var p=G,f=0;f<I;f++){var m=z[f],g=B[f],v=W[0]+m*X[0]+g*q[0],_=W[1]+m*X[1]+g*q[1],w=W[2]+m*X[2]+g*q[2];if(-1===c(v,_,w,t,e))for(var S=Math.floor(E*(v-V[0])),M=Math.floor(E*(_-V[1])),P=Math.floor(E*(w-V[2])),T=Math.max(0,S-p),L=Math.max(0,M-p),U=Math.max(0,P-p),j=Math.min(R[0],S+p+2),$=Math.min(R[1],M+p+2),Y=Math.min(R[2],P+p+2),Z=T;Z<j;Z++){n=v-N[Z];for(var K=R[1]*R[2]*Z,Q=L;Q<$;Q++)for(var J=n*n+(o=_-k[Q])*o,tt=K+R[2]*Q,et=U;et<Y;et++){s=J+(a=w-F[et])*a;var it=et+tt,rt=O[it];rt>0&&s<rt*rt&&(O[it]=Math.sqrt(s),C&&(D[it]=t))}}}}function d(t,e){return t[0]=t[1]=t[2]=1,0!==e[0]?t[0]=(e[1]+e[2])/-e[0]:0!==e[1]?t[1]=(e[0]+e[2])/-e[1]:0!==e[2]&&(t[2]=(e[0]+e[1])/-e[2]),t}function f(){for(var t=0;t<O.length;t++)O[t]<0&&(O[t]=0)}function m(){for(var t=0;t<D.length;t++)D[t]=i[D[t]]}function g(t,e,i){console.time("AVSurface.getVolume"),console.time("AVSurface.init"),r(t,e,i),console.timeEnd("AVSurface.init"),console.time("AVSurface.projectPoints"),h(),console.timeEnd("AVSurface.projectPoints"),console.time("AVSurface.projectTorii"),l(),console.timeEnd("AVSurface.projectTorii"),f(),m(),console.timeEnd("AVSurface.getVolume")}for(var v=e.length,y=new Float32Array(v),b=new Float32Array(v),x=new Float32Array(v),_=0;_<v;_++){var w=3*_;y[_]=t[w],b[_]=t[w+1],x[_]=t[w+2]}var S=Qo(t);0===t.length&&(S[0].set([0,0,0]),S[1].set([0,0,0]));var A,M,P,T,E,C,I,R,L,O,D,N,k,F,B,z,U,j,G,V=S[0],$=S[1],H=-1,W=new Float32Array([0,0,0]),X=new Float32Array([0,0,0]),q=new Float32Array([0,0,0]);this.getSurface=function(t,e,i,r,n,o,a){return g(e,i,n),new Ya(O,R[2],R[1],R[0],D).getSurface(e,!1,void 0,L,a)}}function $s(t){function e(t){for(var e=l.atomCount[t],n=l.atomOffset[t],o=new Array(e),a=0;a<e;++a)o[a]=h.atomTypeId[n+a];l.residueTypeId[t]=f.add(i,o,r)}var i,r,n=null,o=null,a=null,s=null,c=null,u=null,h=t.atomStore,l=t.residueStore,p=t.chainStore,d=t.modelStore,f=t.residueMap,m=-1,g=-1,v=-1,y=-1;this.addAtom=function(t,f,b,x,_,w,S,A){var M=!1,P=!1,T=!1;n!==t?(M=!0,P=!0,T=!0,y+=1,v+=1,g+=1):o!==b?(P=!0,T=!0,v+=1,g+=1):s===_&&a===x&&c===A||(T=!0,g+=1),m+=1,M&&(d.growIfFull(),d.chainOffset[y]=v,d.chainCount[y]=0,d.count+=1,p.modelIndex[v]=y),P&&(p.growIfFull(),p.setChainname(v,f),p.setChainid(v,b),p.residueOffset[v]=g,p.residueCount[v]=0,p.count+=1,p.modelIndex[v]=y,d.chainCount[y]+=1,l.chainIndex[g]=v),T&&(i=a,r=u,g>0&&e(g-1),l.growIfFull(),l.resno[g]=_,void 0!==S&&(l.sstruc[g]=S.charCodeAt(0)),void 0!==A&&(l.inscode[g]=A.charCodeAt(0)),l.atomOffset[g]=m,l.atomCount[g]=0,l.count+=1,l.chainIndex[g]=v,p.residueCount[v]+=1),h.count+=1,h.residueIndex[m]=g,l.atomCount[g]+=1,n=t,o=b,a=x,s=_,c=A,u=w},this.finalize=function(){i=a,r=u,g>-1&&e(g)}}function Hs(t){switch(t=t.toLowerCase()){case"polymer":return fg;case"non-polymer":return mg;case"macrolide":return gg;case"water":return vg;default:return dg}}function Ws(t){return!t||t[0]!==t[t.length-1]||"'"!==t[0]&&'"'!==t[0]?t:t.substring(1,t.length-1)}function Xs(t,e){Array.isArray(t[e])||Object.keys(t).forEach(function(e){t[e]=[t[e]]})}function qs(t){return"?"!==t}function Ys(t,e){return qs(t)?t:e}function Zs(t){switch(t.toLowerCase()){case"?":case"sing":return 1;case"doub":return 2;case"trip":return 3;case"quad":return 4}return 0}function Ks(t,e,i){var r,n,o=e.atomStore,a=e.atomMap,s=t.chem_comp,c=t.chem_comp_atom,u=t.chem_comp_bond;s&&(s.name&&(e.title=s.name.trim().replace(Bx,"")),s.id&&(e.id=s.id.trim().replace(Bx,"")));var h={};if(c){var l,p,d,f;for(n=c.comp_id.length,r=0;r<n;++r)o.growIfFull(),l=c.atom_id[r].replace(Fx,""),p=c.type_symbol[r],h[l]=r,o.atomTypeId[r]=a.add(l,p),o.x[r]=c.model_Cartn_x[r],o.y[r]=c.model_Cartn_y[r],o.z[r]=c.model_Cartn_z[r],o.serial[r]=r,d=c.pdbx_component_comp_id[r],f=c.pdbx_residue_numbering?c.pdbx_residue_numbering[r]:1,i.addAtom(0,"","",d,f,1);for(r=0;r<n;++r){var m=r+n;o.growIfFull(),l=c.atom_id[r].replace(Fx,""),p=c.type_symbol[r],o.atomTypeId[m]=a.add(l,p),o.x[m]=c.pdbx_model_Cartn_x_ideal[r],o.y[m]=c.pdbx_model_Cartn_y_ideal[r],o.z[m]=c.pdbx_model_Cartn_z_ideal[r],o.serial[m]=m,d=c.pdbx_component_comp_id[r],f=c.pdbx_residue_numbering?c.pdbx_residue_numbering[r]:1,i.addAtom(1,"","",d,f,1)}}if(c&&u){var g,v,y;n=u.comp_id.length;var b=c.comp_id.length,x=e.getAtomProxy(),_=e.getAtomProxy();for(r=0;r<n;++r)g=u.atom_id_1[r].replace(Fx,""),v=u.atom_id_2[r].replace(Fx,""),y=Zs(u.value_order[r]),x.index=h[g],_.index=h[v],e.bondStore.growIfFull(),e.bondStore.addBond(x,_,y),x.index+=b,_.index+=b,e.bondStore.growIfFull(),e.bondStore.addBond(x,_,y)}}function Qs(t,e,i){function r(t){return o.get(n.atomTypeId[t]).covalent}var n=e.atomStore,o=e.atomMap;t.data&&(e.id=t.data,e.name=t.data),e.unitcell=new Lx({a:parseFloat(t.cell_length_a),b:parseFloat(t.cell_length_b),c:parseFloat(t.cell_length_c),alpha:parseFloat(t.cell_angle_alpha),beta:parseFloat(t.cell_angle_beta),gamma:parseFloat(t.cell_angle_gamma),spacegroup:Ws(t.symmetry_space_group_name_H)});for(var a=new g,s=new g,c=t.atom_site_type_symbol.length,u=0;u<c;++u){n.growIfFull();var h=t.atom_site_label[u],l=t.atom_site_type_symbol[u];n.atomTypeId[u]=o.add(h,l),a.set(t.atom_site_fract_x[u],t.atom_site_fract_y[u],t.atom_site_fract_z[u]),a.applyMatrix4(e.unitcell.fracToCart),s.add(a),n.x[u]=a.x,n.y[u]=a.y,n.z[u]=a.z,t.atom_site_occupancy&&(n.occupancy[u]=parseFloat(t.atom_site_occupancy[u])),n.serial[u]=u,i.addAtom(0,"","","HET",1,1)}s.divideScalar(c),e.center=s,hs(e);for(var p=new g,d=new g,f=e.biomolDict.SUPERCELL.partList[0].matrixList,m=c,y=new v,b=0;b<c;++b)!function(t){var e=r(t);a.set(n.x[t],n.y[t],n.z[t]),f.forEach(function(o){if(!y.equals(o)){p.copy(a),p.applyMatrix4(o);for(var s=0;s<c;++s){d.set(n.x[s],n.y[s],n.z[s]);var u=p.distanceToSquared(d),h=r(s)+e,l=h+.3,f=h-.5;if(u<l*l&&u>f*f)return n.growIfFull(),n.atomTypeId[m]=n.atomTypeId[t],n.x[m]=p.x,n.y[m]=p.y,n.z[m]=p.z,n.occupancy[m]=n.occupancy[t],n.serial[m]=m,n.altloc[m]="A".charCodeAt(0),i.addAtom(0,"","","HET",1,1),void(m+=1)}}})}(b)}function Js(t,e,i){var r,n,o,a,s=[],c=[],u=t.struct_conf;if(u)for(Xs(u,"id"),r=0,n=u.beg_auth_seq_id.length;r<n;++r){var h=parseInt(u.pdbx_PDB_helix_class[r]);Number.isNaN(h)||(o=u.pdbx_beg_PDB_ins_code[r],a=u.pdbx_end_PDB_ins_code[r],s.push([i[u.beg_label_asym_id[r]],parseInt(u.beg_auth_seq_id[r]),Ys(o,""),i[u.end_label_asym_id[r]],parseInt(u.end_auth_seq_id[r]),Ys(a,""),(Ox[h]||Ox[""]).charCodeAt(0)]))}var l=t.struct_sheet_range;if(l)for(Xs(l,"id"),r=0,n=l.beg_auth_seq_id.length;r<n;++r)o=l.pdbx_beg_PDB_ins_code[r],a=l.pdbx_end_PDB_ins_code[r],c.push([i[l.beg_label_asym_id[r]],parseInt(l.beg_auth_seq_id[r]),Ys(o,""),i[l.end_label_asym_id[r]],parseInt(l.end_auth_seq_id[r]),Ys(a,"")]);return!(!u&&!l)&&{helices:s,sheets:c}}function tc(t,e,i){var r={},n=e.biomolDict;if(t.pdbx_struct_oper_list){var o=t.pdbx_struct_oper_list;Xs(o,"id"),o.id.forEach(function(t,e){var i=new v,n=i.elements;n[0]=parseFloat(o["matrix[1][1]"][e]),n[1]=parseFloat(o["matrix[1][2]"][e]),n[2]=parseFloat(o["matrix[1][3]"][e]),n[4]=parseFloat(o["matrix[2][1]"][e]),n[5]=parseFloat(o["matrix[2][2]"][e]),n[6]=parseFloat(o["matrix[2][3]"][e]),n[8]=parseFloat(o["matrix[3][1]"][e]),n[9]=parseFloat(o["matrix[3][2]"][e]),n[10]=parseFloat(o["matrix[3][3]"][e]),n[3]=parseFloat(o["vector[1]"][e]),n[7]=parseFloat(o["vector[2]"][e]),n[11]=parseFloat(o["vector[3]"][e]),i.transpose(),r[t]=i})}if(t.pdbx_struct_assembly_gen){var a=t.pdbx_struct_assembly_gen;Xs(a,"assembly_id");var s=function(t){var e={};return t.replace(/[()']/g,"").split(",").forEach(function(t){if(t.includes("-"))for(var i=t.split("-"),n=parseInt(i[0]),o=parseInt(i[1]);n<=o;++n)e[n]=r[n];else e[t]=r[t]}),e};a.assembly_id.forEach(function(t,e){var r={},o=a.oper_expression[e].replace(/['"]\(|['"]/g,"");if(o.includes(")(")||o.indexOf("(")>0){o=o.split("(");var c=s(o[0]),u=s(o[1]);Object.keys(c).forEach(function(t){Object.keys(u).forEach(function(e){var i=new v;i.multiplyMatrices(c[t],u[e]),r[t+"x"+e]=i})})}else r=s(o);var h=[];for(var l in r)h.push(r[l]);var p=t;/^(0|[1-9][0-9]*)$/.test(p)&&(p="BU"+p);for(var d=a.asym_id_list[e].split(","),f=0,m=d.length;f<m;++f)d[f]=i[d[f]];void 0===n[p]&&(n[p]=new uv(p)),n[p].addPart(h,d)})}if(t.struct_ncs_oper){var c=t.struct_ncs_oper;Xs(c,"id");n.NCS=new uv("NCS");var u=n.NCS.addPart();c.id.forEach(function(t,e){if("given"!==c.code[e]){var i=new v,r=i.elements;r[0]=parseFloat(c["matrix[1][1]"][e]),r[1]=parseFloat(c["matrix[1][2]"][e]),r[2]=parseFloat(c["matrix[1][3]"][e]),r[4]=parseFloat(c["matrix[2][1]"][e]),r[5]=parseFloat(c["matrix[2][2]"][e]),r[6]=parseFloat(c["matrix[2][3]"][e]),r[8]=parseFloat(c["matrix[3][1]"][e]),r[9]=parseFloat(c["matrix[3][2]"][e]),r[10]=parseFloat(c["matrix[3][3]"][e]),r[3]=parseFloat(c["vector[1]"][e]),r[7]=parseFloat(c["vector[2]"][e]),r[11]=parseFloat(c["vector[3]"][e]),i.transpose(),u.matrixList.push(i)}}),0===u.matrixList.length&&delete n.NCS}var h={};if(t.cell){var l=t.cell,p=parseFloat(l.length_a),d=parseFloat(l.length_b),f=parseFloat(l.length_c),m=new Float32Array(9);m[0]=p,m[4]=d,m[8]=f,e.boxes.push(m),h.a=p,h.b=d,h.c=f,h.alpha=parseFloat(l.angle_alpha),h.beta=parseFloat(l.angle_beta),h.gamma=parseFloat(l.angle_gamma)}t.symmetry&&(h.spacegroup=Ws(t.symmetry["space_group_name_H-M"]));var g=new v;if(t.database_PDB_matrix){var y=t.database_PDB_matrix,b=g.elements;b[0]=parseFloat(y["origx[1][1]"]),b[1]=parseFloat(y["origx[1][2]"]),b[2]=parseFloat(y["origx[1][3]"]),b[4]=parseFloat(y["origx[2][1]"]),b[5]=parseFloat(y["origx[2][2]"]),b[6]=parseFloat(y["origx[2][3]"]),b[8]=parseFloat(y["origx[3][1]"]),b[9]=parseFloat(y["origx[3][2]"]),b[10]=parseFloat(y["origx[3][3]"]),b[3]=parseFloat(y["origx_vector[1]"]),b[7]=parseFloat(y["origx_vector[2]"]),b[11]=parseFloat(y["origx_vector[3]"]),g.transpose(),h.origx=g}var x=new v;if(t.atom_sites){var _=t.atom_sites,w=x.elements;w[0]=parseFloat(_["fract_transf_matrix[1][1]"]),w[1]=parseFloat(_["fract_transf_matrix[1][2]"]),w[2]=parseFloat(_["fract_transf_matrix[1][3]"]),w[4]=parseFloat(_["fract_transf_matrix[2][1]"]),w[5]=parseFloat(_["fract_transf_matrix[2][2]"]),w[6]=parseFloat(_["fract_transf_matrix[2][3]"]),w[8]=parseFloat(_["fract_transf_matrix[3][1]"]),w[9]=parseFloat(_["fract_transf_matrix[3][2]"]),w[10]=parseFloat(_["fract_transf_matrix[3][3]"]),w[3]=parseFloat(_["fract_transf_vector[1]"]),w[7]=parseFloat(_["fract_transf_vector[2]"]),w[11]=parseFloat(_["fract_transf_vector[3]"]),x.transpose(),h.scale=x}void 0!==h.a?e.unitcell=new Lx(h):e.unitcell=void 0}function ec(e,i,r){var n=e.struct_conn;if(n){Xs(n,"id");for(var o=i.getAtomProxy(),a=i.getAtomProxy(),s={},c=0,u=n.id.length;c<u;++c){var h=n.conn_type_id[c];if("hydrog"!==h&&"mismat"!==h&&"saltbr"!==h&&("1_555"===n.ptnr1_symmetry[c]&&"1_555"===n.ptnr2_symmetry[c])){var l=n.pdbx_ptnr1_PDB_ins_code[c],p=n.pdbx_ptnr1_label_alt_id[c],d=n.ptnr1_auth_seq_id[c]+(qs(l)?"^"+l:"")+":"+r[n.ptnr1_label_asym_id[c]]+"."+n.ptnr1_label_atom_id[c].replace(/"/g,"")+(qs(p)?"%"+p:""),f=s[d];if(!f){var m=new Kd(d);if(m.selection.error){t.Debug&&cf.warn("invalid selection for connection",d);continue}f=i.getAtomIndices(m),s[d]=f}var g=n.pdbx_ptnr2_PDB_ins_code[c],v=n.pdbx_ptnr2_label_alt_id[c],y=n.ptnr2_auth_seq_id[c]+(qs(g)?"^"+g:"")+":"+r[n.ptnr2_label_asym_id[c]]+"."+n.ptnr2_label_atom_id[c].replace(/"/g,"")+(qs(v)?"%"+v:""),b=s[y];if(!b){var x=new Kd(y);if(x.selection.error){t.Debug&&cf.warn("invalid selection for connection",y);continue}b=i.getAtomIndices(x),s[y]=b}var _=f.length,w=b.length;if(_>w){var S=_;_=w,w=S;var A=f;f=b,b=A}if(0!==_&&0!==w)for(var M=0;M<w;++M)o.index=f[M%_],a.index=b[M],o&&a?i.bondStore.addBond(o,a,Zs(n.pdbx_value_order[c])):cf.log("atoms for connection not found");else t.Debug&&cf.warn("no atoms found for",d,y)}}}}function ic(t,e,i){if(t.entity){Xs(t.entity,"id");for(var r=t.entity,n=r.id.length,o=0;o<n;++o){var a=r.pdbx_description[o],s=r.type[o],c=Array.from(i[r.id[o]]);e.entityList[o]=new Ix(e,o,a,s,c)}}}function rc(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function nc(t){return rc(DataView,t)}function oc(t){return rc(Uint8Array,t)}function ac(t){return rc(Int8Array,t)}function sc(t){return rc(Int32Array,t,4)}function cc(t){return rc(Float32Array,t,4)}function uc(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,n=0;r<i;++r,n+=2)e[r]=t[n]<<8^t[n+1]<<0;return e}function hc(t,e){var i=t.length/4;e||(e=new Int32Array(i));for(var r=0,n=0;r<i;++r,n+=4)e[r]=t[n]<<24^t[n+1]<<16^t[n+2]<<8^t[n+3]<<0;return e}function lc(t,e){var i=t.length;e||(e=new Float32Array(i/4));for(var r=nc(e),n=nc(t),o=0,a=0,s=i/4;o<s;++o,a+=4)r.setFloat32(a,n.getFloat32(a),!0);return e}function pc(t,e,i){var r=t.length,n=1/e;i||(i=new Float32Array(r));for(var o=0;o<r;++o)i[o]=t[o]*n;return i}function dc(t,e){var i,r;if(!e){var n=0;for(i=0,r=t.length;i<r;i+=2)n+=t[i+1];e=new t.constructor(n)}var o=0;for(i=0,r=t.length;i<r;i+=2)for(var a=t[i],s=t[i+1],c=0;c<s;++c)e[o]=a,++o;return e}function fc(t,e){var i=t.length;e||(e=new t.constructor(i)),i&&(e[0]=t[0]);for(var r=1;r<i;++r)e[r]=t[r]+e[r-1];return e}function mc(t,e){var i,r,n=t instanceof Int8Array?127:32767,o=-n-1,a=t.length;if(!e){var s=0;for(i=0;i<a;++i)t[i]<n&&t[i]>o&&++s;e=new Int32Array(s)}for(i=0,r=0;i<a;){for(var c=0;t[i]===n||t[i]===o;)c+=t[i],++i;c+=t[i],++i,e[r]=c,++r}return e}function gc(t,e){return fc(dc(t),e)}function vc(t,e,i){return pc(dc(t,sc(i)),e,i)}function yc(t,e,i){return pc(fc(t,sc(i)),e,i)}function bc(t,e,i){return pc(mc(t,sc(i)),e,i)}function xc(t,e,i){var r=mc(t,sc(i));return yc(r,e,cc(r))}function _c(t){var e=nc(t),i=e.getInt32(0),r=e.getInt32(4),n=t.subarray(8,12);return[i,t=t.subarray(12),r,n]}function wc(t){function e(t){for(var e={},i=0;i<t;i++)e[o()]=o();return e}function i(e){var i=t.subarray(a,a+e);return a+=e,i}function r(e){var i=t.subarray(a,a+e);a+=e;if(e>65535){for(var r=[],n=0;n<i.length;n+=65535)r.push(String.fromCharCode.apply(null,i.subarray(n,n+65535)));return r.join("")}return String.fromCharCode.apply(null,i)}function n(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=o();return e}function o(){var o,c,u=t[a];if(0==(128&u))return a++,u;if(128==(240&u))return c=15&u,a++,e(c);if(144==(240&u))return c=15&u,a++,n(c);if(160==(224&u))return c=31&u,a++,r(c);if(224==(224&u))return o=s.getInt8(a),a++,o;switch(u){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,i(c);case 197:return c=s.getUint16(a+1),a+=3,i(c);case 198:return c=s.getUint32(a+1),a+=5,i(c);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return c=s.getUint8(a+1),a+=2,r(c);case 218:return c=s.getUint16(a+1),a+=3,r(c);case 219:return c=s.getUint32(a+1),a+=5,r(c);case 220:return c=s.getUint16(a+1),a+=3,n(c);case 221:return c=s.getUint32(a+1),a+=5,n(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+u.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function Sc(t,e,i,r){switch(t){case 1:return lc(e);case 2:return ac(e);case 3:return uc(e);case 4:return hc(e);case 5:return oc(e);case 6:return dc(hc(e),new Uint8Array(i));case 7:return dc(hc(e));case 8:return gc(hc(e));case 9:return vc(hc(e),hc(r)[0]);case 10:return xc(uc(e),hc(r)[0]);case 11:return pc(uc(e),hc(r)[0]);case 12:return bc(uc(e),hc(r)[0]);case 13:return bc(ac(e),hc(r)[0]);case 14:return mc(uc(e));case 15:return mc(ac(e))}}function Ac(t,e){var i=(e=e||{}).ignoreFields,r={};return Gx.forEach(function(e){var n=!!i&&-1!==i.indexOf(e),o=t[e];n||void 0===o||(o instanceof Uint8Array?r[e]=Sc.apply(null,_c(o)):r[e]=o)}),r}function Mc(){this.regexp={vertex_pattern:/^v\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|.|+|\-|e|E]+)\s+([\d|.|+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}}function Pc(){this.propertyNameMapping={}}function Tc(t){return t.replace(__,"")}function Ec(t){function e(){if(o(/^<\?xml\s*/)){for(var t={attributes:{}};!a()&&!s("?>");){var e=n();if(!e)return t;t.attributes[e.name]=e.value}return o(/\?>\s*/),t}}function i(){var t=o(w_);if(t){for(var e={name:t[1],attributes:{},children:[]};!(a()||s(">")||s("?>")||s("/>"));){var c=n();if(!c)return e;e.attributes[c.name]=c.value}if(o(/^\s*\/>\s*/))return e;o(/\??>\s*/),e.content=r();for(var u;u=i();)e.children.push(u);return o(/^<\/[\w-:.]+>\s*/),e}}function r(){var t=o(S_);return t?t[1]:""}function n(){var t=o(A_);if(t)return{name:t[1],value:Tc(t[2])}}function o(e){var i=t.match(e);if(i)return t=t.slice(i[0].length),i}function a(){return 0===t.length}function s(e){return 0===t.indexOf(e)}return t=t.trim().replace(/<!--[\s\S]*?-->/g,""),function(){return{declaration:e(),root:i()}}()}function Cc(t,e,i){var r=t.icode.value,n=t.chain.value,o=t.altcode.value,a=t.resnum.value;return r.trim()&&(a+="^"+r),n.trim()&&(a+=":"+n),e&&(a+="."+e),i&&o.trim()&&(a+="%"+o),a+="/"+(parseInt(t.model.value)-1)}function Ic(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function Rc(t,e){return void 0!==t&&t.value===e}function Lc(t){var e=t.inscode,i=t.chainname,r=t.atomname,n=t.altloc,o=t.resno;return e&&(o+="^"+e),i&&(o+=":"+i),r&&(o+="."+r),n&&(o+="%"+n),o+="/"+t.modelIndex}function Oc(t,e,i){for(var r=0,n=e.getElementsByTagName("clash"),o=0,a=n.length;o<a;++o)if(t[n[o].attributes.cid.value]){r+=1;break}return e.getElementsByTagName("angle-outlier").length>0&&(r+=1),e.getElementsByTagName("bond-outlier").length>0&&(r+=1),e.getElementsByTagName("plane-outlier").length>0&&(r+=1),Rc(i.rota,"OUTLIER")&&(r+=1),Rc(i.rama,"OUTLIER")&&(r+=1),Rc(i.RNApucker,"outlier")&&(r+=1),r}function Dc(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}function Nc(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)}function kc(t,e,i,r,n){if(e.subarray&&t.subarray)return void t.set(e.subarray(i,i+r),n);for(var o=0;o<r;o++)t[n+o]=e[i+o]}function Fc(t){var e,i,r,n,o,a;for(r=0,e=0,i=t.length;e<i;e++)r+=t[e].length;for(a=new Uint8Array(r),n=0,e=0,i=t.length;e<i;e++)o=t[e],a.set(o,n),n+=o.length;return a}function Bc(t,e,i,r){for(var n=65535&t|0,o=t>>>16&65535|0,a=0;0!==i;){i-=a=i>2e3?2e3:i;do{o=o+(n=n+e[r++]|0)|0}while(--a);n%=65521,o%=65521}return n|o<<16|0}function zc(t,e,i,r){var n=R_,o=r+i;t^=-1;for(var a=r;a<o;a++)t=t>>>8^n[255&(t^e[a])];return-1^t}function Uc(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P;i=t.state,r=t.next_in,M=t.input,n=r+(t.avail_in-5),o=t.next_out,P=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),c=i.dmax,u=i.wsize,h=i.whave,l=i.wnext,p=i.window,d=i.hold,f=i.bits,m=i.lencode,g=i.distcode,v=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;t:do{f<15&&(d+=M[r++]<<f,f+=8,d+=M[r++]<<f,f+=8),b=m[d&v];e:for(;;){if(x=b>>>24,d>>>=x,f-=x,0===(x=b>>>16&255))P[o++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<<x)-1)];continue e}if(32&x){i.mode=O_;break t}t.msg="invalid literal/length code",i.mode=L_;break t}_=65535&b,(x&=15)&&(f<x&&(d+=M[r++]<<f,f+=8),_+=d&(1<<x)-1,d>>>=x,f-=x),f<15&&(d+=M[r++]<<f,f+=8,d+=M[r++]<<f,f+=8),b=g[d&y];i:for(;;){if(x=b>>>24,d>>>=x,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<<x)-1)];continue i}t.msg="invalid distance code",i.mode=L_;break t}if(w=65535&b,x&=15,f<x&&(d+=M[r++]<<f,(f+=8)<x&&(d+=M[r++]<<f,f+=8)),(w+=d&(1<<x)-1)>c){t.msg="invalid distance too far back",i.mode=L_;break t}if(d>>>=x,f-=x,x=o-a,w>x){if((x=w-x)>h&&i.sane){t.msg="invalid distance too far back",i.mode=L_;break t}if(S=0,A=p,0===l){if(S+=u-x,x<_){_-=x;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}}else if(l<x){if(S+=u+l-x,(x-=l)<_){_-=x;do{P[o++]=p[S++]}while(--x);if(S=0,l<_){_-=x=l;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}}}else if(S+=l-x,x<_){_-=x;do{P[o++]=p[S++]}while(--x);S=o-w,A=P}for(;_>2;)P[o++]=A[S++],P[o++]=A[S++],P[o++]=A[S++],_-=3;_&&(P[o++]=A[S++],_>1&&(P[o++]=A[S++]))}else{S=o-w;do{P[o++]=P[S++],P[o++]=P[S++],P[o++]=P[S++],_-=3}while(_>2);_&&(P[o++]=P[S++],_>1&&(P[o++]=P[S++]))}break}}break}}while(r<n&&o<s);r-=_=f>>3,d&=(1<<(f-=_<<3))-1,t.next_in=r,t.next_out=o,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=o<s?s-o+257:257-(o-s),i.hold=d,i.bits=f}function jc(t,e,i,r,n,o,a,s){var c,u,h,l,p,d,f,m,g,v=s.bits,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,P=0,T=0,E=null,C=0,I=new Uint16Array(D_+1),R=new Uint16Array(D_+1),L=null,O=0;for(y=0;y<=D_;y++)I[y]=0;for(b=0;b<r;b++)I[e[i+b]]++;for(w=v,_=D_;_>=1&&0===I[_];_--);if(w>_&&(w=_),0===_)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(x=1;x<_&&0===I[x];x++);for(w<x&&(w=x),M=1,y=1;y<=D_;y++)if(M<<=1,(M-=I[y])<0)return-1;if(M>0&&(t===F_||1!==_))return-1;for(R[1]=0,y=1;y<D_;y++)R[y+1]=R[y]+I[y];for(b=0;b<r;b++)0!==e[i+b]&&(a[R[e[i+b]]++]=b);if(t===F_?(E=L=a,d=19):t===B_?(E=U_,C-=257,L=j_,O-=257,d=256):(E=G_,L=V_,d=-1),T=0,b=0,y=x,p=o,S=w,A=0,h=-1,P=1<<w,l=P-1,t===B_&&P>N_||t===z_&&P>k_)return 1;for(var D=0;;){D++,f=y-A,a[b]<d?(m=0,g=a[b]):a[b]>d?(m=L[O+a[b]],g=E[C+a[b]]):(m=96,g=0),c=1<<y-A,x=u=1<<S;do{n[p+(T>>A)+(u-=c)]=f<<24|m<<16|g|0}while(0!==u);for(c=1<<y-1;T&c;)c>>=1;if(0!==c?(T&=c-1,T+=c):T=0,b++,0==--I[y]){if(y===_)break;y=e[i+a[b]]}if(y>w&&(T&l)!==h){for(0===A&&(A=w),p+=x,M=1<<(S=y-A);S+A<_&&!((M-=I[S+A])<=0);)S++,M<<=1;if(P+=1<<S,t===B_&&P>N_||t===z_&&P>k_)return 1;n[h=T&l]=w<<24|S<<16|p-o|0}}return 0!==T&&(n[p+T]=y-A<<24|64<<16|0),s.bits=w,0}function Gc(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function Vc(){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 $c(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=nw,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(kw),e.distcode=e.distdyn=new Int32Array(Fw),e.sane=1,e.back=-1,Z_):J_}function Hc(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,$c(t)):J_}function Wc(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)?J_:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,Hc(t))):J_}function Xc(t,e){var i,r;return t?(r=new Vc,t.state=r,r.window=null,(i=Wc(t,e))!==Z_&&(t.state=null),i):J_}function qc(t){if(Bw){var e;for(C_=new Int32Array(512),I_=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(jc(H_,t.lens,0,288,C_,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;jc(W_,t.lens,0,32,I_,0,t.work,{bits:5}),Bw=!1}t.lencode=C_,t.lenbits=9,t.distcode=I_,t.distbits=5}function Yc(t,e,i,r){var n,o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),r>=o.wsize?(kc(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((n=o.wsize-o.wnext)>r&&(n=r),kc(o.window,e,i-r,n,o.wnext),(r-=n)?(kc(o.window,e,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0}function Zc(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P=0,T=new Uint8Array(4),E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return J_;(i=t.state).mode===mw&&(i.mode=gw),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,r=t.input,s=t.avail_in,u=i.hold,h=i.bits,l=s,p=c,S=Z_;t:for(;;)switch(i.mode){case nw:if(0===i.wrap){i.mode=gw;break}for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(2&i.wrap&&35615===u){i.check=0,T[0]=255&u,T[1]=u>>>8&255,i.check=zc(i.check,T,2,0),u=0,h=0,i.mode=ow;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",i.mode=Ow;break}if((15&u)!==rw){t.msg="unknown compression method",i.mode=Ow;break}if(u>>>=4,h-=4,w=8+(15&u),0===i.wbits)i.wbits=w;else if(w>i.wbits){t.msg="invalid window size",i.mode=Ow;break}i.dmax=1<<w,t.adler=i.check=1,i.mode=512&u?dw:mw,u=0,h=0;break;case ow:for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(i.flags=u,(255&i.flags)!==rw){t.msg="unknown compression method",i.mode=Ow;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=Ow;break}i.head&&(i.head.text=u>>8&1),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,i.check=zc(i.check,T,2,0)),u=0,h=0,i.mode=aw;case aw:for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.head&&(i.head.time=u),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,i.check=zc(i.check,T,4,0)),u=0,h=0,i.mode=sw;case sw:for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.head&&(i.head.xflags=255&u,i.head.os=u>>8),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,i.check=zc(i.check,T,2,0)),u=0,h=0,i.mode=cw;case cw:if(1024&i.flags){for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.length=u,i.head&&(i.head.extra_len=u),512&i.flags&&(T[0]=255&u,T[1]=u>>>8&255,i.check=zc(i.check,T,2,0)),u=0,h=0}else i.head&&(i.head.extra=null);i.mode=uw;case uw:if(1024&i.flags&&((d=i.length)>s&&(d=s),d&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),kc(i.head.extra,r,o,d,w)),512&i.flags&&(i.check=zc(i.check,r,d,o)),s-=d,o+=d,i.length-=d),i.length))break t;i.length=0,i.mode=hw;case hw:if(2048&i.flags){if(0===s)break t;d=0;do{w=r[o+d++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&d<s);if(512&i.flags&&(i.check=zc(i.check,r,d,o)),s-=d,o+=d,w)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=lw;case lw:if(4096&i.flags){if(0===s)break t;d=0;do{w=r[o+d++],i.head&&w&&i.length<65536&&(i.head.comment+=String.fromCharCode(w))}while(w&&d<s);if(512&i.flags&&(i.check=zc(i.check,r,d,o)),s-=d,o+=d,w)break t}else i.head&&(i.head.comment=null);i.mode=pw;case pw:if(512&i.flags){for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u!==(65535&i.check)){t.msg="header crc mismatch",i.mode=Ow;break}u=0,h=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=mw;break;case dw:for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}t.adler=i.check=Gc(u),u=0,h=0,i.mode=fw;case fw:if(0===i.havedict)return t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,Q_;t.adler=i.check=1,i.mode=mw;case mw:if(e===q_||e===Y_)break t;case gw:if(i.last){u>>>=7&h,h-=7&h,i.mode=Iw;break}for(;h<3;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}switch(i.last=1&u,u>>>=1,h-=1,3&u){case 0:i.mode=vw;break;case 1:if(qc(i),i.mode=Sw,e===Y_){u>>>=2,h-=2;break t}break;case 2:i.mode=xw;break;case 3:t.msg="invalid block type",i.mode=Ow}u>>>=2,h-=2;break;case vw:for(u>>>=7&h,h-=7&h;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if((65535&u)!=(u>>>16^65535)){t.msg="invalid stored block lengths",i.mode=Ow;break}if(i.length=65535&u,u=0,h=0,i.mode=yw,e===Y_)break t;case yw:i.mode=bw;case bw:if(d=i.length){if(d>s&&(d=s),d>c&&(d=c),0===d)break t;kc(n,r,o,d,a),s-=d,o+=d,c-=d,a+=d,i.length-=d;break}i.mode=mw;break;case xw:for(;h<14;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(i.nlen=257+(31&u),u>>>=5,h-=5,i.ndist=1+(31&u),u>>>=5,h-=5,i.ncode=4+(15&u),u>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Ow;break}i.have=0,i.mode=_w;case _w:for(;i.have<i.ncode;){for(;h<3;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.lens[E[i.have++]]=7&u,u>>>=3,h-=3}for(;i.have<19;)i.lens[E[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=jc($_,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid code lengths set",i.mode=Ow;break}i.have=0,i.mode=ww;case ww:for(;i.have<i.nlen+i.ndist;){for(;P=i.lencode[u&(1<<i.lenbits)-1],g=P>>>24,v=P>>>16&255,y=65535&P,!(g<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(y<16)u>>>=g,h-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u>>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=Ow;break}w=i.lens[i.have-1],d=3+(3&u),u>>>=2,h-=2}else if(17===y){for(M=g+3;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}h-=g,w=0,d=3+(7&(u>>>=g)),u>>>=3,h-=3}else{for(M=g+7;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}h-=g,w=0,d=11+(127&(u>>>=g)),u>>>=7,h-=7}if(i.have+d>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Ow;break}for(;d--;)i.lens[i.have++]=w}}if(i.mode===Ow)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Ow;break}if(i.lenbits=9,A={bits:i.lenbits},S=jc(H_,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid literal/lengths set",i.mode=Ow;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=jc(W_,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){t.msg="invalid distances set",i.mode=Ow;break}if(i.mode=Sw,e===Y_)break t;case Sw:i.mode=Aw;case Aw:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,Uc(t,p),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,r=t.input,s=t.avail_in,u=i.hold,h=i.bits,i.mode===mw&&(i.back=-1);break}for(i.back=0;P=i.lencode[u&(1<<i.lenbits)-1],g=P>>>24,v=P>>>16&255,y=65535&P,!(g<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(v&&0==(240&v)){for(b=g,x=v,_=y;P=i.lencode[_+((u&(1<<b+x)-1)>>b)],g=P>>>24,v=P>>>16&255,y=65535&P,!(b+g<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}u>>>=b,h-=b,i.back+=b}if(u>>>=g,h-=g,i.back+=g,i.length=y,0===v){i.mode=Cw;break}if(32&v){i.back=-1,i.mode=mw;break}if(64&v){t.msg="invalid literal/length code",i.mode=Ow;break}i.extra=15&v,i.mode=Mw;case Mw:if(i.extra){for(M=i.extra;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.length+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=Pw;case Pw:for(;P=i.distcode[u&(1<<i.distbits)-1],g=P>>>24,v=P>>>16&255,y=65535&P,!(g<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(0==(240&v)){for(b=g,x=v,_=y;P=i.distcode[_+((u&(1<<b+x)-1)>>b)],g=P>>>24,v=P>>>16&255,y=65535&P,!(b+g<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}u>>>=b,h-=b,i.back+=b}if(u>>>=g,h-=g,i.back+=g,64&v){t.msg="invalid distance code",i.mode=Ow;break}i.offset=y,i.extra=15&v,i.mode=Tw;case Tw:if(i.extra){for(M=i.extra;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.offset+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Ow;break}i.mode=Ew;case Ew:if(0===c)break t;if(d=p-c,i.offset>d){if((d=i.offset-d)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Ow;break}d>i.wnext?(d-=i.wnext,f=i.wsize-d):f=i.wnext-d,d>i.length&&(d=i.length),m=i.window}else m=n,f=a-i.offset,d=i.length;d>c&&(d=c),c-=d,i.length-=d;do{n[a++]=m[f++]}while(--d);0===i.length&&(i.mode=Aw);break;case Cw:if(0===c)break t;n[a++]=i.length,c--,i.mode=Aw;break;case Iw:if(i.wrap){for(;h<32;){if(0===s)break t;s--,u|=r[o++]<<h,h+=8}if(p-=c,t.total_out+=p,i.total+=p,p&&(t.adler=i.check=i.flags?zc(i.check,n,p,a-p):Bc(i.check,n,p,a-p)),p=c,(i.flags?u:Gc(u))!==i.check){t.msg="incorrect data check",i.mode=Ow;break}u=0,h=0}i.mode=Rw;case Rw:if(i.wrap&&i.flags){for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=Ow;break}u=0,h=0}i.mode=Lw;case Lw:S=K_;break t;case Ow:S=tw;break t;case Dw:return ew;case Nw:default:return J_}return t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,(i.wsize||p!==t.avail_out&&i.mode<Ow&&(i.mode<Iw||e!==X_))&&Yc(t,t.output,t.next_out,p-t.avail_out)?(i.mode=Dw,ew):(l-=t.avail_in,p-=t.avail_out,t.total_in+=l,t.total_out+=p,i.total+=p,i.wrap&&p&&(t.adler=i.check=i.flags?zc(i.check,n,p,t.next_out-p):Bc(i.check,n,p,t.next_out-p)),t.data_type=i.bits+(i.last?64:0)+(i.mode===mw?128:0)+(i.mode===Sw||i.mode===yw?256:0),(0===l&&0===p||e===X_)&&S===Z_&&(S=iw),S)}function Kc(t){if(!t||!t.state)return J_;var e=t.state;return e.window&&(e.window=null),t.state=null,Z_}function Qc(t,e){var i;return t&&t.state?0==(2&(i=t.state).wrap)?J_:(i.head=e,e.done=!1,Z_):J_}function Jc(t,e){var i,r,n=e.length;return t&&t.state?0!==(i=t.state).wrap&&i.mode!==fw?J_:i.mode===fw&&(r=1,(r=Bc(r,e,n,0))!==i.check)?tw:Yc(t,e,n,n)?(i.mode=Dw,ew):(i.havedict=1,Z_):J_}function tu(t){var e,i,r,n,o,a=t.length,s=0;for(n=0;n<a;n++)55296==(64512&(i=t.charCodeAt(n)))&&n+1<a&&56320==(64512&(r=t.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),s+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(s),o=0,n=0;o<s;n++)55296==(64512&(i=t.charCodeAt(n)))&&n+1<a&&56320==(64512&(r=t.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),i<128?e[o++]=i:i<2048?(e[o++]=192|i>>>6,e[o++]=128|63&i):i<65536?(e[o++]=224|i>>>12,e[o++]=128|i>>>6&63,e[o++]=128|63&i):(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63,e[o++]=128|i>>>6&63,e[o++]=128|63&i);return e}function eu(t,e){if(e<65537&&(t.subarray&&Uw||!t.subarray&&zw))return String.fromCharCode.apply(null,Nc(t,e));for(var i="",r=0;r<e;r++)i+=String.fromCharCode(t[r]);return i}function iu(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i<r;i++)e[i]=t.charCodeAt(i);return e}function ru(t,e){var i,r,n,o,a=e||t.length,s=new Array(2*a);for(r=0,i=0;i<a;)if((n=t[i++])<128)s[r++]=n;else if((o=jw[n])>4)s[r++]=65533,i+=o-1;else{for(n&=2===o?31:3===o?15:7;o>1&&i<a;)n=n<<6|63&t[i++],o--;o>1?s[r++]=65533:n<65536?s[r++]=n:(n-=65536,s[r++]=55296|n>>10&1023,s[r++]=56320|1023&n)}return eu(s,r)}function nu(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0?e:0===i?e:i+jw[t[i]]>e?i:e}function ou(){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 au(){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}function su(t){if(!(this instanceof su))return new su(t);this.options=Dc({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 ou,this.strm.avail_out=0;var i=Xc(this.strm,e.windowBits);if(i!==Vw)throw new Error($w[i]);this.header=new au,Qc(this.strm,this.header)}function cu(t,e){var i=new su(e);if(i.push(t,!0),i.err)throw i.msg;return i.result}function uu(t){var e;t instanceof ArrayBuffer&&(t=new Uint8Array(t));try{e=cu(t)}catch(i){e=t}return e}function hu(){this.getUrl=function(t){var e,i=_n(t),r=i.name.substr(0,4);return!["pdb","cif"].includes(i.ext)||!1!==i.compressed&&"gz"!==i.compressed?"mmtf"===i.ext?e=i.base.endsWith(".bb")?qw+r:Xw+r:i.ext?(cf.warn("unsupported ext",i.ext),e=Xw+r):e=Xw+r:e=Ww+i.path,vn()+e},this.getExt=function(t){var e=_n(t);if("mmtf"===e.ext||!e.ext)return"mmtf"}}function lu(){this.getUrl=function(t){var e,i=_n(t),r=i.name;return i.ext&&"sdf"!==i.ext?(cf.warn("unsupported ext",i.ext),e=Yw+r+Zw):e=Yw+r+Zw,vn()+e},this.getExt=function(t){var e=_n(t);if(!e.ext||"sdf"===e.ext)return"sdf"}}function pu(){this.getUrl=function(t){return t}}function du(t){t=t||"",this.getUrl=function(e){var i=_n(e),r=t+i.path;return Kw.test(t)||(r=bn(r)),r}}"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,i=window.console,r={},n=function(){},o="memory".split(","),a="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(",");t=o.pop();)i[t]||(i[t]=r);for(;e=a.pop();)i[e]||(i[e]=n)}(),void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var r=window.atob(this.toDataURL(e,i).split(",")[1]),n=r.length,o=n>>2,a=new Uint8Array(n),s=new Uint32Array(a.buffer,0,o),c=0,u=0;c<o;c++)s[c]=r.charCodeAt(u++)|r.charCodeAt(u++)<<8|r.charCodeAt(u++)<<16|r.charCodeAt(u++)<<24;for(var h=3&n;h--;)a[u]=r.charCodeAt(u++);t(new window.Blob([a],{type:e||"image/png"}))}}),Math.cbrt=Math.cbrt||function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},Math.sign||(Math.sign=function(t){return t=+t,0===t||isNaN(t)?Number(t):t>0?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}),Number.isNaN||(Number.isNaN=function(t){return t!==t}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var e=arguments;if(void 0===t||null===t)throw new TypeError("Cannot convert first argument to object");for(var i,r=Object(t),n=!1,o=1;o<arguments.length;o++){var a=e[o];if(void 0!==a&&null!==a){for(var s=Object.keys(Object(a)),c=0,u=s.length;c<u;c++){var h=s[c];try{var l=Object.getOwnPropertyDescriptor(a,h);void 0!==l&&l.enumerable&&(r[h]=a[h])}catch(t){n||(n=!0,i=t)}}if(n)throw i}}return r}}),String.prototype.startsWith||function(){var t=function(){var t;try{var e={},i=Object.defineProperty;t=i(e,e,e)&&i}catch(t){}return t}(),e={}.toString,i=function(t){if(null===this)throw TypeError();var i=String(this);if(t&&"[object RegExp]"===e.call(t))throw TypeError();var r=i.length,n=String(t),o=n.length,a=arguments.length>1?arguments[1]:void 0,s=a?Number(a):0;Number.isNaN(s)&&(s=0);var c=Math.min(Math.max(s,0),r);if(o+c>r)return!1;for(var u=-1;++u<o;)if(i.charCodeAt(c+u)!==n.charCodeAt(u))return!1;return!0};t?t(String.prototype,"startsWith",{value:i,configurable:!0,writable:!0}):String.prototype.startsWith=i}(),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var i=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>i.length)&&(e=i.length),e-=t.length;var r=i.indexOf(t,e);return-1!==r&&r===e}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||(Array.prototype.includes=function(t){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),i=parseInt(e.length,10)||0;if(0===i)return!1;var r,n=parseInt(arguments[1],10)||0;n>=0?r=n:(r=i+n)<0&&(r=0);for(var o;r<i;){if(o=e[r],t===o||Number.isNaN(t)&&Number.isNaN(o))return!0;r++}return!1}),Array.from||(Array.from=function(){var t=Object.prototype.toString,e=function(e){return"function"==typeof e||"[object Function]"===t.call(e)},i=function(t){var e=Number(t);return isNaN(e)?0:0!==e&&isFinite(e)?(e>0?1:-1)*Math.floor(Math.abs(e)):e},r=Math.pow(2,53)-1,n=function(t){var e=i(t);return Math.min(Math.max(e,0),r)};return function(t){var i=this,r=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var o,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!e(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(o=arguments[2])}for(var s,c=n(r.length),u=e(i)?Object(new i(c)):new Array(c),h=0;h<c;)s=r[h],u[h]=a?void 0===o?a(s,h):a.call(o,s,h):s,h+=1;return u.length=c,u}}()),"undefined"!=typeof window&&function(){for(var t=0,e=["ms","moz","webkit","o"],i=0;i<e.length&&!window.requestAnimationFrame;++i)window.requestAnimationFrame=window[e[i]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[i]+"CancelAnimationFrame"]||window[e[i]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var i=(new Date).getTime(),r=Math.max(0,16-(i-t)),n=window.setTimeout(function(){e(i+r)},r);return t=i+r,n}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}(),void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),"undefined"!=typeof window&&(void 0===window.performance&&(self.performance={}),void 0===window.performance.now&&function(){var t=Date.now();window.performance.now=function(){return Date.now()-t}}());var fu=setTimeout,mu="function"==typeof setImmediate&&setImmediate||function(t){fu(t,0)},gu=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};r.prototype.catch=function(t){return this.then(null,t)},r.prototype.then=function(t,i){var r=new this.constructor(e);return n(this,new c(t,i,r)),r},r.all=function(t){var e=Array.prototype.slice.call(t);return new r(function(t,i){function r(o,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(t){r(o,t)},i)}e[o]=a,0==--n&&t(e)}catch(t){i(t)}}if(0===e.length)return t([]);for(var n=e.length,o=0;o<e.length;o++)r(o,e[o])})},r.resolve=function(t){return t&&"object"==typeof t&&t.constructor===r?t:new r(function(e){e(t)})},r.reject=function(t){return new r(function(e,i){i(t)})},r.race=function(t){return new r(function(e,i){for(var r=0,n=t.length;r<n;r++)t[r].then(e,i)})},r._setImmediateFn=function(t){mu=t},r._setUnhandledRejectionFn=function(t){gu=t},void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(t){var e=arguments;if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),r=1;r<arguments.length;r++){var n=e[r];if(void 0!==n&&null!==n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])}return i}}(),Object.assign(h.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var i=this._listeners[t];if(void 0!==i){var r=i.indexOf(e);-1!==r&&i.splice(r,1)}}},dispatchEvent:function(t){var e=this;if(void 0!==this._listeners){var i=this._listeners[t.type];if(void 0!==i){t.target=this;for(var r=i.slice(0),n=0,o=r.length;n<o;n++)r[n].call(e,t)}}}});var vu="86",yu=0,bu=1,xu=2,_u=0,wu=1,Su=2,Au=0,Mu=1,Pu=2,Tu=1,Eu=2,Cu=0,Iu=1,Ru=2,Lu=0,Ou=1,Du=2,Nu=3,ku=4,Fu=5,Bu=100,zu=101,Uu=102,ju=103,Gu=104,Vu=200,$u=201,Hu=202,Wu=203,Xu=204,qu=205,Yu=206,Zu=207,Ku=208,Qu=209,Ju=210,th=0,eh=1,ih=2,rh=3,nh=4,oh=5,ah=6,sh=7,ch=0,uh=1,hh=2,lh=0,ph=1,dh=2,fh=3,mh=4,gh=301,vh=302,yh=303,bh=304,xh=305,_h=306,wh=307,Sh=1e3,Ah=1001,Mh=1002,Ph=1003,Th=1004,Eh=1005,Ch=1006,Ih=1007,Rh=1008,Lh=1009,Oh=1010,Dh=1011,Nh=1012,kh=1013,Fh=1014,Bh=1015,zh=1016,Uh=1017,jh=1018,Gh=1019,Vh=1020,$h=1021,Hh=1022,Wh=1023,Xh=1024,qh=1025,Yh=1026,Zh=1027,Kh=2001,Qh=2002,Jh=2003,tl=2004,el=2100,il=2101,rl=2102,nl=2103,ol=2151,al=2201,sl=2400,cl=0,ul=1,hl=2,ll=3e3,pl=3001,dl=3007,fl=3002,ml=3004,gl=3005,vl=3006,yl=3200,bl=3201,xl={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t,e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var n=0;n<36;n++)8===n||13===n||18===n||23===n?i[n]="-":14===n?i[n]="4":(r<=2&&(r=33554432+16777216*Math.random()|0),t=15&r,r>>=4,i[n]=e[19===n?3&t|8:t]);return i.join("")}}(),clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,r,n){return r+(t-e)*(n-r)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*xl.DEG2RAD},radToDeg:function(t){return t*xl.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};Object.defineProperties(l.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(l.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t=new l,e=new l;return function(i,r){return t.set(i,i),e.set(r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,o=this.y-t.y;return this.x=n*i-o*r+t.x,this.y=n*r+o*i+t.y,this}});var _l=0;p.DEFAULT_IMAGE=void 0,p.DEFAULT_MAPPING=300,Object.defineProperty(p.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(p.prototype,h.prototype,{constructor:p,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;void 0===i.uuid&&(i.uuid=xl.generateUUID()),void 0===t.images[i.uuid]&&(t.images[i.uuid]={uuid:i.uuid,url:function(t){var e;return void 0!==t.toDataURL?e=t:((e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0,t.width,t.height)),e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(i)}),e.image=i.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case Sh:t.x=t.x-Math.floor(t.x);break;case Ah:t.x=t.x<0?0:1;break;case Mh:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case Sh:t.y=t.y-Math.floor(t.y);break;case Ah:t.y=t.y<0?0:1;break;case Mh:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.assign(d.prototype,{isVector4:!0,set:function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*e+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*e+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*e+o[7]*i+o[11]*r+o[15]*n,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,i,r,n,o=t.elements,a=o[0],s=o[4],c=o[8],u=o[1],h=o[5],l=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(c-p)<.01&&Math.abs(l-d)<.01){if(Math.abs(s+u)<.1&&Math.abs(c+p)<.1&&Math.abs(l+d)<.1&&Math.abs(a+h+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(h+1)/2,v=(f+1)/2,y=(s+u)/4,b=(c+p)/4,x=(l+d)/4;return m>g&&m>v?m<.01?(i=0,r=.707106781,n=.707106781):(r=y/(i=Math.sqrt(m)),n=b/i):g>v?g<.01?(i=.707106781,r=0,n=.707106781):(i=y/(r=Math.sqrt(g)),n=x/r):v<.01?(i=.707106781,r=.707106781,n=0):(i=b/(n=Math.sqrt(v)),r=x/n),this.set(i,r,n,e),this}var _=Math.sqrt((d-l)*(d-l)+(c-p)*(c-p)+(u-s)*(u-s));return Math.abs(_)<.001&&(_=1),this.x=(d-l)/_,this.y=(c-p)/_,this.z=(u-s)/_,this.w=Math.acos((a+h+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(i,r){return void 0===t&&(t=new d,e=new d),t.set(i,i,i,i),e.set(r,r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Object.assign(f.prototype,h.prototype,{isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.assign(m,{slerp:function(t,e,i,r){return i.copy(t).slerp(e,r)},slerpFlat:function(t,e,i,r,n,o,a){var s=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3],l=n[o+0],p=n[o+1],d=n[o+2],f=n[o+3];if(h!==f||s!==l||c!==p||u!==d){var m=1-a,g=s*l+c*p+u*d+h*f,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,a=Math.sin(a*x)/b}var _=a*v;if(s=s*m+l*_,c=c*m+p*_,u=u*m+d*_,h=h*m+f*_,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+h*h);s*=w,c*=w,u*=w,h*=w}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=h}}),Object.defineProperties(m.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(m.prototype,{set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=t._x,r=t._y,n=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(i/2),u=a(r/2),h=a(n/2),l=s(i/2),p=s(r/2),d=s(n/2);return"XYZ"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h-l*p*d):"YXZ"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h+l*p*d):"ZXY"===o?(this._x=l*u*h-c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h-l*p*d):"ZYX"===o?(this._x=l*u*h-c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h+l*p*d):"YZX"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h-l*p*d):"XZY"===o&&(this._x=l*u*h-c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h+l*p*d),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,i=t.elements,r=i[0],n=i[4],o=i[8],a=i[1],s=i[5],c=i[9],u=i[2],h=i[6],l=i[10],p=r+s+l;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(h-c)*e,this._y=(o-u)*e,this._z=(a-n)*e):r>s&&r>l?(e=2*Math.sqrt(1+r-s-l),this._w=(h-c)/e,this._x=.25*e,this._y=(n+a)/e,this._z=(o+u)/e):s>l?(e=2*Math.sqrt(1+s-r-l),this._w=(o-u)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(c+h)/e):(e=2*Math.sqrt(1+l-r-s),this._w=(a-n)/e,this._x=(o+u)/e,this._y=(c+h)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new g;return function(i,r){return void 0===e&&(e=new g),t=i.dot(r)+1,t<1e-6?(t=0,Math.abs(i.x)>Math.abs(i.z)?e.set(-i.y,i.x,0):e.set(0,-i.z,i.y)):e.crossVectors(i,r),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var i=t._x,r=t._y,n=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=i*u+o*a+r*c-n*s,this._y=r*u+o*s+n*a-i*c,this._z=n*u+o*c+i*s-r*a,this._w=o*u-i*a-r*s-n*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*t._w+i*t._x+r*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,a),u=Math.sin((1-e)*c)/s,h=Math.sin(e*c)/s;return this._w=o*u+this._w*h,this._x=i*u+this._x*h,this._y=r*u+this._y*h,this._z=n*u+this._z*h,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(g.prototype,{isVector3:!0,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t=new m;return function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new m;return function(e,i){return this.applyQuaternion(t.setFromAxisAngle(e,i))}}(),applyMatrix3:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements,o=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(t){var e=this.x,i=this.y,r=this.z,n=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*r-a*i,u=s*i+a*e-n*r,h=s*r+n*i-o*e,l=-n*e-o*i-a*r;return this.x=c*s+l*-n+u*-a-h*-o,this.y=u*s+l*-o+h*-n-c*-a,this.z=h*s+l*-a+c*-o-u*-n,this},project:function(){var t=new v;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new v;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t=new g,e=new g;return function(i,r){return t.set(i,i,i),e.set(r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var i=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-i*t.z,this.z=i*t.y-r*t.x,this},crossVectors:function(t,e){var i=t.x,r=t.y,n=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new g;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new g;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(xl.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(v.prototype,{isMatrix4:!0,set:function(t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=r,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=h,g[14]=l,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new v).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:function(){var t=new g;return function(e){var i=this.elements,r=e.elements,n=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i[4]=r[4]*o,i[5]=r[5]*o,i[6]=r[6]*o,i[8]=r[8]*a,i[9]=r[9]*a,i[10]=r[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,i=t.x,r=t.y,n=t.z,o=Math.cos(i),a=Math.sin(i),s=Math.cos(r),c=Math.sin(r),u=Math.cos(n),h=Math.sin(n);if("XYZ"===t.order){var l=o*u,p=o*h,d=a*u,f=a*h;e[0]=s*u,e[4]=-s*h,e[8]=c,e[1]=p+d*c,e[5]=l-f*c,e[9]=-a*s,e[2]=f-l*c,e[6]=d+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*u,g=s*h,v=c*u,y=c*h;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*u,g=s*h,v=c*u,y=c*h;e[0]=m-y*a,e[4]=-o*h,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*u,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var l=o*u,p=o*h,d=a*u,f=a*h;e[0]=s*u,e[4]=d*c-p,e[8]=l*c+f,e[1]=s*h,e[5]=f*c+l,e[9]=p*c-d,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=w-b*h,e[8]=_*h+x,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=x*h+_,e[10]=b-w*h}else if("XZY"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=-h,e[8]=c*u,e[1]=b*h+w,e[5]=o*u,e[9]=x*h-_,e[2]=_*h-x,e[6]=a*u,e[10]=w*h+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,i=t._x,r=t._y,n=t._z,o=t._w,a=i+i,s=r+r,c=n+n,u=i*a,h=i*s,l=i*c,p=r*s,d=r*c,f=n*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+f),e[4]=h-v,e[8]=l+g,e[1]=h+v,e[5]=1-(u+f),e[9]=d-m,e[2]=l-g,e[6]=d+m,e[10]=1-(u+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new g,e=new g,i=new g;return function(r,n,o){var a=this.elements;return i.subVectors(r,n),0===i.lengthSq()&&(i.z=1),i.normalize(),t.crossVectors(o,i),0===t.lengthSq()&&(1===Math.abs(o.z)?i.x+=1e-4:i.z+=1e-4,i.normalize(),t.crossVectors(o,i)),t.normalize(),e.crossVectors(i,t),a[0]=t.x,a[4]=e.x,a[8]=i.x,a[1]=t.y,a[5]=e.y,a[9]=i.y,a[2]=t.z,a[6]=e.z,a[10]=i.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,r=e.elements,n=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],u=i[1],h=i[5],l=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],b=i[11],x=i[15],_=r[0],w=r[4],S=r[8],A=r[12],M=r[1],P=r[5],T=r[9],E=r[13],C=r[2],I=r[6],R=r[10],L=r[14],O=r[3],D=r[7],N=r[11],k=r[15];return n[0]=o*_+a*M+s*C+c*O,n[4]=o*w+a*P+s*I+c*D,n[8]=o*S+a*T+s*R+c*N,n[12]=o*A+a*E+s*L+c*k,n[1]=u*_+h*M+l*C+p*O,n[5]=u*w+h*P+l*I+p*D,n[9]=u*S+h*T+l*R+p*N,n[13]=u*A+h*E+l*L+p*k,n[2]=d*_+f*M+m*C+g*O,n[6]=d*w+f*P+m*I+g*D,n[10]=d*S+f*T+m*R+g*N,n[14]=d*A+f*E+m*L+g*k,n[3]=v*_+y*M+b*C+x*O,n[7]=v*w+y*P+b*I+x*D,n[11]=v*S+y*T+b*R+x*N,n[15]=v*A+y*E+b*L+x*k,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t=new g;return function(e){for(var i=this,r=0,n=e.count;r<n;r++)t.x=e.getX(r),t.y=e.getY(r),t.z=e.getZ(r),t.applyMatrix4(i),e.setXYZ(r,t.x,t.y,t.z);return e}}(),determinant:function(){var t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],o=t[1],a=t[5],s=t[9],c=t[13],u=t[2],h=t[6],l=t[10],p=t[14];return t[3]*(+n*s*h-r*c*h-n*a*l+i*c*l+r*a*p-i*s*p)+t[7]*(+e*s*p-e*c*l+n*o*l-r*o*p+r*c*u-n*s*u)+t[11]*(+e*c*h-e*a*p-n*o*h+i*o*p+n*a*u-i*c*u)+t[15]*(-r*a*u-e*s*h+e*a*l+r*o*h-i*o*l+i*s*u)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var i=this.elements,r=t.elements,n=r[0],o=r[1],a=r[2],s=r[3],c=r[4],u=r[5],h=r[6],l=r[7],p=r[8],d=r[9],f=r[10],m=r[11],g=r[12],v=r[13],y=r[14],b=r[15],x=d*y*l-v*f*l+v*h*m-u*y*m-d*h*b+u*f*b,_=g*f*l-p*y*l-g*h*m+c*y*m+p*h*b-c*f*b,w=p*v*l-g*d*l+g*u*m-c*v*m-p*u*b+c*d*b,S=g*d*h-p*v*h-g*u*f+c*v*f+p*u*y-c*d*y,A=n*x+o*_+a*w+s*S;if(0===A){var M="THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0";if(!0===e)throw new Error(M);return console.warn(M),this.identity()}var P=1/A;return i[0]=x*P,i[1]=(v*f*s-d*y*s-v*a*m+o*y*m+d*a*b-o*f*b)*P,i[2]=(u*y*s-v*h*s+v*a*l-o*y*l-u*a*b+o*h*b)*P,i[3]=(d*h*s-u*f*s-d*a*l+o*f*l+u*a*m-o*h*m)*P,i[4]=_*P,i[5]=(p*y*s-g*f*s+g*a*m-n*y*m-p*a*b+n*f*b)*P,i[6]=(g*h*s-c*y*s-g*a*l+n*y*l+c*a*b-n*h*b)*P,i[7]=(c*f*s-p*h*s+p*a*l-n*f*l-c*a*m+n*h*m)*P,i[8]=w*P,i[9]=(g*d*s-p*v*s-g*o*m+n*v*m+p*o*b-n*d*b)*P,i[10]=(c*v*s-g*u*s+g*o*l-n*v*l-c*o*b+n*u*b)*P,i[11]=(p*u*s-c*d*s-p*o*l+n*d*l+c*o*m-n*u*m)*P,i[12]=S*P,i[13]=(p*v*a-g*d*a+g*o*f-n*v*f-p*o*y+n*d*y)*P,i[14]=(g*u*a-c*v*a-g*o*h+n*v*h+c*o*y-n*u*y)*P,i[15]=(c*d*a-p*u*a+p*o*h-n*d*h-c*o*f+n*u*f)*P,this},scale:function(t){var e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))},makeTranslation:function(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=1-i,o=t.x,a=t.y,s=t.z,c=n*o,u=n*a;return this.set(c*o+i,c*a-r*s,c*s+r*a,0,c*a+r*s,u*a+i,u*s-r*o,0,c*s-r*a,u*s+r*o,n*s*s+i,0,0,0,0,1),this},makeScale:function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,i){return this.makeRotationFromQuaternion(e),this.scale(i),this.setPosition(t),this},decompose:function(){var t=new g,e=new v;return function(i,r,n){var o=this.elements,a=t.set(o[0],o[1],o[2]).length(),s=t.set(o[4],o[5],o[6]).length(),c=t.set(o[8],o[9],o[10]).length();this.determinant()<0&&(a=-a),i.x=o[12],i.y=o[13],i.z=o[14],e.copy(this);var u=1/a,h=1/s,l=1/c;return e.elements[0]*=u,e.elements[1]*=u,e.elements[2]*=u,e.elements[4]*=h,e.elements[5]*=h,e.elements[6]*=h,e.elements[8]*=l,e.elements[9]*=l,e.elements[10]*=l,r.setFromRotationMatrix(e),n.x=a,n.y=s,n.z=c,this}}(),makePerspective:function(t,e,i,r,n,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,s=2*n/(e-t),c=2*n/(i-r),u=(e+t)/(e-t),h=(i+r)/(i-r),l=-(o+n)/(o-n),p=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=l,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makeOrthographic:function(t,e,i,r,n,o){var a=this.elements,s=1/(e-t),c=1/(i-r),u=1/(o-n),h=(e+t)*s,l=(i+r)*c,p=(o+n)*u;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-l,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t,e){var i=this;void 0===e&&(e=0);for(var r=0;r<16;r++)i.elements[r]=t[r+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}),y.prototype=Object.create(p.prototype),y.prototype.constructor=y,y.prototype.isDataTexture=!0,b.prototype=Object.create(p.prototype),b.prototype.constructor=b,b.prototype.isCubeTexture=!0,Object.defineProperty(b.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});var wl=new p,Sl=new b,Al=[],Ml=[],Pl=new Float32Array(16),Tl=new Float32Array(9);Z.prototype.setValue=function(t,e){for(var i=this.seq,r=0,n=i.length;r!==n;++r){var o=i[r];o.setValue(t,e[o.id])}};var El=/([\w\d_]+)(\])?(\[|\.)?/g;J.prototype.setValue=function(t,e,i){var r=this.map[e];void 0!==r&&r.setValue(t,i,this.renderer)},J.prototype.setOptional=function(t,e,i){var r=e[i];void 0!==r&&this.setValue(t,i,r)},J.upload=function(t,e,i,r){for(var n=0,o=e.length;n!==o;++n){var a=e[n],s=i[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,r)}},J.seqWithValue=function(t,e){for(var i=[],r=0,n=t.length;r!==n;++r){var o=t[r];o.id in e&&i.push(o)}return i};var Cl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(tt.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(){function t(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}return function(e,i,r){if(e=xl.euclideanModulo(e,1),i=xl.clamp(i,0,1),r=xl.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var n=r<=.5?r*(1+i):r+i-r*i,o=2*r-n;this.r=t(o,n,e+1/3),this.g=t(o,n,e),this.b=t(o,n,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(a,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u=(h=i[1]).length;if(3===u)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(t&&t.length>0){var h=Cl[t];void 0!==h?this.setHex(h):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(){var t=this.r,e=this.g,i=this.b;return this.r=t*t,this.g=e*e,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,i,r=t||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),c=Math.min(n,o,a),u=(c+s)/2;if(c===s)e=0,i=0;else{var h=s-c;switch(i=u<=.5?h/(s+c):h/(2-s-c),s){case n:e=(o-a)/h+(o<a?6:0);break;case o:e=(a-n)/h+2;break;case a:e=(n-o)/h+4}e/=6}return r.h=e,r.s=i,r.l=u,r},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,i){var r=this.getHSL();return r.h+=t,r.s+=e,r.l+=i,this.setHSL(r.h,r.s,r.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}});var Il={common:{diffuse:{value:new tt(15658734)},opacity:{value:1},map:{value:null},offsetRepeat:{value:new d(0,0,1,1)},specularMap:{value:null},alphaMap:{value:null},envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new l(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new tt(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},offsetRepeat:{value:new d(0,0,1,1)}}},Rl={merge:function(t){for(var e=this,i={},r=0;r<t.length;r++){var n=e.clone(t[r]);for(var o in n)i[o]=n[o]}return i},clone:function(t){var e={};for(var i in t){e[i]={};for(var r in t[i]){var n=t[i][r];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture)?e[i][r]=n.clone():Array.isArray(n)?e[i][r]=n.slice():e[i][r]=n}}return e}},Ll={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE  = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS  = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1  (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale =  bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:"  gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M      = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM            = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D      = max( maxRange / maxRGB, 1.0 );\n\tD            = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value )  {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = asin( flipNormal * reflectVec.y ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n  varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3(   1,   0, t.y ),\n\t\t\tvec3(   0, t.z,   0 ),\n\t\t\tvec3( t.w,   0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n  gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include <common>\n#include <packing>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <skinbase_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <normal_flip>\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <normal_flip>\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",shadow_frag:"uniform float opacity;\n#include <common>\n#include <packing>\n#include <bsdfs>\n#include <lights_pars>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n"},Ol={basic:{uniforms:Rl.merge([Il.common,Il.aomap,Il.lightmap,Il.fog]),vertexShader:Ll.meshbasic_vert,fragmentShader:Ll.meshbasic_frag},lambert:{uniforms:Rl.merge([Il.common,Il.aomap,Il.lightmap,Il.emissivemap,Il.fog,Il.lights,{emissive:{value:new tt(0)}}]),vertexShader:Ll.meshlambert_vert,fragmentShader:Ll.meshlambert_frag},phong:{uniforms:Rl.merge([Il.common,Il.aomap,Il.lightmap,Il.emissivemap,Il.bumpmap,Il.normalmap,Il.displacementmap,Il.gradientmap,Il.fog,Il.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30}}]),vertexShader:Ll.meshphong_vert,fragmentShader:Ll.meshphong_frag},standard:{uniforms:Rl.merge([Il.common,Il.aomap,Il.lightmap,Il.emissivemap,Il.bumpmap,Il.normalmap,Il.displacementmap,Il.roughnessmap,Il.metalnessmap,Il.fog,Il.lights,{emissive:{value:new tt(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Ll.meshphysical_vert,fragmentShader:Ll.meshphysical_frag},points:{uniforms:Rl.merge([Il.points,Il.fog]),vertexShader:Ll.points_vert,fragmentShader:Ll.points_frag},dashed:{uniforms:Rl.merge([Il.common,Il.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ll.linedashed_vert,fragmentShader:Ll.linedashed_frag},depth:{uniforms:Rl.merge([Il.common,Il.displacementmap]),vertexShader:Ll.depth_vert,fragmentShader:Ll.depth_frag},normal:{uniforms:Rl.merge([Il.common,Il.bumpmap,Il.normalmap,Il.displacementmap,{opacity:{value:1}}]),vertexShader:Ll.normal_vert,fragmentShader:Ll.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ll.cube_vert,fragmentShader:Ll.cube_frag},equirect:{uniforms:{tEquirect:{value:null},tFlip:{value:-1}},vertexShader:Ll.equirect_vert,fragmentShader:Ll.equirect_frag},distanceRGBA:{uniforms:{lightPos:{value:new g}},vertexShader:Ll.distanceRGBA_vert,fragmentShader:Ll.distanceRGBA_frag}};Ol.physical={uniforms:Rl.merge([Ol.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Ll.meshphysical_vert,fragmentShader:Ll.meshphysical_frag},Object.assign(et.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){var e=this;this.makeEmpty();for(var i=0,r=t.length;i<r;i++)e.expandByPoint(t[i]);return this},setFromCenterAndSize:function(){var t=new l;return function(e,i){var r=t.copy(i).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){var e=t||new l;return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new l;return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new l).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return(e||new l).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new l;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var Dl=0;Object.assign(nt.prototype,h.prototype,{isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){var e=this;if(void 0!==t)for(var i in t){var r=t[i];if(void 0!==r){var n=e[i];void 0!==n?n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):e[i]="overdraw"===i?Number(r):r:console.warn("THREE."+e.type+": '"+i+"' is not a property of this material.")}else console.warn("THREE.Material: '"+i+"' parameter is undefined.")}},toJSON:function(t){function e(t){var e=[];for(var i in t){var r=t[i];delete r.metadata,e.push(r)}return e}var i=void 0===t;i&&(t={textures:{},images:{}});var r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearCoat&&(r.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(r.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,r.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Ou&&(r.blending=this.blending),this.shading!==Eu&&(r.shading=this.shading),this.side!==Au&&(r.side=this.side),this.vertexColors!==Cu&&(r.vertexColors=this.vertexColors),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),r.skinning=this.skinning,r.morphTargets=this.morphTargets,r.dithering=this.dithering,i){var n=e(t.textures),o=e(t.images);n.length>0&&(r.textures=n),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.shading=t.shading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,i=null;if(null!==e){var r=e.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ot.prototype=Object.create(nt.prototype),ot.prototype.constructor=ot,ot.prototype.isShaderMaterial=!0,ot.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Rl.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},ot.prototype.toJSON=function(t){var e=nt.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},at.prototype=Object.create(nt.prototype),at.prototype.constructor=at,at.prototype.isMeshDepthMaterial=!0,at.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},Object.assign(st.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],h=t[s+1],l=t[s+2];u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),u>n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return this.min.set(e,i,r),this.max.set(n,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;s<c;s++){var u=t.getX(s),h=t.getY(s),l=t.getZ(s);u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),u>n&&(n=u),h>o&&(o=h),l>a&&(a=l)}return this.min.set(e,i,r),this.max.set(n,o,a),this},setFromPoints:function(t){var e=this;this.makeEmpty();for(var i=0,r=t.length;i<r;i++)e.expandByPoint(t[i]);return this},setFromCenterAndSize:function(){var t=new g;return function(e,i){var r=t.copy(i).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}}(),setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){var e=t||new g;return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new g;return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(){var t=new g;return function(e){var i=this;return e.updateMatrixWorld(!0),e.traverse(function(e){var r,n,o=e.geometry;if(void 0!==o)if(o.isGeometry){var a=o.vertices;for(r=0,n=a.length;r<n;r++)t.copy(a[r]),t.applyMatrix4(e.matrixWorld),i.expandByPoint(t)}else if(o.isBufferGeometry){var s=o.attributes.position;if(void 0!==s)for(r=0,n=s.count;r<n;r++)t.fromBufferAttribute(s,r).applyMatrix4(e.matrixWorld),i.expandByPoint(t)}}),this}}(),containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new g).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:function(){var t=new g;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=t.constant&&i>=t.constant},clampPoint:function(t,e){return(e||new g).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new g;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new g;return function(e){var i=e||new ct;return this.getCenter(i.center),i.radius=.5*this.getSize(t).length(),i}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new g,new g,new g,new g,new g,new g,new g,new g];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(ct.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new st;return function(e,i){var r=this.center;void 0!==i?r.copy(i):t.setFromPoints(e).getCenter(r);for(var n=0,o=0,a=e.length;o<a;o++)n=Math.max(n,r.distanceToSquared(e[o]));return this.radius=Math.sqrt(n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(this.center.dot(t.normal)-t.constant)<=this.radius},clampPoint:function(t,e){var i=this.center.distanceToSquared(t),r=e||new g;return r.copy(t),i>this.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(t){var e=t||new st;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(ut.prototype,{isMatrix3:!0,set:function(t,e,i,r,n,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=n,u[5]=s,u[6]=i,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t=new g;return function(e){for(var i=this,r=0,n=e.count;r<n;r++)t.x=e.getX(r),t.y=e.getY(r),t.z=e.getZ(r),t.applyMatrix3(i),e.setXYZ(r,t.x,t.y,t.z);return e}}(),multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,r=e.elements,n=this.elements,o=i[0],a=i[3],s=i[6],c=i[1],u=i[4],h=i[7],l=i[2],p=i[5],d=i[8],f=r[0],m=r[3],g=r[6],v=r[1],y=r[4],b=r[7],x=r[2],_=r[5],w=r[8];return n[0]=o*f+a*v+s*x,n[3]=o*m+a*y+s*_,n[6]=o*g+a*b+s*w,n[1]=c*f+u*v+h*x,n[4]=c*m+u*y+h*_,n[7]=c*g+u*b+h*w,n[2]=l*f+p*v+d*x,n[5]=l*m+p*y+d*_,n[8]=l*g+p*b+d*w,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],o=t[4],a=t[5],s=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-i*n*u+i*a*s+r*n*c-r*o*s},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3.getInverse no longer takes a Matrix4 argument.");var i=t.elements,r=this.elements,n=i[0],o=i[1],a=i[2],s=i[3],c=i[4],u=i[5],h=i[6],l=i[7],p=i[8],d=p*c-u*l,f=u*h-p*s,m=l*s-c*h,g=n*d+o*f+a*m;if(0===g){var v="THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0";if(!0===e)throw new Error(v);return console.warn(v),this.identity()}var y=1/g;return r[0]=d*y,r[1]=(a*l-p*o)*y,r[2]=(u*o-a*c)*y,r[3]=f*y,r[4]=(p*n-a*h)*y,r[5]=(a*s-u*n)*y,r[6]=m*y,r[7]=(o*h-l*n)*y,r[8]=(c*n-o*s)*y,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t,e){var i=this;void 0===e&&(e=0);for(var r=0;r<9;r++)i.elements[r]=t[r+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}}),Object.assign(ht.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(){var t=new g,e=new g;return function(i,r,n){var o=t.subVectors(n,r).cross(e.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return this.orthoPoint(t,e).sub(t).negate()},orthoPoint:function(t,e){var i=this.distanceToPoint(t);return(e||new g).copy(this.normal).multiplyScalar(i)},intersectLine:function(){var t=new g;return function(e,i){var r=i||new g,n=e.delta(t),o=this.normal.dot(n);if(0!==o){var a=-(e.start.dot(this.normal)+this.constant)/o;if(!(a<0||a>1))return r.copy(n).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return r.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new g).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new g,e=new ut;return function(i,r){var n=this.coplanarPoint(t).applyMatrix4(i),o=r||e.getNormalMatrix(i),a=this.normal.applyMatrix3(o).normalize();return this.constant=-n.dot(a),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(lt.prototype,{set:function(t,e,i,r,n,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(r),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,i=0;i<6;i++)e[i].copy(t.planes[i]);return this},setFromMatrix:function(t){var e=this.planes,i=t.elements,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],c=i[5],u=i[6],h=i[7],l=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return e[0].setComponents(a-r,h-s,f-l,y-m).normalize(),e[1].setComponents(a+r,h+s,f+l,y+m).normalize(),e[2].setComponents(a+n,h+c,f+p,y+g).normalize(),e[3].setComponents(a-n,h-c,f-p,y-g).normalize(),e[4].setComponents(a-o,h-u,f-d,y-v).normalize(),e[5].setComponents(a+o,h+u,f+d,y+v).normalize(),this},intersectsObject:function(){var t=new ct;return function(e){var i=e.geometry;return null===i.boundingSphere&&i.computeBoundingSphere(),t.copy(i.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new ct;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,i=t.center,r=-t.radius,n=0;n<6;n++)if(e[n].distanceToPoint(i)<r)return!1;return!0},intersectsBox:function(){var t=new g,e=new g;return function(i){for(var r=this.planes,n=0;n<6;n++){var o=r[n];t.x=o.normal.x>0?i.min.x:i.max.x,e.x=o.normal.x>0?i.max.x:i.min.x,t.y=o.normal.y>0?i.min.y:i.max.y,e.y=o.normal.y>0?i.max.y:i.min.y,t.z=o.normal.z>0?i.min.z:i.max.z,e.z=o.normal.z>0?i.max.z:i.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}}),ft.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ft.DefaultOrder="XYZ",Object.defineProperties(ft.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(ft.prototype,{isEuler:!0,set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,i){var r=xl.clamp,n=t.elements,o=n[0],a=n[4],s=n[8],c=n[1],u=n[5],h=n[9],l=n[2],p=n[6],d=n[10];return e=e||this._order,"XYZ"===e?(this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-r(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-l,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-r(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===e?(this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-l,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e?(this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-h,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==i&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new v;return function(e,i,r){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,i,r)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new m;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new g(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(mt.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},test:function(t){return 0!=(this.mask&t.mask)}});var Nl=0;gt.DefaultUp=new g(0,1,0),gt.DefaultMatrixAutoUpdate=!0,Object.assign(gt.prototype,h.prototype,{isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(t){this.matrix.multiplyMatrices(t,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(){var t=new m;return function(e,i){return t.setFromAxisAngle(e,i),this.quaternion.multiply(t),this}}(),rotateX:function(){var t=new g(1,0,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateY:function(){var t=new g(0,1,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateZ:function(){var t=new g(0,0,1);return function(e){return this.rotateOnAxis(t,e)}}(),translateOnAxis:function(){var t=new g;return function(e,i){return t.copy(e).applyQuaternion(this.quaternion),this.position.add(t.multiplyScalar(i)),this}}(),translateX:function(){var t=new g(1,0,0);return function(e){return this.translateOnAxis(t,e)}}(),translateY:function(){var t=new g(0,1,0);return function(e){return this.translateOnAxis(t,e)}}(),translateZ:function(){var t=new g(0,0,1);return function(e){return this.translateOnAxis(t,e)}}(),localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var t=new v;return function(e){return e.applyMatrix4(t.getInverse(this.matrixWorld))}}(),lookAt:function(){var t=new v;return function(e){this.isCamera?t.lookAt(this.position,e,this.up):t.lookAt(e,this.position,this.up),this.quaternion.setFromRotationMatrix(t)}}(),add:function(t){var e=arguments,i=this;if(arguments.length>1){for(var r=0;r<arguments.length;r++)i.add(e[r]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,t.dispatchEvent({type:"added"}),this.children.push(t)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){var e=arguments,i=this;if(arguments.length>1){for(var r=0;r<arguments.length;r++)i.remove(e[r]);return this}var n=this.children.indexOf(t);return-1!==n&&(t.parent=null,t.dispatchEvent({type:"removed"}),this.children.splice(n,1)),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){var i=this;if(this[t]===e)return this;for(var r=0,n=this.children.length;r<n;r++){var o=i.children[r].getObjectByProperty(t,e);if(void 0!==o)return o}},getWorldPosition:function(t){var e=t||new g;return this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var t=new g,e=new g;return function(i){var r=i||new m;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,r,e),r}}(),getWorldRotation:function(){var t=new m;return function(e){var i=e||new ft;return this.getWorldQuaternion(t),i.setFromQuaternion(t,this.rotation.order,!1)}}(),getWorldScale:function(){var t=new g,e=new m;return function(i){var r=i||new g;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,e,r),r}}(),getWorldDirection:function(){var t=new m;return function(e){var i=e||new g;return this.getWorldQuaternion(t),i.set(0,0,1).applyQuaternion(t)}}(),raycast:function(){},traverse:function(t){t(this);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].updateMatrixWorld(t)},toJSON:function(t){function e(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}function i(t){var e=[];for(var i in t){var r=t[i];delete r.metadata,e.push(r)}return e}var r=this,n=void 0===t||""===t,o={};n&&(t={geometries:{},materials:{},textures:{},images:{}},o.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var a={};if(a.uuid=this.uuid,a.type=this.type,""!==this.name&&(a.name=this.name),"{}"!==JSON.stringify(this.userData)&&(a.userData=this.userData),!0===this.castShadow&&(a.castShadow=!0),!0===this.receiveShadow&&(a.receiveShadow=!0),!1===this.visible&&(a.visible=!1),a.matrix=this.matrix.toArray(),void 0!==this.geometry&&(a.geometry=e(t.geometries,this.geometry)),void 0!==this.material)if(Array.isArray(this.material)){for(var s=[],c=0,u=this.material.length;c<u;c++)s.push(e(t.materials,r.material[c]));a.material=s}else a.material=e(t.materials,this.material);if(this.children.length>0){a.children=[];for(c=0;c<this.children.length;c++)a.children.push(r.children[c].toJSON(t).object)}if(n){var h=i(t.geometries),l=i(t.materials),p=i(t.textures),d=i(t.images);h.length>0&&(o.geometries=h),l.length>0&&(o.materials=l),p.length>0&&(o.textures=p),d.length>0&&(o.images=d)}return o.object=a,o},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){var i=this;if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;r<t.children.length;r++){var n=t.children[r];i.add(n.clone())}return this}}),vt.prototype=Object.assign(Object.create(gt.prototype),{constructor:vt,isCamera:!0,copy:function(t,e){return gt.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this},getWorldDirection:function(){var t=new m;return function(e){var i=e||new g;return this.getWorldQuaternion(t),i.set(0,0,-1).applyQuaternion(t)}}(),updateMatrixWorld:function(t){gt.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),yt.prototype=Object.assign(Object.create(vt.prototype),{constructor:yt,isOrthographicCamera:!0,copy:function(t,e){return vt.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,i,r,n,o){this.view={fullWidth:t,fullHeight:e,offsetX:i,offsetY:r,width:n,height:o},this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null,this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,n=i-t,o=i+t,a=r+e,s=r-e;if(null!==this.view){var c=this.zoom/(this.view.width/this.view.fullWidth),u=this.zoom/(this.view.height/this.view.fullHeight),h=(this.right-this.left)/this.view.width,l=(this.top-this.bottom)/this.view.height;o=(n+=h*(this.view.offsetX/c))+h*(this.view.width/c),s=(a-=l*(this.view.offsetY/u))-l*(this.view.height/u)}this.projectionMatrix.makeOrthographic(n,o,a,s,this.near,this.far)},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),bt.prototype=Object.assign(Object.create(vt.prototype),{constructor:bt,isPerspectiveCamera:!0,copy:function(t,e){return vt.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*xl.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*xl.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*xl.RAD2DEG*Math.atan(Math.tan(.5*xl.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,r,n,o){this.aspect=t/e,this.view={fullWidth:t,fullHeight:e,offsetX:i,offsetY:r,width:n,height:o},this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null,this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*xl.DEG2RAD*this.fov)/this.zoom,i=2*e,r=this.aspect*i,n=-.5*r,o=this.view;if(null!==o){var a=o.fullWidth,s=o.fullHeight;n+=o.offsetX*r/a,e-=o.offsetY*i/s,r*=o.width/a,i*=o.height/s}var c=this.filmOffset;0!==c&&(n+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,e,e-i,t,this.far)},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}),Object.assign(xt.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){var e=this;this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var i=0,r=t.vertexNormals.length;i<r;i++)e.vertexNormals[i]=t.vertexNormals[i].clone();for(var i=0,r=t.vertexColors.length;i<r;i++)e.vertexColors[i]=t.vertexColors[i].clone();return this}});var kl=0;Object.assign(wt.prototype,h.prototype,{isGeometry:!0,applyMatrix:function(t){for(var e=this,i=(new ut).getNormalMatrix(t),r=0,n=this.vertices.length;r<n;r++)e.vertices[r].applyMatrix4(t);for(var r=0,n=this.faces.length;r<n;r++){var o=e.faces[r];o.normal.applyMatrix3(i).normalize();for(var a=0,s=o.vertexNormals.length;a<s;a++)o.vertexNormals[a].applyMatrix3(i).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(){var t=new v;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new v;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new v;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new v;return function(e,i,r){return t.makeTranslation(e,i,r),this.applyMatrix(t),this}}(),scale:function(){var t=new v;return function(e,i,r){return t.makeScale(e,i,r),this.applyMatrix(t),this}}(),lookAt:function(){var t=new gt;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),fromBufferGeometry:function(t){function e(t,e,r,n){var o=new xt(t,e,r,void 0!==a?[h[t].clone(),h[e].clone(),h[r].clone()]:[],void 0!==s?[i.colors[t].clone(),i.colors[e].clone(),i.colors[r].clone()]:[],n);i.faces.push(o),void 0!==c&&i.faceVertexUvs[0].push([p[t].clone(),p[e].clone(),p[r].clone()]),void 0!==u&&i.faceVertexUvs[1].push([d[t].clone(),d[e].clone(),d[r].clone()])}var i=this,r=null!==t.index?t.index.array:void 0,n=t.attributes,o=n.position.array,a=void 0!==n.normal?n.normal.array:void 0,s=void 0!==n.color?n.color.array:void 0,c=void 0!==n.uv?n.uv.array:void 0,u=void 0!==n.uv2?n.uv2.array:void 0;void 0!==u&&(this.faceVertexUvs[1]=[]);for(var h=[],p=[],d=[],f=0,m=0;f<o.length;f+=3,m+=2)i.vertices.push(new g(o[f],o[f+1],o[f+2])),void 0!==a&&h.push(new g(a[f],a[f+1],a[f+2])),void 0!==s&&i.colors.push(new tt(s[f],s[f+1],s[f+2])),void 0!==c&&p.push(new l(c[m],c[m+1])),void 0!==u&&d.push(new l(u[m],u[m+1]));var v=t.groups;if(v.length>0)for(f=0;f<v.length;f++)for(var y=v[f],b=y.start,m=b,x=b+y.count;m<x;m+=3)void 0!==r?e(r[m],r[m+1],r[m+2],y.materialIndex):e(m,m+1,m+2,y.materialIndex);else if(void 0!==r)for(f=0;f<r.length;f+=3)e(r[f],r[f+1],r[f+2]);else for(f=0;f<o.length/3;f+=3)e(f,f+1,f+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,e=this.boundingSphere.radius,i=0===e?1:1/e,r=new v;return r.set(i,0,0,-i*t.x,0,i,0,-i*t.y,0,0,i,-i*t.z,0,0,0,1),this.applyMatrix(r),this},computeFaceNormals:function(){for(var t=this,e=new g,i=new g,r=0,n=this.faces.length;r<n;r++){var o=t.faces[r],a=t.vertices[o.a],s=t.vertices[o.b],c=t.vertices[o.c];e.subVectors(c,s),i.subVectors(a,s),e.cross(i),e.normalize(),o.normal.copy(e)}},computeVertexNormals:function(t){var e=this;void 0===t&&(t=!0);var i,r,n,o,a,s;for(s=new Array(this.vertices.length),i=0,r=this.vertices.length;i<r;i++)s[i]=new g;if(t){var c,u,h,l=new g,p=new g;for(n=0,o=this.faces.length;n<o;n++)a=e.faces[n],c=e.vertices[a.a],u=e.vertices[a.b],h=e.vertices[a.c],l.subVectors(h,u),p.subVectors(c,u),l.cross(p),s[a.a].add(l),s[a.b].add(l),s[a.c].add(l)}else for(this.computeFaceNormals(),n=0,o=this.faces.length;n<o;n++)s[(a=e.faces[n]).a].add(a.normal),s[a.b].add(a.normal),s[a.c].add(a.normal);for(i=0,r=this.vertices.length;i<r;i++)s[i].normalize();for(n=0,o=this.faces.length;n<o;n++){var d=(a=e.faces[n]).vertexNormals;3===d.length?(d[0].copy(s[a.a]),d[1].copy(s[a.b]),d[2].copy(s[a.c])):(d[0]=s[a.a].clone(),d[1]=s[a.b].clone(),d[2]=s[a.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,i,r=this;for(this.computeFaceNormals(),t=0,e=this.faces.length;t<e;t++){var n=(i=r.faces[t]).vertexNormals;3===n.length?(n[0].copy(i.normal),n[1].copy(i.normal),n[2].copy(i.normal)):(n[0]=i.normal.clone(),n[1]=i.normal.clone(),n[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,i,r,n,o=this;for(i=0,r=this.faces.length;i<r;i++)for((n=o.faces[i]).__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),t=0,e=n.vertexNormals.length;t<e;t++)n.__originalVertexNormals[t]?n.__originalVertexNormals[t].copy(n.vertexNormals[t]):n.__originalVertexNormals[t]=n.vertexNormals[t].clone();var a=new wt;for(a.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!o.morphNormals[t]){o.morphNormals[t]={},o.morphNormals[t].faceNormals=[],o.morphNormals[t].vertexNormals=[];var s=o.morphNormals[t].faceNormals,c=o.morphNormals[t].vertexNormals;for(i=0,r=this.faces.length;i<r;i++)h=new g,l={a:new g,b:new g,c:new g},s.push(h),c.push(l)}var u=o.morphNormals[t];a.vertices=o.morphTargets[t].vertices,a.computeFaceNormals(),a.computeVertexNormals();var h,l;for(i=0,r=this.faces.length;i<r;i++)n=o.faces[i],h=u.faceNormals[i],l=u.vertexNormals[i],h.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}for(i=0,r=this.faces.length;i<r;i++)(n=o.faces[i]).normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeLineDistances:function(){for(var t=this,e=0,i=this.vertices,r=0,n=i.length;r<n;r++)r>0&&(e+=i[r].distanceTo(i[r-1])),t.lineDistances[r]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new st),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new ct),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,i){if(!t||!t.isGeometry)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);var r,n=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,u=this.faceVertexUvs[0],h=t.faceVertexUvs[0],l=this.colors,p=t.colors;void 0===i&&(i=0),void 0!==e&&(r=(new ut).getNormalMatrix(e));for(var d=0,f=a.length;d<f;d++){var m=a[d].clone();void 0!==e&&m.applyMatrix4(e),o.push(m)}for(var d=0,f=p.length;d<f;d++)l.push(p[d].clone());for(d=0,f=c.length;d<f;d++){var g,v,y,b=c[d],x=b.vertexNormals,_=b.vertexColors;(g=new xt(b.a+n,b.b+n,b.c+n)).normal.copy(b.normal),void 0!==r&&g.normal.applyMatrix3(r).normalize();for(var w=0,S=x.length;w<S;w++)v=x[w].clone(),void 0!==r&&v.applyMatrix3(r).normalize(),g.vertexNormals.push(v);g.color.copy(b.color);for(var w=0,S=_.length;w<S;w++)y=_[w],g.vertexColors.push(y.clone());g.materialIndex=b.materialIndex+i,s.push(g)}for(d=0,f=h.length;d<f;d++){var A=h[d],M=[];if(void 0!==A){for(var w=0,S=A.length;w<S;w++)M.push(A[w].clone());u.push(M)}}},mergeMesh:function(t){if(!t||!t.isMesh)return void console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)},mergeVertices:function(){var t,e,i,r,n,o,a,s,c=this,u={},h=[],l=[],p=Math.pow(10,4);for(i=0,r=this.vertices.length;i<r;i++)t=c.vertices[i],void 0===u[e=Math.round(t.x*p)+"_"+Math.round(t.y*p)+"_"+Math.round(t.z*p)]?(u[e]=i,h.push(c.vertices[i]),l[i]=h.length-1):l[i]=l[u[e]];var d=[];for(i=0,r=this.faces.length;i<r;i++){(n=c.faces[i]).a=l[n.a],n.b=l[n.b],n.c=l[n.c],o=[n.a,n.b,n.c];for(var f=0;f<3;f++)if(o[f]===o[(f+1)%3]){d.push(i);break}}for(i=d.length-1;i>=0;i--){var m=d[i];for(c.faces.splice(m,1),a=0,s=this.faceVertexUvs.length;a<s;a++)c.faceVertexUvs[a].splice(m,1)}var g=this.vertices.length-h.length;return this.vertices=h,g},sortFacesByMaterialIndex:function(){function t(t,e){return t.materialIndex-e.materialIndex}for(var e=this.faces,i=e.length,r=0;r<i;r++)e[r]._id=r;e.sort(t);var n,o,a=this.faceVertexUvs[0],s=this.faceVertexUvs[1];a&&a.length===i&&(n=[]),s&&s.length===i&&(o=[]);for(r=0;r<i;r++){var c=e[r]._id;n&&n.push(a[c]),o&&o.push(s[c])}n&&(this.faceVertexUvs[0]=n),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){function t(t,e,i){return i?t|1<<e:t&~(1<<e)}function e(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==d[e]?d[e]:(d[e]=p.length/3,p.push(t.x,t.y,t.z),d[e])}function i(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==m[e]?m[e]:(m[e]=f.length,f.push(t.getHex()),m[e])}function r(t){var e=t.x.toString()+t.y.toString();return void 0!==v[e]?v[e]:(v[e]=g.length/2,g.push(t.x,t.y),v[e])}var n=this,o={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(o.uuid=this.uuid,o.type=this.type,""!==this.name&&(o.name=this.name),void 0!==this.parameters){var a=this.parameters;for(var s in a)void 0!==a[s]&&(o[s]=a[s]);return o}for(var c=[],u=0;u<this.vertices.length;u++){var h=n.vertices[u];c.push(h.x,h.y,h.z)}for(var l=[],p=[],d={},f=[],m={},g=[],v={},u=0;u<this.faces.length;u++){var y=n.faces[u],b=void 0!==n.faceVertexUvs[0][u],x=y.normal.length()>0,_=y.vertexNormals.length>0,w=1!==y.color.r||1!==y.color.g||1!==y.color.b,S=y.vertexColors.length>0,A=0;if(A=t(A,0,0),A=t(A,1,!0),A=t(A,2,!1),A=t(A,3,b),A=t(A,4,x),A=t(A,5,_),A=t(A,6,w),A=t(A,7,S),l.push(A),l.push(y.a,y.b,y.c),l.push(y.materialIndex),b){var M=n.faceVertexUvs[0][u];l.push(r(M[0]),r(M[1]),r(M[2]))}if(x&&l.push(e(y.normal)),_){var P=y.vertexNormals;l.push(e(P[0]),e(P[1]),e(P[2]))}if(w&&l.push(i(y.color)),S){var T=y.vertexColors;l.push(i(T[0]),i(T[1]),i(T[2]))}}return o.data={},o.data.vertices=c,o.data.normals=p,f.length>0&&(o.data.colors=f),g.length>0&&(o.data.uvs=[g]),o.data.faces=l,o},clone:function(){return(new wt).copy(this)},copy:function(t){var e,i,r,n,o,a,s=this;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var c=t.vertices;for(e=0,i=c.length;e<i;e++)s.vertices.push(c[e].clone());var u=t.colors;for(e=0,i=u.length;e<i;e++)s.colors.push(u[e].clone());var h=t.faces;for(e=0,i=h.length;e<i;e++)s.faces.push(h[e].clone());for(e=0,i=t.faceVertexUvs.length;e<i;e++){var l=t.faceVertexUvs[e];for(void 0===s.faceVertexUvs[e]&&(s.faceVertexUvs[e]=[]),r=0,n=l.length;r<n;r++){var p=l[r],d=[];for(o=0,a=p.length;o<a;o++){var f=p[o];d.push(f.clone())}s.faceVertexUvs[e].push(d)}}var m=t.morphTargets;for(e=0,i=m.length;e<i;e++){var g={};if(g.name=m[e].name,void 0!==m[e].vertices)for(g.vertices=[],r=0,n=m[e].vertices.length;r<n;r++)g.vertices.push(m[e].vertices[r].clone());if(void 0!==m[e].normals)for(g.normals=[],r=0,n=m[e].normals.length;r<n;r++)g.normals.push(m[e].normals[r].clone());s.morphTargets.push(g)}var v=t.morphNormals;for(e=0,i=v.length;e<i;e++){var y={};if(void 0!==v[e].vertexNormals)for(y.vertexNormals=[],r=0,n=v[e].vertexNormals.length;r<n;r++){var b=v[e].vertexNormals[r],x={};x.a=b.a.clone(),x.b=b.b.clone(),x.c=b.c.clone(),y.vertexNormals.push(x)}if(void 0!==v[e].faceNormals)for(y.faceNormals=[],r=0,n=v[e].faceNormals.length;r<n;r++)y.faceNormals.push(v[e].faceNormals[r].clone());s.morphNormals.push(y)}var _=t.skinWeights;for(e=0,i=_.length;e<i;e++)s.skinWeights.push(_[e].clone());var w=t.skinIndices;for(e=0,i=w.length;e<i;e++)s.skinIndices.push(w[e].clone());var S=t.lineDistances;for(e=0,i=S.length;e<i;e++)s.lineDistances.push(S[e]);var A=t.boundingBox;null!==A&&(this.boundingBox=A.clone());var M=t.boundingSphere;return null!==M&&(this.boundingSphere=M.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(St.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(St.prototype,{isBufferAttribute:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.itemSize:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){var r=this;t*=this.itemSize,i*=e.itemSize;for(var n=0,o=this.itemSize;n<o;n++)r.array[t+n]=e.array[i+n];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),o=new tt),e[i++]=o.r,e[i++]=o.g,e[i++]=o.b}return this},copyIndicesArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];e[i++]=o.a,e[i++]=o.b,e[i++]=o.c}return this},copyVector2sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),o=new l),e[i++]=o.x,e[i++]=o.y}return this},copyVector3sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),o=new g),e[i++]=o.x,e[i++]=o.y,e[i++]=o.z}return this},copyVector4sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),o=new d),e[i++]=o.x,e[i++]=o.y,e[i++]=o.z,e[i++]=o.w}return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=r,this},setXYZW:function(t,e,i,r,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=r,this.array[t+3]=n,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),At.prototype=Object.create(St.prototype),At.prototype.constructor=At,Mt.prototype=Object.create(St.prototype),Mt.prototype.constructor=Mt,Pt.prototype=Object.create(St.prototype),Pt.prototype.constructor=Pt,Object.assign(Tt.prototype,{computeGroups:function(t){for(var e,i=[],r=void 0,n=t.faces,o=0;o<n.length;o++){var a=n[o];a.materialIndex!==r&&(r=a.materialIndex,void 0!==e&&(e.count=3*o-e.start,i.push(e)),e={start:3*o,materialIndex:r})}void 0!==e&&(e.count=3*o-e.start,i.push(e)),this.groups=i},fromGeometry:function(t){var e,i=this,r=t.faces,n=t.vertices,o=t.faceVertexUvs,a=o[0]&&o[0].length>0,s=o[1]&&o[1].length>0,c=t.morphTargets,u=c.length;if(u>0){e=[];for(y=0;y<u;y++)e[y]=[];this.morphTargets.position=e}var h,p=t.morphNormals,d=p.length;if(d>0){h=[];for(y=0;y<d;y++)h[y]=[];this.morphTargets.normal=h}for(var f=t.skinIndices,m=t.skinWeights,g=f.length===n.length,v=m.length===n.length,y=0;y<r.length;y++){var b=r[y];i.vertices.push(n[b.a],n[b.b],n[b.c]);var x=b.vertexNormals;if(3===x.length)i.normals.push(x[0],x[1],x[2]);else{var _=b.normal;i.normals.push(_,_,_)}var w=b.vertexColors;if(3===w.length)i.colors.push(w[0],w[1],w[2]);else{var S=b.color;i.colors.push(S,S,S)}if(!0===a&&(void 0!==(A=o[0][y])?i.uvs.push(A[0],A[1],A[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",y),i.uvs.push(new l,new l,new l))),!0===s){var A=o[1][y];void 0!==A?i.uvs2.push(A[0],A[1],A[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",y),i.uvs2.push(new l,new l,new l))}for(P=0;P<u;P++){var M=c[P].vertices;e[P].push(M[b.a],M[b.b],M[b.c])}for(var P=0;P<d;P++){var T=p[P].vertexNormals[y];h[P].push(T.a,T.b,T.c)}g&&i.skinIndices.push(f[b.a],f[b.b],f[b.c]),v&&i.skinWeights.push(m[b.a],m[b.b],m[b.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}}),Ct.MaxIndex=65535,Object.assign(Ct.prototype,h.prototype,{isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(Et(t)>65535?Mt:At)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new St(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,i){this.groups.push({start:t,count:e,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var i=this.attributes.normal;return void 0!==i&&((new ut).getNormalMatrix(t).applyToBufferAttribute(i),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new v;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new v;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new v;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new v;return function(e,i,r){return t.makeTranslation(e,i,r),this.applyMatrix(t),this}}(),scale:function(){var t=new v;return function(e,i,r){return t.makeScale(e,i,r),this.applyMatrix(t),this}}(),lookAt:function(){var t=new gt;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var i=new Pt(3*e.vertices.length,3),r=new Pt(3*e.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(e.vertices)),this.addAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var n=new Pt(e.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var i=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(i=void 0,e.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(e);i.verticesNeedUpdate=e.verticesNeedUpdate,i.normalsNeedUpdate=e.normalsNeedUpdate,i.colorsNeedUpdate=e.colorsNeedUpdate,i.uvsNeedUpdate=e.uvsNeedUpdate,i.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=i}var r;return!0===e.verticesNeedUpdate&&(void 0!==(r=this.attributes.position)&&(r.copyVector3sArray(e.vertices),r.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(r=this.attributes.normal)&&(r.copyVector3sArray(e.normals),r.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(r=this.attributes.color)&&(r.copyColorsArray(e.colors),r.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(r=this.attributes.uv)&&(r.copyVector2sArray(e.uvs),r.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(r=this.attributes.lineDistance)&&(r.copyArray(e.lineDistances),r.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Tt).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=this,i=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new St(i,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new St(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new St(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var o=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new St(o,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new St(a,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var s=new(Et(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new St(s,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var c in t.morphTargets){for(var u=[],h=t.morphTargets[c],l=0,p=h.length;l<p;l++){var d=h[l],f=new Pt(3*d.length,3);u.push(f.copyVector3sArray(d))}e.morphAttributes[c]=u}if(t.skinIndices.length>0){var m=new Pt(4*t.skinIndices.length,4);this.addAttribute("skinIndex",m.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var g=new Pt(4*t.skinWeights.length,4);this.addAttribute("skinWeight",g.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new st);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new st,e=new g;return function(){null===this.boundingSphere&&(this.boundingSphere=new ct);var i=this.attributes.position;if(i){var r=this.boundingSphere.center;t.setFromBufferAttribute(i),t.getCenter(r);for(var n=0,o=0,a=i.count;o<a;o++)e.x=i.getX(o),e.y=i.getY(o),e.z=i.getZ(o),n=Math.max(n,r.distanceToSquared(e));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.attributes,i=this.groups;if(e.position){var r=e.position.array;if(void 0===e.normal)this.addAttribute("normal",new St(new Float32Array(r.length),3));else for(var n=e.normal.array,o=0,a=n.length;o<a;o++)n[o]=0;var s,c,u,h=e.normal.array,l=new g,p=new g,d=new g,f=new g,m=new g;if(t){var v=t.array;0===i.length&&this.addGroup(0,v.length);for(var y=0,b=i.length;y<b;++y)for(var x=i[y],_=x.start,o=_,a=_+x.count;o<a;o+=3)s=3*v[o+0],c=3*v[o+1],u=3*v[o+2],l.fromArray(r,s),p.fromArray(r,c),d.fromArray(r,u),f.subVectors(d,p),m.subVectors(l,p),f.cross(m),h[s]+=f.x,h[s+1]+=f.y,h[s+2]+=f.z,h[c]+=f.x,h[c+1]+=f.y,h[c+2]+=f.z,h[u]+=f.x,h[u+1]+=f.y,h[u+2]+=f.z}else for(var o=0,a=r.length;o<a;o+=9)l.fromArray(r,o),p.fromArray(r,o+3),d.fromArray(r,o+6),f.subVectors(d,p),m.subVectors(l,p),f.cross(m),h[o]=f.x,h[o+1]=f.y,h[o+2]=f.z,h[o+3]=f.x,h[o+4]=f.y,h[o+5]=f.z,h[o+6]=f.x,h[o+7]=f.y,h[o+8]=f.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},merge:function(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0);var i=this.attributes;for(var r in i)if(void 0!==t.attributes[r])for(var n=i[r].array,o=t.attributes[r],a=o.array,s=0,c=o.itemSize*e;s<a.length;s++,c++)n[c]=a[s];return this},normalizeNormals:function(){for(var t,e,i,r,n=this.attributes.normal,o=0,a=n.count;o<a;o++)t=n.getX(o),e=n.getY(o),i=n.getZ(o),r=1/Math.sqrt(t*t+e*e+i*i),n.setXYZ(o,t*r,e*r,i*r)},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new Ct,e=this.index.array,i=this.attributes;for(var r in i){for(var n=i[r],o=n.array,a=n.itemSize,s=new o.constructor(e.length*a),c=0,u=0,h=0,l=e.length;h<l;h++){c=e[h]*a;for(var p=0;p<a;p++)s[u++]=o[c++]}t.addAttribute(r,new St(s,a))}return t},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};var r=this.index;if(null!==r){a=Array.prototype.slice.call(r.array);t.data.index={type:r.array.constructor.name,array:a}}var n=this.attributes;for(var i in n){var o=n[i],a=Array.prototype.slice.call(o.array);t.data.attributes[i]={itemSize:o.itemSize,type:o.array.constructor.name,array:a,normalized:o.normalized}}var s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Ct).copy(this)},copy:function(t){var e,i,r,n=this;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var o=t.index;null!==o&&this.setIndex(o.clone());var a=t.attributes;for(e in a){var s=a[e];n.addAttribute(e,s.clone())}var c=t.morphAttributes;for(e in c){var u=[],h=c[e];for(i=0,r=h.length;i<r;i++)u.push(h[i].clone());n.morphAttributes[e]=u}var l=t.groups;for(i=0,r=l.length;i<r;i++){var p=l[i];n.addGroup(p.start,p.count,p.materialIndex)}var d=t.boundingBox;null!==d&&(this.boundingBox=d.clone());var f=t.boundingSphere;return null!==f&&(this.boundingSphere=f.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),It.prototype=Object.create(wt.prototype),It.prototype.constructor=It,Rt.prototype=Object.create(Ct.prototype),Rt.prototype.constructor=Rt,Lt.prototype=Object.create(wt.prototype),Lt.prototype.constructor=Lt,Ot.prototype=Object.create(Ct.prototype),Ot.prototype.constructor=Ot,Dt.prototype=Object.create(nt.prototype),Dt.prototype.constructor=Dt,Dt.prototype.isMeshBasicMaterial=!0,Dt.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},Object.assign(Nt.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new g).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new g;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var i=e||new g;i.subVectors(t,this.origin);var r=i.dot(this.direction);return r<0?i.copy(this.origin):i.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new g;return function(e){var i=t.subVectors(e,this.origin).dot(this.direction);return i<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(i).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new g,e=new g,i=new g;return function(r,n,o,a){t.copy(r).add(n).multiplyScalar(.5),e.copy(n).sub(r).normalize(),i.copy(this.origin).sub(t);var s,c,u,h,l=.5*r.distanceTo(n),p=-this.direction.dot(e),d=i.dot(this.direction),f=-i.dot(e),m=i.lengthSq(),g=Math.abs(1-p*p);if(g>0)if(s=p*f-d,c=p*d-f,h=l*g,s>=0)if(c>=-h)if(c<=h){var v=1/g;u=(s*=v)*(s+p*(c*=v)+2*d)+c*(p*s+c+2*f)+m}else c=l,u=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c=-l,u=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c<=-h?u=-(s=Math.max(0,-(-p*l+d)))*s+(c=s>0?-l:Math.min(Math.max(-l,-f),l))*(c+2*f)+m:c<=h?(s=0,u=(c=Math.min(Math.max(-l,-f),l))*(c+2*f)+m):u=-(s=Math.max(0,-(p*l+d)))*s+(c=s>0?l:Math.min(Math.max(-l,-f),l))*(c+2*f)+m;else c=p>0?-l:l,u=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),u}}(),intersectSphere:function(){var t=new g;return function(e,i){t.subVectors(e.center,this.origin);var r=t.dot(this.direction),n=t.dot(t)-r*r,o=e.radius*e.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=r-a,c=r+a;return s<0&&c<0?null:s<0?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null},intersectPlane:function(t,e){var i=this.distanceToPlane(t);return null===i?null:this.at(i,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var i,r,n,o,a,s,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,l=this.origin;return c>=0?(i=(t.min.x-l.x)*c,r=(t.max.x-l.x)*c):(i=(t.max.x-l.x)*c,r=(t.min.x-l.x)*c),u>=0?(n=(t.min.y-l.y)*u,o=(t.max.y-l.y)*u):(n=(t.max.y-l.y)*u,o=(t.min.y-l.y)*u),i>o||n>r?null:((n>i||i!==i)&&(i=n),(o<r||r!==r)&&(r=o),h>=0?(a=(t.min.z-l.z)*h,s=(t.max.z-l.z)*h):(a=(t.max.z-l.z)*h,s=(t.min.z-l.z)*h),i>s||a>r?null:((a>i||i!==i)&&(i=a),(s<r||r!==r)&&(r=s),r<0?null:this.at(i>=0?i:r,e)))},intersectsBox:function(){var t=new g;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new g,e=new g,i=new g,r=new g;return function(n,o,a,s,c){e.subVectors(o,n),i.subVectors(a,n),r.crossVectors(e,i);var u,h=this.direction.dot(r);if(h>0){if(s)return null;u=1}else{if(!(h<0))return null;u=-1,h=-h}t.subVectors(this.origin,n);var l=u*this.direction.dot(i.crossVectors(t,i));if(l<0)return null;var p=u*this.direction.dot(e.cross(t));if(p<0)return null;if(l+p>h)return null;var d=-u*t.dot(r);return d<0?null:this.at(d/h,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(kt.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return(t||new g).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new g).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var i=e||new g;return this.delta(i).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new g,e=new g;return function(i,r){t.subVectors(i,this.start),e.subVectors(this.end,this.start);var n=e.dot(e),o=e.dot(t)/n;return r&&(o=xl.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,i){var r=this.closestPointToPointParameter(t,e),n=i||new g;return this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(Ft,{normal:function(){var t=new g;return function(e,i,r,n){var o=n||new g;o.subVectors(r,i),t.subVectors(e,i),o.cross(t);var a=o.lengthSq();return a>0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),barycoordFromPoint:function(){var t=new g,e=new g,i=new g;return function(r,n,o,a,s){t.subVectors(a,n),e.subVectors(o,n),i.subVectors(r,n);var c=t.dot(t),u=t.dot(e),h=t.dot(i),l=e.dot(e),p=e.dot(i),d=c*l-u*u,f=s||new g;if(0===d)return f.set(-2,-1,-1);var m=1/d,v=(l*h-u*p)*m,y=(c*p-u*h)*m;return f.set(1-v-y,y,v)}}(),containsPoint:function(){var t=new g;return function(e,i,r,n){var o=Ft.barycoordFromPoint(e,i,r,n,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Ft.prototype,{set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,r){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new g,e=new g;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new g).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return Ft.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new ht).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Ft.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Ft.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t=new ht,e=[new kt,new kt,new kt],i=new g,r=new g;return function(n,o){var a=o||new g,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(n,i),!0===this.containsPoint(i))a.copy(i);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c<e.length;c++){e[c].closestPointToPoint(i,!0,r);var u=i.distanceToSquared(r);u<s&&(s=u,a.copy(r))}}return a}}(),equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),Bt.prototype=Object.assign(Object.create(gt.prototype),{constructor:Bt,isMesh:!0,setDrawMode:function(t){this.drawMode=t},copy:function(t){return gt.prototype.copy.call(this,t),this.drawMode=t.drawMode,this},updateMorphTargets:function(){var t,e,i,r=this,n=this.geometry;if(n.isBufferGeometry){var o=n.morphAttributes,a=Object.keys(o);if(a.length>0){var s=o[a[0]];if(void 0!==s)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t<e;t++)i=s[t].name||String(t),r.morphTargetInfluences.push(0),r.morphTargetDictionary[i]=t}}else{var c=n.morphTargets;if(void 0!==c&&c.length>0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=c.length;t<e;t++)i=c[t].name||String(t),r.morphTargetInfluences.push(0),r.morphTargetDictionary[i]=t}},raycast:function(){function t(t,e,i,r,n,o,a){return Ft.barycoordFromPoint(t,e,i,r,y),n.multiplyScalar(y.x),o.multiplyScalar(y.y),a.multiplyScalar(y.z),n.add(o).add(a),n.clone()}function e(t,e,i,r,n,o,a){var s=t.material;if(null===(s.side===Mu?i.intersectTriangle(o,n,r,!0,a):i.intersectTriangle(r,n,o,s.side!==Pu,a)))return null;x.copy(a),x.applyMatrix4(t.matrixWorld);var c=e.ray.origin.distanceTo(x);return c<e.near||c>e.far?null:{distance:c,point:x.clone(),object:t}}function i(i,r,n,o,u,h,l,p){a.fromBufferAttribute(o,h),s.fromBufferAttribute(o,l),c.fromBufferAttribute(o,p);var g=e(i,r,n,a,s,c,b);return g&&(u&&(d.fromBufferAttribute(u,h),f.fromBufferAttribute(u,l),m.fromBufferAttribute(u,p),g.uv=t(b,a,s,c,d,f,m)),g.face=new xt(h,l,p,Ft.normal(a,s,c)),g.faceIndex=h),g}var r=new v,n=new Nt,o=new ct,a=new g,s=new g,c=new g,u=new g,h=new g,p=new g,d=new l,f=new l,m=new l,y=new g,b=new g,x=new g;return function(l,g){var v=this,y=this.geometry,x=this.material,_=this.matrixWorld;if(void 0!==x&&(null===y.boundingSphere&&y.computeBoundingSphere(),o.copy(y.boundingSphere),o.applyMatrix4(_),!1!==l.ray.intersectsSphere(o)&&(r.getInverse(_),n.copy(l.ray).applyMatrix4(r),null===y.boundingBox||!1!==n.intersectsBox(y.boundingBox)))){var w;if(y.isBufferGeometry){var S,A,M,P,T,E=y.index,C=y.attributes.position,I=y.attributes.uv;if(null!==E)for(P=0,T=E.count;P<T;P+=3)S=E.getX(P),A=E.getX(P+1),M=E.getX(P+2),(w=i(v,l,n,C,I,S,A,M))&&(w.faceIndex=Math.floor(P/3),g.push(w));else for(P=0,T=C.count;P<T;P+=3)(w=i(v,l,n,C,I,S=P,A=P+1,M=P+2))&&(w.index=S,g.push(w))}else if(y.isGeometry){var R,L,O,D,N=Array.isArray(x),k=y.vertices,F=y.faces,B=y.faceVertexUvs[0];B.length>0&&(D=B);for(var z=0,U=F.length;z<U;z++){var j=F[z],G=N?x[j.materialIndex]:x;if(void 0!==G){if(R=k[j.a],L=k[j.b],O=k[j.c],!0===G.morphTargets){var V=y.morphTargets,$=v.morphTargetInfluences;a.set(0,0,0),s.set(0,0,0),c.set(0,0,0);for(var H=0,W=V.length;H<W;H++){var X=$[H];if(0!==X){var q=V[H].vertices;a.addScaledVector(u.subVectors(q[j.a],R),X),s.addScaledVector(h.subVectors(q[j.b],L),X),c.addScaledVector(p.subVectors(q[j.c],O),X)}}a.add(R),s.add(L),c.add(O),R=a,L=s,O=c}if(w=e(v,l,n,R,L,O,b)){if(D&&D[z]){var Y=D[z];d.copy(Y[0]),f.copy(Y[1]),m.copy(Y[2]),w.uv=t(b,R,L,O,d,f,m)}w.face=j,w.faceIndex=z,g.push(w)}}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Fl=0;fe.prototype=Object.assign(Object.create(bt.prototype),{constructor:fe,isArrayCamera:!0}),be.prototype.isFogExp2=!0,be.prototype.clone=function(){return new be(this.color.getHex(),this.density)},be.prototype.toJSON=function(t){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},xe.prototype.isFog=!0,xe.prototype.clone=function(){return new xe(this.color.getHex(),this.near,this.far)},xe.prototype.toJSON=function(t){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},_e.prototype=Object.assign(Object.create(gt.prototype),{constructor:_e,copy:function(t,e){return gt.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}),we.prototype=Object.assign(Object.create(gt.prototype),{constructor:we,isLensFlare:!0,copy:function(t){var e=this;gt.prototype.copy.call(this,t),this.positionScreen.copy(t.positionScreen),this.customUpdateCallback=t.customUpdateCallback;for(var i=0,r=t.lensFlares.length;i<r;i++)e.lensFlares.push(t.lensFlares[i]);return this},add:function(t,e,i,r,n,o){void 0===e&&(e=-1),void 0===i&&(i=0),void 0===o&&(o=1),void 0===n&&(n=new tt(16777215)),void 0===r&&(r=Ou),i=Math.min(i,Math.max(0,i)),this.lensFlares.push({texture:t,size:e,distance:i,x:0,y:0,z:0,scale:1,rotation:0,opacity:o,color:n,blending:r})},updateLensFlares:function(){var t,e,i=this,r=this.lensFlares.length,n=2*-this.positionScreen.x,o=2*-this.positionScreen.y;for(t=0;t<r;t++)(e=i.lensFlares[t]).x=i.positionScreen.x+n*e.distance,e.y=i.positionScreen.y+o*e.distance,e.wantedRotation=e.x*Math.PI*.25,e.rotation+=.25*(e.wantedRotation-e.rotation)}}),Se.prototype=Object.create(nt.prototype),Se.prototype.constructor=Se,Se.prototype.isSpriteMaterial=!0,Se.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.rotation=t.rotation,this},Ae.prototype=Object.assign(Object.create(gt.prototype),{constructor:Ae,isSprite:!0,raycast:function(){var t=new g,e=new g,i=new g;return function(r,n){e.setFromMatrixPosition(this.matrixWorld),r.ray.closestPointToPoint(e,t),i.setFromMatrixScale(this.matrixWorld);var o=i.x*i.y/4;if(!(e.distanceToSquared(t)>o)){var a=r.ray.origin.distanceTo(t);a<r.near||a>r.far||n.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),Me.prototype=Object.assign(Object.create(gt.prototype),{constructor:Me,copy:function(t){var e=this;gt.prototype.copy.call(this,t,!1);for(var i=t.levels,r=0,n=i.length;r<n;r++){var o=i[r];e.addLevel(o.object.clone(),o.distance)}return this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var i=this.levels,r=0;r<i.length&&!(e<i[r].distance);r++);i.splice(r,0,{distance:e,object:t}),this.add(t)},getObjectForDistance:function(t){for(var e=this.levels,i=1,r=e.length;i<r&&!(t<e[i].distance);i++);return e[i-1].object},raycast:function(){var t=new g;return function(e,i){t.setFromMatrixPosition(this.matrixWorld);var r=e.ray.origin.distanceTo(t);this.getObjectForDistance(r).raycast(e,i)}}(),update:function(){var t=new g,e=new g;return function(i){var r=this.levels;if(r.length>1){t.setFromMatrixPosition(i.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var n=t.distanceTo(e);r[0].object.visible=!0;for(var o=1,a=r.length;o<a&&n>=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;o<a;o++)r[o].object.visible=!1}}}(),toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);e.object.levels=[];for(var i=this.levels,r=0,n=i.length;r<n;r++){var o=i[r];e.object.levels.push({object:o.object.uuid,distance:o.distance})}return e}}),Object.assign(Pe.prototype,{calculateInverses:function(){var t=this;this.boneInverses=[];for(var e=0,i=this.bones.length;e<i;e++){var r=new v;t.bones[e]&&r.getInverse(t.bones[e].matrixWorld),t.boneInverses.push(r)}},pose:function(){var t,e,i,r=this;for(e=0,i=this.bones.length;e<i;e++)(t=r.bones[e])&&t.matrixWorld.getInverse(r.boneInverses[e]);for(e=0,i=this.bones.length;e<i;e++)(t=r.bones[e])&&(t.parent&&t.parent.isBone?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},update:function(){var t=new v,e=new v;return function(){for(var i=this.bones,r=this.boneInverses,n=this.boneMatrices,o=this.boneTexture,a=0,s=i.length;a<s;a++){var c=i[a]?i[a].matrixWorld:e;t.multiplyMatrices(c,r[a]),t.toArray(n,16*a)}void 0!==o&&(o.needsUpdate=!0)}}(),clone:function(){return new Pe(this.bones,this.boneInverses)}}),Te.prototype=Object.assign(Object.create(gt.prototype),{constructor:Te,isBone:!0}),Ee.prototype=Object.assign(Object.create(Bt.prototype),{constructor:Ee,isSkinnedMesh:!0,initBones:function(){var t,e,i,r,n=this,o=[];if(this.geometry&&void 0!==this.geometry.bones){for(i=0,r=this.geometry.bones.length;i<r;i++)e=n.geometry.bones[i],t=new Te,o.push(t),t.name=e.name,t.position.fromArray(e.pos),t.quaternion.fromArray(e.rotq),void 0!==e.scl&&t.scale.fromArray(e.scl);for(i=0,r=this.geometry.bones.length;i<r;i++)-1!==(e=n.geometry.bones[i]).parent&&null!==e.parent&&void 0!==o[e.parent]?o[e.parent].add(o[i]):n.add(o[i])}return this.updateMatrixWorld(!0),o},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var t,e,i=this;if(this.geometry&&this.geometry.isGeometry)for(e=0;e<this.geometry.skinWeights.length;e++){var r=i.geometry.skinWeights[e];(t=1/r.lengthManhattan())!==1/0?r.multiplyScalar(t):r.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){var n=new d,o=this.geometry.attributes.skinWeight;for(e=0;e<o.count;e++)n.x=o.getX(e),n.y=o.getY(e),n.z=o.getZ(e),n.w=o.getW(e),(t=1/n.lengthManhattan())!==1/0?n.multiplyScalar(t):n.set(1,0,0,0),o.setXYZW(e,n.x,n.y,n.z,n.w)}},updateMatrixWorld:function(t){Bt.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Ce.prototype=Object.create(nt.prototype),Ce.prototype.constructor=Ce,Ce.prototype.isLineBasicMaterial=!0,Ce.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this},Ie.prototype=Object.assign(Object.create(gt.prototype),{constructor:Ie,isLine:!0,raycast:function(){var t=new v,e=new Nt,i=new ct;return function(r,n){var o=this,a=r.linePrecision,s=a*a,c=this.geometry,u=this.matrixWorld;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(u),!1!==r.ray.intersectsSphere(i)){t.getInverse(u),e.copy(r.ray).applyMatrix4(t);var h=new g,l=new g,p=new g,d=new g,f=this&&this.isLineSegments?2:1;if(c.isBufferGeometry){var m=c.index,v=c.attributes.position.array;if(null!==m)for(var y=m.array,b=0,x=y.length-1;b<x;b+=f){var _=y[b],w=y[b+1];h.fromArray(v,3*_),l.fromArray(v,3*w),(M=e.distanceSqToSegment(h,l,d,p))>s||(d.applyMatrix4(o.matrixWorld),(P=r.ray.origin.distanceTo(d))<r.near||P>r.far||n.push({distance:P,point:p.clone().applyMatrix4(o.matrixWorld),index:b,face:null,faceIndex:null,object:o}))}else for(var b=0,x=v.length/3-1;b<x;b+=f)h.fromArray(v,3*b),l.fromArray(v,3*b+3),(M=e.distanceSqToSegment(h,l,d,p))>s||(d.applyMatrix4(o.matrixWorld),(P=r.ray.origin.distanceTo(d))<r.near||P>r.far||n.push({distance:P,point:p.clone().applyMatrix4(o.matrixWorld),index:b,face:null,faceIndex:null,object:o}))}else if(c.isGeometry)for(var S=c.vertices,A=S.length,b=0;b<A-1;b+=f){var M=e.distanceSqToSegment(S[b],S[b+1],d,p);if(!(M>s)){d.applyMatrix4(o.matrixWorld);var P=r.ray.origin.distanceTo(d);P<r.near||P>r.far||n.push({distance:P,point:p.clone().applyMatrix4(o.matrixWorld),index:b,face:null,faceIndex:null,object:o})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Re.prototype=Object.assign(Object.create(Ie.prototype),{constructor:Re,isLineSegments:!0}),Le.prototype=Object.assign(Object.create(Ie.prototype),{constructor:Le,isLineLoop:!0}),Oe.prototype=Object.create(nt.prototype),Oe.prototype.constructor=Oe,Oe.prototype.isPointsMaterial=!0,Oe.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},De.prototype=Object.assign(Object.create(gt.prototype),{constructor:De,isPoints:!0,raycast:function(){var t=new v,e=new Nt,i=new ct;return function(r,n){function o(t,i){var o=e.distanceSqToPoint(t);if(o<l){var s=e.closestPointToPoint(t);s.applyMatrix4(c);var u=r.ray.origin.distanceTo(s);if(u<r.near||u>r.far)return;n.push({distance:u,distanceToRay:Math.sqrt(o),point:s.clone(),index:i,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=r.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),i.copy(s.boundingSphere),i.applyMatrix4(c),i.radius+=u,!1!==r.ray.intersectsSphere(i)){t.getInverse(c),e.copy(r.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),l=h*h,p=new g;if(s.isBufferGeometry){var d=s.index,f=s.attributes.position.array;if(null!==d)for(var m=d.array,v=0,y=m.length;v<y;v++){var b=m[v];p.fromArray(f,3*b),o(p,b)}else for(var v=0,x=f.length/3;v<x;v++)p.fromArray(f,3*v),o(p,v)}else for(var _=s.vertices,v=0,x=_.length;v<x;v++)o(_[v],v)}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Ne.prototype=Object.assign(Object.create(gt.prototype),{constructor:Ne}),ke.prototype=Object.create(p.prototype),ke.prototype.constructor=ke,ke.prototype.isCompressedTexture=!0,Fe.prototype=Object.create(p.prototype),Fe.prototype.constructor=Fe,Be.prototype=Object.create(Ct.prototype),Be.prototype.constructor=Be,ze.prototype=Object.create(wt.prototype),ze.prototype.constructor=ze,Ue.prototype=Object.create(Ct.prototype),Ue.prototype.constructor=Ue,je.prototype=Object.create(wt.prototype),je.prototype.constructor=je,Ge.prototype=Object.create(Ct.prototype),Ge.prototype.constructor=Ge,Ve.prototype=Object.create(wt.prototype),Ve.prototype.constructor=Ve,$e.prototype=Object.create(Ge.prototype),$e.prototype.constructor=$e,He.prototype=Object.create(wt.prototype),He.prototype.constructor=He,We.prototype=Object.create(Ge.prototype),We.prototype.constructor=We,Xe.prototype=Object.create(wt.prototype),Xe.prototype.constructor=Xe,qe.prototype=Object.create(Ge.prototype),qe.prototype.constructor=qe,Ye.prototype=Object.create(wt.prototype),Ye.prototype.constructor=Ye,Ze.prototype=Object.create(Ge.prototype),Ze.prototype.constructor=Ze,Ke.prototype=Object.create(wt.prototype),Ke.prototype.constructor=Ke,Qe.prototype=Object.create(Ct.prototype),Qe.prototype.constructor=Qe,Je.prototype=Object.create(wt.prototype),Je.prototype.constructor=Je,ti.prototype=Object.create(Ct.prototype),ti.prototype.constructor=ti,ei.prototype=Object.create(wt.prototype),ei.prototype.constructor=ei,ii.prototype=Object.create(Ct.prototype),ii.prototype.constructor=ii;var Bl={area:function(t){for(var e=t.length,i=0,r=e-1,n=0;n<e;r=n++)i+=t[r].x*t[n].y-t[n].x*t[r].y;return.5*i},triangulate:function(){function t(t,e,i,r,n,o){var a,s,c,u,h,l,p,d,f;if(s=t[o[e]].x,c=t[o[e]].y,u=t[o[i]].x,h=t[o[i]].y,l=t[o[r]].x,p=t[o[r]].y,(u-s)*(p-c)-(h-c)*(l-s)<=0)return!1;var m,g,v,y,b,x,_,w,S,A,M,P,T,E,C;for(m=l-u,g=p-h,v=s-l,y=c-p,b=u-s,x=h-c,a=0;a<n;a++)if(d=t[o[a]].x,f=t[o[a]].y,!(d===s&&f===c||d===u&&f===h||d===l&&f===p)&&(_=d-s,w=f-c,S=d-u,A=f-h,M=d-l,P=f-p,C=m*A-g*S,T=b*w-x*_,E=v*P-y*M,C>=-Number.EPSILON&&E>=-Number.EPSILON&&T>=-Number.EPSILON))return!1;return!0}return function(e,i){var r=e.length;if(r<3)return null;var n,o,a,s=[],c=[],u=[];if(Bl.area(e)>0)for(o=0;o<r;o++)c[o]=o;else for(o=0;o<r;o++)c[o]=r-1-o;var h=r,l=2*h;for(o=h-1;h>2;){if(l--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?u:s;if(n=o,h<=n&&(n=0),o=n+1,h<=o&&(o=0),a=o+1,h<=a&&(a=0),t(e,n,o,a,h,c)){var p,d,f,m,g;for(p=c[n],d=c[o],f=c[a],s.push([e[p],e[d],e[f]]),u.push([c[n],c[o],c[a]]),m=o,g=o+1;g<h;m++,g++)c[m]=c[g];l=2*--h}}return i?u:s}}(),triangulateShape:function(t,e){function i(t){var e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function r(t,e,i){return t.x!==e.x?t.x<e.x?t.x<=i.x&&i.x<=e.x:e.x<=i.x&&i.x<=t.x:t.y<e.y?t.y<=i.y&&i.y<=e.y:e.y<=i.y&&i.y<=t.y}function n(t,e,i,n,o){var a=e.x-t.x,s=e.y-t.y,c=n.x-i.x,u=n.y-i.y,h=t.x-i.x,l=t.y-i.y,p=s*c-a*u,d=s*h-a*l;if(Math.abs(p)>Number.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=u*h-c*l)<0||f>p)return[]}else{if(d>0||d<p)return[];if((f=u*h-c*l)>0||f<p)return[]}if(0===f)return!o||0!==d&&d!==p?[t]:[];if(f===p)return!o||0!==d&&d!==p?[e]:[];if(0===d)return[i];if(d===p)return[n];var m=f/p;return[{x:t.x+m*a,y:t.y+m*s}]}if(0!==d||u*h!=c*l)return[];var g=0===a&&0===s,v=0===c&&0===u;if(g&&v)return t.x!==i.x||t.y!==i.y?[]:[t];if(g)return r(i,n,t)?[t]:[];if(v)return r(t,e,i)?[i]:[];var y,b,x,_,w,S,A,M;return 0!==a?(t.x<e.x?(y=t,x=t.x,b=e,_=e.x):(y=e,x=e.x,b=t,_=t.x),i.x<n.x?(w=i,A=i.x,S=n,M=n.x):(w=n,A=n.x,S=i,M=i.x)):(t.y<e.y?(y=t,x=t.y,b=e,_=e.y):(y=e,x=e.y,b=t,_=t.y),i.y<n.y?(w=i,A=i.y,S=n,M=n.y):(w=n,A=n.y,S=i,M=i.y)),x<=A?_<A?[]:_===A?o?[]:[w]:_<=M?[w,b]:[w,S]:x>M?[]:x===M?o?[]:[y]:_<=M?[y,b]:[y,S]}function o(t,e,i,r){var n=e.x-t.x,o=e.y-t.y,a=i.x-t.x,s=i.y-t.y,c=r.x-t.x,u=r.y-t.y,h=n*s-o*a,l=n*u-o*c;if(Math.abs(h)>Number.EPSILON){var p=c*s-u*a;return h>0?l>=0&&p>=0:l>=0||p>=0}return l>0}i(t),e.forEach(i);for(var a,s,c,u,h,l,p={},d=t.concat(),f=0,m=e.length;f<m;f++)Array.prototype.push.apply(d,e[f]);for(a=0,s=d.length;a<s;a++)void 0!==p[h=d[a].x+":"+d[a].y]&&console.warn("THREE.ShapeUtils: Duplicate point",h,a),p[h]=a;var g=function(t,e){for(var i,r,a,s,c,u,h,l,p,d,f,m=t.concat(),g=[],v=[],y=0,b=e.length;y<b;y++)g.push(y);for(var x=0,_=2*g.length;g.length>0;){if(--_<0){console.log("Infinite Loop! Holes left:"+g.length+", Probably Hole outside Shape!");break}for(a=x;a<m.length;a++){s=m[a],r=-1;for(y=0;y<g.length;y++)if(u=g[y],h=s.x+":"+s.y+":"+u,void 0===v[h]){i=e[u];for(var w=0;w<i.length;w++)if(c=i[w],function(t,e){var r=m.length-1,n=t-1;n<0&&(n=r);var a=t+1;a>r&&(a=0);var s=o(m[t],m[n],m[a],i[e]);if(!s)return!1;var c=i.length-1,u=e-1;u<0&&(u=c);var h=e+1;return h>c&&(h=0),!!(s=o(i[e],i[u],i[h],m[t]))}(a,w)&&!function(t,e){var i,r;for(i=0;i<m.length;i++)if(r=i+1,r%=m.length,n(t,e,m[i],m[r],!0).length>0)return!0;return!1}(s,c)&&!function(t,i){var r,o,a,s;for(r=0;r<g.length;r++)for(o=e[g[r]],a=0;a<o.length;a++)if(s=a+1,s%=o.length,n(t,i,o[a],o[s],!0).length>0)return!0;return!1}(s,c)){r=w,g.splice(y,1),l=m.slice(0,a+1),p=m.slice(a),d=i.slice(r),f=i.slice(0,r+1),m=l.concat(d).concat(f).concat(p),x=a;break}if(r>=0)break;v[h]=!0}if(r>=0)break}}return m}(t,e),v=Bl.triangulate(g,!1);for(a=0,s=v.length;a<s;a++)for(u=v[a],c=0;c<3;c++)void 0!==(l=p[h=u[c].x+":"+u[c].y])&&(u[c]=l);return v.concat()},isClockWise:function(t){return Bl.area(t)<0}};ri.prototype=Object.create(wt.prototype),ri.prototype.constructor=ri,ni.prototype=Object.create(Ct.prototype),ni.prototype.constructor=ni,ni.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],i=this.getAttribute("uv"),r=i?Array.prototype.slice.call(i.array):[],n=this.index;return{position:e,uv:r,index:n?Array.prototype.slice.call(n.array):[]}},ni.prototype.addShapeList=function(t,e){var i=this,r=t.length;e.arrays=this.getArrays();for(var n=0;n<r;n++){var o=t[n];i.addShape(o,e)}this.setIndex(e.arrays.index),this.addAttribute("position",new Pt(e.arrays.position,3)),this.addAttribute("uv",new Pt(e.arrays.uv,2))},ni.prototype.addShape=function(t,e){function i(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}function r(t,e,i){var r,n,o,a=t.x-e.x,s=t.y-e.y,c=i.x-t.x,u=i.y-t.y,h=a*a+s*s,p=a*u-s*c;if(Math.abs(p)>Number.EPSILON){var d=Math.sqrt(h),f=Math.sqrt(c*c+u*u),m=e.x-s/d,g=e.y+a/d,v=((i.x-u/f-m)*u-(i.y+c/f-g)*c)/(a*u-s*c),y=(r=m+a*v-t.x)*r+(n=g+s*v-t.y)*n;if(y<=2)return new l(r,n);o=Math.sqrt(y/2)}else{var b=!1;a>Number.EPSILON?c>Number.EPSILON&&(b=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(b=!0):Math.sign(s)===Math.sign(u)&&(b=!0),b?(r=-s,n=a,o=Math.sqrt(h)):(r=a,n=s,o=Math.sqrt(h/2))}return new l(r/o,n/o)}function n(t,e){var i,r;for(Z=t.length;--Z>=0;){i=Z,(r=Z-1)<0&&(r=t.length-1);var n=0,o=E+2*M;for(n=0;n<o;n++){var a=X*n,c=X*(n+1);s(e+i+a,e+r+a,e+r+c,e+i+c,t,n,o,i,r)}}}function o(t,e,i){_.push(t),_.push(e),_.push(i)}function a(t,e,i){c(t),c(e),c(i);var r=y.length/3,n=R.generateTopUV(N,y,r-3,r-2,r-1);u(n[0]),u(n[1]),u(n[2])}function s(t,e,i,r,n,o,a,s,h){c(t),c(e),c(r),c(e),c(i),c(r);var l=y.length/3,p=R.generateSideWallUV(N,y,l-6,l-3,l-2,l-1);u(p[0]),u(p[1]),u(p[3]),u(p[1]),u(p[2]),u(p[3])}function c(t){b.push(y.length/3),y.push(_[3*t+0]),y.push(_[3*t+1]),y.push(_[3*t+2])}function u(t){x.push(t.x),x.push(t.y)}var h,p,d,f,m,v=e.arrays?e.arrays:this.getArrays(),y=v.position,b=v.index,x=v.uv,_=[],w=void 0!==e.amount?e.amount:100,S=void 0!==e.bevelThickness?e.bevelThickness:6,A=void 0!==e.bevelSize?e.bevelSize:S-2,M=void 0!==e.bevelSegments?e.bevelSegments:3,P=void 0===e.bevelEnabled||e.bevelEnabled,T=void 0!==e.curveSegments?e.curveSegments:12,E=void 0!==e.steps?e.steps:1,C=e.extrudePath,I=!1,R=void 0!==e.UVGenerator?e.UVGenerator:ri.WorldUVGenerator;C&&(h=C.getSpacedPoints(E),I=!0,P=!1,p=void 0!==e.frames?e.frames:C.computeFrenetFrames(E,!1),d=new g,f=new g,m=new g),P||(M=0,S=0,A=0);var L,O,D,N=this,k=t.extractPoints(T),F=k.shape,B=k.holes;if(!Bl.isClockWise(F))for(F=F.reverse(),O=0,D=B.length;O<D;O++)L=B[O],Bl.isClockWise(L)&&(B[O]=L.reverse());var z=Bl.triangulateShape(F,B),U=F;for(O=0,D=B.length;O<D;O++)L=B[O],F=F.concat(L);for(var j,G,V,$,H,W,X=F.length,q=z.length,Y=[],Z=0,K=U.length,Q=K-1,J=Z+1;Z<K;Z++,Q++,J++)Q===K&&(Q=0),J===K&&(J=0),Y[Z]=r(U[Z],U[Q],U[J]);var tt,et=[],it=Y.concat();for(O=0,D=B.length;O<D;O++){for(L=B[O],tt=[],Z=0,Q=(K=L.length)-1,J=Z+1;Z<K;Z++,Q++,J++)Q===K&&(Q=0),J===K&&(J=0),tt[Z]=r(L[Z],L[Q],L[J]);et.push(tt),it=it.concat(tt)}for(j=0;j<M;j++){for(V=j/M,$=S*Math.cos(V*Math.PI/2),G=A*Math.sin(V*Math.PI/2),Z=0,K=U.length;Z<K;Z++)o((H=i(U[Z],Y[Z],G)).x,H.y,-$);for(O=0,D=B.length;O<D;O++)for(L=B[O],tt=et[O],Z=0,K=L.length;Z<K;Z++)o((H=i(L[Z],tt[Z],G)).x,H.y,-$)}for(G=A,Z=0;Z<X;Z++)H=P?i(F[Z],it[Z],G):F[Z],I?(f.copy(p.normals[0]).multiplyScalar(H.x),d.copy(p.binormals[0]).multiplyScalar(H.y),m.copy(h[0]).add(f).add(d),o(m.x,m.y,m.z)):o(H.x,H.y,0);var rt;for(rt=1;rt<=E;rt++)for(Z=0;Z<X;Z++)H=P?i(F[Z],it[Z],G):F[Z],I?(f.copy(p.normals[rt]).multiplyScalar(H.x),d.copy(p.binormals[rt]).multiplyScalar(H.y),m.copy(h[rt]).add(f).add(d),o(m.x,m.y,m.z)):o(H.x,H.y,w/E*rt);for(j=M-1;j>=0;j--){for(V=j/M,$=S*Math.cos(V*Math.PI/2),G=A*Math.sin(V*Math.PI/2),Z=0,K=U.length;Z<K;Z++)o((H=i(U[Z],Y[Z],G)).x,H.y,w+$);for(O=0,D=B.length;O<D;O++)for(L=B[O],tt=et[O],Z=0,K=L.length;Z<K;Z++)H=i(L[Z],tt[Z],G),I?o(H.x,H.y+h[E-1].y,h[E-1].x+$):o(H.x,H.y,w+$)}!function(){var t=y.length/3;if(P){var i=0,r=X*i;for(Z=0;Z<q;Z++)a((W=z[Z])[2]+r,W[1]+r,W[0]+r);for(r=X*(i=E+2*M),Z=0;Z<q;Z++)a((W=z[Z])[0]+r,W[1]+r,W[2]+r)}else{for(Z=0;Z<q;Z++)a((W=z[Z])[2],W[1],W[0]);for(Z=0;Z<q;Z++)a((W=z[Z])[0]+X*E,W[1]+X*E,W[2]+X*E)}N.addGroup(t,y.length/3-t,void 0!==e.material?e.material:0)}(),function(){var t=y.length/3,i=0;for(n(U,i),i+=U.length,O=0,D=B.length;O<D;O++)n(L=B[O],i),i+=L.length;N.addGroup(t,y.length/3-t,void 0!==e.extrudeMaterial?e.extrudeMaterial:1)}(),e.arrays||(this.setIndex(b),this.addAttribute("position",new Pt(y,3)),this.addAttribute("uv",new Pt(e.arrays.uv,2)))},ri.WorldUVGenerator={generateTopUV:function(t,e,i,r,n){var o=e[3*i],a=e[3*i+1],s=e[3*r],c=e[3*r+1],u=e[3*n],h=e[3*n+1];return[new l(o,a),new l(s,c),new l(u,h)]},generateSideWallUV:function(t,e,i,r,n,o){var a=e[3*i],s=e[3*i+1],c=e[3*i+2],u=e[3*r],h=e[3*r+1],p=e[3*r+2],d=e[3*n],f=e[3*n+1],m=e[3*n+2],g=e[3*o],v=e[3*o+1],y=e[3*o+2];return Math.abs(s-h)<.01?[new l(a,1-c),new l(u,1-p),new l(d,1-m),new l(g,1-y)]:[new l(s,1-c),new l(h,1-p),new l(f,1-m),new l(v,1-y)]}},oi.prototype=Object.create(wt.prototype),oi.prototype.constructor=oi,ai.prototype=Object.create(ni.prototype),ai.prototype.constructor=ai,si.prototype=Object.create(wt.prototype),si.prototype.constructor=si,ci.prototype=Object.create(Ct.prototype),ci.prototype.constructor=ci,ui.prototype=Object.create(wt.prototype),ui.prototype.constructor=ui,hi.prototype=Object.create(Ct.prototype),hi.prototype.constructor=hi,li.prototype=Object.create(wt.prototype),li.prototype.constructor=li,pi.prototype=Object.create(Ct.prototype),pi.prototype.constructor=pi,di.prototype=Object.create(wt.prototype),di.prototype.constructor=di,fi.prototype=Object.create(Ct.prototype),fi.prototype.constructor=fi,mi.prototype=Object.create(Ct.prototype),mi.prototype.constructor=mi,gi.prototype=Object.create(wt.prototype),gi.prototype.constructor=gi,vi.prototype=Object.create(Ct.prototype),vi.prototype.constructor=vi,yi.prototype=Object.create(gi.prototype),yi.prototype.constructor=yi,bi.prototype=Object.create(vi.prototype),bi.prototype.constructor=bi,xi.prototype=Object.create(wt.prototype),xi.prototype.constructor=xi,_i.prototype=Object.create(Ct.prototype),_i.prototype.constructor=_i;var zl=Object.freeze({WireframeGeometry:Be,ParametricGeometry:ze,ParametricBufferGeometry:Ue,TetrahedronGeometry:Ve,TetrahedronBufferGeometry:$e,OctahedronGeometry:He,OctahedronBufferGeometry:We,IcosahedronGeometry:Xe,IcosahedronBufferGeometry:qe,DodecahedronGeometry:Ye,DodecahedronBufferGeometry:Ze,PolyhedronGeometry:je,PolyhedronBufferGeometry:Ge,TubeGeometry:Ke,TubeBufferGeometry:Qe,TorusKnotGeometry:Je,TorusKnotBufferGeometry:ti,TorusGeometry:ei,TorusBufferGeometry:ii,TextGeometry:oi,TextBufferGeometry:ai,SphereGeometry:si,SphereBufferGeometry:ci,RingGeometry:ui,RingBufferGeometry:hi,PlaneGeometry:Lt,PlaneBufferGeometry:Ot,LatheGeometry:li,LatheBufferGeometry:pi,ShapeGeometry:di,ShapeBufferGeometry:fi,ExtrudeGeometry:ri,ExtrudeBufferGeometry:ni,EdgesGeometry:mi,ConeGeometry:yi,ConeBufferGeometry:bi,CylinderGeometry:gi,CylinderBufferGeometry:vi,CircleGeometry:xi,CircleBufferGeometry:_i,BoxGeometry:It,BoxBufferGeometry:Rt});wi.prototype=Object.create(ot.prototype),wi.prototype.constructor=wi,wi.prototype.isShadowMaterial=!0,Si.prototype=Object.create(ot.prototype),Si.prototype.constructor=Si,Si.prototype.isRawShaderMaterial=!0,Ai.prototype=Object.create(nt.prototype),Ai.prototype.constructor=Ai,Ai.prototype.isMeshStandardMaterial=!0,Ai.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Mi.prototype=Object.create(Ai.prototype),Mi.prototype.constructor=Mi,Mi.prototype.isMeshPhysicalMaterial=!0,Mi.prototype.copy=function(t){return Ai.prototype.copy.call(this,t),this.defines={PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearCoat=t.clearCoat,this.clearCoatRoughness=t.clearCoatRoughness,this},Pi.prototype=Object.create(nt.prototype),Pi.prototype.constructor=Pi,Pi.prototype.isMeshPhongMaterial=!0,Pi.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ti.prototype=Object.create(Pi.prototype),Ti.prototype.constructor=Ti,Ti.prototype.isMeshToonMaterial=!0,Ti.prototype.copy=function(t){return Pi.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Ei.prototype=Object.create(nt.prototype),Ei.prototype.constructor=Ei,Ei.prototype.isMeshNormalMaterial=!0,Ei.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ci.prototype=Object.create(nt.prototype),Ci.prototype.constructor=Ci,Ci.prototype.isMeshLambertMaterial=!0,Ci.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Ii.prototype=Object.create(nt.prototype),Ii.prototype.constructor=Ii,Ii.prototype.isLineDashedMaterial=!0,Ii.prototype.copy=function(t){return nt.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Ul=Object.freeze({ShadowMaterial:wi,SpriteMaterial:Se,RawShaderMaterial:Si,ShaderMaterial:ot,PointsMaterial:Oe,MeshPhysicalMaterial:Mi,MeshStandardMaterial:Ai,MeshPhongMaterial:Pi,MeshToonMaterial:Ti,MeshNormalMaterial:Ei,MeshLambertMaterial:Ci,MeshDepthMaterial:at,MeshBasicMaterial:Dt,LineDashedMaterial:Ii,LineBasicMaterial:Ce,Material:nt}),jl={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}},Gl=new Ri;Object.assign(Li.prototype,{load:function(t,e,i,r){var n=this;void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var o=this,a=jl.get(t);if(void 0!==a)return o.manager.itemStart(t),setTimeout(function(){e&&e(a),o.manager.itemEnd(t)},0),a;var s=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(s){var c=s[1],u=!!s[2],h=s[3];h=window.decodeURIComponent(h),u&&(h=window.atob(h));try{var l,p=(this.responseType||"").toLowerCase();switch(p){case"arraybuffer":case"blob":l=new ArrayBuffer(h.length);for(var d=new Uint8Array(l),f=0;f<h.length;f++)d[f]=h.charCodeAt(f);"blob"===p&&(l=new Blob([l],{type:c}));break;case"document":var m=new DOMParser;l=m.parseFromString(h,c);break;case"json":l=JSON.parse(h);break;default:l=h}window.setTimeout(function(){e&&e(l),o.manager.itemEnd(t)},0)}catch(e){window.setTimeout(function(){r&&r(e),o.manager.itemEnd(t),o.manager.itemError(t)},0)}}else{var g=new XMLHttpRequest;g.open("GET",t,!0),g.addEventListener("load",function(i){var n=i.target.response;jl.add(t,n),200===this.status?(e&&e(n),o.manager.itemEnd(t)):0===this.status?(console.warn("THREE.FileLoader: HTTP Status 0 received."),e&&e(n),o.manager.itemEnd(t)):(r&&r(i),o.manager.itemEnd(t),o.manager.itemError(t))},!1),void 0!==i&&g.addEventListener("progress",function(t){i(t)},!1),g.addEventListener("error",function(e){r&&r(e),o.manager.itemEnd(t),o.manager.itemError(t)},!1),void 0!==this.responseType&&(g.responseType=this.responseType),void 0!==this.withCredentials&&(g.withCredentials=this.withCredentials),g.overrideMimeType&&g.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(var v in n.requestHeader)g.setRequestHeader(v,n.requestHeader[v]);g.send(null)}return o.manager.itemStart(t),g},setPath:function(t){return this.path=t,this},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),Object.assign(Oi.prototype,{load:function(t,e,i,r){var n=this,o=[],a=new ke;a.image=o;var s=new Li(this.manager);if(s.setPath(this.path),s.setResponseType("arraybuffer"),Array.isArray(t))for(var c=0,u=0,h=t.length;u<h;++u)!function(u){s.load(t[u],function(t){var i=n._parser(t,!0);o[u]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},6===(c+=1)&&(1===i.mipmapCount&&(a.minFilter=Ch),a.format=i.format,a.needsUpdate=!0,e&&e(a))},i,r)}(u);else s.load(t,function(t){var i=n._parser(t,!0);if(i.isCubemap)for(var r=i.mipmaps.length/i.mipmapCount,s=0;s<r;s++){o[s]={mipmaps:[]};for(var c=0;c<i.mipmapCount;c++)o[s].mipmaps.push(i.mipmaps[s*i.mipmapCount+c]),o[s].format=i.format,o[s].width=i.width,o[s].height=i.height}else a.image.width=i.width,a.image.height=i.height,a.mipmaps=i.mipmaps;1===i.mipmapCount&&(a.minFilter=Ch),a.format=i.format,a.needsUpdate=!0,e&&e(a)},i,r);return a},setPath:function(t){return this.path=t,this}}),Object.assign(Di.prototype,{load:function(t,e,i,r){var n=this,o=new y,a=new Li(this.manager);return a.setResponseType("arraybuffer"),a.load(t,function(t){var i=n._parser(t);i&&(void 0!==i.image?o.image=i.image:void 0!==i.data&&(o.image.width=i.width,o.image.height=i.height,o.image.data=i.data),o.wrapS=void 0!==i.wrapS?i.wrapS:Ah,o.wrapT=void 0!==i.wrapT?i.wrapT:Ah,o.magFilter=void 0!==i.magFilter?i.magFilter:Ch,o.minFilter=void 0!==i.minFilter?i.minFilter:Rh,o.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.format&&(o.format=i.format),void 0!==i.type&&(o.type=i.type),void 0!==i.mipmaps&&(o.mipmaps=i.mipmaps),1===i.mipmapCount&&(o.minFilter=Ch),o.needsUpdate=!0,e&&e(o,i))},i,r),o}}),Object.assign(Ni.prototype,{load:function(t,e,i,r){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var n=this,o=jl.get(t);if(void 0!==o)return n.manager.itemStart(t),setTimeout(function(){e&&e(o),n.manager.itemEnd(t)},0),o;var a=document.createElementNS("http://www.w3.org/1999/xhtml","img");return a.addEventListener("load",function(){jl.add(t,this),e&&e(this),n.manager.itemEnd(t)},!1),a.addEventListener("error",function(e){r&&r(e),n.manager.itemEnd(t),n.manager.itemError(t)},!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),n.manager.itemStart(t),a.src=t,a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(ki.prototype,{load:function(t,e,i,r){var n=new b,o=new Ni(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);for(var a=0,s=0;s<t.length;++s)!function(i){o.load(t[i],function(t){n.images[i]=t,6==++a&&(n.needsUpdate=!0,e&&e(n))},void 0,r)}(s);return n},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Fi.prototype,{load:function(t,e,i,r){var n=new Ni(this.manager);n.setCrossOrigin(this.crossOrigin),n.setPath(this.path);var o=new p;return o.image=n.load(t,function(){var i=t.search(/\.(jpg|jpeg)$/)>0||0===t.search(/^data\:image\/jpeg/);o.format=i?Hh:Wh,o.needsUpdate=!0,void 0!==e&&e(o)},i,r),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Bi.prototype=Object.assign(Object.create(gt.prototype),{constructor:Bi,isLight:!0,copy:function(t){return gt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=gt.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),zi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:zi,isHemisphereLight:!0,copy:function(t){return Bi.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Ui.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),ji.prototype=Object.assign(Object.create(Ui.prototype),{constructor:ji,isSpotLightShadow:!0,update:function(t){var e=this.camera,i=2*xl.RAD2DEG*t.angle,r=this.mapSize.width/this.mapSize.height,n=t.distance||e.far;i===e.fov&&r===e.aspect&&n===e.far||(e.fov=i,e.aspect=r,e.far=n,e.updateProjectionMatrix())}}),Gi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Gi,isSpotLight:!0,copy:function(t){return Bi.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Vi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Vi,isPointLight:!0,copy:function(t){return Bi.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),$i.prototype=Object.assign(Object.create(Ui.prototype),{constructor:$i}),Hi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Hi,isDirectionalLight:!0,copy:function(t){return Bi.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Wi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Wi,isAmbientLight:!0}),Xi.prototype=Object.assign(Object.create(Bi.prototype),{constructor:Xi,isRectAreaLight:!0,copy:function(t){return Bi.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Bi.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var Vl={arraySlice:function(t,e,i){return Vl.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){function e(e,i){return t[e]-t[i]}for(var i=t.length,r=new Array(i),n=0;n!==i;++n)r[n]=n;return r.sort(e),r},sortedArray:function(t,e,i){for(var r=t.length,n=new t.constructor(r),o=0,a=0;a!==r;++o)for(var s=i[o]*e,c=0;c!==e;++c)n[a++]=t[s+c];return n},flattenJSON:function(t,e,i,r){for(var n=1,o=t[0];void 0!==o&&void 0===o[r];)o=t[n++];if(void 0!==o){var a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(e.push(o.time),i.push.apply(i,a)),o=t[n++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(e.push(o.time),a.toArray(i,i.length)),o=t[n++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(e.push(o.time),i.push(a)),o=t[n++]}while(void 0!==o)}}};Object.assign(qi.prototype,{evaluate:function(t){var e=this,i=this.parameterPositions,r=this._cachedIndex,n=i[r],o=i[r-1];t:{e:{var a;i:{r:if(!(t<n)){for(c=r+2;;){if(void 0===n){if(t<o)break r;return r=i.length,e._cachedIndex=r,e.afterEnd_(r-1,t,o)}if(r===c)break;if(o=n,n=i[++r],t<n)break e}a=i.length;break i}{if(t>=o)break t;var s=i[1];t<s&&(r=2,o=s);for(var c=r-2;;){if(void 0===o)return e._cachedIndex=0,e.beforeStart_(0,t,n);if(r===c)break;if(n=o,o=i[--r-1],t>=o)break e}a=r,r=0}}for(;r<a;){var u=r+a>>>1;t<i[u]?a=u:r=u+1}if(n=i[r],void 0===(o=i[r-1]))return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return r=i.length,this._cachedIndex=r,this.afterEnd_(r-1,o,t)}this._cachedIndex=r,this.intervalChanged_(r,o,n)}return this.interpolate_(r,o,t,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=t*r,o=0;o!==r;++o)e[o]=i[n+o];return e},interpolate_:function(t,e,i,r){throw new Error("call to abstract method")},intervalChanged_:function(t,e,i){}}),Object.assign(qi.prototype,{beforeStart_:qi.prototype.copySampleValue_,afterEnd_:qi.prototype.copySampleValue_}),Yi.prototype=Object.assign(Object.create(qi.prototype),{constructor:Yi,DefaultSettings_:{endingStart:sl,endingEnd:sl},intervalChanged_:function(t,e,i){var r=this.parameterPositions,n=t-2,o=t+1,a=r[n],s=r[o];if(void 0===a)switch(this.getSettings_().endingStart){case 2401:n=t,a=2*e-i;break;case 2402:a=e+r[n=r.length-2]-r[n+1];break;default:n=t,a=i}if(void 0===s)switch(this.getSettings_().endingEnd){case 2401:o=t,s=2*i-e;break;case 2402:o=1,s=i+r[1]-r[0];break;default:o=t-1,s=e}var c=.5*(i-e),u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(s-i),this._offsetPrev=n*u,this._offsetNext=o*u},interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,u=this._offsetPrev,h=this._offsetNext,l=this._weightPrev,p=this._weightNext,d=(i-e)/(r-e),f=d*d,m=f*d,g=-l*m+2*l*f-l*d,v=(1+l)*m+(-1.5-2*l)*f+(-.5+l)*d+1,y=(-1-p)*m+(1.5+p)*f+.5*d,b=p*m-p*f,x=0;x!==a;++x)n[x]=g*o[u+x]+v*o[c+x]+y*o[s+x]+b*o[h+x];return n}}),Zi.prototype=Object.assign(Object.create(qi.prototype),{constructor:Zi,interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,u=(i-e)/(r-e),h=1-u,l=0;l!==a;++l)n[l]=o[c+l]*h+o[s+l]*u;return n}}),Ki.prototype=Object.assign(Object.create(qi.prototype),{constructor:Ki,interpolate_:function(t,e,i,r){return this.copySampleValue_(t-1)}});var $l;$l={TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(t){return new Ki(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new Zi(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Yi(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}return void console.warn("THREE.KeyframeTrackPrototype:",i)}this.createInterpolant=e},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,i=0,r=e.length;i!==r;++i)e[i]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,i=0,r=e.length;i!==r;++i)e[i]*=t;return this},trim:function(t,e){for(var i=this.times,r=i.length,n=0,o=r-1;n!==r&&i[n]<t;)++n;for(;-1!==o&&i[o]>e;)--o;if(++o,0!==n||o!==r){n>=o&&(n=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=Vl.arraySlice(i,n,o),this.values=Vl.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var t=this,e=!0,i=this.getValueSize();i-Math.floor(i)!=0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),e=!1);var r=this.times,n=this.values,o=r.length;0===o&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),e=!1);for(var a=null,s=0;s!==o;s++){var c=r[s];if("number"==typeof c&&isNaN(c)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",t,s,c),e=!1;break}if(null!==a&&a>c){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",t,s,c,a),e=!1;break}a=c}if(void 0!==n&&Vl.isTypedArray(n))for(var s=0,u=n.length;s!==u;++s){var h=n[s];if(isNaN(h)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",t,s,h),e=!1;break}}return e},optimize:function(){for(var t=this.times,e=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,o=t.length-1,a=1;a<o;++a){var s=!1,c=t[a];if(c!==t[a+1]&&(1!==a||c!==c[0]))if(r)s=!0;else for(var u=a*i,h=u-i,l=u+i,p=0;p!==i;++p){var d=e[u+p];if(d!==e[h+p]||d!==e[l+p]){s=!0;break}}if(s){if(a!==n){t[n]=t[a];for(var f=a*i,m=n*i,p=0;p!==i;++p)e[m+p]=e[f+p]}++n}}if(o>0){t[n]=t[o];for(var f=o*i,m=n*i,p=0;p!==i;++p)e[m+p]=e[f+p];++n}return n!==t.length&&(this.times=Vl.arraySlice(t,0,n),this.values=Vl.arraySlice(e,0,n*i)),this}},Ji.prototype=Object.assign(Object.create($l),{constructor:Ji,ValueTypeName:"vector"}),tr.prototype=Object.assign(Object.create(qi.prototype),{constructor:tr,interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(i-e)/(r-e),u=s+a;s!==u;s+=4)m.slerpFlat(n,0,o,s-a,o,s,c);return n}}),er.prototype=Object.assign(Object.create($l),{constructor:er,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new tr(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),ir.prototype=Object.assign(Object.create($l),{constructor:ir,ValueTypeName:"number"}),rr.prototype=Object.assign(Object.create($l),{constructor:rr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),nr.prototype=Object.assign(Object.create($l),{constructor:nr,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),or.prototype=Object.assign(Object.create($l),{constructor:or,ValueTypeName:"color"}),ar.prototype=$l,$l.constructor=ar,Object.assign(ar,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=ar._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var i=[],r=[];Vl.flattenJSON(t.keys,i,r,"value"),t.times=i,t.values=r}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,i=t.constructor;if(void 0!==i.toJSON)e=i.toJSON(t);else{e={name:t.name,times:Vl.convertArray(t.times,Array),values:Vl.convertArray(t.values,Array)};var r=t.getInterpolation();r!==t.DefaultInterpolation&&(e.interpolation=r)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ir;case"vector":case"vector2":case"vector3":case"vector4":return Ji;case"color":return or;case"quaternion":return er;case"bool":case"boolean":return nr;case"string":return rr}throw new Error("Unsupported typeName: "+t)}}),Object.assign(sr,{parse:function(t){for(var e=[],i=t.tracks,r=1/(t.fps||1),n=0,o=i.length;n!==o;++n)e.push(ar.parse(i[n]).scale(r));return new sr(t.name,t.duration,e)},toJSON:function(t){for(var e=[],i=t.tracks,r={name:t.name,duration:t.duration,tracks:e},n=0,o=i.length;n!==o;++n)e.push(ar.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(t,e,i,r){for(var n=e.length,o=[],a=0;a<n;a++){var s=[],c=[];s.push((a+n-1)%n,a,(a+1)%n),c.push(0,1,0);var u=Vl.getKeyframeOrder(s);s=Vl.sortedArray(s,1,u),c=Vl.sortedArray(c,1,u),r||0!==s[0]||(s.push(n),c.push(c[0])),o.push(new ir(".morphTargetInfluences["+e[a].name+"]",s,c).scale(1/i))}return new sr(t,-1,o)},findByName:function(t,e){var i=t;if(!Array.isArray(t)){var r=t;i=r.geometry&&r.geometry.animations||r.animations}for(var n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null},CreateClipsFromMorphTargetSequences:function(t,e,i){for(var r={},n=0,o=t.length;n<o;n++){var a=t[n],s=a.name.match(/^([\w-]*?)([\d]+)$/);if(s&&s.length>1){var c=r[h=s[1]];c||(r[h]=c=[]),c.push(a)}}var u=[];for(var h in r)u.push(sr.CreateFromMorphTargetSequence(h,r[h],e,i));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(t,e,i,r,n){if(0!==i.length){var o=[],a=[];Vl.flattenJSON(i,o,a,r),0!==o.length&&n.push(new t(e,o,a))}},r=[],n=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c<s.length;c++){var u=s[c].keys;if(u&&0!==u.length)if(u[0].morphTargets){for(var h={},l=0;l<u.length;l++)if(u[l].morphTargets)for(m=0;m<u[l].morphTargets.length;m++)h[u[l].morphTargets[m]]=-1;for(var p in h){for(var d=[],f=[],m=0;m!==u[l].morphTargets.length;++m){var g=u[l];d.push(g.time),f.push(g.morphTarget===p?1:0)}r.push(new ir(".morphTargetInfluence["+p+"]",d,f))}o=h.length*(a||1)}else{var v=".bones["+e[c].name+"]";i(Ji,v+".position",u,"pos",r),i(er,v+".quaternion",u,"rot",r),i(Ji,v+".scale",u,"scl",r)}}return 0===r.length?null:new sr(n,o,r)}}),Object.assign(sr.prototype,{resetDuration:function(){for(var t=this,e=0,i=0,r=this.tracks.length;i!==r;++i){var n=t.tracks[i];e=Math.max(e,n.times[n.times.length-1])}this.duration=e},trim:function(){for(var t=this,e=0;e<this.tracks.length;e++)t.tracks[e].trim(0,t.duration);return this},optimize:function(){for(var t=this,e=0;e<this.tracks.length;e++)t.tracks[e].optimize();return this}}),Object.assign(cr.prototype,{load:function(t,e,i,r){var n=this;new Li(n.manager).load(t,function(t){e(n.parse(JSON.parse(t)))},i,r)},setTextures:function(t){this.textures=t},parse:function(t){function e(t){return void 0===i[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),i[t]}var i=this.textures,r=new Ul[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&r.specular.setHex(t.specular),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearCoat&&(r.clearCoat=t.clearCoat),void 0!==t.clearCoatRoughness&&(r.clearCoatRoughness=t.clearCoatRoughness),void 0!==t.uniforms&&(r.uniforms=t.uniforms),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.vertexColors&&(r.vertexColors=t.vertexColors),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.shading&&(r.shading=t.shading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.side&&(r.side=t.side),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.skinning&&(r.skinning=t.skinning),void 0!==t.morphTargets&&(r.morphTargets=t.morphTargets),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=e(t.map)),void 0!==t.alphaMap&&(r.alphaMap=e(t.alphaMap),r.transparent=!0),void 0!==t.bumpMap&&(r.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=e(t.normalMap)),void 0!==t.normalScale){var n=t.normalScale;!1===Array.isArray(n)&&(n=[n,n]),r.normalScale=(new l).fromArray(n)}return void 0!==t.displacementMap&&(r.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=e(t.specularMap)),void 0!==t.envMap&&(r.envMap=e(t.envMap)),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.lightMap&&(r.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=e(t.gradientMap)),r}}),Object.assign(ur.prototype,{load:function(t,e,i,r){var n=this;new Li(n.manager).load(t,function(t){e(n.parse(JSON.parse(t)))},i,r)},parse:function(t){var e=new Ct,i=t.data.index;if(void 0!==i){a=new Hl[i.type](i.array);e.setIndex(new St(a,1))}var r=t.data.attributes;for(var n in r){var o=r[n],a=new Hl[o.type](o.array);e.addAttribute(n,new St(a,o.itemSize,o.normalized))}var s=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==s)for(var c=0,u=s.length;c!==u;++c){var h=s[c];e.addGroup(h.start,h.count,h.materialIndex)}var l=t.data.boundingSphere;if(void 0!==l){var p=new g;void 0!==l.center&&p.fromArray(l.center),e.boundingSphere=new ct(p,l.radius)}return e}});var Hl={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};hr.Handlers={handlers:[],add:function(t,e){this.handlers.push(t,e)},get:function(t){for(var e=this.handlers,i=0,r=e.length;i<r;i+=2){var n=e[i],o=e[i+1];if(n.test(t))return o}return null}},Object.assign(hr.prototype,{crossOrigin:void 0,extractUrlBase:function(t){var e=t.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},initMaterials:function(t,e,i){for(var r=this,n=[],o=0;o<t.length;++o)n[o]=r.createMaterial(t[o],e,i);return n},createMaterial:function(){var t={NoBlending:Lu,NormalBlending:Ou,AdditiveBlending:Du,SubtractiveBlending:Nu,MultiplyBlending:ku,CustomBlending:Fu},e=new tt,i=new Fi,r=new cr;return function(n,o,a){function s(t,e,r,n,s){var u,h=o+t,l=hr.Handlers.get(h);null!==l?u=l.load(h):(i.setCrossOrigin(a),u=i.load(h)),void 0!==e&&(u.repeat.fromArray(e),1!==e[0]&&(u.wrapS=Sh),1!==e[1]&&(u.wrapT=Sh)),void 0!==r&&u.offset.fromArray(r),void 0!==n&&("repeat"===n[0]&&(u.wrapS=Sh),"mirror"===n[0]&&(u.wrapS=Mh),"repeat"===n[1]&&(u.wrapT=Sh),"mirror"===n[1]&&(u.wrapT=Mh)),void 0!==s&&(u.anisotropy=s);var p=xl.generateUUID();return c[p]=u,p}var c={},u={uuid:xl.generateUUID(),type:"MeshLambertMaterial"};for(var h in n){var l=n[h];switch(h){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":u.name=l;break;case"blending":u.blending=t[l];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",h,"is no longer supported.");break;case"colorDiffuse":u.color=e.fromArray(l).getHex();break;case"colorSpecular":u.specular=e.fromArray(l).getHex();break;case"colorEmissive":u.emissive=e.fromArray(l).getHex();break;case"specularCoef":u.shininess=l;break;case"shading":"basic"===l.toLowerCase()&&(u.type="MeshBasicMaterial"),"phong"===l.toLowerCase()&&(u.type="MeshPhongMaterial"),"standard"===l.toLowerCase()&&(u.type="MeshStandardMaterial");break;case"mapDiffuse":u.map=s(l,n.mapDiffuseRepeat,n.mapDiffuseOffset,n.mapDiffuseWrap,n.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":u.emissiveMap=s(l,n.mapEmissiveRepeat,n.mapEmissiveOffset,n.mapEmissiveWrap,n.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":u.lightMap=s(l,n.mapLightRepeat,n.mapLightOffset,n.mapLightWrap,n.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":u.aoMap=s(l,n.mapAORepeat,n.mapAOOffset,n.mapAOWrap,n.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":u.bumpMap=s(l,n.mapBumpRepeat,n.mapBumpOffset,n.mapBumpWrap,n.mapBumpAnisotropy);break;case"mapBumpScale":u.bumpScale=l;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":u.normalMap=s(l,n.mapNormalRepeat,n.mapNormalOffset,n.mapNormalWrap,n.mapNormalAnisotropy);break;case"mapNormalFactor":u.normalScale=[l,l];break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":u.specularMap=s(l,n.mapSpecularRepeat,n.mapSpecularOffset,n.mapSpecularWrap,n.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":u.metalnessMap=s(l,n.mapMetalnessRepeat,n.mapMetalnessOffset,n.mapMetalnessWrap,n.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":u.roughnessMap=s(l,n.mapRoughnessRepeat,n.mapRoughnessOffset,n.mapRoughnessWrap,n.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":u.alphaMap=s(l,n.mapAlphaRepeat,n.mapAlphaOffset,n.mapAlphaWrap,n.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":u.side=Mu;break;case"doubleSided":u.side=Pu;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),u.opacity=l;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":u[h]=l;break;case"vertexColors":!0===l&&(u.vertexColors=Ru),"face"===l&&(u.vertexColors=Iu);break;default:console.error("THREE.Loader.createMaterial: Unsupported",h,l)}}return"MeshBasicMaterial"===u.type&&delete u.emissive,"MeshPhongMaterial"!==u.type&&delete u.specular,u.opacity<1&&(u.transparent=!0),r.setTextures(c),r.parse(u)}}()}),Object.assign(lr.prototype,{load:function(t,e,i,r){var n=this,o=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:hr.prototype.extractUrlBase(t),a=new Li(this.manager);a.setWithCredentials(this.withCredentials),a.load(t,function(i){var r=JSON.parse(i),a=r.metadata;if(void 0!==a){var s=a.type;if(void 0!==s){if("object"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.ObjectLoader instead.");if("scene"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.SceneLoader instead.")}}var c=n.parse(r,o);e(c.geometry,c.materials)},i,r)},setTexturePath:function(t){this.texturePath=t},parse:function(){function t(t,e){function i(t,e){return t&1<<e}var r,n,o,a,s,c,u,h,p,d,f,m,v,y,b,x,_,w,S,A,M,P,T,E,C,I=t.faces,R=t.vertices,L=t.normals,O=t.colors,D=t.scale,N=0;if(void 0!==t.uvs){for(r=0;r<t.uvs.length;r++)t.uvs[r].length&&N++;for(r=0;r<N;r++)e.faceVertexUvs[r]=[]}for(a=0,s=R.length;a<s;)(w=new g).x=R[a++]*D,w.y=R[a++]*D,w.z=R[a++]*D,e.vertices.push(w);for(a=0,s=I.length;a<s;)if(d=I[a++],f=i(d,0),m=i(d,1),v=i(d,3),y=i(d,4),b=i(d,5),x=i(d,6),_=i(d,7),f){if(A=new xt,A.a=I[a],A.b=I[a+1],A.c=I[a+3],M=new xt,M.a=I[a+1],M.b=I[a+2],M.c=I[a+3],a+=4,m&&(p=I[a++],A.materialIndex=p,M.materialIndex=p),o=e.faces.length,v)for(r=0;r<N;r++)for(E=t.uvs[r],e.faceVertexUvs[r][o]=[],e.faceVertexUvs[r][o+1]=[],n=0;n<4;n++)C=new l(E[2*(h=I[a++])],E[2*h+1]),2!==n&&e.faceVertexUvs[r][o].push(C),0!==n&&e.faceVertexUvs[r][o+1].push(C);if(y&&(u=3*I[a++],A.normal.set(L[u++],L[u++],L[u]),M.normal.copy(A.normal)),b)for(r=0;r<4;r++)u=3*I[a++],T=new g(L[u++],L[u++],L[u]),2!==r&&A.vertexNormals.push(T),0!==r&&M.vertexNormals.push(T);if(x&&(P=O[c=I[a++]],A.color.setHex(P),M.color.setHex(P)),_)for(r=0;r<4;r++)P=O[c=I[a++]],2!==r&&A.vertexColors.push(new tt(P)),0!==r&&M.vertexColors.push(new tt(P));e.faces.push(A),e.faces.push(M)}else{if(S=new xt,S.a=I[a++],S.b=I[a++],S.c=I[a++],m&&(p=I[a++],S.materialIndex=p),o=e.faces.length,v)for(r=0;r<N;r++)for(E=t.uvs[r],e.faceVertexUvs[r][o]=[],n=0;n<3;n++)C=new l(E[2*(h=I[a++])],E[2*h+1]),e.faceVertexUvs[r][o].push(C);if(y&&(u=3*I[a++],S.normal.set(L[u++],L[u++],L[u])),b)for(r=0;r<3;r++)u=3*I[a++],T=new g(L[u++],L[u++],L[u]),S.vertexNormals.push(T);if(x&&(c=I[a++],S.color.setHex(O[c])),_)for(r=0;r<3;r++)c=I[a++],S.vertexColors.push(new tt(O[c]));e.faces.push(S)}}function e(t,e){var i=void 0!==t.influencesPerVertex?t.influencesPerVertex:2;if(t.skinWeights)for(var r=0,n=t.skinWeights.length;r<n;r+=i){var o=t.skinWeights[r],a=i>1?t.skinWeights[r+1]:0,s=i>2?t.skinWeights[r+2]:0,c=i>3?t.skinWeights[r+3]:0;e.skinWeights.push(new d(o,a,s,c))}if(t.skinIndices)for(var r=0,n=t.skinIndices.length;r<n;r+=i){var u=t.skinIndices[r],h=i>1?t.skinIndices[r+1]:0,l=i>2?t.skinIndices[r+2]:0,p=i>3?t.skinIndices[r+3]:0;e.skinIndices.push(new d(u,h,l,p))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}function i(t,e){var i=t.scale;if(void 0!==t.morphTargets)for(var r=0,n=t.morphTargets.length;r<n;r++){e.morphTargets[r]={},e.morphTargets[r].name=t.morphTargets[r].name,e.morphTargets[r].vertices=[];for(var o=e.morphTargets[r].vertices,a=t.morphTargets[r].vertices,s=0,c=a.length;s<c;s+=3){var u=new g;u.x=a[s]*i,u.y=a[s+1]*i,u.z=a[s+2]*i,o.push(u)}}if(void 0!==t.morphColors&&t.morphColors.length>0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=e.faces,l=t.morphColors[0].colors,r=0,n=h.length;r<n;r++)h[r].color.fromArray(l,3*r)}}function r(t,e){var i=[],r=[];void 0!==t.animation&&r.push(t.animation),void 0!==t.animations&&(t.animations.length?r=r.concat(t.animations):r.push(t.animations));for(var n=0;n<r.length;n++){var o=sr.parseAnimation(r[n],e.bones);o&&i.push(o)}if(e.morphTargets){var a=sr.CreateClipsFromMorphTargetSequences(e.morphTargets,10);i=i.concat(a)}i.length>0&&(e.animations=i)}return function(n,o){void 0!==n.data&&(n=n.data),void 0!==n.scale?n.scale=1/n.scale:n.scale=1;var a=new wt;return t(n,a),e(n,a),i(n,a),r(n,a),a.computeFaceNormals(),a.computeBoundingSphere(),void 0===n.materials||0===n.materials.length?{geometry:a}:{geometry:a,materials:hr.prototype.initMaterials(n.materials,o,this.crossOrigin)}}}()}),Object.assign(pr.prototype,{load:function(t,e,i,r){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var n=this;new Li(n.manager).load(t,function(i){var o=null;try{o=JSON.parse(i)}catch(e){return void 0!==r&&r(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.");n.parse(o,e)},i,r)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var i=this.parseGeometries(t.geometries),r=this.parseImages(t.images,function(){void 0!==e&&e(a)}),n=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,n),a=this.parseObject(t.object,i,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e=this,i={};if(void 0!==t)for(var r=new lr,n=new ur,o=0,a=t.length;o<a;o++){var s,c=t[o];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new zl[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new zl[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new zl[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new zl[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":s=new zl[c.type](c.radius,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new zl[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":case"IcosahedronGeometry":case"OctahedronGeometry":case"TetrahedronGeometry":s=new zl[c.type](c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new zl[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new zl[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new zl[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"LatheGeometry":case"LatheBufferGeometry":s=new zl[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"BufferGeometry":s=n.parse(c);break;case"Geometry":s=r.parse(c,e.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}s.uuid=c.uuid,void 0!==c.name&&(s.name=c.name),i[c.uuid]=s}return i},parseMaterials:function(t,e){var i={};if(void 0!==t){var r=new cr;r.setTextures(e);for(var n=0,o=t.length;n<o;n++){var a=t[n];if("MultiMaterial"===a.type){for(var s=[],c=0;c<a.materials.length;c++)s.push(r.parse(a.materials[c]));i[a.uuid]=s}else i[a.uuid]=r.parse(a)}}return i},parseAnimations:function(t){for(var e=[],i=0;i<t.length;i++){var r=sr.parse(t[i]);e.push(r)}return e},parseImages:function(t,e){var i=this,r={};if(void 0!==t&&t.length>0){var n=new Ni(new Ri(e));n.setCrossOrigin(this.crossOrigin);for(var o=0,a=t.length;o<a;o++){var s=t[o],c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(s.url)?s.url:i.texturePath+s.url;r[s.uuid]=function(t){return i.manager.itemStart(t),n.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemEnd(t),i.manager.itemError(t)})}(c)}}return r},parseTextures:function(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var r={};if(void 0!==t)for(var n=0,o=t.length;n<o;n++){var a=t[n];void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===e[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image);var s=new p(e[a.image]);s.needsUpdate=!0,s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.mapping&&(s.mapping=i(a.mapping,Wl)),void 0!==a.offset&&s.offset.fromArray(a.offset),void 0!==a.repeat&&s.repeat.fromArray(a.repeat),void 0!==a.wrap&&(s.wrapS=i(a.wrap[0],Xl),s.wrapT=i(a.wrap[1],Xl)),void 0!==a.minFilter&&(s.minFilter=i(a.minFilter,ql)),void 0!==a.magFilter&&(s.magFilter=i(a.magFilter,ql)),void 0!==a.anisotropy&&(s.anisotropy=a.anisotropy),void 0!==a.flipY&&(s.flipY=a.flipY),r[a.uuid]=s}return r},parseObject:function(){var t=new v;return function(e,i,r){function n(t){return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),i[t]}function o(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],i=0,n=t.length;i<n;i++){var o=t[i];void 0===r[o]&&console.warn("THREE.ObjectLoader: Undefined material",o),e.push(r[o])}return e}return void 0===r[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),r[t]}}var a,s=this;switch(e.type){case"Scene":a=new _e,void 0!==e.background&&Number.isInteger(e.background)&&(a.background=new tt(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new xe(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new be(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":a=new bt(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new yt(e.left,e.right,e.top,e.bottom,e.near,e.far);break;case"AmbientLight":a=new Wi(e.color,e.intensity);break;case"DirectionalLight":a=new Hi(e.color,e.intensity);break;case"PointLight":a=new Vi(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Xi(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Gi(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new zi(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var c=n(e.geometry),u=o(e.material);a=c.bones&&c.bones.length>0?new Ee(c,u):new Bt(c,u);break;case"LOD":a=new Me;break;case"Line":a=new Ie(n(e.geometry),o(e.material),e.mode);break;case"LineLoop":a=new Le(n(e.geometry),o(e.material));break;case"LineSegments":a=new Re(n(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new De(n(e.geometry),o(e.material));break;case"Sprite":a=new Ae(o(e.material));break;case"Group":a=new Ne;break;default:a=new gt}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var h in e.children)a.add(s.parseObject(e.children[h],i,r));if("LOD"===e.type)for(var l=e.levels,p=0;p<l.length;p++){var d=l[p];void 0!==(h=a.getObjectByProperty("uuid",d.object))&&a.addLevel(h,d.distance)}return a}}()});var Wl={UVMapping:300,CubeReflectionMapping:gh,CubeRefractionMapping:vh,EquirectangularReflectionMapping:yh,EquirectangularRefractionMapping:bh,SphericalReflectionMapping:xh,CubeUVReflectionMapping:_h,CubeUVRefractionMapping:wh},Xl={RepeatWrapping:Sh,ClampToEdgeWrapping:Ah,MirroredRepeatWrapping:Mh},ql={NearestFilter:Ph,NearestMipMapNearestFilter:Th,NearestMipMapLinearFilter:Eh,LinearFilter:Ch,LinearMipMapNearestFilter:Ih,LinearMipMapLinearFilter:Rh};Object.assign(Sr.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t){var e=this.getUtoTmapping(t);return this.getPoint(e)},getPoints:function(t){var e=this;void 0===t&&(t=5);for(var i=[],r=0;r<=t;r++)i.push(e.getPoint(r/t));return i},getSpacedPoints:function(t){var e=this;void 0===t&&(t=5);for(var i=[],r=0;r<=t;r++)i.push(e.getPointAt(r/t));return i},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){var e=this;if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var i,r,n=[],o=this.getPoint(0),a=0;for(n.push(0),r=1;r<=t;r++)a+=(i=e.getPoint(r/t)).distanceTo(o),n.push(a),o=i;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var i,r=this.getLengths(),n=0,o=r.length;i=e||t*r[o-1];for(var a,s=0,c=o-1;s<=c;)if(n=Math.floor(s+(c-s)/2),(a=r[n]-i)<0)s=n+1;else{if(!(a>0)){c=n;break}c=n-1}if(n=c,r[n]===i)return n/(o-1);var u=r[n];return(n+(i-u)/(r[n+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);var r=this.getPoint(e);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var i,r,n,o=this,a=new g,s=[],c=[],u=[],h=new g,l=new v;for(i=0;i<=t;i++)r=i/t,s[i]=o.getTangentAt(r),s[i].normalize();c[0]=new g,u[0]=new g;var p=Number.MAX_VALUE,d=Math.abs(s[0].x),f=Math.abs(s[0].y),m=Math.abs(s[0].z);for(d<=p&&(p=d,a.set(1,0,0)),f<=p&&(p=f,a.set(0,1,0)),m<=p&&a.set(0,0,1),h.crossVectors(s[0],a).normalize(),c[0].crossVectors(s[0],h),u[0].crossVectors(s[0],c[0]),i=1;i<=t;i++)c[i]=c[i-1].clone(),u[i]=u[i-1].clone(),h.crossVectors(s[i-1],s[i]),h.length()>Number.EPSILON&&(h.normalize(),n=Math.acos(xl.clamp(s[i-1].dot(s[i]),-1,1)),c[i].applyMatrix4(l.makeRotationAxis(h,n))),u[i].crossVectors(s[i],c[i]);if(!0===e)for(n=Math.acos(xl.clamp(c[0].dot(c[t]),-1,1)),n/=t,s[0].dot(h.crossVectors(c[0],c[t]))>0&&(n=-n),i=1;i<=t;i++)c[i].applyMatrix4(l.makeRotationAxis(s[i],n*i)),u[i].crossVectors(s[i],c[i]);return{tangents:s,normals:c,binormals:u}}}),Ar.prototype=Object.create(Sr.prototype),Ar.prototype.constructor=Ar,Ar.prototype.isLineCurve=!0,Ar.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},Ar.prototype.getPointAt=function(t){return this.getPoint(t)},Ar.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},Mr.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Mr,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new Ar(e,t))},getPoint:function(t){for(var e=this,i=t*this.getLength(),r=this.getCurveLengths(),n=0;n<r.length;){if(r[n]>=i){var o=r[n]-i,a=e.curves[n],s=a.getLength(),c=0===s?0:1-o/s;return a.getPointAt(c)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){var t=this;if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],i=0,r=0,n=this.curves.length;r<n;r++)i+=t.curves[r].getLength(),e.push(i);return this.cacheLengths=e,e},getSpacedPoints:function(t){var e=this;void 0===t&&(t=40);for(var i=[],r=0;r<=t;r++)i.push(e.getPoint(r/t));return this.autoClose&&i.push(i[0]),i},getPoints:function(t){t=t||12;for(var e,i=[],r=0,n=this.curves;r<n.length;r++)for(var o=n[r],a=o&&o.isEllipseCurve?2*t:o&&o.isLineCurve?1:o&&o.isSplineCurve?t*o.points.length:t,s=o.getPoints(a),c=0;c<s.length;c++){var u=s[c];e&&e.equals(u)||(i.push(u),e=u)}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new wt,i=0,r=t.length;i<r;i++){var n=t[i];e.vertices.push(new g(n.x,n.y,n.z||0))}return e}}),Pr.prototype=Object.create(Sr.prototype),Pr.prototype.constructor=Pr,Pr.prototype.isEllipseCurve=!0,Pr.prototype.getPoint=function(t){for(var e=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)<Number.EPSILON;i<0;)i+=e;for(;i>e;)i-=e;i<Number.EPSILON&&(i=r?0:e),!0!==this.aClockwise||r||(i===e?i=-e:i-=e);var n=this.aStartAngle+t*i,o=this.aX+this.xRadius*Math.cos(n),a=this.aY+this.yRadius*Math.sin(n);if(0!==this.aRotation){var s=Math.cos(this.aRotation),c=Math.sin(this.aRotation),u=o-this.aX,h=a-this.aY;o=u*s-h*c+this.aX,a=u*c+h*s+this.aY}return new l(o,a)},Tr.prototype=Object.create(Sr.prototype),Tr.prototype.constructor=Tr,Tr.prototype.isSplineCurve=!0,Tr.prototype.getPoint=function(t){var e=this.points,i=(e.length-1)*t,r=Math.floor(i),n=i-r,o=e[0===r?r:r-1],a=e[r],s=e[r>e.length-2?e.length-1:r+1],c=e[r>e.length-3?e.length-1:r+2];return new l(dr(n,o.x,a.x,s.x,c.x),dr(n,o.y,a.y,s.y,c.y))},Er.prototype=Object.create(Sr.prototype),Er.prototype.constructor=Er,Er.prototype.getPoint=function(t){var e=this.v0,i=this.v1,r=this.v2,n=this.v3;return new l(wr(t,e.x,i.x,r.x,n.x),wr(t,e.y,i.y,r.y,n.y))},Cr.prototype=Object.create(Sr.prototype),Cr.prototype.constructor=Cr,Cr.prototype.getPoint=function(t){var e=this.v0,i=this.v1,r=this.v2;return new l(vr(t,e.x,i.x,r.x),vr(t,e.y,i.y,r.y))};var Yl=Object.assign(Object.create(Mr.prototype),{fromPoints:function(t){var e=this;this.moveTo(t[0].x,t[0].y);for(var i=1,r=t.length;i<r;i++)e.lineTo(t[i].x,t[i].y)},moveTo:function(t,e){this.currentPoint.set(t,e)},lineTo:function(t,e){var i=new Ar(this.currentPoint.clone(),new l(t,e));this.curves.push(i),this.currentPoint.set(t,e)},quadraticCurveTo:function(t,e,i,r){var n=new Cr(this.currentPoint.clone(),new l(t,e),new l(i,r));this.curves.push(n),this.currentPoint.set(i,r)},bezierCurveTo:function(t,e,i,r,n,o){var a=new Er(this.currentPoint.clone(),new l(t,e),new l(i,r),new l(n,o));this.curves.push(a),this.currentPoint.set(n,o)},splineThru:function(t){var e=new Tr([this.currentPoint.clone()].concat(t));this.curves.push(e),this.currentPoint.copy(t[t.length-1])},arc:function(t,e,i,r,n,o){var a=this.currentPoint.x,s=this.currentPoint.y;this.absarc(t+a,e+s,i,r,n,o)},absarc:function(t,e,i,r,n,o){this.absellipse(t,e,i,i,r,n,o)},ellipse:function(t,e,i,r,n,o,a,s){var c=this.currentPoint.x,u=this.currentPoint.y;this.absellipse(t+c,e+u,i,r,n,o,a,s)},absellipse:function(t,e,i,r,n,o,a,s){var c=new Pr(t,e,i,r,n,o,a,s);if(this.curves.length>0){var u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)}});Ir.prototype=Yl,Yl.constructor=Ir,Rr.prototype=Object.assign(Object.create(Yl),{constructor:Rr,getPointsHoles:function(t){for(var e=this,i=[],r=0,n=this.holes.length;r<n;r++)i[r]=e.holes[r].getPoints(t);return i},extractAllPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},extractPoints:function(t){return this.extractAllPoints(t)}}),Object.assign(Lr.prototype,{moveTo:function(t,e){this.currentPath=new Ir,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e)},lineTo:function(t,e){this.currentPath.lineTo(t,e)},quadraticCurveTo:function(t,e,i,r){this.currentPath.quadraticCurveTo(t,e,i,r)},bezierCurveTo:function(t,e,i,r,n,o){this.currentPath.bezierCurveTo(t,e,i,r,n,o)},splineThru:function(t){this.currentPath.splineThru(t)},toShapes:function(t,e){function i(t){for(var e=[],i=0,r=t.length;i<r;i++){var n=t[i],o=new Rr;o.curves=n.curves,e.push(o)}return e}var r=Bl.isClockWise,n=this.subPaths;if(0===n.length)return[];if(!0===e)return i(n);var o,a,s,c=[];if(1===n.length)return a=n[0],s=new Rr,s.curves=a.curves,c.push(s),c;var u=!r(n[0].getPoints());u=t?!u:u;var h,l=[],p=[],d=[],f=0;p[f]=void 0,d[f]=[];for(var m=0,g=n.length;m<g;m++)o=r(h=(a=n[m]).getPoints()),(o=t?!o:o)?(!u&&p[f]&&f++,p[f]={s:new Rr,p:h},p[f].s.curves=a.curves,u&&f++,d[f]=[]):d[f].push({h:a,p:h[0]});if(!p[0])return i(n);if(p.length>1){for(var v=!1,y=[],b=0,x=p.length;b<x;b++)l[b]=[];for(var b=0,x=p.length;b<x;b++)for(var _=d[b],w=0;w<_.length;w++){for(var S=_[w],A=!0,M=0;M<p.length;M++)(function(t,e){for(var i=e.length,r=!1,n=i-1,o=0;o<i;n=o++){var a=e[n],s=e[o],c=s.x-a.x,u=s.y-a.y;if(Math.abs(u)>Number.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[n],u=-u),t.y<a.y||t.y>s.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var h=u*(t.x-a.x)-c*(t.y-a.y);if(0===h)return!0;if(h<0)continue;r=!r}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return r})(S.p,p[M].p)&&(b!==M&&y.push({froms:b,tos:M,hole:w}),A?(A=!1,l[M].push(S)):v=!0);A&&l[b].push(S)}y.length>0&&(v||(d=l))}for(var P,m=0,T=p.length;m<T;m++){s=p[m].s,c.push(s);for(var E=0,C=(P=d[m]).length;E<C;E++)s.holes.push(P[E].h)}return c}}),Object.assign(Or.prototype,{isFont:!0,generateShapes:function(t,e,i){function r(t,e,r,o){var a=n.glyphs[t]||n.glyphs["?"];if(a){var s,c,u,h,l,p,d,f,m,g,v,y=new Lr,b=[];if(a.o)for(var x=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),_=0,w=x.length;_<w;)switch(x[_++]){case"m":s=x[_++]*e+r,c=x[_++]*e+o,y.moveTo(s,c);break;case"l":s=x[_++]*e+r,c=x[_++]*e+o,y.lineTo(s,c);break;case"q":if(u=x[_++]*e+r,h=x[_++]*e+o,d=x[_++]*e+r,f=x[_++]*e+o,y.quadraticCurveTo(d,f,u,h),v=b[b.length-1]){l=v.x,p=v.y;for(S=1;S<=i;S++)vr(A=S/i,l,d,u),vr(A,p,f,h)}break;case"b":if(u=x[_++]*e+r,h=x[_++]*e+o,d=x[_++]*e+r,f=x[_++]*e+o,m=x[_++]*e+r,g=x[_++]*e+o,y.bezierCurveTo(d,f,m,g,u,h),v=b[b.length-1]){l=v.x,p=v.y;for(var S=1;S<=i;S++){var A=S/i;wr(A,l,d,m,u),wr(A,p,f,g,h)}}}return{offsetX:a.ha*e,path:y}}}void 0===e&&(e=100),void 0===i&&(i=4);for(var n=this.data,o=function(t){for(var i=String(t).split(""),o=e/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*o,s=0,c=0,u=[],h=0;h<i.length;h++){var l=i[h];if("\n"===l)s=0,c-=a;else{var p=r(l,o,s,c);s+=p.offsetX,u.push(p.path)}}return u}(t),a=[],s=0,c=o.length;s<c;s++)Array.prototype.push.apply(a,o[s].toShapes());return a}}),Object.assign(Dr.prototype,{load:function(t,e,i,r){var n=this;new Li(this.manager).load(t,function(t){var i;try{i=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}var r=n.parse(i);e&&e(r)},i,r)},parse:function(t){return new Or(t)}});var Zl,Kl={getContext:function(){return void 0===Zl&&(Zl=new(window.AudioContext||window.webkitAudioContext)),Zl},setContext:function(t){Zl=t}};Object.assign(Nr.prototype,{load:function(t,e,i,r){var n=new Li(this.manager);n.setResponseType("arraybuffer"),n.load(t,function(t){Kl.getContext().decodeAudioData(t,function(t){e(t)})},i,r)}}),Object.assign(kr.prototype,{update:function(){var t,e,i,r,n,o,a,s,c=new v,u=new v;return function(h){if(t!==this||e!==h.focus||i!==h.fov||r!==h.aspect*this.aspect||n!==h.near||o!==h.far||a!==h.zoom||s!==this.eyeSep){t=this,e=h.focus,i=h.fov,r=h.aspect*this.aspect,n=h.near,o=h.far,a=h.zoom;var l,p,d=h.projectionMatrix.clone(),f=(s=this.eyeSep/2)*n/e,m=n*Math.tan(xl.DEG2RAD*i*.5)/a;u.elements[12]=-s,c.elements[12]=s,l=-m*r+f,p=m*r+f,d.elements[0]=2*n/(p-l),d.elements[8]=(p+l)/(p-l),this.cameraL.projectionMatrix.copy(d),l=-m*r-f,p=m*r-f,d.elements[0]=2*n/(p-l),d.elements[8]=(p+l)/(p-l),this.cameraR.projectionMatrix.copy(d)}this.cameraL.matrixWorld.copy(h.matrixWorld).multiply(u),this.cameraR.matrixWorld.copy(h.matrixWorld).multiply(c)}}()}),Fr.prototype=Object.assign(Object.create(gt.prototype),{constructor:Fr,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)},getFilter:function(){return this.filter},setFilter:function(t){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination)},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(t){this.gain.gain.value=t},updateMatrixWorld:function(){var t=new g,e=new m,i=new g,r=new g;return function(n){gt.prototype.updateMatrixWorld.call(this,n);var o=this.context.listener,a=this.up;this.matrixWorld.decompose(t,e,i),r.set(0,0,-1).applyQuaternion(e),o.positionX?(o.positionX.setValueAtTime(t.x,this.context.currentTime),o.positionY.setValueAtTime(t.y,this.context.currentTime),o.positionZ.setValueAtTime(t.z,this.context.currentTime),o.forwardX.setValueAtTime(r.x,this.context.currentTime),o.forwardY.setValueAtTime(r.y,this.context.currentTime),o.forwardZ.setValueAtTime(r.z,this.context.currentTime),o.upX.setValueAtTime(a.x,this.context.currentTime),o.upY.setValueAtTime(a.y,this.context.currentTime),o.upZ.setValueAtTime(a.z,this.context.currentTime)):(o.setPosition(t.x,t.y,t.z),o.setOrientation(r.x,r.y,r.z,a.x,a.y,a.z))}}()}),Br.prototype=Object.assign(Object.create(gt.prototype),{constructor:Br,getOutput:function(){return this.gain},setNodeSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},setBuffer:function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.onended=this.onEnded.bind(this),t.playbackRate.setValueAtTime(this.playbackRate,this.startTime),t.start(0,this.startTime),this.isPlaying=!0,this.source=t,this.connect()},pause:function(){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=this.context.currentTime,this.isPlaying=!1,this)},stop:function(){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=0,this.isPlaying=!1,this)},connect:function(){var t=this;if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,i=this.filters.length;e<i;e++)t.filters[e-1].connect(t.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){var t=this;if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var e=1,i=this.filters.length;e<i;e++)t.filters[e-1].disconnect(t.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(t){return t||(t=[]),!0===this.isPlaying?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(t){return this.setFilters(t?[t]:[])},setPlaybackRate:function(t){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this)},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(t){return!1===this.hasPlaybackControl?void console.warn("THREE.Audio: this Audio has no playback control."):(this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this)},getVolume:function(){return this.gain.gain.value},setVolume:function(t){return this.gain.gain.value=t,this}}),zr.prototype=Object.assign(Object.create(Br.prototype),{constructor:zr,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(t){this.panner.refDistance=t},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(t){this.panner.rolloffFactor=t},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(t){this.panner.distanceModel=t},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(t){this.panner.maxDistance=t},updateMatrixWorld:function(){var t=new g;return function(e){gt.prototype.updateMatrixWorld.call(this,e),t.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(t.x,t.y,t.z)}}()}),Object.assign(Ur.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var t=0,e=this.getFrequencyData(),i=0;i<e.length;i++)t+=e[i];return t/e.length}}),Object.assign(jr.prototype,{accumulate:function(t,e){var i=this.buffer,r=this.valueSize,n=t*r+r,o=this.cumulativeWeight;if(0===o){for(var a=0;a!==r;++a)i[n+a]=i[a];o=e}else{var s=e/(o+=e);this._mixBufferRegion(i,n,0,s,r)}this.cumulativeWeight=o},apply:function(t){var e=this.valueSize,i=this.buffer,r=t*e+e,n=this.cumulativeWeight,o=this.binding;if(this.cumulativeWeight=0,n<1){var a=3*e;this._mixBufferRegion(i,r,a,1-n,e)}for(var s=e,c=e+e;s!==c;++s)if(i[s]!==i[s+e]){o.setValue(i,r);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,i=this.valueSize,r=3*i;t.getValue(e,r);for(var n=i,o=r;n!==o;++n)e[n]=e[r+n%i];this.cumulativeWeight=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_select:function(t,e,i,r,n){if(r>=.5)for(var o=0;o!==n;++o)t[e+o]=t[i+o]},_slerp:function(t,e,i,r){m.slerpFlat(t,e,t,e,t,i,r)},_lerp:function(t,e,i,r,n){for(var o=1-r,a=0;a!==n;++a){var s=e+a;t[s]=t[s]*o+t[i+a]*r}}}),Object.assign(Gr.prototype,{getValue:function(t,e){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(t,e)},setValue:function(t,e){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(Vr,{Composite:Gr,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new Vr.Composite(t,e,i):new Vr(t,e,i)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:function(){var t=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),e=["material","materials","bones"];return function(i){var r=t.exec(i);if(!r)throw new Error("PropertyBinding: Cannot parse trackName: "+i);var n={nodeName:r[2],objectName:r[3],objectIndex:r[4],propertyName:r[5],propertyIndex:r[6]},o=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==o&&-1!==o){var a=n.nodeName.substring(o+1);-1!==e.indexOf(a)&&(n.nodeName=n.nodeName.substring(0,o),n.objectName=a)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+i);return n}}(),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var i=function(t){for(var i=0;i<t.bones.length;i++){var r=t.bones[i];if(r.name===e)return r}return null}(t.skeleton);if(i)return i}if(t.children){var r=function(t){for(var i=0;i<t.length;i++){var n=t[i];if(n.name===e||n.uuid===e)return n;var o=r(n.children);if(o)return o}return null},n=r(t.children);if(n)return n}return null}}),Object.assign(Vr.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)t[e++]=i[r]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.node[this.propertyName]=t[e]},function(t,e){this.node[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.node[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++]},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,i=e.objectName,r=e.propertyName,n=e.propertyIndex;if(t||(t=Vr.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){var o=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(h=0;h<t.length;h++)if(t[h].name===o){o=h;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==o){if(void 0===t[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[o]}}var a=t[r];if(void 0===a){var s=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+s+"."+r+" but it wasn't found.",t)}var c=this.Versioning.None;void 0!==t.needsUpdate?(c=this.Versioning.NeedsUpdate,this.targetObject=t):void 0!==t.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=t);var u=this.BindingType.Direct;if(void 0!==n){if("morphTargetInfluences"===r){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(h=0;h<this.node.geometry.morphAttributes.position.length;h++)if(t.geometry.morphAttributes.position[h].name===n){n=h;break}}else{if(!t.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(var h=0;h<this.node.geometry.morphTargets.length;h++)if(t.geometry.morphTargets[h].name===n){n=h;break}}}u=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else void 0!==a.fromArray&&void 0!==a.toArray?(u=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(u=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][c]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Vr.prototype,{_getValue_unbound:Vr.prototype.getValue,_setValue_unbound:Vr.prototype.setValue}),Object.assign($r.prototype,{isAnimationObjectGroup:!0,add:function(t){for(var e=arguments,i=this._objects,r=i.length,n=this.nCachedObjects_,o=this._indicesByUUID,a=this._paths,s=this._parsedPaths,c=this._bindings,u=c.length,h=0,l=arguments.length;h!==l;++h){var p=e[h],d=p.uuid,f=o[d],m=void 0;if(void 0===f){f=r++,o[d]=f,i.push(p);for(var g=0,v=u;g!==v;++g)c[g].push(new Vr(p,a[g],s[g]))}else if(f<n){m=i[f];var y=--n,b=i[y];o[b.uuid]=f,i[f]=b,o[d]=y,i[y]=p;for(var g=0,v=u;g!==v;++g){var x=c[g],_=x[y],w=x[f];x[f]=_,void 0===w&&(w=new Vr(p,a[g],s[g])),x[y]=w}}else i[f]!==m&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=n},remove:function(t){for(var e=arguments,i=this._objects,r=this.nCachedObjects_,n=this._indicesByUUID,o=this._bindings,a=o.length,s=0,c=arguments.length;s!==c;++s){var u=e[s],h=u.uuid,l=n[h];if(void 0!==l&&l>=r){var p=r++,d=i[p];n[d.uuid]=l,i[l]=d,n[h]=p,i[p]=u;for(var f=0,m=a;f!==m;++f){var g=o[f],v=g[p],y=g[l];g[l]=v,g[p]=y}}}this.nCachedObjects_=r},uncache:function(t){for(var e=arguments,i=this._objects,r=i.length,n=this.nCachedObjects_,o=this._indicesByUUID,a=this._bindings,s=a.length,c=0,u=arguments.length;c!==u;++c){var h=e[c].uuid,l=o[h];if(void 0!==l)if(delete o[h],l<n){var p=--n,d=i[p],f=i[b=--r];o[d.uuid]=l,i[l]=d,o[f.uuid]=p,i[p]=f,i.pop();for(var m=0,g=s;m!==g;++m){var v=(x=a[m])[p],y=x[b];x[l]=v,x[p]=y,x.pop()}}else{var b=--r;o[(f=i[b]).uuid]=l,i[l]=f,i.pop();for(var m=0,g=s;m!==g;++m){var x=a[m];x[l]=x[b],x.pop()}}}this.nCachedObjects_=n},subscribe_:function(t,e){var i=this._bindingsIndicesByPath,r=i[t],n=this._bindings;if(void 0!==r)return n[r];var o=this._paths,a=this._parsedPaths,s=this._objects,c=s.length,u=this.nCachedObjects_,h=new Array(c);r=n.length,i[t]=r,o.push(t),a.push(e),n.push(h);for(var l=u,p=s.length;l!==p;++l){var d=s[l];h[l]=new Vr(d,t,e)}return h},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){var r=this._paths,n=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];e[t[a]]=i,o[i]=s,o.pop(),n[i]=n[a],n.pop(),r[i]=r[a],r.pop()}}}),Object.assign(Hr.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(t){return this._startTime=t,this},setLoop:function(t,e){return this.loop=t,this.repetitions=e,this},setEffectiveWeight:function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(t){return this._scheduleFading(t,0,1)},fadeOut:function(t){return this._scheduleFading(t,1,0)},crossFadeFrom:function(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){var r=this._clip.duration,n=t._clip.duration,o=n/r,a=r/n;t.warp(1,o,e),this.warp(a,1,e)}return this},crossFadeTo:function(t,e,i){return t.crossFadeFrom(this,e,i)},stopFading:function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},setEffectiveTimeScale:function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},syncWith:function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},halt:function(t){return this.warp(this._effectiveTimeScale,0,t)},warp:function(t,e,i){var r=this._mixer,n=r.time,o=this._timeScaleInterpolant,a=this.timeScale;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,c=o.sampleValues;return s[0]=n,s[1]=n+i,c[0]=t/a,c[1]=e/a,this},stopWarping:function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(t,e,i,r){if(!this.enabled)return void this._updateWeight(t);var n=this._startTime;if(null!==n){var o=(t-n)*i;if(o<0||0===i)return;this._startTime=null,e=i*o}e*=this._updateTimeScale(t);var a=this._updateTime(e),s=this._updateWeight(t);if(s>0)for(var c=this._interpolants,u=this._propertyBindings,h=0,l=c.length;h!==l;++h)c[h].evaluate(a),u[h].accumulate(r,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(t)[0];e*=r,t>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var i=this._clip.duration,r=this.loop,n=this._loopCount;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=i)e=i;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===r;if(-1===n&&(t>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=i||e<0){var a=Math.floor(e/i);e-=i*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&n))return this.time=e,i-e}return this.time=e,e},_setEndings:function(t,e,i){var r=this._interpolantSettings;i?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=t?this.zeroSlopeAtStart?2401:sl:2402,r.endingEnd=e?this.zeroSlopeAtEnd?2401:sl:2402)},_scheduleFading:function(t,e,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=e,a[1]=n+t,s[1]=i,this}}),Object.assign(Wr.prototype,h.prototype,{_bindAction:function(t,e){var i=this,r=t._localRoot||this._root,n=t._clip.tracks,o=n.length,a=t._propertyBindings,s=t._interpolants,c=r.uuid,u=this._bindingsByRootAndName,h=u[c];void 0===h&&(h={},u[c]=h);for(var l=0;l!==o;++l){var p=n[l],d=p.name,f=h[d];if(void 0!==f)a[l]=f;else{if(void 0!==(f=a[l])){null===f._cacheIndex&&(++f.referenceCount,i._addInactiveBinding(f,c,d));continue}var m=e&&e._propertyBindings[l].binding.parsedPath;++(f=new jr(Vr.create(r,d,m),p.ValueTypeName,p.getValueSize())).referenceCount,i._addInactiveBinding(f,c,d),a[l]=f}s[l].resultBuffer=f.buffer}},_activateAction:function(t){var e=this;if(!this._isActiveAction(t)){if(null===t._cacheIndex){var i=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,i)}for(var o=t._propertyBindings,a=0,s=o.length;a!==s;++a){var c=o[a];0==c.useCount++&&(e._lendBinding(c),c.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){var e=this;if(this._isActiveAction(t)){for(var i=t._propertyBindings,r=0,n=i.length;r!==n;++r){var o=i[r];0==--o.useCount&&(o.restoreOriginalState(),e._takeBackBinding(o))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,i){var r=this._actions,n=this._actionsByClip,o=n[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,n[e]=o;else{var a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[i]=t},_removeInactiveAction:function(t){var e=this._actions,i=e[e.length-1],r=t._cacheIndex;i._cacheIndex=r,e[r]=i,e.pop(),t._cacheIndex=null;var n=t._clip.uuid,o=this._actionsByClip,a=o[n],s=a.knownActions,c=s[s.length-1],u=t._byClipCacheIndex;c._byClipCacheIndex=u,s[u]=c,s.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete o[n],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=this,i=t._propertyBindings,r=0,n=i.length;r!==n;++r){var o=i[r];0==--o.referenceCount&&e._removeInactiveBinding(o)}},_lendAction:function(t){var e=this._actions,i=t._cacheIndex,r=this._nActiveActions++,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_takeBackAction:function(t){var e=this._actions,i=t._cacheIndex,r=--this._nActiveActions,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_addInactiveBinding:function(t,e,i){var r=this._bindingsByRootAndName,n=r[e],o=this._bindings;void 0===n&&(n={},r[e]=n),n[i]=t,t._cacheIndex=o.length,o.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,i=t.binding,r=i.rootNode.uuid,n=i.path,o=this._bindingsByRootAndName,a=o[r],s=e[e.length-1],c=t._cacheIndex;s._cacheIndex=c,e[c]=s,e.pop(),delete a[n];t:{for(var u in a)break t;delete o[r]}},_lendBinding:function(t){var e=this._bindings,i=t._cacheIndex,r=this._nActiveBindings++,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_takeBackBinding:function(t){var e=this._bindings,i=t._cacheIndex,r=--this._nActiveBindings,n=e[r];t._cacheIndex=r,e[r]=t,n._cacheIndex=i,e[i]=n},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,i=t[e];return void 0===i&&((i=new Zi(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=i),i},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,i=t.__cacheIndex,r=--this._nActiveControlInterpolants,n=e[r];t.__cacheIndex=r,e[r]=t,n.__cacheIndex=i,e[i]=n},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e){var i=e||this._root,r=i.uuid,n="string"==typeof t?sr.findByName(i,t):t,o=null!==n?n.uuid:t,a=this._actionsByClip[o],s=null;if(void 0!==a){var c=a.actionByRoot[r];if(void 0!==c)return c;s=a.knownActions[0],null===n&&(n=s._clip)}if(null===n)return null;var u=new Hr(this,n,e);return this._bindAction(u,s),this._addInactiveAction(u,o,r),u},existingAction:function(t,e){var i=e||this._root,r=i.uuid,n="string"==typeof t?sr.findByName(i,t):t,o=n?n.uuid:t,a=this._actionsByClip[o];return void 0!==a?a.actionByRoot[r]||null:null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,i=this._bindings,r=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(n=0;n!==e;++n)t[n].reset();for(var n=0;n!==r;++n)i[n].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,i=this._nActiveActions,r=this.time+=t,n=Math.sign(t),o=this._accuIndex^=1,a=0;a!==i;++a)e[a]._update(r,t,n,o);for(var s=this._bindings,c=this._nActiveBindings,a=0;a!==c;++a)s[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this,i=this._actions,r=t.uuid,n=this._actionsByClip,o=n[r];if(void 0!==o){for(var a=o.knownActions,s=0,c=a.length;s!==c;++s){var u=a[s];e._deactivateAction(u);var h=u._cacheIndex,l=i[i.length-1];u._cacheIndex=null,u._byClipCacheIndex=null,l._cacheIndex=h,i[h]=l,i.pop(),e._removeInactiveBindingsForAction(u)}delete n[r]}},uncacheRoot:function(t){var e=this,i=t.uuid,r=this._actionsByClip;for(var n in r){var o=r[n].actionByRoot[i];void 0!==o&&(e._deactivateAction(o),e._removeInactiveAction(o))}var a=this._bindingsByRootAndName[i];if(void 0!==a)for(var s in a){var c=a[s];c.restoreOriginalState(),e._removeInactiveBinding(c)}},uncacheAction:function(t,e){var i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}),Xr.prototype.clone=function(){return new Xr(void 0===this.value.clone?this.value:this.value.clone())},qr.prototype=Object.assign(Object.create(Ct.prototype),{constructor:qr,isInstancedBufferGeometry:!0,addGroup:function(t,e,i){this.groups.push({start:t,count:e,materialIndex:i})},copy:function(t){var e=this,i=t.index;null!==i&&this.setIndex(i.clone());var r=t.attributes;for(var n in r){var o=r[n];e.addAttribute(n,o.clone())}for(var a=t.groups,s=0,c=a.length;s<c;s++){var u=a[s];e.addGroup(u.start,u.count,u.materialIndex)}return this}}),Object.defineProperties(Yr.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Yr.prototype,{isInterleavedBufferAttribute:!0,setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=r,this},setXYZW:function(t,e,i,r,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=r,this.data.array[t+3]=n,this}}),Object.defineProperty(Zr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Zr.prototype,{isInterleavedBuffer:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.stride:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){var r=this;t*=this.stride,i*=e.stride;for(var n=0,o=this.stride;n<o;n++)r.array[t+n]=e.array[i+n];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}}),Kr.prototype=Object.assign(Object.create(Zr.prototype),{constructor:Kr,isInstancedInterleavedBuffer:!0,copy:function(t){return Zr.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Qr.prototype=Object.assign(Object.create(St.prototype),{constructor:Qr,isInstancedBufferAttribute:!0,copy:function(t){return St.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Object.assign(Jr.prototype,{linePrecision:1,set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize()):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e){var i=[];return en(t,this,i,e),i.sort(tn),i},intersectObjects:function(t,e){var i=this,r=[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(var n=0,o=t.length;n<o;n++)en(t[n],i,r,e);return r.sort(tn),r}}),Object.assign(rn.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"==typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}),Object.assign(nn.prototype,{set:function(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(t){return this.radius=t.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(xl.clamp(t.y/this.radius,-1,1))),this}}),Object.assign(on.prototype,{set:function(t,e,i){return this.radius=t,this.theta=e,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.radius=Math.sqrt(t.x*t.x+t.z*t.z),this.theta=Math.atan2(t.x,t.z),this.y=t.y,this}}),an.prototype=Object.create(Re.prototype),an.prototype.constructor=an,an.prototype.update=function(){var t=new g,e=new g,i=new ut;return function(){var r=this,n=["a","b","c"];this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);var o=this.object.matrixWorld,a=this.geometry.attributes.position,s=this.object.geometry;if(s&&s.isGeometry)for(var c=s.vertices,u=s.faces,h=0,l=0,p=u.length;l<p;l++)for(var d=u[l],f=0,m=d.vertexNormals.length;f<m;f++){var g=c[d[n[f]]],v=d.vertexNormals[f];t.copy(g).applyMatrix4(o),e.copy(v).applyMatrix3(i).normalize().multiplyScalar(r.size).add(t),a.setXYZ(h,t.x,t.y,t.z),h+=1,a.setXYZ(h,e.x,e.y,e.z),h+=1}else if(s&&s.isBufferGeometry)for(var y=s.attributes.position,b=s.attributes.normal,h=0,f=0,m=y.count;f<m;f++)t.set(y.getX(f),y.getY(f),y.getZ(f)).applyMatrix4(o),e.set(b.getX(f),b.getY(f),b.getZ(f)),e.applyMatrix3(i).normalize().multiplyScalar(r.size).add(t),a.setXYZ(h,t.x,t.y,t.z),h+=1,a.setXYZ(h,e.x,e.y,e.z),h+=1;a.needsUpdate=!0}}(),cn.prototype=Object.create(Re.prototype),cn.prototype.constructor=cn,cn.prototype.onBeforeRender=function(){var t=new g,e=new v,i=new v;return function(){var r=this.bones,n=this.geometry,o=n.getAttribute("position");i.getInverse(this.root.matrixWorld);for(var a=0,s=0;a<r.length;a++){var c=r[a];c.parent&&c.parent.isBone&&(e.multiplyMatrices(i,c.matrixWorld),t.setFromMatrixPosition(e),o.setXYZ(s,t.x,t.y,t.z),e.multiplyMatrices(i,c.parent.matrixWorld),t.setFromMatrixPosition(e),o.setXYZ(s+1,t.x,t.y,t.z),s+=2)}n.getAttribute("position").needsUpdate=!0}}(),un.prototype=Object.create(gt.prototype),un.prototype.constructor=un,un.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},un.prototype.update=function(){var t=new g,e=new tt,i=new tt;return function(){var r=this.children[0],n=r.geometry.getAttribute("color");e.copy(this.light.color),i.copy(this.light.groundColor);for(var o=0,a=n.count;o<a;o++){var s=o<a/2?e:i;n.setXYZ(o,s.r,s.g,s.b)}r.lookAt(t.setFromMatrixPosition(this.light.matrixWorld).negate()),n.needsUpdate=!0}}(),hn.prototype=Object.create(Re.prototype),hn.prototype.constructor=hn,hn.prototype.update=function(){var t=new g,e=new g,i=new ut;return function(){var r=this;this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);for(var n=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry,s=a.vertices,c=a.faces,u=0,h=0,l=c.length;h<l;h++){var p=c[h],d=p.normal;t.copy(s[p.a]).add(s[p.b]).add(s[p.c]).divideScalar(3).applyMatrix4(n),e.copy(d).applyMatrix3(i).normalize().multiplyScalar(r.size).add(t),o.setXYZ(u,t.x,t.y,t.z),u+=1,o.setXYZ(u,e.x,e.y,e.z),u+=1}o.needsUpdate=!0}}(),ln.prototype=Object.create(Re.prototype),ln.prototype.constructor=ln,ln.prototype.update=function(){function t(t,o,a,s){r.set(o,a,s).unproject(n);var c=i[t];if(void 0!==c)for(var u=e.getAttribute("position"),h=0,l=c.length;h<l;h++)u.setXYZ(c[h],r.x,r.y,r.z)}var e,i,r=new g,n=new vt;return function(){e=this.geometry,i=this.pointMap;n.projectionMatrix.copy(this.camera.projectionMatrix),t("c",0,0,-1),t("t",0,0,1),t("n1",-1,-1,-1),t("n2",1,-1,-1),t("n3",-1,1,-1),t("n4",1,1,-1),t("f1",-1,-1,1),t("f2",1,-1,1),t("f3",-1,1,1),t("f4",1,1,1),t("u1",.7,1.1,-1),t("u2",-.7,1.1,-1),t("u3",0,2,-1),t("cf1",-1,0,1),t("cf2",1,0,1),t("cf3",0,-1,1),t("cf4",0,1,1),t("cn1",-1,0,-1),t("cn2",1,0,-1),t("cn3",0,-1,-1),t("cn4",0,1,-1),e.getAttribute("position").needsUpdate=!0}}();var Ql=new g,Jl=new pn,tp=new pn,ep=new pn;dn.prototype=Object.create(Sr.prototype),dn.prototype.constructor=dn,dn.prototype.getPoint=function(t){var e=this.points,i=e.length,r=(i-(this.closed?0:1))*t,n=Math.floor(r),o=r-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/e.length)+1)*e.length:0===o&&n===i-1&&(n=i-2,o=1);var a,s,c,u;if(this.closed||n>0?a=e[(n-1)%i]:(Ql.subVectors(e[0],e[1]).add(e[0]),a=Ql),s=e[n%i],c=e[(n+1)%i],this.closed||n+2<i?u=e[(n+2)%i]:(Ql.subVectors(e[i-1],e[i-2]).add(e[i-1]),u=Ql),void 0===this.type||"centripetal"===this.type||"chordal"===this.type){var h="chordal"===this.type?.5:.25,l=Math.pow(a.distanceToSquared(s),h),p=Math.pow(s.distanceToSquared(c),h),d=Math.pow(c.distanceToSquared(u),h);p<1e-4&&(p=1),l<1e-4&&(l=p),d<1e-4&&(d=p),Jl.initNonuniformCatmullRom(a.x,s.x,c.x,u.x,l,p,d),tp.initNonuniformCatmullRom(a.y,s.y,c.y,u.y,l,p,d),ep.initNonuniformCatmullRom(a.z,s.z,c.z,u.z,l,p,d)}else if("catmullrom"===this.type){var f=void 0!==this.tension?this.tension:.5;Jl.initCatmullRom(a.x,s.x,c.x,u.x,f),tp.initCatmullRom(a.y,s.y,c.y,u.y,f),ep.initCatmullRom(a.z,s.z,c.z,u.z,f)}return new g(Jl.calc(o),tp.calc(o),ep.calc(o))},Sr.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Sr.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},fn.prototype=Object.create(dn.prototype),Object.assign(fn.prototype,{initFromArray:function(t){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(t){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(t){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),cn.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(et.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(st.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),kt.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},xl.random16=function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},Object.assign(ut.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(t){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(t,e,i){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(t,e,i){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(v.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){var t;return function(){return void 0===t&&(t=new g),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),t.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(t){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(t,e,i){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(t,e,i){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,i,r,n,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,i,n,o)}}),ht.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},m.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(Nt.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(Rr.prototype,{extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ri(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new di(this,t)}}),Object.assign(l.prototype,{fromAttribute:function(t,e,i){return console.error("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)}}),Object.assign(g.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,i){return console.error("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)}}),Object.assign(d.prototype,{fromAttribute:function(t,e,i){return console.error("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)}}),wt.prototype.computeTangents=function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},Object.assign(gt.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)}}),Object.defineProperties(gt.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(Me.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Pe.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Object.defineProperty(Sr.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),bt.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Bi.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(St.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}}}),Object.assign(Ct.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addDrawCall:function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}),Object.defineProperties(Ct.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(Xr.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(nt.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new tt}}}),Object.defineProperties(Pi.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(ot.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(ye.prototype,{getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}}),Object.defineProperties(ye.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace."),this.shadowMap.cullFace=t}}}),Object.defineProperties(pt.prototype,{cullFace:{get:function(){return this.renderReverseSided?xu:bu},set:function(t){var e=t!==bu;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+e+"."),this.renderReverseSided=e}}}),Object.defineProperties(f.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Br.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new Nr).load(t,function(t){e.setBuffer(t)}),this},Ur.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()};var ip=function(t){this.name=t,this._dict={}},rp={names:{}};ip.prototype.add=function(t,e){this._dict[Un(t)]=e},ip.prototype.get=function(t){return this._dict[Un(t)]},rp.names.get=function(){return Object.keys(this._dict)},Object.defineProperties(ip.prototype,rp);var np=function(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}};np.prototype.add=function(t,e,i){this._funcDict[t]=e,this._depsDict[t]=i},np.prototype.get=function(t){return this._blobDict[t]||(this._blobDict[t]=$n(this._funcDict[t],this._depsDict[t])),this._blobDict[t]};var op,ap,sp,cp,up,hp,lp,pp,dp,fp,mp,gp,vp,yp,bp,xp,_p,wp,Sp,Ap,Mp,Pp,Tp,Ep,Cp,Ip,Rp,Lp,Op,Dp,Np,kp,Fp,Bp,zp,Up,jp,Gp,Vp,$p,Hp,Wp,Xp,qp,Yp,Zp,Kp,Qp,Jp,td,ed,id,rd,nd,od,ad,sd,cd,ud,hd,ld,pd,dd,fd,md,gd,vd,yd,bd,xd,_d,wd,Sd,Ad,Md,Pd,Td,Ed,Cd,Id="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Rd=new Array(36),Ld=[].slice;Md=function(){var t,e,i,r,n;for(t={},r=0,e=(n="Boolean Number String Function Array Date RegExp Undefined Null".split(" ")).length;r<e;r++)i=n[r],t["[object "+i+"]"]=i.toLowerCase();return function(e){var i;return i=Object.prototype.toString.call(e),t[i]||"object"}}(),Yp=function(t,e,i){return null==e&&(e=0),null==i&&(i=1),t<e&&(t=e),t>i&&(t=i),t},Pd=function(t){return t.length>=3?[].slice.call(t):t[0]},Ap=function(t){var e,i;for(t._clipped=!1,t._unclipped=t.slice(0),e=i=0;i<3;e=++i)e<3?((t[e]<0||t[e]>255)&&(t._clipped=!0),t[e]<0&&(t[e]=0),t[e]>255&&(t[e]=255)):3===e&&(t[e]<0&&(t[e]=0),t[e]>1&&(t[e]=1));return t._clipped||delete t._unclipped,t},cp=Math.PI,xd=Math.round,Pp=Math.cos,Rp=Math.floor,nd=Math.pow,Zp=Math.log,wd=Math.sin,Sd=Math.sqrt,vp=Math.atan2,Jp=Math.max,gp=Math.abs,lp=2*cp,up=cp/3,ap=cp/180,hp=180/cp,mp=[],(Sp=function(){return arguments[0]instanceof op?arguments[0]:function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,arguments,function(){})}).version="1.3.3",fp={},pp=[],dp=!1,op=function(){function t(){var t,e,i,r,n,o,a,s,c,u=arguments;for(o=this,e=[],s=0,r=arguments.length;s<r;s++)null!=(t=u[s])&&e.push(t);if(a=e[e.length-1],null!=fp[a])o._rgb=Ap(fp[a](Pd(e.slice(0,-1))));else{for(dp||(pp=pp.sort(function(t,e){return e.p-t.p}),dp=!0),c=0,n=pp.length;c<n&&(i=pp[c],!(a=i.test.apply(i,e)));c++);a&&(o._rgb=Ap(fp[a].apply(fp,e)))}null==o._rgb&&console.warn("unknown format: "+e),null==o._rgb&&(o._rgb=[0,0,0]),3===o._rgb.length&&o._rgb.push(1)}return t.prototype.toString=function(){return this.hex()},t}(),Sp._input=fp,Sp.brewer=_p={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},function(){var t,e;e=[];for(t in _p)e.push(_p[t.toLowerCase()]=_p[t])}(),Td={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},Sp.colors=Td,$p=function(){var t,e,i,r,n,o,a,s,c;return e=Pd(arguments),n=e[0],t=e[1],i=e[2],s=(n+16)/116,a=isNaN(t)?s:s+t/500,c=isNaN(i)?s:s-i/200,s=sp.Yn*Hp(s),a=sp.Xn*Hp(a),c=sp.Zn*Hp(c),o=Cd(3.2404542*a-1.5371385*s-.4985314*c),r=Cd(-.969266*a+1.8760108*s+.041556*c),i=Cd(.0556434*a-.2040259*s+1.0572252*c),[o,r,i,e.length>3?e[3]:1]},Cd=function(t){return 255*(t<=.00304?12.92*t:1.055*nd(t,1/2.4)-.055)},Hp=function(t){return t>sp.t1?t*t*t:sp.t2*(t-sp.t0)},sp={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},pd=function(){var t,e,i,r,n,o,a,s;return r=Pd(arguments),i=r[0],e=r[1],t=r[2],n=vd(i,e,t),o=n[0],a=n[1],s=n[2],[116*a-16,500*(o-a),200*(a-s)]},yd=function(t){return(t/=255)<=.04045?t/12.92:nd((t+.055)/1.055,2.4)},Ed=function(t){return t>sp.t3?nd(t,1/3):t/sp.t2+sp.t0},vd=function(){var t,e,i,r,n,o,a;return r=Pd(arguments),i=r[0],e=r[1],t=r[2],i=yd(i),e=yd(e),t=yd(t),n=Ed((.4124564*i+.3575761*e+.1804375*t)/sp.Xn),o=Ed((.2126729*i+.7151522*e+.072175*t)/sp.Yn),a=Ed((.0193339*i+.119192*e+.9503041*t)/sp.Zn),[n,o,a]},Sp.lab=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["lab"]),function(){})},fp.lab=$p,op.prototype.lab=function(){return pd(this._rgb)},yp=function(t){var e,i,r,n,o,a,s,c,u,h,l;return t=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(Sp(n));return r}(),2===t.length?(u=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(n.lab());return r}(),o=u[0],a=u[1],e=function(t){var e,i;return i=function(){var i,r;for(r=[],e=i=0;i<=2;e=++i)r.push(o[e]+t*(a[e]-o[e]));return r}(),Sp.lab.apply(Sp,i)}):3===t.length?(h=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(n.lab());return r}(),o=h[0],a=h[1],s=h[2],e=function(t){var e,i;return i=function(){var i,r;for(r=[],e=i=0;i<=2;e=++i)r.push((1-t)*(1-t)*o[e]+2*(1-t)*t*a[e]+t*t*s[e]);return r}(),Sp.lab.apply(Sp,i)}):4===t.length?(l=function(){var e,i,r;for(r=[],i=0,e=t.length;i<e;i++)n=t[i],r.push(n.lab());return r}(),o=l[0],a=l[1],s=l[2],c=l[3],e=function(t){var e,i;return i=function(){var i,r;for(r=[],e=i=0;i<=2;e=++i)r.push((1-t)*(1-t)*(1-t)*o[e]+3*(1-t)*(1-t)*t*a[e]+3*(1-t)*t*t*s[e]+t*t*t*c[e]);return r}(),Sp.lab.apply(Sp,i)}):5===t.length&&(i=yp(t.slice(0,3)),r=yp(t.slice(2,5)),e=function(t){return t<.5?i(2*t):r(2*(t-.5))}),e},Sp.bezier=function(t){var e;return e=yp(t),e.scale=function(){return Sp.scale(e)},e},Sp.cubehelix=function(t,e,i,r,n){var o,a,s;return null==t&&(t=300),null==e&&(e=-1.5),null==i&&(i=1),null==r&&(r=1),null==n&&(n=[0,1]),o=0,"array"===Md(n)?a=n[1]-n[0]:(a=0,n=[n,n]),s=function(s){var c,u,h,l,p,d,f,m,g;return c=lp*((t+120)/360+e*s),f=nd(n[0]+a*s,r),d=0!==o?i[0]+s*o:i,u=d*f*(1-f)/2,l=Pp(c),g=wd(c),m=f+u*(-.14861*l+1.78277*g),p=f+u*(-.29227*l-.90649*g),h=f+u*(1.97294*l),Sp(Ap([255*m,255*p,255*h]))},s.start=function(e){return null==e?t:(t=e,s)},s.rotations=function(t){return null==t?e:(e=t,s)},s.gamma=function(t){return null==t?r:(r=t,s)},s.hue=function(t){return null==t?i:(i=t,"array"===Md(i)?0===(o=i[1]-i[0])&&(i=i[1]):o=0,s)},s.lightness=function(t){return null==t?n:("array"===Md(t)?(n=t,a=t[1]-t[0]):(n=[t,t],a=0),s)},s.scale=function(){return Sp.scale(s)},s.hue(i),s},Sp.random=function(){var t,e;for("0123456789abcdef",t="#",e=0;e<6;++e)t+="0123456789abcdef".charAt(Rp(16*Math.random()));return new op(t)},Sp.average=function(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f;null==e&&(e="rgb"),h=t.length,d=(c=(t=t.map(function(t){return Sp(t)})).splice(0,1)[0]).get(e),o=[],a=0,s=0;for(u in d)d[u]=d[u]||0,o.push(isNaN(d[u])?0:1),"h"!==e.charAt(u)||isNaN(d[u])||(i=d[u]/180*cp,a+=Pp(i),s+=wd(i));for(r=c.alpha(),p=0,l=t.length;p<l;p++){f=(n=t[p]).get(e),r+=n.alpha();for(u in d)isNaN(f[u])||(d[u]+=f[u],o[u]+=1,"h"===e.charAt(u)&&(i=d[u]/180*cp,a+=Pp(i),s+=wd(i)))}for(u in d)if(d[u]=d[u]/o[u],"h"===e.charAt(u)){for(i=vp(s/o[u],a/o[u])/cp*180;i<0;)i+=360;for(;i>=360;)i-=360;d[u]=i}return Sp(d,e).alpha(r/h)},fp.rgb=function(){var t,e,i,r;e=Pd(arguments),i=[];for(t in e)r=e[t],i.push(r);return i},Sp.rgb=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["rgb"]),function(){})},op.prototype.rgb=function(t){return null==t&&(t=!0),t?this._rgb.map(Math.round).slice(0,3):this._rgb.slice(0,3)},op.prototype.rgba=function(t){return null==t&&(t=!0),t?[Math.round(this._rgb[0]),Math.round(this._rgb[1]),Math.round(this._rgb[2]),this._rgb[3]]:this._rgb.slice(0)},pp.push({p:3,test:function(t){var e;return e=Pd(arguments),"array"===Md(e)&&3===e.length?"rgb":4===e.length&&"number"===Md(e[3])&&e[3]>=0&&e[3]<=1?"rgb":void 0}}),Op=function(t){var e,i,r,n,o,a;if(t.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]),a=parseInt(t,16),n=a>>16,r=a>>8&255,i=255&a,[n,r,i,1];if(t.match(/^#?([A-Fa-f0-9]{8})$/))return 9===t.length&&(t=t.substr(1)),a=parseInt(t,16),n=a>>24&255,r=a>>16&255,i=a>>8&255,e=xd((255&a)/255*100)/100,[n,r,i,e];if(null!=fp.css&&(o=fp.css(t)))return o;throw"unknown color: "+t},cd=function(t,e){var i,r,n,o,a,s,c;return null==e&&(e="rgb"),a=t[0],n=t[1],r=t[2],i=t[3],a=Math.round(a),n=Math.round(n),r=Math.round(r),c=a<<16|n<<8|r,s="000000"+c.toString(16),s=s.substr(s.length-6),o="0"+xd(255*i).toString(16),o=o.substr(o.length-2),"#"+function(){switch(e.toLowerCase()){case"rgba":return s+o;case"argb":return o+s;default:return s}}()},fp.hex=function(t){return Op(t)},Sp.hex=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["hex"]),function(){})},op.prototype.hex=function(t){return null==t&&(t="rgb"),cd(this._rgb,t)},pp.push({p:4,test:function(t){if(1===arguments.length&&"string"===Md(t))return"hex"}}),kp=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d;if(t=Pd(arguments),n=t[0],h=t[1],a=t[2],0===h)c=r=e=255*a;else{for(d=[0,0,0],i=[0,0,0],l=2*a-(p=a<.5?a*(1+h):a+h-a*h),n/=360,d[0]=n+1/3,d[1]=n,d[2]=n-1/3,o=s=0;s<=2;o=++s)d[o]<0&&(d[o]+=1),d[o]>1&&(d[o]-=1),6*d[o]<1?i[o]=l+6*(p-l)*d[o]:2*d[o]<1?i[o]=p:3*d[o]<2?i[o]=l+(p-l)*(2/3-d[o])*6:i[o]=l;c=(u=[xd(255*i[0]),xd(255*i[1]),xd(255*i[2])])[0],r=u[1],e=u[2]}return t.length>3?[c,r,e,t[3]]:[c,r,e]},hd=function(t,e,i){var r,n,o,a,s;return void 0!==t&&t.length>=3&&(t=(a=t)[0],e=a[1],i=a[2]),t/=255,e/=255,i/=255,o=Math.min(t,e,i),Jp=Math.max(t,e,i),n=(Jp+o)/2,Jp===o?(s=0,r=Number.NaN):s=n<.5?(Jp-o)/(Jp+o):(Jp-o)/(2-Jp-o),t===Jp?r=(e-i)/(Jp-o):e===Jp?r=2+(i-t)/(Jp-o):i===Jp&&(r=4+(t-e)/(Jp-o)),(r*=60)<0&&(r+=360),[r,s,n]},Sp.hsl=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["hsl"]),function(){})},fp.hsl=kp,op.prototype.hsl=function(){return hd(this._rgb)},Fp=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v;if(t=Pd(arguments),n=t[0],m=t[1],v=t[2],v*=255,0===m)c=r=e=v;else switch(360===n&&(n=0),n>360&&(n-=360),n<0&&(n+=360),n/=60,o=Rp(n),i=n-o,a=v*(1-m),s=v*(1-m*i),g=v*(1-m*(1-i)),o){case 0:c=(u=[v,g,a])[0],r=u[1],e=u[2];break;case 1:c=(h=[s,v,a])[0],r=h[1],e=h[2];break;case 2:c=(l=[a,v,g])[0],r=l[1],e=l[2];break;case 3:c=(p=[a,s,v])[0],r=p[1],e=p[2];break;case 4:c=(d=[g,a,v])[0],r=d[1],e=d[2];break;case 5:c=(f=[v,a,s])[0],r=f[1],e=f[2]}return[c,r,e,t.length>3?t[3]:1]},ld=function(){var t,e,i,r,n,o,a,s,c;return a=Pd(arguments),o=a[0],i=a[1],t=a[2],n=Math.min(o,i,t),Jp=Math.max(o,i,t),e=Jp-n,c=Jp/255,0===Jp?(r=Number.NaN,s=0):(s=e/Jp,o===Jp&&(r=(i-t)/e),i===Jp&&(r=2+(t-o)/e),t===Jp&&(r=4+(o-i)/e),(r*=60)<0&&(r+=360)),[r,s,c]},Sp.hsv=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["hsv"]),function(){})},fp.hsv=Fp,op.prototype.hsv=function(){return ld(this._rgb)},id=function(t){var e,i,r;return"number"===Md(t)&&t>=0&&t<=16777215?(r=t>>16,i=t>>8&255,e=255&t,[r,i,e,1]):(console.warn("unknown num color: "+t),[0,0,0,1])},md=function(){var t,e,i,r;return r=Pd(arguments),i=r[0],e=r[1],t=r[2],(i<<16)+(e<<8)+t},Sp.num=function(t){return new op(t,"num")},op.prototype.num=function(t){return null==t&&(t="rgb"),md(this._rgb,t)},fp.num=id,pp.push({p:1,test:function(t){if(1===arguments.length&&"number"===Md(t)&&t>=0&&t<=16777215)return"num"}}),Lp=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b;if(i=Pd(arguments),s=i[0],n=i[1],e=i[2],n/=100,a=a/100*255,t=255*n,0===n)l=a=r=e;else switch(360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360),s/=60,c=Rp(s),o=s-c,u=e*(1-n),h=u+t*(1-o),y=u+t*o,b=u+t,c){case 0:l=(p=[b,y,u])[0],a=p[1],r=p[2];break;case 1:l=(d=[h,b,u])[0],a=d[1],r=d[2];break;case 2:l=(f=[u,b,y])[0],a=f[1],r=f[2];break;case 3:l=(m=[u,h,b])[0],a=m[1],r=m[2];break;case 4:l=(g=[y,u,b])[0],a=g[1],r=g[2];break;case 5:l=(v=[b,u,h])[0],a=v[1],r=v[2]}return[l,a,r,i.length>3?i[3]:1]},sd=function(){var t,e,i,r,n,o,a,s,c;return c=Pd(arguments),s=c[0],n=c[1],e=c[2],a=Math.min(s,n,e),Jp=Math.max(s,n,e),r=Jp-a,i=100*r/255,t=a/(255-r)*100,0===r?o=Number.NaN:(s===Jp&&(o=(n-e)/r),n===Jp&&(o=2+(e-s)/r),e===Jp&&(o=4+(s-n)/r),(o*=60)<0&&(o+=360)),[o,i,t]},Sp.hcg=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["hcg"]),function(){})},fp.hcg=Lp,op.prototype.hcg=function(){return sd(this._rgb)},Tp=function(t){var e,i,r,n,o,a,s,c;if(t=t.toLowerCase(),null!=Sp.colors&&Sp.colors[t])return Op(Sp.colors[t]);if(o=t.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=o.slice(1,4),n=a=0;a<=2;n=++a)s[n]=+s[n];s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(s=o.slice(1,5),n=c=0;c<=3;n=++c)s[n]=+s[n];else if(o=t.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=o.slice(1,4),n=e=0;e<=2;n=++e)s[n]=xd(2.55*s[n]);s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(s=o.slice(1,5),n=i=0;i<=2;n=++i)s[n]=xd(2.55*s[n]);s[3]=+s[3]}else(o=t.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((r=o.slice(1,4))[1]*=.01,r[2]*=.01,(s=kp(r))[3]=1):(o=t.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((r=o.slice(1,4))[1]*=.01,r[2]*=.01,(s=kp(r))[3]=+o[4]);return s},ad=function(t){var e;return e=t[3]<1?"rgba":"rgb","rgb"===e?e+"("+t.slice(0,3).map(xd).join(",")+")":"rgba"===e?e+"("+t.slice(0,3).map(xd).join(",")+","+t[3]+")":void 0},bd=function(t){return xd(100*t)/100},Np=function(t,e){var i;return i=e<1?"hsla":"hsl",t[0]=bd(t[0]||0),t[1]=bd(100*t[1])+"%",t[2]=bd(100*t[2])+"%","hsla"===i&&(t[3]=e),i+"("+t.join(",")+")"},fp.css=function(t){return Tp(t)},Sp.css=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["css"]),function(){})},op.prototype.css=function(t){return null==t&&(t="rgb"),"rgb"===t.slice(0,3)?ad(this._rgb):"hsl"===t.slice(0,3)?Np(this.hsl(),this.alpha()):void 0},fp.named=function(t){return Op(Td[t])},pp.push({p:5,test:function(t){if(1===arguments.length&&null!=Td[t])return"named"}}),op.prototype.name=function(t){var e,i;arguments.length&&(Td[t]&&(this._rgb=Op(Td[t])),this._rgb[3]=1),e=this.hex();for(i in Td)if(e===Td[i])return i;return e},Wp=function(){var t,e,i,r;return r=Pd(arguments),i=r[0],t=r[1],e=r[2],e*=ap,[i,Pp(e)*t,wd(e)*t]},Xp=function(){var t,e,i,r,n,o,a,s,c,u,h;return i=Pd(arguments),s=i[0],n=i[1],a=i[2],u=Wp(s,n,a),t=u[0],e=u[1],r=u[2],h=$p(t,e,r),c=h[0],o=h[1],r=h[2],[c,o,r,i.length>3?i[3]:1]},Vp=function(){var t,e,i,r,n,o;return o=Pd(arguments),n=o[0],t=o[1],e=o[2],i=Sd(t*t+e*e),r=(vp(e,t)*hp+360)%360,0===xd(1e4*i)&&(r=Number.NaN),[n,i,r]},dd=function(){var t,e,i,r,n,o,a;return o=Pd(arguments),n=o[0],i=o[1],e=o[2],a=pd(n,i,e),r=a[0],t=a[1],e=a[2],Vp(r,t,e)},Sp.lch=function(){var t;return t=Pd(arguments),new op(t,"lch")},Sp.hcl=function(){var t;return t=Pd(arguments),new op(t,"hcl")},fp.lch=Xp,fp.hcl=function(){var t,e,i,r;return r=Pd(arguments),e=r[0],t=r[1],i=r[2],Xp([i,t,e])},op.prototype.lch=function(){return dd(this._rgb)},op.prototype.hcl=function(){return dd(this._rgb).reverse()},od=function(t){var e,i,r,n,o,a,s,c,u;return null==t&&(t="rgb"),c=Pd(arguments),s=c[0],n=c[1],e=c[2],s/=255,n/=255,e/=255,o=1-Math.max(s,Math.max(n,e)),r=o<1?1/(1-o):0,i=(1-s-o)*r,a=(1-n-o)*r,u=(1-e-o)*r,[i,a,u,o]},Mp=function(){var t,e,i,r,n,o,a,s,c;return e=Pd(arguments),r=e[0],a=e[1],c=e[2],o=e[3],t=e.length>4?e[4]:1,1===o?[0,0,0,t]:(s=r>=1?0:255*(1-r)*(1-o),n=a>=1?0:255*(1-a)*(1-o),i=c>=1?0:255*(1-c)*(1-o),[s,n,i,t])},fp.cmyk=function(){return Mp(Pd(arguments))},Sp.cmyk=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["cmyk"]),function(){})},op.prototype.cmyk=function(){return od(this._rgb)},fp.gl=function(){var t,e,i,r,n;for(r=function(){var t,i;t=Pd(arguments),i=[];for(e in t)n=t[e],i.push(n);return i}.apply(this,arguments),t=i=0;i<=2;t=++i)r[t]*=255;return r},Sp.gl=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["gl"]),function(){})},op.prototype.gl=function(){var t;return t=this._rgb,[t[0]/255,t[1]/255,t[2]/255,t[3]]},fd=function(t,e,i){var r;return r=Pd(arguments),t=r[0],e=r[1],i=r[2],t=Kp(t),e=Kp(e),i=Kp(i),.2126*t+.7152*e+.0722*i},Kp=function(t){return t/=255,t<=.03928?t/12.92:nd((t+.055)/1.055,2.4)},mp=[],Bp=function(t,e,i,r){var n,o,a,s;for(null==i&&(i=.5),null==r&&(r="rgb"),"object"!==Md(t)&&(t=Sp(t)),"object"!==Md(e)&&(e=Sp(e)),a=0,o=mp.length;a<o;a++)if(n=mp[a],r===n[0]){s=n[1](t,e,i,r);break}if(null==s)throw"color mode "+r+" is not supported";return s.alpha(t.alpha()+i*(e.alpha()-t.alpha()))},Sp.interpolate=Bp,op.prototype.interpolate=function(t,e,i){return Bp(this,t,e,i)},Sp.mix=Bp,op.prototype.mix=op.prototype.interpolate,Gp=function(t,e,i,r){var n,o;return n=t._rgb,o=e._rgb,new op(n[0]+i*(o[0]-n[0]),n[1]+i*(o[1]-n[1]),n[2]+i*(o[2]-n[2]),r)},mp.push(["rgb",Gp]),op.prototype.luminance=function(t,e){var i,r,n,o;return null==e&&(e="rgb"),arguments.length?(0===t?this._rgb=[0,0,0,this._rgb[3]]:1===t?this._rgb=[255,255,255,this._rgb[3]]:(r=1e-7,n=20,o=function(i,a){var s,c;return c=i.interpolate(a,.5,e),s=c.luminance(),Math.abs(t-s)<r||!n--?c:s>t?o(i,c):o(c,a)},i=fd(this._rgb),this._rgb=(i>t?o(Sp("black"),this):o(this,Sp("white"))).rgba()),this):fd(this._rgb)},Ad=function(t){var e,i,r,n;return n=t/100,n<66?(r=255,i=-155.25485562709179-.44596950469579133*(i=n-2)+104.49216199393888*Zp(i),e=n<20?0:.8274096064007395*(e=n-10)-254.76935184120902+115.67994401066147*Zp(e)):(r=351.97690566805693+.114206453784165*(r=n-55)-40.25366309332127*Zp(r),i=325.4494125711974+.07943456536662342*(i=n-50)-28.0852963507957*Zp(i),e=255),[r,i,e]},gd=function(){var t,e,i,r,n,o,a;for(r=(n=Pd(arguments))[0],n[1],t=n[2],i=1e3,e=4e4,.4;e-i>.4;)(o=Ad(a=.5*(e+i)))[2]/o[0]>=t/r?e=a:i=a;return xd(a)},Sp.temperature=Sp.kelvin=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["temperature"]),function(){})},fp.temperature=fp.kelvin=fp.K=Ad,op.prototype.temperature=function(){return gd(this._rgb)},op.prototype.kelvin=op.prototype.temperature,Sp.contrast=function(t,e){var i,r,n,o;return"string"!==(n=Md(t))&&"number"!==n||(t=new op(t)),"string"!==(o=Md(e))&&"number"!==o||(e=new op(e)),i=t.luminance(),r=e.luminance(),i>r?(i+.05)/(r+.05):(r+.05)/(i+.05)},Sp.distance=function(t,e,i){var r,n,o,a,s,c,u;null==i&&(i="lab"),"string"!==(s=Md(t))&&"number"!==s||(t=new op(t)),"string"!==(c=Md(e))&&"number"!==c||(e=new op(e)),o=t.get(i),a=e.get(i),u=0;for(n in o)u+=(r=(o[n]||0)-(a[n]||0))*r;return Math.sqrt(u)},Sp.deltaE=function(t,e,i,r){var n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I;for(null==i&&(i=1),null==r&&(r=1),"string"!==(x=Md(t))&&"number"!==x||(t=new op(t)),"string"!==(_=Md(e))&&"number"!==_||(e=new op(e)),n=(w=t.lab())[0],a=w[1],c=w[2],o=(S=e.lab())[0],s=S[1],u=S[2],h=Sd(a*a+c*c),l=Sd(s*s+u*u),P=n<16?.511:.040975*n/(1+.01765*n),A=.0638*h/(1+.0131*h)+.638,b=h<1e-6?0:180*vp(c,a)/cp;b<0;)b+=360;for(;b>=360;)b-=360;return T=b>=164&&b<=345?.56+gp(.2*Pp(cp*(b+168)/180)):.36+gp(.4*Pp(cp*(b+35)/180)),p=h*h*h*h,y=Sd(p/(p+1900)),M=A*(y*T+1-y),v=n-o,g=h-l,f=a-s,m=c-u,d=f*f+m*m-g*g,E=v/(i*P),C=g/(r*A),I=M,Sd(E*E+C*C+d/(I*I))},op.prototype.get=function(t){var e,i,r,n,o,a;return r=this,o=t.split("."),n=o[0],e=o[1],a=r[n](),e?(i=n.indexOf(e),i>-1?a[i]:console.warn("unknown channel "+e+" in mode "+n)):a},op.prototype.set=function(t,e){var i,r,n,o,a,s;if(n=this,a=t.split("."),o=a[0],i=a[1])if(s=n[o](),(r=o.indexOf(i))>-1)if("string"===Md(e))switch(e.charAt(0)){case"+":case"-":s[r]+=+e;break;case"*":s[r]*=+e.substr(1);break;case"/":s[r]/=+e.substr(1);break;default:s[r]=+e}else s[r]=e;else console.warn("unknown channel "+i+" in mode "+o);else s=e;return Sp(s,o).alpha(n.alpha())},op.prototype.clipped=function(){return this._rgb._clipped||!1},op.prototype.alpha=function(t){return arguments.length?Sp.rgb([this._rgb[0],this._rgb[1],this._rgb[2],t]):this._rgb[3]},op.prototype.darken=function(t){var e,i;return null==t&&(t=1),i=this,e=i.lab(),e[0]-=sp.Kn*t,Sp.lab(e).alpha(i.alpha())},op.prototype.brighten=function(t){return null==t&&(t=1),this.darken(-t)},op.prototype.darker=op.prototype.darken,op.prototype.brighter=op.prototype.brighten,op.prototype.saturate=function(t){var e,i;return null==t&&(t=1),i=this,e=i.lch(),e[1]+=t*sp.Kn,e[1]<0&&(e[1]=0),Sp.lch(e).alpha(i.alpha())},op.prototype.desaturate=function(t){return null==t&&(t=1),this.saturate(-t)},op.prototype.premultiply=function(){var t,e;return e=this.rgb(),t=this.alpha(),Sp(e[0]*t,e[1]*t,e[2]*t,t)},xp=function(t){return function(e,i){var r,n;return r=Sp(i).rgb(),n=Sp(e).rgb(),Sp(t(r,n),"rgb")}},Ip=function(t){return function(e,i){var r,n,o;for(o=[],r=n=0;n<=3;r=++n)o[r]=t(e[r],i[r]);return o}},ed=function(t,e){return t},td=function(t,e){return t*e/255},Ep=function(t,e){return t>e?e:t},qp=function(t,e){return t>e?t:e},_d=function(t,e){return 255*(1-(1-t/255)*(1-e/255))},rd=function(t,e){return e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255))},wp=function(t,e){return 255*(1-(1-e/255)/(t/255))},Cp=function(t,e){return 255===t?255:(t=e/255*255/(1-t/255),t>255?255:t)},(bp=function(t,e,i){if(!bp[i])throw"unknown blend mode "+i;return bp[i](t,e)}).normal=xp(Ip(ed)),bp.multiply=xp(Ip(td)),bp.screen=xp(Ip(_d)),bp.overlay=xp(Ip(rd)),bp.darken=xp(Ip(Ep)),bp.lighten=xp(Ip(qp)),bp.dodge=xp(Ip(Cp)),bp.burn=xp(Ip(wp)),Sp.blend=bp,Sp.analyze=function(t){var e,i,r,n;for(r={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},i=0,e=t.length;i<e;i++)null==(n=t[i])||isNaN(n)||(r.values.push(n),r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.count+=1);return r.domain=[r.min,r.max],r.limits=function(t,e){return Sp.limits(r,t,e)},r},Sp.scale=function(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_;return u="rgb",h=Sp("#ccc"),f=0,!1,a=[0,1],d=[],p=[0,0],i=!1,n=[],l=!1,c=0,s=1,o=!1,r={},m=!0,x=function(t){var e,i,r,o,a,s;if(null==t&&(t=["#fff","#000"]),null!=t&&"string"===Md(t)&&null!=Sp.brewer&&(t=Sp.brewer[t]||Sp.brewer[t.toLowerCase()]||t),"array"===Md(t)){for(e=r=0,o=(t=t.slice(0)).length-1;0<=o?r<=o:r>=o;e=0<=o?++r:--r)i=t[e],"string"===Md(i)&&(t[e]=Sp(i));for(d.length=0,e=s=0,a=t.length-1;0<=a?s<=a:s>=a;e=0<=a?++s:--s)d.push(e/(t.length-1))}return b(),n=t},v=function(t){var e,r;if(null!=i){for(r=i.length-1,e=0;e<r&&t>=i[e];)e++;return e-1}return 0},_=function(t){return t},function(t){var e,r,n,o,a;return a=t,i.length>2&&(o=i.length-1,e=v(t),n=i[0]+(i[1]-i[0])*(0+.5*f),r=i[o-1]+(i[o]-i[o-1])*(1-.5*f),a=c+(i[e]+.5*(i[e+1]-i[e])-n)/(r-n)*(s-c)),a},y=function(t,e){var o,a,l,f,g,y,b;if(null==e&&(e=!1),isNaN(t))return h;if(e?b=t:i&&i.length>2?(b=v(t)/(i.length-2),b=p[0]+b*(1-p[0]-p[1])):s!==c?(b=(t-c)/(s-c),b=p[0]+b*(1-p[0]-p[1]),b=Math.min(1,Math.max(0,b))):b=1,e||(b=_(b)),l=Math.floor(1e4*b),m&&r[l])o=r[l];else{if("array"===Md(n))for(a=f=0,y=d.length-1;0<=y?f<=y:f>=y;a=0<=y?++f:--f){if(g=d[a],b<=g){o=n[a];break}if(b>=g&&a===d.length-1){o=n[a];break}if(b>g&&b<d[a+1]){b=(b-g)/(d[a+1]-g),o=Sp.interpolate(n[a],n[a+1],b,u);break}}else"function"===Md(n)&&(o=n(b));m&&(r[l]=o)}return o},b=function(){return r={}},x(t),g=function(t){var e;return e=Sp(y(t)),l&&e[l]?e[l]():e},g.classes=function(t){var e;return null!=t?("array"===Md(t)?(i=t,a=[t[0],t[t.length-1]]):(e=Sp.analyze(a),i=0===t?[e.min,e.max]:Sp.limits(e,"e",t)),g):i},g.domain=function(t){var e,i,r,o,u,h,l;if(!arguments.length)return a;if(c=t[0],s=t[t.length-1],d=[],r=n.length,t.length===r&&c!==s)for(u=0,o=t.length;u<o;u++)i=t[u],d.push((i-c)/(s-c));else for(e=l=0,h=r-1;0<=h?l<=h:l>=h;e=0<=h?++l:--l)d.push(e/(r-1));return a=[c,s],g},g.mode=function(t){return arguments.length?(u=t,b(),g):u},g.range=function(t,e){return x(t),g},g.out=function(t){return l=t,g},g.spread=function(t){return arguments.length?(f=t,g):f},g.correctLightness=function(t){return null==t&&(t=!0),o=t,b(),_=o?function(t){var e,i,r,n,o,a,s,c,u;for(e=y(0,!0).lab()[0],i=y(1,!0).lab()[0],s=e>i,r=y(t,!0).lab()[0],n=r-(o=e+(i-e)*t),c=0,u=1,a=20;Math.abs(n)>.01&&a-- >0;)!function(){s&&(n*=-1),n<0?(c=t,t+=.5*(u-t)):(u=t,t+=.5*(c-t)),r=y(t,!0).lab()[0],n=r-o}();return t}:function(t){return t},g},g.padding=function(t){return null!=t?("number"===Md(t)&&(t=[t,t]),p=t,g):p},g.colors=function(e,r){var o,s,c,u,h,l,p;if(null==r&&(r="hex"),0===arguments.length)return n.map(function(t){return t[r]()});if(e)return 1===e?g(.5)[r]():(s=a[0],o=a[1]-s,function(){h=[];for(var t=0;0<=e?t<e:t>e;0<=e?t++:t--)h.push(t);return h}.apply(this).map(function(t){return g(s+t/(e-1)*o)[r]()}));if(t=[],l=[],i&&i.length>2)for(c=p=1,u=i.length;1<=u?p<u:p>u;c=1<=u?++p:--p)l.push(.5*(i[c-1]+i[c]));else l=a;return l.map(function(t){return g(t)[r]()})},g.cache=function(t){return null!=t?m=t:m},g},null==Sp.scales&&(Sp.scales={}),Sp.scales.cool=function(){return Sp.scale([Sp.hsl(180,1,.9),Sp.hsl(250,.7,.4)])},Sp.scales.hot=function(){return Sp.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},Sp.analyze=function(t,e,i){var r,n,o,a,s,c;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==i&&(i=function(){return!0}),r=function(t){null==t||isNaN(t)||(s.values.push(t),s.sum+=t,t<s.min&&(s.min=t),t>s.max&&(s.max=t),s.count+=1)},c=function(t,n){if(i(t,n))return r(null!=e&&"function"===Md(e)?e(t):null!=e&&"string"===Md(e)||"number"===Md(e)?t[e]:t)},"array"===Md(t))for(a=0,o=t.length;a<o;a++)c(t[a]);else for(n in t)c(t[n],n);return s.domain=[s.min,s.max],s.limits=function(t,e){return Sp.limits(s,t,e)},s},Sp.limits=function(t,e,i){var r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,P,T,E,C,I,R,L,O,D,N,k,F,B,z,U,j,G,V,$,H,W,X,q,Y,Z,K,Q,J,tt,et,it,rt;if(null==e&&(e="equal"),null==i&&(i=7),"array"===Md(t)&&(t=Sp.analyze(t)),T=t.min,Jp=t.max,t.sum,it=t.values.sort(function(t,e){return t-e}),1===i)return[T,Jp];if(M=[],"c"===e.substr(0,1)&&(M.push(T),M.push(Jp)),"e"===e.substr(0,1)){for(M.push(T),w=O=1,F=i-1;1<=F?O<=F:O>=F;w=1<=F?++O:--O)M.push(T+w/i*(Jp-T));M.push(Jp)}else if("l"===e.substr(0,1)){if(T<=0)throw"Logarithmic scales are only possible for values > 0";for(E=Math.LOG10E*Zp(T),P=Math.LOG10E*Zp(Jp),M.push(T),w=rt=1,B=i-1;1<=B?rt<=B:rt>=B;w=1<=B?++rt:--rt)M.push(nd(10,E+w/i*(P-E)));M.push(Jp)}else if("q"===e.substr(0,1)){for(M.push(T),w=r=1,$=i-1;1<=$?r<=$:r>=$;w=1<=$?++r:--r)D=(it.length-1)*w/i,(N=Rp(D))===D?M.push(it[N]):(k=D-N,M.push(it[N]*(1-k)+it[N+1]*k));M.push(Jp)}else if("k"===e.substr(0,1)){for(I=it.length,g=new Array(I),x=new Array(i),Q=!0,R=0,y=null,(y=[]).push(T),w=n=1,H=i-1;1<=H?n<=H:n>=H;w=1<=H?++n:--n)y.push(T+w/i*(Jp-T));for(y.push(Jp);Q;){for(S=o=0,W=i-1;0<=W?o<=W:o>=W;S=0<=W?++o:--o)x[S]=0;for(w=a=0,X=I-1;0<=X?a<=X:a>=X;w=0<=X?++a:--a){for(et=it[w],C=Number.MAX_VALUE,S=s=0,q=i-1;0<=q?s<=q:s>=q;S=0<=q?++s:--s)(_=gp(y[S]-et))<C&&(C=_,v=S);x[v]++,g[w]=v}for(L=new Array(i),S=c=0,Y=i-1;0<=Y?c<=Y:c>=Y;S=0<=Y?++c:--c)L[S]=null;for(w=u=0,Z=I-1;0<=Z?u<=Z:u>=Z;w=0<=Z?++u:--u)null===L[b=g[w]]?L[b]=it[w]:L[b]+=it[w];for(S=h=0,K=i-1;0<=K?h<=K:h>=K;S=0<=K?++h:--h)L[S]*=1/x[S];for(Q=!1,S=l=0,z=i-1;0<=z?l<=z:l>=z;S=0<=z?++l:--l)if(L[S]!==y[w]){Q=!0;break}y=L,++R>200&&(Q=!1)}for(A={},S=p=0,U=i-1;0<=U?p<=U:p>=U;S=0<=U?++p:--p)A[S]=[];for(w=d=0,j=I-1;0<=j?d<=j:d>=j;w=0<=j?++d:--d)A[b=g[w]].push(it[w]);for(J=[],S=f=0,G=i-1;0<=G?f<=G:f>=G;S=0<=G?++f:--f)J.push(A[S][0]),J.push(A[S][A[S].length-1]);for(J=J.sort(function(t,e){return t-e}),M.push(J[0]),w=m=1,V=J.length-1;m<=V;w=m+=2)tt=J[w],isNaN(tt)||-1!==M.indexOf(tt)||M.push(tt)}return M},Dp=function(t,e,i){var r,n,o,a;return r=Pd(arguments),t=r[0],e=r[1],i=r[2],isNaN(t)&&(t=0),t/=360,t<1/3?o=1-((n=(1-e)/3)+(a=(1+e*Pp(lp*t)/Pp(up-lp*t))/3)):t<2/3?n=1-((a=(1-e)/3)+(o=(1+e*Pp(lp*(t-=1/3))/Pp(up-lp*t))/3)):a=1-((o=(1-e)/3)+(n=(1+e*Pp(lp*(t-=2/3))/Pp(up-lp*t))/3)),a=Yp(i*a*3),o=Yp(i*o*3),n=Yp(i*n*3),[255*a,255*o,255*n,r.length>3?r[3]:1]},ud=function(){var t,e,i,r,n,o,a,s;return a=Pd(arguments),o=a[0],e=a[1],t=a[2],lp=2*Math.PI,o/=255,e/=255,t/=255,n=Math.min(o,e,t),r=(o+e+t)/3,s=1-n/r,0===s?i=0:(i=(o-e+(o-t))/2,i/=Math.sqrt((o-e)*(o-e)+(o-t)*(e-t)),i=Math.acos(i),t>e&&(i=lp-i),i/=lp),[360*i,s,r]},Sp.hsi=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(op,Ld.call(arguments).concat(["hsi"]),function(){})},fp.hsi=Dp,op.prototype.hsi=function(){return ud(this._rgb)},zp=function(t,e,i,r){var n,o,a,s,c,u,h,l,p,d,f;return"hsl"===r?(d=t.hsl(),f=e.hsl()):"hsv"===r?(d=t.hsv(),f=e.hsv()):"hcg"===r?(d=t.hcg(),f=e.hcg()):"hsi"===r?(d=t.hsi(),f=e.hsi()):"lch"!==r&&"hcl"!==r||(r="hcl",d=t.hcl(),f=e.hcl()),"h"===r.substr(0,1)&&(o=d[0],l=d[1],c=d[2],a=f[0],p=f[1],u=f[2]),isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?n=Number.NaN:(n=a,1!==c&&0!==c||"hsv"===r||(h=p)):(n=o,1!==u&&0!==u||"hsv"===r||(h=l)):n=o+i*(a>o&&a-o>180?a-(o+360):a<o&&o-a>180?a+360-o:a-o),null==h&&(h=l+i*(p-l)),s=c+i*(u-c),Sp[r](n,h,s)},jp=function(t,e,i,r){var n,o;return n=t.num(),o=e.num(),Sp.num(n+(o-n)*i,"num")},(mp=mp.concat(function(){var t,e,i,r;for(r=[],e=0,t=(i=["hsv","hsl","hsi","hcl","lch","hcg"]).length;e<t;e++)Qp=i[e],r.push([Qp,zp]);return r}())).push(["num",jp]),Up=function(t,e,i,r){var n,o;return n=t.lab(),o=e.lab(),new op(n[0]+i*(o[0]-n[0]),n[1]+i*(o[1]-n[1]),n[2]+i*(o[2]-n[2]),r)},mp.push(["lab",Up]);var Od=Sp,Dd=function(t){var e=t||{};this.scale=gn(e.scale,"uniform"),this.mode=gn(e.mode,"hcl"),this.domain=gn(e.domain,[0,1]),this.value=new tt(gn(e.value,16777215)).getHex(),this.reverse=gn(e.reverse,!1),this.structure=e.structure,this.volume=e.volume,this.surface=e.surface,this.structure&&(this.atomProxy=this.structure.getAtomProxy())};Dd.prototype.getScale=function(t){var e=t||{},i=gn(e.scale,this.scale);"rainbow"===i?i=["red","orange","yellow","green","blue"]:"rwb"===i&&(i=["red","white","blue"]);var r=gn(e.domain,this.domain);return this.reverse&&(r=r.slice().reverse()),Od.scale(i).mode(gn(e.mode,this.mode)).domain(r).out("num")},Dd.prototype.colorToArray=function(t,e,i){return void 0===e&&(e=[]),void 0===i&&(i=0),e[i+0]=(t>>16&255)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(255&t)/255,e},Dd.prototype.atomColorToArray=function(t,e,i){return this.colorToArray(this.atomColor(t),e,i)},Dd.prototype.bondColor=function(t,e){return this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)},Dd.prototype.bondColorToArray=function(t,e,i,r){return this.colorToArray(this.bondColor(t,e),i,r)},Dd.prototype.volumeColorToArray=function(t,e,i){return this.colorToArray(this.volumeColor(t),e,i)},Dd.prototype.positionColorToArray=function(t,e,i){return this.colorToArray(this.positionColor(t),e,i)},ro.prototype={active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,i),this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},oo.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,e,i,r){var n,o=this._indexOfListener(t,i);if(-1!==o){if((n=this._bindings[o]).isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else n=new ro(this,t,e,i,r),this._addBinding(n);return this.memorize&&this._prevParams&&n.execute(this._prevParams),n},_addBinding:function(t){var e=this._bindings.length;do{--e}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var i,r=this,n=this._bindings.length;n--;)if((i=r._bindings[n])._listener===t&&i.context===e)return n;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){return no(t,"add"),this._registerListener(t,!1,e,i)},addOnce:function(t,e,i){return no(t,"addOnce"),this._registerListener(t,!0,e,i)},remove:function(t,e){no(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(){for(var t=this,e=this._bindings.length;e--;)t._bindings[e]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(t){if(this.active){var e,i=Array.prototype.slice.call(arguments),r=this._bindings.length;if(this.memorize&&(this._prevParams=i),r){e=this._bindings.slice(),this._shouldPropagate=!0;do{r--}while(e[r]&&this._shouldPropagate&&!1!==e[r].execute(i))}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var Nd={PROTEIN:1,NUCLEIC:2,RNA:3,DNA:4,POLYMER:5,WATER:6,HELIX:7,SHEET:8,TURN:9,BACKBONE:10,SIDECHAIN:11,ALL:12,HETERO:13,ION:14,SACCHARIDE:15,SUGAR:15,BONDED:16,RING:17},kd=["*","","ALL"],Fd=[Nd.BACKBONE,Nd.SIDECHAIN,Nd.BONDED,Nd.RING],Bd=[Nd.POLYMER,Nd.WATER],zd=["ALA","GLY","SER"],Ud=["CYS","SER","THR"],jd=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Gd=["PHE","TRP","TYR","HIS"],Vd=["ASN","GLN"],$d=["ASP","GLU"],Hd=["ARG","HIS","LYS"],Wd=["ARG","ASP","GLU","HIS","LYS"],Xd=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],qd=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],Yd=["HIS","PHE","PRO","TRP","TYR"],Zd=["ALA","GLY","ILE","LEU","VAL"],Kd=function(t){this.signals={stringChanged:new oo},this.setString(t)},Qd={type:{}};Qd.type.get=function(){return"selection"},Kd.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.parse(t)}catch(t){this.selection={error:t.message}}this.string=t,this.test=this.makeAtomTest(),this.residueTest=this.makeResidueTest(),this.chainTest=this.makeChainTest(),this.modelTest=this.makeModelTest(),this.atomOnlyTest=this.makeAtomTest(!0),this.residueOnlyTest=this.makeResidueTest(!0),this.chainOnlyTest=this.makeChainTest(!0),this.modelOnlyTest=this.makeModelTest(!0),e||this.signals.stringChanged.dispatch(this.string)}},Kd.prototype.parse=function(t){var e=this;if(this.selection={operator:void 0,rules:[]},t){var i,r,n=this.selection,o=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());for(var a,s=t.split(/\s+/),c=function(t){i={operator:t,rules:[]},void 0===n?(n=i,e.selection=i):(n.rules.push(i),o.push(n),n=i)},u=function(t){r=n,void 0===(n=o.pop())&&(c(t),h(r))},h=function(t){n.rules.push(t)},l=0;l<s.length;++l){var p=s[l],d=p.toUpperCase();if("("!==p)if(")"!==p){if(a>0)if("NOT"===d)a=1;else if(1===a)a=2;else{if(2!==a)throw new Error("something went wrong with 'not'");a=!1,u()}if("AND"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){var f=Nd[d];if(void 0===f)if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("LIGAND"!==d)if(-1===kd.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(p.length>=1&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))h({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(g.length>1&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var v=g[0].split("%");v.length>1&&m.rules.push({altloc:v[1]});var y=v[0].split(".");if(y.length>1&&y[1]){if(y[1].length>4)throw new Error("atomname must be one to four characters");m.rules.push({atomname:y[1].substring(0,4).toUpperCase()})}var b=y[0].split(":");b.length>1&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(x.length>1&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var S=x[0].split("-");if(1===S.length){if(S=parseInt(S[0]),isNaN(S))throw new Error("resi must be an integer");_&&(S*=-1),m.rules.push({resno:S})}else{if(2!==S.length)throw new Error("resi range must contain one '-'");_&&(S[0]*=-1),w&&(S[1]*=-1),m.rules.push({resno:[parseInt(S[0]),parseInt(S[1])]})}}if(1===m.rules.length)h(m.rules[0]);else{if(!(m.rules.length>1))throw new Error("empty selection chunk");h(m)}}else{var A=d.substr(1,p.length-2).split(","),M=A.length>1?A:A[0];h({resname:M})}else h({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),h({element:d.substr(1)});else{for(var P=p.substr(1).split(","),T=0,E=P.length;T<E;++T)P[T]=parseInt(P[T]);P.sort(function(t,e){return t-e}),h({atomindex:P})}else h({keyword:Nd.ALL});else h({operator:"AND",rules:[{operator:"OR",rules:[{keyword:Nd.HETERO},{negate:!0,operator:void 0,rules:[{keyword:Nd.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:Nd.WATER},{keyword:Nd.ION}]}]}]});else h({operator:"OR",rules:[{keyword:Nd.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:Nd.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:Nd.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"C5'"},{atomname:"C5*"}]}]}]});else h({resname:Zd});else h({resname:Yd});else h({resname:qd});else h({resname:Xd});else h({resname:Wd});else h({resname:Hd});else h({resname:$d});else h({resname:Vd});else h({resname:Gd});else h({resname:jd});else h({resname:Ud});else h({resname:zd});else h({element:"H"});else h({keyword:f})}else a=1,c(),n.negate=!0;else"AND"===n.operator?u("OR"):n.operator="OR";else if("OR"===n.operator){var C=n.rules.pop();c("AND"),h(C)}else n.operator="AND"}else u(),n.negate&&u();else a=!1,c()}void 0===this.selection.operator&&1===this.selection.rules.length&&this.selection.rules[0].hasOwnProperty("operator")&&(this.selection=this.selection.rules[0])}},Kd.prototype._makeTest=function(t,e){var i=this;if(void 0===e&&(e=this.selection),null===e)return!1;if(e.error)return!1;var r=e.rules.length;if(0===r)return!1;for(var n=!e.negate,o=!!e.negate,a=[],s=0;s<r;++s){var c=e.rules[s];c.hasOwnProperty("operator")&&(a[s]=i._makeTest(t,c))}return function(i){for(var s="AND"===e.operator,c=!1,u=0;u<r;++u){var h=e.rules[u],l=void 0;if(h.hasOwnProperty("operator")){if(-1===(l=a[u]?a[u](i):-1)){c=!0;continue}if(!0===l){if(s)continue;return n}if(s)return o}else{if(h.keyword===Nd.ALL){if(s)continue;return n}if(-1!==(l=t(i,h))){if(!0===l){if(s)continue;return n}if(s)return o}else c=!0}}return c?-1:s?n:o}},Kd.prototype._filter=function(t,e){var i=this;if(void 0===e&&(e=this.selection),e.error)return e;var r=e.rules.length;if(0===r)return e;var n={operator:e.operator,rules:[]};e.hasOwnProperty("negate")&&(n.negate=e.negate);for(var o=0;o<r;++o){var a=e.rules[o];if(a.hasOwnProperty("operator")){var s=i._filter(t,a);null!==s&&n.rules.push(s)}else t(a)||n.rules.push(a)}return n.rules.length>0?e:null},Kd.prototype.makeAtomTest=function(t){var e;return e=t?this._filter(function(t){return void 0!==t.keyword&&!Fd.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))}):this.selection,this._makeTest(ao,e)},Kd.prototype.makeResidueTest=function(t){var e;return e=t?this._filter(function(t){return!(void 0===t.keyword||!Fd.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))}):this.selection,this._makeTest(so,e)},Kd.prototype.makeChainTest=function(t){var e;return e=t?this._filter(function(t){return void 0!==t.keyword&&!Bd.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))))))}):this.selection,this._makeTest(co,e)},Kd.prototype.makeModelTest=function(t){var e;return e=t?this._filter(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)))))))}):this.selection,this._makeTest(uo,e)},Object.defineProperties(Kd.prototype,Qd);var Jd=function(t){function e(e){var i=this;t.call(this,e);var r=e.dataList||[];this.colormakerList=[],this.selectionList=[],r.forEach(function(t){var e=t[0],r=t[1],n=t[2];void 0===n&&(n={}),lf.hasScheme(e)?Object.assign(n,{scheme:e,structure:i.structure}):Object.assign(n,{scheme:"uniform",value:new tt(e).getHex()}),i.colormakerList.push(lf.getScheme(n)),i.selectionList.push(new Kd(r))})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){for(var e=this,i=0,r=this.selectionList.length;i<r;++i)if(e.selectionList[i].test(t))return e.colormakerList[i].atomColor(t);return 16777215},e}(Dd),tf={"":"",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",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",Set1:"[Q] Set1",Set2:"[Q] Set2",Set3:"[Q] Set3",Dark2:"[Q] Dark2",Paired:"[Q] Paired",Pastel1:"[Q] Pastel1",Pastel2:"[Q] Pastel2",Accent:"[Q] Accent",rainbow:"[?] Rainbow",rwb:"[?] Red-White-Blue"},ef={"":"",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"},rf=function(){this.schemes={},this.userSchemes={}};rf.prototype.getScheme=function(t){var e=(t||{}).scheme||"";return new(e in this.schemes?this.schemes[e]:e in this.userSchemes?this.userSchemes[e]:Dd)(t)},rf.prototype.getSchemes=function(){var 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},rf.prototype.getScales=function(){return tf},rf.prototype.getModes=function(){return ef},rf.prototype.add=function(t,e){this.schemes[t]=e},rf.prototype.addScheme=function(t,e){return t instanceof Dd||(t=this._createScheme(t,e)),this._addUserScheme(t,e)},rf.prototype._addUserScheme=function(t,e){e=e||"";var i=Xn()+"|"+e;return this.userSchemes[i]=t,i},rf.prototype.removeScheme=function(t){delete this.userSchemes[t]},rf.prototype._createScheme=function(t,e){var i=function(i){Dd.call(this,i),this.label=e||"",t.call(this,i)};return i.prototype=Dd.prototype,i.prototype.constructor=Dd,i},rf.prototype.addSelectionScheme=function(t,e){var i=function(e){function i(i){e.call(this,Object.assign({dataList:t},i))}return e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i,i}(Jd);return this._addUserScheme(i,e)},rf.prototype.hasScheme=function(t){return t in this.schemes||t in this.userSchemes};var nf=yn(),of="undefined"!=typeof window&&void 0!==window.orientation,af=!1,sf=!1,cf={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)};t.Debug=function(t){return!!t&&("string"!=typeof t||/^1|true|t|yes|y$/i.test(t))}(mn("debug"));var uf='<div style="display:flex;align-items:center;justify-content:center;height:100%;"><p style="padding:15px;text-align:center;">Your browser/graphics card does not seem to support <a target="_blank" href="https://en.wikipedia.org/wiki/WebGL">WebGL</a>.<br/><br/>Find out how to get it <a target="_blank" href="http://get.webgl.org/">here</a>.</p></div>',hf=new np,lf=new rf,pf=new ip("datasource"),df=new ip("representatation"),ff=new ip("parser"),mf=new ip("shader"),gf=new ip("decompressor"),vf=new ip("component"),yf=function(t,e){var i=e||{};this.compressed=gn(i.compressed,!1),this.binary=gn(i.binary,!1),this.json=gn(i.json,!1),this.xml=gn(i.xml,!1),this.src=t,this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.__srcName&&(this[this.__srcName]=t)},bf={type:{},__srcName:{}};bf.type.get=function(){return""},bf.__srcName.get=function(){},yf.prototype.isBinary=function(){return this.binary||this.compressed},yf.prototype.onload=function(){},yf.prototype.onprogress=function(){},yf.prototype.onerror=function(){},yf.prototype.read=function(){var t=this;return new Promise(function(e,i){try{t._read(function(i){var r=gf.get(t.compressed);t.compressed&&r?t.data=r(i):((t.binary||t.compressed)&&i instanceof ArrayBuffer&&(i=new Uint8Array(i)),t.data=i),e(t.data)})}catch(t){i(t)}})},yf.prototype._read=function(t){t(this.src)},yf.prototype._chunk=function(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)},yf.prototype.chunk=function(t){var e=t+this.chunkSize;return this._chunk(t,e)},yf.prototype.peekLines=function(t){var e,i=this.data,r=i.length,n=this.isBinary()?this.newline.charCodeAt(0):this.newline,o=0;for(e=0;e<r&&(i[e]===n&&++o,o!==t);++e);var a=this._chunk(0,e+1);return this.chunkToLines(a,"",e>r).lines},yf.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},yf.prototype.asText=function(){return this.isBinary()?Cn(this.data):this.data},yf.prototype.chunkToLines=function(t,e,i){var r=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(r),partialLine:""};var n=[],o=this.isBinary()?Cn(t):t,a=o.lastIndexOf(r);if(-1===a)e+=o;else{var s=e+o.substr(0,a);n=n.concat(s.split(r)),e=a===o.length-r.length?"":o.substr(a+r.length)}return i&&""!==e&&n.push(e),{lines:n,partialLine:e}},yf.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},yf.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,i=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=i.partialLine,i.lines}},yf.prototype.eachChunk=function(t){for(var e=this,i=this.chunkSize,r=this.data.length,n=this.chunkCount(),o=0;o<r;o+=i)t(e.chunk(o),Math.round(o/i),n)},yf.prototype.eachChunkOfLines=function(t){var e=this;this.eachChunk(function(i,r,n){var o=r===n+1,a=e.chunkToLines(i,e.__partialLine,o);e.__partialLine=a.partialLine,t(a.lines,r,n)})},yf.prototype.dispose=function(){delete this.src,this.__srcName&&delete this[this.__srcName]},Object.defineProperties(yf.prototype,bf);var xf=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__srcName:{}};return i.type.get=function(){return"file"},i.__srcName.get=function(){return"file"},e.prototype._read=function(t){var e,i=this;if("function"==typeof importScripts){e=new window.FileReaderSync;var r;r=this.binary||this.compressed?e.readAsArrayBuffer(this.file):e.readAsText(this.file),t(r)}else(e=new window.FileReader).onload=function(e){t(e.target.result)},"function"==typeof this.onprogress&&(e.onprogress=function(t){i.onprogress(t)}),"function"==typeof this.onerror&&(e.onerror=function(t){i.onerror(t)}),this.binary||this.compressed?e.readAsArrayBuffer(this.file):e.readAsText(this.file)},Object.defineProperties(e.prototype,i),e}(yf),_f=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__srcName:{}};return i.type.get=function(){return"network"},i.__srcName.get=function(){return"url"},e.prototype._read=function(t){var e=this.src;"function"==typeof importScripts&&"../"===e.substr(0,3)&&(e="../"+e);var i=new window.XMLHttpRequest;i.open("GET",e,!0),i.addEventListener("load",function(){if(200!==i.status&&304!==i.status&&0!==i.status)throw"function"==typeof this.onerror&&this.onerror(i.status),new Error("NetworkStreamer._read: status code "+i.status);try{t(i.response)}catch(t){this.onerror(t)}}.bind(this),!1),"function"==typeof this.onerror&&i.addEventListener("error",function(t){this.onerror(t)}.bind(this),!1),this.isBinary()?i.responseType="arraybuffer":this.json?i.responseType="json":this.xml?i.responseType="document":i.responseType="text",i.send(null)},Object.defineProperties(e.prototype,i),e}(yf),wf=["mmtf","dcd","mrc","ccp4","map","dsn6","brix","dxbin"],Sf=["json"],Af=["xml","validation"],Mf=function(t,e){var i=Object.assign({},e),r=wf.includes(i.ext);this.compressed=gn(i.compressed,!1),this.binary=gn(i.binary,r),this.name=gn(i.name,""),this.ext=gn(i.ext,""),this.dir=gn(i.dir,""),this.path=gn(i.path,""),this.protocol=gn(i.protocol,""),this.params=e;var n={compressed:this.compressed,binary:this.binary,json:Sf.includes(this.ext),xml:Af.includes(this.ext)};"undefined"!=typeof File&&t instanceof window.File||"undefined"!=typeof Blob&&t instanceof window.Blob?this.streamer=new xf(t,n):this.streamer=new _f(t,n),"function"==typeof i.onProgress&&(this.streamer.onprogress=i.onprogress)};Mf.prototype.load=function(){return Promise.reject(new Error("not implemented"))};var Pf=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.load=function(){return new(ff.get(this.ext))(this.streamer,this.params).parse()},e}(Mf),Tf=function(t,e,i){this.signals={elementAdded:new oo,elementRemoved:new oo,nameChanged:new oo},this.name=e,this.path=i,this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","panel","__name__","__path__","__dir__",t)}catch(t){cf.error("Script compilation failed",t),this.fn=function(){}}},Ef={type:{}};Ef.type.get=function(){return"Script"},Tf.prototype.call=function(t){var e=this,i={add:function(){this.signals.elementAdded.dispatch(arguments)}.bind(this),remove:function(){this.signals.elementRemoved.dispatch(arguments)}.bind(this),setName:function(t){this.signals.nameChanged.dispatch(t)}.bind(this)};return new Promise(function(r,n){var o=[t,i,e.name,e.path,e.dir];try{e.fn.apply(null,o),r()}catch(t){cf.error("Script.fn",t),n(t)}})},Object.defineProperties(Tf.prototype,Ef);var Cf=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.load=function(){var t=this;return this.streamer.read().then(function(){return new Tf(t.streamer.asText(),t.name,t.path)})},e}(Mf),If=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.load=function(){var t,e=this;return t=this.protocol?this.protocol+"://"+this.dir:this.dir,this.streamer.read().then(function(){var i=JSON.parse(e.streamer.asText()),r=[];return i.files.map(function(e){r.push(mo(t+e,{ext:"text",useWorker:!1}))}),Promise.all(r).then(function(t){var r=t.reduce(function(t,e){return t+"\n\n"+e.data},"");return r+=i.source||"",new Tf(r,e.name,e.path)})})},e}(Mf),Rf={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/bcdiefguxX/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};go.format=function(t,e){var i,r,n,o,a,s,c,u=1,h=t.length,l="",p=[],d=!0,f="";for(r=0;r<h;r++)if("string"===(l=vo(t[r])))p[p.length]=t[r];else if("array"===l){if((o=t[r])[2])for(i=e[u],n=0;n<o[2].length;n++){if(!i.hasOwnProperty(o[2][n]))throw new Error(go('[sprintf] property "%s" does not exist',o[2][n]));i=i[o[2][n]]}else i=o[1]?e[o[1]]:e[u++];if(Rf.not_type.test(o[8])&&Rf.not_primitive.test(o[8])&&"function"==vo(i)&&(i=i()),Rf.numeric_arg.test(o[8])&&"number"!=vo(i)&&isNaN(i))throw new TypeError(go("[sprintf] expecting number but found %s",vo(i)));switch(Rf.number.test(o[8])&&(d=i>=0),o[8]){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,o[6]?parseInt(o[6]):0);break;case"e":i=o[7]?parseFloat(i).toExponential(o[7]):parseFloat(i).toExponential();break;case"f":i=o[7]?parseFloat(i).toFixed(o[7]):parseFloat(i);break;case"g":i=o[7]?parseFloat(i).toPrecision(o[7]):parseFloat(i);break;case"o":i=i.toString(8);break;case"s":i=String(i),i=o[7]?i.substring(0,o[7]):i;break;case"t":i=String(!!i),i=o[7]?i.substring(0,o[7]):i;break;case"T":i=vo(i),i=o[7]?i.substring(0,o[7]):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=o[7]?i.substring(0,o[7]):i;break;case"x":i=parseInt(i,10).toString(16);break;case"X":i=parseInt(i,10).toString(16).toUpperCase()}Rf.json.test(o[8])?p[p.length]=i:(!Rf.number.test(o[8])||d&&!o[3]?f="":(f=d?"+":"-",i=i.toString().replace(Rf.sign,"")),s=o[4]?"0"===o[4]?"0":o[4].charAt(1):" ",c=o[6]-(f+i).length,a=o[6]&&c>0?yo(s,c):"",p[p.length]=o[5]?f+i+a:"0"===s?f+a+i:a+f+i)}return p.join("")},go.cache={},go.parse=function(t){for(var e=t,i=[],r=[],n=0;e;){if(null!==(i=Rf.text.exec(e)))r[r.length]=i[0];else if(null!==(i=Rf.modulo.exec(e)))r[r.length]="%";else{if(null===(i=Rf.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(i[2]){n|=1;var o=[],a=i[2],s=[];if(null===(s=Rf.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o[o.length]=s[1];""!==(a=a.substring(s[0].length));)if(null!==(s=Rf.key_access.exec(a)))o[o.length]=s[1];else{if(null===(s=Rf.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o[o.length]=s[1]}i[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r[r.length]=i}e=e.substring(i[0].length)}return r};var Lf={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," ","  ","   ","    ","     ","      ","       "],_:["","_","__","___","____","_____","______","_______"]},Of=function(){this.count=0,this.signals={countChanged:new oo}};Of.prototype.clear=function(){this.change(-this.count)},Of.prototype.change=function(t){this.count+=t,this.signals.countChanged.dispatch(t,this.count),this.count<0&&cf.warn("Counter.count below zero",this.count)},Of.prototype.increment=function(){this.change(1)},Of.prototype.decrement=function(){this.change(-1)},Of.prototype.listen=function(t){this.change(t.count),t.signals.countChanged.add(this.change,this)},Of.prototype.unlisten=function(t){var e=t.signals.countChanged;e.has(this.change,this)&&e.remove(this.change,this)},Of.prototype.onZeroOnce=function(t,e){if(0===this.count)t.call(e,0,0);else{var i=function(){0===this.count&&(this.signals.countChanged.remove(i,this),t.apply(e,arguments))};this.signals.countChanged.add(i,this)}},Of.prototype.dispose=function(){this.clear(),this.signals.countChanged.dispose()},mf.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),mf.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}"),mf.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),mf.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}"),xo.prototype={update:function(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()},begin:function(){this.startTime=window.performance.now(),this.lastFrames=this.frames},end:function(){var 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}},mf.add("shader/chunk/dull_interior_fragment.glsl","#ifdef DULL_INTERIOR\nif( gl_FrontFacing == false ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#endif"),mf.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"),mf.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}"),mf.add("shader/chunk/nearclip_vertex.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip - 5.0 )\ngl_Position.z = 2.0 * gl_Position.w;\n#endif"),mf.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip )\ndiscard;\n#endif"),mf.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"),mf.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"),mf.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),mf.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}");var Df=/^(?!\/\/)\s*#include\s+(\S+)/gim,Nf={};if("undefined"!=typeof window&&window.WebGLRenderingContext){var kf=window.WebGLRenderingContext.prototype,Ff=kf.getShaderParameter;kf.getShaderParameter=function(){return!t.Debug||Ff.apply(this,arguments)};var Bf=kf.getShaderInfoLog;kf.getShaderInfoLog=function(){return t.Debug?Bf.apply(this,arguments):""};var zf=kf.getProgramParameter;kf.getProgramParameter=function(e,i){return!t.Debug&&i===kf.LINK_STATUS||zf.apply(this,arguments)};var Uf=kf.getProgramInfoLog;kf.getProgramInfoLog=function(){return t.Debug?Uf.apply(this,arguments):""}}var jf=[[[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]]];jf.forEach(function(t){t.forEach(function(t){t[0]*=.0625,t[1]*=.0625})}),So.prototype.constructor=So;var Gf=2*Math.PI,Vf=(new Float32Array(4),new Float32Array(4),new g),$f=new v,Hf=new v,Wf=new v,Xf=new v,qf=new Float32Array(4),Yf=new Uint8Array(4),Zf=new v;Ho.prototype.constructor=Ho;var Kf=function(t,e){this.signals={moved:new oo,scrolled:new oo,dragged:new oo,dropped:new oo,clicked:new oo,hovered:new oo};var i=Object.assign({},e);this.hoverTimeout=gn(i.hoverTimeout,50),this.handleScroll=gn(i.handleScroll,!0),this.domElement=t,this.position=new l,this.prevPosition=new l,this.down=new l,this.canvasPosition=new l,this.moving=!1,this.hovering=!0,this.scrolled=!1,this.lastMoved=1/0,this.which=void 0,this.buttons=void 0,this.pressed=void 0,this.altKey=void 0,this.ctrlKey=void 0,this.metaKey=void 0,this.shiftKey=void 0,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(),document.addEventListener("mousewheel",this._onMousewheel),document.addEventListener("wheel",this._onMousewheel),document.addEventListener("MozMousePixelScroll",this._onMousewheel),document.addEventListener("mousemove",this._onMousemove),document.addEventListener("mousedown",this._onMousedown),document.addEventListener("mouseup",this._onMouseup),document.addEventListener("contextmenu",this._onContextmenu),document.addEventListener("touchstart",this._onTouchstart),document.addEventListener("touchend",this._onTouchend),document.addEventListener("touchmove",this._onTouchmove)},Qf={key:{}};Qf.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},Kf.prototype.setParameters=function(t){var e=Object.assign({},t);this.hoverTimeout=gn(e.hoverTimeout,this.hoverTimeout)},Kf.prototype._listen=function(){if(window.performance.now()-this.lastMoved>this.hoverTimeout&&(this.moving=!1),(this.scrolled||!this.moving&&!this.hovering)&&(this.scrolled=!1,-1!==this.hoverTimeout&&this.overElement)){this.hovering=!0;var t=this.canvasPosition;this.signals.hovered.dispatch(t.x,t.y)}window.requestAnimationFrame(this._listen)},Kf.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var i=0;i=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail/3:-t.deltaY/(t.deltaMode?.33:30),this.signals.scrolled.dispatch(i),setTimeout(function(){e.scrolled=!0},this.hoverTimeout)}},Kf.prototype._onMousemove=function(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);var 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)},Kf.prototype._onMousedown=function(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=Xo(t),this.pressed=!0,this._setCanvasPosition(t))},Kf.prototype._onMouseup=function(t){t.target===this.domElement&&t.preventDefault(),this._setKeys(t);var e=this.canvasPosition;this.signals.clicked.dispatch(e.x,e.y),this.which=void 0,this.buttons=void 0,this.pressed=void 0},Kf.prototype._onContextmenu=function(t){t.target===this.domElement&&t.preventDefault()},Kf.prototype._onTouchstart=function(t){if(t.target===this.domElement)switch(t.preventDefault(),this.pressed=!0,t.touches.length){case 1:this.moving=!1,this.hovering=!1,this.down.set(t.touches[0].pageX,t.touches[0].pageY),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);break;case 2:this.down.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.lastTouchDistance=Wo(t)}},Kf.prototype._onTouchend=function(t){t.target===this.domElement&&t.preventDefault(),this.pressed=!1},Kf.prototype._onTouchmove=function(t){switch(t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,t.touches.length){case 1:this._setKeys(t),this.which=void 0,this.buttons=void 0,this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);var 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);break;case 2:this.which=3,this.buttons=2;var r=Wo(t),n=r-this.lastTouchDistance;if(this.lastTouchDistance=r,Math.abs(n)>1)this.signals.scrolled.dispatch(n/2);else{this.prevPosition.copy(this.position),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2);var o=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(o,a),this.pressed&&this.signals.dragged.dispatch(o,a)}}},Kf.prototype._distance=function(){return this.position.distanceTo(this.down)},Kf.prototype._setCanvasPosition=function(t){var e,i,r=this.domElement.getBoundingClientRect();"offsetX"in t&&"offsetY"in t?(e=t.offsetX,i=t.offsetY):(e=t.clientX-r.left,i=t.clientY-r.top),this.canvasPosition.set(e,r.height-i)},Kf.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},Kf.prototype.dispose=function(){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(Kf.prototype,Qf);var Jf=new v,tm=new v,em=new v,im=new g,rm=new m,nm=new v,om=new g,am=function(t,e){var i=e||{};this.rotateSpeed=gn(i.rotateSpeed,2),this.zoomSpeed=gn(i.zoomSpeed,1.2),this.panSpeed=gn(i.panSpeed,1),this.stage=t,this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},sm={component:{}};sm.component.get=function(){return this.stage.transformComponent},am.prototype._setPanVector=function(t,e){var i,r=this.viewer.camera;if("OrthographicCamera"===r.type)i=1/r.zoom;else{var n=Hn(r.fov);i=-2*r.position.z*Math.tan(n/2)/this.viewer.height}om.set(t,e,0),om.multiplyScalar(this.panSpeed*i)},am.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},am.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},am.prototype.pan=function(t,e){this._setPanVector(t,e),nm.getInverse(this.viewer.rotationGroup.matrix),om.applyMatrix4(nm),this.controls.translate(om)},am.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),nm.extractRotation(this.component.transform),nm.premultiply(this.viewer.rotationGroup.matrix),nm.getInverse(nm),om.applyMatrix4(nm),this.component.position.add(om),this.component.updateMatrix())},am.prototype.rotate=function(t,e){var i=this._getRotateXY(t,e),r=i[0],n=i[1];Jf.makeRotationX(n),tm.makeRotationY(r),Jf.multiply(tm),this.controls.applyMatrix(Jf)},am.prototype.rotateComponent=function(t,e){if(this.component){var i=this._getRotateXY(t,e),r=i[0],n=i[1];em.extractRotation(this.component.transform),em.premultiply(this.viewer.rotationGroup.matrix),em.getInverse(em),im.set(1,0,0),im.applyMatrix4(em),Jf.makeRotationAxis(im,n),im.set(0,1,0),im.applyMatrix4(em),tm.makeRotationAxis(im,r),Jf.multiply(tm),rm.setFromRotationMatrix(Jf),this.component.quaternion.premultiply(rm),this.component.updateMatrix()}},Object.defineProperties(am.prototype,sm);var cm=function(t,e){this.pid=t.pid,this.picker=t.picker,this.instance=t.instance,this.stage=e,this.controls=e.viewerControls,this.mouse=e.mouseObserver},um={type:{},altKey:{},ctrlKey:{},metaKey:{},shiftKey:{},canvasPosition:{},component:{},object:{},position:{},closestBondAtom:{},arrow:{},atom:{},axes:{},bond:{},cone:{},clash:{},contact:{},cylinder:{},distance:{},ellipsoid:{},mesh:{},slice:{},sphere:{},surface:{},unitcell:{},unknown:{},volume:{}};um.type.get=function(){return this.picker.type},um.altKey.get=function(){return this.mouse.altKey},um.ctrlKey.get=function(){return this.mouse.ctrlKey},um.metaKey.get=function(){return this.mouse.metaKey},um.shiftKey.get=function(){return this.mouse.shiftKey},um.canvasPosition.get=function(){return this.mouse.canvasPosition},um.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},um.object.get=function(){return this.picker.getObject(this.pid)},um.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},um.closestBondAtom.get=function(){if("bond"===this.type){var t=this.bond,e=this.controls;return qo(this.canvasPosition,e.getPositionOnCanvas(t.atom1),e.getPositionOnCanvas(t.atom2))?t.atom1:t.atom2}},um.arrow.get=function(){return this._objectIfType("arrow")},um.atom.get=function(){return this._objectIfType("atom")},um.axes.get=function(){return this._objectIfType("axes")},um.bond.get=function(){return this._objectIfType("bond")},um.cone.get=function(){return this._objectIfType("cone")},um.clash.get=function(){return this._objectIfType("clash")},um.contact.get=function(){return this._objectIfType("contact")},um.cylinder.get=function(){return this._objectIfType("cylinder")},um.distance.get=function(){return this._objectIfType("distance")},um.ellipsoid.get=function(){return this._objectIfType("ellipsoid")},um.mesh.get=function(){return this._objectIfType("mesh")},um.slice.get=function(){return this._objectIfType("slice")},um.sphere.get=function(){return this._objectIfType("sphere")},um.surface.get=function(){return this._objectIfType("surface")},um.unitcell.get=function(){return this._objectIfType("unitcell")},um.unknown.get=function(){return this._objectIfType("unknown")},um.volume.get=function(){return this._objectIfType("volume")},cm.prototype._objectIfType=function(t){return this.type===t?this.object:void 0},cm.prototype.getLabel=function(){var t="nothing";return this.arrow?t="arrow: "+(this.arrow.name||this.pid)+" ("+this.arrow.shape.name+")":this.atom?t="atom: "+this.atom.qualifiedName()+" ("+this.atom.structure.name+")":this.axes?t="axes":this.bond?t="bond: "+this.bond.atom1.qualifiedName()+" - "+this.bond.atom2.qualifiedName()+" ("+this.bond.structure.name+")":this.cone?t="cone: "+(this.cone.name||this.pid)+" ("+this.cone.shape.name+")":this.clash?t="clash: "+this.clash.clash.sele1+" - "+this.clash.clash.sele2:this.contact?t="contact: "+this.contact.atom1.qualifiedName()+" - "+this.contact.atom2.qualifiedName()+" ("+this.contact.structure.name+")":this.cylinder?t="cylinder: "+(this.cylinder.name||this.pid)+" ("+this.cylinder.shape.name+")":this.distance?t="distance: "+this.distance.atom1.qualifiedName()+" - "+this.distance.atom2.qualifiedName()+" ("+this.distance.structure.name+")":this.ellipsoid?t="ellipsoid: "+(this.ellipsoid.name||this.pid)+" ("+this.ellipsoid.shape.name+")":this.mesh?t="mesh: "+(this.mesh.name||this.mesh.serial)+" ("+this.mesh.shape.name+")":this.slice?t="slice: "+this.slice.value.toPrecision(3)+" ("+this.slice.volume.name+")":this.sphere?t="sphere: "+(this.sphere.name||this.pid)+" ("+this.sphere.shape.name+")":this.surface?t="surface: "+this.surface.surface.name:this.unitcell?t="unitcell: "+this.unitcell.unitcell.spacegroup+" ("+this.unitcell.structure.name+")":this.unknown?t="unknown":this.volume&&(t="volume: "+this.volume.value.toPrecision(3)+" ("+this.volume.volume.name+")"),t},Object.defineProperties(cm.prototype,um);var hm=function(t){this.stage=t,this.viewer=t.viewer};hm.prototype.pick=function(t,e){var i=this.viewer.pick(t,e);if(i.picker&&"ignore"!==i.picker.type&&void 0!==i.pid){var r=i.picker.array;if(!(r&&i.pid>=r.length))return new cm(i,this.stage);console.error("pid >= picker.array.length")}};var lm=new m,pm=new g,dm=new g,fm=new g,mm=new g,gm=new v,vm=new g,ym=new v,bm=function(t){this.stage=t,this.viewer=t.viewer,this.signals={changed:new oo}},xm={position:{},rotation:{}};xm.position.get=function(){return this.viewer.translationGroup.position},xm.rotation.get=function(){return this.viewer.rotationGroup.quaternion},bm.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},bm.prototype.getPositionOnCanvas=function(t,e){var i=Nn(e),r=this.viewer;return fm.copy(t).add(r.translationGroup.position).applyMatrix4(r.rotationGroup.matrix).project(r.camera),i.set((fm.x+1)*r.width/2,(fm.y+1)*r.height/2)},bm.prototype.getOrientation=function(t){var e=Fn(t);e.copy(this.viewer.rotationGroup.matrix);var i=-this.viewer.camera.position.z;return e.scale(mm.set(i,i,i)),e.setPosition(this.viewer.translationGroup.position),e},bm.prototype.orient=function(t){Fn(t).decompose(pm,lm,dm);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(lm),e.translationGroup.position.copy(pm),e.camera.position.z=-dm.z,e.updateZoom(),this.changed()},bm.prototype.translate=function(t){this.viewer.translationGroup.position.add(kn(t)),this.changed()},bm.prototype.center=function(t){this.viewer.translationGroup.position.copy(kn(t)).negate(),this.changed()},bm.prototype.zoom=function(t){this.distance(this.viewer.camera.position.z*(1-t))},bm.prototype.distance=function(t){this.viewer.camera.position.z=t,this.viewer.updateZoom(),this.changed()},bm.prototype.spin=function(t,e){gm.getInverse(this.viewer.rotationGroup.matrix),vm.copy(kn(t)).applyMatrix4(gm),this.viewer.rotationGroup.rotateOnAxis(vm,e),this.changed()},bm.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(Bn(t)),this.changed()},bm.prototype.align=function(t){ym.getInverse(Fn(t)),this.viewer.rotationGroup.setRotationFromMatrix(ym),this.changed()},bm.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix(Fn(t)),this.changed()},Object.defineProperties(bm.prototype,xm);var _m=function(t,e){for(var i=[],r=arguments.length-2;r-- >0;)i[r]=arguments[r+2];this.duration=gn(t,1e3),this.controls=e,this.startTime=window.performance.now(),this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],(n=this)._init.apply(n,i);var n},wm={done:{},paused:{}};wm.done.get=function(){return 1===this.alpha},wm.paused.get=function(){return this._paused},_m.prototype._init=function(){},_m.prototype._tick=function(){},_m.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=eo(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach(function(t){return t()}),this.done},_m.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},_m.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},_m.prototype.toggle=function(){this._paused?this.resume():this.pause()},_m.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise(function(t){return e._resolveList.push(t)})).then(t)},Object.defineProperties(_m.prototype,wm);var Sm=function(t){function e(e){for(var i=[],r=arguments.length-1;r-- >0;)i[r]=arguments[r+1];t.apply(this,[gn(e,1/0)].concat(i))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){Array.isArray(t)?this.axis=(new g).fromArray(t):this.axis=gn(t,new g(0,1,0)),this.angle=gn(e,.01)},e.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},e}(_m),Am=function(t){function e(e){for(var i=[],r=arguments.length-1;r-- >0;)i[r]=arguments[r+1];t.apply(this,[gn(e,1/0)].concat(i))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,i){Array.isArray(t)?this.axis=(new g).fromArray(t):this.axis=gn(t,new g(0,1,0)),this.angleStep=gn(e,.01),this.angleEnd=gn(i,.2),this.angleSum=0,this.direction=1},e.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=eo(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)}},e}(_m),Mm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.moveFrom=kn(gn(t,new g)),this.moveTo=kn(gn(e,new g))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(_m),Pm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.zoomFrom=t,this.zoomTo=e},e.prototype._tick=function(){this.controls.distance(Jn(this.zoomFrom,this.zoomTo,this.alpha))},e}(_m),Tm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e){this.rotateFrom=Bn(t),this.rotateTo=Bn(e),this._currentRotation=new m},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(_m),Em=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t,e,i){this.valueFrom=t,this.valueTo=e,this.callback=i},e.prototype._tick=function(){this.callback(Jn(this.valueFrom,this.valueTo,this.alpha))},e}(_m),Cm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(_m),Im=function(t){this._list=t||[],this._resolveList=[]},Rm={done:{}};Rm.done.get=function(){return this._list.every(function(t){return t.done})},Im.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise(function(t){e._resolveList.push(t),e._list.forEach(function(t){t.then(function(){e._resolveList.forEach(function(t){t()}),e._resolveList.length=0})})})).then(t)},Object.defineProperties(Im.prototype,Rm);var Lm=function(t){this.stage=t,this.viewer=t.viewer,this.controls=t.viewerControls,this.animationList=[],this.finishedList=[]},Om={paused:{}};Om.paused.get=function(){return this.animationList.every(function(t){return t.paused})},Lm.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},Lm.prototype.remove=function(t){var e=this.animationList,i=e.indexOf(t);i>-1&&e.splice(i,1)},Lm.prototype.run=function(t){for(var e=this,i=this.finishedList,r=this.animationList,n=r.length,o=0;o<n;++o){var a=r[o];a.tick(t)&&i.push(a)}var s=i.length;if(s){for(var c=0;c<s;++c)e.remove(i[c]);i.length=0}},Lm.prototype.spin=function(t,e,i){return this.add(new Sm(i,this.controls,t,e))},Lm.prototype.rock=function(t,e,i,r){return this.add(new Am(r,this.controls,t,e,i))},Lm.prototype.rotate=function(t,e){var i=this.viewer.rotationGroup.quaternion.clone();return this.add(new Tm(e,this.controls,i,t))},Lm.prototype.move=function(t,e){var i=this.controls.position.clone().negate();return this.add(new Mm(e,this.controls,i,t))},Lm.prototype.zoom=function(t,e){var i=this.viewer.camera.position.z;return this.add(new Pm(e,this.controls,i,t))},Lm.prototype.zoomMove=function(t,e,i){return new Im([this.move(t,i),this.zoom(e,i)])},Lm.prototype.orient=function(t,e){var i=new g,r=new m,n=new g;return Fn(t).decompose(i,r,n),new Im([this.move(i.negate(),e),this.rotate(r,e),this.zoom(-n.x,e)])},Lm.prototype.value=function(t,e,i,r){return this.add(new Em(r,this.controls,t,e,i))},Lm.prototype.timeout=function(t,e){return this.add(new Cm(e,this.controls,t))},Lm.prototype.spinComponent=function(t,e,i,r){return this.add(new Sm(r,t.controls,e,i))},Lm.prototype.rockComponent=function(t,e,i,r,n){return this.add(new Am(n,t.controls,e,i,r))},Lm.prototype.moveComponent=function(t,e,i){var r=t.controls.position.clone().negate();return this.add(new Mm(i,t.controls,r,e))},Lm.prototype.pause=function(){this.animationList.forEach(function(t){return t.pause()})},Lm.prototype.resume=function(){this.animationList.forEach(function(t){return t.resume()})},Lm.prototype.toggle=function(){this.paused?this.resume():this.pause()},Lm.prototype.clear=function(){this.animationList.length=0},Lm.prototype.dispose=function(){this.clear()},Object.defineProperties(Lm.prototype,Om);var Dm=function(){};Dm.zoomScroll=function(t,e){t.trackballControls.zoom(e)},Dm.clipNearScroll=function(t,e){var i=t.getParameters();t.setParameters({clipNear:i.clipNear+e/10})},Dm.focusScroll=function(t,e){var i=2*t.getParameters().clipNear,r=Math.sign(e)*io((100-i)/10,5,.2);t.setFocus(i+r)},Dm.isolevelScroll=function(t,e){var i=Math.sign(e)/5;t.eachRepresentation(function(t){if("surface"===t.repr.type){var e=t.getParameters().isolevel;t.setParameters({isolevel:e+i})}},"volume")},Dm.panDrag=function(t,e,i){t.trackballControls.pan(e,i)},Dm.rotateDrag=function(t,e,i){t.trackballControls.rotate(e,i)},Dm.zoomDrag=function(t,e,i){t.trackballControls.zoom((e+i)/-2)},Dm.zoomFocusDrag=function(t,e,i){t.trackballControls.zoom((e+i)/-2);var r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))},Dm.panComponentDrag=function(t,e,i){t.trackballControls.panComponent(e,i)},Dm.rotateComponentDrag=function(t,e,i){t.trackballControls.rotateComponent(e,i)},Dm.movePick=function(t,e){e&&t.animationControls.move(e.position.clone())},Dm.tooltipPick=function(t,e){var i=t.tooltip;if(t.getParameters().tooltip&&e){var r=e.mouse.position;i.innerText=e.getLabel(),i.style.bottom=window.innerHeight-r.y+3+"px",i.style.left=r.x+3+"px",i.style.display="block"}else i.style.display="none"};var Nm={default:[["scroll",Dm.zoomScroll],["scroll-ctrl",Dm.clipNearScroll],["scroll-shift",Dm.focusScroll],["scroll-alt",Dm.isolevelScroll],["drag-right",Dm.panDrag],["drag-left",Dm.rotateDrag],["drag-middle",Dm.zoomDrag],["drag-shift-right",Dm.zoomDrag],["drag-left+right",Dm.zoomDrag],["drag-ctrl-right",Dm.panComponentDrag],["drag-ctrl-left",Dm.rotateComponentDrag],["clickPick-middle",Dm.movePick],["hoverPick",Dm.tooltipPick]],pymol:[["drag-left",Dm.rotateDrag],["drag-middle",Dm.panDrag],["drag-right",Dm.zoomDrag],["drag-shift-right",Dm.focusScroll],["clickPick-ctrl+shift-middle",Dm.movePick],["hoverPick",Dm.tooltipPick]],coot:[["scroll",Dm.isolevelScroll],["drag-left",Dm.rotateDrag],["drag-middle",Dm.panDrag],["drag-ctrl-left",Dm.panDrag],["drag-right",Dm.zoomFocusDrag],["drag-ctrl-right",Dm.focusScroll],["clickPick-middle",Dm.movePick],["hoverPick",Dm.tooltipPick]]},km=function(t,e){var i=e||{};this.stage=t,this.mouse=t.mouseObserver,this.actionList=[],this.preset(i.preset||"default")};km.prototype.run=function(t){for(var e=this,i=[],r=arguments.length-1;r-- >0;)i[r]=arguments[r+1];var n=this.mouse.key||0,o=this.mouse.buttons||0;this.actionList.forEach(function(r){r.type===t&&r.key===n&&r.button===o&&r.callback.apply(r,[e.stage].concat(i))})},km.prototype.add=function(t,e){var i=Yo(t),r=i[0],n=i[1],o=i[2];this.actionList.push({type:r,key:n,button:o,callback:e})},km.prototype.remove=function(t,e){var i=t.includes("*"),r=Yo(t),n=r[0],o=r[1],a=r[2],s=this.actionList.filter(function(t){return!((t.type===n||i&&""===n)&&(t.key===o||i&&0===o)&&(t.button===a||i&&0===a)&&(t.callback===e||void 0===e))});this.actionList=s},km.prototype.preset=function(t){var e=this;this.clear(),(Nm[t]||[]).forEach(function(t){(i=e).add.apply(i,t);var i})},km.prototype.clear=function(){this.actionList.length=0};var Fm=function(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)};Fm.prototype._onClick=function(t,e){var i=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)},Fm.prototype._onHover=function(t,e){var i=this.stage.pickingControls.pick(t,e);i&&this.mouse.down.equals(this.mouse.position)&&(this.stage.transformComponent=i.component),this.stage.signals.hovered.dispatch(i),this.controls.run("hoverPick",i)},Fm.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Bm=function(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)};Bm.prototype._onMove=function(){this.stage.tooltip.style.display="none"},Bm.prototype._onScroll=function(t){this.controls.run("scroll",t)},Bm.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},Bm.prototype._onClick=function(t,e){this.controls.run("click",t,e)},Bm.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},Bm.prototype.dispose=function(){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)};var zm=function(t){this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};zm.prototype._onTick=function(t){this.animationControls.run(t)},zm.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var Um=function(t){this.stage=t,this._onKeydown=this._onKeydown.bind(this),this._onKeyup=this._onKeyup.bind(this),this._onKeypress=this._onKeypress.bind(this),document.addEventListener("keydown",this._onKeydown),document.addEventListener("keyup",this._onKeyup),document.addEventListener("keypress",this._onKeypress)};Um.prototype._onKeydown=function(){},Um.prototype._onKeyup=function(){},Um.prototype._onKeypress=function(t){switch(t.keyCode){case 73:case 105:this.stage.toggleSpin();break;case 75:case 107:this.stage.toggleRock();break;case 80:case 112:this.stage.animationControls.toggle()}},Um.prototype.dispose=function(){document.removeEventListener("keydown",this._onKeypress),document.removeEventListener("keyup",this._onKeypress),document.removeEventListener("keypress",this._onKeypress)};var jm=function(t,e,i,r){var n=r||{};this.offsetX=gn(n.offsetX,0),this.offsetY=gn(n.offsetY,0),this.visible=gn(n.visible,!0),this.component=t,this.stage=t.stage,this.viewer=this.stage.viewer,this.position=e,this._viewerPosition=new g,this._updateViewerPosition(),this._canvasPosition=new g,this._cameraPosition=new g,this.element=document.createElement("div"),Object.assign(this.element.style,{display:"block",position:"fixed",zIndex:1+(parseInt(this.viewer.container.style.zIndex)||0),pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif",left:"-10000px"}),this.viewer.container.appendChild(this.element),this.setContent(i),this.updateVisibility(),this.viewer.signals.ticked.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};jm.prototype.setContent=function(t){var e=this.element.style.display;"none"===e&&(this.element.style.left="-10000px",this.element.style.display="block"),t instanceof window.Element?(this.element.innerHTML="",this.element.appendChild(t)):this.element.innerHTML=t,this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)},jm.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},jm.prototype.getVisibility=function(){return this.visible&&this.component.visible},jm.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},jm.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},jm.prototype._update=function(){if(this.getVisibility()){var 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",t.opacity=1-eo(this.viewer.scene.fog.near,this.viewer.scene.fog.far,this._cameraPosition.length()),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"}},jm.prototype.dispose=function(){this.viewer.container.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var Gm=new v,Vm=new g,$m=new m,Hm=function(t){this.component=t,this.stage=t.stage,this.viewer=t.stage.viewer,this.signals={changed:new oo}},Wm={position:{},rotation:{}};Wm.position.get=function(){return this.component.position},Wm.rotation.get=function(){return this.component.quaternion},Hm.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},Hm.prototype.spin=function(t,e){Gm.getInverse(this.viewer.rotationGroup.matrix),Vm.copy(kn(t)).applyMatrix4(Gm),Gm.extractRotation(this.component.transform),Gm.premultiply(this.viewer.rotationGroup.matrix),Gm.getInverse(Gm),Vm.copy(kn(t)),Vm.applyMatrix4(Gm),Gm.makeRotationAxis(Vm,e),$m.setFromRotationMatrix(Gm),this.component.quaternion.premultiply($m),this.changed()},Object.defineProperties(Hm.prototype,Wm),sa.__deps=[ca],ua.__deps=[ca,aa];var Xm=function(t){this.array=t};Xm.prototype.getIndex=function(t){return this.array?this.array[t]:t},Xm.prototype.getObject=function(){return{}},Xm.prototype._applyTransformations=function(t,e,i){return e&&t.applyMatrix4(e.matrix),i&&t.applyMatrix4(i.matrix),t},Xm.prototype._getPosition=function(){return new g},Xm.prototype.getPosition=function(t,e,i){return this._applyTransformations(this._getPosition(t),e,i)};var qm=function(t){function e(e){t.call(this),this.shape=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={data:{}};return i.data.get=function(){return this.shape},Object.defineProperties(e.prototype,i),e}(Xm),Ym=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"cylinder"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,color:(new tt).fromArray(e.cylinderColor,3*t),radius:e.cylinderRadius[t],position1:(new g).fromArray(e.cylinderPosition1,3*t),position2:(new g).fromArray(e.cylinderPosition2,3*t),name:e.cylinderName[t]}},e.prototype._getPosition=function(t){var e=this.shape,i=(new g).fromArray(e.cylinderPosition1,3*t),r=(new g).fromArray(e.cylinderPosition2,3*t);return i.add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(qm),Zm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"arrow"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),position1:(new g).fromArray(e.arrowPosition1,3*t),position2:(new g).fromArray(e.arrowPosition2,3*t),color:(new tt).fromArray(e.arrowColor,3*t),radius:e.arrowRadius[t],name:e.arrowName[t]}},e.prototype._getPosition=function(t){var e=this.shape,i=(new g).fromArray(e.arrowPosition1,3*t),r=(new g).fromArray(e.arrowPosition2,3*t);return i.add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(qm),Km=function(t){function e(e,i){t.call(this,e),this.structure=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"atom"},i.data.get=function(){return this.structure},e.prototype.getObject=function(t){return this.structure.getAtomProxy(this.getIndex(t))},e.prototype._getPosition=function(t){return(new g).copy(this.getObject(t))},Object.defineProperties(e.prototype,i),e}(Xm),Qm=function(t){function e(e){t.call(this),this.axes=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"axes"},i.data.get=function(){return this.axes},e.prototype.getObject=function(){return{axes:this.axes}},e.prototype._getPosition=function(){return this.axes.center.clone()},Object.defineProperties(e.prototype,i),e}(Xm),Jm=function(t){function e(e,i,r){t.call(this,e),this.structure=i,this.bondStore=r||i.bondStore}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"bond"},i.data.get=function(){return this.structure},e.prototype.getObject=function(t){var e=this.structure.getBondProxy(this.getIndex(t));return e.bondStore=this.bondStore,e},e.prototype._getPosition=function(t){var e=this.getObject(t);return(new g).copy(e.atom1).add(e.atom2).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Xm),tg=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"contact"},Object.defineProperties(e.prototype,i),e}(Jm),eg=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"cone"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),position1:(new g).fromArray(e.conePosition1,3*t),position2:(new g).fromArray(e.conePosition2,3*t),color:(new tt).fromArray(e.coneColor,3*t),radius:e.coneRadius[t],name:e.coneName[t]}},e.prototype._getPosition=function(t){var e=this.shape,i=(new g).fromArray(e.conePosition1,3*t),r=(new g).fromArray(e.conePosition2,3*t);return i.add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(qm),ig=function(t){function e(e,i,r){t.call(this,e),this.validation=i,this.structure=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"clash"},i.data.get=function(){return this.validation},e.prototype.getObject=function(t){var e=this.validation,i=this.getIndex(t);return{validation:e,index:i,clash:e.clashArray[i]}},e.prototype._getAtomProxyFromSele=function(t){var e=new Kd(t),i=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(i)},e.prototype._getPosition=function(t){var e=this.getObject(t).clash,i=this._getAtomProxyFromSele(e.sele1),r=this._getAtomProxyFromSele(e.sele2);return(new g).copy(i).add(r).multiplyScalar(.5)},Object.defineProperties(e.prototype,i),e}(Xm),rg=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"distance"},Object.defineProperties(e.prototype,i),e}(Jm),ng=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"ellipsoid"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),color:(new tt).fromArray(e.ellipsoidColor,3*t),radius:e.ellipsoidRadius[t],majorAxis:(new g).fromArray(e.ellipsoidMajorAxis,3*t),minorAxis:(new g).fromArray(e.ellipsoidMinorAxis,3*t),name:e.ellipsoidName[t]}},e.prototype._getPosition=function(t){return(new g).fromArray(this.shape.ellipsoidPosition,3*t)},Object.defineProperties(e.prototype,i),e}(qm),og=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"ignore"},Object.defineProperties(e.prototype,i),e}(Xm),ag=function(t){function e(e,i){t.call(this,e),this.mesh=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"mesh"},e.prototype.getObject=function(){var t=this.mesh;return{shape:this.shape,name:t.name,serial:t.serial}},e.prototype._getPosition=function(){return this.__position||(this.__position=Zo(this.mesh.position)),this.__position},Object.defineProperties(e.prototype,i),e}(qm),sg=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"sphere"},e.prototype.getObject=function(t){var e=this.shape;return{shape:e,position:this._getPosition(t),color:(new tt).fromArray(e.sphereColor,3*t),radius:e.sphereRadius[t],name:e.sphereName[t]}},e.prototype._getPosition=function(t){return(new g).fromArray(this.shape.spherePosition,3*t)},Object.defineProperties(e.prototype,i),e}(qm),cg=function(t){function e(e,i){t.call(this,e),this.surface=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"surface"},i.data.get=function(){return this.surface},e.prototype.getObject=function(t){return{surface:this.surface,index:this.getIndex(t)}},e.prototype._getPosition=function(){return this.surface.center.clone()},Object.defineProperties(e.prototype,i),e}(Xm),ug=function(t){function e(e,i){t.call(this),this.unitcell=e,this.structure=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"unitcell"},i.data.get=function(){return this.unitcell},e.prototype.getObject=function(){return{unitcell:this.unitcell,structure:this.structure}},e.prototype._getPosition=function(){return this.unitcell.getCenter(this.structure)},Object.defineProperties(e.prototype,i),e}(Xm),hg=(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};i.type.get=function(){return"unknown"},Object.defineProperties(e.prototype,i)}(Xm),function(t){function e(e,i){t.call(this,e),this.volume=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},data:{}};return i.type.get=function(){return"volume"},i.data.get=function(){return this.volume},e.prototype.getObject=function(t){var e=this.volume,i=this.getIndex(t);return{volume:e,index:i,value:e.data[i]}},e.prototype._getPosition=function(t){var e=this.volume.position,i=this.getIndex(t);return new g(e[3*i],e[3*i+1],e[3*i+2])},Object.defineProperties(e.prototype,i),e}(Xm)),lg=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"slice"},Object.defineProperties(e.prototype,i),e}(hg),pg=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};pg.prototype.get=function(t){return 0!=(this._words[t>>>5]&1<<t)},pg.prototype.set=function(t){this._words[t>>>5]|=1<<t},pg.prototype.clear=function(t){this._words[t>>>5]&=~(1<<t)},pg.prototype.flip=function(t){this._words[t>>>5]^=1<<t},pg.prototype._assignRange=function(t,e,i){for(var r=this._words,n=!0===i?4294967295:0,o=t>>>5,a=e>>>5,s=o;s<a;++s)r[s]=n;var c=o<<5,u=a<<5;if(!0===i)if(e-t<32)for(var h=t,l=e+1;h<l;++h)r[h>>>5]|=1<<h;else{for(var p=t,d=c;p<d;++p)r[p>>>5]|=1<<p;for(var f=u,m=e+1;f<m;++f)r[f>>>5]|=1<<f}else if(e-t<32)for(var g=t,v=e+1;g<v;++g)r[g>>>5]&=~(1<<g);else{for(var y=t,b=c;y<b;++y)r[y>>>5]&=~(1<<y);for(var x=u,_=e+1;x<_;++x)r[x>>>5]&=~(1<<x)}return this},pg.prototype.setRange=function(t,e){return this._assignRange(t,e,!0)},pg.prototype.clearRange=function(t,e){return this._assignRange(t,e,!1)},pg.prototype.setBits=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];e[n>>>5]|=1<<n}return this},pg.prototype.clearBits=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];e[n>>>5]&=~(1<<n)}return this},pg.prototype.setAll=function(){return this._assignRange(0,this.length-1,!0)},pg.prototype.clearAll=function(){return this._assignRange(0,this.length-1,!1)},pg.prototype.flipAll=function(){for(var t=this._words.length,e=this._words,i=32-this.length%32,r=0;r<t-1;++r)e[r]=~e[r];return e[t-1]=~(e[t-1]<<i)>>>i,this},pg.prototype._isRangeValue=function(t,e,i){for(var r=this._words,n=!0===i?4294967295:0,o=t>>>5,a=e>>>5,s=o;s<a;++s)if(r[s]!==n)return!1;if(e-t<32){for(var c=t,u=e+1;c<u;++c)if(!!(r[c>>>5]&1<<c)!==i)return!1}else{for(var h=a<<5,l=t,p=o<<5<<5;l<p;++l)if(!!(r[l>>>5]&1<<l)!==i)return!1;for(var d=h,f=e+1;d<f;++d)if(!!(r[d>>>5]&1<<d)!==i)return!1}return!0},pg.prototype.isRangeSet=function(t,e){return this._isRangeValue(t,e,!0)},pg.prototype.isRangeClear=function(t,e){return this._isRangeValue(t,e,!1)},pg.prototype.isAllSet=function(){return this._isRangeValue(0,this.length-1,!0)},pg.prototype.isAllClear=function(){return this._isRangeValue(0,this.length-1,!1)},pg.prototype.isSet=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];if(0==(e[n>>>5]&1<<n))return!1}return!0},pg.prototype.isClear=function(){for(var t=arguments,e=this._words,i=arguments.length,r=0;r<i;++r){var n=t[r];if(0!=(e[n>>>5]&1<<n))return!1}return!0},pg.prototype.isEqualTo=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)if(e[n]!==i[n])return!1;return!0},pg.prototype.getSize=function(){for(var t=this._words.length,e=this._words,i=0,r=0;r<t;++r)i+=ma(e[r]);return i},pg.prototype.difference=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]=e[n]&~i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},pg.prototype.union=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]|=i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},pg.prototype.intersection=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]&=i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},pg.prototype.intersects=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)if(0!=(e[n]&i[n]))return!0;return!1},pg.prototype.getIntersectionSize=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0,o=0;o<r;++o)n+=ma(e[o]&i[o]);return n},pg.prototype.makeIntersection=function(t){var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=new Uint32Array(r),o=Object.create(pg.prototype);o._words=n,o.length=Math.min(this.length,t.length);for(var a=0;a<r;++a)n[a]=e[a]&i[a];return o},pg.prototype.forEach=function(t){for(var e=this._words.length,i=this._words,r=0,n=0;n<e;++n)for(var o=i[n];0!==o;){var a=o&-o;t((n<<5)+ma(a-1),r),o^=a,++r}},pg.prototype.toArray=function(){for(var t=this._words,e=new Array(this.getSize()),i=this._words.length,r=0,n=0;n<i;++n)for(var o=t[n];0!==o;){var a=o&-o;e[r++]=(n<<5)+ma(a-1),o^=a}return e},pg.prototype.toString=function(){return"{"+this.toArray().join(",")+"}"},pg.prototype.toSeleString=function(){var t=this.toArray().join(",");return t?"@"+t:"NONE"},pg.prototype.clone=function(){var t=Object.create(pg.prototype);return t.length=this.length,t._words=new Uint32Array(this._words),t};var dg=0,fg=1,mg=2,gg=3,vg=4,yg=0,bg=["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"],xg=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],_g=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],wg=["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"],Sg=["OTHER"],Ag=["NON-POLYMER"].concat(Sg,wg),Mg=["h","g","i"],Pg=["e","b"],Tg=["s","t","l",""],Eg={H:1.1,HE:1.4,LI:1.81,BE:1.53,B:1.92,C:1.7,N:1.55,O:1.52,F:1.47,NE:1.54,NA:2.27,MG:1.73,AL:1.84,SI:2.1,P:1.8,S:1.8,CL:1.75,AR:1.88,K:2.75,CA:2.31,SC:2.3,TI:2.15,V:2.05,CR:2.05,MN:2.05,FE:2.05,CO:2,NI:2,CU:2,ZN:2.1,GA:1.87,GE:2.11,AS:1.85,SE:1.9,BR:1.83,KR:2.02,RB:3.03,SR:2.49,Y:2.4,ZR:2.3,NB:2.15,MO:2.1,TC:2.05,RU:2.05,RH:2,PD:2.05,AG:2.1,CD:2.2,IN:2.2,SN:1.93,SB:2.17,TE:2.06,I:1.98,XE:2.16,CS:3.43,BA:2.68,LA:2.5,CE:2.48,PR:2.47,ND:2.45,PM:2.43,SM:2.42,EU:2.4,GD:2.38,TB:2.37,DY:2.35,HO:2.33,ER:2.32,TM:2.3,YB:2.28,LU:2.27,HF:2.25,TA:2.2,W:2.1,RE:2.05,OS:2,IR:2,PT:2.05,AU:2.1,HG:2.05,TL:1.96,PB:2.02,BI:2.07,PO:1.97,AT:2.02,RN:2.2,FR:3.48,RA:2.83,AC:2,TH:2.4,PA:2,U:2.3,NP:2,PU:2,AM:2,CM:2,BK:2,CF:2,ES:2,FM:2,MD:2,NO:2,LR:2,RF:2,DB:2,SG:2,BH:2,HS:2,MT:2,DS:2,RG:2,CN:2,UUT:2,FL:2,UUP:2,LV:2,UUH:2},Cg={H:.31,HE:.28,LI:1.28,BE:.96,B:.84,C:.76,N:.71,O:.66,F:.57,NE:.58,NA:1.66,MG:1.41,AL:1.21,SI:1.11,P:1.07,S:1.05,CL:1.02,AR:1.06,K:2.03,CA:1.76,SC:1.7,TI:1.6,V:1.53,CR:1.39,MN:1.39,FE:1.32,CO:1.26,NI:1.24,CU:1.32,ZN:1.22,GA:1.22,GE:1.2,AS:1.19,SE:1.2,BR:1.2,KR:1.16,RB:2.2,SR:1.95,Y:1.9,ZR:1.75,NB:1.64,MO:1.54,TC:1.47,RU:1.46,RH:1.42,PD:1.39,AG:1.45,CD:1.44,IN:1.42,SN:1.39,SB:1.39,TE:1.38,I:1.39,XE:1.4,CS:2.44,BA:2.15,LA:2.07,CE:2.04,PR:2.03,ND:2.01,PM:1.99,SM:1.98,EU:1.98,GD:1.96,TB:1.94,DY:1.92,HO:1.92,ER:1.89,TM:1.9,YB:1.87,LU:1.87,HF:1.75,TA:1.7,W:1.62,RE:1.51,OS:1.44,IR:1.41,PT:1.36,AU:1.36,HG:1.32,TL:1.45,PB:1.46,BI:1.48,PO:1.4,AT:1.5,RN:1.5,FR:2.6,RA:2.21,AC:2.15,TH:2.06,PA:2,U:1.96,NP:1.9,PU:1.87,AM:1.8,CM:1.69,BK:1.6,CF:1.6,ES:1.6,FM:1.6,MD:1.6,NO:1.6,LR:1.6,RF:1.6,DB:1.6,SG:1.6,BH:1.6,HS:1.6,MT:1.6,DS:1.6,RG:1.6,CN:1.6,UUT:1.6,FL:1.6,UUP:1.6,LV:1.6,UUH:1.6},Ig={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]},Rg=[0,0,0],Lg={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",ASH:"D",GLH:"E",UNK:""},Og=Object.keys(Lg),Dg=["A","C","T","G","U"],Ng=["DA","DC","DT","DG","DU","TCY","MCY","5CM"],kg=["A","G","DA","DG"],Fg=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4"],Bg=["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"],zg=["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"],Ug=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","H","H1","H2","H3","HA","BB"],jg=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*"],Gg={};Gg[1]={trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT"],backboneStart:"N",backboneEnd:"C"},Gg[2]={trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},Gg[3]={trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},Gg[4]={trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},Gg[5]={trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},Gg[6]={trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]},Gg[yg]={},ga.prototype={constructor:ga,atomRadius:function(t){var e,i=this.type,r=this.scale;switch(i){case"vdw":e=Eg[t.element]||2;break;case"covalent":e=Cg[t.element]||1.6;break;case"bfactor":e=t.bfactor||1;break;case"sstruc":var n=t.sstruc;e="h"===n?.25:"g"===n?.25:"i"===n?.25:"e"===n?.25:"b"===n?.25:jg.includes(t.atomname)?.4:.1;break;default:e=i||1}return Math.min(e*r,this.max)}},ga.types={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size"},va.prototype={copyTo:function(t){t.data.set(this.data)}};var Vg=1.192092896e-7,$g=1e-37;Oa.__deps=[Ra],Da.__deps=[Ra],Na.__deps=[Ra],Fa.__deps=[ia,ra];var Hg=new g(-1,-1,-1),Wg=new v,Xg=function(t){var e=t.rows,i=e/3,r=new va(e,3),n=new va(3,3),o=new va(1,3),a=new va(3,3),s=new va(3,3),c=Sa(t);Aa(t,c),ya(r,t),ba(n,r,r),Ca(n,o,a,s);var u=new g(c[0],c[1],c[2]),h=new g(a.data[0],a.data[3],a.data[6]),l=new g(a.data[1],a.data[4],a.data[7]),p=new g(a.data[2],a.data[5],a.data[8]),d=h.clone().multiplyScalar(Math.sqrt(o.data[0]/i)),f=l.clone().multiplyScalar(Math.sqrt(o.data[1]/i)),m=p.clone().multiplyScalar(Math.sqrt(o.data[2]/i));this.begA=u.clone().sub(d),this.endA=u.clone().add(d),this.begB=u.clone().sub(f),this.endB=u.clone().add(f),this.begC=u.clone().sub(m),this.endC=u.clone().add(m),this.center=u,this.vecA=d,this.vecB=f,this.vecC=m,this.normVecA=h,this.normVecB=l,this.normVecC=p};Xg.prototype.getBasisMatrix=function(t){var e=t||new v;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(Hg),e},Xg.prototype.getRotationQuaternion=function(t){var e=t||new m;return e.setFromRotationMatrix(this.getBasisMatrix(Wg)),e.inverse()},Xg.prototype.getProjectedScaleForAtoms=function(t){var e=-1/0,i=-1/0,r=-1/0,n=-1/0,o=-1/0,a=-1/0,s=new g,c=new g,u=this.center,h=this.normVecA,l=this.normVecB,p=this.normVecC;return t.eachAtom(function(t){Ko(s.copy(t),h,u);var d=c.subVectors(s,u).normalize().dot(h),f=s.distanceTo(u);d>0?f>e&&(e=f):f>i&&(i=f),Ko(s.copy(t),l,u);var m=c.subVectors(s,u).normalize().dot(l),g=s.distanceTo(u);m>0?g>r&&(r=g):g>n&&(n=g),Ko(s.copy(t),p,u);var v=c.subVectors(s,u).normalize().dot(p),y=s.distanceTo(u);v>0?y>o&&(o=y):y>a&&(a=y)}),{d1a:e,d2a:r,d3a:o,d1b:-i,d2b:-n,d3b:-a}},za.prototype.constructor=za,Ua.prototype.constructor=Ua,$a.__deps=[ja,Ga,Va,Ln],Ha.__deps=[Wa],Wa.__deps=[na,ra,oa,ea],qa.__deps=[Hn,ha,la,sa,ca,pa,da,na,fa,Ia,La,Da,Oa,Na];var qg=function(t,e,i){this.name=t||"",this.path=e||"",this.info={},this.center=new g,this.boundingBox=new st,i instanceof wt||i instanceof Ct||i instanceof Ne?this.fromGeometry(i):i&&(this.set(i.position,i.index,i.normal,i.color,i.atomindex,i.contour),this.boundingBox.setFromArray(i.position),this.boundingBox.getCenter(this.center))},Yg={type:{}};Yg.type.get=function(){return"Surface"},qg.prototype.set=function(t,e,i,r,n,o){this.position=t,this.index=e,this.normal=i,this.color=r,this.atomindex=n,this.size=t.length/3,this.contour=o},qg.prototype.fromGeometry=function(e){t.Debug&&cf.time("GeometrySurface.fromGeometry");var i;e instanceof wt?(e.computeVertexNormals(!0),i=(new Ct).fromGeometry(e)):i=e instanceof Ct?e:e[0],i.boundingBox||i.computeBoundingBox(),this.boundingBox.copy(i.boundingBox),this.boundingBox.getCenter(this.center);var r,n,o;if(i instanceof Ct){var a=i.attributes,s=!!a.normal&&a.normal.array;(!s||0===s[0]&&0===s[1]&&0===s[2])&&i.computeVertexNormals(),r=a.position.array,n=a.index?a.index.array:null,o=a.normal.array}this.set(r,n,o,void 0,void 0),t.Debug&&cf.timeEnd("GeometrySurface.setGeometry")},qg.prototype.getPosition=function(){return this.position},qg.prototype.getColor=function(t){var e=t||{};e.surface=this;var i=this.size,r=new Float32Array(3*i),n=lf.getScheme(e);if(n.volumeColor||"random"===e.scheme)for(var o=0;o<i;++o)n.volumeColorToArray(o,r,3*o);else if(n.positionColor)for(var a=new g,s=this.position,c=0;c<i;++c){var u=3*c;a.set(s[u],s[u+1],s[u+2]),n.positionColorToArray(a,r,u)}else if(n.atomColor&&this.atomindex)for(var h=e.structure.getAtomProxy(),l=this.atomindex,p=0;p<i;++p)h.index=l[p],n.atomColorToArray(h,r,3*p);else{var d=new tt(e.value);To(i,d.r,d.g,d.b,r)}return r},qg.prototype.getPicking=function(t){return this.atomindex&&t?new Km(this.atomindex,t):new cg(Co(this.size),this)},qg.prototype.getNormal=function(){return this.normal},qg.prototype.getSize=function(t,e){return Po(this.size,t*e)},qg.prototype.getIndex=function(){return this.index},qg.prototype.getFilteredIndex=function(t,e){if(t&&this.atomindex){for(var i=new Kd(t),r=e.getAtomSet(i),n=[],o=this.atomindex,a=this.index,s=a.length,c=this.contour?2:3,u=0,h=0;h<s;h+=c){for(var l=!0,p=0;p<c;p++){var d=o[a[h+p]];if(!r.get(d)){l=!1;break}}if(l)for(var f=0;f<c;f++,u++)n[u]=a[h+f]}return Ln(n,this.position.length/3)}return this.index},qg.prototype.getAtomindex=function(){return this.atomindex},qg.prototype.dispose=function(){},Object.defineProperties(qg.prototype,Yg),Ya.__deps=[Ha,Wa,$a,Jo,ta,ka,Fa],hf.add("surf",function(t,e){var i=t.data.args,r=t.data.params;if(i&&(self.volsurf=new Ya(i[0],i[1],i[2],i[3],i[4])),r){var n=self.volsurf.getSurface(r.isolevel,r.smooth,r.box,r.matrix,r.contour,r.wrap),o=[n.position.buffer,n.index.buffer];n.normal&&o.push(n.normal.buffer),n.atomindex&&o.push(n.atomindex.buffer),e({sd:n,p:r},o)}},[Ya]);var Zg=function(t,e,i,r,n,o,a){this.name=t,this.path=e,this.matrix=new v,this.normalMatrix=new ut,this.inverseMatrix=new v,this.center=new g,this.boundingBox=new st,this.setData(i,r,n,o,a)},Kg={type:{},position:{},min:{},max:{},sum:{},mean:{},rms:{}};Kg.type.get=function(){return"Volume"},Zg.prototype.setData=function(t,e,i,r,n){this.nx=e||1,this.ny=i||1,this.nz=r||1,this.data=t||new Float32Array(1),this.setAtomindex(n),delete this._position,delete this._min,delete this._max,delete this._mean,delete this._rms,this.worker&&this.worker.terminate()},Zg.prototype.setMatrix=function(t){this.matrix.copy(t);var e=this.boundingBox,i=this.center,r=this.nx-1,n=this.ny-1,o=this.nz-1;e.makeEmpty(),e.expandByPoint(i.set(r,n,o)),e.expandByPoint(i.set(r,n,0)),e.expandByPoint(i.set(r,0,o)),e.expandByPoint(i.set(r,0,0)),e.expandByPoint(i.set(0,n,o)),e.expandByPoint(i.set(0,0,o)),e.expandByPoint(i.set(0,n,0)),e.expandByPoint(i.set(0,0,0)),e.applyMatrix4(this.matrix),e.getCenter(this.center);var a=this.matrix.elements,s=new g(a[0],a[1],a[2]),c=new g(a[4],a[5],a[6]),u=new g(a[8],a[9],a[10]),h=new g,l=this.normalMatrix.elements;h.crossVectors(c,u),l[0]=h.x,l[1]=h.y,l[2]=h.z,h.crossVectors(u,s),l[3]=h.x,l[4]=h.y,l[5]=h.z,h.crossVectors(s,c),l[6]=h.x,l[7]=h.y,l[8]=h.z,this.inverseMatrix.getInverse(this.matrix)},Zg.prototype.setAtomindex=function(t){this.atomindex=t},Zg.prototype.getBox=function(t,e,i){return i||(i=new st),i.set(t,t),i.expandByScalar(e),i.applyMatrix4(this.inverseMatrix),i.min.round(),i.max.round(),i},Zg.prototype._getBox=function(t,e){if(t&&e){this.__box||(this.__box=new st);var i=this.getBox(t,e,this.__box);return[i.min.toArray(),i.max.toArray()]}},Zg.prototype._makeSurface=function(t,e,i){var r=this.name+"@"+e.toPrecision(2),n=new qg(r,"",t);return n.info.isolevel=e,n.info.smooth=i,n.info.volume=this,n},Zg.prototype.getSurface=function(t,e,i,r,n,o){t=isNaN(t)?this.getValueForSigma(2):t,e=gn(e,0),void 0===this.volsurf&&(this.volsurf=new Ya(this.data,this.nx,this.ny,this.nz,this.atomindex));var a=this._getBox(i,r),s=this.volsurf.getSurface(t,e,a,this.matrix.elements,n,o);return this._makeSurface(s,t,e)},Zg.prototype.getSurfaceWorker=function(t,e,i,r,n,o,a){var s=this;if(t=isNaN(t)?this.getValueForSigma(2):t,e=e||0,window.Worker){void 0===this.workerPool&&(this.workerPool=new Ua("surf",2));var c={},u=this.workerPool.getNextWorker();0===u.postCount&&(c.args=[this.data,this.nx,this.ny,this.nz,this.atomindex]),c.params={isolevel:t,smooth:e,box:this._getBox(i,r),matrix:this.matrix.elements,contour:n,wrap:o},u.post(c,void 0,function(t){var e=t.data.sd,i=t.data.p;a(s._makeSurface(e,i.isolevel,i.smooth))},function(c){console.warn("Volume.getSurfaceWorker error - trying without worker",c);var u=s.getSurface(t,e,i,r,n,o);a(u)})}else{var h=this.getSurface(t,e,i,r,n,o);a(h)}},Zg.prototype.getValueForSigma=function(t){return this.mean+gn(t,2)*this.rms},Zg.prototype.getSigmaForValue=function(t){return(gn(t,0)-this.mean)/this.rms},Kg.position.get=function(){if(!this._position){for(var t=this.nz,e=this.ny,i=this.nx,r=new Float32Array(i*e*t*3),n=0,o=0;o<t;++o)for(var a=0;a<e;++a)for(var s=0;s<i;++s)r[n+0]=s,r[n+1]=a,r[n+2]=o,n+=3;Jo(this.matrix.elements,r),this._position=r}return this._position},Zg.prototype.getDataAtomindex=function(){return this.atomindex},Zg.prototype.getDataPosition=function(){return this.position},Zg.prototype.getDataColor=function(t){var e=t||{};e.volume=this,e.scale=e.scale||"Spectral",e.domain=e.domain||[this.min,this.max];for(var i=lf.getScheme(e),r=this.position.length/3,n=new Float32Array(3*r),o=0;o<r;++o)i.volumeColorToArray(o,n,3*o);return n},Zg.prototype.getDataPicking=function(){var t=Co(this.position.length/3);return new hg(t,this)},Zg.prototype.getDataSize=function(t,e){var i,r=this.data,n=this.position.length/3;switch(t){case"value":i=new Float32Array(r);break;case"abs-value":i=new Float32Array(r);for(var o=0;o<n;++o)i[o]=Math.abs(i[o]);break;case"value-min":i=new Float32Array(r);for(var a=this.min,s=0;s<n;++s)i[s]-=a;break;case"deviation":i=new Float32Array(r);break;default:i=Po(n,t)}if(1!==e)for(var c=0;c<n;++c)i[c]*=e;return i},Kg.min.get=function(){return void 0===this._min&&(this._min=ko(this.data)),this._min},Kg.max.get=function(){return void 0===this._max&&(this._max=No(this.data)),this._max},Kg.sum.get=function(){return void 0===this._sum&&(this._sum=Fo(this.data)),this._sum},Kg.mean.get=function(){return void 0===this._mean&&(this._mean=Bo(this.data)),this._mean},Kg.rms.get=function(){return void 0===this._rms&&(this._rms=zo(this.data)),this._rms},Zg.prototype.clone=function(){var t=new Zg(this.name,this.path,this.data,this.nx,this.ny,this.nz,this.atomindex);return t.matrix.copy(this.matrix),t.header=Object.assign({},this.header),t},Zg.prototype.dispose=function(){this.workerPool&&this.workerPool.terminate()},Object.defineProperties(Zg.prototype,Kg);var Qg=function(t,e,i,r){this.volume=t,this.setFilter(e,i,r)},Jg={header:{},matrix:{},normalMatrix:{},inverseMatrix:{},center:{},boundingBox:{},min:{},max:{},mean:{},rms:{}};Jg.header.get=function(){return this.volume.header},Jg.matrix.get=function(){return this.volume.matrix},Jg.normalMatrix.get=function(){return this.volume.normalMatrix},Jg.inverseMatrix.get=function(){return this.volume.inverseMatrix},Jg.center.get=function(){return this.volume.center},Jg.boundingBox.get=function(){return this.volume.boundingBox},Jg.min.get=function(){return this.volume.min},Jg.max.get=function(){return this.volume.max},Jg.mean.get=function(){return this.volume.mean},Jg.rms.get=function(){return this.volume.rms},Qg.prototype._getFilterHash=function(t,e,i){return JSON.stringify([t,e,i])},Qg.prototype.setFilter=function(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=gn(e,1/0),i=gn(i,!1);var r=this.volume.data,n=this.volume.position,o=this.volume.atomindex,a=this._getFilterHash(t,e,i);if(a!==this._filterHash){if(t===-1/0&&e===1/0)this.data=r,this.position=n,this.atomindex=o;else{var s=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*s),this._positionBuffer=new ArrayBuffer(3*s*4),o&&(this._atomindexBuffer=new ArrayBuffer(4*s)));var c,u=new Float32Array(this._dataBuffer),h=new Float32Array(this._positionBuffer);o&&(c=new Uint32Array(this._atomindexBuffer));for(var l=0,p=0;p<s;++p){var d=3*p,f=r[p];if(!i&&f>=t&&f<=e||i&&(f<t||f>e)){var m=3*l;u[l]=f,h[m+0]=n[d+0],h[m+1]=n[d+1],h[m+2]=n[d+2],o&&(c[l]=o[p]),l+=1}}this.data=new Float32Array(this._dataBuffer,0,l),this.position=new Float32Array(this._positionBuffer,0,3*l),o&&(this.atomindex=new Float32Array(this._atomindexBuffer,0,l))}this._filterHash=a}},Object.defineProperties(Qg.prototype,Jg),Qg.prototype.getValueForSigma=Zg.prototype.getValueForSigma,Qg.prototype.getSigmaForValue=Zg.prototype.getSigmaForValue,Qg.prototype.getDataAtomindex=Zg.prototype.getDataAtomindex,Qg.prototype.getDataPosition=Zg.prototype.getDataPosition,Qg.prototype.getDataColor=Zg.prototype.getDataColor,Qg.prototype.getDataPicking=Zg.prototype.getDataPicking,Qg.prototype.getDataSize=Zg.prototype.getDataSize;var tv=function(e,i){t.Debug&&cf.time("BondHash init");for(var r=e.count,n=e.atomIndex1,o=e.atomIndex2,a=new Uint8Array(i),s=new Int32Array(i),c=0;c<r;++c)a[n[c]]+=1,a[o[c]]+=1;for(var u=1;u<i;++u)s[u]+=s[u-1]+a[u-1];for(var h=2*r,l=new Int32Array(h),p=0;p<h;++p)l[p]=-1;for(var d=0;d<r;++d){for(var f=n[d],m=o[d],g=s[f];-1!==l[g];)g+=1;l[g]=d;for(var v=s[m];-1!==l[v];)v+=1;l[v]=d}t.Debug&&cf.timeEnd("BondHash init"),this.countArray=a,this.offsetArray=s,this.indexArray=l},ev=function(t){Number.isInteger(t)?this._init(t):this._init(0)};ev.prototype._init=function(t){var e=this;this.length=t,this.count=0;for(var i=0,r=this.__fields.length;i<r;++i){var n=e.__fields[i][0],o=e.__fields[i][1],a=e.__fields[i][2],s=e.length*o;e[n]=Rn(a,s)}},ev.prototype.resize=function(t){var e=this;this.length=Math.round(t||0),this.count=Math.min(this.count,this.length);for(var i=0,r=this.__fields.length;i<r;++i){var n=e.__fields[i][0],o=e.__fields[i][1],a=e.length*o,s=new e[n].constructor(a);e[n].length>a?s.set(e[n].subarray(0,a)):s.set(e[n]),e[n]=s}},ev.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},ev.prototype.copyFrom=function(t,e,i,r){for(var n=this,o=0,a=this.__fields.length;o<a;++o)for(var s=n.__fields[o][0],c=n.__fields[o][1],u=n[s],h=t[s],l=0;l<r;++l)for(var p=c*(e+l),d=c*(i+l),f=0;f<c;++f)u[p+f]=h[d+f]},ev.prototype.copyWithin=function(t,e,i){for(var r=this,n=0,o=this.__fields.length;n<o;++n)for(var a=r.__fields[n][0],s=r.__fields[n][1],c=r[a],u=0;u<i;++u)for(var h=s*(t+u),l=s*(e+u),p=0;p<s;++p)c[h+p]=c[l+p]},ev.prototype.sort=function(t){function e(t,e){t!==e&&(n.copyFrom(r,0,t,1),r.copyWithin(t,e,1),r.copyFrom(n,e,0,1))}function i(r,n){if(r<n){var o=Math.floor((r+n)/2),a=r,s=n;do{for(;t(a,o)<0;)a+=1;for(;t(s,o)>0;)s-=1;a<=s&&(a===o?o=s:s===o&&(o=a),e(a,s),a+=1,s-=1)}while(a<=s);i(r,s),i(a,n)}}cf.time("Store.sort");var r=this,n=new this.constructor(1);i(0,this.count-1),cf.timeEnd("Store.sort")},ev.prototype.clear=function(){this.count=0},ev.prototype.dispose=function(){var t=this;delete this.length,delete this.count;for(var e=0,i=this.__fields.length;e<i;++e)delete t[t.__fields[e][0]]};var iv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]},e.prototype.addBond=function(t,e,i){this.growIfFull();var r=this.count,n=t.index,o=e.index;n<o?(this.atomIndex1[r]=n,this.atomIndex2[r]=o):(this.atomIndex2[r]=n,this.atomIndex1[r]=o),i&&(this.bondOrder[r]=i),this.count+=1},e.prototype.addBondIfConnected=function(t,e,i){return!!t.connectedTo(e)&&(this.addBond(t,e,i),!0)},Object.defineProperties(e.prototype,i),e}(ev),rv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.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"]]},e.prototype.setAltloc=function(t,e){this.altloc[t]=e.charCodeAt(0)},e.prototype.getAltloc=function(t){var e=this.altloc[t];return e?String.fromCharCode(e):""},Object.defineProperties(e.prototype,i),e}(ev),nv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["chainIndex",1,"uint32"],["atomOffset",1,"uint32"],["atomCount",1,"uint16"],["residueTypeId",1,"uint16"],["resno",1,"int32"],["sstruc",1,"uint8"],["inscode",1,"uint8"]]},e.prototype.setSstruc=function(t,e){this.sstruc[t]=e.charCodeAt(0)},e.prototype.getSstruc=function(t){var e=this.sstruc[t];return e?String.fromCharCode(e):""},e.prototype.setInscode=function(t,e){this.inscode[t]=e.charCodeAt(0)},e.prototype.getInscode=function(t){var e=this.inscode[t];return e?String.fromCharCode(e):""},Object.defineProperties(e.prototype,i),e}(ev),ov=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["entityIndex",1,"uint16"],["modelIndex",1,"uint16"],["residueOffset",1,"uint32"],["residueCount",1,"uint32"],["chainname",4,"uint8"],["chainid",4,"uint8"]]},e.prototype.setChainname=function(t,e){var i=4*t;this.chainname[i]=e.charCodeAt(0),this.chainname[i+1]=e.charCodeAt(1),this.chainname[i+2]=e.charCodeAt(2),this.chainname[i+3]=e.charCodeAt(3)},e.prototype.getChainname=function(t){for(var e=this,i="",r=0;r<4;++r){var n=e.chainname[4*t+r];if(!n)break;i+=String.fromCharCode(n)}return i},e.prototype.setChainid=function(t,e){var i=4*t;this.chainid[i]=e.charCodeAt(0),this.chainid[i+1]=e.charCodeAt(1),this.chainid[i+2]=e.charCodeAt(2),this.chainid[i+3]=e.charCodeAt(3)},e.prototype.getChainid=function(t){for(var e=this,i="",r=0;r<4;++r){var n=e.chainid[4*t+r];if(!n)break;i+=String.fromCharCode(n)}return i},Object.defineProperties(e.prototype,i),e}(ev),av=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={__fields:{}};return i.__fields.get=function(){return[["chainOffset",1,"uint32"],["chainCount",1,"uint32"]]},Object.defineProperties(e.prototype,i),e}(ev);Za.prototype={constructor:Za,getCenterIterator:function(t){function e(){var t=this.get(s);return s+=1,t}function i(e){e=Math.min(o-1,Math.max(0,e));var i=c[a%4],r=3*e;if(i.fromArray(n,r),t){var s,u,h,l=Math.min(t,e,o-e-1);for(u=1;u<=l;++u)s=3*u,h=(l+1-u)/(l+1),i.x+=h*n[r-s+0]+h*n[r+s+0],i.y+=h*n[r-s+1]+h*n[r+s+1],i.z+=h*n[r-s+2]+h*n[r+s+2];i.x/=l+1,i.y/=l+1,i.z/=l+1}return a+=1,i}function r(){a=0,s=-1}var n=this.getPosition().center,o=n.length/3,a=0,s=-1,c=[new g,new g,new g,new g];return{size:o,next:e,get:i,reset:r}},getColor:function(t){var e=this.polymer,i=e.structure,r=e.residueCount,n=e.residueIndexStart,o=new Float32Array(3*r),a=t||{};a.structure=i;for(var s=lf.getScheme(a),c=i.getResidueProxy(),u=i.getAtomProxy(),h=0;h<r;++h)c.index=n+h,u.index=c.traceAtomIndex,s.atomColorToArray(u,o,3*h);return{color:o}},getPicking:function(){for(var t=this.polymer,e=t.structure,i=t.residueCount,r=t.residueIndexStart,n=new Float32Array(i),o=e.getResidueProxy(),a=0;a<i;++a)o.index=r+a,n[a]=o.traceAtomIndex;return{picking:new Km(n,e)}},getSize:function(t,e){for(var i=this.polymer,r=i.structure,n=i.residueCount,o=i.residueIndexStart,a=new Float32Array(n),s=new ga(t,e),c=r.getResidueProxy(),u=r.getAtomProxy(),h=0;h<n;++h)c.index=o+h,u.index=c.traceAtomIndex,a[h]=s.atomRadius(u);return{size:a}},getPosition:function(){var t,e,i,r,n,o=this.polymer,a=o.structure,s=o.residueCount,c=s-3,u=new Float32Array(3*s),h=new Float32Array(3*s),l=new Float32Array(s),p=new Float32Array(s),d=new Float32Array(s),f=new Float32Array(s),m=new Float32Array(3*s),v=new g,y=new g,b=new g,x=new g,_=new g,w=new g,S=new g,A=new g,M=new g,P=new g,T=new g,E=new g(0,0,0),C="trace",I=a.getAtomProxy(),R=a.getAtomProxy(o.getAtomIndexByType(0,C)),L=a.getAtomProxy(o.getAtomIndexByType(1,C)),O=a.getAtomProxy(o.getAtomIndexByType(2,C));for(i=0;i<c;++i)I.index=R.index,R.index=L.index,L.index=O.index,O.index=o.getAtomIndexByType(i+3,C),e=3*i,v.subVectors(R,I),y.subVectors(L,R),b.subVectors(O,L),x.subVectors(v,y),_.subVectors(y,b),M.crossVectors(x,_).normalize(),M.toArray(h,e),i>0&&(l[i]=M.angleTo(P)),t=Math.cos(x.angleTo(_)),f[i]=180/Math.PI*Math.acos(t),r=x.length(),n=_.length(),p[i]=Math.sqrt(n*r)/Math.max(2,2*(1-t)),d[i]=Math.abs(y.dot(M)),w.copy(x).multiplyScalar(p[i]/r),S.copy(_).multiplyScalar(p[i]/n),w.subVectors(R,w),S.subVectors(L,S),w.toArray(u,e+3),S.toArray(u,e+6),T.subVectors(I,E),T.toArray(m,e),P.copy(M),E.copy(w);for(w.fromArray(u,3),S.fromArray(u,6),M.subVectors(w,S).normalize(),I.index=o.getAtomIndexByType(0,C),E.copy(I),A.copy(I),Ko(A,M,w),A.toArray(u,0),T.subVectors(E,w),T.toArray(m,0),w.fromArray(u,3*s-6),S.fromArray(u,3*s-9),M.subVectors(w,S).normalize(),I.index=o.getAtomIndexByType(s-1,C),E.copy(I),A.copy(I),Ko(A,M,w),A.toArray(u,3*s-3),i=s-3;i<s;++i)w.fromArray(u,3*i),I.index=o.getAtomIndexByType(i,C),E.copy(I),T.subVectors(E,w),T.toArray(m,3*i);var D=new Float32Array(s),N=new Float32Array(s),k=new Float32Array(s),F=new Float32Array(s);for(D[1]=p[0],N[1]=f[0],k[1]=p[0],i=2;i<s-2;++i)D[i]=.5*(p[i-2]+p[i-1]),N[i]=.5*(f[i-2]+f[i-1]),k[i]=.5*(d[i-2]+d[i-1]),w.fromArray(h,3*(i-2)),S.fromArray(h,3*(i-1)),F[i]=180/Math.PI*Math.acos(Math.cos(w.angleTo(S)));D[s-2]=p[s-4],N[s-2]=f[s-4],k[s-2]=d[s-4];var B=new Float32Array(3*s);for(Lo(h,B,0,0,3),Lo(h,B,0,3,3),i=2;i<s-2;++i)w.fromArray(h,3*(i-2)),S.fromArray(h,3*(i-1)),M.addVectors(S,w).multiplyScalar(.5).normalize(),M.toArray(B,3*i);return Lo(h,B,3*s-12,3*s-6,3),Lo(h,B,3*s-12,3*s-3,3),{center:u,axis:B,bending:F,radius:D,rise:k,twist:N,resdir:m}}},Ka.prototype={constructor:Ka,getAxis:function(t,e,i,r,n,o){t=t||30,e=e||2.5,i=void 0!==i&&i;var a=this.polymer,s=a.structure,c=a.residueCount,u=a.residueIndexStart,h=this.position,l=r||{};l.structure=s;for(var p,d,f=lf.getScheme(l),m=new ga(n,o),v=0,y=0,b=[],x=[],_=[],w=[],S=[],A=[],M=[],P=[],T=[],E=[],C=[],I=new g,R=new g,L=s.getResidueProxy(),O=s.getResidueProxy(),D=s.getAtomProxy(),N=new g,k=new g,F=!1,B=0;B<c;++B)if(L.index=u+B,N.fromArray(h.center,3*B),B===c-1?F=!0:(O.index=u+B+1,k.fromArray(h.center,3*B+3),i&&L.sstruc!==O.sstruc?F=!0:N.distanceTo(k)>e?F=!0:h.bending[B]>t&&(F=!0)),F){if(B-v<4){v=B,F=!1;continue}D.index=L.traceAtomIndex,E=h.axis.subarray(3*v+3,3*B),C=h.center.subarray(3*v,3*B+3),p=Zo(E).normalize(),d=Zo(C),I.fromArray(C),Ko(I,p,d),R.fromArray(C,C.length-3),Ko(R,p,d),p.subVectors(R,I),p.toArray(b,y),d.toArray(x,y),I.toArray(_,y),R.toArray(w,y),f.atomColorToArray(D,S,y),A.push(D.index),M.push(m.atomRadius(D)),P.push(u+v),T.push(u+B+1-v),y+=3,v=B,F=!1}var z=new Float32Array(A);return{axis:new Float32Array(b),center:new Float32Array(x),begin:new Float32Array(_),end:new Float32Array(w),color:new Float32Array(S),picking:new Km(z,s),size:new Float32Array(M),residueOffset:P,residueCount:T}}},Qa.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},peek:function(){return this.content[0]},remove:function(t){for(var e=this,i=this.content.length,r=0;r<i;r++)if(e.content[r]===t){var n=e.content.pop();return void(r!==i-1&&(e.content[r]=n,e.scoreFunction(n)<e.scoreFunction(t)?e.bubbleUp(r):e.sinkDown(r)))}throw new Error("Node not found.")},size:function(){return this.content.length},bubbleUp:function(t){for(var e=this,i=this.content[t];t>0;){var r=Math.floor((t+1)/2)-1,n=e.content[r];if(!(e.scoreFunction(i)<e.scoreFunction(n)))break;e.content[r]=i,e.content[t]=n,t=r}},sinkDown:function(t){for(var e,i=this,r=this.content.length,n=this.content[t],o=this.scoreFunction(n);;){var a=2*(t+1),s=a-1,c=null;if(s<r){var u=i.content[s];(e=i.scoreFunction(u))<o&&(c=s)}if(a<r){var h=i.content[a];i.scoreFunction(h)<(null===c?o:e)&&(c=a)}if(null===c)break;i.content[t]=i.content[c],i.content[c]=n,t=c}}},ts.prototype={nearest:function(){var t=new Float32Array(3);return function(e,i,r){e.toArray?e.toArray(t):e.positionToArray&&e.positionToArray(t);for(var n=this.kdtree.nearest(t,i,r),o=this.kdtree.indices,a=this.kdtree.nodes,s=this.atomIndices,c=[],u=0,h=n.length;u<h;++u){var l=n[u],p=l[0],d=l[1];c.push({index:s[o[a[p]]],distance:d})}return c}}()};var sv={" ":"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"},cv={"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":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},uv=function(t){this.name=t||"",this.partList=[]},hv={type:{}};hv.type.get=function(){return"Assembly"},uv.prototype.addPart=function(t,e){var i=new lv(t,e);return this.partList.push(i),i},uv.prototype._getCount=function(t,e){var i=0;return this.partList.forEach(function(r){i+=r[e](t)}),i},uv.prototype.getAtomCount=function(t){return this._getCount(t,"getAtomCount")},uv.prototype.getResidueCount=function(t){return this._getCount(t,"getResidueCount")},uv.prototype.getInstanceCount=function(){var t=0;return this.partList.forEach(function(e){t+=e.matrixList.length}),t},uv.prototype.isIdentity=function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new v).equals(e.matrixList[0]))return!1;var i=[];return t.eachChain(function(t){i.push(t.chainname)}),i=En(i),e.chainList.length===i.length},uv.prototype.getBoundingBox=function(t){var e=new st;return this.partList.forEach(function(i){var r=i.getBoundingBox(t);e.expandByPoint(r.min),e.expandByPoint(r.max)}),e},uv.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter()},uv.prototype.getSelection=function(){var t=[];return this.partList.forEach(function(e){t=t.concat(e.chainList)}),is(t)},Object.defineProperties(uv.prototype,hv);var lv=function(t,e){this.matrixList=t||[],this.chainList=e||[]},pv={type:{}};pv.type.get=function(){return"AssemblyPart"},lv.prototype._getCount=function(t,e){var i=0,r=this.chainList;return t.eachChain(function(t){(0===r.length||r.includes(t.chainname))&&(i+=t[e])}),this.matrixList.length*i},lv.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},lv.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},lv.prototype.getBoundingBox=function(t){var e=new st,i=new st,r=this.getSelection(),n=t.getBoundingBox(r);return this.matrixList.forEach(function(t){i.copy(n).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)}),e},lv.prototype.getSelection=function(){return is(this.chainList)},lv.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},lv.prototype.getInstanceList=function(){for(var t=this,e=[],i=0,r=this.matrixList.length;i<r;++i)e.push({id:i+1,name:i,matrix:t.matrixList[i]});return e},Object.defineProperties(lv.prototype,pv);var dv=function(){var e=function(t,e,i,r){for(var n=t.structure,o=t.residueIndexStart,a=n.getResidueProxy(),s=n.getResidueProxy(),c=n.getAtomProxy(),u=n.getAtomProxy(),h=Math.max(0,e-2);h<=e;++h)for(var l=2;l<5;++l)if(!(h+l>=t.residueCount)){a.index=o+h,s.index=o+h+l,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-i[l-2])>r)return!1}return!0},i=function(t,i){return e(t,i,[5.45,5.18,6.37],2.1)},r=function(t,i){return e(t,i,[6.1,10.4,13],1.42)},n=function(t){for(var e=t.residueStore,n=t.residueIndexStart,o=0,a=t.residueCount;o<a;++o){var s="c";i(t,o)?s="h":r(t,o)&&(s="s"),e.sstruc[n+o]=s.charCodeAt(0)}},o=function(t){for(var e=t.residueStore,i=t.residueIndexStart,r=new Ka(t).position,n=new g,o=new g,a=0,s=t.residueCount;a<s;++a){n.fromArray(r.center,3*a),o.fromArray(r.center,3*a+3);var c=n.distanceTo(o);c<2&&c>1&&r.bending[a]<20&&(e.sstruc[i+a]="h".charCodeAt(0),e.sstruc[i+a+1]="h".charCodeAt(0))}};return function(e){t.Debug&&cf.time("calculateSecondaryStructure"),e.eachPolymer(function(t){if(!(t.residueCount<4)){if(t.isCg())o(t);else{if(!t.isProtein())return;n(t)}var e,i=0;t.eachResidue(function(t){t.sstruc===e?i+=1:(1===i&&(t.index-=1,t.sstruc="c"),i=1,e=t.sstruc)})}}),t.Debug&&cf.timeEnd("calculateSecondaryStructure")}}(),fv=["H","C","O","N","S","P"],mv=["NA","CL","FE"],gv=function(t,e,i){this.structure=t,i=i||ls(e),this.atomname=e,this.element=i,this.vdw=Eg[i],this.covalent=Cg[i]},vv=function(t){this.structure=t,this.dict={},this.list=[]};vv.prototype.add=function(t,e){var i=ds(t=t.toUpperCase(),e=e?e.toUpperCase():ls(t)),r=this.dict[i];if(void 0===r){var n=new gv(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(n)}return r},vv.prototype.get=function(t){return this.list[t]};var yv=function(t,e,i,r,n,o){this.structure=t,this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=n,this.bonds=o,this.rings=void 0,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();var a=Gg[this.backboneType],s=Gg[this.backboneStartType],c=Gg[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=void 0!==u?u:-1;var h=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=void 0!==h?h:-1;var l=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=void 0!==l?l:-1;var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=void 0!==p?p:-1;var d=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=void 0!==d?d:-1;var f;f=kg.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=void 0!==f?f:-1,this.bondReferenceAtomIndices=[]};yv.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=Ug;break;case 4:case 5:t=jg;break;default:return e}for(var i=this.structure.atomMap,r=this.atomTypeIdList,n=0,o=this.atomCount;n<o;++n){var a=i.get(r[n]);t.includes(a.atomname)&&e.push(n)}return e},yv.prototype.getMoleculeType=function(){return this.isProtein()?3:this.isRna()?4:this.isDna()?5:this.isWater()?1:this.isIon()?2:this.isSaccharide()?6:0},yv.prototype.getBackboneType=function(t){return this.hasProteinBackbone(t)?1:this.hasRnaBackbone(t)?2:this.hasDnaBackbone(t)?3:this.hasCgProteinBackbone(t)?4:this.hasCgRnaBackbone(t)?5:this.hasCgDnaBackbone(t)?6:yg},yv.prototype.isProtein=function(){return this.chemCompType?bg.includes(this.chemCompType):this.hasAtomWithName("CA","C","N")||Og.includes(this.resname)},yv.prototype.isCg=function(){var t=this.backboneType;return 4===t||5===t||6===t},yv.prototype.isNucleic=function(){return this.isRna()||this.isDna()},yv.prototype.isRna=function(){return this.chemCompType?xg.includes(this.chemCompType):this.hasAtomWithName(["P","O3'","O3*"],["C4'","C4*"],["O2'","O2*","F2'","F2*"])||Dg.includes(this.resname)&&this.hasAtomWithName(["O2'","O2*","F2'","F2*"])},yv.prototype.isDna=function(){return this.chemCompType?_g.includes(this.chemCompType):this.hasAtomWithName(["P","O3'","O3*"],["C3'","C3*"])&&!this.hasAtomWithName(["O2'","O2*","F2'","F2*"])||Ng.includes(this.resname)},yv.prototype.isHetero=function(){return 1===this.hetero},yv.prototype.isIon=function(){return Bg.includes(this.resname)},yv.prototype.isWater=function(){return Fg.includes(this.resname)},yv.prototype.isSaccharide=function(){return this.chemCompType?wg.includes(this.chemCompType):zg.includes(this.resname)},yv.prototype.hasBackboneAtoms=function(t,e){var i=Gg[e];return-1===t?this.hasAtomWithName(i.trace,i.backboneEnd,i.direction1,i.direction2):0===t?this.hasAtomWithName(i.trace,i.direction1,i.direction2):1===t?this.hasAtomWithName(i.trace,i.backboneStart,i.direction1,i.direction2):this.hasAtomWithName(i.trace,i.backboneStart,i.backboneEnd,i.direction1,i.direction2)},yv.prototype.hasProteinBackbone=function(t){return this.isProtein()&&this.hasBackboneAtoms(t,1)},yv.prototype.hasRnaBackbone=function(t){return this.isRna()&&this.hasBackboneAtoms(t,2)},yv.prototype.hasDnaBackbone=function(t){return this.isDna()&&this.hasBackboneAtoms(t,3)},yv.prototype.hasCgProteinBackbone=function(t){return this.isProtein()&&this.hasBackboneAtoms(t,4)},yv.prototype.hasCgRnaBackbone=function(t){return this.isRna()&&this.hasBackboneAtoms(t,5)},yv.prototype.hasCgDnaBackbone=function(t){return this.isDna()&&this.hasBackboneAtoms(t,6)},yv.prototype.hasBackbone=function(t){return this.hasProteinBackbone(t)||this.hasRnaBackbone(t)||this.hasDnaBackbone(t)||this.hasCgProteinBackbone(t)||this.hasCgRnaBackbone(t)||this.hasCgDnaBackbone(t)},yv.prototype.getAtomIndexByName=function(t){var e=this.atomCount,i=this.structure.atomMap,r=this.atomTypeIdList;if(Array.isArray(t))for(var n=0;n<e;++n){var o=r[n];if(t.includes(i.get(o).atomname))return n}else for(var a=0;a<e;++a){var s=r[a];if(t===i.get(s).atomname)return a}},yv.prototype.hasAtomWithName=function(){for(var t=arguments,e=this,i=arguments.length,r=0;r<i;++r)if(void 0!==t[r]&&void 0===e.getAtomIndexByName(t[r]))return!1;return!0},yv.prototype.getBonds=function(t){return void 0===this.bonds&&(this.bonds=as(t)),this.bonds},yv.prototype.getRings=function(){return void 0===this.rings&&this.calculateRings(),this.rings},yv.prototype.getBondGraph=function(){return void 0===this.bondGraph&&this.calculateBondGraph(),this.bondGraph},yv.prototype.calculateBondGraph=function(){for(var t=this.bondGraph={},e=this.getBonds(),i=e.atomIndices1.length,r=e.atomIndices1,n=e.atomIndices2,o=0;o<i;++o){var a=r[o],s=n[o];(t[a]=t[a]||[]).push(s),(t[s]=t[s]||[]).push(a)}},yv.prototype.calculateRings=function(){function t(a,s,c){if(i[a])throw new Error("DFS revisited atom");i[a]=1,o.push(a);for(var u=s.length,h=0;h<u;++h){var l=s[h];if(0===i[l])e[l]&&e[l].length>=2?t(l,e[l],a):i[l]=2;else if(1===i[l]&&c&&c!==l){var p=[l];r[l]=1,n.push(p);for(var d=o.length-1;d>=0;--d){var f=o[d];if(f===l)break;p.push(f),r[f]=1}}}i[a]=2,o.pop()}for(var e=this.getBondGraph(),i=new Int8Array(this.atomCount),r=new Int8Array(this.atomCount),n=[],o=[],a=0;a<this.atomCount;++a)if(!i[a]){var s=e[a];!s||s.length<2?i[a]=2:(o.length=0,t(a,s))}this.rings={flags:r,rings:n}},yv.prototype.assignBondReferenceAtomIndices=function(){var t=this.getBondGraph(),e=this.getRings(),i=e.flags,r=e.rings,n=this.bonds.atomIndices1,o=this.bonds.atomIndices2,a=this.bonds.bondOrders,s=this.bondReferenceAtomIndices,c=this.bonds.atomIndices1.length;s.length=0;for(var u=0;u<c;++u)if(!(a[u]<=1)){var h=n[u],l=o[u];if(i[h]&&i[l]){for(var p=0;p<r.length&&void 0===s[u];++p)for(var d=r[p],f=null,m=!1,g=0;g<d.length;++g){var v=d[g];if(v===h||v===l?m=!0:f=v,m&&null!==f){s[u]=f;break}}if(void 0!==s[u])continue}if(t[h].length>1)for(var y=0;y<t[h].length;++y){var b=t[h][y];if(b!==l){s[u]=b;break}}else if(t[l].length>1)for(var x=0;x<t[l].length;++x){var _=t[l][x];if(_!==h){s[u]=_;break}}else;}},yv.prototype.getBondIndex=function(t,e){for(var i=this.bonds,r=i.atomIndices1,n=i.atomIndices2,o=r.indexOf(t),a=n.indexOf(e),s=a;-1!==o;){for(;-1!==a;){if(o===a)return o;a=n.indexOf(e,a+1)}o=r.indexOf(t,o+1),a=s}},yv.prototype.getBondReferenceAtomIndex=function(t,e){var i=this.getBondIndex(t,e);if(void 0!==i)return 0===this.bondReferenceAtomIndices.length&&this.assignBondReferenceAtomIndices(),this.bondReferenceAtomIndices[i]};var bv=function(t){this.structure=t,this.dict={},this.list=[]};bv.prototype.add=function(t,e,i,r,n){var o=fs(t=t.toUpperCase(),e,i,r),a=this.dict[o];if(void 0===a){var s=new yv(this.structure,t,e,i,r,n);a=this.list.length,this.dict[o]=a,this.list.push(s)}return a},bv.prototype.get=function(t){return this.list[t]};var xv=function(t,e){this.structure=t,this.bondStore=t.bondStore,this.index=e,this._v12=new g,this._v13=new g,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()},_v={atom1:{},atom2:{},atomIndex1:{},atomIndex2:{},bondOrder:{}};_v.atom1.get=function(){return this.structure.getAtomProxy(this.atomIndex1)},_v.atom2.get=function(){return this.structure.getAtomProxy(this.atomIndex2)},_v.atomIndex1.get=function(){return this.bondStore.atomIndex1[this.index]},_v.atomIndex1.set=function(t){this.bondStore.atomIndex1[this.index]=t},_v.atomIndex2.get=function(){return this.bondStore.atomIndex2[this.index]},_v.atomIndex2.set=function(t){this.bondStore.atomIndex2[this.index]=t},_v.bondOrder.get=function(){return this.bondStore.bondOrder[this.index]},_v.bondOrder.set=function(t){this.bondStore.bondOrder[this.index]=t},xv.prototype.getReferenceAtomIndex=function(){var t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex===e.residueIndex){var i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,n=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==n)return n+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}},xv.prototype.calculateShiftDir=function(t){t||(t=new g);var e=this._ap1,i=this._ap2,r=this._ap3,n=this._v12,o=this._v13;e.index=this.atomIndex1,i.index=this.atomIndex2;var a=this.getReferenceAtomIndex();n.subVectors(e,i).normalize(),void 0!==a?(r.index=a,o.subVectors(e,r)):o.copy(e),o.normalize();var s=n.dot(o);return 1-Math.abs(s)<1e-5&&(o.set(1,0,0),s=n.dot(o),1-Math.abs(s)<1e-5&&(o.set(0,1,0),s=n.dot(o))),t.copy(o.sub(n.multiplyScalar(s))).normalize()},xv.prototype.qualifiedName=function(){return this.atomIndex1+"="+this.atomIndex2},xv.prototype.clone=function(){return new this.constructor(this.structure,this.index)},xv.prototype.toObject=function(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}},Object.defineProperties(xv.prototype,_v);var wv=function(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap,this.index=e},Sv={bondHash:{},entity:{},entityIndex:{},modelIndex:{},chainIndex:{},residue:{},residueIndex:{},sstruc:{},inscode:{},resno:{},chainname:{},chainid:{},residueType:{},atomType:{},residueAtomOffset:{},resname:{},hetero:{},atomname:{},element:{},vdw:{},covalent:{},x:{},y:{},z:{},serial:{},bfactor:{},occupancy:{},altloc:{}};Sv.bondHash.get=function(){return this.structure.bondHash},Sv.entity.get=function(){return this.structure.entityList[this.entityIndex]},Sv.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},Sv.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},Sv.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndex]},Sv.residue.get=function(){return console.warn("residue - might be expensive"),this.structure.getResidueProxy(this.residueIndex)},Sv.residueIndex.get=function(){return this.atomStore.residueIndex[this.index]},Sv.residueIndex.set=function(t){this.atomStore.residueIndex[this.index]=t},Sv.sstruc.get=function(){return this.residueStore.getSstruc(this.residueIndex)},Sv.inscode.get=function(){return this.residueStore.getInscode(this.residueIndex)},Sv.resno.get=function(){return this.residueStore.resno[this.residueIndex]},Sv.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},Sv.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},Sv.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.residueIndex])},Sv.atomType.get=function(){return this.atomMap.get(this.atomStore.atomTypeId[this.index])},Sv.residueAtomOffset.get=function(){return this.residueStore.atomOffset[this.residueIndex]},Sv.resname.get=function(){return this.residueType.resname},Sv.hetero.get=function(){return this.residueType.hetero},Sv.atomname.get=function(){return this.atomType.atomname},Sv.element.get=function(){return this.atomType.element},Sv.vdw.get=function(){return this.atomType.vdw},Sv.covalent.get=function(){return this.atomType.covalent},Sv.x.get=function(){return this.atomStore.x[this.index]},Sv.x.set=function(t){this.atomStore.x[this.index]=t},Sv.y.get=function(){return this.atomStore.y[this.index]},Sv.y.set=function(t){this.atomStore.y[this.index]=t},Sv.z.get=function(){return this.atomStore.z[this.index]},Sv.z.set=function(t){this.atomStore.z[this.index]=t},Sv.serial.get=function(){return this.atomStore.serial[this.index]},Sv.serial.set=function(t){this.atomStore.serial[this.index]=t},Sv.bfactor.get=function(){return this.atomStore.bfactor[this.index]},Sv.bfactor.set=function(t){this.atomStore.bfactor[this.index]=t},Sv.occupancy.get=function(){return this.atomStore.occupancy[this.index]},Sv.occupancy.set=function(t){this.atomStore.occupancy[this.index]=t},Sv.altloc.get=function(){return this.atomStore.getAltloc(this.index)},Sv.altloc.set=function(t){this.atomStore.setAltloc(this.index,t)},wv.prototype.eachBond=function(t,e){e=e||this.structure._bp;for(var i=this.index,r=this.bondHash,n=r.indexArray,o=r.countArray[i],a=r.offsetArray[i],s=0;s<o;++s)e.index=n[a+s],t(e)},wv.prototype.eachBondedAtom=function(t,e){e=e||this.structure._ap;var i=this.index;this.eachBond(function(r){i!==r.atomIndex1?e.index=r.atomIndex1:e.index=r.atomIndex2,t(e)})},wv.prototype.isBackbone=function(){var t=this.residueType.backboneIndexList;if(t.length>0){var e=this.residueStore.atomOffset[this.residueIndex];return t.includes(this.index-e)}return!1},wv.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},wv.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},wv.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},wv.prototype.isHetero=function(){return 1===this.residueType.hetero},wv.prototype.isProtein=function(){return 3===this.residueType.moleculeType},wv.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},wv.prototype.isRna=function(){return 4===this.residueType.moleculeType},wv.prototype.isDna=function(){return 5===this.residueType.moleculeType},wv.prototype.isWater=function(){return 1===this.residueType.moleculeType},wv.prototype.isIon=function(){return 2===this.residueType.moleculeType},wv.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},wv.prototype.isHelix=function(){return Mg.includes(this.sstruc)},wv.prototype.isSheet=function(){return Pg.includes(this.sstruc)},wv.prototype.isTurn=function(){return Tg.includes(this.sstruc)&&this.isProtein()},wv.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},wv.prototype.isRing=function(){return 1===this.residueType.getRings().flags[this.index-this.residueAtomOffset]},wv.prototype.distanceTo=function(t){var e=this.atomStore,i=t.atomStore,r=this.index,n=t.index,o=e.x[r]-i.x[n],a=e.y[r]-i.y[n],s=e.z[r]-i.z[n],c=o*o+a*a+s*s;return Math.sqrt(c)},wv.prototype.connectedTo=function(t){var e=this.atomStore,i=t.atomStore,r=this.index,n=t.index;if(e.altloc&&i.altloc){var o=e.altloc[r],a=i.altloc[n];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=e.x[r]-i.x[n],c=e.y[r]-i.y[n],u=e.z[r]-i.z[n],h=s*s+c*c+u*u;if(h<64&&this.isCg())return!0;if(isNaN(h))return!1;var l=this.covalent+t.covalent,p=l+.3,d=l-.5;return h<p*p&&h>d*d},wv.prototype.positionFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this},wv.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var 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},wv.prototype.positionToVector3=function(t){return void 0===t&&(t=new g),t.x=this.x,t.y=this.y,t.z=this.z,t},wv.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},wv.prototype.getResidueBonds=function(t){var e,i,r,n,o=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(t||(n=[]),e=c.indexOf(a);-1!==e;){if(r=u[e]+o,t)return r;n.push(r),e=c.indexOf(a,e+1)}for(i=u.indexOf(a);-1!==i;){if(r=c[i]+o,t)return r;n.push(r),i=u.indexOf(a,i+1)}return n},wv.prototype.qualifiedName=function(t){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},wv.prototype.clone=function(){return new this.constructor(this.structure,this.index)},wv.prototype.toObject=function(){return{index:this.index,residueIndex:this.residueIndex,atomno:this.atomno,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(wv.prototype,Sv);var Av=function(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap,this.index=e},Mv={entity:{},entityIndex:{},chain:{},chainIndex:{},atomOffset:{},atomCount:{},atomEnd:{},modelIndex:{},chainname:{},chainid:{},resno:{},sstruc:{},inscode:{},residueType:{},resname:{},hetero:{},moleculeType:{},backboneType:{},backboneStartType:{},backboneEndType:{},traceAtomIndex:{},direction1AtomIndex:{},direction2AtomIndex:{},backboneStartAtomIndex:{},backboneEndAtomIndex:{},rungEndAtomIndex:{}};Mv.entity.get=function(){return this.structure.entityList[this.entityIndex]},Mv.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},Mv.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},Mv.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},Mv.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},Mv.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},Mv.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},Mv.atomCount.get=function(){return this.residueStore.atomCount[this.index]},Mv.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},Mv.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},Mv.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},Mv.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},Mv.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},Mv.resno.get=function(){return this.residueStore.resno[this.index]},Mv.resno.set=function(t){this.residueStore.resno[this.index]=t},Mv.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},Mv.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},Mv.inscode.get=function(){return this.residueStore.getInscode(this.index)},Mv.inscode.set=function(t){this.residueStore.getInscode(this.index,t)},Mv.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},Mv.resname.get=function(){return this.residueType.resname},Mv.hetero.get=function(){return this.residueType.hetero},Mv.moleculeType.get=function(){return this.residueType.moleculeType},Mv.backboneType.get=function(){return this.residueType.backboneType},Mv.backboneStartType.get=function(){return this.residueType.backboneStartType},Mv.backboneEndType.get=function(){return this.residueType.backboneEndType},Mv.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},Mv.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},Mv.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},Mv.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},Mv.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},Mv.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},Av.prototype.eachAtom=function(t,e){var i,r=this.atomCount,n=this.atomOffset,o=this.structure._ap,a=n+r;if(e&&e.atomOnlyTest){var s=e.atomOnlyTest;for(i=n;i<a;++i)o.index=i,s(o)&&t(o)}else for(i=n;i<a;++i)o.index=i,t(o)},Av.prototype.isProtein=function(){return 3===this.residueType.moleculeType},Av.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},Av.prototype.isRna=function(){return 4===this.residueType.moleculeType},Av.prototype.isDna=function(){return 5===this.residueType.moleculeType},Av.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},Av.prototype.isPolymer=function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},Av.prototype.isHetero=function(){return 1===this.residueType.hetero},Av.prototype.isWater=function(){return 1===this.residueType.moleculeType},Av.prototype.isIon=function(){return 2===this.residueType.moleculeType},Av.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},Av.prototype.isHelix=function(){return Mg.includes(this.sstruc)},Av.prototype.isSheet=function(){return Pg.includes(this.sstruc)},Av.prototype.isTurn=function(){return Tg.includes(this.sstruc)&&this.isProtein()},Av.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},Av.prototype.getResname1=function(){return Lg[this.resname.toUpperCase()]||"X"},Av.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},Av.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},Av.prototype.getAtomByName=function(t){return this.residueType.getAtomByName(t)},Av.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},Av.prototype.getAtomnameList=function(){var t=this;console.warn("getAtomnameList - might be expensive");for(var e=this.atomCount,i=this.atomOffset,r=new Array(e),n=0;n<e;++n)r[n]=t.getAtomType(i+n).atomname;return r},Av.prototype.connectedTo=function(t){var e=this.structure.getAtomProxy(this.backboneEndAtomIndex),i=this.structure.getAtomProxy(t.backboneStartAtomIndex);return!(!e||!i)&&e.connectedTo(i)},Av.prototype.getNextConnectedResidue=function(){var t=this.chainStore.residueOffset[this.chainIndex],e=this.chainStore.residueCount[this.chainIndex],i=this.index+1;if(i<t+e){var r=this.structure.getResidueProxy(i);if(this.connectedTo(r))return r}else if(i===t+e){var n=this.structure.getResidueProxy(t);if(this.connectedTo(n))return n}},Av.prototype.getPreviousConnectedResidue=function(){var t=this.chainStore.residueOffset[this.chainIndex],e=this.index-1;if(e>=t){var i=this.structure.getResidueProxy(e);if(i.connectedTo(this))return i}else if(e===t-1){var r=this.chainStore.residueCount[this.chainIndex],n=this.structure.getResidueProxy(t+r-1);if(n.connectedTo(this))return n}},Av.prototype.getBonds=function(){return this.residueType.getBonds(this)},Av.prototype.getRings=function(){return this.residueType.getRings()},Av.prototype.qualifiedName=function(t){var 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},Av.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Av.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(Av.prototype,Mv);var Pv=function(t,e,i){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueIndexStart=e,this.residueIndexEnd=i,this.residueCount=i-e+1;var r=this.structure.getResidueProxy(this.residueIndexStart),n=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();var o=n.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=this.isNextConnected&&void 0!==o.getNextConnectedResidue(),this.isCyclic=n.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()},Tv={chainIndex:{},modelIndex:{},chainname:{}};Tv.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},Tv.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},Tv.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},Pv.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},Pv.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},Pv.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},Pv.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},Pv.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},Pv.prototype.getAtomIndexByType=function(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));var i=this.__residueProxy;i.index=this.residueIndexStart+t;var r;switch(e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:var n=i.getAtomByName(e);r=n?n.index:void 0}return r},Pv.prototype.eachAtom=function(t,e){this.eachResidue(function(i){i.eachAtom(t,e)},e)},Pv.prototype.eachAtomN=function(t,e,i){var r,n=this,o=this.residueCount,a=new Array(t);for(r=0;r<t;++r)a[r]=n.structure.getAtomProxy(n.getAtomIndexByType(r,i));e.apply(this,a);for(var s=t;s<o;++s){for(r=1;r<t;++r)a[r-1].index=a[r].index;a[t-1].index=n.getAtomIndexByType(s,i),e.apply(n,a)}},Pv.prototype.eachAtomN2=function(t,e,i){var r=this,n=this.atomOffset,o=this.atomCount,a=n+o;if(!(o<t)){for(var s=new Array(t),c=0;c<t;++c)s[c]=r.structure.getAtomProxy();var u=this.structure.atomSetCache["__"+i];void 0===u&&(cf.warn("no precomputed atomSet for: "+i),u=this.structure.getAtomSet(!1),this.eachResidue(function(t){var e=t.getAtomByName(i);u.set(e.index)}));var h=0;u.forEach(function(i){if(i>=n&&i<a){for(var r=1;r<t;++r)s[r-1].index=s[r].index;s[t-1].index=i,(h+=1)>=t&&e.apply(this,s)}})}},Pv.prototype.eachResidue=function(t){for(var e=this.structure.getResidueProxy(),i=this.residueCount,r=this.residueIndexStart,n=0;n<i;++n)e.index=r+n,t(e)},Pv.prototype.qualifiedName=function(){var t=this.structure.getResidueProxy(this.residueIndexStart),e=this.structure.getResidueProxy(this.residueIndexEnd);return t.qualifiedName()+" - "+e.qualifiedName()},Object.defineProperties(Pv.prototype,Tv);var Ev=function(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e},Cv={entity:{},model:{},entityIndex:{},modelIndex:{},residueOffset:{},residueCount:{},residueEnd:{},atomOffset:{},atomEnd:{},atomCount:{},chainname:{},chainid:{}};Cv.entity.get=function(){return this.structure.entityList[this.entityIndex]},Cv.model.get=function(){return this.structure.getModelProxy(this.modelIndex)},Cv.entityIndex.get=function(){return this.chainStore.entityIndex[this.index]},Cv.entityIndex.set=function(t){this.chainStore.entityIndex[this.index]=t},Cv.modelIndex.get=function(){return this.chainStore.modelIndex[this.index]},Cv.modelIndex.set=function(t){this.chainStore.modelIndex[this.index]=t},Cv.residueOffset.get=function(){return this.chainStore.residueOffset[this.index]},Cv.residueOffset.set=function(t){this.chainStore.residueOffset[this.index]=t},Cv.residueCount.get=function(){return this.chainStore.residueCount[this.index]},Cv.residueCount.set=function(t){this.chainStore.residueCount[this.index]=t},Cv.residueEnd.get=function(){return this.residueOffset+this.residueCount-1},Cv.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},Cv.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},Cv.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},Cv.chainname.get=function(){return this.chainStore.getChainname(this.index)},Cv.chainname.set=function(t){this.chainStore.setChainname(this.index,t)},Cv.chainid.get=function(){return this.chainStore.getChainid(this.index)},Cv.chainid.set=function(t){this.chainStore.setChainid(this.index,t)},Ev.prototype.eachAtom=function(t,e){this.eachResidue(function(i){i.eachAtom(t,e)},e)},Ev.prototype.eachResidue=function(t,e){var i,r=this.residueCount,n=this.residueOffset,o=this.structure._rp,a=n+r;if(e&&e.test){var s=e.residueOnlyTest;if(s)for(i=n;i<a;++i)o.index=i,s(o)&&t(o,e);else for(i=n;i<a;++i)o.index=i,t(o,e)}else for(i=n;i<a;++i)o.index=i,t(o)},Ev.prototype.eachResidueN=function(t,e){var i,r=this,n=this.residueCount,o=this.residueOffset,a=o+n;if(!(n<t)){var s=new Array(t);for(i=0;i<t;++i)s[i]=r.structure.getResidueProxy(o+i);e.apply(this,s);for(var c=o+t;c<a;++c){for(i=0;i<t;++i)s[i].index+=1;e.apply(r,s)}}},Ev.prototype.eachPolymer=function(t,e){for(var i,r,n=e?e.residueOnlyTest:void 0,o=this.model.structure,a=this.residueCount,s=this.residueOffset,c=s+a,u=this.structure.getResidueProxy(),h=this.structure.getResidueProxy(s),l=this.structure.getAtomProxy(),p=this.structure.getAtomProxy(),d=!0,f=s+1;f<c;++f){u.index=h.index,h.index=f,d&&(i=u.index,d=!1),r=h.index;var m=d?u.backboneEndType:u.backboneType,g=h.backboneType;m!==yg&&m===g?(l.index=u.backboneEndAtomIndex,p.index=h.backboneStartAtomIndex,l&&p&&l.connectedTo(p)&&(!n||n(u)&&n(h))||(u.index-i>1&&t(new Pv(o,i,u.index)),i=r)):(m!==yg&&u.index-i>1&&t(new Pv(o,i,u.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneStartType&&t(new Pv(o,i,r))},Ev.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},Ev.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Ev.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(Ev.prototype,Cv);var Iv=function(t,e){this.structure=t,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e},Rv={chainOffset:{},chainCount:{},residueOffset:{},atomOffset:{},chainEnd:{},residueEnd:{},atomEnd:{},residueCount:{},atomCount:{}};Rv.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},Rv.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},Rv.chainCount.get=function(){return this.modelStore.chainCount[this.index]},Rv.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},Rv.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},Rv.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},Rv.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},Rv.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},Rv.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},Rv.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},Rv.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},Iv.prototype.eachAtom=function(t,e){this.eachChain(function(i){i.eachAtom(t,e)},e)},Iv.prototype.eachResidue=function(t,e){this.eachChain(function(i){i.eachResidue(t,e)},e)},Iv.prototype.eachPolymer=function(t,e){if(e&&e.chainOnlyTest){var i=e.chainOnlyTest;this.eachChain(function(r){i(r)&&r.eachPolymer(t,e)})}else this.eachChain(function(i){i.eachPolymer(t,e)})},Iv.prototype.eachChain=function(t,e){var i,r=this.chainCount,n=this.chainOffset,o=this.structure._cp,a=n+r;if(e&&e.test){var s=e.chainOnlyTest;if(s)for(i=n;i<a;++i)o.index=i,s(o)&&t(o,e);else for(i=n;i<a;++i)o.index=i,t(o,e)}else for(i=n;i<a;++i)o.index=i,t(o)},Iv.prototype.qualifiedName=function(){return"/"+this.index},Iv.prototype.clone=function(){return new this.constructor(this.structure,this.index)},Iv.prototype.toObject=function(){return{index:this.index,chainOffset:this.chainOffset,chainCount:this.chainCount}},Object.defineProperties(Iv.prototype,Rv);var Lv=function(t,e){this.signals={refreshed:new oo},this.init(t,e)},Ov={type:{}};Lv.prototype.init=function(t,e){this.name=t,this.path=e,this.title="",this.id="",this.header={},this.extraData={},this.atomSetCache=void 0,this.atomSetDict={},this.biomolDict={},this.entityList=[],this.unitcell=void 0,this.frames=[],this.boxes=[],this.validation=void 0,this.bondStore=new iv(0),this.backboneBondStore=new iv(0),this.rungBondStore=new iv(0),this.atomStore=new rv(0),this.residueStore=new nv(0),this.chainStore=new ov(0),this.modelStore=new av(0),this.atomMap=new vv(this),this.residueMap=new bv(this),this.bondHash=void 0,this.spatialHash=void 0,this.atomSet=void 0,this.bondSet=void 0,this.center=void 0,this.boundingBox=void 0,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy()},Ov.type.get=function(){return"Structure"},Lv.prototype.finalizeAtoms=function(){this.atomSet=this.getAtomSet(),this.atomCount=this.atomStore.count,this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(),this.spatialHash=new Ba(this.atomStore,this.boundingBox)},Lv.prototype.finalizeBonds=function(){var t=this;this.bondSet=this.getBondSet(),this.bondCount=this.bondStore.count,this.bondHash=new tv(this.bondStore,this.atomStore.count),this.atomSetCache={},this.atomSetDict.rung||(this.atomSetDict.rung=this.getAtomSet(!1));for(var e in t.atomSetDict)t.atomSetCache["__"+e]=t.atomSetDict[e].clone()},Lv.prototype.getBondProxy=function(t){return new xv(this,t)},Lv.prototype.getAtomProxy=function(t){return new wv(this,t)},Lv.prototype.getResidueProxy=function(t){return new Av(this,t)},Lv.prototype.getChainProxy=function(t){return new Ev(this,t)},Lv.prototype.getModelProxy=function(t){return new Iv(this,t)},Lv.prototype.getBondSet=function(){var t=this.bondStore.count,e=new pg(t),i=this.atomSet;if(i)for(var r=this.getBondProxy(),n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index);else e.setAll();return e},Lv.prototype.getBackboneBondSet=function(){var t=this.backboneBondStore.count,e=new pg(t),i=this.atomSetCache.__backbone;if(i){var r=this.getBondProxy();r.bondStore=this.backboneBondStore;for(var n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index)}else e.set_all(!0);return e},Lv.prototype.getRungBondSet=function(){var t=this.rungBondStore.count,e=new pg(t),i=this.atomSetCache.__rung;if(i){var r=this.getBondProxy();r.bondStore=this.rungBondStore;for(var n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index)}else e.set_all(!0);return e},Lv.prototype.getAtomSet=function(t){var e,i=this.atomStore.count;if(t instanceof pg)e=t;else if(t&&t.test){var r=t.string;r in this.atomSetCache?e=this.atomSetCache[r]:(e=new pg(i),this.eachAtom(function(t){e.set(t.index)},t),this.atomSetCache[r]=e)}else e=!1===t?new pg(i):new pg(i,!0);return e},Lv.prototype.getAtomSetWithinSelection=function(t,e){var i=this.spatialHash,r=this.getAtomSet(!1),n=this.getAtomProxy();return this.getAtomSet(t).forEach(function(t){n.index=t,i.within(n.x,n.y,n.z,e).forEach(function(t){r.set(t)})}),r},Lv.prototype.getAtomSetWithinPoint=function(t,e){var i=t,r=this.getAtomSet(!1);return this.spatialHash.within(i.x,i.y,i.z,e).forEach(function(t){r.set(t)}),r},Lv.prototype.getAtomSetWithinVolume=function(t,e,i,r,n){for(var o=this,a=new Qg(t,i,r,n),s=a.getDataPosition(),c=s.length,u=a.matrix.getMaxScaleOnAxis(),h=this.getAtomSet(!1),l=0;l<c;l+=3)o.spatialHash.within(s[l],s[l+1],s[l+2],u).forEach(function(t){h.set(t)});return h},Lv.prototype.getAtomSetWithinGroup=function(t){var e=this.atomStore.residueIndex,i=this.getAtomSet(!1),r=this.getResidueProxy();return this.getAtomSet(t).forEach(function(t){r.index=e[t];for(var n=r.atomOffset;n<=r.atomEnd;++n)i.set(n)}),i},Lv.prototype.getSelection=function(){return!1},Lv.prototype.getStructure=function(){return this},Lv.prototype.eachEntity=function(t,e){this.entityList.forEach(function(i){void 0!==e&&i.getEntityType()!==e||t(i)})},Lv.prototype.eachBond=function(t,e){var i,r=this.getBondProxy();if(e&&e.test&&(i=this.getBondSet(e),this.bondSet&&i.intersection(this.bondSet)),i)i.forEach(function(e){r.index=e,t(r)});else for(var n=this.bondStore.count,o=0;o<n;++o)r.index=o,t(r)},Lv.prototype.eachAtom=function(t,e){if(e&&e.test)this.eachModel(function(i){i.eachAtom(t,e)},e);else for(var i=this.atomStore.count,r=this.getAtomProxy(),n=0;n<i;++n)r.index=n,t(r)},Lv.prototype.eachResidue=function(t,e){var i;if(e&&e.test){var r=this.modelStore.count,n=this.getModelProxy(),o=e.modelOnlyTest;if(o)for(i=0;i<r;++i)n.index=i,o(n)&&n.eachResidue(t,e);else for(i=0;i<r;++i)n.index=i,n.eachResidue(t,e)}else{var a=this.residueStore.count,s=this.getResidueProxy();for(i=0;i<a;++i)s.index=i,t(s)}},Lv.prototype.eachResidueN=function(t,e){var i,r,n=this,o=this.residueStore.count;if(!(o<t)){var a=new Array(t);for(i=0;i<t;++i)a[i]=n.getResidueProxy(i);for(e.apply(this,a),r=t;r<o;++r){for(i=0;i<t;++i)a[i].index+=1;e.apply(n,a)}}},Lv.prototype.eachPolymer=function(t,e){if(e&&e.modelOnlyTest){var i=e.modelOnlyTest;this.eachModel(function(r){i(r)&&r.eachPolymer(t,e)})}else this.eachModel(function(i){i.eachPolymer(t,e)})},Lv.prototype.eachChain=function(t,e){if(e&&e.test)this.eachModel(function(i){i.eachChain(t,e)});else for(var i=this.chainStore.count,r=this.getChainProxy(),n=0;n<i;++n)r.index=n,t(r)},Lv.prototype.eachModel=function(t,e){var i,r=this.modelStore.count,n=this.getModelProxy();if(e&&e.test){var o=e.modelOnlyTest;if(o)for(i=0;i<r;++i)n.index=i,o(n)&&t(n,e);else for(i=0;i<r;++i)n.index=i,t(n,e)}else for(i=0;i<r;++i)n.index=i,t(n)},Lv.prototype.getAtomData=function(t){var e=Object.assign({},t);e.colorParams&&(e.colorParams.structure=this.getStructure());var i,r,n,o,a,s,c,u=e.what,h=gn(e.atomSet,this.atomSet),l={},p=this.getAtomProxy(),d=h.getSize();return u&&!u.position||(n=new Float32Array(3*d),l.position=n),u&&!u.color||(o=new Float32Array(3*d),l.color=o,r=lf.getScheme(e.colorParams)),u&&!u.picking||(a=new Float32Array(d),l.picking=new Km(a,this.getStructure())),u&&!u.radius||(s=new Float32Array(d),l.radius=s,i=new ga(e.radiusParams.radius,e.radiusParams.scale)),u&&!u.index||(c=new Float32Array(d),l.index=c),h.forEach(function(t,e){var u=3*e;p.index=t,n&&p.positionToArray(n,u),o&&r.atomColorToArray(p,o,u),a&&(a[e]=t),s&&(s[e]=i.atomRadius(p)),c&&(c[e]=t)}),l},Lv.prototype.getBondData=function(t){var e=Object.assign({},t);e.colorParams&&(e.colorParams.structure=this.getStructure());var i,r,n,o,a,s,c,u,h,l=e.what,p=gn(e.bondSet,this.bondSet),d=gn(e.multipleBond,"off"),f="off"!==d,m="offset"===d,v=gn(e.bondScale,.4),y=gn(e.bondSpacing,1),b={},x=this.getBondProxy();e.bondStore&&(x.bondStore=e.bondStore);var _,w=this.getAtomProxy(),S=this.getAtomProxy();if(f){var A=x.bondStore.bondOrder;_=0,p.forEach(function(t){_+=A[t]})}else _=p.getSize();l&&!l.position||(n=new Float32Array(3*_),o=new Float32Array(3*_),b.position1=n,b.position2=o),l&&!l.color||(a=new Float32Array(3*_),s=new Float32Array(3*_),b.color=a,b.color2=s,r=lf.getScheme(e.colorParams)),l&&!l.picking||(c=new Float32Array(_),b.picking=new Jm(c,this.getStructure(),e.bondStore)),(!l||l.radius||f&&l.position)&&(i=new ga(e.radiusParams.radius,e.radiusParams.scale)),l&&!l.radius||(u=new Float32Array(_),b.radius=u,e.radius2&&(h=new Float32Array(_),b.radius2=h));var M,P,T,E,C,I,R,L=0,O=new g,D=new g,N=new g;return p.forEach(function(t){if(P=3*L,x.index=t,w.index=x.atomIndex1,S.index=x.atomIndex2,E=x.bondOrder,n&&(f&&E>1?(C=i.atomRadius(w),I=C*v/(.5*E),x.calculateShiftDir(N),m?(R=2*y*C,N.multiplyScalar(R),N.negate(),D.subVectors(S,w).multiplyScalar(Math.max(.1,R/1.88)),w.positionToArray(n,P),S.positionToArray(o,P),E>=2&&(O.addVectors(w,N).add(D).toArray(n,P+3),O.addVectors(S,N).sub(D).toArray(o,P+3),E>=3&&(O.subVectors(w,N).add(D).toArray(n,P+6),O.subVectors(S,N).sub(D).toArray(o,P+6)))):(R=(y-v)*C,N.multiplyScalar(R),2===E?(O.addVectors(w,N).toArray(n,P),O.subVectors(w,N).toArray(n,P+3),O.addVectors(S,N).toArray(o,P),O.subVectors(S,N).toArray(o,P+3)):3===E?(w.positionToArray(n,P),O.addVectors(w,N).toArray(n,P+3),O.subVectors(w,N).toArray(n,P+6),S.positionToArray(o,P),O.addVectors(S,N).toArray(o,P+3),O.subVectors(S,N).toArray(o,P+6)):(w.positionToArray(n,P),S.positionToArray(o,P)))):(w.positionToArray(n,P),S.positionToArray(o,P))),a&&(r.bondColorToArray(x,1,a,P),r.bondColorToArray(x,0,s,P),f&&E>1))for(M=1;M<E;++M)Oo(a,P,T=3*M+P,3),Oo(s,P,T,3);if(c&&(c[L]=t,f&&E>1))for(M=1;M<E;++M)c[L+M]=t;if(u&&(u[L]=i.atomRadius(w),f&&E>1))for(I=u[L]*v/(m?1:.5*E),M=m?1:0;M<E;++M)u[L+M]=I;if(h&&(h[L]=i.atomRadius(S),f&&E>1))for(I=h[L]*v/(m?1:.5*E),M=m?1:0;M<E;++M)h[L+M]=I;L+=f?E:1}),b},Lv.prototype.getBackboneAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__backbone},t),this.getAtomData(t)},Lv.prototype.getBackboneBondData=function(t){return t=Object.assign({bondSet:this.getBackboneBondSet(),bondStore:this.backboneBondStore},t),this.getBondData(t)},Lv.prototype.getRungAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__rung},t),this.getAtomData(t)},Lv.prototype.getRungBondData=function(t){return t=Object.assign({bondSet:this.getRungBondSet(),bondStore:this.rungBondStore},t),this.getBondData(t)},Lv.prototype.getBoundingBox=function(e,i){t.Debug&&cf.time("getBoundingBox"),i=i||new st;var r=1/0,n=1/0,o=1/0,a=-1/0,s=-1/0,c=-1/0;return this.eachAtom(function(t){var e=t.x,i=t.y,u=t.z;e<r&&(r=e),i<n&&(n=i),u<o&&(o=u),e>a&&(a=e),i>s&&(s=i),u>c&&(c=u)},e),i.min.set(r,n,o),i.max.set(a,s,c),t.Debug&&cf.timeEnd("getBoundingBox"),i},Lv.prototype.getPrincipalAxes=function(e){t.Debug&&cf.time("getPrincipalAxes");var i=0,r=new va(3,this.atomCount),n=r.data;return this.eachAtom(function(t){n[i+0]=t.x,n[i+1]=t.y,n[i+2]=t.z,i+=3},e),t.Debug&&cf.timeEnd("getPrincipalAxes"),new Xg(r)},Lv.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter():this.center.clone()},Lv.prototype.getSequence=function(t){var e=[],i=this.getResidueProxy();return this.eachAtom(function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())},t),e},Lv.prototype.getAtomIndices=function(t){var e;if(t&&t.string)e=[],this.eachAtom(function(t){e.push(t.index)},t);else{var i={what:{index:!0}};e=this.getAtomData(i).index}return e},Lv.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain(function(t){t.residueCount&&e.add(t.chainname)},t),e.size},Lv.prototype.updatePosition=function(t){var e=0;this.eachAtom(function(i){i.positionFromArray(t,e),e+=3})},Lv.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Ba(this.atomStore,this.boundingBox)},Lv.prototype.dispose=function(){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.bondStore,delete this.atomStore,delete this.residueStore,delete this.chainStore,delete this.modelStore,delete this.frames,delete this.boxes,delete this.cif,delete this.bondSet,delete this.atomSet},Object.defineProperties(Lv.prototype,Ov);var Dv=function(t,e){var i;"function"==typeof t.eachAtom?i=t.atomCount:t instanceof Float32Array&&(i=t.length/3);var r=new va(3,i),n=new va(3,i);this.coords1t=new va(i,3),this.coords2t=new va(i,3),this.A=new va(3,3),this.W=new va(1,3),this.U=new va(3,3),this.V=new va(3,3),this.VH=new va(3,3),this.R=new va(3,3),this.tmp=new va(3,3),this.c=new va(3,3),this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,r),this.prepCoords(e,n),this._superpose(r,n)};Dv.prototype._superpose=function(e,i){this.mean1=Sa(e),this.mean2=Sa(i),Aa(e,this.mean1),Aa(i,this.mean2),ya(this.coords1t,e),ya(this.coords2t,i),ba(this.A,this.coords2t,this.coords1t),Ca(this.A,this.W,this.U,this.V),xa(this.V,this.VH),wa(this.R,this.U,this.VH),_a(this.R)<0&&(t.Debug&&cf.log("R not a right handed system"),wa(this.tmp,this.c,this.VH),wa(this.R,this.U,this.tmp))},Dv.prototype.prepCoords=function(t,e){var i=0,r=e.data;"function"==typeof t.eachAtom?t.eachAtom(function(t){r[i+0]=t.x,r[i+1]=t.y,r[i+2]=t.z,i+=3}):t instanceof Float32Array?r.set(t):cf.warn("prepCoords: input type unknown")},Dv.prototype.transform=function(t){var e;"function"==typeof t.eachAtom?e=t.atomCount:t instanceof Float32Array&&(e=t.length/3);var i=new va(3,e),r=new va(e,3);this.prepCoords(t,i),Aa(i,this.mean1),ba(r,this.R,i),ya(i,r),Ma(i,this.mean2);var n=0,o=i.data;"function"==typeof t.eachAtom?t.eachAtom(function(t){t.x=o[n+0],t.y=o[n+1],t.z=o[n+2],n+=3}):t instanceof Float32Array?t.set(o.subarray(0,3*e)):cf.warn("transform: input type unknown")};var Nv=function(t,e){this.signals={startedRunning:new oo,haltedRunning:new oo};var i=Object.assign({},e);t.signals.playerChanged.add(function(t){t!==this&&this.pause()},this);var r=gn(t.numframes,1);this.traj=t,this.start=gn(i.start,0),this.end=Math.min(gn(i.end,r-1),r-1),this.step=gn(i.step,Math.ceil((r+1)/100)),this.timeout=gn(i.timeout,50),this.interpolateType=gn(i.interpolateType,""),this.interpolateStep=gn(i.interpolateStep,5),this.mode=gn(i.mode,"loop"),this.direction=gn(i.direction,"forward"),this._stopFlag=!1,this._running=!1,t.signals.gotNumframes.add(function(t){this.end=Math.min(gn(i.end,t-1),t-1)},this)};Nv.prototype._animate=function(){var t;if(this._running=!0,this.traj.inProgress||this._stopFlag||(((t="forward"===this.direction?this.traj.currentFrame+this.step:this.traj.currentFrame-this.step)>=this.end||t<this.start)&&("once"===this.mode?(this.pause(),t="forward"===this.direction?this.end:this.start):t="forward"===this.direction?this.start:this.end),this.interpolateType||this.traj.setFrame(t)),this._stopFlag)this._running=!1;else if(!this.traj.inProgress&&this.interpolateType){var e,i,r;"forward"===this.direction?(e=Math.max(this.start,t-this.step),i=Math.max(this.start,t-2*this.step),r=Math.max(this.start,t-3*this.step)):(e=Math.min(this.end,t+this.step),i=Math.min(this.end,t+2*this.step),r=Math.min(this.end,t+3*this.step)),this._interpolate(t,e,i,r,1/this.interpolateStep,0)}else setTimeout(this._animate.bind(this),this.timeout)},Nv.prototype._interpolate=function(t,e,i,r,n,o){if((o+=n)<=1){var a=Math.round(this.timeout*n);this.traj.setFrameInterpolated(t,e,i,r,o,this.interpolateType,function(){setTimeout(function(){this._interpolate(t,e,i,r,n,o)}.bind(this),a)}.bind(this))}else setTimeout(this._animate.bind(this),0)},Nv.prototype.toggle=function(){this._running?this.pause():this.play()},Nv.prototype.play=function(){if(!this._running){this.traj.player!==this&&this.traj.setPlayer(this);var t=this.traj.currentFrame,e=Math.ceil(t/this.step)*this.step;"forward"===this.direction&&t>=this.end?e=this.start:"backward"===this.direction&&t<=this.start&&(e=this.end),this.traj.setFrame(e),this._stopFlag=!1,this._animate(),this.signals.startedRunning.dispatch()}},Nv.prototype.pause=function(){this._running&&(this._stopFlag=!0,this.signals.haltedRunning.dispatch())},Nv.prototype.stop=function(){this.traj.setFrame(this.start),this.pause()};var kv=function(t,e,i){this.signals={gotNumframes:new oo,frameChanged:new oo,selectionChanged:new oo,playerChanged:new oo};var r=i||{};r.centerPbc=gn(r.centerPbc,!0),r.removePbc=gn(r.removePbc,!0),r.superpose=gn(r.superpose,!0),this.setParameters(r),this.name=t.replace(/^.*[\\/]/,""),this.selection=new Kd(gn(r.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add(function(){this.makeIndices(),this.resetCache()},this),this.setStructure(e),this.setPlayer(new Nv(this)),this.trajPath=t,this.numframes=void 0,this.getNumframes()};kv.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.makeAtomIndices(),this.saveInitialStructure(),this.backboneIndices=this.getIndices(new Kd("backbone and not hydrogen")),this.makeIndices(),this.frameCache=[],this.boxCache=[],this.pathCache=[],this.frameCacheSize=0,this.currentFrame=-1},kv.prototype.saveInitialStructure=function(){var t=0,e=new Float32Array(3*this.atomCount);this.structure.eachAtom(function(i){e[t+0]=i.x,e[t+1]=i.y,e[t+2]=i.z,t+=3}),this.initialStructure=e},kv.prototype.setSelection=function(t){return this.selection.setString(t),this},kv.prototype.getIndices=function(t){var e;if(t&&t.test){var i=0,r=t.test;e=[],this.structure.eachAtom(function(t){r(t)&&e.push(i),i+=1})}else e=this.structure.getAtomIndices(this.selection);return e},kv.prototype.makeIndices=function(){var t=this;this.indices=this.getIndices(this.selection);var e,i,r=3*this.indices.length;this.coords1=new Float32Array(r),this.coords2=new Float32Array(r);var n=this.initialStructure,o=this.coords2;for(e=0;e<r;e+=3)i=3*t.indices[e/3],o[e+0]=n[i+0],o[e+1]=n[i+1],o[e+2]=n[i+2]},kv.prototype.makeAtomIndices=function(){cf.error("Trajectory.makeAtomIndices not implemented")},kv.prototype.getNumframes=function(){cf.error("Trajectory.loadFrame not implemented")},kv.prototype.resetCache=function(){return this.frameCache=[],this.boxCache=[],this.pathCache=[],this.frameCacheSize=0,this.setFrame(this.currentFrame),this},kv.prototype.setParameters=function(t){var e=t,i=!1;void 0!==e.centerPbc&&e.centerPbc!==this.centerPbc&&(this.centerPbc=e.centerPbc,i=!0),void 0!==e.removePbc&&e.removePbc!==this.removePbc&&(this.removePbc=e.removePbc,i=!0),void 0!==e.superpose&&e.superpose!==this.superpose&&(this.superpose=e.superpose,i=!0),i&&this.resetCache()},kv.prototype.setFrame=function(t,e){return void 0===t?this:(this.inProgress=!0,t=parseInt(t),-1===t||this.frameCache[t]?this.updateStructure(t,e):this.loadFrame(t,function(){this.updateStructure(t,e)}.bind(this)),this)},kv.prototype.interpolate=function(t,e,i,r,n,o,a){var s,c=this.frameCache,u=c[t],h=c[e],l=c[i],p=c[r],d=u.length,f=new Float32Array(d);if("spline"===o)for(s=0;s<d;s+=3)f[s+0]=to(p[s+0],l[s+0],h[s+0],u[s+0],n,1),f[s+1]=to(p[s+1],l[s+1],h[s+1],u[s+1],n,1),f[s+2]=to(p[s+2],l[s+2],h[s+2],u[s+2],n,1);else for(s=0;s<d;s+=3)f[s+0]=Jn(h[s+0],u[s+0],n),f[s+1]=Jn(h[s+1],u[s+1],n),f[s+2]=Jn(h[s+2],u[s+2],n);this.structure.updatePosition(f),this.currentFrame=t,this.signals.frameChanged.dispatch(t),"function"==typeof a&&a()},kv.prototype.setFrameInterpolated=function(t,e,i,r,n,o,a){if(void 0===t)return this;var s=this.frameCache,c=[];return s[r]||c.push(r),s[i]||c.push(i),s[e]||c.push(e),s[t]||c.push(t),c.length?this.loadFrame(c,function(){this.interpolate(t,e,i,r,n,o,a)}.bind(this)):this.interpolate(t,e,i,r,n,o,a),this},kv.prototype.loadFrame=function(t,e){if(Array.isArray(t)){var i,r=function(t,r){this._loadFrame(t,r),0===i.length()&&"function"==typeof e&&e()}.bind(this);i=new ms(r,t)}else this._loadFrame(t,e)},kv.prototype._loadFrame=function(t,e){cf.error("Trajectory._loadFrame not implemented",t,e)},kv.prototype.updateStructure=function(t,e){this._disposed||(-1===t?this.structure.updatePosition(this.initialStructure):this.structure.updatePosition(this.frameCache[t]),this.structure.trajectory={name:this.trajPath,frame:t},"function"==typeof e&&e(),this.currentFrame=t,this.inProgress=!1,this.signals.frameChanged.dispatch(t))},kv.prototype.getCircularMean=function(t,e,i){return[Ao(e,i[0],3,0,t),Ao(e,i[1],3,1,t),Ao(e,i[2],3,2,t)]},kv.prototype.doSuperpose=function(t){var e,i,r=this,n=3*this.indices.length,o=this.coords1,a=this.coords2;for(e=0;e<n;e+=3)i=3*r.indices[e/3],o[e+0]=t[i+0],o[e+1]=t[i+1],o[e+2]=t[i+2];new Dv(o,a).transform(t)},kv.prototype.process=function(t,e,i,r){if(this.setNumframes(r),e){if(this.backboneIndices.length>0&&this.centerPbc){var n=[e[0],e[4],e[8]];gs(i,this.getCircularMean(this.backboneIndices,i,n),n)}this.removePbc&&vs(i,e)}this.indices.length>0&&this.superpose&&this.doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1},kv.prototype.setNumframes=function(t){t!==this.numframes&&(this.numframes=t,this.signals.gotNumframes.dispatch(t))},kv.prototype.dispose=function(){this.frameCache=[],this._disposed=!0,this.player&&this.player.stop()},kv.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},kv.prototype.getPath=function(t,e){cf.error("Trajectory.getPath not implemented",t,e)},mf.add("shader/Mesh.vert","#define STANDARD\nuniform float nearClip;\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}"),mf.add("shader/Mesh.frag","#define STANDARD\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\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\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.7 )\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_flip\n#include normal_fragment\n#include dull_interior_fragment\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\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}");var Fv={f:1,v2:2,v3:3,c:3},Bv=function(t,e){var i=t||{},r=e||{};this.opaqueBack=gn(r.opaqueBack,!1),this.dullInterior=gn(r.dullInterior,!1),this.side=gn(r.side,"double"),this.opacity=gn(r.opacity,1),this.depthWrite=gn(r.depthWrite,!0),this.clipNear=gn(r.clipNear,0),this.clipRadius=gn(r.clipRadius,0),this.clipCenter=gn(r.clipCenter,new g),this.flatShaded=gn(r.flatShaded,!1),this.background=gn(r.background,!1),this.linewidth=gn(r.linewidth,1),this.wireframe=gn(r.wireframe,!1),this.wireframeLinewidth=gn(r.wireframeLinewidth,1),this.roughness=gn(r.roughness,.4),this.metalness=gn(r.metalness,0),this.diffuse=gn(r.diffuse,16777215),this.forceTransparent=gn(r.forceTransparent,!1),this.disablePicking=gn(r.disablePicking,!1),this.geometry=new Ct,this.indexVersion=0,this.wireframeIndexVersion=-1,this.uniforms=Rl.merge([Il.common,{fogColor:{value:null},fogNear:{value:0},fogFar:{value:0},opacity:{value:this.opacity},nearClip:{value:0},clipRadius:{value:this.clipRadius},clipCenter:{value:this.clipCenter}},{emissive:{value:new tt(0)},roughness:{value:this.roughness},metalness:{value:this.metalness}},Il.ambient,Il.lights]),this.uniforms.diffuse.value.set(this.diffuse),this.pickingUniforms={nearClip:{value:0},objectId:{value:0},opacity:{value:this.opacity}},this.group=new Ne,this.wireframeGroup=new Ne,this.pickingGroup=new Ne,this.matrix=gn(r.matrix,new v);var n=i.position||i.position1;this._positionDataSize=n?n.length/3:0,this.addAttributes({position:{type:"v3",value:i.position},color:{type:"c",value:i.color},primitiveId:{type:"f",value:i.primitiveId}}),i.index&&this.initIndex(i.index),this.picking=i.picking,this.makeWireframeGeometry()},zv={parameters:{},matrix:{},transparent:{},size:{},attributeSize:{},pickable:{},dynamic:{},vertexShader:{},fragmentShader:{}};zv.parameters.get=function(){return{opaqueBack:{updateShader:!0},dullInterior:{updateShader:!0},side:{updateShader:!0,property:!0},opacity:{uniform:!0},depthWrite:{property:!0},clipNear:{updateShader:!0,property:!0},clipRadius:{updateShader:!0,property:!0,uniform:!0},clipCenter:{uniform:!0},flatShaded:{updateShader:!0},background:{updateShader:!0},linewidth:{property:!0},wireframe:{updateVisibility:!0},roughness:{uniform:!0},metalness:{uniform:!0},diffuse:{uniform:!0},matrix:{}}},zv.matrix.set=function(t){this.setMatrix(t)},zv.matrix.get=function(){return this.group.matrix.clone()},zv.transparent.get=function(){return this.opacity<1||this.forceTransparent},zv.size.get=function(){return this._positionDataSize},zv.attributeSize.get=function(){return this.size},zv.pickable.get=function(){return!!this.picking&&!this.disablePicking},zv.dynamic.get=function(){return!0},zv.vertexShader.get=function(){},zv.fragmentShader.get=function(){},Bv.prototype.setMatrix=function(t){bs(this.group,t),bs(this.wireframeGroup,t),bs(this.pickingGroup,t)},Bv.prototype.initIndex=function(t){this.geometry.setIndex(new St(t,1)),this.geometry.getIndex().setDynamic(this.dynamic)},Bv.prototype.makeMaterial=function(){var t=ys(this.side),e=new ot({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!0,fog:!0,side:t,linewidth:this.linewidth});e.vertexColors=Ru,e.extensions.derivatives=this.flatShaded,e.extensions.fragDepth=this.isImpostor,e.clipNear=this.clipNear;var i=new ot({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.depthWrite,lights:!1,fog:!0,side:t,linewidth:this.linewidth});i.vertexColors=Ru,i.clipNear=this.clipNear;var r=new ot({uniforms:this.pickingUniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:!1,depthWrite:this.depthWrite,lights:!1,fog:!1,side:t,linewidth:this.linewidth,blending:Lu});r.vertexColors=Ru,r.extensions.fragDepth=this.isImpostor,r.clipNear=this.clipNear,this.material=e,this.wireframeMaterial=i,this.pickingMaterial=r,this.updateShader()},Bv.prototype.makeWireframeGeometry=function(){this.makeWireframeIndex();var t=this.geometry,e=this.wireframeIndex,i=new Ct;i.attributes=t.attributes,e&&(i.setIndex(new St(e,1).setDynamic(this.dynamic)),i.setDrawRange(0,this.wireframeIndexCount)),this.wireframeGeometry=i},Bv.prototype.makeWireframeIndex=function(){function t(t,i){if(t>i){var r=t;t=i,i=r}var n=e[t];return void 0===n?(e[t]=[i],!0):!n.includes(i)&&(n.push(i),!0)}var e=[],i=this.geometry,r=i.index;if(this.wireframe)if(r){var n=r.array,o=n.length;i.drawRange.count!==1/0&&(o=i.drawRange.count);var a;a=this.wireframeIndex&&this.wireframeIndex.length>2*o?this.wireframeIndex:Ln(2*o,i.attributes.position.count);var s=0;e.length=0;for(var c=0;c<o;c+=3){var u=n[c+0],h=n[c+1],l=n[c+2];t(u,h)&&(a[s+0]=u,a[s+1]=h,s+=2),t(h,l)&&(a[s+0]=h,a[s+1]=l,s+=2),t(l,u)&&(a[s+0]=l,a[s+1]=u,s+=2)}this.wireframeIndex=a,this.wireframeIndexCount=s,this.wireframeIndexVersion=this.indexVersion}else{var p,d=i.attributes.position.count;p=this.wireframeIndex&&this.wireframeIndex.length>2*d?this.wireframeIndex:Ln(2*d,d);for(var f=0,m=0;f<d;f+=3)p[m+0]=f,p[m+1]=f+1,p[m+2]=f+1,p[m+3]=f+2,p[m+4]=f+2,p[m+5]=f,m+=6;this.wireframeIndex=p,this.wireframeIndexCount=2*d,this.wireframeIndexVersion=this.indexVersion}else this.wireframeIndex=new Uint16Array(0),this.wireframeIndexCount=0},Bv.prototype.updateWireframeIndex=function(){if(this.wireframeGeometry.setDrawRange(0,1/0),this.wireframeIndexVersion<this.indexVersion&&this.makeWireframeIndex(),this.wireframeIndex.length>this.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new St(this.wireframeIndex,1).setDynamic(this.dynamic));else{var t=this.wireframeGeometry.getIndex();t.set(this.wireframeIndex),t.needsUpdate=this.wireframeIndexCount>0,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)},Bv.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},Bv.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,i=this.geometry,r=this[t];return this.isLine?e=new Re(i,r):this.isPoint?(e=new De(i,r),this.sortParticles&&(e.sortParticles=!0)):e=new Bt(i,r),e.frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},Bv.prototype.getMesh=function(){return this._getMesh("material")},Bv.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),t=new Re(this.wireframeGeometry,this.wireframeMaterial),t.frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},Bv.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},Bv.prototype.getShader=function(t,e){return wo(t,this.getDefines(e))},Bv.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},Bv.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},Bv.prototype.getDefines=function(t){var e={};return this.clipNear&&(e.NEAR_CLIP=1),this.clipRadius&&(e.RADIUS_CLIP=1),"picking"===t?e.PICKING=1:(("background"===t||this.background)&&(e.NOLIGHT=1),this.flatShaded&&(e.FLAT_SHADED=1),this.opaqueBack&&(e.OPAQUE_BACK=1),this.dullInterior&&(e.DULL_INTERIOR=1)),e},Bv.prototype.getParameters=function(){var t=this,e={};for(var i in t.parameters)e[i]=t[i];return e},Bv.prototype.addUniforms=function(t){this.uniforms=Rl.merge([this.uniforms,t]),this.pickingUniforms=Rl.merge([this.pickingUniforms,t])},Bv.prototype.addAttributes=function(t){var e=this;for(var i in t){var r=void 0,n=t[i],o=e.attributeSize*Fv[n.type];n.value?(o!==n.value.length&&cf.error("attribute value has wrong length",i),r=n.value):r=Rn("float32",o),e.geometry.addAttribute(i,new St(r,Fv[n.type]).setDynamic(e.dynamic))}},Bv.prototype.updateRenderOrder=function(){function t(t){t.renderOrder=e}var e=this.getRenderOrder();this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)},Bv.prototype.updateShader=function(){var 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},Bv.prototype.setParameters=function(t){var e=this;if(t){var i=t,r=this.parameters,n={},o={},a=!1,s=!1;for(var c in i){var u=i[c];void 0!==u&&(void 0!==r[c]&&(e[c]=u,r[c].property&&(!0!==r[c].property?n[r[c].property]=u:n[c]=u),r[c].uniform&&(!0!==r[c].uniform?o[r[c].uniform]=u:o[c]=u),r[c].updateShader&&(a=!0),r[c].updateVisibility&&(s=!0),e.dynamic&&"wireframe"===c&&!0===u&&e.updateWireframeIndex(),"flatShaded"===c&&(e.material.extensions.derivatives=e.flatShaded),"forceTransparent"===c&&(n.transparent=e.transparent)))}this.setProperties(n),this.setUniforms(o),a&&this.updateShader(),s&&this.setVisibility(this.visible)}},Bv.prototype.setAttributes=function(t){var e=this,i=this.geometry,r=i.attributes;for(var n in t)if("picking"!==n){var o=t[n],a=o.length;if("index"===n){var s=i.getIndex();i.setDrawRange(0,1/0),a>s.array.length?i.setIndex(new St(o,1).setDynamic(e.dynamic)):(s.set(o),s.needsUpdate=a>0,s.updateRange.count=a,i.setDrawRange(0,a)),e.indexVersion++,e.wireframe&&e.updateWireframeIndex()}else{var c=r[n];a>c.array.length?i.addAttribute(n,new St(o,c.itemSize).setDynamic(e.dynamic)):(r[n].set(o),r[n].needsUpdate=a>0,r[n].updateRange.count=a)}}},Bv.prototype.setUniforms=function(t){var e=this;if(t){var i=this.material.uniforms,r=this.wireframeMaterial.uniforms,n=this.pickingMaterial.uniforms;for(var o in t)"opacity"===o&&e.setProperties({transparent:e.transparent}),void 0!==i[o]&&(i[o].value.isVector3?i[o].value.copy(t[o]):i[o].value.set?i[o].value.set(t[o]):i[o].value=t[o]),void 0!==r[o]&&(r[o].value.isVector3?r[o].value.copy(t[o]):r[o].value.set?r[o].value.set(t[o]):r[o].value=t[o]),void 0!==n[o]&&(n[o].value.isVector3?n[o].value.copy(t[o]):n[o].value.set?n[o].value.set(t[o]):n[o].value=t[o])}},Bv.prototype.setProperties=function(t){var e=this;if(t){var i=this.material,r=this.wireframeMaterial,n=this.pickingMaterial;for(var o in t){var a=t[o];"transparent"===o?e.updateRenderOrder():"side"===o&&(a=ys(a)),void 0!==i[o]&&(i[o]=a),void 0!==r[o]&&(r[o]=a),void 0!==n[o]&&(n[o]=a)}i.needsUpdate=!0,r.needsUpdate=!0,n.needsUpdate=!0}},Bv.prototype.setVisibility=function(t){this.visible=t,this.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))},Bv.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},Object.defineProperties(Bv.prototype,zv);var Uv=function(t){function e(e,i){var r=e||{};!r.primitiveId&&r.position&&(r.primitiveId=Co(r.position.length/3)),t.call(this,r,i),this.addAttributes({normal:{type:"v3",value:r.normal}}),void 0===r.normal&&this.geometry.computeVertexNormals()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={vertexShader:{},fragmentShader:{}};return i.vertexShader.get=function(){return"Mesh.vert"},i.fragmentShader.get=function(){return"Mesh.frag"},Object.defineProperties(e.prototype,i),e}(Bv),jv=new v,Gv=new ut,Vv=function(t){function e(e,i,r){var n,o=e||{},a=i||{},s=r.attributes.position.array,c=r.attributes.normal.array,u=r.index?r.index.array:void 0,h=o.position.length/3,l=s.length/3,p=h*l,d=new Float32Array(3*p),f=new Float32Array(3*p),m=new Float32Array(3*p);u&&(n=Ln(h*u.length,p)),t.call(this,{position:d,color:m,index:n,normal:f,primitiveId:o.primitiveId||Io(h,l),picking:o.picking},a),this.setAttributes(o),this.geoPosition=s,this.geoNormal=c,this.geoIndex=u,this.positionCount=h,this.geoPositionCount=l,this.transformedGeoPosition=new Float32Array(3*l),this.transformedGeoNormal=new Float32Array(3*l),this.meshPosition=d,this.meshColor=m,this.meshIndex=n,this.meshNormal=f,this.meshIndex=n,this.makeIndex()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(){},e.prototype.setAttributes=function(t,e){var i,r,n,o,a,s,c,u,h,l=this,p=this.geometry.attributes,d=this.updateNormals;t.position&&(i=t.position,n=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,p.position.needsUpdate=!0,(d||e)&&(o=this.geoNormal,h=this.meshNormal,s=this.transformedGeoNormal,p.normal.needsUpdate=!0)),t.color&&(r=t.color,u=this.meshColor,p.color.needsUpdate=!0);for(var f=this.positionCount,m=this.geoPositionCount,g=0;g<f;++g){var v=void 0,y=void 0,b=g*m*3,x=3*g;if(i&&(a.set(n),jv.makeTranslation(i[x],i[x+1],i[x+2]),l.applyPositionTransform(jv,g,x),Jo(jv.elements,a),c.set(a,b),d?(s.set(o),Gv.getNormalMatrix(jv),ta(Gv.elements,s),h.set(s,b)):e&&h.set(o,b)),r)for(v=0;v<m;++v)u[y=b+3*v]=r[x],u[y+1]=r[x+1],u[y+2]=r[x+2]}},e.prototype.makeIndex=function(){var t=this.geoIndex,e=this.meshIndex;if(t)for(var i=this.positionCount,r=this.geoPositionCount,n=3*(t.length/3),o=0;o<i;++o){var a=o*n,s=a+n;e.set(t,a);for(var c=a;c<s;++c)e[c]+=o*r}},i.updateNormals.get=function(){return!1},Object.defineProperties(e.prototype,i),e}(Uv),$v=new g,Hv=function(t){function e(e,i){var r=i||{},n=new qe(1,gn(r.sphereDetail,1));t.call(this,e,r,n),this.setAttributes(e,!0)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.applyPositionTransform=function(t,e){var i=this._radius[e];$v.set(i,i,i),t.scale($v)},e.prototype.setAttributes=function(e,i){e.radius&&(this._radius=e.radius),t.prototype.setAttributes.call(this,e,i)},e}(Vv);mf.add("shader/SphereImpostor.vert","uniform mat4 projectionMatrixInverse;\nuniform float nearClip;\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 transpose( 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 = transpose( 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}"),mf.add("shader/SphereImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\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\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, nearClip - 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}else{\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;\nreturn false;\n}else if( calcClip( cameraPos ) > 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\nreturn false;\n}else{\ncameraNormal = normalize( cameraPos - cameraSpherePos );\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nreturn false;\n}else{\ncameraNormal = normalize( cameraPos - cameraSpherePos );\n}\n#endif\nreturn true;\n}\nreturn false;\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( - ( nearClip - 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\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_flip\n#include normal_fragment\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\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}");var Wv=function(t){function e(e,i){t.call(this,e,i),this.index=Ln(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index,1),this.addAttributes({mapping:{type:this.mappingType,value:null}}),this.setAttributes({primitiveId:Co(this.size)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={attributeSize:{},indexSize:{},mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.attributeSize.get=function(){return this.size*this.mappingSize},i.indexSize.get=function(){return this.size*this.mappingIndicesSize},i.mapping.get=function(){},i.mappingIndices.get=function(){},i.mappingIndicesSize.get=function(){},i.mappingType.get=function(){},i.mappingSize.get=function(){},i.mappingItemSize.get=function(){},e.prototype.addAttributes=function(e){var i={};for(var r in e){var n=e[r];i[r]={type:n.type,value:null}}t.prototype.addAttributes.call(this,i)},e.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},e.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Mo(t.position1,t.position2));var e,i,r,n,o,a,s,c=this.size,u=this.mappingSize,h=this.geometry.attributes;for(var l in t)if("index"!==l&&"picking"!==l){i=t[l],r=(e=h[l]).itemSize,n=e.array;for(var p=0;p<c;++p){a=(o=p*r)*u;for(var d=0;d<u;++d){s=a+r*d;for(var f=0;f<r;++f)n[s+f]=i[o+f]}}e.needsUpdate=!0}},e.prototype.makeMapping=function(){for(var t=this.size,e=this.mapping,i=this.mappingSize,r=this.mappingItemSize,n=this.geometry.attributes.mapping.array,o=0;o<t;o++)n.set(e,o*r*i)},e.prototype.makeIndex=function(){for(var t,e,i=this.size,r=this.mappingSize,n=this.mappingIndices,o=this.mappingIndicesSize,a=this.index,s=0;s<i;s++){t=s*o,e=s*r,a.set(n,t);for(var c=0;c<o;++c)a[t+c]+=e}},Object.defineProperties(e.prototype,i),e}(Bv),Xv=new Float32Array([-1,1,-1,-1,1,1,1,-1]),qv=new Uint16Array([0,1,2,1,3,2]),Yv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.mapping.get=function(){return Xv},i.mappingIndices.get=function(){return qv},i.mappingIndicesSize.get=function(){return 6},i.mappingType.get=function(){return"v2"},i.mappingSize.get=function(){return 4},i.mappingItemSize.get=function(){return 2},Object.defineProperties(e.prototype,i),e}(Wv),Zv=function(t){function e(e,i){t.call(this,e,i),this.addUniforms({projectionMatrixInverse:{value:new v},ortho:{value:0}}),this.addAttributes({radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isImpostor:{},vertexShader:{},fragmentShader:{}};return i.isImpostor.get=function(){return!0},i.vertexShader.get=function(){return"SphereImpostor.vert"},i.fragmentShader.get=function(){return"SphereImpostor.frag"},Object.defineProperties(e.prototype,i),e}(Yv),Kv=function(t,e){return!sf||e&&e.disableImpostor?new Hv(t,e):new Zv(t,e)},Qv=new g,Jv=new g,ty=new g,ey=new g(0,0,0),iy=function(t){function e(e,i){var r=i||{},n=new qe(1,gn(r.sphereDetail,2));t.call(this,e,r,n),this.setAttributes(e,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,i){Jv.fromArray(this._majorAxis,i),ty.fromArray(this._minorAxis,i),t.lookAt(ey,Jv,ty),Qv.set(this._radius[e],ty.length(),Jv.length()),t.scale(Qv)},e.prototype.setAttributes=function(e,i){e.radius&&(this._radius=e.radius),e.majorAxis&&(this._majorAxis=e.majorAxis),e.minorAxis&&(this._minorAxis=e.minorAxis),t.prototype.setAttributes.call(this,e,i)},i.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Vv),ry=function(t,e){return new iy(t,e)},ny=new g,oy=new g,ay=new g,sy=new g(0,1,0),cy=function(t){function e(e,i){var r=e||{},n=i||{},o=gn(n.radialSegments,10),a=gn(n.openEnded,!0),s=(new v).makeRotationX(Math.PI/2),c=new vi(1,1,1,o,1,a);c.applyMatrix(s);var u=r.position1.length,h=r.radius.length,l=c.attributes.position.array.length/3,p=u/3,d=new Float32Array(2*p*l);Io(p,l,0,d),Io(p,l,p*l,d);var f=new Float32Array(2*u),m=new Float32Array(2*u);t.call(this,{position:f,color:m,primitiveId:d,picking:r.picking},n,c),this.__center=new Float32Array(u),this._position=f,this._color=m,this._from=new Float32Array(2*u),this._to=new Float32Array(2*u),this._radius=new Float32Array(2*h),this.setAttributes(r,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,i){oy.fromArray(this._from,i),ay.fromArray(this._to,i),t.lookAt(oy,ay,sy);var r=this._radius[e];ny.set(r,r,oy.distanceTo(ay)),t.scale(ny)},e.prototype.setAttributes=function(e,i){var r={};e.position1&&e.position2&&(Mo(e.position1,e.position2,this.__center),Mo(e.position1,this.__center,this._position),Mo(this.__center,e.position2,this._position,e.position1.length),this._from.set(e.position1),this._from.set(this.__center,e.position1.length),this._to.set(this.__center),this._to.set(e.position2,this.__center.length),r.position=this._position),e.color&&e.color2&&(this._color.set(e.color),this._color.set(e.color2,e.color.length),r.color=this._color),e.radius&&(this._radius.set(e.radius),this._radius.set(e.radius,e.radius.length),r.radius=this._radius),t.prototype.setAttributes.call(this,r,i)},i.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Vv);mf.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}"),mf.add("shader/CylinderImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\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\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, nearClip - 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( - ( nearClip - 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\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 );\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\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}");var uy=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),hy=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),ly=function(t){function e(e,i){t.call(this,e,i);var r=i||{};this.openEnded=gn(r.openEnded,!1),this.addUniforms({modelViewMatrixInverse:{value:new v},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(e),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},isImpostor:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{openEnded:{updateShader:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.openEnded||(i.CAP=1),i},i.isImpostor.get=function(){return!0},i.vertexShader.get=function(){return"CylinderImpostor.vert"},i.fragmentShader.get=function(){return"CylinderImpostor.frag"},Object.defineProperties(e.prototype,i),e}(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.mapping.get=function(){return uy},i.mappingIndices.get=function(){return hy},i.mappingIndicesSize.get=function(){return 12},i.mappingType.get=function(){return"v3"},i.mappingSize.get=function(){return 6},i.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,i),e}(Wv)),py=function(t,e){return!sf||e&&e.disableImpostor?new cy(t,e):new ly(t,e)},dy=new g,fy=new g,my=new g,gy=new g(0,1,0),vy=function(t){function e(e,i){var r=i||{},n=gn(r.radialSegments,60),o=gn(r.openEnded,!1),a=(new v).makeRotationX(-Math.PI/2),s=new bi(1,1,n,1,o);s.applyMatrix(a);var c=e.position1.length,u=e.radius.length,h=new Float32Array(c);t.call(this,{position:h,color:e.color,picking:e.picking},r,s),this._position=h,this._from=new Float32Array(c),this._to=new Float32Array(c),this._radius=new Float32Array(u),this.setAttributes(e,!0)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={updateNormals:{}};return e.prototype.applyPositionTransform=function(t,e,i){fy.fromArray(this._from,i),my.fromArray(this._to,i),t.lookAt(fy,my,gy);var r=this._radius[e];dy.set(r,r,fy.distanceTo(my)),t.scale(dy)},e.prototype.setAttributes=function(e,i){var r={};e.position1&&e.position2&&(Mo(e.position1,e.position2,this._position),this._from.set(e.position1),this._to.set(e.position2),r.position=this._position),e.color&&(r.color=e.color),e.radius&&this._radius.set(e.radius),t.prototype.setAttributes.call(this,r,i)},i.updateNormals.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Vv),yy=function(t,e){return new vy(t,e)},by=function(t){this.geometryList=t,this.boundingBox=null};by.prototype.computeBoundingBox=function(){var t=this;this.boundingBox?this.boundingBox.empty():this.boundingBox=new st,this.geometryList.forEach(function(e){e.boundingBox||e.computeBoundingBox(),t.boundingBox.union(e.boundingBox)})};var xy=function(t,e){var i=t||{},r=e||{};this.aspectRatio=gn(r.aspectRatio,1.5),this.wireframe=gn(r.wireframe,!1),this.splitPosition=new Float32Array(i.position1.length),this.cylinderRadius=new Float32Array(i.radius.length);var n=this.makeAttributes(i),o={radialSegments:gn(r.radialSegments,50),openEnded:gn(r.openEnded,!1),disableImpostor:gn(r.disableImpostor,!1)};this.cylinderBuffer=new py(n.cylinder,o),this.coneBuffer=new yy(n.cone,o),this.geometry=new by([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.group=new Ne,this.wireframeGroup=new Ne,this.pickingGroup=new Ne,this.matrix=gn(r.matrix,new v),this.picking=i.picking},_y={matrix:{},pickable:{}};_y.matrix.set=function(t){Bv.prototype.setMatrix.call(this,t)},_y.matrix.get=function(){return this.group.matrix.clone()},_y.pickable.get=function(){return!!this.picking},xy.prototype.makeAttributes=function(t){var e,i,r=this.splitPosition,n=this.cylinderRadius,o=this.aspectRatio,a={},s={};if(t.radius){for(e=0,i=n.length;e<i;++e)n[e]=t.radius[e]/o;a.radius=n,s.radius=t.radius}if(t.position1&&t.position2){var c=new g,u=new g,h=new g,l=new g;for(e=0,i=r.length;e<i;e+=3){c.fromArray(t.position1,e),u.fromArray(t.position2,e),h.subVectors(c,u);var p=h.length(),d=n[e/3]*o*2,f=Math.min(p,d);h.setLength(f),l.copy(u).add(h),l.toArray(r,e)}a.position1=t.position1,a.position2=r,s.position1=r,s.position2=t.position2}return t.color&&(a.color=t.color,a.color2=t.color,s.color=t.color),{cylinder:a,cone:s}},xy.prototype.getMesh=function(t){return(new Ne).add(this.cylinderBuffer.getMesh(t),this.coneBuffer.getMesh(t))},xy.prototype.getWireframeMesh=function(){return(new Ne).add(this.cylinderBuffer.getWireframeMesh(),this.coneBuffer.getWireframeMesh())},xy.prototype.getPickingMesh=function(){return(new Ne).add(this.cylinderBuffer.getPickingMesh(),this.coneBuffer.getPickingMesh())},xy.prototype.setAttributes=function(t){var e=this.makeAttributes(t);this.cylinderBuffer.setAttributes(e.cylinder),this.coneBuffer.setAttributes(e.cone)},xy.prototype.setParameters=function(t){(t=Object.assign({},t))&&void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,t&&void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),this.cylinderBuffer.setParameters(t),this.coneBuffer.setParameters(t)},xy.prototype.setVisibility=function(){Bv.prototype.setVisibility.apply(this,arguments)},xy.prototype.dispose=function(){this.cylinderBuffer.dispose(),this.coneBuffer.dispose()},Object.defineProperties(xy.prototype,_y),mf.add("shader/SDFFont.vert","uniform float nearClip;\nuniform float clipRadius;\nuniform vec3 clipCenter;\nuniform float xOffset;\nuniform float yOffset;\nuniform float zOffset;\nuniform bool ortho;\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 _zOffset = zOffset * scale;\nif( texCoord.x == 10.0 ){\n_zOffset -= 0.001;\n}\nvec3 pos = position;\nif( ortho ){\npos += normalize( cameraPosition ) * _zOffset;\n}\nvec4 cameraPos = modelViewMatrix * vec4( pos, 1.0 );\nvec4 cameraCornerPos = vec4( cameraPos.xyz, 1.0 );\ncameraCornerPos.xy += mapping * inputSize * 0.01 * scale;\ncameraCornerPos.x += xOffset * scale;\ncameraCornerPos.y += yOffset * scale;\nif( !ortho ){\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}"),mf.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 nearClip;\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\n#ifdef SDF\nconst float smoothness = 16.0;\n#else\nconst float smoothness = 256.0;\n#endif\nconst float gamma = 2.2;\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 w = clamp(\nsmoothness * ( abs( dFdx( texCoord.x ) ) + abs( dFdy( texCoord.y ) ) ),\n0.0,\n0.5\n);\nfloat a = smoothstep( 0.5 - w, 0.5 + w, sdf );\na = pow( a, 1.0 / gamma );\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( 0.5 + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\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}");var wy={},Sy=function(t){var e=Object.assign({},t);if(this.font=gn(e.font,["sans-serif"]),this.size=gn(e.size,36),this.style=gn(e.style,"normal"),this.variant=gn(e.variant,"normal"),this.weight=gn(e.weight,"normal"),this.outline=gn(e.outline,0),this.width=gn(e.width,2048),this.height=gn(e.height,2048),this.gamma=1,"undefined"!=typeof navigator){var i=navigator.userAgent;i.match(/Chrome/)&&i.match(/OS X/)&&(this.gamma=.5)}this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.build(),this.populate(),this.texture=new Fe(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};Sy.prototype.build=function(){var t=this.size+2*this.outline+Math.round(this.size/4),e=this.width/4,i=document.createElement("canvas");i.width=e,i.height=t;var r=i.getContext("2d");r.font=this.style+" "+this.variant+" "+this.weight+" "+this.size+"px "+this.font,r.fillStyle="#FF0000",r.textAlign="left",r.textBaseline="bottom",r.lineJoin="round";for(var n=[],o=3*this.outline,a=0;a<o;++a){var s=("00"+Math.max(0,8*-a+128-8*!a).toString(16)).slice(-2);n.push("#"+s+s+s)}var c=new Uint8Array(e*t*2);this.canvas=i,this.context=r,this.lineHeight=t,this.maxWidth=e,this.colors=n,this.scratch=c,this.data=new Uint8Array(this.width*this.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=this.width,this.canvas2.height=this.height,this.context2=this.canvas2.getContext("2d")},Sy.prototype.map=function(t){return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>this.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>this.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]},Sy.prototype.get=function(t){return this.mapped[t]||this.placeholder},Sy.prototype.draw=function(t){var e=this.lineHeight,i=this.outline,r=this.context,n=this.scratch,o=this.maxWidth,a=this.colors,s=i,c=e-this.outline,u=r.measureText(t),h=Math.min(o,Math.ceil(u.width+2*s+1));r.clearRect(0,0,h,e);var l,p,d,f,m;if(0===this.outline)for(r.fillText(t,s,c),d=3,l=0,p=(m=(f=r.getImageData(0,0,h,e)).data).length/4;l<p;++l)n[l]=m[d],d+=4;else{for(r.globalCompositeOperation="source-over",l=i+1;l>0;--l)d=l>1?2*l-2:l,r.strokeStyle=a[d-1],r.lineWidth=d,r.strokeText(t,s,c);r.globalCompositeOperation="multiply",r.fillStyle="#FF00FF",r.fillText(t,s,c),m=(f=r.getImageData(0,0,h,e)).data,d=0;var g=this.gamma;for(l=0,p=m.length/4;l<p;++l){var v=m[d],y=v?m[d+1]/v:1;.5===g&&(y=Math.sqrt(y));var b=256-v,x=b+(v-b)*(y=Math.min(1,Math.max(0,y)));n[l]=Math.max(0,Math.min(255,x+2)),m[d+3]=n[l],d+=4}}r.putImageData(f,0,0),this.scratchW=h,this.scratchH=e},Sy.prototype.populate=function(){var t=this;this.placeholder=this.map(String.fromCharCode(65533));for(var e=0;e<127;++e)t.map(String.fromCharCode(e));for(var i=128;i<255;++i)t.map(String.fromCharCode(i));for(var r=880;r<1023;++r)t.map(String.fromCharCode(r));for(var n=1024;n<1279;++n)t.map(String.fromCharCode(n));this.map(String.fromCharCode(8491))};var Ay=function(t){function e(e,i){var r=e||{},n=i||{};n.forceTransparent=!0;for(var o=r.position.length/3,a=0,s=0;s<o;++s)a+=r.text[s].length;var c=a;n.showBackground&&(c+=o),t.call(this,{position:new Float32Array(3*c),color:new Float32Array(3*c),picking:new og},n),this.fontFamily=gn(n.fontFamily,"sans-serif"),this.fontStyle=gn(n.fontStyle,"normal"),this.fontWeight=gn(n.fontWeight,"bold"),this.fontSize=gn(n.fontSize,48),this.sdf=gn(n.sdf,"Chrome"===nf),this.xOffset=gn(n.xOffset,0),this.yOffset=gn(n.yOffset,0),this.zOffset=gn(n.zOffset,.5),this.attachment=gn(n.attachment,"bottom-left"),this.showBorder=gn(n.showBorder,!1),this.borderColor=gn(n.borderColor,"lightgrey"),this.borderWidth=gn(n.borderWidth,.15),this.showBackground=gn(n.showBackground,!1),this.backgroundColor=gn(n.backgroundColor,"lightgrey"),this.backgroundMargin=gn(n.backgroundMargin,.5),this.backgroundOpacity=gn(n.backgroundOpacity,1),this.text=r.text,this.positionCount=o,this.addUniforms({fontTexture:{value:null},xOffset:{value:this.xOffset},yOffset:{value:this.yOffset},zOffset:{value:this.zOffset},ortho:{value:!1},showBorder:{value:this.showBorder},borderColor:{value:new tt(this.borderColor)},borderWidth:{value:this.borderWidth},backgroundColor:{value:new tt(this.backgroundColor)},backgroundOpacity:{value:this.backgroundOpacity}}),this.addAttributes({inputTexCoord:{type:"v2",value:null},inputSize:{type:"f",value:null}}),this.setAttributes(e),this.makeTexture(),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},wireframe:{},isText:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{fontFamily:{uniform:!0},fontStyle:{uniform:!0},fontWeight:{uniform:!0},fontSize:{uniform:!0},sdf:{updateShader:!0,uniform:!0},xOffset:{uniform:!0},yOffset:{uniform:!0},zOffset:{uniform:!0},showBorder:{uniform:!0},borderColor:{uniform:!0},borderWidth:{uniform:!0},backgroundColor:{uniform:!0},backgroundOpacity:{uniform:!0}},t.prototype.parameters,{flatShaded:void 0})},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this);var e=this.texture,i=this.material;i.extensions.derivatives=!0,i.lights=!1,i.uniforms.fontTexture.value=e,i.needsUpdate=!0;var r=this.wireframeMaterial;r.extensions.derivatives=!0,r.lights=!1,r.uniforms.fontTexture.value=e,r.needsUpdate=!0;var n=this.pickingMaterial;n.extensions.derivatives=!0,n.lights=!1,n.uniforms.fontTexture.value=e,n.needsUpdate=!0},e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s=this,c=this.text,u=this.geometry.attributes;t.position&&(e=t.position,n=u.position.array,u.position.needsUpdate=!0),t.size&&(i=t.size,o=u.inputSize.array,u.inputSize.needsUpdate=!0),t.color&&(r=t.color,a=u.color.array,u.color.needsUpdate=!0);for(var h,l,p,d,f=this.positionCount,m=0,g=0;g<f;++g)for(l=3*g,d=c[g].length,s.showBackground&&(d+=1),p=0;p<d;++p,++m)for(var v=0;v<4;v++)h=4*m*3+3*v,e&&(n[h]=e[l],n[h+1]=e[l+1],n[h+2]=e[l+2]),i&&(o[4*m+v]=i[g]),r&&(a[h]=r[l],a[h+1]=r[l+1],a[h+2]=r[l+2])},e.prototype.makeTexture=function(){this.textAtlas=xs({font:[this.fontFamily],style:this.fontStyle,weight:this.fontWeight,size:this.fontSize,outline:this.sdf?5:0}),this.texture=this.textAtlas.texture},e.prototype.makeMapping=function(){for(var t,e,i,r,n,o,a,s,c=this,u=this.textAtlas,h=this.text,l=this.attachment,p=u.lineHeight*this.backgroundMargin*.1-10,d=this.geometry.attributes.inputTexCoord.array,f=this.geometry.attributes.mapping.array,m=this.positionCount,g=0,v=0;v<m;++v){for(r=0,o=(i=h[v]).length,n=0;n<o;++n)r+=(t=u.get(i[n])).w-2*u.outline;for(s=l.startsWith("top")?u.lineHeight/1.25:l.startsWith("middle")?u.lineHeight/2.5:0,a=l.endsWith("right")?r:l.endsWith("center")?r/2:0,a+=u.outline,s+=u.outline,c.showBackground&&(f[(e=2*g*4)+0]=-u.lineHeight/6-a-p,f[e+1]=u.lineHeight-s+p,f[e+2]=-u.lineHeight/6-a-p,f[e+3]=0-s-p,f[e+4]=r+u.lineHeight/6-a+2*u.outline+p,f[e+5]=u.lineHeight-s+p,f[e+6]=r+u.lineHeight/6-a+2*u.outline+p,f[e+7]=0-s-p,d[e+0]=10,d[e+2]=10,d[e+4]=10,d[e+6]=10,g+=1),r=0,n=0;n<o;++n,++g){t=u.get(i[n]),f[(e=2*g*4)+0]=r-a,f[e+1]=t.h-s,f[e+2]=r-a,f[e+3]=0-s,f[e+4]=r+t.w-a,f[e+5]=t.h-s,f[e+6]=r+t.w-a,f[e+7]=0-s;var y=u.width,b=u.height,x=[t.x/y,t.y/b,t.x/y,(t.y+t.h)/b,(t.x+t.w)/y,t.y/b,(t.x+t.w)/y,(t.y+t.h)/b];d.set(x,e),r+=t.w-2*u.outline}}this.geometry.attributes.inputTexCoord.needsUpdate=!0,this.geometry.attributes.mapping.needsUpdate=!0},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.sdf&&(i.SDF=1),i},e.prototype.setUniforms=function(e){!e||void 0===e.fontFamily&&void 0===e.fontStyle&&void 0===e.fontWeight&&void 0===e.fontSize&&void 0===e.sdf||(this.makeTexture(),this.makeMapping(),this.texture.needsUpdate=!0,e.fontTexture=this.texture),t.prototype.setUniforms.call(this,e)},i.wireframe.set=function(t){},i.wireframe.get=function(){return!1},i.isText.get=function(){return!0},i.vertexShader.get=function(){return"SDFFont.vert"},i.fragmentShader.get=function(){return"SDFFont.frag"},Object.defineProperties(e.prototype,i),e}(Yv),My=new g,Py=new st,Ty=function(t,e){this.name=gn(t,"shape");var i=e||{};this.aspectRatio=gn(i.aspectRatio,1.5),this.sphereDetail=gn(i.sphereDetail,2),this.radialSegments=gn(i.radialSegments,50),this.disableImpostor=gn(i.disableImpostor,!1),this.openEnded=gn(i.openEnded,!1),this.labelParams=gn(i.labelParams,{}),this.boundingBox=new st,this.bufferList=[],this.meshCount=0,this.spherePosition=[],this.sphereColor=[],this.sphereRadius=[],this.sphereName=[],this.ellipsoidPosition=[],this.ellipsoidColor=[],this.ellipsoidRadius=[],this.ellipsoidMajorAxis=[],this.ellipsoidMinorAxis=[],this.ellipsoidName=[],this.cylinderPosition1=[],this.cylinderPosition2=[],this.cylinderColor=[],this.cylinderRadius=[],this.cylinderName=[],this.conePosition1=[],this.conePosition2=[],this.coneColor=[],this.coneRadius=[],this.coneName=[],this.arrowPosition1=[],this.arrowPosition2=[],this.arrowColor=[],this.arrowRadius=[],this.arrowName=[],this.labelPosition=[],this.labelColor=[],this.labelSize=[],this.labelText=[]},Ey={center:{},type:{}};Ty.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},Ty.prototype.addMesh=function(t,e,i,r,n){t=zn(t),e=zn(e),Array.isArray(i)&&(i=Ln(i,t.length)),r&&(r=zn(r));var o={position:t,color:e,index:i,normal:r},a=new ag(this,Object.assign({serial:this.meshCount,name:n},o)),s=new Uv(Object.assign({picking:a},o));return this.bufferList.push(s),Py.setFromArray(t),this.boundingBox.union(Py),this.meshCount+=1,this},Ty.prototype.addSphere=function(t,e,i,r){return _s(t,this.spherePosition),_s(e,this.sphereColor),this.sphereRadius.push(i),this.sphereName.push(r),this.boundingBox.expandByPoint(My.fromArray(t)),this},Ty.prototype.addEllipsoid=function(t,e,i,r,n,o){return _s(t,this.ellipsoidPosition),_s(e,this.ellipsoidColor),this.ellipsoidRadius.push(i),_s(r,this.ellipsoidMajorAxis),_s(n,this.ellipsoidMinorAxis),this.ellipsoidName.push(o),this.boundingBox.expandByPoint(My.fromArray(t)),this},Ty.prototype.addCylinder=function(t,e,i,r,n){return _s(t,this.cylinderPosition1),_s(e,this.cylinderPosition2),_s(i,this.cylinderColor),this.cylinderRadius.push(r),this.cylinderName.push(n),this.boundingBox.expandByPoint(My.fromArray(t)),this.boundingBox.expandByPoint(My.fromArray(e)),this},Ty.prototype.addCone=function(t,e,i,r,n){return _s(t,this.conePosition1),_s(e,this.conePosition2),_s(i,this.coneColor),this.coneRadius.push(r),this.coneName.push(n),this.boundingBox.expandByPoint(My.fromArray(t)),this.boundingBox.expandByPoint(My.fromArray(e)),this},Ty.prototype.addArrow=function(t,e,i,r,n){return _s(t,this.arrowPosition1),_s(e,this.arrowPosition2),_s(i,this.arrowColor),this.arrowRadius.push(r),this.arrowName.push(n),this.boundingBox.expandByPoint(My.fromArray(t)),this.boundingBox.expandByPoint(My.fromArray(e)),this},Ty.prototype.addLabel=function(t,e,i,r){return _s(t,this.labelPosition),_s(e,this.labelColor),this.labelSize.push(i),this.labelText.push(r),this.boundingBox.expandByPoint(My.fromArray(t)),this},Ty.prototype.getBufferList=function(){var t=[];if(this.spherePosition.length){var e=new Kv({position:new Float32Array(this.spherePosition),color:new Float32Array(this.sphereColor),radius:new Float32Array(this.sphereRadius),picking:new sg(this)},{sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor});t.push(e)}if(this.ellipsoidPosition.length){var i=new ry({position:new Float32Array(this.ellipsoidPosition),color:new Float32Array(this.ellipsoidColor),radius:new Float32Array(this.ellipsoidRadius),majorAxis:new Float32Array(this.ellipsoidMajorAxis),minorAxis:new Float32Array(this.ellipsoidMinorAxis),picking:new ng(this)},{sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor});t.push(i)}if(this.cylinderPosition1.length){var r=new py({position1:new Float32Array(this.cylinderPosition1),position2:new Float32Array(this.cylinderPosition2),color:new Float32Array(this.cylinderColor),color2:new Float32Array(this.cylinderColor),radius:new Float32Array(this.cylinderRadius),picking:new Ym(this)},{radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded});t.push(r)}if(this.conePosition1.length){var n=new yy({position1:new Float32Array(this.conePosition1),position2:new Float32Array(this.conePosition2),color:new Float32Array(this.coneColor),radius:new Float32Array(this.coneRadius),picking:new eg(this)},{radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded});t.push(n)}if(this.arrowPosition1.length){var o=new xy({position1:new Float32Array(this.arrowPosition1),position2:new Float32Array(this.arrowPosition2),color:new Float32Array(this.arrowColor),radius:new Float32Array(this.arrowRadius),picking:new Zm(this)},{aspectRatio:this.aspectRatio,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,openEnded:this.openEnded});t.push(o)}if(this.labelPosition.length){var a=new Ay({position:new Float32Array(this.labelPosition),color:new Float32Array(this.labelColor),size:new Float32Array(this.labelSize),text:this.labelText},this.labelParams);t.push(a)}return this.bufferList.concat(t)},Ty.prototype.dispose=function(){this.bufferList.forEach(function(t){t.dispose()}),this.bufferList.length=0,this.spherePosition.length=0,this.sphereColor.length=0,this.sphereRadius.length=0,this.sphereName.length=0,this.ellipsoidPosition.length=0,this.ellipsoidColor.length=0,this.ellipsoidRadius.length=0,this.ellipsoidMajorAxis.length=0,this.ellipsoidMinorAxis.length=0,this.ellipsoidName.length=0,this.cylinderPosition1.length=0,this.cylinderPosition2.length=0,this.cylinderColor.length=0,this.cylinderRadius.length=0,this.cylinderName.length=0,this.conePosition1.length=0,this.conePosition2.length=0,this.coneColor.length=0,this.coneRadius.length=0,this.coneName.length=0,this.arrowPosition1.length=0,this.arrowPosition2.length=0,this.arrowColor.length=0,this.arrowRadius.length=0,this.arrowName.length=0,this.labelPosition.length=0,this.labelColor.length=0,this.labelSize.length=0,this.labelText.length=0},Ey.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter()),this._center},Ey.type.get=function(){return"Shape"},Object.defineProperties(Ty.prototype,Ey);var Cy=function(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},linewidth:{type:"integer",max:50,min:1,buffer:!0},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:lf.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:lf.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},matrix:{type:"hidden",buffer:!0},disablePicking:{type:"boolean",rebuild:!0}},this.viewer=e,this.tasks=new Of,this.queue=new ms(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=lf.getSchemes())};Cy.prototype.init=function(t){var e=t||{};this.clipNear=gn(e.clipNear,0),this.clipRadius=gn(e.clipRadius,0),this.clipCenter=gn(e.clipCenter,new g),this.flatShaded=gn(e.flatShaded,!1),this.side=gn(e.side,"double"),this.opacity=gn(e.opacity,1),this.depthWrite=gn(e.depthWrite,!0),this.wireframe=gn(e.wireframe,!1),this.linewidth=gn(e.linewidth,2),this.setColor(e.color,e),this.colorScheme=gn(e.colorScheme,"uniform"),this.colorScale=gn(e.colorScale,""),this.colorReverse=gn(e.colorReverse,!1),this.colorValue=gn(e.colorValue,9474192),this.colorDomain=gn(e.colorDomain,void 0),this.colorMode=gn(e.colorMode,"hcl"),this.visible=gn(e.visible,!0),this.quality=gn(e.quality,void 0),this.roughness=gn(e.roughness,.4),this.metalness=gn(e.metalness,0),this.diffuse=gn(e.diffuse,16777215),this.lazy=gn(e.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=gn(e.matrix,new v),this.disablePicking=gn(e.disablePicking,!1);var i=this.parameters;!0===i.sphereDetail&&(i.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===i.radialSegments&&(i.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===i.openEnded&&(i.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===i.disableImpostor&&(i.disableImpostor={type:"boolean",rebuild:!0}),"low"===e.quality?(i.sphereDetail&&(this.sphereDetail=0),i.radialSegments&&(this.radialSegments=5)):"medium"===e.quality?(i.sphereDetail&&(this.sphereDetail=1),i.radialSegments&&(this.radialSegments=10)):"high"===e.quality?(i.sphereDetail&&(this.sphereDetail=2),i.radialSegments&&(this.radialSegments=20)):(i.sphereDetail&&(this.sphereDetail=gn(e.sphereDetail,1)),i.radialSegments&&(this.radialSegments=gn(e.radialSegments,10))),i.openEnded&&(this.openEnded=gn(e.openEnded,!0)),i.disableImpostor&&(this.disableImpostor=gn(e.disableImpostor,!1))},Cy.prototype.getColorParams=function(t){return Object.assign({scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode},t)},Cy.prototype.getBufferParams=function(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,linewidth:this.linewidth,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse,matrix:this.matrix,disablePicking:this.disablePicking},t)},Cy.prototype.setColor=function(t,e){return Object.keys(lf.getSchemes()).includes(t)?e?e.colorScheme=t:this.setParameters({colorScheme:t}):void 0!==t&&(t=new tt(t).getHex(),e?(e.colorScheme="uniform",e.colorValue=t):this.setParameters({colorScheme:"uniform",colorValue:t})),this},Cy.prototype.create=function(){},Cy.prototype.update=function(){this.build()},Cy.prototype.build=function(t){return this.lazy&&!this.visible?void(this.lazyProps.build=!0):this.prepare?(this.queue.length()>0?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),void this.queue.push(t||!1)):(this.tasks.increment(),void this.make())},Cy.prototype.make=function(e,i){t.Debug&&cf.time("Representation.make "+this.type);var r=function(){e?(this.update(e),this.viewer.requestRender(),this.tasks.decrement(),i&&i()):(this.clear(),this.create(),this.manualAttach||this.disposed||(t.Debug&&cf.time("Representation.attach "+this.type),this.attach(function(){t.Debug&&cf.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),i&&i()}.bind(this)))),t.Debug&&cf.timeEnd("Representation.make "+this.type)}.bind(this);this.prepare?this.prepare(r):r()},Cy.prototype.attach=function(t){this.setVisibility(this.visible),t()},Cy.prototype.setVisibility=function(t,e){if(this.visible=t,this.visible){var i=this.lazyProps,r=i.bufferParams,n=i.what;if(i.build)return i.build=!1,void this.build();(Object.keys(r).length||Object.keys(n).length)&&(i.bufferParams={},i.what={},this.updateParameters(r,n))}return this.bufferList.forEach(function(e){e.setVisibility(t)}),e||this.viewer.requestRender(),this},Cy.prototype.setParameters=function(t,e,i){var r=this,n=t||{},o=this.parameters;e=e||{},i=i||!1;var a={};for(var s in n)void 0!==n[s]&&void 0!==o[s]&&(o[s].int&&(n[s]=parseInt(n[s])),o[s].float&&(n[s]=parseFloat(n[s])),(n[s]!==r[s]||n[s].equals&&!n[s].equals(r[s]))&&(r[s].set?r[s].set(n[s]):r[s]=n[s],o[s].buffer&&(!0===o[s].buffer?a[s]=n[s]:a[o[s].buffer]=n[s]),o[s].update&&(e[o[s].update]=!0),!o[s].rebuild||"impostor"===o[s].rebuild&&sf&&!r.disableImpostor||(i=!0)));return i?this.build():this.updateParameters(a,e),this},Cy.prototype.updateParameters=function(t,e){if(this.lazy&&!this.visible)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()},Cy.prototype.getParameters=function(){var t=this,e={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(function(i){null!==t.parameters[i]&&(e[i]=t[i])}),e},Cy.prototype.clear=function(){var t=this;this.bufferList.forEach(function(e){t.viewer.remove(e),e.dispose()}),this.bufferList.length=0,this.viewer.requestRender()},Cy.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var Iy=function(t){function e(e,i,r){Array.isArray(e)||(e=[e]),t.call(this,e,i,r),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){t.prototype.init.call(this,e),this.build()},e.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t),t.setParameters(e.getBufferParams())}),this.setVisibility(this.visible),t()},e}(Cy),Ry=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isSurface:{}};return i.isSurface.get=function(){return!0},Object.defineProperties(e.prototype,i),e}(Uv),Ly=function(t){this.size=t.size,this.side=t.side,this.wireframe=t.wireframe,this.visible=t.visible,this.geometry=t.geometry,this.picking=t.picking,this.background=t.background,this.disablePicking=t.disablePicking,this.group=new Ne,this.wireframeGroup=new Ne,this.pickingGroup=new Ne,this.matrix=t.matrix,this.frontMeshes=[],this.backMeshes=[];var e=t,i=new t.constructor;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.opacity}),this.buffer=t,this.frontBuffer=e,this.backBuffer=i},Oy={matrix:{},pickable:{}};Oy.matrix.set=function(t){Bv.prototype.setMatrix.call(this,t)},Oy.matrix.get=function(){return this.group.matrix.clone()},Oy.pickable.get=function(){return!!this.picking&&!this.disablePicking},Ly.prototype.getMesh=function(t){var 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 Ne).add(i,e)},Ly.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},Ly.prototype.getPickingMesh=function(){return this.getMesh(!0)},Ly.prototype.setAttributes=function(t){this.buffer.setAttributes(t)},Ly.prototype.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(ws),this.backMeshes.forEach(Ss)):"back"===t.side?(this.frontMeshes.forEach(Ss),this.backMeshes.forEach(ws)):"double"===t.side&&(this.frontMeshes.forEach(ws),this.backMeshes.forEach(ws)),void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,void 0!==t.side&&(this.side=t.side),delete t.side,this.frontBuffer.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,this.backBuffer.setParameters(t)},Ly.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},Object.defineProperties(Ly.prototype,Oy),Ly.prototype.setVisibility=Bv.prototype.setVisibility,mf.add("shader/Line.vert","uniform float nearClip;\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}"),mf.add("shader/Line.frag","uniform float opacity;\nuniform float nearClip;\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}");var Dy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(Bv),Ny=function(t){function e(e,i,r){t.call(this,e,i,r),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"},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),e instanceof Zg?(this.surface=void 0,this.volume=e):(this.surface=e,this.volume=void 0),this.boxCenter=new g,this.__boxCenter=new g,this.box=new st,this.__box=new st,this._position=new g,this.setBox=function(){this._position.copy(i.translationGroup.position).negate(),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.viewer.signals.ticked.add(this.setBox,this),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"uniform"),i.colorValue=gn(i.colorValue,14540253),this.isolevelType=gn(i.isolevelType,"sigma"),this.isolevel=gn(i.isolevel,2),this.negateIsolevel=gn(i.negateIsolevel,!1),this.smooth=gn(i.smooth,0),this.background=gn(i.background,!1),this.opaqueBack=gn(i.opaqueBack,!0),this.boxSize=gn(i.boxSize,0),this.colorVolume=gn(i.colorVolume,void 0),this.contour=gn(i.contour,!1),this.useWorker=gn(i.useWorker,!0),this.wrap=gn(i.wrap,!1),t.prototype.init.call(this,i),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.prepare=function(t){var e=this;if(this.volume){var i;if(i="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(i*=-1),!this.surface||this.__isolevel!==i||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=i,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 r=function(i){e.surface=i,t()};this.useWorker?this.volume.getSurfaceWorker(i,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,r):r(this.volume.getSurface(i,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else t()}else t()},e.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new Dy(e,this.getBufferParams({wireframe:!1}));else{e.normal=this.surface.getNormal(),e.picking=this.surface.getPicking();var i=new Ry(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new Ly(i)}this.bufferList.push(t)},e.prototype.update=function(t){if(0!==this.bufferList.length){var 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)})}},e.prototype.setParameters=function(e,i,r){return e&&void 0!==e.isolevelType&&this.volume&&("value"===this.isolevelType&&"sigma"===e.isolevelType?this.isolevel=this.volume.getSigmaForValue(this.isolevel):"sigma"===this.isolevelType&&"value"===e.isolevelType&&(this.isolevel=this.volume.getValueForSigma(this.isolevel)),this.isolevelType=e.isolevelType),e&&e.boxCenter&&(this.boxCenter.copy(e.boxCenter),delete e.boxCenter),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,i,r),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),e&&void 0!==e.colorVolume&&(i.color=!0),this.surface&&(void 0!==e.isolevel||void 0!==e.negateIsolevel||void 0!==e.smooth||void 0!==e.wrap||void 0!==e.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),t.prototype.dispose.call(this)},e}(Cy);mf.add("shader/Point.vert","uniform float nearClip;\nuniform float clipRadius;\nuniform vec3 clipCenter;\nuniform float size;\nuniform float canvasHeight;\nuniform float pixelRatio;\nvarying vec3 vViewPosition;\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\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\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n#include radiusclip_vertex\n}"),mf.add("shader/Point.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float nearClip;\nuniform float clipRadius;\nvarying vec3 vViewPosition;\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\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\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}");var ky=function(t){function e(e,i){var r=e||{},n=i||{};r.primitiveId||(r.primitiveId=Co(r.position.length/3)),t.call(this,r,n),this.pointSize=gn(n.pointSize,1),this.sizeAttenuation=gn(n.sizeAttenuation,!0),this.sortParticles=gn(n.sortParticles,!1),this.alphaTest=gn(n.alphaTest,.5),this.useTexture=gn(n.useTexture,!1),this.forceTransparent=gn(n.forceTransparent,!1),this.edgeBleach=gn(n.edgeBleach,0),this.addUniforms({size:{value:this.pointSize},canvasHeight:{value:1},pixelRatio:{value:1},map:{value:null}})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},isPoint:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{pointSize:{uniform:"size"},sizeAttenuation:{updateShader:!0},sortParticles:{},alphaTest:{updateShader:!0},useTexture:{updateShader:!0},forceTransparent:{},edgeBleach:{uniform:!0}},t.prototype.parameters)},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.makeTexture();var e=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;e.uniforms.map.value=this.tex,e.needsUpdate=!0,i.uniforms.map.value=this.tex,i.needsUpdate=!0,r.uniforms.map.value=this.tex,r.needsUpdate=!0},e.prototype.makeTexture=function(){this.tex&&this.tex.dispose(),this.tex=Ms({delta:this.edgeBleach})},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.sizeAttenuation&&(i.USE_SIZEATTENUATION=1),this.useTexture&&(i.USE_MAP=1),this.alphaTest>0&&this.alphaTest<=1&&(i.ALPHATEST=this.alphaTest.toPrecision(2)),i},e.prototype.setUniforms=function(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.tex&&this.tex.dispose()},i.isPoint.get=function(){return!0},i.vertexShader.get=function(){return"Point.vert"},i.fragmentShader.get=function(){return"Point.frag"},Object.defineProperties(e.prototype,i),e}(Bv),Fy=function(t){function e(e,i,r){t.call(this,e,i,r),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"}}}),e instanceof Zg?(this.surface=void 0,this.volume=new Qg(e)):(this.surface=e,this.volume=void 0),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"uniform"),i.colorValue=gn(i.colorValue,14540253),this.thresholdType=gn(i.thresholdType,"sigma"),this.thresholdMin=gn(i.thresholdMin,2),this.thresholdMax=gn(i.thresholdMax,1/0),this.thresholdOut=gn(i.thresholdOut,!1),this.dotType=gn(i.dotType,"point"),this.radius=gn(i.radius,.1),this.scale=gn(i.scale,1),this.pointSize=gn(i.pointSize,1),this.sizeAttenuation=gn(i.sizeAttenuation,!0),this.sortParticles=gn(i.sortParticles,!1),this.useTexture=gn(i.useTexture,!1),this.alphaTest=gn(i.alphaTest,.5),this.forceTransparent=gn(i.forceTransparent,!1),this.edgeBleach=gn(i.edgeBleach,0),t.prototype.init.call(this,i),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.create=function(){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),t.position=r.getDataPosition(),t.color=r.getDataColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=r.getDataSize(this.radius,this.scale),t.picking=r.getDataPicking())}else{var n=this.surface;t.position=n.getPosition(),t.color=n.getColor(this.getColorParams()),"sphere"===this.dotType&&(t.radius=n.getSize(this.radius,this.scale),t.picking=n.getPicking())}"sphere"===this.dotType?this.dotBuffer=new Kv(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new ky(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)},e.prototype.update=function(t){if(0!==this.bufferList.length){var e={};(t=t||{}).color&&(this.volume?e.color=this.volume.getDataColor(this.getColorParams()):e.color=this.surface.getColor(this.getColorParams())),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?e.radius=this.volume.getDataSize(this.radius,this.scale):e.radius=this.surface.getSize(this.radius,this.scale)),this.dotBuffer.setAttributes(e)}},e.prototype.setParameters=function(e,i,r){return i=i||{},e&&void 0!==e.thresholdType&&this.volume instanceof Zg&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=e.radiusType,i.radius=!0,"sphere"!==this.dotType||sf&&!this.disableImpostor||(r=!0)),e&&void 0!==e.radius&&(i.radius=!0,"sphere"!==this.dotType||sf&&!this.disableImpostor||(r=!0)),e&&void 0!==e.scale&&(i.scale=!0,"sphere"!==this.dotType||sf&&!this.disableImpostor||(r=!0)),t.prototype.setParameters.call(this,e,i,r),this},e}(Cy);mf.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}"),mf.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float nearClip;\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.7 )\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}");var By=new Uint16Array([0,1,2,1,3,2]),zy=new Float32Array([0,1,0,0,1,1,1,0]),Uy=function(t){function e(e,i){var r=e||{},n=i||{};t.call(this,{position:r.position,index:By,picking:r.picking},n),this.forceTransparent=!0,this.filter=gn(n.filter,"nearest");var o=new y(r.imageData,r.width,r.height);o.flipY=!0,this.tex=o;for(var a=r.imageData.length,s=new Uint8Array(a),c=0;c<a;c+=4){var u=c/4;s[c]=u>>16&255,s[c+1]=u>>8&255,s[c+2]=255&u}var h=new y(s,r.width,r.height);h.flipY=!0,h.minFilter=Ph,h.magFilter=Ph,this.pickingTex=h,this.addUniforms({map:{value:o},pickingMap:{value:h},mapSize:{value:new l(r.width,r.height)}}),this.geometry.addAttribute("uv",new St(zy,2))}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{filter:{updateShader:!0,uniform:!0}},t.prototype.parameters)},e.prototype.getDefines=function(e){var i=t.prototype.getDefines.call(this,e);return this.filter.startsWith("cubic")&&(i.CUBIC_INTERPOLATION=1,this.filter.endsWith("bspline")?i.BSPLINE_FILTER=1:this.filter.endsWith("catmulrom")?i.CATMULROM_FILTER=1:this.filter.endsWith("mitchell")&&(i.MITCHELL_FILTER=1)),i},e.prototype.updateTexture=function(){var t=this.tex;this.filter.startsWith("cubic")?(t.minFilter=Ph,t.magFilter=Ph):"linear"===this.filter?(t.minFilter=Ch,t.magFilter=Ch):(t.minFilter=Ph,t.magFilter=Ph),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},e.prototype.makeMaterial=function(){t.prototype.makeMaterial.call(this),this.updateTexture();var e=this.material;e.uniforms.map.value=this.tex,e.blending=Ou,e.needsUpdate=!0;var i=this.wireframeMaterial;i.uniforms.map.value=this.tex,i.blending=Ou,i.needsUpdate=!0;var r=this.pickingMaterial;r.uniforms.map.value=this.tex,r.uniforms.pickingMap.value=this.pickingTex,r.blending=Ou,r.needsUpdate=!0},e.prototype.setUniforms=function(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),t.prototype.setUniforms.call(this,e)},i.vertexShader.get=function(){return"Image.vert"},i.fragmentShader.get=function(){return"Image.frag"},Object.defineProperties(e.prototype,i),e}(Bv),jy=function(t,e){var i=e||{};this.dimension=gn(i.dimension,"x"),this.positionType=gn(i.positionType,"percent"),this.position=gn(i.position,30),this.thresholdType=gn(i.thresholdType,"sigma"),this.thresholdMin=gn(i.thresholdMin,-1/0),this.thresholdMax=gn(i.thresholdMax,1/0),this.normalize=gn(i.normalize,!1),this.volume=t};jy.prototype.getPositionFromCoordinate=function(t){var e,i=this.dimension,r=this.volume,n=r.matrix,o=(new g).setFromMatrixPosition(n)[i],a=(new g).setFromMatrixScale(n)[i];return e="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-o)/(e/100)+1)/a)},jy.prototype.getData=function(t){function e(t){return Math.round(t/100*(o-1))}function i(t,e,i,r){return 3*(i*a.ny*a.nx+e*a.nx+t)+r}function r(t,e,i,r){m.set(t,e,i).applyMatrix4(c).toArray(f,r)}var n=this;t=t||{};var o,a=this.volume,s=a.data,c=a.matrix;o="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var u,h,l,p,d,f=new Float32Array(12),m=new g,v=0,y=0,b=0,x=a.nx,_=a.ny,w=a.nz;"x"===this.dimension?(l=e(a.nx),p=a.ny-1,d=a.nz-1,u=a.nz,h=a.ny,x=(v=l)+1,r(l,0,0,0),r(l,p,0,3),r(l,0,d,6),r(l,p,d,9)):"y"===this.dimension?(l=a.nx-1,p=e(a.ny),d=a.nz-1,u=a.nz,h=a.nx,_=(y=p)+1,r(0,p,0,0),r(l,p,0,3),r(0,p,d,6),r(l,p,d,9)):"z"===this.dimension&&(l=a.nx-1,p=a.ny-1,d=e(a.nz),u=a.nx,h=a.ny,w=(b=d)+1,r(0,0,d,0),r(0,p,d,3),r(l,0,d,6),r(l,p,d,9));var S,A,M=0,P=0,T=new Uint8Array(u*h*4),E=new Float32Array(u*h);"sigma"===this.thresholdType?(S=a.getValueForSigma(this.thresholdMin),A=a.getValueForSigma(this.thresholdMax)):(S=this.thresholdMin,A=this.thresholdMax);var C=Object.assign({},t.colorParams,{volume:a});this.normalize&&(C.domain=[0,1]);var I,R,L,O=lf.getScheme(C),D=new Float32Array(3),N=O.getScale();if(this.normalize){I=1/0,R=-1/0;for(var k=y;k<_;++k)for(var F=v;F<x;++F)for(var B=b;B<w;++B){var z=s[i(F,k,B,0)/3];z<I&&(I=z),z>R&&(R=z)}L=R-I}for(var U=y;U<_;++U)for(var j=v;j<x;++j)for(var G=b;G<w;++G){var V=i(j,U,G,0)/3,$=s[V];n.normalize&&($=($-I)/L),O.colorToArray(N($),D),T[M]=Math.round(255*D[0]),T[M+1]=Math.round(255*D[1]),T[M+2]=Math.round(255*D[2]),T[M+3]=$>S&&$<A?255:0,E[P]=V,++P,M+=4}var H=new lg(E,a);return{position:f,imageData:T,width:u,height:h,picking:H}};var Gy=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="slice",this.parameters=Object.assign({filter:{type:"select",buffer:!0,options:{nearest:"nearest",linear:"linear","cubic-bspline":"cubic-bspline","cubic-catmulrom":"cubic-catmulrom","cubic-mitchell":"cubic-mitchell"}},positionType:{type:"select",rebuild:!0,options:{percent:"percent",coordinate:"coordinate"}},position:{type:"range",step:.1,max:100,min:1,rebuild:!0},dimension:{type:"select",rebuild:!0,options:{x:"x",y:"y",z:"z"}},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},normalize:{type:"boolean",rebuild:!0}},this.parameters,{flatShaded:null,side:null,wireframe:null,linewidth:null,colorScheme:null,roughness:null,metalness:null,diffuse:null}),this.volume=e,this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=this.volume,r=e||{};r.colorDomain=gn(r.colorDomain,[i.min,i.max]),r.colorScheme=gn(r.colorScheme,"value"),r.colorScale=gn(r.colorScale,"Spectral"),this.colorScheme="value",this.dimension=gn(r.dimension,"x"),this.filter=gn(r.filter,"cubic-bspline"),this.positionType=gn(r.positionType,"percent"),this.position=gn(r.position,30),this.thresholdType=gn(r.thresholdType,"sigma"),this.thresholdMin=gn(r.thresholdMin,-1/0),this.thresholdMax=gn(r.thresholdMax,1/0),this.normalize=gn(r.normalize,!1),t.prototype.init.call(this,r),this.build()},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.create=function(){var t=new jy(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 Uy(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)},e}(Cy),Vy=function(t){function e(e,i,r){var n=r||{};if(t.call(this,e,i,n),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:ga.types},radius:{type:"number",precision:3,max:10,min:.001},scale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new Kd(n.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){var o={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach(function(t){o[t]=t}),this.parameters.assembly={type:"select",options:o,rebuild:!0}}else this.parameters.assembly=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={defaultScale:{}};return i.defaultScale.get=function(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}},e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"element"),this.radius=gn(i.radius,"vdw"),this.scale=gn(i.scale,1),this.assembly=gn(i.assembly,"default"),this.defaultAssembly=gn(i.defaultAssembly,""),"auto"===i.quality&&(i.quality=this.getQuality()),t.prototype.init.call(this,i),this.selection.signals.stringChanged.add(function(){this.build()},this),this.build()},e.prototype.getAssembly=function(){var t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]},e.prototype.getQuality=function(){var t,e=this.structureView,i=this.getAssembly();return t=i?i.getAtomCount(e):e.atomCount,of&&(t*=4),e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=this.getAssembly();if(t)t.partList.forEach(function(t,e){var i=t.getView(this.structureView);if(0!==i.atomCount){var r=this.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),this.dataList.push(r))}},this);else{var e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}},e.prototype.createData=function(){console.error("createData not implemented")},e.prototype.update=function(t){if(this.lazy&&!this.visible)return void Object.assign(this.lazyProps.what,t);this.dataList.forEach(function(e){e.bufferList.length>0&&this.updateData(t,e)},this)},e.prototype.updateData=function(){this.build()},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.structure=this.structure,e},e.prototype.getAtomParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},e.prototype.getBondParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},e.prototype.setSelection=function(t,e){return this.selection.setString(t,e),this},e.prototype.setParameters=function(e,i,r){return i=i||{},e&&void 0!==e.radiusType&&("size"===e.radiusType?this.radius=1:this.radius=e.radiusType,delete e.radiusType,i.radius=!0,sf&&!this.disableImpostor||(r=!0)),e&&void 0!==e.radius&&(i.radius=!0,sf&&!this.disableImpostor||(r=!0)),e&&void 0!==e.scale&&(i.radius=!0,sf&&!this.disableImpostor||(r=!0)),e&&void 0!==e.defaultAssembly&&(r=!0),t.prototype.setParameters.call(this,e,i,r),this},e.prototype.getParameters=function(){return Object.assign(t.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},e.prototype.attach=function(t){var 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()},e.prototype.clear=function(){this.dataList.length=0,t.prototype.clear.call(this)},e.prototype.dispose=function(){this.structureView.dispose(),delete this.structure,delete this.structureView,t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,i),e}(Cy),$y=function(t){function e(e,i){var r=4*(e.position1.length/3);t.call(this,{position:new Float32Array(3*r),color:new Float32Array(3*r)},i),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s=this.geometry.attributes;t.position1&&t.position2&&(e=t.position1,i=t.position2,o=s.position.array,s.position.needsUpdate=!0),t.color&&t.color2&&(r=t.color,n=t.color2,a=s.color.array,s.color.needsUpdate=!0);for(var c,u,h,l,p,d,f,m,g,v,y,b=this.size,x=0;x<b;x++)u=3*x,c=4*x*3,e&&i&&(d=e[u],f=e[u+1],m=e[u+2],h=(d+(g=i[u]))/2,l=(f+(v=i[u+1]))/2,p=(m+(y=i[u+2]))/2,o[c]=d,o[c+1]=f,o[c+2]=m,o[c+3]=h,o[c+4]=l,o[c+5]=p,o[c+6]=h,o[c+7]=l,o[c+8]=p,o[c+9]=g,o[c+10]=v,o[c+11]=y),r&&n&&(a[c]=a[c+3]=r[u],a[c+1]=a[c+4]=r[u+1],a[c+2]=a[c+5]=r[u+2],a[c+6]=a[c+9]=n[u],a[c+7]=a[c+10]=n[u+1],a[c+8]=a[c+11]=n[u+2])},i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(Bv),Hy=function(t){function e(e,i,r){t.call(this,e.structure,i,r),this.type="trajectory",this.parameters=Object.assign({drawLine:{type:"boolean",rebuild:!0},drawCylinder:{type:"boolean",rebuild:!0},drawPoint:{type:"boolean",rebuild:!0},drawSphere:{type:"boolean",rebuild:!0},linewidth:{type:"integer",max:20,min:1,rebuild:!0},pointSize:{type:"integer",max:20,min:1,rebuild:!0},sizeAttenuation:{type:"boolean",rebuild:!0},sort:{type:"boolean",rebuild:!0}},this.parameters),this.manualAttach=!0,this.trajectory=e,this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"uniform"),i.colorValue=gn(i.colorValue,14540253),this.drawLine=gn(i.drawLine,!0),this.drawCylinder=gn(i.drawCylinder,!1),this.drawPoint=gn(i.drawPoint,!1),this.drawSphere=gn(i.drawSphere,!1),this.pointSize=gn(i.pointSize,1),this.sizeAttenuation=gn(i.sizeAttenuation,!1),this.sort=gn(i.sort,!0),t.prototype.init.call(this,i)},e.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},e.prototype.prepare=function(t){t()},e.prototype.create=function(){if(0!==this.atomSet.atomCount){var t=this,e=this.atomSet.atoms[0].index;this.trajectory.getPath(e,function(e){var i=e.length/3,r=new tt(t.colorValue);if(t.drawSphere){var n=new Kv({position:e,color:To(i,r.r,r.g,r.b),radius:Po(i,.2)},t.getBufferParams({sphereDetail:t.sphereDetail,dullInterior:!0,disableImpostor:t.disableImpostor}));t.bufferList.push(n)}if(t.drawCylinder){var o=new py({position1:e.subarray(0,-3),position2:e.subarray(3),color:To(i-1,r.r,r.g,r.b),color2:To(i-1,r.r,r.g,r.b),radius:Po(i,.05)},t.getBufferParams({openEnded:!1,radialSegments:t.radialSegments,disableImpostor:t.disableImpostor,dullInterior:!0}));t.bufferList.push(o)}if(t.drawPoint){var a=new ky({position:e,color:To(i,r.r,r.g,r.b)},t.getBufferParams({pointSize:t.pointSize,sizeAttenuation:t.sizeAttenuation,sort:t.sort}));t.bufferList.push(a)}if(t.drawLine){var s=new $y({position1:e.subarray(0,-3),position2:e.subarray(3),color:To(i-1,r.r,r.g,r.b),color2:To(i-1,r.r,r.g,r.b)},t.getBufferParams());t.bufferList.push(s)}t.attach()})}},e}(Vy),Wy=0,Xy=new v,qy=new g,Yy=function(t,e){Object.defineProperty(this,"id",{value:Wy++});var i=e||{};this.name=i.name,this.uuid=Xn(),this.visible=void 0===i.visible||i.visible,this.signals={representationAdded:new oo,representationRemoved:new oo,visibilityChanged:new oo,matrixChanged:new oo,statusChanged:new oo,nameChanged:new oo,disposed:new oo},this.stage=t,this.viewer=t.viewer,this.reprList=[],this.annotationList=[],this.matrix=new v,this.position=new g,this.quaternion=new m,this.scale=new g(1,1,1),this.transform=new v,this.controls=new Hm(this)},Zy={type:{}};Zy.type.get=function(){return"component"},Yy.prototype.setPosition=function(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this},Yy.prototype.setRotation=function(t){if(Array.isArray(t))if(3===t.length){var e=(new ft).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof ft?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this},Yy.prototype.setScale=function(t){return this.scale.set(t,t,t),this.updateMatrix(),this},Yy.prototype.setTransform=function(t){return this.transform.copy(t),this.updateMatrix(),this},Yy.prototype.updateMatrix=function(){var t=this,e=this.getCenterUntransformed(qy);this.matrix.makeTranslation(-e.x,-e.y,-e.z),Xy.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(Xy),Xy.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(Xy);var i=this.position;Xy.makeTranslation(i.x+e.x,i.y+e.y,i.z+e.z),this.matrix.premultiply(Xy),this.matrix.premultiply(this.transform),this.reprList.forEach(function(e){e.setParameters({matrix:t.matrix})}),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)},Yy.prototype.addAnnotation=function(t,e,i){var r=new jm(this,t,e,i);return this.annotationList.push(r),r},Yy.prototype.removeAnnotation=function(t){var e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())},Yy.prototype.removeAllAnnotations=function(){this.annotationList.forEach(function(t){t.dispose()}),this.annotationList.length=0},Yy.prototype.addRepresentation=function(t,e,i){var r=i||{},n=this.stage.getParameters();r.matrix=this.matrix.clone(),r.quality=r.quality||n.quality,r.disableImpostor=gn(r.disableImpostor,!n.impostor),r.useWorker=gn(r.useWorker,n.workerDefault),r.visible=gn(r.visible,!0);var o=Object.assign({},r,{visible:this.visible&&r.visible}),a=Ts(t,e,this.viewer,o),s=this.__getRepresentationComponent(a,r);return this.reprList.push(s),this.signals.representationAdded.dispatch(s),s},Yy.prototype.addBufferRepresentation=function(t,e){return Yy.prototype.addRepresentation.call(this,"buffer",t,e)},Yy.prototype.hasRepresentation=function(t){return-1!==this.reprList.indexOf(t)},Yy.prototype.removeRepresentation=function(t){var e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))},Yy.prototype.updateRepresentations=function(t){this.reprList.forEach(function(e){e.update(t)}),this.stage.viewer.requestRender()},Yy.prototype.removeAllRepresentations=function(){this.reprList.slice(0).forEach(function(t){t.dispose()})},Yy.prototype.dispose=function(){this.removeAllAnnotations(),this.removeAllRepresentations(),delete this.annotationList,delete this.reprList,this.signals.disposed.dispatch()},Yy.prototype.setVisibility=function(t){return this.visible=t,this.eachRepresentation(function(t){t.updateVisibility()}),this.annotationList.forEach(function(t){t.updateVisibility()}),this.signals.visibilityChanged.dispatch(t),this},Yy.prototype.setStatus=function(t){return this.status=t,this.signals.statusChanged.dispatch(t),this},Yy.prototype.setName=function(t){return this.name=t,this.signals.nameChanged.dispatch(t),this},Yy.prototype.getBox=function(){return(t=this).getBoxUntransformed.apply(t,arguments).clone().applyMatrix4(this.matrix);var t},Yy.prototype.getCenter=function(){return(t=this).getCenterUntransformed.apply(t,arguments).clone().applyMatrix4(this.matrix);var t},Yy.prototype.getZoom=function(){return this.stage.getZoomForBox((t=this).getBox.apply(t,arguments));var t},Yy.prototype.getBoxUntransformed=function(){},Yy.prototype.getCenterUntransformed=function(){return this.getBoxUntransformed().getCenter()},Yy.prototype.autoView=function(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),gn(t,0))},Yy.prototype.eachRepresentation=function(t){this.reprList.forEach(t)},Object.defineProperties(Yy.prototype,Zy),Yy.prototype.__getRepresentationComponent=function(t,e){return new Ky(this.stage,t,e,this)};var Ky=function(t){function e(e,i,r,n){var o=r||{};o.name=gn(o.name,i.type),t.call(this,e,o),this.signals=Object.assign(this.signals,{parametersChanged:new oo}),this.parent=n,this.setRepresentation(i)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"representation"},e.prototype.getType=function(){return this.repr.type},e.prototype.setRepresentation=function(t){this.disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()},e.prototype.addRepresentation=function(){},e.prototype.removeRepresentation=function(){},e.prototype.hasRepresentation=function(){},e.prototype.disposeRepresentation=function(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())},e.prototype.dispose=function(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this.disposeRepresentation(),this.signals.disposed.dispatch())},e.prototype.setVisibility=function(t){return this.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.visible),this},e.prototype.getVisibility=function(){return this.parent?this.parent.visible&&this.visible:this.visible},e.prototype.toggleVisibility=function(){return this.setVisibility(!this.visible)},e.prototype.updateVisibility=function(){this.repr.setVisibility(this.getVisibility())},e.prototype.update=function(t){return this.repr.update(t),this},e.prototype.build=function(t){return this.repr.build(t),this},e.prototype.setSelection=function(t){return this.repr.setSelection(t),this},e.prototype.setParameters=function(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this},e.prototype.getParameters=function(){return this.repr.getParameters()},e.prototype.setColor=function(t){return this.repr.setColor(t),this},e.prototype.getCenter=function(){},e.prototype.getZoom=function(){},e.prototype.getBox=function(){},Object.defineProperties(e.prototype,i),e}(Yy),Qy=function(t){var e=this;this.list=t||[];for(var i=this.list.length,r=0;r<i;++r)e.list[r].signals.disposed.add(e._remove,e)};Qy.prototype._remove=function(t){var e=this.list.indexOf(t);-1!==e&&this.list.splice(e,1)},Qy.prototype._invoke=function(t,e){for(var i=this,r=this.list.length,n=0;n<r;++n){var o=i.list[n],a=o[t];"function"==typeof a&&a.apply(o,e)}return this},Qy.prototype.setVisibility=function(t){return this._invoke("setVisibility",[t])},Qy.prototype.setSelection=function(t){return this._invoke("setSelection",[t])},Qy.prototype.dispose=function(){return this._invoke("dispose")};var Jy=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.addRepresentation=function(t,e){return this._invoke("addRepresentation",[t,e])},e.prototype.autoView=function(t){return this._invoke("autoView",[t])},e}(Qy),tb=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setParameters=function(t){return this._invoke("setParameters",[t])},e.prototype.setColor=function(t){return this._invoke("setColor",[t])},e}(Qy),eb=new g,ib=function(t,e){if(this.signals={parametersChanged:new oo,fullscreenChanged:new oo,componentAdded:new oo,componentRemoved:new oo,clicked:new oo,hovered:new oo},this.tasks=new Of,this.compList=[],this.defaultFileParams={},this.viewer=new Ho(t),this.viewer.renderer){this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:2+(parseInt(this.viewer.container.style.zIndex)||0),pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),document.body.appendChild(this.tooltip),this.mouseObserver=new Kf(this.viewer.renderer.domElement),this.viewerControls=new bm(this),this.trackballControls=new am(this),this.pickingControls=new hm(this),this.animationControls=new Lm(this),this.mouseControls=new km(this),this.pickingBehavior=new Fm(this),this.mouseBehavior=new Bm(this),this.animationBehavior=new zm(this),this.keyBehavior=new Um(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);var i=Object.assign({impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,fogNear:50,fogFar:100,cameraFov:40,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"},e);this.parameters={backgroundColor:{type:"color"},quality:{type:"select",options:{auto:"auto",low:"low",medium:"medium",high:"high"}},sampleLevel:{type:"range",step:1,max:5,min:-1},impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:{type:"number",precision:1,max:10,min:0},zoomSpeed:{type:"number",precision:1,max:10,min:0},panSpeed:{type:"number",precision:1,max:10,min:0},clipNear:{type:"range",step:1,max:100,min:0},clipFar:{type:"range",step:1,max:100,min:0},clipDist:{type:"integer",max:200,min:0},fogNear:{type:"range",step:1,max:100,min:0},fogFar:{type:"range",step:1,max:100,min:0},cameraType:{type:"select",options:{perspective:"perspective",orthographic:"orthographic"}},cameraFov:{type:"range",step:1,max:120,min:15},lightColor:{type:"color"},lightIntensity:{type:"number",precision:2,max:10,min:0},ambientColor:{type:"color"},ambientIntensity:{type:"number",precision:2,max:10,min:0},hoverTimeout:{type:"integer",max:1e4,min:-1},tooltip:{type:"boolean"},mousePreset:{type:"select",options:{default:"default",pymol:"pymol",coot:"coot"}}},this.setParameters(i),this.viewer.animate()}};ib.prototype.setParameters=function(t){var e=Object.assign({},t),i=this.parameters,r=this.viewer,n=this.trackballControls;for(var o in e)void 0!==e[o]&&i[o]&&(i[o].int&&(e[o]=parseInt(e[o])),i[o].float&&(e[o]=parseFloat(e[o])),i[o].value=e[o]);return void 0!==e.quality&&this.setQuality(e.quality),void 0!==e.impostor&&this.setImpostor(e.impostor),void 0!==e.rotateSpeed&&(n.rotateSpeed=e.rotateSpeed),void 0!==e.zoomSpeed&&(n.zoomSpeed=e.zoomSpeed),void 0!==e.panSpeed&&(n.panSpeed=e.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(e.mousePreset),this.mouseObserver.setParameters({hoverTimeout:e.hoverTimeout}),r.setClip(e.clipNear,e.clipFar,e.clipDist),r.setFog(void 0,e.fogNear,e.fogFar),r.setCamera(e.cameraType,e.cameraFov),r.setSampling(e.sampleLevel),r.setBackground(e.backgroundColor),r.setLight(e.lightColor,e.lightIntensity,e.ambientColor,e.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this},ib.prototype.getParameters=function(){var t=this,e={};for(var i in t.parameters)e[i]=t.parameters[i].value;return e},ib.prototype.defaultFileRepresentation=function(e){if("structure"===e.type){e.setSelection("/0");var i,r,n,o=e.structure;if(o.biomolDict.BU1){var a=o.biomolDict.BU1;i=a.getAtomCount(o),r=a.getResidueCount(o),n=a.getInstanceCount(),e.setDefaultAssembly("BU1")}else i=o.getModelProxy(0).atomCount,r=o.getModelProxy(0).residueCount,n=1;var s=i;of&&(s*=4);var c=o.atomStore.count/o.residueStore.count<2;c&&(s*=10);var u="chainname",h="RdYlBu",l=!1;if(1===o.getChainnameCount("polymer and /0")&&(u="residueindex",h="spectral",l=!0),t.Debug&&console.log(s,i,n,c),r/n<4)e.addRepresentation("ball+stick",{colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(n>5&&s>15e3||s>7e5){var p=Math.min(1.5,Math.max(.1,2e3/(s/n)));c&&(p=Math.min(p,.15)),e.addRepresentation("surface",{sele:"polymer",surfaceType:"sas",probeRadius:1.4,scaleFactor:p,colorScheme:u,colorScale:h,colorReverse:l,useWorker:!1})}else s>25e4?e.addRepresentation("backbone",{lineOnly:!0,colorScheme:u,colorScale:h,colorReverse:l}):s>1e5?e.addRepresentation("backbone",{quality:"low",disableImpostor:!0,colorScheme:u,colorScale:h,colorReverse:l,scale:2}):s>8e4?e.addRepresentation("backbone",{colorScheme:u,colorScale:h,colorReverse:l,scale:2}):(e.addRepresentation("cartoon",{colorScheme:u,colorScale:h,colorReverse:l,scale:.7,aspectRatio:5,quality:"auto"}),s<5e4&&e.addRepresentation("base",{colorScheme:u,colorScale:h,colorReverse:l,quality:"auto"}),e.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));e.structure.frames.length&&e.addTrajectory()}else"surface"!==e.type&&"volume"!==e.type||e.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},ib.prototype.loadFile=function(t,e){var i=Object.assign({},this.defaultFileParams,e),r=new Yy(this,i);r.name=_n(t).name,this.addComponent(r);var n=this.tasks;n.increment();var o=function(t){return this.removeComponent(r),r=this.addComponentFromObject(t,i),"script"===r.type?r.run():i.defaultRepresentation&&this.defaultFileRepresentation(r),n.decrement(),r}.bind(this),a=function(t){throw r.setStatus(t),n.decrement(),t};return("dcd"===gn(i.ext,_n(t).ext)?Promise.reject(new Error("loadFile: ext 'dcd' must be loaded into a structure component")):mo(t,i)).then(o,a)},ib.prototype.addComponent=function(t){if(!t)return void cf.warn("Stage.addComponent: no component given");this.compList.push(t),this.signals.componentAdded.dispatch(t)},ib.prototype.addComponentFromObject=function(t,e){var i=vf.get(t.type);if(i){var r=new i(this,t,e);return this.addComponent(r),r}cf.warn("no component for object type",t.type)},ib.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},ib.prototype.removeAllComponents=function(t){this.compList.slice().forEach(function(e){t&&e.type!==t||this.removeComponent(e)},this)},ib.prototype.handleResize=function(){this.viewer.handleResize()},ib.prototype.setSize=function(t,e){var i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())},ib.prototype.toggleFullscreen=function(t){function e(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function i(){if(!e()&&r.lastFullscreenElement){var t=r.lastFullscreenElement;t.style.width=t.dataset.normalWidth,t.style.height=t.dataset.normalHeight,document.removeEventListener("fullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i),r.handleResize(),r.signals.fullscreenChanged.dispatch(!1)}}if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void cf.log("fullscreen mode (currently) not possible");var r=this;t=t||this.viewer.container,this.lastFullscreenElement=t,e()?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",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout(function(){r.handleResize()},100))},ib.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},ib.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},ib.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},ib.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},ib.prototype.setFocus=function(t){var e=Zn(t/2,0,49.9),i=100-e,r=(i-e)/2;this.setParameters({clipNear:e,clipFar:i,fogNear:Kn(i-r),fogFar:Kn(i+r)})},ib.prototype.getZoomForBox=function(t){var e=t.getSize(eb),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z),n=i+Math.sqrt(r),o=Hn(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=a/s,u=s<a?1:c;return n=Math.abs(.5*n/u/Math.sin(o/2)),-(n+=this.parameters.clipDist.value)},ib.prototype.getBox=function(){return this.viewer.boundingBox},ib.prototype.getZoom=function(){return this.getZoomForBox(this.getBox())},ib.prototype.getCenter=function(t){return this.getBox().getCenter(t)},ib.prototype.autoView=function(t){this.animationControls.zoomMove(this.getCenter(),this.getZoom(),gn(t,0))},ib.prototype.makeImage=function(t){var e=this.viewer,i=this.tasks;return new Promise(function(r,n){function o(){i.increment(),e.makeImage(t).then(function(t){i.decrement(),r(t)}).catch(function(t){i.decrement(),n(t)})}i.onZeroOnce(o)})},ib.prototype.setImpostor=function(t){this.parameters.impostor.value=t;var e=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(i){if("script"!==i.type&&e.includes(i.getType())){var r=i.getParameters();r.disableImpostor=!t,i.build(r)}})},ib.prototype.setQuality=function(t){this.parameters.quality.value=t;var e=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(r){if("script"!==r.type){var n=r.getParameters();if(!e.includes(r.getType())){if(!i.includes(r.getType()))return;if(!n.disableImpostor)return void(r.repr.quality=t)}n.quality=t,r.build(n)}})},ib.prototype.eachComponent=function(t,e){this.compList.slice().forEach(function(i,r){e&&i.type!==e||t(i,r)})},ib.prototype.eachRepresentation=function(t,e){this.eachComponent(function(e){e.reprList.slice().forEach(function(i){t(i,e)})},e)},ib.prototype.getComponentsByName=function(t,e){var i=[];return this.eachComponent(function(e){(void 0===t||Es(t,e))&&i.push(e)},e),new Jy(i)},ib.prototype.getComponentsByObject=function(t){var e=[];return this.eachComponent(function(i){i[i.type]===t&&e.push(i)}),new Jy(e)},ib.prototype.getRepresentationsByName=function(t,e){var i,r;"object"!=typeof t||t instanceof RegExp?(i=void 0,r=t):(i=t.comp,r=t.repr);var n=[];return this.eachRepresentation(function(t,e){(void 0===i||Es(i,e))&&(void 0===r||Es(r,t))&&n.push(t)},e),new tb(n)},ib.prototype.getAnythingByName=function(t){var e=this.getComponentsByName(t).list,i=this.getRepresentationsByName(t).list;return new Qy(e.concat(i))},ib.prototype.dispose=function(){this.tasks.dispose()};var rb=[[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]],nb=[[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]],ob=function(){return{blosum62:Cs("ARNDCQEGHILKMFPSTWYVBZ?",nb),blosum62x:Cs("ACDEFGHIKLMNPQRSTVWY",rb)}}(),ab=function(t,e,i,r,n){this.seq1=t,this.seq2=e,this.gapPenalty=i||-10,this.gapExtensionPenalty=r||-1,this.substMatrix=n||"blosum62",this.substMatrix&&(this.substMatrix=ob[this.substMatrix])};ab.prototype.initMatrices=function(){var t=this;this.n=this.seq1.length,this.m=this.seq2.length,this.score=void 0,this.ali="",this.S=[],this.V=[],this.H=[];var e,i;for(e=0;e<=this.n;++e)for(t.S[e]=[],t.V[e]=[],t.H[e]=[],i=0;i<=this.m;++i)t.S[e][i]=0,t.V[e][i]=0,t.H[e][i]=0;for(e=0;e<=this.n;++e)t.S[e][0]=t.gap(0),t.H[e][0]=-1/0;for(i=0;i<=this.m;++i)t.S[0][i]=t.gap(0),t.V[0][i]=-1/0;this.S[0][0]=0},ab.prototype.gap=function(t){return this.gapPenalty+t*this.gapExtensionPenalty},ab.prototype.makeScoreFn=function(){var t,e,i=this.seq1,r=this.seq2,n=this.substMatrix;return n?function(o,a){t=i[o],e=r[a];try{return n[t][e]}catch(t){return-4}}:(cf.warn("Alignment: no subst matrix"),function(n,o){return t=i[n],e=r[o],t===e?5:-3})},ab.prototype.calc=function(){t.Debug&&cf.time("Alignment.calc"),this.initMatrices();var e,i,r,n,o,a,s,c=this.gap(0),u=this.makeScoreFn(),h=this.gapExtensionPenalty,l=this.V,p=this.H,d=this.S,f=this.n,m=this.m;for(a=1;a<=f;++a)for(i=d[a-1],e=l[a-1],r=l[a],n=p[a],o=d[a],s=1;s<=m;++s)r[s]=Math.max(i[s]+c,e[s]+h),n[s]=Math.max(o[s-1]+c,n[s-1]+h),o[s]=Math.max(i[s-1]+u(a-1,s-1),r[s],n[s]);t.Debug&&cf.timeEnd("Alignment.calc"),t.Debug&&cf.log(this.S,this.V,this.H)},ab.prototype.trace=function(){var e=this;t.Debug&&cf.time("Alignment.trace"),this.ali1="",this.ali2="";var i,r=this.makeScoreFn(),n=this.n,o=this.m;for(this.S[n][o]>=this.V[n][o]?(i="S",this.score=this.S[n][o]):this.V[n][o]>=this.H[n][o]?(i="V",this.score=this.V[n][o]):(i="H",this.score=this.H[n][o]),t.Debug&&cf.log("Alignment: SCORE",this.score),t.Debug&&cf.log("Alignment: S, V, H",this.S[n][o],this.V[n][o],this.H[n][o]);n>0&&o>0;)"S"===i?e.S[n][o]===e.S[n-1][o-1]+r(n-1,o-1)?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--n,--o,i="S"):e.S[n][o]===e.V[n][o]?i="V":e.S[n][o]===e.H[n][o]?i="H":(--n,--o):"V"===i?e.V[n][o]===e.V[n-1][o]+e.gapExtensionPenalty?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n,i="V"):e.V[n][o]===e.S[n-1][o]+e.gap(0)?(e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n,i="S"):--n:"H"===i?e.H[n][o]===e.H[n][o-1]+e.gapExtensionPenalty?(e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o,i="H"):e.H[n][o]===e.S[n][o-1]+e.gap(0)?(e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o,i="S"):--o:cf.error("Alignment: no matrix");for(;n>0;)e.ali1=e.seq1[n-1]+e.ali1,e.ali2="-"+e.ali2,--n;for(;o>0;)e.ali1="-"+e.ali1,e.ali2=e.seq2[o-1]+e.ali2,--o;t.Debug&&cf.timeEnd("Alignment.trace"),t.Debug&&cf.log([this.ali1,this.ali2])};var sb=function(t){function e(e){var i=this;t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=gn(e.reverse,!0)),this.scalePerModel={},this.structure.eachModel(function(t){i.domain=[t.atomOffset,t.atomEnd],i.scalePerModel[t.index]=i.getScale()})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.index)},e}(Dd);lf.add("atomindex",sb);var cb=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="OrRd"),!e.domain){var i,r=1/0,n=-1/0;e.sele&&(i=new Kd(e.sele)),this.structure.eachAtom(function(t){var e=t.bfactor;r=Math.min(r,e),n=Math.max(n,e)},i),this.domain=[r,n]}this.bfactorScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return this.bfactorScale(t.bfactor)},e}(Dd);lf.add("bfactor",cb);var ub=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var i={},r={};this.structure.eachModel(function(t){var e=0,n={};t.eachChain(function(t){void 0===n[t.chainid]&&(n[t.chainid]=e,e+=1)}),this.domain=[0,e-1],i[t.index]=n,r[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=i[t.modelIndex];return r[t.modelIndex](e[t.chainid])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("chainid",ub);var hb=function(t){function e(e){if(t.call(this,e),e.scale||(this.scale="Spectral"),e.domain){var i=this.getScale();this.atomColor=function(t){return i(t.chainIndex)}}else{var r={};this.structure.eachModel(function(t){this.domain=[t.chainOffset,t.chainEnd],r[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){return r[t.modelIndex](t.chainIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("chainindex",hb);var lb=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral");var i={},r={};this.structure.eachModel(function(t){var e=0,n={};t.eachChain(function(t){void 0===n[t.chainname]&&(n[t.chainname]=e,e+=1)}),this.domain=[0,e-1],i[t.index]=n,r[t.index]=this.getScale()}.bind(this)),this.atomColor=function(t){var e=i[t.modelIndex];return r[t.modelIndex](e[t.chainname])}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("chainname",lb);var pb=function(t){function e(e){t.call(this,e),e.scale||(this.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});var i=e.structure.validation||{};this.rsrzDict=i.rsrzDict||{},this.rsccDict=i.rsccDict||{}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.resno;t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);var r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192},e}(Dd);lf.add("densityfit",pb);var db={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}},fb=12,mb=1.04,gb=.25,vb=function(t){function e(e){function i(t){return t.isProtein()?db[t.resname]&&db[t.resname][t.atomname]||db.backbone[t.atomname]||0:0}t.call(this,e),e.scale||(this.scale="rwb"),e.domain||(this.domain=[-.5,0,.5]);var r=this.getScale(),n=this.structure,o=new Float32Array(n.atomCount),a=[],s=[];n.eachAtom(function(t){if(o[t.index]=i(t)*t.occupancy,"N"===t.atomname){var e=Rs(t);void 0!==e&&(a.push(e),s.push(gb*t.occupancy))}});var c=this.structure.getBoundingBox();c.expandByScalar(mb);var u=Ls(a),h=new Ba(u,c),l=new Ba(this.structure.atomStore,c),p=this.atomProxy,d=new g,f=fb*fb;this.positionColor=function(t){for(var e=0,i=l.within(t.x,t.y,t.z,fb),n=0;n<i.length;n++){var a=i[n],c=o[a];if(0!==c){p.index=a,d.x=t.x-p.x,d.y=t.y-p.y,d.z=t.z-p.z;var m=d.lengthSq();m<f&&(e+=c/m)}}for(var g=h.within(t.x,t.y,t.z,fb),v=0;v<g.length;v++){var y=g[v];d.x=t.x-u.x[y],d.y=t.y-u.y[y],d.z=t.z-u.z[y];var b=d.lengthSq();b<f&&(e+=s[y]/b)}return r(e)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("electrostatic",vb);var yb={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},bb=function(t){function e(e){var i=e||{};i.value=gn(i.value,yb.C),t.call(this,i)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.element;return"C"===e?this.value:yb[e]||16777215},e}(Dd);lf.add("element",bb);var xb=function(t){function e(e){t.call(this,e),e.scale||(this.scale="Spectral"),e.domain||(this.domain=[0,this.structure.entityList.length-1]);var i=this.getScale();this.atomColor=function(t){return i(t.entityIndex)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("entityindex",xb);var _b=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.entity;switch(e?e.entityType:void 0){case fg:return 8374655;case mg:return 16629894;case gg:return 12496596;case vg:return 3697840;default:return 16777113}},e}(Dd);lf.add("entitytype",_b);var wb=function(t){function e(e){t.call(this,e);var i=e.structure.validation||{};this.geoAtomDict=i.geoAtomDict||{},this.geoDict=i.geoDict||{}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.resno;t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var i,r=this.geoAtomDict[e];return i=void 0!==r?qn(r[t.atomname]||0):this.geoDict[e]||0,0===i?2188972:1===i?16703627:2===i?16018755:i>=3?10813478:9474192},e}(Dd);lf.add("geoquality",wb);var Sb=function(t){function e(e){t.call(this,e),e.scale||(this.scale="RdYlGn");var i,r={};for(i in Ig)r[i]=Ig[i][0];if(!e.domain){var n,o=1/0,a=-1/0;for(i in r)n=r[i],o=Math.min(o,n),a=Math.max(a,n);this.domain=[o,0,a]}var s=this.getScale();this.atomColor=function(t){return s(r[t.resname]||Rg)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("hydrophobicity",Sb);var Ab=function(t){function e(e){t.call(this,e),e.scale||(this.scale="rainbow"),e.domain||(this.domain=[0,this.structure.modelStore.count]);var i=this.getScale();this.atomColor=function(t){return i(t.modelIndex)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("modelindex",Ab);var Mb=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(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}},e}(Dd);lf.add("moleculetype",Mb);var Pb=function(t){function e(e){t.call(this,e),e.scale||(this.scale="PuBu"),e.domain||(this.domain=[0,1]);var i=this.getScale();this.atomColor=function(t){return i(t.occupancy)}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("occupancy",Pb);var Tb=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return Os()},e.prototype.volumeColor=function(){return Os()},e.prototype.positionColor=function(){return Os()},e}(Dd);lf.add("random",Tb);var Eb=function(t){function e(e){var i=this;if(t.call(this,e),e.scale||(this.scale="rainbow",this.reverse=gn(e.reverse,!0)),e.domain){var r=this.getScale();this.atomColor=function(t){return r(t.residueIndex)}}else{var n={};this.structure.eachChain(function(t){i.domain=[t.residueOffset,t.residueEnd],n[t.index]=i.getScale()}),this.atomColor=function(t){return n[t.chainIndex](t.residueIndex)}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Dd);lf.add("residueindex",Eb);var Cb={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:10526975,G:16740464,I:8454143,C:16747595,T:10551200,U:16744576,DA:10526975,DG:16740464,DI:8454143,DC:16747595,DT:10551200,DU:16744576},Ib=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){return Cb[t.resname]||16711935},e}(Dd);lf.add("resname",Ib);var Rb={alphaHelix:16711808,threeTenHelix:10485888,piHelix:6291584,betaStrand:16762880,betaTurn:6324479,coil:16777215,dna:11403518,rna:16580962,carbohydrate:10921722},Lb=function(t){function e(e){t.call(this,e),this.rp=this.structure.getResidueProxy()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(t){var e=t.sstruc,i=this.rp;return"h"===e?Rb.alphaHelix:"g"===e?Rb.threeTenHelix:"i"===e?Rb.piHelix:"e"===e||"b"===e?Rb.betaStrand:"t"===e?Rb.betaTurn:(i.index=t.residueIndex,i.isDna()?Rb.dna:i.isRna()?Rb.rna:i.isSaccharide()?Rb.carbohydrate:i.isProtein()||"s"===e||"l"===e?Rb.coil:8421504)},e}(Dd);lf.add("sstruc",Lb);var Ob=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.atomColor=function(){return this.value},e.prototype.bondColor=function(){return this.value},e.prototype.valueColor=function(){return this.value},e.prototype.volumeColor=function(){return this.value},e}(Dd);lf.add("uniform",Ob);var Db=function(t){function e(e){t.call(this,e),this.valueScale=this.getScale()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.volumeColor=function(t){return this.valueScale(this.volume.data[t])},e}(Dd);lf.add("value",Db);var Nb=function(t){function e(e){t.call(this,e);var i=this.volume;if(i&&i.inverseMatrix){var r=this.getScale(),n=i.inverseMatrix,o=i.data,a=i.nx,s=i.ny,c=a*s,u=new g;this.positionColor=function(t){u.copy(t),u.applyMatrix4(n);var e=Math.floor(u.x),i=Math.floor(u.y),h=Math.floor(u.z),l=(h*s+i)*a+e,p=l+1,d=l+a,f=l+c,m=d+1,g=f+1,v=d+c,y=v+1,b=o[l],x=o[p],_=o[d],w=o[f],S=o[m],A=o[g],M=o[v],P=o[y],T=u.x-e,E=u.y-i,C=u.z-h,I=Jn(b,x,T),R=Jn(w,A,T),L=Jn(_,S,T),O=Jn(M,P,T),D=Jn(Jn(I,L,E),Jn(R,O,E),C);return r(D)}}else{var h=this.value;this.positionColor=function(){return h}}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.positionColor=function(){},e}(Dd);lf.add("volume",Nb);var kb=function(t){function e(e,i,r){var n=this,o=r||{};o.name=gn(o.name,i.name),t.call(this,e,o),this.script=i,this.status="loaded",this.script.signals.nameChanged.add(function(t){n.setName(t)})}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"script"},e.prototype.addRepresentation=function(){},e.prototype.removeRepresentation=function(){},e.prototype.run=function(){var t=this;this.setStatus("running"),this.script.call(this.stage).then(function(){t.setStatus("finished")}),this.setStatus("called")},e.prototype.dispose=function(){this.signals.disposed.dispatch()},e.prototype.setVisibility=function(){},e.prototype.getCenter=function(){},e.prototype.getZoom=function(){},e.prototype.getBox=function(){},Object.defineProperties(e.prototype,i),e}(Yy);vf.add("script",kb);var Fb=function(t){function e(e,i,r){var n=r||{};n.name=gn(n.name,i.name),t.call(this,e,n),this.shape=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"shape"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.shape,i)},e.prototype.getBoxUntransformed=function(){return this.shape.boundingBox},e.prototype.getCenterUntransformed=function(){return this.shape.center},e.prototype.dispose=function(){this.shape.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,i),e}(Yy);vf.add("shape",Fb);var Bb=function(t){function e(e,i,r,n){var o=this,a=r||{};a.name=gn(a.name,i.name),t.call(this,e,a),this.signals=Object.assign(this.signals,{frameChanged:new oo,playerChanged:new oo,gotNumframes:new oo,parametersChanged:new oo}),this.trajectory=i,this.parent=n,this.status="loaded",this.defaultStep=gn(a.defaultStep,void 0),this.defaultTimeout=gn(a.defaultTimeout,50),this.defaultInterpolateType=gn(a.defaultInterpolateType,""),this.defaultInterpolateStep=gn(a.defaultInterpolateStep,5),this.defaultMode=gn(a.defaultMode,"loop"),this.defaultDirection=gn(a.defaultDirection,"forward"),i.signals.frameChanged.add(function(t){o.signals.frameChanged.dispatch(t)}),i.signals.playerChanged.add(function(t){o.signals.playerChanged.dispatch(t)}),i.signals.gotNumframes.add(function(t){o.signals.gotNumframes.dispatch(t)}),void 0!==a.initialFrame&&this.setFrame(a.initialFrame)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"trajectory"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.trajectory,i)},e.prototype.setFrame=function(t){this.trajectory.setFrame(t)},e.prototype.setParameters=function(t){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)},e.prototype.dispose=function(){this.trajectory.dispose(),t.prototype.dispose.call(this)},e.prototype.getCenter=function(){},Object.defineProperties(e.prototype,i),e}(Yy),zb=function(t){function e(e,i,r){t.call(this,"",i,r),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this.getNumframes()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"frames"},e.prototype.makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=null},e.prototype._loadFrame=function(t,e){var i,r=this.frames[t];if(this.atomIndices){var n=this.atomIndices,o=n.length;i=new Float32Array(3*o);for(var a=0;a<o;++a){var s=3*a,c=3*n[a];i[s+0]=r[c+0],i[s+1]=r[c+1],i[s+2]=r[c+2]}}else i=new Float32Array(r);var u=this.boxes[t],h=this.frames.length;this.process(t,u,i,h),"function"==typeof e&&e()},e.prototype.getNumframes=function(){this.frames&&this.setNumframes(this.frames.length)},e.prototype.getPath=function(t,e){var i,r,n,o=this,a=this.numframes,s=3*t,c=new Float32Array(3*a);for(i=0;i<a;++i)r=3*i,n=o.frames[i],c[r+0]=n[s+0],c[r+1]=n[s+1],c[r+2]=n[s+2];e(c)},Object.defineProperties(e.prototype,i),e}(kv),Ub=function(t){function e(e,i,r){t.call(this,"",i,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"structure"},e.prototype.makeAtomIndices=function(){this.structure.atomSet.getSize()<this.structure.atomStore.count?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=null},e.prototype._loadFrame=function(t,e){var i,r=this.structure,n=r.frames[t];if(this.atomIndices){var o=this.atomIndices,a=o.length;i=new Float32Array(3*a);for(var s=0;s<a;++s){var c=3*s,u=3*o[s];i[c+0]=n[u+0],i[c+1]=n[u+1],i[c+2]=n[u+2]}}else i=new Float32Array(n);var h=r.boxes[t],l=r.frames.length;this.process(t,h,i,l),"function"==typeof e&&e()},e.prototype.getNumframes=function(){this.setNumframes(this.structure.frames.length)},e.prototype.getPath=function(t,e){var i,r,n,o=this,a=this.numframes,s=3*t,c=new Float32Array(3*a);for(i=0;i<a;++i)r=3*i,n=o.structure.frames[i],c[r+0]=n[s+0],c[r+1]=n[s+1],c[r+2]=n[s+2];e(c)},Object.defineProperties(e.prototype,i),e}(kv),jb=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"remote"},e.prototype.makeAtomIndices=function(){var t=[];if("StructureView"===this.structure.type){var e,i,r=this.structure.getAtomIndices(),n=r[0],o=r[0],a=r.length;for(e=1;e<a;++e)o+1<(i=r[e])&&(t.push([n,o+1]),n=i),o=i;t.push([n,o+1])}else t.push([0,this.atomCount]);this.atomIndices=t},e.prototype._loadFrame=function(t,e){var i=new window.XMLHttpRequest,r=pf.trajectory,n=r.getFrameUrl(this.trajPath,t),o=r.getFrameParams(this.trajPath,this.atomIndices);i.open("POST",n,!0),i.responseType="arraybuffer",i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.addEventListener("load",function(){var r=i.response;if(!r)return void cf.error("empty arrayBuffer for '"+n+"'");var o=new Int32Array(r,0,1)[0],a=new Float32Array(r,8,9),s=new Float32Array(r,44);this.process(t,a,s,o),"function"==typeof e&&e()}.bind(this),!1),i.send(o)},e.prototype.getNumframes=function(){var t=new window.XMLHttpRequest,e=pf.trajectory.getNumframesUrl(this.trajPath);t.open("GET",e,!0),t.addEventListener("load",function(){this.setNumframes(parseInt(t.response))}.bind(this),!1),t.send(null)},e.prototype.getPath=function(t,e){if(this.pathCache[t])return void e(this.pathCache[t]);cf.time("loadPath");var i=new window.XMLHttpRequest,r=pf.trajectory.getPathUrl(this.trajPath,t);i.open("POST",r,!0),i.responseType="arraybuffer",i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.addEventListener("load",function(){cf.timeEnd("loadPath");var n=i.response;if(!n)return void cf.error("empty arrayBuffer for '"+r+"'");var o=new Float32Array(n);this.pathCache[t]=o,e(o)}.bind(this),!1),i.send("")},Object.defineProperties(e.prototype,i),e}(kv);Lv.prototype.getView=function(t){return new Gb(this,t)};var Gb=function(e){function i(t,i){e.call(this),this.structure=t,this.selection=i,this.center=new g,this.boundingBox=new st,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()}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{},name:{},path:{},title:{},id:{},atomSetDict:{},biomolDict:{},entityList:{},unitcell:{},frames:{},boxes:{},validation:{},bondStore:{},backboneBondStore:{},rungBondStore:{},atomStore:{},residueStore:{},chainStore:{},modelStore:{},atomMap:{},residueMap:{},bondHash:{},spatialHash:{}};return i.prototype.init=function(){},r.type.get=function(){return"StructureView"},r.name.get=function(){return this.structure.name},r.path.get=function(){return this.structure.path},r.title.get=function(){return this.structure.title},r.id.get=function(){return this.structure.id},r.atomSetDict.get=function(){return this.structure.atomSetDict},r.biomolDict.get=function(){return this.structure.biomolDict},r.entityList.get=function(){return this.structure.entityList},r.unitcell.get=function(){return this.structure.unitcell},r.frames.get=function(){return this.structure.frames},r.boxes.get=function(){return this.structure.boxes},r.validation.get=function(){return this.structure.validation},r.bondStore.get=function(){return this.structure.bondStore},r.backboneBondStore.get=function(){return this.structure.backboneBondStore},r.rungBondStore.get=function(){return this.structure.rungBondStore},r.atomStore.get=function(){return this.structure.atomStore},r.residueStore.get=function(){return this.structure.residueStore},r.chainStore.get=function(){return this.structure.chainStore},r.modelStore.get=function(){return this.structure.modelStore},r.atomMap.get=function(){return this.structure.atomMap},r.residueMap.get=function(){return this.structure.residueMap},r.bondHash.get=function(){return this.structure.bondHash},r.spatialHash.get=function(){return this.structure.spatialHash},i.prototype.refresh=function(){var e=this;t.Debug&&cf.time("StructureView.refresh"),this.atomSetCache={},this.atomSet=this.getAtomSet(this.selection,!0),this.structure.atomSet&&(this.atomSet=this.atomSet.intersection(this.structure.atomSet)),this.bondSet=this.getBondSet();for(var i in e.atomSetDict){var r=e.atomSetDict[i];e.atomSetCache["__"+i]=r.makeIntersection(e.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(),t.Debug&&cf.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()},i.prototype.setSelection=function(t){this.selection=t,this.refresh()},i.prototype.getSelection=function(t){var e=[];t&&t.string&&e.push(t.string);var i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);var r="";return e.length>0&&(r="( "+e.join(" ) AND ( ")+" )"),new Kd(r)},i.prototype.getStructure=function(){return this.structure.getStructure()},i.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},i.prototype.eachAtom=function(t,e){var i=this.getAtomProxy(),r=this.getAtomSet(e),n=this.atomStore.count;if(r.getSize()<n)r.forEach(function(e){i.index=e,t(i)});else for(var o=0;o<n;++o)i.index=o,t(i)},i.prototype.eachResidue=function(t,e){this.structure.eachResidue(t,this.getSelection(e))},i.prototype.eachResidueN=function(){console.error("StructureView.eachResidueN() not implemented")},i.prototype.eachChain=function(t,e){this.structure.eachChain(t,this.getSelection(e))},i.prototype.eachModel=function(t,e){this.structure.eachModel(t,this.getSelection(e))},i.prototype.getAtomSet=function(t,e){var i=this.structure.getAtomSet(t);return!e&&this.atomSet&&(i=i.makeIntersection(this.atomSet)),i},i.prototype.getAtomIndices=function(t){return this.structure.getAtomIndices(this.getSelection(t))},i.prototype.refreshPosition=function(){return this.structure.refreshPosition()},i.prototype.dispose=function(){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(i.prototype,r),i}(Lv),Vb=function(t){function e(e,i,r){var n=r||{};n.name=gn(n.name,i.name),t.call(this,e,n),this.signals=Object.assign(this.signals,{trajectoryAdded:new oo,trajectoryRemoved:new oo,defaultAssemblyChanged:new oo}),this.structure=i,this.trajList=[],this.initSelection(n.sele),this.setDefaultAssembly(n.assembly||"")}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"structure"},e.prototype.initSelection=function(t){var e=this;this.selection=new Kd(t),this.structureView=new Gb(this.structure,this.selection),this.selection.signals.stringChanged.add(function(){e.structureView.setSelection(e.selection),e.rebuildRepresentations(),e.rebuildTrajectories()})},e.prototype.setSelection=function(t){return this.selection.setString(t),this},e.prototype.setDefaultAssembly=function(t){var e=this;this.defaultAssembly=t,this.reprList.forEach(function(t){t.setParameters({defaultAssembly:e.defaultAssembly})}),this.signals.defaultAssemblyChanged.dispatch(t)},e.prototype.rebuildRepresentations=function(){this.reprList.forEach(function(t){t.build()})},e.prototype.rebuildTrajectories=function(){var t=this;this.trajList.slice().forEach(function(e){e.trajectory.setStructure(t.structureView)})},e.prototype.addRepresentation=function(e,i){var r=i||{};return r.defaultAssembly=this.defaultAssembly,t.prototype.addRepresentation.call(this,e,this.structureView,r)},e.prototype.addTrajectory=function(t,e){var i=this,r=Ds(t,this.structureView,e);r.signals.frameChanged.add(function(){i.updateRepresentations({position:!0})});var n=new Bb(this.stage,r,e,this);return this.trajList.push(n),this.signals.trajectoryAdded.dispatch(n),n},e.prototype.removeTrajectory=function(t){var e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)},e.prototype.dispose=function(){this.trajList.slice().forEach(function(t){t.dispose()}),this.trajList.length=0,this.structure.dispose(),t.prototype.dispose.call(this)},e.prototype.autoView=function(t,e){Number.isInteger(t)&&(e=t,t=void 0),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),gn(e,0))},e.prototype.getBoxUntransformed=function(t){return t?this.structureView.getBoundingBox(new Kd(t)):this.structureView.boundingBox},e.prototype.getCenterUntransformed=function(t){return t&&"string"==typeof t?this.structure.atomCenter(new Kd(t)):this.structure.center},e.prototype.superpose=function(t,e,i,r){return Is(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this},e.prototype.setVisibility=function(e){return t.prototype.setVisibility.call(this,e),this.trajList.forEach(function(t){t.setVisibility(e)}),this},Object.defineProperties(e.prototype,i),e}(Yy);vf.add("structure",Vb),vf.add("structureview",Vb);var $b=function(t){function e(e,i,r){var n=r||{};n.name=gn(n.name,i.name),t.call(this,e,n),this.surface=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"surface"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.surface,i)},e.prototype.getBoxUntransformed=function(){return this.surface.boundingBox},e.prototype.getCenterUntransformed=function(){return this.surface.center},e.prototype.dispose=function(){this.surface.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,i),e}(Yy);vf.add("surface",$b);var Hb=function(t){function e(e,i,r){var n=r||{};n.name=gn(n.name,i.name),t.call(this,e,n),this.volume=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"volume"},e.prototype.addRepresentation=function(e,i){return t.prototype.addRepresentation.call(this,e,this.volume,i)},e.prototype.getBoxUntransformed=function(){return this.volume.boundingBox},e.prototype.getCenterUntransformed=function(){return this.volume.center},e.prototype.dispose=function(){this.volume.dispose(),t.prototype.dispose.call(this)},Object.defineProperties(e.prototype,i),e}(Yy);vf.add("volume",Hb);var Wb=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="axes",this.parameters=Object.assign({radius:{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(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=gn(i.radius,.5),i.colorValue=gn(i.colorValue,"lightgreen"),this.showAxes=gn(i.showAxes,!0),this.showBox=gn(i.showBox,!1),t.prototype.init.call(this,i)},e.prototype.getPrincipalAxes=function(){var t,e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)},e.prototype.getAxesData=function(t){var e=this.getPrincipalAxes(t),i=new tt(this.colorValue),r=0,n=0;this.showAxes&&(r+=6,n+=3),this.showBox&&(r+=8,n+=12);var o=new Float32Array(3*r),a=To(r,i.r,i.g,i.b),s=Po(r,this.radius),c=new Float32Array(3*n),u=new Float32Array(3*n),h=To(n,i.r,i.g,i.b),l=Po(n,this.radius),p=0;if(this.showAxes){var d=function(t,e){t.toArray(o,2*p),e.toArray(o,2*p+3),t.toArray(c,p),e.toArray(u,p),p+=3};d(e.begA,e.endA),d(e.begB,e.endB),d(e.begC,e.endC)}if(this.showBox){var f=new g,m=e.getProjectedScaleForAtoms(t),v=m.d1a,y=m.d2a,b=m.d3a,x=m.d1b,_=m.d2b,w=m.d3b;console.log(v,y,b,x,_,w);var S=2*p,A=function(t,i,r){f.copy(e.center).addScaledVector(e.normVecA,t).addScaledVector(e.normVecB,i).addScaledVector(e.normVecC,r),f.toArray(o,S),S+=3};A(v,y,b),A(v,y,w),A(v,_,w),A(v,_,b),A(x,_,w),A(x,_,b),A(x,y,b),A(x,y,w);var M=p,P=function(t,e){f.fromArray(o,2*p+3*t).toArray(c,M),f.fromArray(o,2*p+3*e).toArray(u,M),M+=3};P(0,1),P(0,3),P(0,6),P(1,2),P(1,7),P(2,3),P(2,4),P(3,5),P(4,5),P(4,7),P(5,6),P(6,7)}var T=new Qm(e);return{vertex:{position:o,color:a,radius:s,picking:T},edge:{position1:c,position2:u,color:h,color2:h,radius:l,picking:T}}},e.prototype.create=function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new Kv(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new py(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]})},e.prototype.updateData=function(t,e){var i=this.getAxesData(e.sview),r={},n={};t&&!t.position||(r.position=i.vertex.position,n.position1=i.edge.position1,n.position2=i.edge.position2),t&&!t.color||(r.color=i.vertex.color,n.color=i.edge.color,n.color2=i.edge.color),t&&!t.radius||(r.radius=i.vertex.radius,n.radius=i.edge.radius),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(n)},e}(Vy);df.add("axes",Wb);var Xb=function(t){function e(e,i,r){t.call(this,e,i,r),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}},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=gn(i.radius,.15),this.aspectRatio=gn(i.aspectRatio,2),this.lineOnly=gn(i.lineOnly,!1),this.cylinderOnly=gn(i.cylinderOnly,!1),this.multipleBond=gn(i.multipleBond,"off"),this.bondSpacing=gn(i.bondSpacing,1),this.bondScale=gn(i.bondScale,.4),t.prototype.init.call(this,i)},e.prototype.getAtomParams=function(e,i){return i=Object.assign({radiusParams:{radius:this.radius,scale:this.scale*this.aspectRatio}},i),t.prototype.getAtomParams.call(this,e,i)},e.prototype.getAtomData=function(t,e,i){return t.getAtomData(this.getAtomParams(e,i))},e.prototype.getBondParams=function(e,i){return i=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},i),t.prototype.getBondParams.call(this,e,i)},e.prototype.getBondData=function(t,e,i){return t.getBondData(this.getBondParams(e,i))},e.prototype.createData=function(t){var e=this.getBondData(t),i=[];if(this.lineOnly)this.lineBuffer=new $y(e,this.getBufferParams()),i.push(this.lineBuffer);else{var r=new py(e,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(i.push(r),!this.cylinderOnly){var n=new Kv(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));i.push(n)}}return{bufferList:i}},e.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var i=this.getBondData(e.sview,t);if(this.lineOnly){var r={};t&&!t.position||(r.position1=i.position1,r.position2=i.position2),t&&!t.color||(r.color=i.color,r.color2=i.color2),e.bufferList[0].setAttributes(r)}else{var n={};if(t&&!t.position||(n.position1=i.position1,n.position2=i.position2),t&&!t.color||(n.color=i.color,n.color2=i.color2),t&&!t.radius||(n.radius=i.radius),e.bufferList[0].setAttributes(n),!this.cylinderOnly){var o=this.getAtomData(e.sview,t),a={};t&&!t.position||(a.position=o.position),t&&!t.color||(a.color=o.color),t&&!t.radius||(a.radius=o.radius),e.bufferList[1].setAttributes(a)}}},e.prototype.setParameters=function(e){var i=!1,r={};return e&&(e.aspectRatio||e.bondSpacing||e.bondScale)&&(r.radius=!0,sf&&!this.disableImpostor||(i=!0)),t.prototype.setParameters.call(this,e,r,i),this},e}(Vy);df.add("ball+stick",Xb);var qb=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=gn(i.aspectRatio,1),i.radius=gn(i.radius,.25),t.prototype.init.call(this,i)},e.prototype.getAtomData=function(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))},e.prototype.getBondData=function(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))},e}(Xb);df.add("backbone",qb);var Yb=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=gn(i.aspectRatio,1),i.radius=gn(i.radius,.3),t.prototype.init.call(this,i)},e.prototype.getAtomData=function(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))},e.prototype.getBondData=function(t,e,i){var r=this.getBondParams(e,i);return r.colorParams.rung=!0,t.getRungBondData(r)},e}(Xb);df.add("base",Yb),ks.prototype={constructor:ks,getAtomIterator:function(t,e){function i(){var t=this.get(u);return u+=1,t}function r(i){var r=h[c%4];if(r.index=o.getAtomIndexByType(i,t),e&&i>0&&i<s&&"e"===r.sstruc){var n=l[c%4];return p.index=o.getAtomIndexByType(i+1,t),d.index=o.getAtomIndexByType(i-1,t),n.addVectors(p,d).add(r).add(r).multiplyScalar(.25),c+=1,n}return c+=1,r}function n(){c=0,u=-1}var o=this.polymer,a=o.structure,s=o.residueCount,c=0,u=-1,h=[a.getAtomProxy(),a.getAtomProxy(),a.getAtomProxy(),a.getAtomProxy()],l=[new g,new g,new g,new g],p=a.getAtomProxy(),d=a.getAtomProxy();return{size:s,next:i,get:r,reset:n}},getSubdividedColor:function(t){function e(t,e,i){c.atomColorToArray(t,e,i)}var i=this.subdiv,r=this.polymer,n=(r.residueCount-1)*i*3+3;r.isCyclic&&(n+=3*i);var o=new Float32Array(n),a=this.getAtomIterator("trace"),s=t||{};s.structure=r.structure;var c=lf.getScheme(s);return this.interpolator.getColor(a,e,o,0,r.isCyclic),{color:o}},getSubdividedPicking:function(){function t(t){return t.index}var e=this.subdiv,i=this.polymer,r=(i.residueCount-1)*e+1;i.isCyclic&&(r+=e);var n=i.structure,o=this.getAtomIterator("trace"),a=new Float32Array(r);return this.interpolator.getPicking(o,t,a,0,i.isCyclic),{picking:new Km(a,n)}},getSubdividedPosition:function(){return{position:this.getPosition()}},getSubdividedOrientation:function(){var t=this.getTangent(),e=this.getNormals(t);return{tangent:t,normal:e.normal,binormal:e.binormal}},getSubdividedSize:function(t,e){function i(t){return c.atomRadius(t)}var r=this.subdiv,n=this.polymer,o=(n.residueCount-1)*r+1;n.isCyclic&&(o+=r);var a=new Float32Array(o),s=this.getAtomIterator("trace"),c=new ga(t,e);return this.interpolator.getSize(s,i,a,0,n.isCyclic),{size:a}},getPosition:function(){var t=this.subdiv,e=this.polymer,i=(e.residueCount-1)*t*3+3;e.isCyclic&&(i+=3*t);var r=new Float32Array(i),n=this.positionIterator||this.getAtomIterator("trace",this.smoothSheet);return this.interpolator.getPosition(n,r,0,e.isCyclic),r},getTangent:function(){var t=this.subdiv,e=this.polymer,i=(this.size-1)*t*3+3;e.isCyclic&&(i+=3*t);var r=new Float32Array(i),n=this.positionIterator||this.getAtomIterator("trace",this.smoothSheet);return this.interpolator.getTangent(n,r,0,e.isCyclic),r},getNormals:function(t){var e=this.subdiv,i=this.polymer,r=i.isProtein(),n=this.size,o=(n-1)*e*3+3;i.isCyclic&&(o+=3*e);var a=new Float32Array(o),s=new Float32Array(o);if(this.directional&&!this.polymer.isCg()){var c=this.getAtomIterator("direction1"),u=this.getAtomIterator("direction2");this.interpolator.getNormalDir(c,u,t,a,s,0,i.isCyclic,r)}else this.interpolator.getNormal(n,t,a,s,0,i.isCyclic,r);return{normal:a,binormal:s}}};var Zb=new g,Kb=new g,Qb=function(t){function e(e,i){var r=e||{},n=i||{},o=gn(n.radialSegments,4),a=gn(n.capped,!1),s=a?o:0,c=a?o-2:0,u=r.position.length/3,h=u*o*3+2*s*3,l=2*(u-1)*o*3+2*c*3,p=new Float32Array(h),d=new Float32Array(h),f=new Float32Array(h),m=Ln(l,h/3);t.call(this,{position:p,color:d,index:m,normal:f,picking:r.picking},n),this.aspectRatio=gn(n.aspectRatio,1),this.radialSegments=o,this.capped=a,this.capVertices=s,this.capTriangles=c,this.size2=u,r.primitiveId=Co(u),this.setAttributes(r),this.meshIndex=m,this.makeIndex()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s,c,u,h,l,p=this.aspectRatio,d=this.size2,f=d-1,m=this.radialSegments,g=this.geometry.attributes;t.position&&(e=t.position,i=t.normal,r=t.binormal,n=t.tangent,a=t.size,c=g.position.array,h=g.normal.array,g.position.needsUpdate=!0,g.normal.needsUpdate=!0),t.color&&(o=t.color,u=g.color.array,g.color.needsUpdate=!0),t.primitiveId&&(s=t.primitiveId,l=g.primitiveId.array,g.primitiveId.needsUpdate=!0);var v,y,b,x,_,w,S,A,M,P,T,E,C,I,R,L,O,D,N,k,F,B,z,U=[],j=[],G=[],V=[],$=[],H=[];if(e)for(y=0;y<m;++y)S=y/m*2*Math.PI,U[y]=p*Math.cos(S),j[y]=Math.sin(S),G[y]=p*Math.cos(S-.01),V[y]=Math.sin(S-.01),$[y]=p*Math.cos(S+.01),H[y]=Math.sin(S+.01);for(v=0;v<d;++v)for(x=(b=3*v)*m,e&&(Zb.set(n[b],n[b+1],n[b+2]),R=i[b],L=i[b+1],O=i[b+2],D=r[b],N=r[b+1],k=r[b+2],F=e[b],B=e[b+1],z=e[b+2],I=a[v]),y=0;y<m;++y)_=x+3*y,e&&(A=-I*U[y],M=I*j[y],P=-I*G[y],T=I*V[y],E=-I*$[y],C=I*H[y],c[_]=F+A*R+M*D,c[_+1]=B+A*L+M*N,c[_+2]=z+A*O+M*k,Kb.set(E*R+C*D-(P*R+T*D),E*L+C*N-(P*L+T*N),E*O+C*k-(P*O+T*k)).cross(Zb),h[_]=Kb.x,h[_+1]=Kb.y,h[_+2]=Kb.z),o&&(u[_]=o[b],u[_+1]=o[b+1],u[_+2]=o[b+2]),s&&(l[v*m+y]=s[v]);for(b=0,x=3*d*m,y=0;y<m;++y)_=b+3*y,w=x+3*y,e&&(c[w]=c[_],c[w+1]=c[_+1],c[w+2]=c[_+2],h[w]=n[b],h[w+1]=n[b+1],h[w+2]=n[b+2]),o&&(u[w]=u[_],u[w+1]=u[_+1],u[w+2]=u[_+2]),s&&(l[d*m+y]=l[0+y]);for(b=3*(d-1)*m,x=3*(d+1)*m,y=0;y<m;++y)_=b+3*y,w=x+3*y,e&&(c[w]=c[_],c[w+1]=c[_+1],c[w+2]=c[_+2],h[w]=n[3*f],h[w+1]=n[3*f+1],h[w+2]=n[3*f+2]),o&&(u[w]=u[_],u[w+1]=u[_+1],u[w+2]=u[_+2]),s&&(l[(d+1)*m+y]=l[(d-1)*m+y])},e.prototype.makeIndex=function(){var t,e,i,r,n,o,a=this.meshIndex,s=this.size2,c=s-1,u=this.capTriangles,h=this.radialSegments,l=this.radialSegments+1;for(t=0;t<c;++t)for(e=t*h*3*2,i=t*h,r=(t+1)*h,o=0;o<h;++o)a[n=e+3*o*2]=i+o,a[n+1]=i+(o+1)%h,a[n+2]=r+o,a[n+3]=r+o,a[n+4]=i+(o+1)%h,a[n+5]=r+(o+1)%h;var p=[0];for(o=1;o<l/2;++o)p.push(o),h-o!==o&&p.push(h-o);for(n=c*h*3*2,e=s*h,o=0;o<p.length-2;++o)o%2==0?(a[n+3*o+0]=e+p[o+0],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+2]):(a[n+3*o+0]=e+p[o+2],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+0]);for(n=c*h*3*2+3*u,e=s*h+h,o=0;o<p.length-2;++o)o%2==0?(a[n+3*o+0]=e+p[o+0],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+2]):(a[n+3*o+0]=e+p[o+2],a[n+3*o+1]=e+p[o+1],a[n+3*o+2]=e+p[o+0])},e}(Uv),Jb=function(e){function i(t,i,r){e.call(this,t,i,r),this.type="cartoon",this.parameters=Object.assign({aspectRatio:{type:"number",precision:1,max:10,min:1},subdiv:{type:"integer",max:50,min:1,rebuild:!0},radialSegments:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},capped:{type:"boolean",rebuild:!0},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters),this.init(r)}return e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i,i.prototype.init=function(t){var i=t||{};i.colorScheme=gn(i.colorScheme,"chainname"),i.colorScale=gn(i.colorScale,"RdYlBu"),i.radius=gn(i.radius,"sstruc"),i.scale=gn(i.scale,.7),this.aspectRatio=gn(i.aspectRatio,5),this.tension=gn(i.tension,NaN),this.capped=gn(i.capped,!0),this.smoothSheet=gn(i.smoothSheet,!1),"low"===i.quality?(this.subdiv=3,this.radialSegments=6):"medium"===i.quality?this.subdiv=6:"high"===i.quality?this.subdiv=12:this.subdiv=gn(i.subdiv,6),e.prototype.init.call(this,i)},i.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:1!==this.aspectRatio,smoothSheet:this.smoothSheet},t)},i.prototype.getSpline=function(t){return new ks(t,this.getSplineParams())},i.prototype.getScale=function(t){return t.isCg()?this.scale*this.aspectRatio:this.scale},i.prototype.getAspectRatio=function(t){return t.isCg()?1:this.aspectRatio},i.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=e.getSpline(t),o=n.getSubdividedPosition(),a=n.getSubdividedOrientation(),s=n.getSubdividedColor(e.getColorParams()),c=n.getSubdividedPicking(),u=n.getSubdividedSize(e.radius,e.getScale(t));i.push(new Qb(Object.assign({},o,a,s,c,u),e.getBufferParams({radialSegments:e.radialSegments,aspectRatio:e.getAspectRatio(t),capped:e.capped,dullInterior:!0})))}},t.getSelection()),{bufferList:i,polymerList:r}},i.prototype.updateData=function(e,i){var r=this;t.Debug&&cf.time(this.type+" repr update"),e=e||{};for(var n=0,o=i.polymerList.length;n<o;++n){var a={},s=i.polymerList[n],c=r.getSpline(s);if(i.bufferList[n].aspectRatio=r.getAspectRatio(s),e.position||e.radius){var u=c.getSubdividedPosition(),h=c.getSubdividedOrientation(),l=c.getSubdividedSize(r.radius,r.getScale(s));a.position=u.position,a.normal=h.normal,a.binormal=h.binormal,a.tangent=h.tangent,a.size=l.size}if(e.color){var p=c.getSubdividedColor(r.getColorParams());a.color=p.color}if(e.picking){var d=c.getSubdividedPicking();a.picking=d.picking}i.bufferList[n].setAttributes(a)}t.Debug&&cf.timeEnd(this.type+" repr update")},i.prototype.setParameters=function(t){var i={};return t&&t.aspectRatio&&(i.radius=!0),t&&t.tension&&(i.position=!0),e.prototype.setParameters.call(this,t,i,!1),this},i}(Vy);df.add("cartoon",Jb);var tx=function(t,e){this.sview1=t,this.sview2=e,this.kdtree2=new ts(e)};tx.prototype.within=function(t,e){cf.time("Contact within");var i=this.kdtree2,r=this.sview1.getAtomProxy(),n=this.sview1.getAtomSet(!1),o=new iv;this.sview1.eachAtom(function(a){for(var s=!1,c=i.nearest(a,1/0,t),u=0,h=c.length;u<h;++u){var l=c[u];r.index=l.index,a.residueIndex!==r.residueIndex&&(!e||l.distance>e)&&(s=!0,n.set(r.index),o.addBond(a,r,1))}s&&n.set(a.index)});var a=new pg(o.count,!0);return cf.timeEnd("Contact within"),{atomSet:n,bondSet:a,bondStore:o}};var ex=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="contact",this.parameters=Object.assign({contactType:{type:"select",rebuild:!0,options:{polar:"polar",polarBackbone:"polar backbone"}},maxDistance:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxAngle:{type:"integer",max:180,min:0,rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=gn(i.radius,.25),this.contactType=gn(i.contactType,"polarBackbone"),this.maxDistance=gn(i.maxDistance,3.5),this.maxAngle=gn(i.maxAngle,40),t.prototype.init.call(this,i)},e.prototype.getContactData=function(t){return{polar:Fs,polarBackbone:Bs}[this.contactType](t,this.maxDistance,this.maxAngle)},e.prototype.getBondData=function(t,e,i){var r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new tg(r.picking.array,r.picking.structure,i.bondStore)),r},e.prototype.createData=function(t){var e=this.getContactData(t);return{bufferList:[new py(this.getBondData(t,void 0,{bondSet:e.bondSet,bondStore:e.bondStore}),this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],bondSet:e.bondSet,bondStore:e.bondStore}},e.prototype.updateData=function(t,e){if(!t||t.position){var i=this.getContactData(e.sview);e.bondSet=i.bondSet,e.bondStore=i.bondStore}var r={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(e.sview,t,r),o={};t&&!t.position||(o.position=Mo(n.position1,n.position2),o.position1=n.position1,o.position2=n.position2),t&&!t.color||(o.color=n.color,o.color2=n.color2),t&&!t.radius||(o.radius=n.radius),e.bufferList[0].setAttributes(o)},e}(Vy);df.add("contact",ex);var ix=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="distance",this.parameters=Object.assign({labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelVisible:{type:"boolean"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelUnit:{type:"select",rebuild:!0,options:{"":"",angstrom:"angstrom",nm:"nm"}},atomPair:{type:"hidden",rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters,{flatShaded:null,assembly:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.radius=gn(i.radius,.15),this.fontFamily=gn(i.fontFamily,"sans-serif"),this.fontStyle=gn(i.fontStyle,"normal"),this.fontWeight=gn(i.fontWeight,"bold"),this.sdf=gn(i.sdf,"Firefox"!==nf),this.labelSize=gn(i.labelSize,2),this.labelColor=gn(i.labelColor,16777215),this.labelVisible=gn(i.labelVisible,!0),this.labelZOffset=gn(i.labelZOffset,.5),this.labelUnit=gn(i.labelUnit,""),this.atomPair=gn(i.atomPair,[]),t.prototype.init.call(this,i)},e.prototype.getDistanceData=function(t,e){var i=e.length,r=new Array(i),n=new Float32Array(3*i),o=new Kd,a=new Kd,s=new iv,c=t.getAtomProxy(),u=t.getAtomProxy(),h=0;e.forEach(function(e,i){var l=e[0],p=e[1];if(Number.isInteger(l)&&Number.isInteger(p))c.index=l,u.index=p;else{o.setString(l),a.setString(p);var d=t.getAtomIndices(o),f=t.getAtomIndices(a);if(!d.length||!f.length)return void(h+=1);c.index=d[0],u.index=f[0]}s.addBond(c,u,1),i-=h;var m=c.distanceTo(u);switch(this.labelUnit){case"angstrom":r[i]=m.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(m/10).toFixed(2)+" nm";break;default:r[i]=m.toFixed(2)}var g=3*i;n[g+0]=(c.x+u.x)/2,n[g+1]=(c.y+u.y)/2,n[g+2]=(c.z+u.z)/2},this),h>0&&(i-=h,n=n.subarray(0,3*i));var l=new pg(s.count,!0);return{text:r,position:n,bondSet:l,bondStore:s}},e.prototype.getBondData=function(t,e,i){var r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new rg(r.picking.array,r.picking.structure,i.bondStore)),r},e.prototype.create=function(){if(0!==this.structureView.atomCount){var t=this.atomPair.length;if(0!==t){var e=this.getDistanceData(this.structureView,this.atomPair),i=new tt(this.labelColor);this.textBuffer=new Ay({position:e.position,size:Po(t,this.labelSize),color:To(t,i.r,i.g,i.b),text:e.text},this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,sdf:this.sdf,zOffset:this.labelZOffset,opacity:1,visible:this.labelVisible}));var r={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(this.structureView,void 0,r);this.cylinderBuffer=new py(n,this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bondSet:e.bondSet,bondStore:e.bondStore,position:e.position,bufferList:[this.textBuffer,this.cylinderBuffer]})}}},e.prototype.update=function(e){e.position?this.build():t.prototype.update.call(this,e)},e.prototype.updateData=function(t,e){var i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),n={},o={},a=this.atomPair.length;if(t.labelSize&&(o.size=Po(a,this.labelSize)),t.labelColor){var s=new tt(this.labelColor);o.color=To(a,s.r,s.g,s.b)}t.color&&(n.color=r.color,n.color2=r.color2),(t.radius||t.scale)&&(n.radius=r.radius),this.textBuffer.setAttributes(o),this.cylinderBuffer.setAttributes(n)},e.prototype.setVisibility=function(e,i){return t.prototype.setVisibility.call(this,e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),i||this.viewer.requestRender(),this},e.prototype.setParameters=function(e){var i={};return e&&e.labelSize&&(i.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(i.labelColor=!0),t.prototype.setParameters.call(this,e,i,!1),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this},e}(Vy);df.add("distance",ix);var rx=function(t){function e(e,i){var r=i||{},n=2*(e.position.length/3),o=new tt(gn(r.color,"grey")),a=new Float32Array(3*n),s=To(n,o.r,o.g,o.b);t.call(this,{position:a,color:s},r),this.scale=gn(r.scale,1),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n=this.geometry.attributes;t.position&&t.vector&&(e=t.position,i=t.vector,r=n.position.array,n.position.needsUpdate=!0);var o,a,s=this.size/2,c=this.scale;if(t.position&&t.vector)for(var u=0;u<s;u++)a=3*u,r[(o=2*u*3)+0]=e[a+0],r[o+1]=e[a+1],r[o+2]=e[a+2],r[o+3]=e[a+0]+i[a+0]*c,r[o+4]=e[a+1]+i[a+1]*c,r[o+5]=e[a+2]+i[a+2]*c},i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(Bv),nx=function(e){function i(t,i,r){e.call(this,t,i,r),this.type="helixorient",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(r)}return e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i,i.prototype.init=function(t){var i=t||{};i.colorScheme=gn(i.colorScheme,"sstruc"),i.radius=gn(i.radius,.15),i.scale=gn(i.scale,1),e.prototype.init.call(this,i)},i.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=new Za(t),o=n.getPosition(),a=n.getColor(e.getColorParams()),s=n.getSize(e.radius,e.scale),c=n.getPicking();i.push(new Kv({position:o.center,color:a.color,radius:s.size,picking:c.picking},e.getBufferParams({sphereDetail:e.sphereDetail,disableImpostor:e.disableImpostor,dullInterior:!0})),new rx({position:o.center,vector:o.axis},e.getBufferParams({color:"skyblue",scale:1})),new rx({position:o.center,vector:o.resdir},e.getBufferParams({color:"lightgreen",scale:1})))}},t.getSelection()),{bufferList:i,polymerList:r}},i.prototype.updateData=function(e,i){t.Debug&&cf.time(this.type+" repr update"),e=e||{};for(var r=0,n=i.polymerList.length;r<n;++r){var o=3*r,a={},s=new Za(i.polymerList[r]);if(e.position){var c=s.getPosition();a.position=c.center,i.bufferList[o+1].setAttributes({position:c.center,vector:c.axis}),i.bufferList[o+2].setAttributes({position:c.center,vector:c.resdir})}i.bufferList[o].setAttributes(a)}t.Debug&&cf.timeEnd(this.type+" repr update")},i}(Vy);df.add("helixorient",nx);var ox=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="licorice",this.parameters=Object.assign({},this.parameters,{aspectRatio:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=1,t.prototype.init.call(this,i)},e}(Xb);df.add("licorice",ox),mf.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}"),mf.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float nearClip;\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\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, nearClip - 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( - ( nearClip - 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\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 );\nif( interior ){\nnormal = vec3( 0.0, 0.0, 0.4 );\n}\n#include lights_physical_fragment\n#include lights_template\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\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}");var ax=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]),sx=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]),cx=function(t){function e(e,i){t.call(this,e,i);var r=e||{},n=gn((i||{}).shrink,.14);this.addUniforms({modelViewProjectionMatrix:{value:new v},modelViewProjectionMatrixInverse:{value:new v},modelViewMatrixInverseTranspose:{value:new v},shrink:{value:n}}),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(r),this.makeMapping()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={parameters:{},isImpostor:{},vertexShader:{},fragmentShader:{}};return i.parameters.get=function(){return Object.assign.call(this,{shrink:{uniform:!0}},t.prototype.parameters)},i.isImpostor.get=function(){return!0},i.vertexShader.get=function(){return"HyperballStickImpostor.vert"},i.fragmentShader.get=function(){return"HyperballStickImpostor.frag"},Object.defineProperties(e.prototype,i),e}(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={mapping:{},mappingIndices:{},mappingIndicesSize:{},mappingType:{},mappingSize:{},mappingItemSize:{}};return i.mapping.get=function(){return ax},i.mappingIndices.get=function(){return sx},i.mappingIndicesSize.get=function(){return 36},i.mappingType.get=function(){return"v3"},i.mappingSize.get=function(){return 8},i.mappingItemSize.get=function(){return 3},Object.defineProperties(e.prototype,i),e}(Wv)),ux=function(t,e){return!sf||e&&e.disableImpostor?(t.radius=Ro(t.radius1,t.radius2),new cy(t,e)):new cx(t,e)},hx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="hyperball",this.parameters=Object.assign({shrink:{type:"number",precision:3,max:1,min:.001,buffer:!0}},this.parameters,{multipleBond:null,bondSpacing:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.scale=gn(i.scale,.2),i.radius=gn(i.radius,"vdw"),this.shrink=gn(i.shrink,.12),t.prototype.init.call(this,i)},e.prototype.getBondParams=function(e,i){return e&&!e.radius||(i=Object.assign({radius2:!0},i)),t.prototype.getBondParams.call(this,e,i)},e.prototype.createData=function(t){var e=new Kv(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));return this.__center=new Float32Array(3*t.bondCount),{bufferList:[e,new ux(t.getBondData(this.getBondParams()),this.getBufferParams({shrink:this.shrink,radialSegments:this.radialSegments,dullInterior:!0}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams()),r=e.sview.getBondData(this.getBondParams()),n={},o={};if(!t||t.position){n.position=i.position;var a=r.position1,s=r.position2;o.position=Mo(a,s,this.__center),o.position1=a,o.position2=s}t&&!t.color||(n.color=i.color,o.color=r.color,o.color2=r.color2),t&&!t.radius||(n.radius=i.radius,o.radius=r.radius,o.radius2=r.radius2),e.bufferList[0].setAttributes(n),e.bufferList[1].setAttributes(o)},e}(ox);df.add("hyperball",hx),zs.prototype={constructor:zs,atomLabel:function(t){var e;switch(this.type){case"atomname":e=t.atomname;break;case"atomindex":e=""+t.index;break;case"occupancy":e=t.occupancy.toFixed(2);break;case"bfactor":e=t.bfactor.toFixed(2);break;case"serial":e=""+t.serial;break;case"element":e=t.element;break;case"atom":e=t.atomname+"|"+t.index;break;case"resname":e=t.resname;break;case"resno":e=""+t.resno;break;case"res":var i=t.resname.toUpperCase();e=(Lg[i]||i)+t.resno;break;case"text":e=this.text[t.index];break;default:e=t.qualifiedName()}return void 0===e?"":e}},zs.types={"":"",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:"residue name + no",text:"text",qualified:"qualified name"};var lx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="label",this.parameters=Object.assign({labelType:{type:"select",options:zs.types,rebuild:!0},labelText:{type:"hidden",rebuild:!0},fontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:!0},fontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:!0},fontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:!0},sdf:{type:"boolean",buffer:!0},xOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},yOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},zOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},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:!0},showBorder:{type:"boolean",buffer:!0},borderColor:{type:"color",buffer:!0},borderWidth:{type:"number",precision:2,max:.3,min:0,buffer:!0},showBackground:{type:"boolean",rebuild:!0},backgroundColor:{type:"color",buffer:!0},backgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},backgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:!0}},this.parameters,{side:null,flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null,diffuse:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};this.labelType=gn(i.labelType,"res"),this.labelText=gn(i.labelText,{}),this.fontFamily=gn(i.fontFamily,"sans-serif"),this.fontStyle=gn(i.fontStyle,"normal"),this.fontWeight=gn(i.fontWeight,"bold"),this.sdf=gn(i.sdf,"Chrome"===nf),this.xOffset=gn(i.xOffset,0),this.yOffset=gn(i.yOffset,0),this.zOffset=gn(i.zOffset,.5),this.attachment=gn(i.attachment,"bottom-left"),this.showBorder=gn(i.showBorder,!1),this.borderColor=gn(i.borderColor,"lightgrey"),this.borderWidth=gn(i.borderWidth,.15),this.showBackground=gn(i.showBackground,!1),this.backgroundColor=gn(i.backgroundColor,"lightgrey"),this.backgroundMargin=gn(i.backgroundMargin,.5),this.backgroundOpacity=gn(i.backgroundOpacity,1),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e={position:!0,color:!0,radius:!0},i=t.getAtomData(this.getAtomParams(e)),r=[],n=new zs(this.labelType,this.labelText);return t.eachAtom(function(t){r.push(n.atomLabel(t))}),{bufferList:[new Ay({position:i.position,size:i.radius,color:i.color,text:r},this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,sdf:this.sdf,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}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||(r.position=i.position),t&&!t.radius||(r.size=i.radius),t&&!t.color||(r.color=i.color),e.bufferList[0].setAttributes(r)},e}(Vy);df.add("label",lx);var px=function(t){function e(e,i,r){t.call(this,e,i,r),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}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null,diffuse:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};this.multipleBond=gn(i.multipleBond,"off"),this.bondSpacing=gn(i.bondSpacing,1),t.prototype.init.call(this,i)},e.prototype.getBondParams=function(e,i){return i=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{radius:.1,scale:1}},i),t.prototype.getBondParams.call(this,e,i)},e.prototype.createData=function(t){var e={position:!0,color:!0},i=t.getBondData(this.getBondParams(e));return{bufferList:[new $y(i,this.getBufferParams())]}},e.prototype.updateData=function(t,e){var i=e.sview.getBondData(this.getBondParams(t)),r={};t&&!t.position||(r.position1=i.position1,r.position2=i.position2),t&&!t.color||(r.color=i.color,r.color2=i.color2),e.bufferList[0].setAttributes(r)},e.prototype.setParameters=function(e){var i={};return e&&e.bondSpacing&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(Vy);df.add("line",px),js.__deps=[qa,Xa,Ya,Qo,Us],Vs.__deps=[qa,Ya,Po,Qo,ca,ra,ua,Gs,gn],hf.add("molsurf",function(t,e){var i=t.data.args,r=t.data.params;if(i&&r){var n=new("av"===r.type?Vs:js)(i.coordList,i.radiusList,i.indexList).getSurface(r.type,r.probeRadius,r.scaleFactor,r.cutoff,!0,r.smooth,r.contour),o=[n.position.buffer,n.index.buffer];n.normal&&o.push(n.normal.buffer),n.atomindex&&o.push(n.atomindex.buffer),e({sd:n,p:r},o)}},[js,Vs]);var dx=function(t){this.structure=t};dx.prototype._getAtomData=function(){return this.structure.getAtomData({what:{position:!0,radius:!0,index:!0},radiusParams:{radius:"vdw",scale:1}})},dx.prototype._makeSurface=function(t,e){var i=new qg(e.name,"",t);return i.info.type=e.type,i.info.probeRadius=e.probeRadius,i.info.scaleFactor=e.scaleFactor,i.info.smooth=e.smooth,i.info.cutoff=e.cutoff,i},dx.prototype.getSurface=function(t){var e=t||{},i=this._getAtomData(),r=i.position,n=i.radius,o=i.index,a=new("av"===e.type?Vs:js)(r,n,o).getSurface(e.type,e.probeRadius,e.scaleFactor,e.cutoff,!0,e.smooth,e.contour);return this._makeSurface(a,e)},dx.prototype.getSurfaceWorker=function(t,e){var i=this,r=Object.assign({},t);if(window.Worker){void 0===this.worker&&(this.worker=new za("molsurf"));var n=this._getAtomData(),o=n.position,a=n.radius,s=n.index,c={args:{coordList:o,radiusList:a,indexList:s},params:r},u=[o.buffer,a.buffer,s.buffer];this.worker.post(c,u,function(t){e(i._makeSurface(t.data.sd,r))},function(t){console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),i.worker.terminate(),i.worker=void 0;var n=i.getSurface(r);e(n)})}else{var h=this.getSurface(r);e(h)}},dx.prototype.dispose=function(){this.worker&&this.worker.terminate()};var fx=function(t){function e(e,i,r){t.call(this,e,i,r),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,{radiusType:null,radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add(function(){this.__forceNewMolsurf=!0},this),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"uniform"),i.colorValue=gn(i.colorValue,14540253),i.disablePicking=gn(i.disablePicking,!0),this.surfaceType=gn(i.surfaceType,"ms"),this.probeRadius=gn(i.probeRadius,1.4),this.smooth=gn(i.smooth,2),this.scaleFactor=gn(i.scaleFactor,2),this.cutoff=gn(i.cutoff,0),this.contour=gn(i.contour,!1),this.background=gn(i.background,!1),this.opaqueBack=gn(i.opaqueBack,!0),this.filterSele=gn(i.filterSele,""),this.colorVolume=gn(i.colorVolume,void 0),this.useWorker=gn(i.useWorker,!0),t.prototype.init.call(this,e)},e.prototype.prepareData=function(t,e,i){var r=this.__infoList[e];if(r||(r={},this.__infoList[e]=r),r.molsurf&&r.sele===t.selection.string)i(e);else{if(this.filterSele){var n=t.structure.getView(new Kd(this.filterSele)),o=n.boundingBox.getSize(),a=Math.max(o.x,o.y,o.z),s=t.getAtomSetWithinPoint(n.center,a/2+6);t=t.getView(new Kd(t.getAtomSetWithinSelection(s,3).toSeleString()))}r.sele=t.selection.string,r.molsurf=new dx(t);var c=this.getSurfaceParams(),u=function(t){r.surface=t,i(e)};this.useWorker?r.molsurf.getSurfaceWorker(c,u):u(r.molsurf.getSurface(c))}},e.prototype.prepare=function(t){var e=this;if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach(function(t){t.molsurf.dispose()}),this.__infoList.length=0),0===this.structureView.atomCount)return void t();var i=function(){this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()}.bind(this),r="default"===this.assembly?this.defaultAssembly:this.assembly,n=this.structure.biomolDict[r];n?n.partList.forEach(function(t,r){var o=t.getView(e.structureView);e.prepareData(o,r,function(t){t===n.partList.length-1&&i()})}):this.prepareData(this.structureView,0,i)},e.prototype.createData=function(t,e){var i=this.__infoList[e],r=i.surface,n={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},o=[];if(r.contour){var a=new Dy(n,this.getBufferParams({wireframe:!1}));o.push(a)}else{n.normal=r.getNormal(),n.picking=r.getPicking(t.getStructure());var s=new Ry(n,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1})),c=new Ly(s);o.push(c)}return{bufferList:o,info:i}},e.prototype.updateData=function(t,e){var i={};if(t.position)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)},e.prototype.setParameters=function(e,i,r){return i=i||{},e&&e.filterSele&&(i.index=!0),e&&void 0!==e.colorVolume&&(i.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),t.prototype.setParameters.call(this,e,i,r),this},e.prototype.getSurfaceParams=function(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},t)},e.prototype.getColorParams=function(){var e=t.prototype.getColorParams.call(this);return e.volume=this.colorVolume,e},e.prototype.clear=function(){t.prototype.clear.call(this)},e.prototype.dispose=function(){this.__infoList.forEach(function(t){t.molsurf.dispose()}),this.__infoList.length=0,t.prototype.dispose.call(this)},e}(Vy);df.add("surface",fx);var mx=function(t){function e(e,i,r){t.call(this,e,i,r),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,roughness:null,metalness:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};this.pointSize=gn(i.pointSize,1),this.sizeAttenuation=gn(i.sizeAttenuation,!0),this.sortParticles=gn(i.sortParticles,!1),this.useTexture=gn(i.useTexture,!1),this.alphaTest=gn(i.alphaTest,.5),this.forceTransparent=gn(i.forceTransparent,!1),this.edgeBleach=gn(i.edgeBleach,0),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e={position:!0,color:!0,picking:!0},i=t.getAtomData(this.getAtomParams(e));return{bufferList:[new ky(i,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||(r.position=i.position),t&&!t.color||(r.color=i.color),e.bufferList[0].setAttributes(r)},e}(Vy);df.add("point",mx),mf.add("shader/Ribbon.vert","#define STANDARD\nuniform float nearClip;\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}");var gx=new Uint16Array([0,1,2,1,3,2]),vx=function(t){function e(e,i){var r=e||{},n=r.position.length/3-1,o=4*n,a=3*o,s=new Float32Array(a),c=new Float32Array(a),u=new Float32Array(a),h=Ln(a,a/3);t.call(this,{position:s,color:c,index:h,normal:u,picking:r.picking},i),this.addAttributes({dir:{type:"v3",value:new Float32Array(a)}}),this.addAttributes({size:{type:"f",value:new Float32Array(o)}}),r.primitiveId=Co(n),this.setAttributes(r),this.meshIndex=h,this.makeIndex()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={vertexShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n,o,a,s,c,u,h,l,p,d=this.size/4,f=this.geometry.attributes;t.position&&(e=t.position,s=f.position.array,f.position.needsUpdate=!0),t.normal&&(i=t.normal,c=f.normal.array,f.normal.needsUpdate=!0),t.size&&(r=t.size,u=f.size.array,f.size.needsUpdate=!0),t.dir&&(n=t.dir,h=f.dir.array,f.dir.needsUpdate=!0),t.color&&(o=t.color,l=f.color.array,f.color.needsUpdate=!0),t.primitiveId&&(a=t.primitiveId,p=f.primitiveId.array,f.primitiveId.needsUpdate=!0);var m,g,v,y,b,x,_,w=r?r[0]:null;for(m=0;m<d;++m){for(x=3*m,v=3*m*4,b=4*m,e&&(s[v]=s[v+3]=e[x],s[v+1]=s[v+4]=e[x+1],s[v+2]=s[v+5]=e[x+2],s[v+6]=s[v+9]=e[x+3],s[v+7]=s[v+10]=e[x+4],s[v+8]=s[v+11]=e[x+5]),i&&(c[v]=c[v+3]=-i[x],c[v+1]=c[v+4]=-i[x+1],c[v+2]=c[v+5]=-i[x+2],c[v+6]=c[v+9]=-i[x+3],c[v+7]=c[v+10]=-i[x+4],c[v+8]=c[v+11]=-i[x+5]),g=0;g<4;++g)y=v+3*g,o&&(l[y]=o[x],l[y+1]=o[x+1],l[y+2]=o[x+2]),a&&(p[b+g]=a[m]);r&&(_=r[m],w!==r[m]?(u[b]=w,u[b+1]=w,u[b+2]=_,u[b+3]=_):(u[b]=_,u[b+1]=_,u[b+2]=_,u[b+3]=_),w=_),n&&(h[v]=n[x],h[v+1]=n[x+1],h[v+2]=n[x+2],h[v+3]=-n[x],h[v+4]=-n[x+1],h[v+5]=-n[x+2],h[v+6]=n[x+3],h[v+7]=n[x+4],h[v+8]=n[x+5],h[v+9]=-n[x+3],h[v+10]=-n[x+4],h[v+11]=-n[x+5])}},e.prototype.makeIndex=function(){var t,e,i,r,n=this.meshIndex,o=n.length/4/3;for(e=0;e<o;++e)for(i=6*e,r=4*e,n.set(gx,i),t=0;t<6;++t)n[i+t]+=r},i.vertexShader.get=function(){return"Ribbon.vert"},Object.defineProperties(e.prototype,i),e}(Uv),yx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="ribbon",this.parameters=Object.assign({subdiv:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters,{side:null,wireframe:null,linewidth:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"chainname"),i.colorScale=gn(i.colorScale,"RdYlBu"),i.radius=gn(i.radius,"sstruc"),i.scale=gn(i.scale,4),"low"===i.quality?this.subdiv=3:"medium"===i.quality?this.subdiv=6:"high"===i.quality?this.subdiv=12:this.subdiv=gn(i.subdiv,6),this.tension=gn(i.tension,NaN),this.smoothSheet=gn(i.smoothSheet,!1),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:!0,smoothSheet:this.smoothSheet},t)},e.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=new ks(t,e.getSplineParams()),o=n.getSubdividedPosition(),a=n.getSubdividedOrientation(),s=n.getSubdividedColor(e.getColorParams()),c=n.getSubdividedPicking(),u=n.getSubdividedSize(e.radius,e.scale);i.push(new vx({position:o.position,normal:a.binormal,dir:a.normal,color:s.color,size:u.size,picking:c.picking},e.getBufferParams()))}},t.getSelection()),{bufferList:i,polymerList:r}},e.prototype.updateData=function(t,e){var i=this;t=t||{};var r=0,n=e.polymerList.length;for(r=0;r<n;++r){var o={},a=new ks(e.polymerList[r],i.getSplineParams());if(t.position){var s=a.getSubdividedPosition(),c=a.getSubdividedOrientation();o.position=s.position,o.normal=c.binormal,o.dir=c.normal}if(t.radius||t.scale){var u=a.getSubdividedSize(i.radius,i.scale);o.size=u.size}if(t.color){var h=a.getSubdividedColor(i.getColorParams());o.color=h.color}e.bufferList[r].setAttributes(o)}},e.prototype.setParameters=function(e){var i={};return e&&e.tension&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(Vy);df.add("ribbon",yx);var bx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="rocket",this.parameters=Object.assign({localAngle:{type:"integer",max:180,min:0,rebuild:!0},centerDist:{type:"number",precision:1,max:10,min:0,rebuild:!0},ssBorder:{type:"boolean",rebuild:!0},radialSegments:!0,openEnded:!0,disableImpostor:!0},this.parameters),this.helixbundleList=[],this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"sstruc"),i.radius=gn(i.radius,1.5),i.scale=gn(i.scale,1),i.openEnded=gn(i.openEnded,!1),this.localAngle=gn(i.localAngle,30),this.centerDist=gn(i.centerDist,2.5),this.ssBorder=gn(i.ssBorder,!1),t.prototype.init.call(this,i)},e.prototype.createData=function(t){var e=this,i=0,r=[],n=[];this.structure.eachPolymer(function(t){if(!(t.residueCount<4||t.isNucleic())){var o=new Ka(t),a=o.getAxis(e.localAngle,e.centerDist,e.ssBorder,e.getColorParams(),e.radius,e.scale);i+=a.size.length,r.push(a),n.push(o)}},t.getSelection());var o={begin:new Float32Array(3*i),end:new Float32Array(3*i),size:new Float32Array(i),color:new Float32Array(3*i),picking:new Float32Array(i)},a=0;return r.forEach(function(t){o.begin.set(t.begin,3*a),o.end.set(t.end,3*a),o.size.set(t.size,a),o.color.set(t.color,3*a),o.picking.set(t.picking.array,a),a+=t.size.length}),i&&(o.picking=new Km(o.picking,t.getStructure())),{bufferList:[new py({position1:o.begin,position2:o.end,color:o.color,color2:o.color,radius:o.size,picking:o.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:r,helixbundleList:n,axisData:o}},e.prototype.updateData=function(t,e){var i=this;if((t=t||{}).position)return void this.build();var r={};if(t.color||t.radius){var n=0;e.helixbundleList.forEach(function(r){var o=r.getAxis(i.localAngle,i.centerDist,i.ssBorder,i.getColorParams(),i.radius,i.scale);t.color&&e.axisData.color.set(o.color,3*n),(t.radius||t.scale)&&e.axisData.size.set(o.size,n),n+=o.size.length}),t.color&&(r.color=e.axisData.color,r.color2=e.axisData.color),(t.radius||t.scale)&&(r.radius=e.axisData.size)}e.bufferList[0].setAttributes(r)},e}(Vy);df.add("rocket",bx);var xx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=1,i.tension=gn(i.tension,.5),i.scale=gn(i.scale,5),i.smoothSheet=!1,this.smooth=gn(i.smooth,2),t.prototype.init.call(this,i)},e.prototype.getSpline=function(t){var e=new Za(t);return new ks(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))},e}(Jb);df.add("rope",xx);var _x=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};t.prototype.init.call(this,i)},e.prototype.createData=function(t){return{bufferList:[new Kv(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}},e.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||(r.position=i.position),t&&!t.color||(r.color=i.color),t&&!t.radius||(r.radius=i.radius),e.bufferList[0].setAttributes(r)},e}(Vy);df.add("spacefill",_x);var wx=function(t){function e(e,i){var r=e||{},n=i||{},o=r.position.length/3-1,a=new Float32Array(3*o*2),s=new Float32Array(3*o*2);t.call(this,{position:a,color:s},n),this.setAttributes(e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={isLine:{},vertexShader:{},fragmentShader:{}};return e.prototype.setAttributes=function(t){var e,i,r,n,o=this.geometry.attributes;if(t.position&&(e=t.position,r=o.position.array,o.position.needsUpdate=!0),t.color&&(i=t.color,n=o.color.array,o.color.needsUpdate=!0),!e&&!i)return void cf.warn("TraceBuffer.prototype.setAttributes no data");for(var a,s,c=this.size-1,u=0;u<c;++u)a=3*u,s=3*u*2,e&&(r[s]=e[a],r[s+1]=e[a+1],r[s+2]=e[a+2],r[s+3]=e[a+3],r[s+4]=e[a+4],r[s+5]=e[a+5]),i&&(n[s]=i[a],n[s+1]=i[a+1],n[s+2]=i[a+2],n[s+3]=i[a+3],n[s+4]=i[a+4],n[s+5]=i[a+5])},i.isLine.get=function(){return!0},i.vertexShader.get=function(){return"Line.vert"},i.fragmentShader.get=function(){return"Line.frag"},Object.defineProperties(e.prototype,i),e}(Bv),Sx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="trace",this.parameters=Object.assign({subdiv:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters,{flatShaded:null,side:null,wireframe:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorScheme=gn(i.colorScheme,"chainname"),i.colorScale=gn(i.colorScale,"RdYlBu"),"low"===i.quality?this.subdiv=3:"medium"===i.quality?this.subdiv=6:"high"===i.quality?this.subdiv=12:this.subdiv=gn(i.subdiv,6),this.tension=gn(i.tension,NaN),this.smoothSheet=gn(i.smoothSheet,!1),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:!1,smoothSheet:this.smoothSheet},t)},e.prototype.createData=function(t){var e=this,i=[],r=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){r.push(t);var n=new ks(t,e.getSplineParams()),o=n.getSubdividedPosition(),a=n.getSubdividedColor(e.getColorParams());i.push(new wx(Object.assign({},o,a),e.getBufferParams()))}},t.getSelection()),{bufferList:i,polymerList:r}},e.prototype.updateData=function(t,e){var i=this;t=t||{};var r=0,n=e.polymerList.length;for(r=0;r<n;++r){var o={},a=new ks(e.polymerList[r],i.getSplineParams());if(t.position){var s=a.getSubdividedPosition();o.position=s.position}if(t.color){var c=a.getSubdividedColor(i.getColorParams());o.color=c.color}e.bufferList[r].setAttributes(o)}},e.prototype.setParameters=function(e){var i={};return e&&e.tension&&(i.position=!0),t.prototype.setParameters.call(this,e,i,!1),this},e}(Vy);df.add("trace",Sx);var Ax=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="tube",this.parameters=Object.assign({},this.parameters,{aspectRatio:null})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.aspectRatio=1,i.scale=gn(i.scale,2),"low"===i.quality&&(this.radialSegments=5),t.prototype.init.call(this,i)},e.prototype.getSplineParams=function(){return t.prototype.getSplineParams.call(this,{directional:!1})},e}(Jb);df.add("tube",Ax);var Mx=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="unitcell",this.parameters=Object.assign({radius:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0},this.parameters,{assembly:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{},r=.5;this.structure.unitcell&&(r=Math.cbrt(this.structure.unitcell.volume)/200),i.radius=gn(i.radius,r),i.colorValue=gn(i.colorValue,"orange"),t.prototype.init.call(this,i)},e.prototype.getUnitcellData=function(t){return t.unitcell.getData(t)},e.prototype.create=function(){var t=this.structureView.getStructure();if(t.unitcell){var e=this.getUnitcellData(t);this.sphereBuffer=new Kv(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new py(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}},e.prototype.updateData=function(t,e){var i=e.sview.getStructure(),r=this.getUnitcellData(i),n={},o={};t&&!t.position||(n.position=r.vertexPosition,o.position1=r.edgePosition1,o.position2=r.edgePosition2),t&&!t.color||(n.color=r.vertexColor,o.color=r.edgeColor,o.color2=r.edgeColor),t&&!t.radius||(n.radius=r.vertexRadius,o.radius=r.edgeRadius),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(o)},e}(Vy);df.add("unitcell",Mx);var Px=function(t){function e(e,i,r){t.call(this,e,i,r),this.type="validation",this.parameters=Object.assign({},this.parameters,{radiusType:null,radius:null,scale:null}),this.init(r)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.init=function(e){var i=e||{};i.colorValue=gn(i.colorValue,"#f0027f"),t.prototype.init.call(this,i)},e.prototype.createData=function(t){if(t.validation){var e=t.validation.getClashData({structure:t,color:this.colorValue});return{bufferList:[new py(e,this.getBufferParams({openEnded:!1}))]}}},e}(Vy);df.add("validation",Px);var Tx=function(t,e){var i=e||{};this.streamer=t,this.name=gn(i.name,""),this.path=gn(i.path,"")},Ex={type:{},__objName:{}};Ex.type.get=function(){return""},Ex.__objName.get=function(){return""},Tx.prototype.parse=function(){var t=this;return this.streamer.read().then(function(){return t._beforeParse(),t._parse(),t._afterParse(),t[t.__objName]})},Tx.prototype._parse=function(){},Tx.prototype._beforeParse=function(){},Tx.prototype._afterParse=function(){t.Debug&&cf.log(this[this.__objName])},Object.defineProperties(Tx.prototype,Ex);var Cx=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.firstModelOnly=gn(r.firstModelOnly,!1),this.asTrajectory=gn(r.asTrajectory,!1),this.cAlphaOnly=gn(r.cAlphaOnly,!1),this.structure=new Lv(this.name,this.path),this.structureBuilder=new $s(this.structure)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"structure"},i.__objName.get=function(){return"structure"},Object.defineProperties(e.prototype,i),e}(Tx),Ix=function(t,e,i,r,n){this.structure=t,this.index=e,this.description=i||"",this.entityType=Hs(r||""),this.chainIndexList=n||[],n.forEach(function(i){t.chainStore.entityIndex[i]=e})},Rx={type:{}};Rx.type.get=function(){return"Entity"},Ix.prototype.getEntityType=function(){return this.entityType},Ix.prototype.isPolymer=function(){return this.entityType===fg},Ix.prototype.isNonPolymer=function(){return this.entityType===mg},Ix.prototype.isMacrolide=function(){return this.entityType===gg},Ix.prototype.isWater=function(){return this.entityType===vg},Ix.prototype.eachChain=function(t){var e=this.structure.getChainProxy();this.chainIndexList.forEach(function(i){e.index=i,t(e)})},Object.defineProperties(Ix.prototype,Rx);var Lx=function(t){var e=t||{};this.a=e.a||1,this.b=e.b||1,this.c=e.c||1,this.alpha=e.alpha||90,this.beta=e.beta||90,this.gamma=e.gamma||90,this.spacegroup=e.spacegroup||"P 1",this.cartToFrac=e.cartToFrac||e.scale,this.fracToCart=new v;var i=Hn(this.alpha),r=Hn(this.beta),n=Hn(this.gamma),o=Math.cos(i),a=Math.cos(r),s=Math.cos(n),c=Math.sin(r),u=Math.sin(n);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-o*o-a*a-s*s+2*o*a*s),void 0===this.cartToFrac){var h=this.a*this.b*u/this.volume,l=(a*s-o)/(c*u);this.fracToCart.set(this.a,0,0,0,this.b*s,this.b*u,0,0,this.c*a,-this.c*c*l,1/h,0,0,0,0,1).transpose(),this.cartToFrac=(new v).getInverse(this.fracToCart)}else this.fracToCart.getInverse(this.cartToFrac)};Lx.prototype.getPosition=function(t){function e(t,e,s){o.set(t,e,s).multiply(n).applyMatrix4(r.fracToCart).toArray(i,a),a+=3}var i=new Float32Array(24),r=t.unitcell,n=t.center.clone().applyMatrix4(r.cartToFrac).floor().multiplyScalar(2).addScalar(1),o=new g,a=0;return e(0,0,0),e(1,0,0),e(0,1,0),e(0,0,1),e(1,1,0),e(1,0,1),e(0,1,1),e(1,1,1),i},Lx.prototype.getCenter=function(t){return Eo(this.getPosition(t))},Lx.prototype.getData=function(t,e){function i(t,e){s.fromArray(c,3*t).toArray(l,m),s.fromArray(c,3*e).toArray(p,m),m+=3}var r=e||{},n=gn(r.colorValue,"orange"),o=gn(r.radius,Math.cbrt(this.volume)/200),a=new tt(n),s=new g,c=this.getPosition(t),u=To(8,a.r,a.g,a.b),h=Po(8,o),l=new Float32Array(36),p=new Float32Array(36),d=To(12,a.r,a.g,a.b),f=Po(12,o),m=0;i(0,1),i(0,2),i(0,3),i(1,4),i(1,5),i(2,6),i(3,5),i(4,7),i(5,7),i(2,4),i(7,6),i(3,6);var v=new ug(this,t);return{vertex:{position:c,color:u,radius:h,picking:v},edge:{position1:l,position2:p,color:d,color2:d,radius:f,picking:v}}};var Ox={1:"h",2:"h",3:"i",4:"h",5:"g",6:"h",7:"h",8:"h",9:"h",10:"h","":"h"},Dx=function(e){function i(t,i){var r=i||{};e.call(this,t,r),this.hex=gn(r.hex,!1)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"pdb"},i.prototype._parse=function(){function e(t,e,r){for(var n=t;n<e;++n)if(l=r[n],"ATOM  "===(p=l.substr(0,6))||"HETATM"===p){if(mt&&(X?(K?(a=new Float32Array(3*ht.count),Y.push(a)):a=[],s=0):W||(J={}),O=(L=1).toString(),D=!0,mt=!1),W&&ft>0)continue;var o=void 0,at=void 0,gt=void 0,vt=void 0,yt=void 0;if(z){if(vt=l.split(U),yt=10===vt.length?1:0,x=vt[2],q&&"CA"!==x)continue;o=parseFloat(vt[6-yt]),at=parseFloat(vt[7-yt]),gt=parseFloat(vt[8-yt])}else{if(x=l.substr(12,4).trim(),q&&"CA"!==x)continue;o=parseFloat(l.substr(30,8)),at=parseFloat(l.substr(38,8)),gt=parseFloat(l.substr(46,8))}if(X){var bt=3*s;if(a[bt+0]=o,a[bt+1]=at,a[bt+2]=gt,s+=1,K)continue}var xt=void 0;z?(d=parseInt(vt[1]),xt="",_="H"===l[0]?1:0,f=yt?"":vt[4],m=parseInt(vt[5-yt]),b="",g=vt[3],w=parseFloat(vt[9-yt]),S="",y=0):(d=parseInt(l.substr(6,5),$),V&&99999===d&&($=16),_="H"===l[0]?1:0,f=l[21].trim(),m=parseInt(l.substr(22,4),H)||1,V&&9999===m&&(H=16),b=l[26].trim(),g=l.substr(17,4).trim()||"MOL",w=parseFloat(l.substr(60,6)),S=l[16].trim(),y=parseFloat(l.substr(54,6)),i||(xt=l.substr(76,2).trim(),f||(f=l.substr(72,4).trim()))),ht.growIfFull(),ht.atomTypeId[dt]=ut.add(x,xt),ht.x[dt]=o,ht.y[dt]=at,ht.z[dt]=gt,ht.serial[dt]=d,ht.bfactor[dt]=isNaN(w)?0:w,ht.altloc[dt]=S.charCodeAt(0),ht.occupancy[dt]=isNaN(y)?0:y,_?N===f&&F===g&&(Fg.includes(g)||k===m&&B===b)||(O=(L+=1).toString(),k=m,F=g,B=b):D||N===f||(O=(L+=1).toString()),G.addAtom(ft,f,O,g,m,_,void 0,b),J[d]=dt,dt+=1,D=!1,N=f}else if("CONECT"===p){var _t=J[parseInt(l.substr(6,5))],wt=[11,16,21,26],St={};if(void 0===_t)continue;for(var At=0;At<4;++At){var Mt=parseInt(l.substr(wt[At],5));if(!Number.isNaN(Mt)&&void 0!==(Mt=J[Mt]))if(_t<Mt?(lt.index=_t,pt.index=Mt):(lt.index=Mt,pt.index=_t),void 0!==St[Mt])j.bondStore.bondOrder[St[Mt]]+=1;else{var Pt=lt.index+"|"+pt.index;void 0===et[Pt]&&(et[Pt]=!0,St[Mt]=j.bondStore.count,j.bondStore.addBond(lt,pt,1))}}}else if("HELIX "===p){A=l[19].trim(),M=parseInt(l.substr(21,4)),P=l[25].trim(),T=l[31].trim(),E=parseInt(l.substr(33,4)),C=l[37].trim();var Tt=parseInt(l.substr(39,1));Tt=(Ox[Tt]||Ox[""]).charCodeAt(0),st.push([A,M,P,T,E,C,Tt])}else if("SHEET "===p)A=l[21].trim(),M=parseInt(l.substr(22,4)),P=l[26].trim(),T=l[32].trim(),E=parseInt(l.substr(33,4)),C=l[37].trim(),ct.push([A,M,P,T,E,C]);else if("HETNAM"===p)ot[l.substr(11,3)]=l.substr(15).trim();else if("COMPND"===p){var Et=l.substr(10,70).trim(),Ct=Et.indexOf(":"),It=Et.substring(0,Ct),Rt=void 0;rt.includes(It)?(R=It,Rt=Et.substring(Ct+2)):Rt=Et,Rt=Rt.replace(/;$/,""),"MOL_ID"===R?(I={chainList:[],name:""},it.push(I)):"MOLECULE"===R?(I.name&&(I.name+=" "),I.name+=Rt):"CHAIN"===R&&Array.prototype.push.apply(I.chainList,Rt.split(/\s*,\s*/))}else if(l.startsWith("TER")){var Lt=j.getChainProxy(j.chainStore.count-1);nt[Lt.chainname]=Lt.index,O=(L+=1).toString(),D=!0}else if("REMARK"===p&&"350"===l.substr(7,3)){if("BIOMOLECULE:"===l.substr(11,12)){var Ot=l.substr(23).trim();/^(0|[1-9][0-9]*)$/.test(Ot)&&(Ot="BU"+Ot),c=new uv(Ot),Q[Ot]=c}else if("BIOMT"===l.substr(13,5)){var Dt=l.split(/\s+/),Nt=parseInt(l[18])-1;0===Nt&&(h=new v,u.matrixList.push(h));var kt=h.elements;kt[0+Nt]=parseFloat(Dt[4]),kt[4+Nt]=parseFloat(Dt[5]),kt[8+Nt]=parseFloat(Dt[6]),kt[12+Nt]=parseFloat(Dt[7])}else if("APPLY THE FOLLOWING TO CHAINS:"===l.substr(11,30)||"                   AND CHAINS:"===l.substr(11,30)){"APPLY"===l.substr(11,5)&&(u=c.addPart());for(var Ft=l.substr(41,30).split(","),Bt=0,zt=Ft.length;Bt<zt;++Bt){var Ut=Ft[Bt].trim();Ut&&u.chainList.push(Ut)}}}else if("HEADER"===p)j.id=l.substr(62,4);else if("TITLE "===p)j.title+=(j.title?" ":"")+l.substr(10,70).trim();else if("MODEL "===p)mt=!0;else if("ENDMDL"===p||l.startsWith("END")){if(mt)continue;X&&!K&&(Y.push(new Float32Array(a)),K=!0),ft+=1,mt=!0}else if("MTRIX"===l.substr(0,5)){if("1"===l[59])continue;var jt=l.split(/\s+/),Gt=jt[1].trim();if("1"===l[5]&&"1"===Gt){c=new uv("NCS"),Q.NCS=c,u=c.addPart()}var Vt=parseInt(l[5])-1;0===Vt&&(h=new v,u.matrixList.push(h));var $t=h.elements;$t[0+Vt]=parseFloat(jt[2]),$t[4+Vt]=parseFloat(jt[3]),$t[8+Vt]=parseFloat(jt[4]),$t[12+Vt]=parseFloat(jt[5])}else if("ORIGX"===l.substr(0,5)){tt.origx||(tt.origx=new v);var Ht=l.split(/\s+/),Wt=parseInt(l[5])-1,Xt=tt.origx.elements;Xt[0+Wt]=parseFloat(Ht[1]),Xt[4+Wt]=parseFloat(Ht[2]),Xt[8+Wt]=parseFloat(Ht[3]),Xt[12+Wt]=parseFloat(Ht[4])}else if("SCALE"===l.substr(0,5)){tt.scale||(tt.scale=new v);var qt=l.split(/\s+/),Yt=parseInt(l[5])-1,Zt=tt.scale.elements;Zt[0+Yt]=parseFloat(qt[1]),Zt[4+Yt]=parseFloat(qt[2]),Zt[8+Yt]=parseFloat(qt[3]),Zt[12+Yt]=parseFloat(qt[4])}else if("CRYST1"===p){var Kt=parseFloat(l.substr(6,9)),Qt=parseFloat(l.substr(15,9)),Jt=parseFloat(l.substr(24,9)),te=parseFloat(l.substr(33,7)),ee=parseFloat(l.substr(40,7)),ie=parseFloat(l.substr(47,7)),re=l.substr(55,11).trim(),ne=new Float32Array(9);ne[0]=Kt,ne[4]=Qt,ne[8]=Jt,Z.push(ne),0===ft&&(tt.a=Kt,tt.b=Qt,tt.c=Jt,tt.alpha=te,tt.beta=ee,tt.gamma=ie,tt.spacegroup=re)}}t.Debug&&cf.time("PdbParser._parse "+this.name);var i=!1,r=this.streamer.peekLines(1)[0],n=r.substr(62,4),o=r.substr(72,4);n===o&&o.trim()&&(i=!0);var a,s,c,u,h,l,p,d,f,m,g,y,b,x,_,w,S,A,M,P,T,E,C,I,R,L,O,D,N,k,F,B,z="pqr"===this.type,U=/\s+/,j=this.structure,G=this.structureBuilder,V=this.hex,$=10,H=10,W=this.firstModelOnly,X=this.asTrajectory,q=this.cAlphaOnly,Y=j.frames,Z=j.boxes,K=!1,Q=j.biomolDict,J={},tt={},et={},it=[],rt=["MOL_ID","MOLECULE","CHAIN","FRAGMENT","SYNONYM","EC","ENGINEERED","MUTATION","OTHER_DETAILS"],nt={},ot={},at={helices:[],sheets:[]},st=at.helices,ct=at.sheets,ut=j.atomMap,ht=j.atomStore;ht.resize(Math.round(this.streamer.data.length/80));var lt=j.getAtomProxy(),pt=j.getAtomProxy(),dt=0,ft=0,mt=!0;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)});var gt=it.length;if(it.length){j.eachChain(function(t){t.entityIndex=gt}),it.forEach(function(t,e){var i=t.chainList.map(function(t){return nt[t]});j.entityList.push(new Ix(j,e,t.name,"polymer",i))});var vt=it.length,yt=j.getResidueProxy(),bt={};j.eachChain(function(t){t.entityIndex===gt&&(yt.index=t.residueOffset,bt[yt.resname]||(bt[yt.resname]=[]),bt[yt.resname].push(t.index))}),Object.keys(bt).forEach(function(t){var e=bt[t],i="non-polymer",r=ot[t]||t;Fg.includes(t)&&(r="water",i="water"),j.entityList.push(new Ix(j,vt,r,i,e)),vt+=1})}void 0!==tt.a?j.unitcell=new Lx(tt):j.unitcell=void 0,(st.length||ct.length)&&rs(j,at),G.finalize(),j.finalizeAtoms(),i||ns(j),os(j),j.finalizeBonds(),st.length||ct.length||dv(j),hs(j),t.Debug&&cf.timeEnd("PdbParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("pdb",Dx),ff.add("pdb1",Dx),ff.add("ent",Dx);var Nx=/\s+/,kx=/'((?:(?!'\s).)*)'|"((?:(?!"\s).)*)"|(\S+)/g,Fx=/"/g,Bx=/^['"]+|['"]+$/g,zx=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"cif"},i.prototype._parse=function(){function e(e,q,Y){for(var Z=e;Z<q;++Z)if(n=Y[Z],((o=n.trim())||L||N)&&"#"!==o[0])if("data_"===o.substring(0,5))C.data=o.substring(5).trim();else if(";"===o[0])L?(N?(B===F.length&&(B=0),F[B].push(O),B+=1):!1===U?C[z]=O:C[z][U]=O,L=!1,O=null):(L=!0,O=o.substring(1));else if("loop_"===o)N=!0,k=!0,F.length=0,G.length=0,B=0;else if("_"===o[0]){var K,Q,J;if(N&&!k&&(N=!1),N)Q=(K=o.split("."))[0].substring(1),J=K[1],1===K.length?(J=!1,C[Q]||(C[Q]=[]),F.push(C[Q])):(C[Q]||(C[Q]={}),C[Q][J]?t.Debug&&cf.warn(Q,J,"already exists"):(C[Q][J]=[],F.push(C[Q][J]),G.push(J))),z=Q,U=J,j=!0;else{var tt=o.match(kx),et=tt[0],it=tt[1];Q=(K=et.split("."))[0].substring(1),J=K[1],1===K.length?(J=!1,C[Q]=it):(C[Q]||(C[Q]={}),C[Q][J]?t.Debug&&cf.warn(Q,J,"already exists"):C[Q][J]=it),it||(D=!0),z=Q,U=J}}else if(L)O+=n;else if(N){if(!o)continue;if("atom_site"===z){var rt=o.split(Nx);j&&(a=G.indexOf("auth_asym_id"),s=G.indexOf("auth_seq_id"),c=G.indexOf("label_atom_id"),u=G.indexOf("label_comp_id"),h=G.indexOf("label_asym_id"),l=G.indexOf("label_entity_id"),p=G.indexOf("label_alt_id"),y=G.indexOf("Cartn_x"),b=G.indexOf("Cartn_y"),x=G.indexOf("Cartn_z"),f=G.indexOf("id"),m=G.indexOf("type_symbol"),d=G.indexOf("group_PDB"),_=G.indexOf("B_iso_or_equiv"),g=G.indexOf("pdbx_PDB_model_num"),v=G.indexOf("pdbx_PDB_ins_code"),w=G.indexOf("occupancy"),j=!1,H=parseInt(rt[g]),P&&(i=[],r=0));var nt=parseInt(rt[g]);if(H!==nt&&(P&&(0===X&&E.push(new Float32Array(i)),i=new Float32Array(3*$.count),E.push(i),r=0),X+=1),H=nt,M&&X>0)continue;var ot=rt[c].replace(Fx,"");if(T&&"CA"!==ot)continue;var at=parseFloat(rt[y]),st=parseFloat(rt[b]),ct=parseFloat(rt[x]);if(P){var ut=3*r;if(i[ut+0]=at,i[ut+1]=st,i[ut+2]=ct,r+=1,X>0)continue}var ht=rt[u],lt=parseInt(rt[s]),pt=rt[v];pt="?"===pt?"":pt;var dt=rt[a],ft=rt[h],mt="H"===rt[d][0]?1:0,gt=rt[m],vt=parseFloat(rt[_]),yt=parseFloat(rt[w]),bt=rt[p];if(bt="."===bt?"":bt,$.growIfFull(),$.atomTypeId[W]=V.add(ot,gt),$.x[W]=at,$.y[W]=st,$.z[W]=ct,$.serial[W]=parseInt(rt[f]),$.bfactor[W]=isNaN(vt)?0:vt,$.occupancy[W]=isNaN(yt)?0:yt,$.altloc[W]=bt.charCodeAt(0),A.addAtom(X,dt,ft,ht,lt,mt,void 0,pt),t.Debug){var xt=I[ft];void 0!==xt&&xt!==dt&&t.Debug&&cf.warn(xt,dt)}I[ft]=dt;var _t=rt[l];R[_t]||(R[_t]=new Set),R[_t].add(S.chainStore.count-1),W+=1}else{var wt=o.match(kx),St=wt.length;B===F.length&&(B=0);for(var At=0;At<St;++At)F[B+At].push(wt[At]);B+=St}k=!1}else if("'"===o[0]&&"'"===o[o.length-1]){var Mt=o.substring(1,o.length-1);!1===U?C[z]=Mt:C[z][U]=Mt}else D?!1===U?C[z]=o:C[z][U]=o:t.Debug&&cf.log("CifParser._parse: unknown state",o);else L=!1,N=!1,D=!1,F.length=0,B=null,z=null,U=null,j=null,G.length=0}cf.time("CifParser._parse "+this.name);var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S=this.structure,A=this.structureBuilder,M=this.firstModelOnly,P=this.asTrajectory,T=this.cAlphaOnly,E=S.frames,C={},I={},R={},L=!1,O=null,D=!1,N=!1,k=!1,F=[],B=null,z=null,U=null,j=null,G=[],V=S.atomMap,$=S.atomStore;$.resize(this.streamer.data.length/100);var H,W=0,X=0;if(this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),C.chem_comp&&C.chem_comp_atom)Ks(C,S,A),A.finalize(),S.finalizeAtoms(),S.finalizeBonds(),ps(S);else if(C.atom_site_type_symbol&&C.atom_site_label&&C.atom_site_fract_x)Qs(C,S,A),A.finalize(),S.finalizeAtoms(),os(S),S.finalizeBonds();else{var q=Js(C,S,I);if(tc(C,S,I),ec(C,S,I),ic(C,S,R),C.struct&&C.struct.title&&(S.title=C.struct.title.trim().replace(Bx,"")),C.entry&&C.entry.id&&(S.id=C.entry.id.trim().replace(Bx,"")),C.database_PDB_rev){if(C.database_PDB_rev.date){Xs(C.database_PDB_rev,"date");var Y=C.database_PDB_rev.date.filter(qs);Y.length&&(S.header.releaseDate=Y[Y.length-1])}if(C.database_PDB_rev.date_original){Xs(C.database_PDB_rev,"date_original");var Z=C.database_PDB_rev.date_original.filter(qs);Z.length&&(S.header.depositionDate=Z[Z.length-1])}}C.reflns&&C.reflns.d_resolution_high?qs(C.reflns.d_resolution_high)&&(S.header.resolution=parseFloat(C.reflns.d_resolution_high)):C.refine&&C.refine.ls_d_res_high&&qs(C.refine.ls_d_res_high)&&(S.header.resolution=parseFloat(C.refine.ls_d_res_high)),C.refine&&C.refine.ls_R_factor_R_free&&qs(C.refine.ls_R_factor_R_free)&&(S.header.rFree=parseFloat(C.refine.ls_R_factor_R_free)),C.refine&&C.refine.ls_R_factor_R_work&&qs(C.refine.ls_R_factor_R_work)&&(S.header.rWork=parseFloat(C.refine.ls_R_factor_R_work)),C.exptl&&C.exptl.method&&(Xs(C.exptl,"method"),S.header.experimentalMethods=C.exptl.method.map(function(t){return t.replace(Bx,"")})),A.finalize(),S.finalizeAtoms(),os(S),S.finalizeBonds(),q?rs(S,q):dv(S),hs(S),S.extraData.cif=C}t.Debug&&cf.timeEnd("CifParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("cif",zx),ff.add("mcif",zx),ff.add("mmcif",zx);var Ux=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"gro"},i.prototype._parse=function(){function e(t,e,n){for(var l=t;l<e;++l){var T=++P-1,E=n[l];if(E)if(T%_==0)s&&(i=new Float32Array(3*x),u.push(i),r=0);else if(T%_==1);else if(T%_==_-1){var C=E.trim().split(/\s+/),I=new Float32Array(9);if(I[0]=10*parseFloat(C[0]),I[4]=10*parseFloat(C[1]),I[8]=10*parseFloat(C[2]),h.push(I),a)return!0;M+=1}else{if(p=E.substr(10,5).trim(),c&&"CA"!==p)continue;var R=10*parseFloat(E.substr(v,g)),L=10*parseFloat(E.substr(y,g)),O=10*parseFloat(E.substr(b,g));if(s){var D=3*r;if(i[D+0]=R,i[D+1]=L,i[D+2]=O,r+=1,T>_)continue}d=E.substr(5,5).trim(),f=parseInt(E.substr(0,5)),m=parseInt(E.substr(15,5)),S.growIfFull(),S.atomTypeId[A]=w.add(p),S.x[A]=R,S.y[A]=L,S.z[A]=O,S.serial[A]=m,o.addAtom(M,"","",d,f,0,"l"),A+=1}}}t.Debug&&cf.time("GroParser._parse "+this.name);var i,r,n=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=this.cAlphaOnly,u=n.frames,h=n.boxes,l=this.streamer.peekLines(3);n.title=l[0].trim();var p,d,f,m,g=5+(l[2].length-l[2].lastIndexOf(".")-1),v=20,y=20+g,b=20+2*g,x=parseInt(l[1]),_=x+3,w=n.atomMap,S=n.atomStore;S.resize(x);var A=0,M=0,P=0;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),o.finalize(),n.finalizeAtoms(),ns(n),os(n),n.finalizeBonds(),dv(n),t.Debug&&cf.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("gro",Ux);var jx=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],Gx=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(jx),Vx={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)},$x=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"mmtf"},i.prototype._parse=function(){t.Debug&&cf.time("MmtfParser._parse "+this.name);var e,i,r,n,o,a=this.structure,s=Ac(wc(this.streamer.data));["depositionDate","releaseDate","resolution","rFree","rWork","experimentalMethods"].forEach(function(t){void 0!==s[t]&&(a.header[t]=s[t])});var c,u,h,l,p,d;if(a.id=s.structureId,a.title=s.title,this.firstModelOnly||this.asTrajectory){for(p=1,h=0,e=0,i=l=s.chainsPerModel[0];e<i;++e)h+=s.groupsPerChain[e];for(u=0,e=0,i=h;e<i;++e)u+=(o=s.groupList[s.groupTypeList[e]]).atomNameList.length;c=s.numBonds,d=[l]}else c=s.numBonds,u=s.numAtoms,h=s.numGroups,l=s.numChains,p=s.numModels,d=s.chainsPerModel;if(c+=h,this.asTrajectory)for(e=0,i=s.numModels;e<i;++e){var f=new Float32Array(3*u),m=u*e;for(r=0;r<u;++r){var g=3*r,y=r+m;f[g]=s.xCoordList[y],f[g+1]=s.yCoordList[y],f[g+2]=s.zCoordList[y]}a.frames.push(f)}var b=new Uint32Array(c),x=new Uint32Array(c),_=new Uint8Array(c),w=new Uint32Array(u),S=new Uint32Array(h),A=new Uint32Array(h),M=new Uint16Array(h),P=new Uint16Array(l),T=new Uint32Array(l),E=new Uint32Array(l),C=new Uint32Array(p),I=new Uint32Array(p),R=0;for(e=0,i=p;e<i;++e){var L=d[e];for(C[e]=R,I[e]=L,r=0;r<L;++r)P[r+R]=e;R+=L}var O=s.groupsPerChain,D=0;for(e=0,i=l;e<i;++e){var N=O[e];for(T[e]=D,E[e]=N,r=0;r<N;++r)S[r+D]=e;D+=N}var k=0,F=0;for(e=0,i=h;e<i;++e){var B=(o=s.groupList[s.groupTypeList[e]]).atomNameList.length,z=o.bondAtomList,U=o.bondOrderList;for(r=0,n=U.length;r<n;++r)b[F]=k+z[2*r],x[F]=k+z[2*r+1],_[F]=U[r],F+=1;for(A[e]=k,M[e]=B,r=0;r<B;++r)w[k]=e,k+=1}var j=s.bondAtomList;if(j)for(s.bondOrderList&&_.set(s.bondOrderList,F),e=0,i=j.length;e<i;e+=2){var G=j[e],V=j[e+1];G<u&&V<u&&(b[F]=G,x[F]=V,F+=1)}a.bondStore.length=_.length,a.bondStore.count=F,a.bondStore.atomIndex1=b,a.bondStore.atomIndex2=x,a.bondStore.bondOrder=_,a.atomStore.length=u,a.atomStore.count=u,a.atomStore.residueIndex=w,a.atomStore.atomTypeId=new Uint16Array(u),a.atomStore.x=s.xCoordList.subarray(0,u),a.atomStore.y=s.yCoordList.subarray(0,u),a.atomStore.z=s.zCoordList.subarray(0,u),a.atomStore.serial=s.atomIdList.subarray(0,u),a.atomStore.bfactor=s.bFactorList.subarray(0,u),a.atomStore.altloc=s.altLocList.subarray(0,u),a.atomStore.occupancy=s.occupancyList.subarray(0,u),a.residueStore.length=h,a.residueStore.count=h,a.residueStore.chainIndex=S,a.residueStore.residueTypeId=s.groupTypeList,a.residueStore.atomOffset=A,a.residueStore.atomCount=M,a.residueStore.resno=s.groupIdList.subarray(0,h),a.residueStore.sstruc=s.secStructList.subarray(0,h),a.residueStore.inscode=s.insCodeList.subarray(0,h),a.chainStore.length=l,a.chainStore.count=l,a.chainStore.entityIndex=new Uint16Array(l),a.chainStore.modelIndex=P,a.chainStore.residueOffset=T,a.chainStore.residueCount=E,a.chainStore.chainname=s.chainNameList.subarray(0,4*l),a.chainStore.chainid=s.chainIdList.subarray(0,4*l),a.modelStore.length=p,a.modelStore.count=p,a.modelStore.chainOffset=C,a.modelStore.chainCount=I;var $={};for(e=0,i=s.groupList.length;e<i;++e){var H=s.groupList[e],W=[];for(r=0,n=H.atomNameList.length;r<n;++r){var X=H.elementList[r].toUpperCase(),q=H.atomNameList[r];W.push(a.atomMap.add(q,X))}var Y=H.chemCompType.toUpperCase(),Z=Ag.includes(Y),K=H.bondOrderList.length,Q=new Array(K),J=new Array(K);for(r=0;r<K;++r)Q[r]=H.bondAtomList[2*r],J[r]=H.bondAtomList[2*r+1];var tt={atomIndices1:Q,atomIndices2:J,bondOrders:H.bondOrderList};$[e]=a.residueMap.add(H.groupName,W,Z,Y,tt)}for(e=0,i=h;e<i;++e)a.residueStore.residueTypeId[e]=$[a.residueStore.residueTypeId[e]];for(e=0,i=a.atomStore.count;e<i;++e){var et=a.atomStore.residueIndex[e],it=a.residueMap.list[a.residueStore.residueTypeId[et]],rt=a.residueStore.atomOffset[et];a.atomStore.atomTypeId[e]=it.atomTypeIdList[e-rt]}if(s.secStructList){var nt=s.secStructList.length;for(e=0,i=a.residueStore.count;e<i;++e){var ot=Vx[a.residueStore.sstruc[e%nt]];void 0!==ot&&(a.residueStore.sstruc[e]=ot)}}if(s.entityList&&s.entityList.forEach(function(t,e){a.entityList[e]=new Ix(a,e,t.description,t.type,t.chainIndexList)}),s.bioAssemblyList&&s.bioAssemblyList.forEach(function(t,e){var i=e+1,r=new uv(i);a.biomolDict["BU"+i]=r;var n={};t.transformList.forEach(function(t){var e=(new v).fromArray(t.matrix).transpose(),i=t.chainIndexList.map(function(t){for(var e="",i=0;i<4;++i){var r=s.chainNameList[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e}),o=n[i];o?o.matrixList.push(e):n[i]=r.addPart([e],i)})}),s.ncsOperatorList){var at=new uv("NCS"),st=at.addPart();s.ncsOperatorList.forEach(function(t){var e=(new v).fromArray(t).transpose();st.matrixList.push(e)}),st.matrixList.length>0&&(a.biomolDict.NCS=at)}var ct=s.unitCell;ct&&Array.isArray(ct)&&ct[0]?a.unitcell=new Lx({a:ct[0],b:ct[1],c:ct[2],alpha:ct[3],beta:ct[4],gamma:ct[5],spacegroup:s.spaceGroup}):a.unitcell=void 0,us(a,!0),cs(a,!0),a.finalizeAtoms(),a.finalizeBonds(),hs(a),t.Debug&&cf.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("mmtf",$x);var Hx=/\s+/,Wx=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"mol2"},i.prototype._parse=function(){function e(t,e,A){for(var M,P=t;P<e;++P){var T=A[P].trim();if(""!==T&&"#"!==T[0])if("@"===T[0])"@<TRIPOS>MOLECULE"===T?(v=y,d=0,++m):"@<TRIPOS>ATOM"===T?(v=b,f=l.count,s&&(r=0,i=new Float32Array(3*g),c.push(i),m>0&&(u=!0))):v="@<TRIPOS>BOND"===T?x:0;else if(v===y)0===d?(n.title=T,n.id=T):1===d&&(M=T.split(Hx),g=parseInt(M[0])),++d;else if(v===b){if(M=T.split(Hx),a&&m>0)continue;var E=parseFloat(M[2]),C=parseFloat(M[3]),I=parseFloat(M[4]);if(s){var R=3*r;if(i[R+0]=E,i[R+1]=C,i[R+2]=I,r+=1,u)continue}var L=M[0],O=M[1],D=M[5].split(".")[0],N=M[6]?parseInt(M[6]):1,k=M[7]?M[7]:"",F=M[8]?parseFloat(M[8]):0;l.growIfFull(),l.atomTypeId[p]=h.add(O,D),l.x[p]=E,l.y[p]=C,l.z[p]=I,l.serial[p]=L,l.bfactor[p]=F,o.addAtom(m,"","",k,N,1),p+=1}else if(v===x){if(a&&m>0)continue;if(s&&m>0)continue;M=T.split(Hx),_.index=parseInt(M[1])-1+f,w.index=parseInt(M[2])-1+f;var B=S[M[3]];n.bondStore.addBond(_,w,B)}}}t.Debug&&cf.time("Mol2Parser._parse "+this.name);var i,r,n=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=n.frames,u=!1,h=n.atomMap,l=n.atomStore;l.resize(Math.round(this.streamer.data.length/60));var p=0,d=0,f=0,m=-1,g=0,v=0,y=1,b=2,x=3,_=n.getAtomProxy(),w=n.getAtomProxy(),S={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),o.finalize(),n.finalizeAtoms(),ns(n),cs(n,!0),us(n,!0),n.finalizeBonds(),ps(n),dv(n),t.Debug&&cf.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("mol2",Wx);var Xx=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,i),e}(Dx);ff.add("pqr",Xx);var qx=1,Yx=2,Zx=3,Kx=4,Qx=5,Jx=6,t_=/\s+/,e_=/(^\*|REMARK)*/,i_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"psf"},i.prototype._parse=function(){function e(t,e,a){for(var d=t;d<e;++d){var f=a[d].trim();if(f)if(i===Yx){var m=f.split(t_),g=parseInt(m[0]),v=parseInt(m[2]),y=m[3],b=m[4];u.growIfFull(),u.atomTypeId[l]=c.add(b),u.serial[l]=g,s.addAtom(0,"","",y,v,1),l+=1}else if(i===Zx)for(var x=f.split(t_),_=0,w=x.length;_<w;_+=2)r[p]=parseInt(x[_])-1,n[p]=parseInt(x[_+1])-1,o[p]=1,p+=1;else if(i===qx)h.push(f.replace(e_,"").trim());else if(i===Kx);else if(i===Qx);else if(i===Jx);else if(f.includes("!NATOM")){i=Yx;var S=parseInt(f.split(t_)[0]);u.resize(S)}else if(f.includes("!NBOND")){i=Zx;var A=parseInt(f.split(t_)[0]);r=new Uint32Array(A),n=new Uint32Array(A),o=new Uint8Array(A)}else f.includes("!NTITLE")?i=qx:f.includes("!NTHETA")?i=Kx:f.includes("!NPHI")?i=Qx:f.includes("!NIMPHI")&&(i=Jx);else i=void 0}}t.Debug&&cf.time("PsfParser._parse "+this.name);var i,r,n,o,a=this.structure,s=this.structureBuilder,c=a.atomMap,u=a.atomStore,h=[],l=0,p=0;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),a.title=h.join(" "),a.bondStore.length=o.length,a.bondStore.count=p,a.bondStore.atomIndex1=r,a.bondStore.atomIndex2=n,a.bondStore.bondOrder=o,s.finalize(),a.finalizeAtoms(),ns(a),a.finalizeBonds(),ps(a),t.Debug&&cf.timeEnd("PsfParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("psf",i_);var r_=/> <(.+)>/,n_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"sdf"},i.prototype._parse=function(){function e(t,e,a){for(var C=t;C<e;++C){var I=a[C];if("$$$$"===I.substr(0,4))v=-1,++y,b=p.count,x.push(w),w={},_=!1;else if(3===v)S=parseInt(I.substr(0,3)),A=parseInt(I.substr(3,3)),E=(T=P=(M=4)+S)+A,o&&(c=0,s=new Float32Array(3*S),u.push(s),y>0&&(h=!0));else if(v>=M&&v<P){if(n&&y>0)continue;var R=parseFloat(I.substr(0,10)),L=parseFloat(I.substr(10,10)),O=parseFloat(I.substr(20,10));if(o){var D=3*c;if(s[D+0]=R,s[D+1]=L,s[D+2]=O,c+=1,h)continue}var N=I.substr(31,3).trim(),k=N+(g+1);p.growIfFull(),p.atomTypeId[g]=l.add(k,N),p.x[g]=R,p.y[g]=L,p.z[g]=O,p.serial[g]=g,r.addAtom(y,"","","HET",1,1),g+=1}else if(v>=T&&v<E){if(n&&y>0)continue;if(o&&y>0)continue;f.index=parseInt(I.substr(0,3))-1+b,m.index=parseInt(I.substr(3,3))-1+b;var F=parseInt(I.substr(6,3));i.bondStore.addBond(f,m,F)}else(d=I.match(r_))?(_=d[1],w[_]=[]):!1!==_&&I&&w[_].push(I);++v}}t.Debug&&cf.time("SdfParser._parse "+this.name);var i=this.structure,r=this.structureBuilder,n=this.firstModelOnly,o=this.asTrajectory,a=this.streamer.peekLines(2);i.id=a[0].trim(),i.title=a[1].trim();var s,c,u=i.frames,h=!1,l=i.atomMap,p=i.atomStore;p.resize(Math.round(this.streamer.data.length/50));var d,f=i.getAtomProxy(),m=i.getAtomProxy(),g=0,v=0,y=0,b=0,x=[],_=!1,w={};i.extraData.sdf=x;var S,A,M,P,T,E;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),r.finalize(),i.finalizeAtoms(),i.finalizeBonds(),ps(i),t.Debug&&cf.timeEnd("SdfParser._parse "+this.name)},i.prototype._postProcess=function(){ps(this.structure)},Object.defineProperties(i.prototype,r),i}(Cx);ff.add("sdf",n_),ff.add("sd",n_);var o_=function(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[]},a_={type:{}};a_.type.get=function(){return"Frames"},Object.defineProperties(o_.prototype,a_);var s_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"dcd"},i.prototype._parse=function(){t.Debug&&cf.time("DcdParser._parse "+this.name);var e=this.streamer.data;e instanceof Uint8Array&&(e=e.buffer);var i,r,n=new DataView(e),o=this.frames,a=o.coordinates,s=o.boxes,c={},u=0,h=new Int32Array(e,0,23),l=h[0]!==n.getInt32(0);if(84!==h[0])for(r=e.byteLength,i=0;i<r;i+=4)n.setFloat32(i,n.getFloat32(i),!0);84!==h[0]&&cf.error("dcd bad format, header block start"),"CORD"!==String.fromCharCode(n.getUint8(4),n.getUint8(5),n.getUint8(6),n.getUint8(7))&&cf.error("dcd bad format, format string");var p=!1,d=!1,f=!1;0!==h[22]&&(p=!0,0!==h[12]&&(d=!0),1===h[13]&&(f=!0)),c.NSET=h[2],c.ISTART=h[3],c.NSAVC=h[4],c.NAMNF=h[10],c.DELTA=p?n.getFloat32(44,l):n.getFloat64(44,l),84!==h[22]&&cf.error("dcd bad format, header block end"),u=u+84+8;var m=n.getInt32(u,l),g=u+1;if((m-4)%80!=0&&cf.error("dcd bad format, title block start"),c.TITLE=Cn(new Uint8Array(e,g,m)),n.getInt32(g+m+4-1,l)!==m&&cf.error("dcd bad format, title block end"),u=u+m+8,4!==n.getInt32(u,l)&&cf.error("dcd bad format, natom block start"),c.NATOM=n.getInt32(u+4,l),4!==n.getInt32(u+8,l)&&cf.error("dcd bad format, natom block end"),u=u+4+8,c.NAMNF>0)return void cf.error("dcd format with fixed atoms unsupported, aborting");var v=c.NATOM,y=4*v;for(i=0,r=c.NSET;i<r;++i){if(d){u+=4;var b=new Float32Array(9);b[0]=n.getFloat64(u,l),b[4]=n.getFloat64(u+16,l),b[8]=n.getFloat64(u+40,l),s.push(b),u+=48,u+=4}for(var x=new Float32Array(3*v),_=0;_<3;++_){n.getInt32(u,l)!==y&&cf.error("dcd bad format, coord block start",i,_),u+=4;for(var w=new Float32Array(e,u,v),S=0;S<v;++S)x[3*S+_]=w[S];u+=y,n.getInt32(u,l)!==y&&cf.error("dcd bad format, coord block end",i,_),u+=4}a.push(x),f&&(u+=4+n.getInt32(u,l)+4)}t.Debug&&cf.timeEnd("DcdParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(function(t){function e(e,i){t.call(this,e,i),this.frames=new o_(this.name,this.path)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"trajectory"},i.__objName.get=function(){return"frames"},Object.defineProperties(e.prototype,i),e}(Tx));ff.add("dcd",s_);var c_=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.volume=new Zg(this.name,this.path),this.voxelSize=gn(r.voxelSize,1)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"volume"},i.__objName.get=function(){return"volume"},e.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix())},e.prototype.getMatrix=function(){return new v},Object.defineProperties(e.prototype,i),e}(Tx),u_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"cube"},i.prototype._parse=function(){function e(t,e){var i=n[t].trim().split(a)[e];return parseFloat(i)}function i(t,e,i){for(var r=t;r<e;++r){var n=i[r].trim();if(""!==n&&h>=o.atomCount+6+l)for(var s=0,p=(n=n.split(a)).length;s<p;++s)1!==n.length&&(c[u]=parseFloat(n[s]),++u);++h}}t.Debug&&cf.time("CubeParser._parse "+this.name);var r=this.volume,n=this.streamer.peekLines(6),o={},a=/\s+/,s=.529177210859*this.voxelSize;o.atomCount=Math.abs(e(2,0)),o.originX=.529177210859*e(2,1),o.originY=.529177210859*e(2,2),o.originZ=.529177210859*e(2,3),o.NVX=e(3,0),o.NVY=e(4,0),o.NVZ=e(5,0),o.basisX=new g(e(3,1),e(3,2),e(3,3)).multiplyScalar(s),o.basisY=new g(e(4,1),e(4,2),e(4,3)).multiplyScalar(s),o.basisZ=new g(e(5,1),e(5,2),e(5,3)).multiplyScalar(s);var c=new Float32Array(o.NVX*o.NVY*o.NVZ),u=0,h=0,l=e(2,0)>0?0:1;this.streamer.eachChunkOfLines(function(t){i(0,t.length,t)}),r.header=o,r.setData(c,o.NVZ,o.NVY,o.NVX),t.Debug&&cf.timeEnd("CubeParser._parse "+this.name)},i.prototype.getMatrix=function(){var t=this.volume.header,e=new v;return e.multiply((new v).makeTranslation(t.originX,t.originY,t.originZ)),e.multiply((new v).makeBasis(t.basisZ,t.basisY,t.basisX)),e},Object.defineProperties(i.prototype,r),i}(c_);ff.add("cub",u_),ff.add("cube",u_);var h_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"dsn6"},i.prototype._parse=function(){t.Debug&&cf.time("Dsn6Parser._parse "+this.name);var e=this.streamer.data;e instanceof Uint8Array&&(e=e.buffer);var i,r,n=this.volume,o={},a=new Int16Array(e),s=new Uint8Array(e),c=String.fromCharCode.apply(null,s.subarray(0,512));if(c.startsWith(":-)"))o.xStart=parseInt(c.substr(10,5)),o.yStart=parseInt(c.substr(15,5)),o.zStart=parseInt(c.substr(20,5)),o.xExtent=parseInt(c.substr(32,5)),o.yExtent=parseInt(c.substr(38,5)),o.zExtent=parseInt(c.substr(42,5)),o.xRate=parseInt(c.substr(52,5)),o.yRate=parseInt(c.substr(58,5)),o.zRate=parseInt(c.substr(62,5)),o.xlen=parseFloat(c.substr(73,10))*this.voxelSize,o.ylen=parseFloat(c.substr(83,10))*this.voxelSize,o.zlen=parseFloat(c.substr(93,10))*this.voxelSize,o.alpha=parseFloat(c.substr(103,10)),o.beta=parseFloat(c.substr(113,10)),o.gamma=parseFloat(c.substr(123,10)),i=parseFloat(c.substr(138,12))/100,r=parseInt(c.substr(155,8));else{if(100!==a[18])for(var u=0,h=a.length;u<h;++u){var l=a[u];a[u]=(255&l)<<8|l>>8&255}o.xStart=a[0],o.yStart=a[1],o.zStart=a[2],o.xExtent=a[3],o.yExtent=a[4],o.zExtent=a[5],o.xRate=a[6],o.yRate=a[7],o.zRate=a[8];var p=1/a[17],d=p*this.voxelSize;o.xlen=a[9]*d,o.ylen=a[10]*d,o.zlen=a[11]*d,o.alpha=a[12]*p,o.beta=a[13]*p,o.gamma=a[14]*p,i=a[15]/100,r=a[16]}n.header=o,cf.log(o,i,r);for(var f=new Float32Array(o.xExtent*o.yExtent*o.zExtent),m=512,g=Math.ceil(o.xExtent/8),v=Math.ceil(o.yExtent/8),y=Math.ceil(o.zExtent/8),b=0;b<y;++b)for(var x=0;x<v;++x)for(var _=0;_<g;++_)for(var w=0;w<8;++w)for(var S=8*b+w,A=0;A<8;++A)for(var M=8*x+A,P=0;P<8;++P){var T=8*_+P;if(!(T<o.xExtent&&M<o.yExtent&&S<o.zExtent)){m+=8-P;break}f[(T*o.yExtent+M)*o.zExtent+S]=(s[m]-r)/i,++m}n.setData(f,o.zExtent,o.yExtent,o.xExtent),t.Debug&&cf.timeEnd("Dsn6Parser._parse "+this.name)},i.prototype.getMatrix=function(){var t=this.volume.header,e=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],r=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[0,e,i,r],o=[0,t.xRate,t.yRate,t.zRate],a=[0,1,2,3],s=new v;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.multiply((new v).makeRotationY(Hn(90))),s.multiply((new v).makeTranslation(-t.zStart,t.yStart,t.xStart)),s.multiply((new v).makeScale(-1,1,1)),s},Object.defineProperties(i.prototype,r),i}(c_);ff.add("dsn6",h_),ff.add("brix",h_);var l_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"dx"},i.prototype._parse=function(){function e(t,e,i){for(var r=t;r<e;++r){if(h<c&&l>a){var n=i[r].trim();if(""!==n)for(var o=n.split(s),p=0,d=o.length;p<d;++p)u[h]=parseFloat(o[p]),++h}++l}}t.Debug&&cf.time("DxParser._parse "+this.name);var i=this.volume,r=this.streamer.peekLines(30),n=this.parseHeaderLines(r),o=this.volume.header,a=n.dataLineStart,s=/\s+/,c=o.nx*o.ny*o.nz,u=new Float32Array(c),h=0,l=0;this.streamer.eachChunkOfLines(function(t){e(0,t.length,t)}),i.setData(u,o.nz,o.ny,o.nx),t.Debug&&cf.timeEnd("DxParser._parse "+this.name)},i.prototype.parseHeaderLines=function(t){for(var e=this,i={},r=t.length,n=0,o=0,a=0,s=0;s<r;++s){var c,u=t[s];if(u.startsWith("object 1"))c=u.split(/\s+/),i.nx=parseInt(c[5]),i.ny=parseInt(c[6]),i.nz=parseInt(c[7]);else if(u.startsWith("origin"))c=u.split(/\s+/),i.xmin=parseFloat(c[1]),i.ymin=parseFloat(c[2]),i.zmin=parseFloat(c[3]);else if(u.startsWith("delta"))c=u.split(/\s+/),0===a?i.hx=parseFloat(c[1])*e.voxelSize:1===a?i.hy=parseFloat(c[2])*e.voxelSize:2===a&&(i.hz=parseFloat(c[3])*e.voxelSize),a+=1;else if(u.startsWith("object 3")){n=s,o+=u.length+1;break}o+=u.length+1}return this.volume.header=i,{dataLineStart:n,headerByteCount:o}},i.prototype.getMatrix=function(){var t=this.volume.header,e=new v;return e.multiply((new v).makeRotationY(Hn(90))),e.multiply((new v).makeTranslation(-t.zmin,t.ymin,t.xmin)),e.multiply((new v).makeScale(-t.hz,t.hy,t.hx)),e},Object.defineProperties(i.prototype,r),i}(c_);ff.add("dx",l_);var p_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"dxbin"},i.prototype._parse=function(){t.Debug&&cf.time("DxbinParser._parse "+this.name);var e=this.streamer.data;e instanceof Uint8Array&&(e=e.buffer);for(var i=In(new Uint8Array(e,0,1e3)),r=this.parseHeaderLines(i),n=this.volume.header,o=r.headerByteCount,a=n.nx*n.ny*n.nz,s=new DataView(e),c=new Float32Array(a),u=0;u<a;++u)c[u]=s.getFloat64(8*u+o,!0);this.volume.setData(c,n.nz,n.ny,n.nx),t.Debug&&cf.timeEnd("DxbinParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(l_);ff.add("dxbin",p_);var d_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"mrc"},i.prototype._parse=function(){t.Debug&&cf.time("MrcParser._parse "+this.name);var e=this.streamer.data;e instanceof Uint8Array&&(e=e.buffer);var i=this.volume,r={},n=new Int32Array(e,0,56),o=new Float32Array(e,0,56),a=new DataView(e);if(r.MAP=String.fromCharCode(a.getUint8(208),a.getUint8(209),a.getUint8(210),a.getUint8(211)),r.MACHST=[a.getUint8(212),a.getUint8(213)],17===r.MACHST[0]&&17===r.MACHST[1])for(var s=e.byteLength,c=0;c<s;c+=4)a.setFloat32(c,a.getFloat32(c),!0);r.NX=n[0],r.NY=n[1],r.NZ=n[2],r.MODE=n[3],r.NXSTART=n[4],r.NYSTART=n[5],r.NZSTART=n[6],r.MX=n[7],r.MY=n[8],r.MZ=n[9],r.xlen=o[10]*this.voxelSize,r.ylen=o[11]*this.voxelSize,r.zlen=o[12]*this.voxelSize,r.alpha=o[13],r.beta=o[14],r.gamma=o[15],r.MAPC=n[16],r.MAPR=n[17],r.MAPS=n[18],r.DMIN=o[19],r.DMAX=o[20],r.DMEAN=o[21],r.ISPG=n[22],r.NSYMBT=n[23],r.LSKFLG=n[24],r.originX=o[49],r.originY=o[50],r.originZ=o[51],r.ARMS=o[54],i.header=r;var u;if(2===r.MODE)u=new Float32Array(e,1024+r.NSYMBT,r.NX*r.NY*r.NZ);else if(0===r.MODE){if(u=new Float32Array(new Int8Array(e,1024+r.NSYMBT,r.NX*r.NY*r.NZ)),-128===n[39]&&127===n[40])for(var h=(r.DMAX-r.DMIN)/255,l=.5*(r.DMIN+r.DMAX+h),p=0,d=u.length;p<d;++p)u[p]=h*u[p]+l}else cf.error("MrcParser unknown mode",r.MODE);i.setData(u,r.NX,r.NY,r.NZ),t.Debug&&cf.timeEnd("MrcParser._parse "+this.name)},i.prototype.getMatrix=function(){var t=this.volume.header,e=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],r=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[0,e,i,r],o=[0,t.MX,t.MY,t.MZ],a=[0,t.MAPC,t.MAPR,t.MAPS],s=new v;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.setPosition(new g(t.originX,t.originY,t.originZ)),s.multiply((new v).makeTranslation(t.NXSTART,t.NYSTART,t.NZSTART)),s},Object.defineProperties(i.prototype,r),i}(c_);ff.add("mrc",d_),ff.add("ccp4",d_),ff.add("map",d_);var f_=function(e){function i(){e.apply(this,arguments)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{}};return r.type.get=function(){return"xplor"},i.prototype._parse=function(){function e(t){return t.trim().split(s).map(parseFloat)}function i(t,e,i){for(var r=t;r<e;++r){var n=i[r];if(v>=c&&(v-c)%y!=0&&g<f)for(var o=0;o<6;++o)m[g]=parseFloat(n.substr(12*o,12)),++g;++v}}t.Debug&&cf.time("XplorParser._parse "+this.name);var r,n=this.volume,o=this.streamer.peekLines(8),a={},s=/\s+/,c=(r=o[2].startsWith("REMARKS")?parseInt(o[1].substring(0,8))+2:5)+3,u=e(o[r]);a.NA=u[0],a.AMIN=u[1],a.AMAX=u[2],a.NB=u[3],a.BMIN=u[4],a.BMAX=u[5],a.NC=u[6],a.CMIN=u[7],a.CMAX=u[8];var h=e(o[r+1]);a.a=h[0]*this.voxelSize,a.b=h[1]*this.voxelSize,a.c=h[2]*this.voxelSize,a.alpha=h[3],a.beta=h[4],a.gamma=h[5];var l=a.AMAX-a.AMIN+1,p=a.BMAX-a.BMIN+1,d=a.CMAX-a.CMIN+1,f=l*p*d,m=new Float32Array(f),g=0,v=0,y=1+l*p/6;this.streamer.eachChunkOfLines(function(t){i(0,t.length,t)}),n.header=a,n.setData(m,l,p,d),t.Debug&&cf.timeEnd("XplorParser._parse "+this.name)},i.prototype.getMatrix=function(){var t=this.volume.header,e=[t.a,0,0],i=[t.b*Math.cos(Math.PI/180*t.gamma),t.b*Math.sin(Math.PI/180*t.gamma),0],r=[t.c*Math.cos(Math.PI/180*t.beta),t.c*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.c*t.c*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[0,e,i,r],o=[0,t.NA,t.NB,t.NC],a=[0,1,2,3],s=new v;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.multiply((new v).makeTranslation(t.AMIN,t.BMIN,t.CMIN)),s},Object.defineProperties(i.prototype,r),i}(c_);ff.add("xplor",f_),ff.add("cns",f_);var m_=function(t){function e(e,i){t.call(this,e,i),this.loader=this.getLoader(),this.surface=new qg(this.name,this.path)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"surface"},i.__objName.get=function(){return"surface"},e.prototype._parse=function(){var t=this.loader.parse(this.streamer.asText());this.surface.fromGeometry(t)},Object.defineProperties(e.prototype,i),e}(Tx);Mc.prototype={constructor:Mc,setPath:function(t){this.path=t},_createParserState:function(){var t={objects:[],object:{},vertices:[],normals:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);this.object={name:t||"",geometry:{vertices:[],normals:[]},fromDeclaration:!1!==e},this.objects.push(this.object)},parseVertexIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=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,n=this.object.geometry.vertices;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[i+0]),n.push(r[i+1]),n.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,n=this.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])},addFace:function(t,e,i,r,n,o,a,s){var c,u=this.vertices.length,h=this.parseVertexIndex(t,u),l=this.parseVertexIndex(e,u),p=this.parseVertexIndex(i,u);if(void 0===r?this.addVertex(h,l,p):(c=this.parseVertexIndex(r,u),this.addVertex(h,l,c),this.addVertex(l,p,c)),void 0!==n){var d=this.normals.length;h=this.parseNormalIndex(n,d),l=n===o?h:this.parseNormalIndex(o,d),p=n===a?h:this.parseNormalIndex(a,d),void 0===r?this.addNormal(h,l,p):(c=this.parseNormalIndex(s,d),this.addNormal(h,l,c),this.addNormal(l,p,c))}},addLineGeometry:function(t){var e=this;this.object.geometry.type="Line";for(var i=this.vertices.length,r=0,n=t.length;r<n;r++)e.addVertexLine(e.parseVertexIndex(t[r],i))}};return t.startObject("",!1),t},parse:function(t){var e=this,i=this._createParserState();-1!==t.indexOf("\r\n")&&(t=t.replace(/\r\n/g,"\n")),-1!==t.indexOf("\\\n")&&(t=t.replace(/\\\n/g,""));var r,n,o=t.split("\n"),a="",s="",c="",u=[],h="function"==typeof"".trimLeft;for(r=0,n=o.length;r<n;r++)if(a=o[r],a=h?a.trimLeft():a.trim(),0!==a.length&&"#"!==(s=a.charAt(0)))if("v"===s){if(" "===(c=a.charAt(1))&&null!==(u=e.regexp.vertex_pattern.exec(a)))i.vertices.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));else if("n"===c&&null!==(u=e.regexp.normal_pattern.exec(a)))i.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));else if("t"!==c||null===(u=e.regexp.uv_pattern.exec(a)))throw new Error("Unexpected vertex/normal/uv line: '"+a+"'")}else if("f"===s)if(null!==(u=e.regexp.face_vertex_uv_normal.exec(a)))i.addFace(u[1],u[4],u[7],u[10],u[3],u[6],u[9],u[12]);else if(null!==(u=e.regexp.face_vertex_uv.exec(a)));else if(null!==(u=e.regexp.face_vertex_normal.exec(a)))i.addFace(u[1],u[3],u[5],u[7],u[2],u[4],u[6],u[8]);else{if(null===(u=e.regexp.face_vertex.exec(a)))throw new Error("Unexpected face line: '"+a+"'");i.addFace(u[1],u[2],u[3],u[4])}else if("l"===s){var l=a.substring(1).trim().split(" "),p=[],d=[];if(-1===a.indexOf("/"))p=l;else for(var f=0,m=l.length;f<m;f++){var g=l[f].split("/");""!==g[0]&&p.push(g[0]),""!==g[1]&&d.push(g[1])}i.addLineGeometry(p,d)}else if(null!==(u=e.regexp.object_pattern.exec(a))){var v=u[0].substr(1).trim();i.startObject(v)}else if(e.regexp.material_use_pattern.test(a));else if(e.regexp.material_library_pattern.test(a));else if(null===(u=e.regexp.smoothing_pattern.exec(a))){if("\0"===a)continue;throw new Error("Unexpected line: '"+a+"'")}var y=[];for(r=0,n=i.objects.length;r<n;r++){var b=i.objects[r].geometry;if(0!==b.vertices.length){var x=new Ct;x.addAttribute("position",new St(new Float32Array(b.vertices),3)),b.normals.length>0?x.addAttribute("normal",new St(new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};var g_=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new Mc},Object.defineProperties(e.prototype,i),e}(m_);ff.add("obj",g_),Pc.prototype={constructor:Pc,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r<t.byteLength;r++)i+=String.fromCharCode(e[r]);return i},isASCII:function(t){return"ascii"===this.parseHeader(this.bin2str(t)).format},parse:function(t){return t instanceof ArrayBuffer?this.isASCII(t)?this.parseASCII(this.bin2str(t)):this.parseBinary(t):this.parseASCII(t)},parseHeader:function(t){var e=this,i="",r=0,n=/ply([\s\S]*)end_header\s/.exec(t);null!==n&&(i=n[1],r=n[0].length);for(var o,a,s,c={comments:[],elements:[],headerLength:r},u=i.split("\n"),h=0;h<u.length;h++){var l=u[h];if(""!==(l=l.trim()))switch(s=l.split(/\s+/),a=s.shift(),l=s.join(" "),a){case"format":c.format=s[0],c.version=s[1];break;case"comment":c.comments.push(l);break;case"element":void 0!==o&&c.elements.push(o),(o={}).name=s[0],o.count=parseInt(s[1]),o.properties=[];break;case"property":o.properties.push(function(t,e){var i={type:t[0]};return"list"===i.type?(i.name=t[3],i.countType=t[1],i.itemType=t[2]):i.name=t[1],i.name in e&&(i.name=e[i.name]),i}(s,e.propertyNameMapping));break;default:console.log("unhandled",a,s)}}return void 0!==o&&c.elements.push(o),c},parseASCIINumber:function(t,e){switch(e){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(t);case"float":case"double":case"float32":case"float64":return parseFloat(t)}},parseASCIIElement:function(t,e){for(var i=this,r=e.split(/\s+/),n={},o=0;o<t.length;o++)if("list"===t[o].type){for(var a=[],s=i.parseASCIINumber(r.shift(),t[o].countType),c=0;c<s;c++)a.push(i.parseASCIINumber(r.shift(),t[o].itemType));n[t[o].name]=a}else n[t[o].name]=i.parseASCIINumber(r.shift(),t[o].type);return n},parseASCII:function(t){var e,i=this,r=new wt,n=this.parseHeader(t),o="";null!==(e=/end_header\s([\s\S]*)$/.exec(t))&&(o=e[1]);var a=o.split("\n"),s=0,c=0;r.useColor=!1;for(var u=0;u<a.length;u++){var h=a[u];if(""!==(h=h.trim())){c>=n.elements[s].count&&(s++,c=0);var l=i.parseASCIIElement(n.elements[s].properties,h);i.handleElement(r,n.elements[s].name,l),c++}}return this.postProcess(r)},postProcess:function(t){if(t.useColor){for(var e=0;e<t.faces.length;e++)t.faces[e].vertexColors=[t.colors[t.faces[e].a],t.colors[t.faces[e].b],t.colors[t.faces[e].c]];t.elementsNeedUpdate=!0}return t.computeBoundingSphere(),t},handleElement:function(t,e,i){if("vertex"===e){if(t.vertices.push(new g(i.x,i.y,i.z)),"red"in i&&"green"in i&&"blue"in i){t.useColor=!0;var r=new tt;r.setRGB(i.red/255,i.green/255,i.blue/255),t.colors.push(r)}}else if("face"===e){var n=i.vertex_indices;3===n.length?t.faces.push(new xt(n[0],n[1],n[2])):4===n.length&&t.faces.push(new xt(n[0],n[1],n[3]),new xt(n[1],n[2],n[3]))}},binaryRead:function(t,e,i,r){switch(i){case"int8":case"char":return[t.getInt8(e),1];case"uint8":case"uchar":return[t.getUint8(e),1];case"int16":case"short":return[t.getInt16(e,r),2];case"uint16":case"ushort":return[t.getUint16(e,r),2];case"int32":case"int":return[t.getInt32(e,r),4];case"uint32":case"uint":return[t.getUint32(e,r),4];case"float32":case"float":return[t.getFloat32(e,r),4];case"float64":case"double":return[t.getFloat64(e,r),8]}},binaryReadElement:function(t,e,i,r){for(var n,o=this,a={},s=0,c=0;c<i.length;c++)if("list"===i[c].type){var u=[],h=(n=o.binaryRead(t,e+s,i[c].countType,r))[0];s+=n[1];for(var l=0;l<h;l++)n=o.binaryRead(t,e+s,i[c].itemType,r),u.push(n[0]),s+=n[1];a[i[c].name]=u}else n=o.binaryRead(t,e+s,i[c].type,r),a[i[c].name]=n[0],s+=n[1];return[a,s]},parseBinary:function(t){for(var e,i=this,r=new wt,n=this.parseHeader(this.bin2str(t)),o="binary_little_endian"===n.format,a=new DataView(t,n.headerLength),s=0,c=0;c<n.elements.length;c++)for(var u=0;u<n.elements[c].count;u++){s+=(e=i.binaryReadElement(a,s,n.elements[c].properties,o))[1];var h=e[0];i.handleElement(r,n.elements[c].name,h)}return this.postProcess(r)}};var v_=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{}};return i.type.get=function(){return"ply"},e.prototype.getLoader=function(){return new Pc},Object.defineProperties(e.prototype,i),e}(m_);ff.add("ply",v_);var y_=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.delimiter=gn(r.delimiter,","),this.comment=gn(r.comment,"#"),this.columnNames=gn(r.columnNames,!1),this.table={name:this.name,path:this.path,columnNames:[],data:[]}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"csv"},i.__objName.get=function(){return"table"},e.prototype._parse=function(){var t=this,e=this.table.data,i=new RegExp("\\s*"+this.delimiter+"\\s*"),r=0;this.streamer.eachChunkOfLines(function(n){for(var o=n.length,a=0;a<o;++a){var s=n[a].trim();if(!s.startsWith(t.comment)){var c=s.split(i);0===r?t.table.columnNames=c:s&&e.push(c),++r}}})},Object.defineProperties(e.prototype,i),e}(Tx);ff.add("csv",y_);var b_=function(t){function e(e,i){var r=i||{};t.call(this,e,r),this.string=gn(r.string,!1),this.json={name:this.name,path:this.path,data:{}}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"json"},i.__objName.get=function(){return"json"},e.prototype._parse=function(){this.streamer.isBinary()||this.string?this.json.data=JSON.parse(this.streamer.asText()):this.json.data=this.streamer.data},Object.defineProperties(e.prototype,i),e}(Tx);ff.add("json",b_);var x_=function(t){function e(e,i){t.call(this,e,i),this.text={name:this.name,path:this.path,data:""}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={type:{},__objName:{}};return i.type.get=function(){return"text"},i.__objName.get=function(){return"text"},e.prototype._parse=function(){this.text.data=this.streamer.asText()},Object.defineProperties(e.prototype,i),e}(Tx);ff.add("txt",x_),ff.add("text",x_);var __=/^['"]|['"]$/g,w_=/^<([\w-:.]+)\s*/,S_=/^([^<]*)/,A_=/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/,M_=function(e){function i(t,i){var r=i||{};e.call(this,t,r),this.useDomParser=gn(r.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={type:{},__objName:{}};return r.type.get=function(){return"xml"},r.__objName.get=function(){return"xml"},i.prototype.__xmlParser=function(t){return Ec(t)},i.prototype.__domParser=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")},i.prototype._parse=function(){t.Debug&&cf.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof window.Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),t.Debug&&cf.timeEnd("XmlParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(Tx);ff.add("xml",M_);var P_=function(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"},T_={type:{}};T_.type.get=function(){return"validation"},P_.prototype.fromXml=function(e){t.Debug&&cf.time("Validation.fromXml");var i=this.rsrzDict,r=this.rsccDict,n=this.clashDict,o=this.clashArray,a=this.geoDict,s=this.geoAtomDict,c=this.atomDict,u=e.getElementsByTagName("ModelledSubgroup"),h={},l=[];t.Debug&&cf.time("Validation.fromXml#clashDict");for(var p=0,d=u.length;p<d;++p){var f=u[p],m=f.attributes,g=Cc(m);void 0!==m.rsrz&&(i[g]=parseFloat(m.rsrz.value)),void 0!==m.rscc&&(r[g]=parseFloat(m.rscc.value)),m.sele=g;for(var v=f.getElementsByTagName("clash"),y=0,b=v.length;y<b;++y){var x=v[y].attributes,_=x.atom.value;if("H"!==ls(_)){var w=x.cid.value,S=Cc(m,_,!0);if(c[S]=!0,void 0===h[w])h[w]={sele1:S,res1:g};else{var A=h[w];A.res1!==g&&(A.sele2=S,A.res2=g,l.push(A.res1,g),n[w]=A,o.push(A))}}}}t.Debug&&cf.timeEnd("Validation.fromXml#clashDict");for(var M=0,P=u.length;M<P;++M){var T=u[M],E=T.attributes,C=E.sele;if("."!==E.seq.value){var I=Oc(n,T,E);I>0&&(a[C]=I)}else{var R=T.getElementsByTagName("clash"),L=T.getElementsByTagName("mog-bond-outlier"),O=T.getElementsByTagName("mog-angle-outlier");if(L.length>0||O.length>0||R.length>0){var D={};s[C]=D;for(var N=0,k=R.length;N<k;++N){var F=R[N].attributes;n[F.cid.value]&&Ic(D,F.atom.value,1)}for(var B=0,z=L.length;B<z;++B)L[B].attributes.atoms.value.split(",").forEach(function(t){Ic(D,t,2)});for(var U=0,j=O.length;U<j;++U)O[U].attributes.atoms.value.split(",").forEach(function(t){Ic(D,t,4)})}}}this.clashSele=l.length?l.join(" OR "):"NONE",t.Debug&&cf.timeEnd("Validation.fromXml")},P_.prototype.getClashData=function(e){t.Debug&&cf.time("Validation.getClashData");var i=e||{},r=i.structure,n=r.atomSet,o=new tt(gn(i.color,"#f0027f")),a=r.getAtomProxy(),s=r.getAtomProxy(),c=new g,u=new g,h=new g,l=this.clashArray,p=l.length,d=new Float32Array(3*p),f=new Float32Array(3*p),m=To(p,o.r,o.g,o.b),v=new Float32Array(p),y=new Float32Array(p);t.Debug&&cf.time("Validation.getClashData#atomDict");var b=this.atomDict;r.eachAtom(function(t){var e=Lc(t);!0===b[e]&&(b[e]=t.index)}),t.Debug&&cf.timeEnd("Validation.getClashData#atomDict");var x=0;return l.forEach(function(t,e){if(a.index=b[t.sele1],s.index=b[t.sele2],void 0!==a.index&&void 0!==s.index&&n.isSet(a.index,s.index)){c.subVectors(s,a).setLength(a.vdw),u.copy(a).add(c),c.subVectors(a,s).setLength(s.vdw),h.copy(s).add(c);var i=a.distanceTo(s)/2,r=Math.sqrt(a.vdw*a.vdw-i*i),o=Math.sqrt(s.vdw*s.vdw-i*i);u.toArray(d,3*x),h.toArray(f,3*x),v[x]=(r+o)/2,y[x]=e,++x}}),t.Debug&&cf.timeEnd("Validation.getClashData"),{position1:d.subarray(0,3*x),position2:f.subarray(0,3*x),color:m.subarray(0,3*x),color2:m.subarray(0,3*x),radius:v.subarray(0,x),picking:new ig(y.subarray(0,x),this,r)}},Object.defineProperties(P_.prototype,T_);var E_=function(e){function i(t,i){var r=i||{};e.call(this,t,r),this.useDomParser=!0,this.validation=new P_(this.name,this.path)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={__objName:{}};return r.__objName.get=function(){return"validation"},i.prototype._parse=function(){e.prototype._parse.call(this),t.Debug&&cf.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),t.Debug&&cf.timeEnd("ValidationParser._parse "+this.name)},Object.defineProperties(i.prototype,r),i}(M_);ff.add("validation",E_);var C_,I_,R_=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}(),L_=30,O_=12,D_=15,N_=852,k_=592,F_=0,B_=1,z_=2,U_=[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],j_=[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],G_=[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],V_=[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],$_=0,H_=1,W_=2,X_=4,q_=5,Y_=6,Z_=0,K_=1,Q_=2,J_=-2,tw=-3,ew=-4,iw=-5,rw=8,nw=1,ow=2,aw=3,sw=4,cw=5,uw=6,hw=7,lw=8,pw=9,dw=10,fw=11,mw=12,gw=13,vw=14,yw=15,bw=16,xw=17,_w=18,ww=19,Sw=20,Aw=21,Mw=22,Pw=23,Tw=24,Ew=25,Cw=26,Iw=27,Rw=28,Lw=29,Ow=30,Dw=31,Nw=32,kw=852,Fw=592,Bw=!0,zw=!0,Uw=!0;try{String.fromCharCode.apply(null,[0])}catch(t){zw=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Uw=!1}for(var jw=new Uint8Array(256),Gw=0;Gw<256;Gw++)jw[Gw]=Gw>=252?6:Gw>=248?5:Gw>=240?4:Gw>=224?3:Gw>=192?2:1;jw[254]=jw[254]=1;var Vw=0,$w={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"},Hw=Object.prototype.toString;su.prototype.push=function(t,e){var i,r,n,o,a,s,c=this,u=this.strm,h=this.options.chunkSize,l=this.options.dictionary,p=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?u.input=iu(t):"[object ArrayBuffer]"===Hw.call(t)?u.input=new Uint8Array(t):u.input=t,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new Uint8Array(h),u.next_out=0,u.avail_out=h),2===(i=Zc(u,0))&&l&&(s="string"==typeof l?tu(l):"[object ArrayBuffer]"===Hw.call(l)?new Uint8Array(l):l,i=Jc(c.strm,s)),-5===i&&!0===p&&(i=Vw,p=!1),1!==i&&i!==Vw)return c.onEnd(i),c.ended=!0,!1;u.next_out&&(0!==u.avail_out&&1!==i&&(0!==u.avail_in||4!==r&&2!==r)||("string"===c.options.to?(n=nu(u.output,u.next_out),o=u.next_out-n,a=ru(u.output,n),u.next_out=o,u.avail_out=h-o,o&&kc(u.output,u.output,n,o,0),c.onData(a)):c.onData(Nc(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(p=!0)}while((u.avail_in>0||0===u.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=Kc(this.strm),this.onEnd(i),this.ended=!0,i===Vw):2!==r||(this.onEnd(Vw),u.avail_out=0,!0)},su.prototype.onData=function(t){this.chunks.push(t)},su.prototype.onEnd=function(t){t===Vw&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Fc(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},gf.add("gz",uu);var Ww="//files.rcsb.org/download/",Xw="//mmtf.rcsb.org/v1.0/full/",qw="//mmtf.rcsb.org/v1.0/reduced/";pf.add("rcsb",new hu);var Yw="//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/",Zw="/SDF?record_type=3d";pf.add("pubchem",new lu),pf.add("ftp",new pu),pf.add("http",new pu),pf.add("https",new pu);var Kw=/^((http|https|ftp):)*\/\//;"undefined"==typeof window||window.Promise||(window.Promise=r),t.Version="0.10.4",t.setDebug=po,t.DatasourceRegistry=pf,t.StaticDatasource=du,t.ParserRegistry=ff,t.autoLoad=mo,t.RepresentationRegistry=df,t.ColormakerRegistry=lf,t.Colormaker=Dd,t.Selection=Kd,t.PdbWriter=bo,t.Stage=ib,t.Collection=Qy,t.ComponentCollection=Jy,t.RepresentationCollection=tb,t.Assembly=uv,t.TrajectoryPlayer=Nv,t.superpose=Is,t.guessElement=ls,t.Queue=ms,t.Counter=Of,t.throttle=wn,t.download=xn,t.getQuery=mn,t.getDataInfo=fo,t.getFileInfo=_n,t.uniqueArray=En,t.BufferRepresentation=Iy,t.SphereBuffer=Kv,t.EllipsoidBuffer=ry,t.CylinderBuffer=py,t.ConeBuffer=yy,t.ArrowBuffer=xy,t.TextBuffer=Ay,t.Shape=Ty,t.Kdtree=ts,t.SpatialHash=Ba,t.MolecularSurface=dx,t.LeftMouseButton=1,t.MiddleMouseButton=2,t.RightMouseButton=3,t.MouseActions=Dm,t.Signal=oo,t.Matrix3=ut,t.Matrix4=v,t.Vector2=l,t.Vector3=g,t.Box3=st,t.Quaternion=m,t.Euler=ft,t.Plane=ht,t.Color=tt,Object.defineProperty(t,"__esModule",{value:!0})});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.NGL={})}(this,function(de){"use strict";var t,u,e,i,c,r,h,n;"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,i=window.console,r={},n=function(){},o="memory".split(","),a="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(",");t=o.pop();)i[t]||(i[t]=r);for(;e=a.pop();)i[e]||(i[e]=n)}(),void 0===window.HTMLCanvasElement||window.HTMLCanvasElement.prototype.toBlob||Object.defineProperty(window.HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var r=window.atob(this.toDataURL(e,i).split(",")[1]),n=r.length,o=n>>2,a=new Uint8Array(n),s=new Uint32Array(a.buffer,0,o),c=0,u=0;c<o;c++)s[c]=r.charCodeAt(u++)|r.charCodeAt(u++)<<8|r.charCodeAt(u++)<<16|r.charCodeAt(u++)<<24;for(var h=3&n;h--;)a[u]=r.charCodeAt(u++);t(new window.Blob([a],{type:e||"image/png"}))}}),Math.cbrt=Math.cbrt||function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},Math.sign||(Math.sign=function(t){return 0===(t=+t)||isNaN(t)?Number(t):0<t?1:-1}),Number.isInteger||(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&-9007199254740992<t&&t<9007199254740992&&Math.floor(t)===t}),Number.isNaN||(Number.isNaN=function(t){return t!=t}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var e=arguments;if(null==t)throw new TypeError("Cannot convert first argument to object");for(var i,r=Object(t),n=!1,o=1;o<arguments.length;o++){var a=e[o];if(null!=a){for(var s=Object.keys(Object(a)),c=0,u=s.length;c<u;c++){var h=s[c];try{var l=Object.getOwnPropertyDescriptor(a,h);void 0!==l&&l.enumerable&&(r[h]=a[h])}catch(t){n||(n=!0,i=t)}}if(n)throw i}}return r}}),String.prototype.startsWith||(t=function(){var t;try{var e={},i=Object.defineProperty;t=i(e,e,e)&&i}catch(t){}return t}(),u={}.toString,e=function(t){if(null===this)throw TypeError();var e=String(this);if(t&&"[object RegExp]"===u.call(t))throw TypeError();var i=e.length,r=String(t),n=r.length,o=1<arguments.length?arguments[1]:void 0,a=o?Number(o):0;Number.isNaN(a)&&(a=0);var s=Math.min(Math.max(a,0),i);if(i<n+s)return!1;for(var c=-1;++c<n;)if(e.charCodeAt(s+c)!==r.charCodeAt(c))return!1;return!0},t?t(String.prototype,"startsWith",{value:e,configurable:!0,writable:!0}):String.prototype.startsWith=e),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var i=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>i.length)&&(e=i.length),e-=t.length;var r=i.indexOf(t,e);return-1!==r&&r===e}),String.prototype.repeat||(String.prototype.repeat=function(t){if(null===this)throw new TypeError("can't convert "+this+" to object");var e=""+this;if(t=+t,Number.isNaN(t)&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t===1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0===e.length||0===t)return"";if(e.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var i="";1==(1&t)&&(i+=e),0!==(t>>>=1);)e+=e;return i}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.includes||(Array.prototype.includes=function(t){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),i=parseInt(e.length,10)||0;if(0===i)return!1;var r,n,o=parseInt(arguments[1],10)||0;for(0<=o?r=o:(r=i+o)<0&&(r=0);r<i;){if(t===(n=e[r])||Number.isNaN(t)&&Number.isNaN(n))return!0;r++}return!1}),Array.from||(Array.from=(i=Object.prototype.toString,c=function(t){return"function"==typeof t||"[object Function]"===i.call(t)},r=Math.pow(2,53)-1,h=function(t){var e,i=(e=Number(t),isNaN(e)?0:0!==e&&isFinite(e)?(0<e?1:-1)*Math.floor(Math.abs(e)):e);return Math.min(Math.max(i,0),r)},function(t){var e=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var i,r=1<arguments.length?arguments[1]:void 0;if(void 0!==r){if(!c(r))throw new TypeError("Array.from: when provided, the second argument must be a function");2<arguments.length&&(i=arguments[2])}for(var n,o=h(e.length),a=c(this)?Object(new this(o)):new Array(o),s=0;s<o;)n=e[s],a[s]=r?void 0===i?r(n,s):r.call(i,n,s):n,s+=1;return a.length=o,a})),"undefined"!=typeof window&&function(){for(var n=0,t=["ms","moz","webkit","o"],e=0;e<t.length&&!window.requestAnimationFrame;++e)window.requestAnimationFrame=window[t[e]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[t[e]+"CancelAnimationFrame"]||window[t[e]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t){var e=(new Date).getTime(),i=Math.max(0,16-(e-n)),r=window.setTimeout(function(){t(e+i)},i);return n=e+i,r}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)})}(),void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),"undefined"!=typeof window&&(void 0===window.performance&&(self.performance={}),void 0===window.performance.now&&(n=Date.now(),window.performance.now=function(){return Date.now()-n})),void 0!==Object.defineProperty&&(void 0===Number.MAX_SAFE_INTEGER&&Object.defineProperty(Number,"MAX_SAFE_INTEGER",{enumerable:!1,configurable:!1,writable:!1,value:Math.pow(2,53)-1}),void 0===Number.MIN_SAFE_INTEGER&&Object.defineProperty(Number,"MIN_SAFE_INTEGER",{enumerable:!1,configurable:!1,writable:!1,value:-(Math.pow(2,53)-1)}));var o=setTimeout;function a(){}function s(t){if(!(this instanceof s))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],g(t,this)}function l(i,r){for(;3===i._state;)i=i._value;0!==i._state?(i._handled=!0,s._immediateFn(function(){var t=1===i._state?r.onFulfilled:r.onRejected;if(null!==t){var e;try{e=t(i._value)}catch(t){return void d(r.promise,t)}p(r.promise,e)}else(1===i._state?p:d)(r.promise,i._value)})):i._deferreds.push(r)}function p(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var i=t.then;if(t instanceof s)return e._state=3,e._value=t,void f(e);if("function"==typeof i)return void g((r=i,n=t,function(){r.apply(n,arguments)}),e)}e._state=1,e._value=t,f(e)}catch(t){d(e,t)}var r,n}function d(t,e){t._state=2,t._value=e,f(t)}function f(t){2===t._state&&0===t._deferreds.length&&s._immediateFn(function(){t._handled||s._unhandledRejectionFn(t._value)});for(var e=0,i=t._deferreds.length;e<i;e++)l(t,t._deferreds[e]);t._deferreds=null}function m(t,e,i){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=i}function g(t,e){var i=!1;try{t(function(t){i||(i=!0,p(e,t))},function(t){i||(i=!0,d(e,t))})}catch(t){if(i)return;i=!0,d(e,t)}}function v(){}s.prototype.catch=function(t){return this.then(null,t)},s.prototype.then=function(t,e){var i=new this.constructor(a);return l(this,new m(t,e,i)),i},s.prototype.finally=function(e){var i=this.constructor;return this.then(function(t){return i.resolve(e()).then(function(){return t})},function(t){return i.resolve(e()).then(function(){return i.reject(t)})})},s.all=function(e){return new s(function(r,n){if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var o=Array.prototype.slice.call(e);if(0===o.length)return r([]);var a=o.length;function s(e,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var i=t.then;if("function"==typeof i)return void i.call(t,function(t){s(e,t)},n)}o[e]=t,0==--a&&r(o)}catch(t){n(t)}}for(var t=0;t<o.length;t++)s(t,o[t])})},s.resolve=function(e){return e&&"object"==typeof e&&e.constructor===s?e:new s(function(t){t(e)})},s.reject=function(i){return new s(function(t,e){e(i)})},s.race=function(n){return new s(function(t,e){for(var i=0,r=n.length;i<r;i++)n[i].then(t,e)})},s._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){o(t,0)},s._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)},void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:0<t?1:+t}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){var e=arguments;if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),r=1;r<arguments.length;r++){var n=e[r];if(null!=n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(i[o]=n[o])}return i}),Object.assign(v.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var i=this._listeners[t];if(void 0!==i){var r=i.indexOf(e);-1!==r&&i.splice(r,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var i=e.slice(0),r=0,n=i.length;r<n;r++)i[r].call(this,t)}}}});var y,b,x,_,w,S,A,M,E,P,T,C,I,O,L,R,D,k,B,N,F,z,$=0,W=1,X=2,U=1,j=2,G=0,wt=1,et=2,V=0,q=0,Y=1,Z=2,K=3,J=4,Q=5,H=100,tt=101,it=102,rt=103,nt=104,ot=200,at=201,st=202,ct=203,ut=204,ht=205,lt=206,pt=207,dt=208,ft=209,mt=210,gt=0,vt=1,yt=2,bt=3,xt=4,_t=5,St=6,At=7,Mt=0,Et=1,Pt=2,Tt=0,Ct=1,It=2,Ot=3,Lt=4,Rt=301,Dt=302,kt=303,Bt=304,Nt=305,Ft=306,zt=307,Ut=1e3,jt=1001,Gt=1002,Vt=1003,Ht=1004,$t=1005,Wt=1006,Xt=1007,qt=1008,Yt=1009,Zt=1010,Kt=1011,Jt=1012,Qt=1013,te=1014,ee=1015,ie=1016,re=1017,ne=1018,oe=1019,ae=1020,se=1021,ce=1022,ue=1023,he=1024,le=1025,pe=1026,fe=1027,ge=33776,ve=33777,ye=33778,be=33779,xe=35840,_e=35841,we=35842,Se=35843,Ae=36196,Me=37808,Ee=37809,Pe=37810,Te=37811,Ce=37812,Ie=37813,Oe=37814,Le=37815,Re=37816,De=37817,ke=37818,Be=37819,Ne=37820,Fe=37821,ze=2400,Ue=2401,je=0,Ge=3e3,Ve=3001,He=3007,$e=3002,We=3004,Xe=3005,qe=3006,Ye=3200,Ze=3201,Ke=0,Je=1,Qe={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){for(var n=[],t=0;t<256;t++)n[t]=(t<16?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(n[255&t]+n[t>>8&255]+n[t>>16&255]+n[t>>24&255]+"-"+n[255&e]+n[e>>8&255]+"-"+n[e>>16&15|64]+n[e>>24&255]+"-"+n[63&i|128]+n[i>>8&255]+"-"+n[i>>16&255]+n[i>>24&255]+n[255&r]+n[r>>8&255]+n[r>>16&255]+n[r>>24&255]).toUpperCase()}}(),clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,r,n){return r+(t-e)*(n-r)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},smoothstep:function(t,e,i){return t<=e?0:i<=t?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:i<=t?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*Qe.DEG2RAD},radToDeg:function(t){return t*Qe.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}};function ti(t,e){this.x=t||0,this.y=e||0}function ei(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function ii(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._w=void 0!==r?r:1}function ri(t,e,i){this.x=t||0,this.y=e||0,this.z=i||0}function ni(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(ti.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(ti.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:(y=new ti,b=new ti,function(t,e){return y.set(t,t),b.set(e,e),this.clamp(y,b)}),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,o=this.y-t.y;return this.x=n*i-o*r+t.x,this.y=n*r+o*i+t.y,this}}),Object.assign(ei.prototype,{isMatrix4:!0,set:function(t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=r,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=h,g[14]=l,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new ei).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},copyPosition:function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},extractBasis:function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this},extractRotation:(T=new ri,function(t){var e=this.elements,i=t.elements,r=1/T.setFromMatrixColumn(t,0).length(),n=1/T.setFromMatrixColumn(t,1).length(),o=1/T.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,i=t.x,r=t.y,n=t.z,o=Math.cos(i),a=Math.sin(i),s=Math.cos(r),c=Math.sin(r),u=Math.cos(n),h=Math.sin(n);if("XYZ"===t.order){var l=o*u,p=o*h,d=a*u,f=a*h;e[0]=s*u,e[4]=-s*h,e[8]=c,e[1]=p+d*c,e[5]=l-f*c,e[9]=-a*s,e[2]=f-l*c,e[6]=d+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*u,g=s*h,v=c*u,y=c*h;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*u,g=s*h,v=c*u,y=c*h;e[0]=m-y*a,e[4]=-o*h,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*u,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){l=o*u,p=o*h,d=a*u,f=a*h;e[0]=s*u,e[4]=d*c-p,e[8]=l*c+f,e[1]=s*h,e[5]=f*c+l,e[9]=p*c-d,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=w-b*h,e[8]=_*h+x,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=x*h+_,e[10]=b-w*h}else if("XZY"===t.order){b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*u,e[4]=-h,e[8]=c*u,e[1]=b*h+w,e[5]=o*u,e[9]=x*h-_,e[2]=_*h-x,e[6]=a*u,e[10]=w*h+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:(E=new ri(0,0,0),P=new ri(1,1,1),function(t){return this.compose(E,t,P)}),lookAt:(S=new ri,A=new ri,M=new ri,function(t,e,i){var r=this.elements;return M.subVectors(t,e),0===M.lengthSq()&&(M.z=1),M.normalize(),S.crossVectors(i,M),0===S.lengthSq()&&(1===Math.abs(i.z)?M.x+=1e-4:M.z+=1e-4,M.normalize(),S.crossVectors(i,M)),S.normalize(),A.crossVectors(M,S),r[0]=S.x,r[4]=A.x,r[8]=M.x,r[1]=S.y,r[5]=A.y,r[9]=M.y,r[2]=S.z,r[6]=A.z,r[10]=M.z,this}),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,r=e.elements,n=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],u=i[1],h=i[5],l=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],b=i[11],x=i[15],_=r[0],w=r[4],S=r[8],A=r[12],M=r[1],E=r[5],P=r[9],T=r[13],C=r[2],I=r[6],O=r[10],L=r[14],R=r[3],D=r[7],k=r[11],B=r[15];return n[0]=o*_+a*M+s*C+c*R,n[4]=o*w+a*E+s*I+c*D,n[8]=o*S+a*P+s*O+c*k,n[12]=o*A+a*T+s*L+c*B,n[1]=u*_+h*M+l*C+p*R,n[5]=u*w+h*E+l*I+p*D,n[9]=u*S+h*P+l*O+p*k,n[13]=u*A+h*T+l*L+p*B,n[2]=d*_+f*M+m*C+g*R,n[6]=d*w+f*E+m*I+g*D,n[10]=d*S+f*P+m*O+g*k,n[14]=d*A+f*T+m*L+g*B,n[3]=v*_+y*M+b*C+x*R,n[7]=v*w+y*E+b*I+x*D,n[11]=v*S+y*P+b*O+x*k,n[15]=v*A+y*T+b*L+x*B,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:(w=new ri,function(t){for(var e=0,i=t.count;e<i;e++)w.x=t.getX(e),w.y=t.getY(e),w.z=t.getZ(e),w.applyMatrix4(this),t.setXYZ(e,w.x,w.y,w.z);return t}),determinant:function(){var t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],o=t[1],a=t[5],s=t[9],c=t[13],u=t[2],h=t[6],l=t[10],p=t[14];return t[3]*(+n*s*h-r*c*h-n*a*l+i*c*l+r*a*p-i*s*p)+t[7]*(+e*s*p-e*c*l+n*o*l-r*o*p+r*c*u-n*s*u)+t[11]*(+e*c*h-e*a*p-n*o*h+i*o*p+n*a*u-i*c*u)+t[15]*(-r*a*u-e*s*h+e*a*l+r*o*h-i*o*l+i*s*u)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var i=this.elements,r=t.elements,n=r[0],o=r[1],a=r[2],s=r[3],c=r[4],u=r[5],h=r[6],l=r[7],p=r[8],d=r[9],f=r[10],m=r[11],g=r[12],v=r[13],y=r[14],b=r[15],x=d*y*l-v*f*l+v*h*m-u*y*m-d*h*b+u*f*b,_=g*f*l-p*y*l-g*h*m+c*y*m+p*h*b-c*f*b,w=p*v*l-g*d*l+g*u*m-c*v*m-p*u*b+c*d*b,S=g*d*h-p*v*h-g*u*f+c*v*f+p*u*y-c*d*y,A=n*x+o*_+a*w+s*S;if(0===A){var M="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(M);return console.warn(M),this.identity()}var E=1/A;return i[0]=x*E,i[1]=(v*f*s-d*y*s-v*a*m+o*y*m+d*a*b-o*f*b)*E,i[2]=(u*y*s-v*h*s+v*a*l-o*y*l-u*a*b+o*h*b)*E,i[3]=(d*h*s-u*f*s-d*a*l+o*f*l+u*a*m-o*h*m)*E,i[4]=_*E,i[5]=(p*y*s-g*f*s+g*a*m-n*y*m-p*a*b+n*f*b)*E,i[6]=(g*h*s-c*y*s-g*a*l+n*y*l+c*a*b-n*h*b)*E,i[7]=(c*f*s-p*h*s+p*a*l-n*f*l-c*a*m+n*h*m)*E,i[8]=w*E,i[9]=(g*d*s-p*v*s-g*o*m+n*v*m+p*o*b-n*d*b)*E,i[10]=(c*v*s-g*u*s+g*o*l-n*v*l-c*o*b+n*u*b)*E,i[11]=(p*u*s-c*d*s-p*o*l+n*d*l+c*o*m-n*u*m)*E,i[12]=S*E,i[13]=(p*v*a-g*d*a+g*o*f-n*v*f-p*o*y+n*d*y)*E,i[14]=(g*u*a-c*v*a-g*o*h+n*v*h+c*o*y-n*u*y)*E,i[15]=(c*d*a-p*u*a+p*o*h-n*d*h-c*o*f+n*u*f)*E,this},scale:function(t){var e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))},makeTranslation:function(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var i=Math.cos(e),r=Math.sin(e),n=1-i,o=t.x,a=t.y,s=t.z,c=n*o,u=n*a;return this.set(c*o+i,c*a-r*s,c*s+r*a,0,c*a+r*s,u*a+i,u*s-r*o,0,c*s-r*a,u*s+r*o,n*s*s+i,0,0,0,0,1),this},makeScale:function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},makeShear:function(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,i){var r=this.elements,n=e._x,o=e._y,a=e._z,s=e._w,c=n+n,u=o+o,h=a+a,l=n*c,p=n*u,d=n*h,f=o*u,m=o*h,g=a*h,v=s*c,y=s*u,b=s*h,x=i.x,_=i.y,w=i.z;return r[0]=(1-(f+g))*x,r[1]=(p+b)*x,r[2]=(d-y)*x,r[3]=0,r[4]=(p-b)*_,r[5]=(1-(l+g))*_,r[6]=(m+v)*_,r[7]=0,r[8]=(d+y)*w,r[9]=(m-v)*w,r[10]=(1-(l+f))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this},decompose:(x=new ri,_=new ei,function(t,e,i){var r=this.elements,n=x.set(r[0],r[1],r[2]).length(),o=x.set(r[4],r[5],r[6]).length(),a=x.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),t.x=r[12],t.y=r[13],t.z=r[14],_.copy(this);var s=1/n,c=1/o,u=1/a;return _.elements[0]*=s,_.elements[1]*=s,_.elements[2]*=s,_.elements[4]*=c,_.elements[5]*=c,_.elements[6]*=c,_.elements[8]*=u,_.elements[9]*=u,_.elements[10]*=u,e.setFromRotationMatrix(_),i.x=n,i.y=o,i.z=a,this}),makePerspective:function(t,e,i,r,n,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,s=2*n/(e-t),c=2*n/(i-r),u=(e+t)/(e-t),h=(i+r)/(i-r),l=-(o+n)/(o-n),p=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=l,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makeOrthographic:function(t,e,i,r,n,o){var a=this.elements,s=1/(e-t),c=1/(i-r),u=1/(o-n),h=(e+t)*s,l=(i+r)*c,p=(o+n)*u;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-l,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}),Object.assign(ii,{slerp:function(t,e,i,r){return i.copy(t).slerp(e,r)},slerpFlat:function(t,e,i,r,n,o,a){var s=i[r+0],c=i[r+1],u=i[r+2],h=i[r+3],l=n[o+0],p=n[o+1],d=n[o+2],f=n[o+3];if(h!==f||s!==l||c!==p||u!==d){var m=1-a,g=s*l+c*p+u*d+h*f,v=0<=g?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,a=Math.sin(a*x)/b}var _=a*v;if(s=s*m+l*_,c=c*m+p*_,u=u*m+d*_,h=h*m+f*_,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+h*h);s*=w,c*=w,u*=w,h*=w}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=h}}),Object.defineProperties(ii.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(ii.prototype,{set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=t._x,r=t._y,n=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(i/2),u=a(r/2),h=a(n/2),l=s(i/2),p=s(r/2),d=s(n/2);return"XYZ"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h-l*p*d):"YXZ"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h+l*p*d):"ZXY"===o?(this._x=l*u*h-c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h-l*p*d):"ZYX"===o?(this._x=l*u*h-c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h+l*p*d):"YZX"===o?(this._x=l*u*h+c*p*d,this._y=c*p*h+l*u*d,this._z=c*u*d-l*p*h,this._w=c*u*h-l*p*d):"XZY"===o&&(this._x=l*u*h-c*p*d,this._y=c*p*h-l*u*d,this._z=c*u*d+l*p*h,this._w=c*u*h+l*p*d),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,i=t.elements,r=i[0],n=i[4],o=i[8],a=i[1],s=i[5],c=i[9],u=i[2],h=i[6],l=i[10],p=r+s+l;return 0<p?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(h-c)*e,this._y=(o-u)*e,this._z=(a-n)*e):s<r&&l<r?(e=2*Math.sqrt(1+r-s-l),this._w=(h-c)/e,this._x=.25*e,this._y=(n+a)/e,this._z=(o+u)/e):l<s?(e=2*Math.sqrt(1+s-r-l),this._w=(o-u)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(c+h)/e):(e=2*Math.sqrt(1+l-r-s),this._w=(a-n)/e,this._x=(o+u)/e,this._y=(c+h)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:(I=new ri,function(t,e){return void 0===I&&(I=new ri),(C=t.dot(e)+1)<1e-6?(C=0,Math.abs(t.x)>Math.abs(t.z)?I.set(-t.y,t.x,0):I.set(0,-t.z,t.y)):I.crossVectors(t,e),this._x=I.x,this._y=I.y,this._z=I.z,this._w=C,this.normalize()}),angleTo:function(t){return 2*Math.acos(Math.abs(Qe.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var i=this.angleTo(t);if(0===i)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var i=t._x,r=t._y,n=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=i*u+o*a+r*c-n*s,this._y=r*u+o*s+n*a-i*c,this._z=n*u+o*c+i*s-r*a,this._w=o*u-i*a-r*s-n*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*t._w+i*t._x+r*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),1<=a)return this._w=o,this._x=i,this._y=r,this._z=n,this;var s=1-a*a;if(s<=Number.EPSILON){var c=1-e;return this._w=c*o+e*this._w,this._x=c*i+e*this._x,this._y=c*r+e*this._y,this._z=c*n+e*this._z,this.normalize()}var u=Math.sqrt(s),h=Math.atan2(u,a),l=Math.sin((1-e)*h)/u,p=Math.sin(e*h)/u;return this._w=o*l+this._w*p,this._x=i*l+this._x*p,this._y=r*l+this._y*p,this._z=n*l+this._z*p,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(ri.prototype,{isVector3:!0,set:function(t,e,i){return this.x=t,this.y=e,this.z=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:(F=new ii,function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(F.setFromEuler(t))}),applyAxisAngle:(N=new ii,function(t,e){return this.applyQuaternion(N.setFromAxisAngle(t,e))}),applyMatrix3:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements,o=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(t){var e=this.x,i=this.y,r=this.z,n=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*r-a*i,u=s*i+a*e-n*r,h=s*r+n*i-o*e,l=-n*e-o*i-a*r;return this.x=c*s+l*-n+u*-a-h*-o,this.y=u*s+l*-o+h*-n-c*-a,this.z=h*s+l*-a+c*-o-u*-n,this},project:(B=new ei,function(t){return B.multiplyMatrices(t.projectionMatrix,B.getInverse(t.matrixWorld)),this.applyMatrix4(B)}),unproject:(k=new ei,function(t){return k.multiplyMatrices(t.matrixWorld,k.getInverse(t.projectionMatrix)),this.applyMatrix4(k)}),transformDirection:function(t){var e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:(R=new ri,D=new ri,function(t,e){return R.set(t,t,t),D.set(e,e,e),this.clamp(R,D)}),clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var i=t.x,r=t.y,n=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:(L=new ri,function(t){return L.copy(this).projectOnVector(t),this.sub(L)}),reflect:(O=new ri,function(t){return this.sub(O.copy(t).multiplyScalar(2*this.dot(t)))}),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(Qe.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(ni.prototype,{isMatrix3:!0,set:function(t,e,i,r,n,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=n,u[5]=s,u[6]=i,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:(z=new ri,function(t){for(var e=0,i=t.count;e<i;e++)z.x=t.getX(e),z.y=t.getY(e),z.z=t.getZ(e),z.applyMatrix3(this),t.setXYZ(e,z.x,z.y,z.z);return t}),multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,r=e.elements,n=this.elements,o=i[0],a=i[3],s=i[6],c=i[1],u=i[4],h=i[7],l=i[2],p=i[5],d=i[8],f=r[0],m=r[3],g=r[6],v=r[1],y=r[4],b=r[7],x=r[2],_=r[5],w=r[8];return n[0]=o*f+a*v+s*x,n[3]=o*m+a*y+s*_,n[6]=o*g+a*b+s*w,n[1]=c*f+u*v+h*x,n[4]=c*m+u*y+h*_,n[7]=c*g+u*b+h*w,n[2]=l*f+p*v+d*x,n[5]=l*m+p*y+d*_,n[8]=l*g+p*b+d*w,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],o=t[4],a=t[5],s=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-i*n*u+i*a*s+r*n*c-r*o*s},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var i=t.elements,r=this.elements,n=i[0],o=i[1],a=i[2],s=i[3],c=i[4],u=i[5],h=i[6],l=i[7],p=i[8],d=p*c-u*l,f=u*h-p*s,m=l*s-c*h,g=n*d+o*f+a*m;if(0===g){var v="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(v);return console.warn(v),this.identity()}var y=1/g;return r[0]=d*y,r[1]=(a*l-p*o)*y,r[2]=(u*o-a*c)*y,r[3]=f*y,r[4]=(p*n-a*h)*y,r[5]=(a*s-u*n)*y,r[6]=m*y,r[7]=(o*h-l*n)*y,r[8]=(c*n-o*s)*y,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},setUvTransform:function(t,e,i,r,n,o,a){var s=Math.cos(n),c=Math.sin(n);this.set(i*s,i*c,-i*(s*o+c*a)+o+t,-r*c,r*s,-r*(-c*o+s*a)+a+e,0,0,1)},scale:function(t,e){var i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=this.elements,n=r[0],o=r[3],a=r[6],s=r[1],c=r[4],u=r[7];return r[0]=e*n+i*s,r[3]=e*o+i*c,r[6]=e*a+i*u,r[1]=-i*n+e*s,r[4]=-i*o+e*c,r[7]=-i*a+e*u,this},translate:function(t,e){var i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this},equals:function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}});var oi,ai,si,ci,ui,hi,li,pi,di,fi,mi,gi,vi,yi,bi,xi={getDataURL:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{"undefined"!=typeof OffscreenCanvas?e=new OffscreenCanvas(t.width,t.height):((e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height);var i=e.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height)}return 2048<e.width||2048<e.height?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},_i=0;function wi(t,e,i,r,n,o,a,s,c,u){Object.defineProperty(this,"id",{value:_i++}),this.uuid=Qe.generateUUID(),this.name="",this.image=void 0!==t?t:wi.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:wi.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:jt,this.wrapT=void 0!==r?r:jt,this.magFilter=void 0!==n?n:Wt,this.minFilter=void 0!==o?o:qt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==a?a:ue,this.type=void 0!==s?s:Yt,this.offset=new ti(0,0),this.repeat=new ti(1,1),this.center=new ti(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ni,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:Ge,this.version=0,this.onUpdate=null}function Si(t,e,i,r){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==r?r:1}function Ai(t,e,i){this.width=t,this.height=e,this.scissor=new Si(0,0,t,e),this.scissorTest=!1,this.viewport=new Si(0,0,t,e),void 0===(i=i||{}).minFilter&&(i.minFilter=Wt),this.texture=new wi(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.generateMipmaps=void 0===i.generateMipmaps||i.generateMipmaps,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0===i.stencilBuffer||i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}function Mi(t,e,i){Ai.call(this,t,e,i),this.activeCubeFace=0,this.activeMipMapLevel=0}function Ei(t,e,i,r,n,o,a,s,c,u,h,l){wi.call(this,null,o,a,s,c,u,r,n,h,l),this.image={data:t,width:e,height:i},this.magFilter=void 0!==c?c:Vt,this.minFilter=void 0!==u?u:Vt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Pi(t,e){this.min=void 0!==t?t:new ri(1/0,1/0,1/0),this.max=void 0!==e?e:new ri(-1/0,-1/0,-1/0)}function Ti(t,e){this.center=void 0!==t?t:new ri,this.radius=void 0!==e?e:0}function Ci(t,e){this.normal=void 0!==t?t:new ri(1,0,0),this.constant=void 0!==e?e:0}function Ii(t,e,i,r,n,o){this.planes=[void 0!==t?t:new Ci,void 0!==e?e:new Ci,void 0!==i?i:new Ci,void 0!==r?r:new Ci,void 0!==n?n:new Ci,void 0!==o?o:new Ci]}wi.DEFAULT_IMAGE=void 0,wi.DEFAULT_MAPPING=300,wi.prototype=Object.assign(Object.create(v.prototype),{constructor:wi,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){var e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=Qe.generateUUID()),!e&&void 0===t.images[r.uuid]){var n;if(Array.isArray(r)){n=[];for(var o=0,a=r.length;o<a;o++)n.push(xi.getDataURL(r[o]))}else n=xi.getDataURL(r);t.images[r.uuid]={uuid:r.uuid,url:n}}i.image=r.uuid}return e||(t.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.applyMatrix3(this.matrix),t.x<0||1<t.x)switch(this.wrapS){case Ut:t.x=t.x-Math.floor(t.x);break;case jt:t.x=t.x<0?0:1;break;case Gt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||1<t.y)switch(this.wrapT){case Ut:t.y=t.y-Math.floor(t.y);break;case jt:t.y=t.y<0?0:1;break;case Gt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.defineProperty(wi.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Si.prototype,{isVector4:!0,set:function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,i=this.y,r=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*e+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*e+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*e+o[7]*i+o[11]*r+o[15]*n,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,i,r,n,o=t.elements,a=o[0],s=o[4],c=o[8],u=o[1],h=o[5],l=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(c-p)<.01&&Math.abs(l-d)<.01){if(Math.abs(s+u)<.1&&Math.abs(c+p)<.1&&Math.abs(l+d)<.1&&Math.abs(a+h+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(h+1)/2,v=(f+1)/2,y=(s+u)/4,b=(c+p)/4,x=(l+d)/4;return g<m&&v<m?m<.01?(i=0,n=r=.707106781):(r=y/(i=Math.sqrt(m)),n=b/i):v<g?g<.01?(r=0,n=i=.707106781):(i=y/(r=Math.sqrt(g)),n=x/r):v<.01?(r=i=.707106781,n=0):(i=b/(n=Math.sqrt(v)),r=x/n),this.set(i,r,n,e),this}var _=Math.sqrt((d-l)*(d-l)+(c-p)*(c-p)+(u-s)*(u-s));return Math.abs(_)<.001&&(_=1),this.x=(d-l)/_,this.y=(c-p)/_,this.z=(u-s)/_,this.w=Math.acos((a+h+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return void 0===oi&&(oi=new Si,ai=new Si),oi.set(t,t,t,t),ai.set(e,e,e,e),this.clamp(oi,ai)},clampLength:function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,i){return this.subVectors(e,t).multiplyScalar(i).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Ai.prototype=Object.assign(Object.create(v.prototype),{constructor:Ai,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),((Mi.prototype=Object.create(Ai.prototype)).constructor=Mi).prototype.isWebGLRenderTargetCube=!0,((Ei.prototype=Object.create(wi.prototype)).constructor=Ei).prototype.isDataTexture=!0,Object.assign(Pi.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],h=t[s+1],l=t[s+2];u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),n<u&&(n=u),o<h&&(o=h),a<l&&(a=l)}return this.min.set(e,i,r),this.max.set(n,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;s<c;s++){var u=t.getX(s),h=t.getY(s),l=t.getZ(s);u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),n<u&&(n=u),o<h&&(o=h),a<l&&(a=l)}return this.min.set(e,i,r),this.max.set(n,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:(hi=new ri,function(t,e){var i=hi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}),setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new ri),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new ri),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(){var n,o,a,s=new ri;function e(t){var e=t.geometry;if(void 0!==e)if(e.isGeometry){var i=e.vertices;for(o=0,a=i.length;o<a;o++)s.copy(i[o]),s.applyMatrix4(t.matrixWorld),n.expandByPoint(s)}else if(e.isBufferGeometry){var r=e.attributes.position;if(void 0!==r)for(o=0,a=r.count;o<a;o++)s.fromBufferAttribute(r,o).applyMatrix4(t.matrixWorld),n.expandByPoint(s)}}return function(t){return n=this,t.updateMatrixWorld(!0),t.traverse(e),this}}(),containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new ri),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:(ui=new ri,function(t){return this.clampPoint(t.center,ui),ui.distanceToSquared(t.center)<=t.radius*t.radius}),intersectsPlane:function(t){var e,i;return 0<t.normal.x?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),0<t.normal.y?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),0<t.normal.z?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=t.constant&&i>=t.constant},intersectsTriangle:function(){var s=new ri,c=new ri,u=new ri,i=new ri,r=new ri,n=new ri,h=new ri,o=new ri,l=new ri,a=new ri;function p(t){var e,i;for(e=0,i=t.length-3;e<=i;e+=3){h.fromArray(t,e);var r=l.x*Math.abs(h.x)+l.y*Math.abs(h.y)+l.z*Math.abs(h.z),n=s.dot(h),o=c.dot(h),a=u.dot(h);if(Math.max(-Math.max(n,o,a),Math.min(n,o,a))>r)return!1}return!0}return function(t){if(this.isEmpty())return!1;this.getCenter(o),l.subVectors(this.max,o),s.subVectors(t.a,o),c.subVectors(t.b,o),u.subVectors(t.c,o),i.subVectors(c,s),r.subVectors(u,c),n.subVectors(s,u);var e=[0,-i.z,i.y,0,-r.z,r.y,0,-n.z,n.y,i.z,0,-i.x,r.z,0,-r.x,n.z,0,-n.x,-i.y,i.x,0,-r.y,r.x,0,-n.y,n.x,0];return!!p(e)&&(!!p(e=[1,0,0,0,1,0,0,0,1])&&(a.crossVectors(i,r),p(e=[a.x,a.y,a.z])))}}(),clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new ri),e.copy(t).clamp(this.min,this.max)},distanceToPoint:(ci=new ri,function(t){return ci.copy(t).clamp(this.min,this.max).sub(t).length()}),getBoundingSphere:(si=new ri,function(t){return void 0===t&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),t=new Ti),this.getCenter(t.center),t.radius=.5*this.getSize(si).length(),t}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){if(this.isEmpty())return this;var e=t.elements,i=e[0]*this.min.x,r=e[1]*this.min.x,n=e[2]*this.min.x,o=e[0]*this.max.x,a=e[1]*this.max.x,s=e[2]*this.max.x,c=e[4]*this.min.y,u=e[5]*this.min.y,h=e[6]*this.min.y,l=e[4]*this.max.y,p=e[5]*this.max.y,d=e[6]*this.max.y,f=e[8]*this.min.z,m=e[9]*this.min.z,g=e[10]*this.min.z,v=e[8]*this.max.z,y=e[9]*this.max.z,b=e[10]*this.max.z;return this.min.x=Math.min(i,o)+Math.min(c,l)+Math.min(f,v)+e[12],this.min.y=Math.min(r,a)+Math.min(u,p)+Math.min(m,y)+e[13],this.min.z=Math.min(n,s)+Math.min(h,d)+Math.min(g,b)+e[14],this.max.x=Math.max(i,o)+Math.max(c,l)+Math.max(f,v)+e[12],this.max.y=Math.max(r,a)+Math.max(u,p)+Math.max(m,y)+e[13],this.max.z=Math.max(n,s)+Math.max(h,d)+Math.max(g,b)+e[14],this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(Ti.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(li=new Pi,function(t,e){var i=this.center;void 0!==e?i.copy(e):li.setFromPoints(t).getCenter(i);for(var r=0,n=0,o=t.length;n<o;n++)r=Math.max(r,i.distanceToSquared(t[n]));return this.radius=Math.sqrt(r),this}),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},clampPoint:function(t,e){var i=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new ri),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new Pi),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(Ci.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:(mi=new ri,gi=new ri,function(t,e,i){var r=mi.subVectors(i,e).cross(gi.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new ri),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:(fi=new ri,function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new ri);var i=t.delta(fi),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var n=-(t.start.dot(this.normal)+this.constant)/r;return n<0||1<n?void 0:e.copy(i).multiplyScalar(n).add(t.start)}),intersectsLine:function(t){var e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&0<i||i<0&&0<e},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new ri),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:(pi=new ri,di=new ni,function(t,e){var i=e||di.getNormalMatrix(t),r=this.coplanarPoint(pi).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),this}),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(Ii.prototype,{set:function(t,e,i,r,n,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(r),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,i=0;i<6;i++)e[i].copy(t.planes[i]);return this},setFromMatrix:function(t){var e=this.planes,i=t.elements,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],c=i[5],u=i[6],h=i[7],l=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return e[0].setComponents(a-r,h-s,f-l,y-m).normalize(),e[1].setComponents(a+r,h+s,f+l,y+m).normalize(),e[2].setComponents(a+n,h+c,f+p,y+g).normalize(),e[3].setComponents(a-n,h-c,f-p,y-g).normalize(),e[4].setComponents(a-o,h-u,f-d,y-v).normalize(),e[5].setComponents(a+o,h+u,f+d,y+v).normalize(),this},intersectsObject:(bi=new Ti,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),bi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(bi)}),intersectsSprite:(yi=new Ti,function(t){return yi.center.set(0,0,0),yi.radius=.7071067811865476,yi.applyMatrix4(t.matrixWorld),this.intersectsSphere(yi)}),intersectsSphere:function(t){for(var e=this.planes,i=t.center,r=-t.radius,n=0;n<6;n++){if(e[n].distanceToPoint(i)<r)return!1}return!0},intersectsBox:(vi=new ri,function(t){for(var e=this.planes,i=0;i<6;i++){var r=e[i];if(vi.x=0<r.normal.x?t.max.x:t.min.x,vi.y=0<r.normal.y?t.max.y:t.min.y,vi.z=0<r.normal.z?t.max.z:t.min.z,r.distanceToPoint(vi)<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}});var Oi,Li={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE  = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS  = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1  (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale =  bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:"  gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M      = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM            = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D      = max( maxRange / maxRGB, 1.0 );\n\tD            = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value )  {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n  varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n  gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}\n",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tvec4 mvPosition;\n\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n"},Ri={merge:function(t){for(var e={},i=0;i<t.length;i++){var r=this.clone(t[i]);for(var n in r)e[n]=r[n]}return e},clone:function(t){var e={};for(var i in t)for(var r in e[i]={},t[i]){var n=t[i][r];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture)?e[i][r]=n.clone():Array.isArray(n)?e[i][r]=n.slice():e[i][r]=n}return e}},Di={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function ki(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}Object.assign(ki.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this},setHSL:function(){function o(t,e,i){return i<0&&(i+=1),1<i&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}return function(t,e,i){if(t=Qe.euclideanModulo(t,1),e=Qe.clamp(e,0,1),i=Qe.clamp(i,0,1),0===e)this.r=this.g=this.b=i;else{var r=i<=.5?i*(1+e):i+e-i*e,n=2*i-r;this.r=o(n,r,t+1/3),this.g=o(n,r,t),this.b=o(n,r,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(a,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var u,h=(u=i[1]).length;if(3===h)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===h)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}e&&0<e.length&&(void 0!==(u=Di[e])?this.setHex(u):console.warn("THREE.Color: Unknown color "+e));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var i=0<e?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this},convertGammaToLinear:function(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(){function e(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),copyLinearToSRGB:function(){function e(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,i,r=this.r,n=this.g,o=this.b,a=Math.max(r,n,o),s=Math.min(r,n,o),c=(s+a)/2;if(s===a)i=e=0;else{var u=a-s;switch(i=c<=.5?u/(a+s):u/(2-a-s),a){case r:e=(n-o)/u+(n<o?6:0);break;case n:e=(o-r)/u+2;break;case o:e=(r-n)/u+4}e/=6}return t.h=e,t.s=i,t.l=c,t},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:(Oi={},function(t,e,i){return this.getHSL(Oi),Oi.h+=t,Oi.s+=e,Oi.l+=i,this.setHSL(Oi.h,Oi.s,Oi.l),this}),add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}});var Bi,Ni,Fi={common:{diffuse:{value:new ki(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ni},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ti(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ki(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new ki(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new ni}},sprite:{diffuse:{value:new ki(15658734)},opacity:{value:1},center:{value:new ti(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new ni}}},zi={basic:{uniforms:Ri.merge([Fi.common,Fi.specularmap,Fi.envmap,Fi.aomap,Fi.lightmap,Fi.fog]),vertexShader:Li.meshbasic_vert,fragmentShader:Li.meshbasic_frag},lambert:{uniforms:Ri.merge([Fi.common,Fi.specularmap,Fi.envmap,Fi.aomap,Fi.lightmap,Fi.emissivemap,Fi.fog,Fi.lights,{emissive:{value:new ki(0)}}]),vertexShader:Li.meshlambert_vert,fragmentShader:Li.meshlambert_frag},phong:{uniforms:Ri.merge([Fi.common,Fi.specularmap,Fi.envmap,Fi.aomap,Fi.lightmap,Fi.emissivemap,Fi.bumpmap,Fi.normalmap,Fi.displacementmap,Fi.gradientmap,Fi.fog,Fi.lights,{emissive:{value:new ki(0)},specular:{value:new ki(1118481)},shininess:{value:30}}]),vertexShader:Li.meshphong_vert,fragmentShader:Li.meshphong_frag},standard:{uniforms:Ri.merge([Fi.common,Fi.envmap,Fi.aomap,Fi.lightmap,Fi.emissivemap,Fi.bumpmap,Fi.normalmap,Fi.displacementmap,Fi.roughnessmap,Fi.metalnessmap,Fi.fog,Fi.lights,{emissive:{value:new ki(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Li.meshphysical_vert,fragmentShader:Li.meshphysical_frag},points:{uniforms:Ri.merge([Fi.points,Fi.fog]),vertexShader:Li.points_vert,fragmentShader:Li.points_frag},dashed:{uniforms:Ri.merge([Fi.common,Fi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Li.linedashed_vert,fragmentShader:Li.linedashed_frag},depth:{uniforms:Ri.merge([Fi.common,Fi.displacementmap]),vertexShader:Li.depth_vert,fragmentShader:Li.depth_frag},normal:{uniforms:Ri.merge([Fi.common,Fi.bumpmap,Fi.normalmap,Fi.displacementmap,{opacity:{value:1}}]),vertexShader:Li.normal_vert,fragmentShader:Li.normal_frag},sprite:{uniforms:Ri.merge([Fi.sprite,Fi.fog]),vertexShader:Li.sprite_vert,fragmentShader:Li.sprite_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Li.cube_vert,fragmentShader:Li.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Li.equirect_vert,fragmentShader:Li.equirect_frag},distanceRGBA:{uniforms:Ri.merge([Fi.common,Fi.displacementmap,{referencePosition:{value:new ri},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Li.distanceRGBA_vert,fragmentShader:Li.distanceRGBA_frag},shadow:{uniforms:Ri.merge([Fi.lights,Fi.fog,{color:{value:new ki(0)},opacity:{value:1}}]),vertexShader:Li.shadow_vert,fragmentShader:Li.shadow_frag}};function Ui(){var i=null,r=!1,n=null;function o(t,e){!1!==r&&(n(t,e),i.requestAnimationFrame(o))}return{start:function(){!0!==r&&null!==n&&(i.requestAnimationFrame(o),r=!0)},stop:function(){r=!1},setAnimationLoop:function(t){n=t},setContext:function(t){i=t}}}function ji(c){var u=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),u.get(t)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);var e=u.get(t);e&&(c.deleteBuffer(e.buffer),u.delete(t))},update:function(t,e){t.isInterleavedBufferAttribute&&(t=t.data);var i,r,n,o,a,s=u.get(t);void 0===s?u.set(t,function(t,e){var i=t.array,r=t.dynamic?c.DYNAMIC_DRAW:c.STATIC_DRAW,n=c.createBuffer();c.bindBuffer(e,n),c.bufferData(e,i,r),t.onUploadCallback();var o=c.FLOAT;return i instanceof Float32Array?o=c.FLOAT:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=c.UNSIGNED_SHORT:i instanceof Int16Array?o=c.SHORT:i instanceof Uint32Array?o=c.UNSIGNED_INT:i instanceof Int32Array?o=c.INT:i instanceof Int8Array?o=c.BYTE:i instanceof Uint8Array&&(o=c.UNSIGNED_BYTE),{buffer:n,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,e)):s.version<t.version&&(i=s.buffer,n=e,o=(r=t).array,a=r.updateRange,c.bindBuffer(n,i),!1===r.dynamic?c.bufferData(n,o,c.STATIC_DRAW):-1===a.count?c.bufferSubData(n,0,o):0===a.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(c.bufferSubData(n,a.offset*o.BYTES_PER_ELEMENT,o.subarray(a.offset,a.offset+a.count)),a.count=-1),s.version=t.version)}}}function Gi(t,e,i,r){this._x=t||0,this._y=e||0,this._z=i||0,this._order=r||Gi.DefaultOrder}function Vi(){this.mask=1}zi.physical={uniforms:Ri.merge([zi.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Li.meshphysical_vert,fragmentShader:Li.meshphysical_frag},Gi.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Gi.DefaultOrder="XYZ",Object.defineProperties(Gi.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(Gi.prototype,{isEuler:!0,set:function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,i){var r=Qe.clamp,n=t.elements,o=n[0],a=n[4],s=n[8],c=n[1],u=n[5],h=n[9],l=n[2],p=n[6],d=n[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-r(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-l,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-r(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===e?(this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-h,u),this._y=Math.atan2(-l,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e?(this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-h,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==i&&this.onChangeCallback(),this},setFromQuaternion:(Ni=new ei,function(t,e,i){return Ni.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ni,e,i)}),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:(Bi=new ii,function(t){return Bi.setFromEuler(this),this.setFromQuaternion(Bi,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new ri(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(Vi.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},test:function(t){return 0!=(this.mask&t.mask)}});var Hi,$i,Wi,Xi,qi,Yi,Zi,Ki,Ji,Qi,tr,er,ir,rr,nr,or,ar,sr,cr=0;function ur(){Object.defineProperty(this,"id",{value:cr++}),this.uuid=Qe.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ur.DefaultUp.clone();var t=new ri,e=new Gi,i=new ii,r=new ri(1,1,1);e.onChange(function(){i.setFromEuler(e,!1)}),i.onChange(function(){e.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:i},scale:{enumerable:!0,value:r},modelViewMatrix:{value:new ei},normalMatrix:{value:new ni}}),this.matrix=new ei,this.matrixWorld=new ei,this.matrixAutoUpdate=ur.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Vi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function hr(){ur.call(this),this.type="Camera",this.matrixWorldInverse=new ei,this.projectionMatrix=new ei}function lr(t,e,i,r,n,o){hr.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=r,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function pr(t,e,i,r,n,o){this.a=t,this.b=e,this.c=i,this.normal=r&&r.isVector3?r:new ri,this.vertexNormals=Array.isArray(r)?r:[],this.color=n&&n.isColor?n:new ki,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=void 0!==o?o:0}ur.DefaultUp=new ri(0,1,0),ur.DefaultMatrixAutoUpdate=!0,ur.prototype=Object.assign(Object.create(v.prototype),{constructor:ur,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(t){this.matrix.multiplyMatrices(t,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:(ar=new ii,function(t,e){return ar.setFromAxisAngle(t,e),this.quaternion.multiply(ar),this}),rotateOnWorldAxis:(or=new ii,function(t,e){return or.setFromAxisAngle(t,e),this.quaternion.premultiply(or),this}),rotateX:(nr=new ri(1,0,0),function(t){return this.rotateOnAxis(nr,t)}),rotateY:(rr=new ri(0,1,0),function(t){return this.rotateOnAxis(rr,t)}),rotateZ:(ir=new ri(0,0,1),function(t){return this.rotateOnAxis(ir,t)}),translateOnAxis:(er=new ri,function(t,e){return er.copy(t).applyQuaternion(this.quaternion),this.position.add(er.multiplyScalar(e)),this}),translateX:(tr=new ri(1,0,0),function(t){return this.translateOnAxis(tr,t)}),translateY:(Qi=new ri(0,1,0),function(t){return this.translateOnAxis(Qi,t)}),translateZ:(Ji=new ri(0,0,1),function(t){return this.translateOnAxis(Ji,t)}),localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:(Ki=new ei,function(t){return t.applyMatrix4(Ki.getInverse(this.matrixWorld))}),lookAt:(Yi=new ei,Zi=new ri,function(t,e,i){t.isVector3?Zi.copy(t):Zi.set(t,e,i),this.isCamera?Yi.lookAt(this.position,Zi,this.up):Yi.lookAt(Zi,this.position,this.up),this.quaternion.setFromRotationMatrix(Yi)}),add:function(t){var e=arguments;if(1<arguments.length){for(var i=0;i<arguments.length;i++)this.add(e[i]);return this}return t===this?console.error("THREE.Object3D.add: object can't be added as a child of itself.",t):t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,t.dispatchEvent({type:"added"}),this.children.push(t)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this},remove:function(t){var e=arguments;if(1<arguments.length){for(var i=0;i<arguments.length;i++)this.remove(e[i]);return this}var r=this.children.indexOf(t);return-1!==r&&(t.parent=null,t.dispatchEvent({type:"removed"}),this.children.splice(r,1)),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(var i=0,r=this.children.length;i<r;i++){var n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new ri),this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:(Xi=new ri,qi=new ri,function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new ii),this.updateMatrixWorld(!0),this.matrixWorld.decompose(Xi,t,qi),t}),getWorldScale:($i=new ri,Wi=new ii,function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new ri),this.updateMatrixWorld(!0),this.matrixWorld.decompose($i,Wi,t),t}),getWorldDirection:(Hi=new ii,function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new ri),this.getWorldQuaternion(Hi),t.set(0,0,1).applyQuaternion(Hi)}),raycast:function(){},traverse:function(t){t(this);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t=!(this.matrixWorldNeedsUpdate=!1));for(var e=this.children,i=0,r=e.length;i<r;i++)e[i].updateMatrixWorld(t)},toJSON:function(i){var t=void 0===i||"string"==typeof i,e={};t&&(i={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var r={};function n(t,e){return void 0===t[e.uuid]&&(t[e.uuid]=e.toJSON(i)),e.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isMesh||this.isLine||this.isPoints){r.geometry=n(i.geometries,this.geometry);var o=this.geometry.parameters;if(void 0!==o&&void 0!==o.shapes){var a=o.shapes;if(Array.isArray(a))for(var s=0,c=a.length;s<c;s++){var u=a[s];n(i.shapes,u)}else n(i.shapes,a)}}if(void 0!==this.material)if(Array.isArray(this.material)){var h=[];for(s=0,c=this.material.length;s<c;s++)h.push(n(i.materials,this.material[s]));r.material=h}else r.material=n(i.materials,this.material);if(0<this.children.length){r.children=[];for(s=0;s<this.children.length;s++)r.children.push(this.children[s].toJSON(i).object)}if(t){var l=m(i.geometries),p=m(i.materials),d=m(i.textures),f=m(i.images);a=m(i.shapes);0<l.length&&(e.geometries=l),0<p.length&&(e.materials=p),0<d.length&&(e.textures=d),0<f.length&&(e.images=f),0<a.length&&(e.shapes=a)}return e.object=r,e;function m(t){var e=[];for(var i in t){var r=t[i];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var i=0;i<t.children.length;i++){var r=t.children[i];this.add(r.clone())}return this}}),hr.prototype=Object.assign(Object.create(ur.prototype),{constructor:hr,isCamera:!0,copy:function(t,e){return ur.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this},getWorldDirection:(sr=new ii,function(t){return void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new ri),this.getWorldQuaternion(sr),t.set(0,0,-1).applyQuaternion(sr)}),updateMatrixWorld:function(t){ur.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),lr.prototype=Object.assign(Object.create(hr.prototype),{constructor:lr,isOrthographicCamera:!0,copy:function(t,e){return hr.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,i,r,n,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,n=i-t,o=i+t,a=r+e,s=r-e;if(null!==this.view&&this.view.enabled){var c=this.zoom/(this.view.width/this.view.fullWidth),u=this.zoom/(this.view.height/this.view.fullHeight),h=(this.right-this.left)/this.view.width,l=(this.top-this.bottom)/this.view.height;o=(n+=h*(this.view.offsetX/c))+h*(this.view.width/c),s=(a-=l*(this.view.offsetY/u))-l*(this.view.height/u)}this.projectionMatrix.makeOrthographic(n,o,a,s,this.near,this.far)},toJSON:function(t){var e=ur.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Object.assign(pr.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}});var dr,fr,mr,gr,vr,yr,br,xr=0;function _r(){Object.defineProperty(this,"id",{value:xr+=2}),this.uuid=Qe.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function wr(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Sr(t,e,i){wr.call(this,new Int8Array(t),e,i)}function Ar(t,e,i){wr.call(this,new Uint8Array(t),e,i)}function Mr(t,e,i){wr.call(this,new Uint8ClampedArray(t),e,i)}function Er(t,e,i){wr.call(this,new Int16Array(t),e,i)}function Pr(t,e,i){wr.call(this,new Uint16Array(t),e,i)}function Tr(t,e,i){wr.call(this,new Int32Array(t),e,i)}function Cr(t,e,i){wr.call(this,new Uint32Array(t),e,i)}function Ir(t,e,i){wr.call(this,new Float32Array(t),e,i)}function Or(t,e,i){wr.call(this,new Float64Array(t),e,i)}function Lr(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Rr(t){if(0===t.length)return-1/0;for(var e=t[0],i=1,r=t.length;i<r;++i)t[i]>e&&(e=t[i]);return e}_r.prototype=Object.assign(Object.create(v.prototype),{constructor:_r,isGeometry:!0,applyMatrix:function(t){for(var e=(new ni).getNormalMatrix(t),i=0,r=this.vertices.length;i<r;i++){this.vertices[i].applyMatrix4(t)}for(i=0,r=this.faces.length;i<r;i++){var n=this.faces[i];n.normal.applyMatrix3(e).normalize();for(var o=0,a=n.vertexNormals.length;o<a;o++)n.vertexNormals[o].applyMatrix3(e).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:(br=new ei,function(t){return br.makeRotationX(t),this.applyMatrix(br),this}),rotateY:(yr=new ei,function(t){return yr.makeRotationY(t),this.applyMatrix(yr),this}),rotateZ:(vr=new ei,function(t){return vr.makeRotationZ(t),this.applyMatrix(vr),this}),translate:(gr=new ei,function(t,e,i){return gr.makeTranslation(t,e,i),this.applyMatrix(gr),this}),scale:(mr=new ei,function(t,e,i){return mr.makeScale(t,e,i),this.applyMatrix(mr),this}),lookAt:(fr=new ur,function(t){fr.lookAt(t),fr.updateMatrix(),this.applyMatrix(fr.matrix)}),fromBufferGeometry:function(t){var o=this,e=null!==t.index?t.index.array:void 0,i=t.attributes,r=i.position.array,a=void 0!==i.normal?i.normal.array:void 0,s=void 0!==i.color?i.color.array:void 0,c=void 0!==i.uv?i.uv.array:void 0,u=void 0!==i.uv2?i.uv2.array:void 0;void 0!==u&&(this.faceVertexUvs[1]=[]);for(var h=[],l=[],p=[],n=0,d=0;n<r.length;n+=3,d+=2)o.vertices.push(new ri(r[n],r[n+1],r[n+2])),void 0!==a&&h.push(new ri(a[n],a[n+1],a[n+2])),void 0!==s&&o.colors.push(new ki(s[n],s[n+1],s[n+2])),void 0!==c&&l.push(new ti(c[d],c[d+1])),void 0!==u&&p.push(new ti(u[d],u[d+1]));function f(t,e,i,r){var n=new pr(t,e,i,void 0!==a?[h[t].clone(),h[e].clone(),h[i].clone()]:[],void 0!==s?[o.colors[t].clone(),o.colors[e].clone(),o.colors[i].clone()]:[],r);o.faces.push(n),void 0!==c&&o.faceVertexUvs[0].push([l[t].clone(),l[e].clone(),l[i].clone()]),void 0!==u&&o.faceVertexUvs[1].push([p[t].clone(),p[e].clone(),p[i].clone()])}var m=t.groups;if(0<m.length)for(n=0;n<m.length;n++)for(var g=m[n],v=g.start,y=(d=v,v+g.count);d<y;d+=3)void 0!==e?f(e[d],e[d+1],e[d+2],g.materialIndex):f(d,d+1,d+2,g.materialIndex);else if(void 0!==e)for(n=0;n<e.length;n+=3)f(e[n],e[n+1],e[n+2]);else for(n=0;n<r.length/3;n+=3)f(n,n+1,n+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:(dr=new ri,function(){return this.computeBoundingBox(),this.boundingBox.getCenter(dr).negate(),this.translate(dr.x,dr.y,dr.z),this}),normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,e=this.boundingSphere.radius,i=0===e?1:1/e,r=new ei;return r.set(i,0,0,-i*t.x,0,i,0,-i*t.y,0,0,i,-i*t.z,0,0,0,1),this.applyMatrix(r),this},computeFaceNormals:function(){for(var t=new ri,e=new ri,i=0,r=this.faces.length;i<r;i++){var n=this.faces[i],o=this.vertices[n.a],a=this.vertices[n.b],s=this.vertices[n.c];t.subVectors(s,a),e.subVectors(o,a),t.cross(e),t.normalize(),n.normal.copy(t)}},computeVertexNormals:function(t){var e,i,r,n,o,a;for(void 0===t&&(t=!0),a=new Array(this.vertices.length),e=0,i=this.vertices.length;e<i;e++)a[e]=new ri;if(t){var s,c,u,h=new ri,l=new ri;for(r=0,n=this.faces.length;r<n;r++)o=this.faces[r],s=this.vertices[o.a],c=this.vertices[o.b],u=this.vertices[o.c],h.subVectors(u,c),l.subVectors(s,c),h.cross(l),a[o.a].add(h),a[o.b].add(h),a[o.c].add(h)}else for(this.computeFaceNormals(),r=0,n=this.faces.length;r<n;r++)a[(o=this.faces[r]).a].add(o.normal),a[o.b].add(o.normal),a[o.c].add(o.normal);for(e=0,i=this.vertices.length;e<i;e++)a[e].normalize();for(r=0,n=this.faces.length;r<n;r++){var p=(o=this.faces[r]).vertexNormals;3===p.length?(p[0].copy(a[o.a]),p[1].copy(a[o.b]),p[2].copy(a[o.c])):(p[0]=a[o.a].clone(),p[1]=a[o.b].clone(),p[2]=a[o.c].clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,i;for(this.computeFaceNormals(),t=0,e=this.faces.length;t<e;t++){var r=(i=this.faces[t]).vertexNormals;3===r.length?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,i,r,n,o=this;for(i=0,r=this.faces.length;i<r;i++)for((n=o.faces[i]).__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),t=0,e=n.vertexNormals.length;t<e;t++)n.__originalVertexNormals[t]?n.__originalVertexNormals[t].copy(n.vertexNormals[t]):n.__originalVertexNormals[t]=n.vertexNormals[t].clone();var a=new _r;for(a.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!o.morphNormals[t]){o.morphNormals[t]={},o.morphNormals[t].faceNormals=[],o.morphNormals[t].vertexNormals=[];var s=o.morphNormals[t].faceNormals,c=o.morphNormals[t].vertexNormals;for(i=0,r=this.faces.length;i<r;i++)u=new ri,h={a:new ri,b:new ri,c:new ri},s.push(u),c.push(h)}var u,h,l=o.morphNormals[t];for(a.vertices=o.morphTargets[t].vertices,a.computeFaceNormals(),a.computeVertexNormals(),i=0,r=this.faces.length;i<r;i++)n=o.faces[i],u=l.faceNormals[i],h=l.vertexNormals[i],u.copy(n.normal),h.a.copy(n.vertexNormals[0]),h.b.copy(n.vertexNormals[1]),h.c.copy(n.vertexNormals[2])}for(i=0,r=this.faces.length;i<r;i++)(n=o.faces[i]).normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Pi),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ti),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,i){if(t&&t.isGeometry){var r,n=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,u=this.faceVertexUvs[0],h=t.faceVertexUvs[0],l=this.colors,p=t.colors;void 0===i&&(i=0),void 0!==e&&(r=(new ni).getNormalMatrix(e));for(var d=0,f=a.length;d<f;d++){var m=a[d].clone();void 0!==e&&m.applyMatrix4(e),o.push(m)}for(d=0,f=p.length;d<f;d++)l.push(p[d].clone());for(d=0,f=c.length;d<f;d++){var g,v,y,b=c[d],x=b.vertexNormals,_=b.vertexColors;(g=new pr(b.a+n,b.b+n,b.c+n)).normal.copy(b.normal),void 0!==r&&g.normal.applyMatrix3(r).normalize();for(var w=0,S=x.length;w<S;w++)v=x[w].clone(),void 0!==r&&v.applyMatrix3(r).normalize(),g.vertexNormals.push(v);g.color.copy(b.color);for(w=0,S=_.length;w<S;w++)y=_[w],g.vertexColors.push(y.clone());g.materialIndex=b.materialIndex+i,s.push(g)}for(d=0,f=h.length;d<f;d++){var A=h[d],M=[];if(void 0!==A){for(w=0,S=A.length;w<S;w++)M.push(A[w].clone());u.push(M)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t)},mergeMesh:function(t){t&&t.isMesh?(t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t)},mergeVertices:function(){var t,e,i,r,n,o,a,s,c={},u=[],h=[],l=Math.pow(10,4);for(i=0,r=this.vertices.length;i<r;i++)t=this.vertices[i],void 0===c[e=Math.round(t.x*l)+"_"+Math.round(t.y*l)+"_"+Math.round(t.z*l)]?(c[e]=i,u.push(this.vertices[i]),h[i]=u.length-1):h[i]=h[c[e]];var p=[];for(i=0,r=this.faces.length;i<r;i++){(n=this.faces[i]).a=h[n.a],n.b=h[n.b],n.c=h[n.c],o=[n.a,n.b,n.c];for(var d=0;d<3;d++)if(o[d]===o[(d+1)%3]){p.push(i);break}}for(i=p.length-1;0<=i;i--){var f=p[i];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a<s;a++)this.faceVertexUvs[a].splice(f,1)}var m=this.vertices.length-u.length;return this.vertices=u,m},setFromPoints:function(t){this.vertices=[];for(var e=0,i=t.length;e<i;e++){var r=t[e];this.vertices.push(new ri(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){for(var t=this.faces,e=t.length,i=0;i<e;i++)t[i]._id=i;t.sort(function(t,e){return t.materialIndex-e.materialIndex});var r,n,o=this.faceVertexUvs[0],a=this.faceVertexUvs[1];o&&o.length===e&&(r=[]),a&&a.length===e&&(n=[]);for(i=0;i<e;i++){var s=t[i]._id;r&&r.push(o[s]),n&&n.push(a[s])}r&&(this.faceVertexUvs[0]=r),n&&(this.faceVertexUvs[1]=n)},toJSON:function(){var t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}for(var r=[],n=0;n<this.vertices.length;n++){var o=this.vertices[n];r.push(o.x,o.y,o.z)}var a=[],s=[],c={},u=[],h={},l=[],p={};for(n=0;n<this.faces.length;n++){var d=this.faces[n],f=void 0!==this.faceVertexUvs[0][n],m=0<d.normal.length(),g=0<d.vertexNormals.length,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=0<d.vertexColors.length,b=0;if(b=S(b=S(b=S(b=S(b=S(b=S(b=S(b=S(b,0,0),1,!0),2,!1),3,f),4,m),5,g),6,v),7,y),a.push(b),a.push(d.a,d.b,d.c),a.push(d.materialIndex),f){var x=this.faceVertexUvs[0][n];a.push(E(x[0]),E(x[1]),E(x[2]))}if(m&&a.push(A(d.normal)),g){var _=d.vertexNormals;a.push(A(_[0]),A(_[1]),A(_[2]))}if(v&&a.push(M(d.color)),y){var w=d.vertexColors;a.push(M(w[0]),M(w[1]),M(w[2]))}}function S(t,e,i){return i?t|1<<e:t&~(1<<e)}function A(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==c[e]||(c[e]=s.length/3,s.push(t.x,t.y,t.z)),c[e]}function M(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==h[e]||(h[e]=u.length,u.push(t.getHex())),h[e]}function E(t){var e=t.x.toString()+t.y.toString();return void 0!==p[e]||(p[e]=l.length/2,l.push(t.x,t.y)),p[e]}return t.data={},t.data.vertices=r,t.data.normals=s,0<u.length&&(t.data.colors=u),0<l.length&&(t.data.uvs=[l]),t.data.faces=a,t},clone:function(){return(new _r).copy(this)},copy:function(t){var e,i,r,n,o,a,s=this;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var c=t.vertices;for(e=0,i=c.length;e<i;e++)s.vertices.push(c[e].clone());var u=t.colors;for(e=0,i=u.length;e<i;e++)s.colors.push(u[e].clone());var h=t.faces;for(e=0,i=h.length;e<i;e++)s.faces.push(h[e].clone());for(e=0,i=t.faceVertexUvs.length;e<i;e++){var l=t.faceVertexUvs[e];for(void 0===s.faceVertexUvs[e]&&(s.faceVertexUvs[e]=[]),r=0,n=l.length;r<n;r++){var p=l[r],d=[];for(o=0,a=p.length;o<a;o++){var f=p[o];d.push(f.clone())}s.faceVertexUvs[e].push(d)}}var m=t.morphTargets;for(e=0,i=m.length;e<i;e++){var g={};if(g.name=m[e].name,void 0!==m[e].vertices)for(g.vertices=[],r=0,n=m[e].vertices.length;r<n;r++)g.vertices.push(m[e].vertices[r].clone());if(void 0!==m[e].normals)for(g.normals=[],r=0,n=m[e].normals.length;r<n;r++)g.normals.push(m[e].normals[r].clone());s.morphTargets.push(g)}var v=t.morphNormals;for(e=0,i=v.length;e<i;e++){var y={};if(void 0!==v[e].vertexNormals)for(y.vertexNormals=[],r=0,n=v[e].vertexNormals.length;r<n;r++){var b=v[e].vertexNormals[r],x={};x.a=b.a.clone(),x.b=b.b.clone(),x.c=b.c.clone(),y.vertexNormals.push(x)}if(void 0!==v[e].faceNormals)for(y.faceNormals=[],r=0,n=v[e].faceNormals.length;r<n;r++)y.faceNormals.push(v[e].faceNormals[r].clone());s.morphNormals.push(y)}var _=t.skinWeights;for(e=0,i=_.length;e<i;e++)s.skinWeights.push(_[e].clone());var w=t.skinIndices;for(e=0,i=w.length;e<i;e++)s.skinIndices.push(w[e].clone());var S=t.lineDistances;for(e=0,i=S.length;e<i;e++)s.lineDistances.push(S[e]);var A=t.boundingBox;null!==A&&(this.boundingBox=A.clone());var M=t.boundingSphere;return null!==M&&(this.boundingSphere=M.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(wr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(wr.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");return this.count=void 0!==t?t.length/this.itemSize:0,this.array=t,this},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(var r=0,n=this.itemSize;r<n;r++)this.array[t+r]=e.array[i+r];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),o=new ki),e[i++]=o.r,e[i++]=o.g,e[i++]=o.b}return this},copyVector2sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),o=new ti),e[i++]=o.x,e[i++]=o.y}return this},copyVector3sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),o=new ri),e[i++]=o.x,e[i++]=o.y,e[i++]=o.z}return this},copyVector4sArray:function(t){for(var e=this.array,i=0,r=0,n=t.length;r<n;r++){var o=t[r];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),o=new Si),e[i++]=o.x,e[i++]=o.y,e[i++]=o.z,e[i++]=o.w}return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=r,this},setXYZW:function(t,e,i,r,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=r,this.array[t+3]=n,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),(Sr.prototype=Object.create(wr.prototype)).constructor=Sr,(Ar.prototype=Object.create(wr.prototype)).constructor=Ar,(Mr.prototype=Object.create(wr.prototype)).constructor=Mr,(Er.prototype=Object.create(wr.prototype)).constructor=Er,(Pr.prototype=Object.create(wr.prototype)).constructor=Pr,(Tr.prototype=Object.create(wr.prototype)).constructor=Tr,(Cr.prototype=Object.create(wr.prototype)).constructor=Cr,(Ir.prototype=Object.create(wr.prototype)).constructor=Ir,(Or.prototype=Object.create(wr.prototype)).constructor=Or,Object.assign(Lr.prototype,{computeGroups:function(t){for(var e,i=[],r=void 0,n=t.faces,o=0;o<n.length;o++){var a=n[o];a.materialIndex!==r&&(r=a.materialIndex,void 0!==e&&(e.count=3*o-e.start,i.push(e)),e={start:3*o,materialIndex:r})}void 0!==e&&(e.count=3*o-e.start,i.push(e)),this.groups=i},fromGeometry:function(t){var e,i=this,r=t.faces,n=t.vertices,o=t.faceVertexUvs,a=o[0]&&0<o[0].length,s=o[1]&&0<o[1].length,c=t.morphTargets,u=c.length;if(0<u){e=[];for(var h=0;h<u;h++)e[h]=[];this.morphTargets.position=e}var l,p=t.morphNormals,d=p.length;if(0<d){l=[];for(h=0;h<d;h++)l[h]=[];this.morphTargets.normal=l}var f=t.skinIndices,m=t.skinWeights,g=f.length===n.length,v=m.length===n.length;0<n.length&&0===r.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(h=0;h<r.length;h++){var y=r[h];i.vertices.push(n[y.a],n[y.b],n[y.c]);var b=y.vertexNormals;if(3===b.length)i.normals.push(b[0],b[1],b[2]);else{var x=y.normal;i.normals.push(x,x,x)}var _,w=y.vertexColors;if(3===w.length)i.colors.push(w[0],w[1],w[2]);else{var S=y.color;i.colors.push(S,S,S)}if(!0===a)void 0!==(_=o[0][h])?i.uvs.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",h),i.uvs.push(new ti,new ti,new ti));if(!0===s)void 0!==(_=o[1][h])?i.uvs2.push(_[0],_[1],_[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",h),i.uvs2.push(new ti,new ti,new ti));for(var A=0;A<u;A++){var M=c[A].vertices;e[A].push(M[y.a],M[y.b],M[y.c])}for(A=0;A<d;A++){var E=p[A].vertexNormals[h];l[A].push(E.a,E.b,E.c)}g&&i.skinIndices.push(f[y.a],f[y.b],f[y.c]),v&&i.skinWeights.push(m[y.a],m[y.b],m[y.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}});var Dr,kr,Br,Nr,Fr,zr,Ur,jr,Gr,Vr,Hr=1;function $r(){Object.defineProperty(this,"id",{value:Hr+=2}),this.uuid=Qe.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}function Wr(t,e,i,r,n,o){_r.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:n,depthSegments:o},this.fromBufferGeometry(new Xr(t,e,i,r,n,o)),this.mergeVertices()}function Xr(t,e,i,r,n,o){$r.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:r,heightSegments:n,depthSegments:o};var C=this;t=t||1,e=e||1,i=i||1,r=Math.floor(r)||1,n=Math.floor(n)||1,o=Math.floor(o)||1;var I=[],O=[],L=[],R=[],D=0,k=0;function a(t,e,i,r,n,o,a,s,c,u,h){var l,p,d=o/c,f=a/u,m=o/2,g=a/2,v=s/2,y=c+1,b=u+1,x=0,_=0,w=new ri;for(p=0;p<b;p++){var S=p*f-g;for(l=0;l<y;l++){var A=l*d-m;w[t]=A*r,w[e]=S*n,w[i]=v,O.push(w.x,w.y,w.z),w[t]=0,w[e]=0,w[i]=0<s?1:-1,L.push(w.x,w.y,w.z),R.push(l/c),R.push(1-p/u),x+=1}}for(p=0;p<u;p++)for(l=0;l<c;l++){var M=D+l+y*p,E=D+l+y*(p+1),P=D+(l+1)+y*(p+1),T=D+(l+1)+y*p;I.push(M,E,T),I.push(E,P,T),_+=6}C.addGroup(k,_,h),k+=_,D+=x}a("z","y","x",-1,-1,i,e,t,o,n,0),a("z","y","x",1,-1,i,e,-t,o,n,1),a("x","z","y",1,1,t,i,e,r,o,2),a("x","z","y",1,-1,t,i,-e,r,o,3),a("x","y","z",1,-1,t,e,i,r,n,4),a("x","y","z",-1,-1,t,e,-i,r,n,5),this.setIndex(I),this.addAttribute("position",new Ir(O,3)),this.addAttribute("normal",new Ir(L,3)),this.addAttribute("uv",new Ir(R,2))}function qr(t,e,i,r){_r.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r},this.fromBufferGeometry(new Yr(t,e,i,r)),this.mergeVertices()}function Yr(t,e,i,r){$r.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:r};var n,o,a=(t=t||1)/2,s=(e=e||1)/2,c=Math.floor(i)||1,u=Math.floor(r)||1,h=c+1,l=u+1,p=t/c,d=e/u,f=[],m=[],g=[],v=[];for(o=0;o<l;o++){var y=o*d-s;for(n=0;n<h;n++){var b=n*p-a;m.push(b,-y,0),g.push(0,0,1),v.push(n/c),v.push(1-o/u)}}for(o=0;o<u;o++)for(n=0;n<c;n++){var x=n+h*o,_=n+h*(o+1),w=n+1+h*(o+1),S=n+1+h*o;f.push(x,_,S),f.push(_,w,S)}this.setIndex(f),this.addAttribute("position",new Ir(m,3)),this.addAttribute("normal",new Ir(g,3)),this.addAttribute("uv",new Ir(v,2))}$r.prototype=Object.assign(Object.create(v.prototype),{constructor:$r,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(65535<Rr(t)?Cr:Pr)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?("index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e)):this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(t,new wr(e,arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,i){this.groups.push({start:t,count:e,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var i=this.attributes.normal;void 0!==i&&((new ni).getNormalMatrix(t).applyToBufferAttribute(i),i.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:(Vr=new ei,function(t){return Vr.makeRotationX(t),this.applyMatrix(Vr),this}),rotateY:(Gr=new ei,function(t){return Gr.makeRotationY(t),this.applyMatrix(Gr),this}),rotateZ:(jr=new ei,function(t){return jr.makeRotationZ(t),this.applyMatrix(jr),this}),translate:(Ur=new ei,function(t,e,i){return Ur.makeTranslation(t,e,i),this.applyMatrix(Ur),this}),scale:(zr=new ei,function(t,e,i){return zr.makeScale(t,e,i),this.applyMatrix(zr),this}),lookAt:(Fr=new ur,function(t){Fr.lookAt(t),Fr.updateMatrix(),this.applyMatrix(Fr.matrix)}),center:(Nr=new ri,function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Nr).negate(),this.translate(Nr.x,Nr.y,Nr.z),this}),setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var i=new Ir(3*e.vertices.length,3),r=new Ir(3*e.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(e.vertices)),this.addAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var n=new Ir(e.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],i=0,r=t.length;i<r;i++){var n=t[i];e.push(n.x,n.y,n.z||0)}return this.addAttribute("position",new Ir(e,3)),this},updateFromObject:function(t){var e,i=t.geometry;if(t.isMesh){var r=i.__directGeometry;if(!0===i.elementsNeedUpdate&&(r=void 0,i.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(i);r.verticesNeedUpdate=i.verticesNeedUpdate,r.normalsNeedUpdate=i.normalsNeedUpdate,r.colorsNeedUpdate=i.colorsNeedUpdate,r.uvsNeedUpdate=i.uvsNeedUpdate,r.groupsNeedUpdate=i.groupsNeedUpdate,i.verticesNeedUpdate=!1,i.normalsNeedUpdate=!1,i.colorsNeedUpdate=!1,i.uvsNeedUpdate=!1,i.groupsNeedUpdate=!1,i=r}return!0===i.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(i.vertices),e.needsUpdate=!0),i.verticesNeedUpdate=!1),!0===i.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(i.normals),e.needsUpdate=!0),i.normalsNeedUpdate=!1),!0===i.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(i.colors),e.needsUpdate=!0),i.colorsNeedUpdate=!1),i.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(i.uvs),e.needsUpdate=!0),i.uvsNeedUpdate=!1),i.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(i.lineDistances),e.needsUpdate=!0),i.lineDistancesNeedUpdate=!1),i.groupsNeedUpdate&&(i.computeGroups(t.geometry),this.groups=i.groups,i.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Lr).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new wr(e,3).copyVector3sArray(t.vertices)),0<t.normals.length){var i=new Float32Array(3*t.normals.length);this.addAttribute("normal",new wr(i,3).copyVector3sArray(t.normals))}if(0<t.colors.length){var r=new Float32Array(3*t.colors.length);this.addAttribute("color",new wr(r,3).copyColorsArray(t.colors))}if(0<t.uvs.length){var n=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new wr(n,2).copyVector2sArray(t.uvs))}if(0<t.uvs2.length){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new wr(o,2).copyVector2sArray(t.uvs2))}for(var a in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[a],u=0,h=c.length;u<h;u++){var l=c[u],p=new Ir(3*l.length,3);s.push(p.copyVector3sArray(l))}this.morphAttributes[a]=s}if(0<t.skinIndices.length){var d=new Ir(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(0<t.skinWeights.length){var f=new Ir(4*t.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Pi);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:(kr=new Pi,Br=new ri,function(){null===this.boundingSphere&&(this.boundingSphere=new Ti);var t=this.attributes.position;if(t){var e=this.boundingSphere.center;kr.setFromBufferAttribute(t),kr.getCenter(e);for(var i=0,r=0,n=t.count;r<n;r++)Br.x=t.getX(r),Br.y=t.getY(r),Br.z=t.getZ(r),i=Math.max(i,e.distanceToSquared(Br));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}),computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.attributes,i=this.groups;if(e.position){var r=e.position.array;if(void 0===e.normal)this.addAttribute("normal",new wr(new Float32Array(r.length),3));else for(var n=e.normal.array,o=0,a=n.length;o<a;o++)n[o]=0;var s,c,u,h=e.normal.array,l=new ri,p=new ri,d=new ri,f=new ri,m=new ri;if(t){var g=t.array;0===i.length&&this.addGroup(0,g.length);for(var v=0,y=i.length;v<y;++v){var b=i[v],x=b.start;for(o=x,a=x+b.count;o<a;o+=3)s=3*g[o+0],c=3*g[o+1],u=3*g[o+2],l.fromArray(r,s),p.fromArray(r,c),d.fromArray(r,u),f.subVectors(d,p),m.subVectors(l,p),f.cross(m),h[s]+=f.x,h[s+1]+=f.y,h[s+2]+=f.z,h[c]+=f.x,h[c+1]+=f.y,h[c+2]+=f.z,h[u]+=f.x,h[u+1]+=f.y,h[u+2]+=f.z}}else for(o=0,a=r.length;o<a;o+=9)l.fromArray(r,o),p.fromArray(r,o+3),d.fromArray(r,o+6),f.subVectors(d,p),m.subVectors(l,p),f.cross(m),h[o]=f.x,h[o+1]=f.y,h[o+2]=f.z,h[o+3]=f.x,h[o+4]=f.y,h[o+5]=f.z,h[o+6]=f.x,h[o+7]=f.y,h[o+8]=f.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},merge:function(t,e){if(t&&t.isBufferGeometry){void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var i=this.attributes;for(var r in i)if(void 0!==t.attributes[r])for(var n=i[r].array,o=t.attributes[r],a=o.array,s=0,c=o.itemSize*e;s<a.length;s++,c++)n[c]=a[s];return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t)},normalizeNormals:(Dr=new ri,function(){for(var t=this.attributes.normal,e=0,i=t.count;e<i;e++)Dr.x=t.getX(e),Dr.y=t.getY(e),Dr.z=t.getZ(e),Dr.normalize(),t.setXYZ(e,Dr.x,Dr.y,Dr.z)}),toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new $r,e=this.index.array,i=this.attributes;for(var r in i){for(var n=i[r],o=n.array,a=n.itemSize,s=new o.constructor(e.length*a),c=0,u=0,h=0,l=e.length;h<l;h++){c=e[h]*a;for(var p=0;p<a;p++)s[u++]=o[c++]}t.addAttribute(r,new wr(s,a))}var d=this.groups;for(h=0,l=d.length;h<l;h++){var f=d[h];t.addGroup(f.start,f.count,f.materialIndex)}return t},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),0<Object.keys(this.userData).length&&(t.userData=this.userData),void 0!==this.parameters){var e=this.parameters;for(var i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};var r=this.index;if(null!==r){var n=Array.prototype.slice.call(r.array);t.data.index={type:r.array.constructor.name,array:n}}var o=this.attributes;for(var i in o){var a=o[i];n=Array.prototype.slice.call(a.array);t.data.attributes[i]={itemSize:a.itemSize,type:a.array.constructor.name,array:n,normalized:a.normalized}}var s=this.groups;0<s.length&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new $r).copy(this)},copy:function(t){var e,i,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var n=t.index;null!==n&&this.setIndex(n.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],u=s[e];for(i=0,r=u.length;i<r;i++)c.push(u[i].clone());this.morphAttributes[e]=c}var h=t.groups;for(i=0,r=h.length;i<r;i++){var l=h[i];this.addGroup(l.start,l.count,l.materialIndex)}var p=t.boundingBox;null!==p&&(this.boundingBox=p.clone());var d=t.boundingSphere;return null!==d&&(this.boundingSphere=d.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),(Wr.prototype=Object.create(_r.prototype)).constructor=Wr,(Xr.prototype=Object.create($r.prototype)).constructor=Xr,(qr.prototype=Object.create(_r.prototype)).constructor=qr,(Yr.prototype=Object.create($r.prototype)).constructor=Yr;var Zr,Kr,Jr,Qr,tn,en,rn,nn,on,an,sn,cn,un,hn,ln,pn,dn,fn,mn,gn,vn,yn,bn,xn,_n=0;function wn(){Object.defineProperty(this,"id",{value:_n++}),this.uuid=Qe.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Y,this.side=G,this.flatShading=!1,this.vertexColors=V,this.opacity=1,this.transparent=!1,this.blendSrc=ut,this.blendDst=ht,this.blendEquation=H,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=bt,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function Sn(t){wn.call(this),this.type="MeshBasicMaterial",this.color=new ki(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Mt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function An(t){wn.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function Mn(t,e){this.origin=void 0!==t?t:new ri,this.direction=void 0!==e?e:new ri}function En(t,e,i){this.a=void 0!==t?t:new ri,this.b=void 0!==e?e:new ri,this.c=void 0!==i?i:new ri}function Pn(t,e){ur.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new $r,this.material=void 0!==e?e:new Sn({color:16777215*Math.random()}),this.drawMode=je,this.updateMorphTargets()}function Tn(o,i,a,r){var s,c,u,h=new ki(0),l=0;function p(t,e){i.buffers.color.setClear(t.r,t.g,t.b,e,r)}return{getClearColor:function(){return h},setClearColor:function(t,e){h.set(t),p(h,l=void 0!==e?e:1)},getClearAlpha:function(){return l},setClearAlpha:function(t){p(h,l=t)},render:function(t,e,i,r){var n=e.background;null===n?p(h,l):n&&n.isColor&&(p(n,1),r=!0),(o.autoClear||r)&&o.clear(o.autoClearColor,o.autoClearDepth,o.autoClearStencil),n&&n.isCubeTexture?(void 0===u&&((u=new Pn(new Xr(1,1,1),new An({uniforms:zi.cube.uniforms,vertexShader:zi.cube.vertexShader,fragmentShader:zi.cube.fragmentShader,side:wt,depthTest:!0,depthWrite:!1,fog:!1}))).geometry.removeAttribute("normal"),u.geometry.removeAttribute("uv"),u.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},a.update(u)),u.material.uniforms.tCube.value=n,t.push(u,u.geometry,u.material,0,null)):n&&n.isTexture&&(void 0===s&&(s=new lr(-1,1,1,-1,0,1),c=new Pn(new Yr(2,2),new Sn({depthTest:!1,depthWrite:!1,fog:!1})),a.update(c)),c.material.map=n,o.renderBufferDirect(s,null,c.geometry,c.material,c,null))}}}function Cn(n,o,a,s){var c;this.setMode=function(t){c=t},this.render=function(t,e){n.drawArrays(c,t,e),a.update(e,c)},this.renderInstances=function(t,e,i){var r;if(s.isWebGL2)r=n;else if(null===(r=o.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");r[s.isWebGL2?"drawArraysInstanced":"drawArraysInstancedANGLE"](c,e,i,t.maxInstancedCount),a.update(i,c,t.maxInstancedCount)}}function In(e,i,t){var r;function n(t){if("highp"===t){if(0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision)return"highp";t="mediump"}return"mediump"===t&&0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision?"mediump":"lowp"}var o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,a=void 0!==t.precision?t.precision:"highp",s=n(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);var c=!0===t.logarithmicDepthBuffer,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),d=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),m=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=0<h,y=o||!!i.get("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:function(){if(void 0!==r)return r;var t=i.get("EXT_texture_filter_anisotropic");return r=null!==t?e.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y}}function On(){var h=this,l=null,p=0,d=!1,f=!1,m=new Ci,g=new ni,v={value:null,needsUpdate:!1};function y(){v.value!==l&&(v.value=l,v.needsUpdate=0<p),h.numPlanes=p,h.numIntersection=0}function b(t,e,i,r){var n=null!==t?t.length:0,o=null;if(0!==n){if(o=v.value,!0!==r||null===o){var a=i+4*n,s=e.matrixWorldInverse;g.getNormalMatrix(s),(null===o||o.length<a)&&(o=new Float32Array(a));for(var c=0,u=i;c!==n;++c,u+=4)m.copy(t[c]).applyMatrix4(s,g),m.normal.toArray(o,u),o[u+3]=m.constant}v.value=o,v.needsUpdate=!0}return h.numPlanes=n,o}this.uniform=v,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,i){var r=0!==t.length||e||0!==p||d;return d=e,l=b(t,i,0),p=t.length,r},this.beginShadows=function(){f=!0,b(null)},this.endShadows=function(){f=!1,y()},this.setState=function(t,e,i,r,n,o){if(!d||null===t||0===t.length||f&&!i)f?b(null):y();else{var a=f?0:p,s=4*a,c=n.clippingState||null;v.value=c,c=b(t,r,s,o);for(var u=0;u!==s;++u)c[u]=l[u];n.clippingState=c,this.numIntersection=e?this.numPlanes:0,this.numPlanes+=a}}}function Ln(i){var r={};return{get:function(t){if(void 0!==r[t])return r[t];var e;switch(t){case"WEBGL_depth_texture":e=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":e=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":e=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":e=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:e=i.getExtension(t)}return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),r[t]=e}}}function Rn(l,p,o){var a={},d={};function s(t){var e=t.target,i=a[e.id];for(var r in null!==i.index&&p.remove(i.index),i.attributes)p.remove(i.attributes[r]);e.removeEventListener("dispose",s),delete a[e.id];var n=d[i.id];n&&(p.remove(n),delete d[i.id]),o.memory.geometries--}return{get:function(t,e){var i=a[e.id];return i||(e.addEventListener("dispose",s),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new $r).setFromObject(t)),i=e._bufferGeometry),a[e.id]=i,o.memory.geometries++,i)},update:function(t){var e=t.index,i=t.attributes;for(var r in null!==e&&p.update(e,l.ELEMENT_ARRAY_BUFFER),i)p.update(i[r],l.ARRAY_BUFFER);var n=t.morphAttributes;for(var r in n)for(var o=n[r],a=0,s=o.length;a<s;a++)p.update(o[a],l.ARRAY_BUFFER)},getWireframeAttribute:function(t){var e=d[t.id];if(e)return e;var i,r=[],n=t.index,o=t.attributes;if(null!==n)for(var a=0,s=(i=n.array).length;a<s;a+=3){var c=i[a+0],u=i[a+1],h=i[a+2];r.push(c,u,u,h,h,c)}else for(a=0,s=(i=o.position.array).length/3-1;a<s;a+=3)c=a+0,u=a+1,h=a+2,r.push(c,u,u,h,h,c);return e=new(65535<Rr(r)?Cr:Pr)(r,1),p.update(e,l.ELEMENT_ARRAY_BUFFER),d[t.id]=e}}}function Dn(n,o,a,s){var c,u,h;this.setMode=function(t){c=t},this.setIndex=function(t){u=t.type,h=t.bytesPerElement},this.render=function(t,e){n.drawElements(c,e,u,t*h),a.update(e,c)},this.renderInstances=function(t,e,i){var r;if(s.isWebGL2)r=n;else if(null===(r=o.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");r[s.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](c,i,u,e*h,t.maxInstancedCount),a.update(i,c,t.maxInstancedCount)}}function kn(r){var n={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:n,programs:null,autoReset:!0,reset:function(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0},update:function(t,e,i){switch(i=i||1,n.calls++,e){case r.TRIANGLES:n.triangles+=i*(t/3);break;case r.TRIANGLE_STRIP:case r.TRIANGLE_FAN:n.triangles+=i*(t-2);break;case r.LINES:n.lines+=i*(t/2);break;case r.LINE_STRIP:n.lines+=i*(t-1);break;case r.LINE_LOOP:n.lines+=i*t;break;case r.POINTS:n.points+=i*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",e)}}}}function Bn(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Nn(d){var f={},m=new Float32Array(8);return{update:function(t,e,i,r){var n=t.morphTargetInfluences,o=n.length,a=f[e.id];if(void 0===a){a=[];for(var s=0;s<o;s++)a[s]=[s,0];f[e.id]=a}var c=i.morphTargets&&e.morphAttributes.position,u=i.morphNormals&&e.morphAttributes.normal;for(s=0;s<o;s++)0!==(h=a[s])[1]&&(c&&e.removeAttribute("morphTarget"+s),u&&e.removeAttribute("morphNormal"+s));for(s=0;s<o;s++)(h=a[s])[0]=s,h[1]=n[s];for(a.sort(Bn),s=0;s<8;s++){var h;if(h=a[s]){var l=h[0],p=h[1];if(p){c&&e.addAttribute("morphTarget"+s,c[l]),u&&e.addAttribute("morphNormal"+s,u[l]),m[s]=p;continue}}m[s]=0}r.getUniforms().setValue(d,"morphTargetInfluences",m)}}}function Fn(n,o){var a={};return{update:function(t){var e=o.render.frame,i=t.geometry,r=n.get(t,i);return a[r.id]!==e&&(i.isGeometry&&r.updateFromObject(t),n.update(r),a[r.id]=e),r},dispose:function(){a={}}}}function zn(t,e,i,r,n,o,a,s,c,u){wi.call(this,t=void 0!==t?t:[],e=void 0!==e?e:Rt,i,r,n,o,a,s,c,u),this.flipY=!1}wn.prototype=Object.assign(Object.create(v.prototype),{constructor:wn,isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var i=t[e];if(void 0!==i)if("shading"!==e){var r=this[e];void 0!==r?r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[e]="overdraw"===e?Number(i):i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){var e=[];for(var i in t){var r=t[i];delete r.metadata,e.push(r)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearCoat&&(i.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(i.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Y&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),this.side!==G&&(i.side=this.side),this.vertexColors!==V&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,0!==this.rotation&&(i.rotation=this.rotation),1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),0<this.alphaTest&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),1<this.wireframeLinewidth&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){var n=r(t.textures),o=r(t.images);0<n.length&&(i.textures=n),0<o.length&&(i.images=o)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,i=null;if(null!==e){var r=e.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.shadowSide=t.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),((Sn.prototype=Object.create(wn.prototype)).constructor=Sn).prototype.isMeshBasicMaterial=!0,Sn.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},((An.prototype=Object.create(wn.prototype)).constructor=An).prototype.isShaderMaterial=!0,An.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ri.clone(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},An.prototype.toJSON=function(t){var e=wn.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},Object.assign(Mn.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new ri),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:(sn=new ri,function(t){return this.origin.copy(this.at(t,sn)),this}),closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new ri),e.subVectors(t,this.origin);var i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:(an=new ri,function(t){var e=an.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(an.copy(this.direction).multiplyScalar(e).add(this.origin),an.distanceToSquared(t))}),distanceSqToSegment:(rn=new ri,nn=new ri,on=new ri,function(t,e,i,r){rn.copy(t).add(e).multiplyScalar(.5),nn.copy(e).sub(t).normalize(),on.copy(this.origin).sub(rn);var n,o,a,s,c=.5*t.distanceTo(e),u=-this.direction.dot(nn),h=on.dot(this.direction),l=-on.dot(nn),p=on.lengthSq(),d=Math.abs(1-u*u);if(0<d)if(o=u*h-l,s=c*d,0<=(n=u*l-h))if(-s<=o)if(o<=s){var f=1/d;a=(n*=f)*(n+u*(o*=f)+2*h)+o*(u*n+o+2*l)+p}else o=c,a=-(n=Math.max(0,-(u*o+h)))*n+o*(o+2*l)+p;else o=-c,a=-(n=Math.max(0,-(u*o+h)))*n+o*(o+2*l)+p;else o<=-s?a=-(n=Math.max(0,-(-u*c+h)))*n+(o=0<n?-c:Math.min(Math.max(-c,-l),c))*(o+2*l)+p:o<=s?(n=0,a=(o=Math.min(Math.max(-c,-l),c))*(o+2*l)+p):a=-(n=Math.max(0,-(u*c+h)))*n+(o=0<n?c:Math.min(Math.max(-c,-l),c))*(o+2*l)+p;else o=0<u?-c:c,a=-(n=Math.max(0,-(u*o+h)))*n+o*(o+2*l)+p;return i&&i.copy(this.direction).multiplyScalar(n).add(this.origin),r&&r.copy(nn).multiplyScalar(o).add(rn),a}),intersectSphere:(en=new ri,function(t,e){en.subVectors(t.center,this.origin);var i=en.dot(this.direction),r=en.dot(en)-i*i,n=t.radius*t.radius;if(n<r)return null;var o=Math.sqrt(n-r),a=i-o,s=i+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(t.normal)+t.constant)/e;return 0<=i?i:null},intersectPlane:function(t,e){var i=this.distanceToPlane(t);return null===i?null:this.at(i,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var i,r,n,o,a,s,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,l=this.origin;return 0<=c?(i=(t.min.x-l.x)*c,r=(t.max.x-l.x)*c):(i=(t.max.x-l.x)*c,r=(t.min.x-l.x)*c),0<=u?(n=(t.min.y-l.y)*u,o=(t.max.y-l.y)*u):(n=(t.max.y-l.y)*u,o=(t.min.y-l.y)*u),o<i||r<n?null:((i<n||i!=i)&&(i=n),(o<r||r!=r)&&(r=o),0<=h?(a=(t.min.z-l.z)*h,s=(t.max.z-l.z)*h):(a=(t.max.z-l.z)*h,s=(t.min.z-l.z)*h),s<i||r<a?null:((i<a||i!=i)&&(i=a),(s<r||r!=r)&&(r=s),r<0?null:this.at(0<=i?i:r,e)))},intersectsBox:(tn=new ri,function(t){return null!==this.intersectBox(t,tn)}),intersectTriangle:(Zr=new ri,Kr=new ri,Jr=new ri,Qr=new ri,function(t,e,i,r,n){Kr.subVectors(e,t),Jr.subVectors(i,t),Qr.crossVectors(Kr,Jr);var o,a=this.direction.dot(Qr);if(0<a){if(r)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}Zr.subVectors(this.origin,t);var s=o*this.direction.dot(Jr.crossVectors(Zr,Jr));if(s<0)return null;var c=o*this.direction.dot(Kr.cross(Zr));if(c<0)return null;if(a<s+c)return null;var u=-o*Zr.dot(Qr);return u<0?null:this.at(u/a,n)}),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(En,{getNormal:(pn=new ri,function(t,e,i,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new ri),r.subVectors(i,e),pn.subVectors(t,e),r.cross(pn);var n=r.lengthSq();return 0<n?r.multiplyScalar(1/Math.sqrt(n)):r.set(0,0,0)}),getBarycoord:(un=new ri,hn=new ri,ln=new ri,function(t,e,i,r,n){un.subVectors(r,e),hn.subVectors(i,e),ln.subVectors(t,e);var o=un.dot(un),a=un.dot(hn),s=un.dot(ln),c=hn.dot(hn),u=hn.dot(ln),h=o*c-a*a;if(void 0===n&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),n=new ri),0===h)return n.set(-2,-1,-1);var l=1/h,p=(c*s-a*u)*l,d=(o*u-a*s)*l;return n.set(1-p-d,d,p)}),containsPoint:(cn=new ri,function(t,e,i,r){return En.getBarycoord(t,e,i,r,cn),0<=cn.x&&0<=cn.y&&cn.x+cn.y<=1})}),Object.assign(En.prototype,{set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,r){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:(bn=new ri,xn=new ri,function(){return bn.subVectors(this.c,this.b),xn.subVectors(this.a,this.b),.5*bn.cross(xn).length()}),getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new ri),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return En.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new ri),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return En.getBarycoord(t,this.a,this.b,this.c,e)},containsPoint:function(t){return En.containsPoint(t,this.a,this.b,this.c)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:(dn=new ri,fn=new ri,mn=new ri,gn=new ri,vn=new ri,yn=new ri,function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new ri);var i,r,n=this.a,o=this.b,a=this.c;dn.subVectors(o,n),fn.subVectors(a,n),gn.subVectors(t,n);var s=dn.dot(gn),c=fn.dot(gn);if(s<=0&&c<=0)return e.copy(n);vn.subVectors(t,o);var u=dn.dot(vn),h=fn.dot(vn);if(0<=u&&h<=u)return e.copy(o);var l=s*h-u*c;if(l<=0&&0<=s&&u<=0)return i=s/(s-u),e.copy(n).addScaledVector(dn,i);yn.subVectors(t,a);var p=dn.dot(yn),d=fn.dot(yn);if(0<=d&&p<=d)return e.copy(a);var f=p*c-s*d;if(f<=0&&0<=c&&d<=0)return r=c/(c-d),e.copy(n).addScaledVector(fn,r);var m=u*d-p*h;if(m<=0&&0<=h-u&&0<=p-d)return mn.subVectors(a,o),r=(h-u)/(h-u+(p-d)),e.copy(o).addScaledVector(mn,r);var g=1/(m+f+l);return i=f*g,r=l*g,e.copy(n).addScaledVector(dn,i).addScaledVector(fn,r)}),equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),Pn.prototype=Object.assign(Object.create(ur.prototype),{constructor:Pn,isMesh:!0,setDrawMode:function(t){this.drawMode=t},copy:function(t){return ur.prototype.copy.call(this,t),this.drawMode=t.drawMode,void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this},updateMorphTargets:function(){var t,e,i,r=this.geometry;if(r.isBufferGeometry){var n=r.morphAttributes,o=Object.keys(n);if(0<o.length){var a=n[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t<e;t++)i=a[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}else{var s=r.morphTargets;if(void 0!==s&&0<s.length)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t<e;t++)i=s[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}},raycast:function(){var z=new ei,U=new Mn,j=new Ti,G=new ri,V=new ri,H=new ri,$=new ri,W=new ri,X=new ri,q=new ti,Y=new ti,Z=new ti,s=new ri,K=new ri,u=new ri;function J(t,e,i,r,n,o,a){return En.getBarycoord(t,e,i,r,s),n.multiplyScalar(s.x),o.multiplyScalar(s.y),a.multiplyScalar(s.z),n.add(o).add(a),n.clone()}function Q(t,e,i,r,n,o,a,s){if(null===(e.side===wt?r.intersectTriangle(a,o,n,!0,s):r.intersectTriangle(n,o,a,e.side!==et,s)))return null;u.copy(s),u.applyMatrix4(t.matrixWorld);var c=i.ray.origin.distanceTo(u);return c<i.near||c>i.far?null:{distance:c,point:u.clone(),object:t}}function tt(t,e,i,r,n,o,a,s,c){G.fromBufferAttribute(n,a),V.fromBufferAttribute(n,s),H.fromBufferAttribute(n,c);var u=Q(t,e,i,r,G,V,H,K);if(u){o&&(q.fromBufferAttribute(o,a),Y.fromBufferAttribute(o,s),Z.fromBufferAttribute(o,c),u.uv=J(K,G,V,H,q,Y,Z));var h=new pr(a,s,c);En.getNormal(G,V,H,h.normal),u.face=h}return u}return function(t,e){var i,r=this.geometry,n=this.material,o=this.matrixWorld;if(void 0!==n&&(null===r.boundingSphere&&r.computeBoundingSphere(),j.copy(r.boundingSphere),j.applyMatrix4(o),!1!==t.ray.intersectsSphere(j)&&(z.getInverse(o),U.copy(t.ray).applyMatrix4(z),null===r.boundingBox||!1!==U.intersectsBox(r.boundingBox))))if(r.isBufferGeometry){var a,s,c,u,h,l,p,d,f,m=r.index,g=r.attributes.position,v=r.attributes.uv,y=r.groups,b=r.drawRange;if(null!==m)if(Array.isArray(n))for(u=0,l=y.length;u<l;u++)for(f=n[(d=y[u]).materialIndex],h=Math.max(d.start,b.start),p=Math.min(d.start+d.count,b.start+b.count);h<p;h+=3)a=m.getX(h),s=m.getX(h+1),c=m.getX(h+2),(i=tt(this,f,t,U,g,v,a,s,c))&&(i.faceIndex=Math.floor(h/3),e.push(i));else for(u=Math.max(0,b.start),l=Math.min(m.count,b.start+b.count);u<l;u+=3)a=m.getX(u),s=m.getX(u+1),c=m.getX(u+2),(i=tt(this,n,t,U,g,v,a,s,c))&&(i.faceIndex=Math.floor(u/3),e.push(i));else if(void 0!==g)if(Array.isArray(n))for(u=0,l=y.length;u<l;u++)for(f=n[(d=y[u]).materialIndex],h=Math.max(d.start,b.start),p=Math.min(d.start+d.count,b.start+b.count);h<p;h+=3)(i=tt(this,f,t,U,g,v,a=h,s=h+1,c=h+2))&&(i.faceIndex=Math.floor(h/3),e.push(i));else for(u=Math.max(0,b.start),l=Math.min(g.count,b.start+b.count);u<l;u+=3)(i=tt(this,n,t,U,g,v,a=u,s=u+1,c=u+2))&&(i.faceIndex=Math.floor(u/3),e.push(i))}else if(r.isGeometry){var x,_,w,S,A=Array.isArray(n),M=r.vertices,E=r.faces,P=r.faceVertexUvs[0];0<P.length&&(S=P);for(var T=0,C=E.length;T<C;T++){var I=E[T],O=A?n[I.materialIndex]:n;if(void 0!==O){if(x=M[I.a],_=M[I.b],w=M[I.c],!0===O.morphTargets){var L=r.morphTargets,R=this.morphTargetInfluences;G.set(0,0,0),V.set(0,0,0),H.set(0,0,0);for(var D=0,k=L.length;D<k;D++){var B=R[D];if(0!==B){var N=L[D].vertices;G.addScaledVector($.subVectors(N[I.a],x),B),V.addScaledVector(W.subVectors(N[I.b],_),B),H.addScaledVector(X.subVectors(N[I.c],w),B)}}G.add(x),V.add(_),H.add(w),x=G,_=V,w=H}if(i=Q(this,O,t,U,x,_,w,K)){if(S&&S[T]){var F=S[T];q.copy(F[0]),Y.copy(F[1]),Z.copy(F[2]),i.uv=J(K,x,_,w,q,Y,Z)}i.face=I,i.faceIndex=T,e.push(i)}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),((zn.prototype=Object.create(wi.prototype)).constructor=zn).prototype.isCubeTexture=!0,Object.defineProperty(zn.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});var Un=new wi,jn=new zn;function Gn(){this.seq=[],this.map={}}var Vn=[],Hn=[],$n=new Float32Array(16),Wn=new Float32Array(9),Xn=new Float32Array(4);function qn(t,e,i){var r=t[0];if(r<=0||0<r)return t;var n=e*i,o=Vn[n];if(void 0===o&&(o=new Float32Array(n),Vn[n]=o),0!==e){r.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=i,t[a].toArray(o,s)}return o}function Yn(t,e){if(t.length!==e.length)return!1;for(var i=0,r=t.length;i<r;i++)if(t[i]!==e[i])return!1;return!0}function Zn(t,e){for(var i=0,r=e.length;i<r;i++)t[i]=e[i]}function Kn(t,e){var i=Hn[e];void 0===i&&(i=new Int32Array(e),Hn[e]=i);for(var r=0;r!==e;++r)i[r]=t.allocTextureUnit();return i}function Jn(t,e){var i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Qn(t,e){var i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function to(t,e){var i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Yn(i,e))return;t.uniform2fv(this.addr,e),Zn(i,e)}}function eo(t,e){var i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Yn(i,e))return;t.uniform3fv(this.addr,e),Zn(i,e)}}function io(t,e){var i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Yn(i,e))return;t.uniform4fv(this.addr,e),Zn(i,e)}}function ro(t,e){var i=this.cache,r=e.elements;if(void 0===r){if(Yn(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Zn(i,e)}else{if(Yn(i,r))return;Xn.set(r),t.uniformMatrix2fv(this.addr,!1,Xn),Zn(i,r)}}function no(t,e){var i=this.cache,r=e.elements;if(void 0===r){if(Yn(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Zn(i,e)}else{if(Yn(i,r))return;Wn.set(r),t.uniformMatrix3fv(this.addr,!1,Wn),Zn(i,r)}}function oo(t,e){var i=this.cache,r=e.elements;if(void 0===r){if(Yn(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Zn(i,e)}else{if(Yn(i,r))return;$n.set(r),t.uniformMatrix4fv(this.addr,!1,$n),Zn(i,r)}}function ao(t,e,i){var r=this.cache,n=i.allocTextureUnit();r[0]!==n&&(t.uniform1i(this.addr,n),r[0]=n),i.setTexture2D(e||Un,n)}function so(t,e,i){var r=this.cache,n=i.allocTextureUnit();r[0]!==n&&(t.uniform1i(this.addr,n),r[0]=n),i.setTextureCube(e||jn,n)}function co(t,e){var i=this.cache;Yn(i,e)||(t.uniform2iv(this.addr,e),Zn(i,e))}function uo(t,e){var i=this.cache;Yn(i,e)||(t.uniform3iv(this.addr,e),Zn(i,e))}function ho(t,e){var i=this.cache;Yn(i,e)||(t.uniform4iv(this.addr,e),Zn(i,e))}function lo(t,e){var i=this.cache;Yn(i,e)||(t.uniform1fv(this.addr,e),Zn(i,e))}function po(t,e){var i=this.cache;Yn(i,e)||(t.uniform1iv(this.addr,e),Zn(i,e))}function fo(t,e){var i=this.cache,r=qn(e,this.size,2);Yn(i,r)||(t.uniform2fv(this.addr,r),this.updateCache(r))}function mo(t,e){var i=this.cache,r=qn(e,this.size,3);Yn(i,r)||(t.uniform3fv(this.addr,r),this.updateCache(r))}function go(t,e){var i=this.cache,r=qn(e,this.size,4);Yn(i,r)||(t.uniform4fv(this.addr,r),this.updateCache(r))}function vo(t,e){var i=this.cache,r=qn(e,this.size,4);Yn(i,r)||(t.uniformMatrix2fv(this.addr,!1,r),this.updateCache(r))}function yo(t,e){var i=this.cache,r=qn(e,this.size,9);Yn(i,r)||(t.uniformMatrix3fv(this.addr,!1,r),this.updateCache(r))}function bo(t,e){var i=this.cache,r=qn(e,this.size,16);Yn(i,r)||(t.uniformMatrix4fv(this.addr,!1,r),this.updateCache(r))}function xo(t,e,i){var r=this.cache,n=e.length,o=Kn(i,n);!1===Yn(r,o)&&(t.uniform1iv(this.addr,o),Zn(r,o));for(var a=0;a!==n;++a)i.setTexture2D(e[a]||Un,o[a])}function _o(t,e,i){var r=this.cache,n=e.length,o=Kn(i,n);!1===Yn(r,o)&&(t.uniform1iv(this.addr,o),Zn(r,o));for(var a=0;a!==n;++a)i.setTextureCube(e[a]||jn,o[a])}function wo(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Jn;case 35664:return to;case 35665:return eo;case 35666:return io;case 35674:return ro;case 35675:return no;case 35676:return oo;case 35678:case 36198:return ao;case 35680:return so;case 5124:case 35670:return Qn;case 35667:case 35671:return co;case 35668:case 35672:return uo;case 35669:case 35673:return ho}}(e.type)}function So(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return lo;case 35664:return fo;case 35665:return mo;case 35666:return go;case 35674:return vo;case 35675:return yo;case 35676:return bo;case 35678:return xo;case 35680:return _o;case 5124:case 35670:return po;case 35667:case 35671:return co;case 35668:case 35672:return uo;case 35669:case 35673:return ho}}(e.type)}function Ao(t){this.id=t,Gn.call(this)}So.prototype.updateCache=function(t){var e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),Zn(e,t)},Ao.prototype.setValue=function(t,e,i){for(var r=this.seq,n=0,o=r.length;n!==o;++n){var a=r[n];a.setValue(t,e[a.id],i)}};var Mo=/([\w\d_]+)(\])?(\[|\.)?/g;function Eo(t,e){t.seq.push(e),t.map[e.id]=e}function Po(t,e,i){var r=t.name,n=r.length;for(Mo.lastIndex=0;;){var o=Mo.exec(r),a=Mo.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===n){Eo(i,void 0===u?new wo(s,t,e):new So(s,t,e));break}var h=i.map[s];void 0===h&&Eo(i,h=new Ao(s)),i=h}}function To(t,e,i){Gn.call(this),this.renderer=i;for(var r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),n=0;n<r;++n){var o=t.getActiveUniform(e,n);Po(o,t.getUniformLocation(e,o.name),this)}}function Co(t,e,i){var r=t.createShader(e);return t.shaderSource(r,i),t.compileShader(r),!1===t.getShaderParameter(r,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(r)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(r),function(t){for(var e=t.split("\n"),i=0;i<e.length;i++)e[i]=i+1+": "+e[i];return e.join("\n")}(i)),r}To.prototype.setValue=function(t,e,i){var r=this.map[e];void 0!==r&&r.setValue(t,i,this.renderer)},To.prototype.setOptional=function(t,e,i){var r=e[i];void 0!==r&&this.setValue(t,i,r)},To.upload=function(t,e,i,r){for(var n=0,o=e.length;n!==o;++n){var a=e[n],s=i[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,r)}},To.seqWithValue=function(t,e){for(var i=[],r=0,n=t.length;r!==n;++r){var o=t[r];o.id in e&&i.push(o)}return i};var Io=0;function Oo(t){switch(t){case Ge:return["Linear","( value )"];case Ve:return["sRGB","( value )"];case $e:return["RGBE","( value )"];case We:return["RGBM","( value, 7.0 )"];case Xe:return["RGBM","( value, 16.0 )"];case qe:return["RGBD","( value, 256.0 )"];case He:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function Lo(t,e){var i=Oo(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function Ro(t){return""!==t}function Do(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function ko(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function Bo(t){return t.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,function(t,e){var i=Li[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return Bo(i)})}function No(t){return t.replace(/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,i,r){for(var n="",o=parseInt(e);o<parseInt(i);o++)n+=r.replace(/\[ i \]/g,"[ "+o+" ]");return n})}function Fo(t,e,i,r,n,o,a){var s=t.context,c=r.defines,u=n.vertexShader,h=n.fragmentShader,l="SHADOWMAP_TYPE_BASIC";o.shadowMapType===U?l="SHADOWMAP_TYPE_PCF":o.shadowMapType===j&&(l="SHADOWMAP_TYPE_PCF_SOFT");var p="ENVMAP_TYPE_CUBE",d="ENVMAP_MODE_REFLECTION",f="ENVMAP_BLENDING_MULTIPLY";if(o.envMap){switch(r.envMap.mapping){case Rt:case Dt:p="ENVMAP_TYPE_CUBE";break;case Ft:case zt:p="ENVMAP_TYPE_CUBE_UV";break;case kt:case Bt:p="ENVMAP_TYPE_EQUIREC";break;case Nt:p="ENVMAP_TYPE_SPHERE"}switch(r.envMap.mapping){case Dt:case Bt:d="ENVMAP_MODE_REFRACTION"}switch(r.combine){case Mt:f="ENVMAP_BLENDING_MULTIPLY";break;case Et:f="ENVMAP_BLENDING_MIX";break;case Pt:f="ENVMAP_BLENDING_ADD"}}var m,g,v,y,b,x,_,w,S=0<t.gammaFactor?t.gammaFactor:1,A=a.isWebGL2?"":(m=r.extensions,g=o,v=e,[(m=m||{}).derivatives||g.envMapCubeUV||g.bumpMap||g.normalMap&&!g.objectSpaceNormalMap||g.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(m.fragDepth||g.logarithmicDepthBuffer)&&v.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",m.drawBuffers&&v.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(m.shaderTextureLOD||g.envMap)&&v.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ro).join("\n")),M=function(t){var e=[];for(var i in t){var r=t[i];!1!==r&&e.push("#define "+i+" "+r)}return e.join("\n")}(c),E=s.createProgram();if(r.isRawShaderMaterial?(0<(y=[M].filter(Ro).join("\n")).length&&(y+="\n"),0<(b=[A,M].filter(Ro).join("\n")).length&&(b+="\n")):(y=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,M,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+S,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.normalMap&&o.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ro).join("\n"),b=[A,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,M,o.alphaTest?"#define ALPHATEST "+o.alphaTest+(o.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+S,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.envMap?"#define "+f:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.normalMap&&o.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&(a.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==Tt?"#define TONE_MAPPING":"",o.toneMapping!==Tt?Li.tonemapping_pars_fragment:"",o.toneMapping!==Tt?function(t,e){var i;switch(e){case Ct:i="Linear";break;case It:i="Reinhard";break;case Ot:i="Uncharted2";break;case Lt:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Li.encodings_pars_fragment:"",o.mapEncoding?Lo("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Lo("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Lo("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(x="linearToOutputTexel",_=o.outputEncoding,w=Oo(_),"vec4 "+x+"( vec4 value ) { return LinearTo"+w[0]+w[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Ro).join("\n")),u=ko(u=Do(u=Bo(u),o),o),h=ko(h=Do(h=Bo(h),o),o),u=No(u),h=No(h),a.isWebGL2&&!r.isRawShaderMaterial){var P=!1,T=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==u.match(T)&&null!==h.match(T)&&(P=!0,u=u.replace(T,""),h=h.replace(T,"")),y=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,b=["#version 300 es\n","#define varying in",P?"":"out highp vec4 pc_fragColor;",P?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+b}var C=y+u,I=b+h,O=Co(s,s.VERTEX_SHADER,C),L=Co(s,s.FRAGMENT_SHADER,I);s.attachShader(E,O),s.attachShader(E,L),void 0!==r.index0AttributeName?s.bindAttribLocation(E,0,r.index0AttributeName):!0===o.morphTargets&&s.bindAttribLocation(E,0,"position"),s.linkProgram(E);var R,D,k=s.getProgramInfoLog(E).trim(),B=s.getShaderInfoLog(O).trim(),N=s.getShaderInfoLog(L).trim(),F=!0,z=!0;return!1===s.getProgramParameter(E,s.LINK_STATUS)?(F=!1,console.error("THREE.WebGLProgram: shader error: ",s.getError(),"gl.VALIDATE_STATUS",s.getProgramParameter(E,s.VALIDATE_STATUS),"gl.getProgramInfoLog",k,B,N)):""!==k?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",k):""!==B&&""!==N||(z=!1),z&&(this.diagnostics={runnable:F,material:r,programLog:k,vertexShader:{log:B,prefix:y},fragmentShader:{log:N,prefix:b}}),s.deleteShader(O),s.deleteShader(L),this.getUniforms=function(){return void 0===R&&(R=new To(s,E,t)),R},this.getAttributes=function(){return void 0===D&&(D=function(t,e){for(var i={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),n=0;n<r;n++){var o=t.getActiveAttrib(e,n).name;i[o]=t.getAttribLocation(e,o)}return i}(s,E)),D},this.destroy=function(){s.deleteProgram(E),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=n.name,this.id=Io++,this.code=i,this.usedTimes=1,this.program=E,this.vertexShader=O,this.fragmentShader=L,this}function zo(l,c,p){var u=[],d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},o=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];function f(t,e){var i;return t?t.isTexture?i=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),i=t.texture.encoding):i=Ge,i===Ge&&e&&(i=He),i}this.getParameters=function(t,e,i,r,n,o,a){var s=d[t.type],c=a.isSkinnedMesh?function(t){var e=t.skeleton.bones;if(p.floatVertexTextures)return 1024;var i=p.maxVertexUniforms,r=Math.floor((i-20)/4),n=Math.min(r,e.length);return n<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+n+"."),0):n}(a):0,u=p.precision;null!==t.precision&&(u=p.getMaxPrecision(t.precision))!==t.precision&&console.warn("THREE.WebGLProgram.getParameters:",t.precision,"not supported, using",u,"instead.");var h=l.getRenderTarget();return{shaderID:s,precision:u,supportsVertexTextures:p.vertexTextures,outputEncoding:f(h?h.texture:null,l.gammaOutput),map:!!t.map,mapEncoding:f(t.map,l.gammaInput),envMap:!!t.envMap,envMapMode:t.envMap&&t.envMap.mapping,envMapEncoding:f(t.envMap,l.gammaInput),envMapCubeUV:!!t.envMap&&(t.envMap.mapping===Ft||t.envMap.mapping===zt),lightMap:!!t.lightMap,aoMap:!!t.aoMap,emissiveMap:!!t.emissiveMap,emissiveMapEncoding:f(t.emissiveMap,l.gammaInput),bumpMap:!!t.bumpMap,normalMap:!!t.normalMap,objectSpaceNormalMap:t.normalMapType===Je,displacementMap:!!t.displacementMap,roughnessMap:!!t.roughnessMap,metalnessMap:!!t.metalnessMap,specularMap:!!t.specularMap,alphaMap:!!t.alphaMap,gradientMap:!!t.gradientMap,combine:t.combine,vertexColors:t.vertexColors,fog:!!r,useFog:t.fog,fogExp:r&&r.isFogExp2,flatShading:t.flatShading,sizeAttenuation:t.sizeAttenuation,logarithmicDepthBuffer:p.logarithmicDepthBuffer,skinning:t.skinning&&0<c,maxBones:c,useVertexTexture:p.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:l.maxMorphTargets,maxMorphNormals:l.maxMorphNormals,numDirLights:e.directional.length,numPointLights:e.point.length,numSpotLights:e.spot.length,numRectAreaLights:e.rectArea.length,numHemiLights:e.hemi.length,numClippingPlanes:n,numClipIntersection:o,dithering:t.dithering,shadowMapEnabled:l.shadowMap.enabled&&a.receiveShadow&&0<i.length,shadowMapType:l.shadowMap.type,toneMapping:l.toneMapping,physicallyCorrectLights:l.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===et,flipSided:t.side===wt,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,e){var i=[];if(e.shaderID?i.push(e.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);for(var n=0;n<o.length;n++)i.push(e[o[n]]);return i.push(t.onBeforeCompile.toString()),i.push(l.gammaOutput),i.join()},this.acquireProgram=function(t,e,i,r){for(var n,o=0,a=u.length;o<a;o++){var s=u[o];if(s.code===r){++(n=s).usedTimes;break}}return void 0===n&&(n=new Fo(l,c,r,t,e,i,p),u.push(n)),n},this.releaseProgram=function(t){if(0==--t.usedTimes){var e=u.indexOf(t);u[e]=u[u.length-1],u.pop(),t.destroy()}},this.programs=u}function Uo(){var r=new WeakMap;return{get:function(t){var e=r.get(t);return void 0===e&&(e={},r.set(t,e)),e},remove:function(t){r.delete(t)},update:function(t,e,i){r.get(t)[e]=i},dispose:function(){r=new WeakMap}}}function jo(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program&&e.program&&t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Go(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Vo(){var a=[],s=0,c=[],u=[];return{opaque:c,transparent:u,init:function(){s=0,c.length=0,u.length=0},push:function(t,e,i,r,n){var o=a[s];void 0===o?(o={id:t.id,object:t,geometry:e,material:i,program:i.program,renderOrder:t.renderOrder,z:r,group:n},a[s]=o):(o.id=t.id,o.object=t,o.geometry=e,o.material=i,o.program=i.program,o.renderOrder=t.renderOrder,o.z=r,o.group=n),(!0===i.transparent?u:c).push(o),s++},sort:function(){1<c.length&&c.sort(jo),1<u.length&&u.sort(Go)}}}function Ho(){var n={};return{get:function(t,e){var i=t.id+","+e.id,r=n[i];return void 0===r&&(r=new Vo,n[i]=r),r},dispose:function(){n={}}}}function $o(){var i={};return{get:function(t){if(void 0!==i[t.id])return i[t.id];var e;switch(t.type){case"DirectionalLight":e={direction:new ri,color:new ki,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ti};break;case"SpotLight":e={position:new ri,direction:new ri,color:new ki,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ti};break;case"PointLight":e={position:new ri,color:new ki,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new ti,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":e={direction:new ri,skyColor:new ki,groundColor:new ki};break;case"RectAreaLight":e={color:new ki,position:new ri,halfWidth:new ri,halfHeight:new ri}}return i[t.id]=e}}}var Wo,Xo,qo,Yo,Zo,Ko,Jo,Qo,ta,ea,ia,ra,na,oa,aa,sa,ca=0;function ua(){var _=new $o,w={id:ca++,hash:{stateID:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,shadowsLength:-1},ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},S=new ri,A=new ei,M=new ei;return{setup:function(t,e,i){for(var r=0,n=0,o=0,a=0,s=0,c=0,u=0,h=0,l=i.matrixWorldInverse,p=0,d=t.length;p<d;p++){var f=t[p],m=f.color,g=f.intensity,v=f.distance,y=f.shadow&&f.shadow.map?f.shadow.map.texture:null;if(f.isAmbientLight)r+=m.r*g,n+=m.g*g,o+=m.b*g;else if(f.isDirectionalLight){if((x=_.get(f)).color.copy(f.color).multiplyScalar(f.intensity),x.direction.setFromMatrixPosition(f.matrixWorld),S.setFromMatrixPosition(f.target.matrixWorld),x.direction.sub(S),x.direction.transformDirection(l),x.shadow=f.castShadow,f.castShadow){var b=f.shadow;x.shadowBias=b.bias,x.shadowRadius=b.radius,x.shadowMapSize=b.mapSize}w.directionalShadowMap[a]=y,w.directionalShadowMatrix[a]=f.shadow.matrix,w.directional[a]=x,a++}else if(f.isSpotLight)(x=_.get(f)).position.setFromMatrixPosition(f.matrixWorld),x.position.applyMatrix4(l),x.color.copy(m).multiplyScalar(g),x.distance=v,x.direction.setFromMatrixPosition(f.matrixWorld),S.setFromMatrixPosition(f.target.matrixWorld),x.direction.sub(S),x.direction.transformDirection(l),x.coneCos=Math.cos(f.angle),x.penumbraCos=Math.cos(f.angle*(1-f.penumbra)),x.decay=0===f.distance?0:f.decay,x.shadow=f.castShadow,f.castShadow&&(b=f.shadow,x.shadowBias=b.bias,x.shadowRadius=b.radius,x.shadowMapSize=b.mapSize),w.spotShadowMap[c]=y,w.spotShadowMatrix[c]=f.shadow.matrix,w.spot[c]=x,c++;else if(f.isRectAreaLight)(x=_.get(f)).color.copy(m).multiplyScalar(g),x.position.setFromMatrixPosition(f.matrixWorld),x.position.applyMatrix4(l),M.identity(),A.copy(f.matrixWorld),A.premultiply(l),M.extractRotation(A),x.halfWidth.set(.5*f.width,0,0),x.halfHeight.set(0,.5*f.height,0),x.halfWidth.applyMatrix4(M),x.halfHeight.applyMatrix4(M),w.rectArea[u]=x,u++;else if(f.isPointLight)(x=_.get(f)).position.setFromMatrixPosition(f.matrixWorld),x.position.applyMatrix4(l),x.color.copy(f.color).multiplyScalar(f.intensity),x.distance=f.distance,x.decay=0===f.distance?0:f.decay,x.shadow=f.castShadow,f.castShadow&&(b=f.shadow,x.shadowBias=b.bias,x.shadowRadius=b.radius,x.shadowMapSize=b.mapSize,x.shadowCameraNear=b.camera.near,x.shadowCameraFar=b.camera.far),w.pointShadowMap[s]=y,w.pointShadowMatrix[s]=f.shadow.matrix,w.point[s]=x,s++;else if(f.isHemisphereLight){var x;(x=_.get(f)).direction.setFromMatrixPosition(f.matrixWorld),x.direction.transformDirection(l),x.direction.normalize(),x.skyColor.copy(f.color).multiplyScalar(g),x.groundColor.copy(f.groundColor).multiplyScalar(g),w.hemi[h]=x,h++}}w.ambient[0]=r,w.ambient[1]=n,w.ambient[2]=o,w.directional.length=a,w.spot.length=c,w.rectArea.length=u,w.point.length=s,w.hemi.length=h,w.hash.stateID=w.id,w.hash.directionalLength=a,w.hash.pointLength=s,w.hash.spotLength=c,w.hash.rectAreaLength=u,w.hash.hemiLength=h,w.hash.shadowsLength=e.length},state:w}}function ha(){var e=new ua,i=[],r=[];return{init:function(){i.length=0,r.length=0},state:{lightsArray:i,shadowsArray:r,lights:e},setupLights:function(t){e.setup(i,r,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){r.push(t)}}}function la(){var r={};return{get:function(t,e){var i;return void 0===r[t.id]?(i=new ha,r[t.id]={},r[t.id][e.id]=i):void 0===r[t.id][e.id]?(i=new ha,r[t.id][e.id]=i):i=r[t.id][e.id],i},dispose:function(){r={}}}}function pa(t){wn.call(this),this.type="MeshDepthMaterial",this.depthPacking=Ye,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function da(t){wn.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new ri,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function fa(b,m,t){for(var x=new Ii,_=new ei,w=new ti,S=new ti(t,t),A=new ri,M=new ri,v=1,y=2,e=1+(v|y),E=new Array(e),P=new Array(e),T={},C={0:wt,1:G,2:et},I=[new ri(1,0,0),new ri(-1,0,0),new ri(0,0,1),new ri(0,0,-1),new ri(0,1,0),new ri(0,-1,0)],O=[new ri(0,1,0),new ri(0,1,0),new ri(0,1,0),new ri(0,1,0),new ri(0,0,1),new ri(0,0,-1)],L=[new Si,new Si,new Si,new Si,new Si,new Si],i=0;i!==e;++i){var r=0!=(i&v),n=0!=(i&y),o=new pa({depthPacking:Ze,morphTargets:r,skinning:n});E[i]=o;var a=new da({morphTargets:r,skinning:n});P[i]=a}var R=this;function g(t,e,i,r,n,o){var a=t.geometry,s=null,c=E,u=t.customDepthMaterial;if(i&&(c=P,u=t.customDistanceMaterial),u)s=u;else{var h=!1;e.morphTargets&&(a&&a.isBufferGeometry?h=a.morphAttributes&&a.morphAttributes.position&&0<a.morphAttributes.position.length:a&&a.isGeometry&&(h=a.morphTargets&&0<a.morphTargets.length)),t.isSkinnedMesh&&!1===e.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var l=t.isSkinnedMesh&&e.skinning,p=0;h&&(p|=v),l&&(p|=y),s=c[p]}if(b.localClippingEnabled&&!0===e.clipShadows&&0!==e.clippingPlanes.length){var d=s.uuid,f=e.uuid,m=T[d];void 0===m&&(m={},T[d]=m);var g=m[f];void 0===g&&(g=s.clone(),m[f]=g),s=g}return s.visible=e.visible,s.wireframe=e.wireframe,s.side=null!=e.shadowSide?e.shadowSide:C[e.side],s.clipShadows=e.clipShadows,s.clippingPlanes=e.clippingPlanes,s.clipIntersection=e.clipIntersection,s.wireframeLinewidth=e.wireframeLinewidth,s.linewidth=e.linewidth,i&&s.isMeshDistanceMaterial&&(s.referencePosition.copy(r),s.nearDistance=n,s.farDistance=o),s}function D(t,e,i,r){if(!1!==t.visible){if(t.layers.test(e.layers)&&(t.isMesh||t.isLine||t.isPoints)&&t.castShadow&&(!t.frustumCulled||x.intersectsObject(t))){t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld);var n=m.update(t),o=t.material;if(Array.isArray(o))for(var a=n.groups,s=0,c=a.length;s<c;s++){var u=a[s],h=o[u.materialIndex];if(h&&h.visible){var l=g(t,h,r,M,i.near,i.far);b.renderBufferDirect(i,null,n,l,t,u)}}else if(o.visible){l=g(t,o,r,M,i.near,i.far);b.renderBufferDirect(i,null,n,l,t,null)}}for(var p=t.children,d=0,f=p.length;d<f;d++)D(p[d],e,i,r)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=U,this.render=function(t,e,i){if(!1!==R.enabled&&(!1!==R.autoUpdate||!1!==R.needsUpdate)&&0!==t.length){var r,n=b.context,o=b.state;o.disable(n.BLEND),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var a=0,s=t.length;a<s;a++){var c=t[a],u=c.shadow,h=c&&c.isPointLight;if(void 0!==u){var l=u.camera;if(w.copy(u.mapSize),w.min(S),h){var p=w.x,d=w.y;L[0].set(2*p,d,p,d),L[1].set(0,d,p,d),L[2].set(3*p,d,p,d),L[3].set(p,d,p,d),L[4].set(3*p,0,p,d),L[5].set(p,0,p,d),w.x*=4,w.y*=2}if(null===u.map){var f={minFilter:Vt,magFilter:Vt,format:ue};u.map=new Ai(w.x,w.y,f),u.map.texture.name=c.name+".shadowMap",l.updateProjectionMatrix()}u.isSpotLightShadow&&u.update(c);var m=u.map,g=u.matrix;M.setFromMatrixPosition(c.matrixWorld),l.position.copy(M),h?(r=6,g.makeTranslation(-M.x,-M.y,-M.z)):(r=1,A.setFromMatrixPosition(c.target.matrixWorld),l.lookAt(A),l.updateMatrixWorld(),g.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),g.multiply(l.projectionMatrix),g.multiply(l.matrixWorldInverse)),b.setRenderTarget(m),b.clear();for(var v=0;v<r;v++){if(h){A.copy(l.position),A.add(I[v]),l.up.copy(O[v]),l.lookAt(A),l.updateMatrixWorld();var y=L[v];o.viewport(y)}_.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),x.setFromMatrix(_),D(e,i,l,h)}}else console.warn("THREE.WebGLShadowMap:",c,"has no shadow.")}R.needsUpdate=!1}}}function ma(h,i,c,r){var n=new function(){var e=!1,o=new Si,i=null,a=new Si(0,0,0,0);return{setMask:function(t){i===t||e||(h.colorMask(t,t,t,t),i=t)},setLocked:function(t){e=t},setClear:function(t,e,i,r,n){!0===n&&(t*=r,e*=r,i*=r),o.set(t,e,i,r),!1===a.equals(o)&&(h.clearColor(t,e,i,r),a.copy(o))},reset:function(){e=!1,i=null,a.set(-1,0,0,0)}}},o=new function(){var e=!1,i=null,r=null,n=null;return{setTest:function(t){t?F(h.DEPTH_TEST):z(h.DEPTH_TEST)},setMask:function(t){i===t||e||(h.depthMask(t),i=t)},setFunc:function(t){if(r!==t){if(t)switch(t){case gt:h.depthFunc(h.NEVER);break;case vt:h.depthFunc(h.ALWAYS);break;case yt:h.depthFunc(h.LESS);break;case bt:h.depthFunc(h.LEQUAL);break;case xt:h.depthFunc(h.EQUAL);break;case _t:h.depthFunc(h.GEQUAL);break;case St:h.depthFunc(h.GREATER);break;case At:h.depthFunc(h.NOTEQUAL);break;default:h.depthFunc(h.LEQUAL)}else h.depthFunc(h.LEQUAL);r=t}},setLocked:function(t){e=t},setClear:function(t){n!==t&&(h.clearDepth(t),n=t)},reset:function(){e=!1,n=r=i=null}}},e=new function(){var e=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,u=null;return{setTest:function(t){t?F(h.STENCIL_TEST):z(h.STENCIL_TEST)},setMask:function(t){i===t||e||(h.stencilMask(t),i=t)},setFunc:function(t,e,i){r===t&&n===e&&o===i||(h.stencilFunc(t,e,i),r=t,n=e,o=i)},setOp:function(t,e,i){a===t&&s===e&&c===i||(h.stencilOp(t,e,i),a=t,s=e,c=i)},setLocked:function(t){e=t},setClear:function(t){u!==t&&(h.clearStencil(t),u=t)},reset:function(){e=!1,u=c=s=a=o=n=r=i=null}}},t=h.getParameter(h.MAX_VERTEX_ATTRIBS),a=new Uint8Array(t),s=new Uint8Array(t),u=new Uint8Array(t),l={},p=null,d=null,f=null,m=null,g=null,v=null,y=null,b=null,x=null,_=!1,w=null,S=null,A=null,M=null,E=null,P=h.getParameter(h.MAX_COMBINED_TEXTURE_IMAGE_UNITS),T=!1,C=0,I=h.getParameter(h.VERSION);-1!==I.indexOf("WebGL")?(C=parseFloat(/^WebGL\ ([0-9])/.exec(I)[1]),T=1<=C):-1!==I.indexOf("OpenGL ES")&&(C=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(I)[1]),T=2<=C);var O=null,L={},R=new Si,D=new Si;function k(t,e,i){var r=new Uint8Array(4),n=h.createTexture();h.bindTexture(t,n),h.texParameteri(t,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(t,h.TEXTURE_MAG_FILTER,h.NEAREST);for(var o=0;o<i;o++)h.texImage2D(e+o,0,h.RGBA,1,1,0,h.RGBA,h.UNSIGNED_BYTE,r);return n}var B={};function N(t,e){(a[t]=1,0===s[t]&&(h.enableVertexAttribArray(t),s[t]=1),u[t]!==e)&&((r.isWebGL2?h:i.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](t,e),u[t]=e)}function F(t){!0!==l[t]&&(h.enable(t),l[t]=!0)}function z(t){!1!==l[t]&&(h.disable(t),l[t]=!1)}function U(t,e,i,r,n,o,a,s){if(t!==q?F(h.BLEND):z(h.BLEND),t!==Q){if(t!==f||s!==_)switch(t){case Z:s?(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.ONE,h.ONE,h.ONE,h.ONE)):(h.blendEquation(h.FUNC_ADD),h.blendFunc(h.SRC_ALPHA,h.ONE));break;case K:s?(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.ZERO,h.ZERO,h.ONE_MINUS_SRC_COLOR,h.ONE_MINUS_SRC_ALPHA)):(h.blendEquation(h.FUNC_ADD),h.blendFunc(h.ZERO,h.ONE_MINUS_SRC_COLOR));break;case J:s?(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.ZERO,h.SRC_COLOR,h.ZERO,h.SRC_ALPHA)):(h.blendEquation(h.FUNC_ADD),h.blendFunc(h.ZERO,h.SRC_COLOR));break;default:s?(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.ONE,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA)):(h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA))}x=b=y=v=g=m=null}else n=n||e,o=o||i,a=a||r,e===m&&n===y||(h.blendEquationSeparate(c.convert(e),c.convert(n)),m=e,y=n),i===g&&r===v&&o===b&&a===x||(h.blendFuncSeparate(c.convert(i),c.convert(r),c.convert(o),c.convert(a)),g=i,v=r,b=o,x=a);f=t,_=s}function j(t){w!==t&&(t?h.frontFace(h.CW):h.frontFace(h.CCW),w=t)}function G(t){t!==$?(F(h.CULL_FACE),t!==S&&(t===W?h.cullFace(h.BACK):t===X?h.cullFace(h.FRONT):h.cullFace(h.FRONT_AND_BACK))):z(h.CULL_FACE),S=t}function V(t,e,i){t?(F(h.POLYGON_OFFSET_FILL),M===e&&E===i||(h.polygonOffset(e,i),M=e,E=i)):z(h.POLYGON_OFFSET_FILL)}function H(t){void 0===t&&(t=h.TEXTURE0+P-1),O!==t&&(h.activeTexture(t),O=t)}return B[h.TEXTURE_2D]=k(h.TEXTURE_2D,h.TEXTURE_2D,1),B[h.TEXTURE_CUBE_MAP]=k(h.TEXTURE_CUBE_MAP,h.TEXTURE_CUBE_MAP_POSITIVE_X,6),n.setClear(0,0,0,1),o.setClear(1),e.setClear(0),F(h.DEPTH_TEST),o.setFunc(bt),j(!1),G(W),F(h.CULL_FACE),F(h.BLEND),U(Y),{buffers:{color:n,depth:o,stencil:e},initAttributes:function(){for(var t=0,e=a.length;t<e;t++)a[t]=0},enableAttribute:function(t){N(t,0)},enableAttributeAndDivisor:N,disableUnusedAttributes:function(){for(var t=0,e=s.length;t!==e;++t)s[t]!==a[t]&&(h.disableVertexAttribArray(t),s[t]=0)},enable:F,disable:z,getCompressedTextureFormats:function(){if(null===p&&(p=[],i.get("WEBGL_compressed_texture_pvrtc")||i.get("WEBGL_compressed_texture_s3tc")||i.get("WEBGL_compressed_texture_etc1")||i.get("WEBGL_compressed_texture_astc")))for(var t=h.getParameter(h.COMPRESSED_TEXTURE_FORMATS),e=0;e<t.length;e++)p.push(t[e]);return p},useProgram:function(t){return d!==t&&(h.useProgram(t),d=t,!0)},setBlending:U,setMaterial:function(t,e){t.side===et?z(h.CULL_FACE):F(h.CULL_FACE);var i=t.side===wt;e&&(i=!i),j(i),t.blending===Y&&!1===t.transparent?U(q):U(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),n.setMask(t.colorWrite),V(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:j,setCullFace:G,setLineWidth:function(t){t!==A&&(T&&h.lineWidth(t),A=t)},setPolygonOffset:V,setScissorTest:function(t){t?F(h.SCISSOR_TEST):z(h.SCISSOR_TEST)},activeTexture:H,bindTexture:function(t,e){null===O&&H();var i=L[O];void 0===i&&(i={type:void 0,texture:void 0},L[O]=i),i.type===t&&i.texture===e||(h.bindTexture(t,e||B[t]),i.type=t,i.texture=e)},compressedTexImage2D:function(){try{h.compressedTexImage2D.apply(h,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{h.texImage2D.apply(h,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(t){!1===R.equals(t)&&(h.scissor(t.x,t.y,t.z,t.w),R.copy(t))},viewport:function(t){!1===D.equals(t)&&(h.viewport(t.x,t.y,t.z,t.w),D.copy(t))},reset:function(){for(var t=0;t<s.length;t++)1===s[t]&&(h.disableVertexAttribArray(t),s[t]=0);l={},L={},S=w=f=d=O=p=null,n.reset(),o.reset(),e.reset()}}}function ga(g,n,v,y,b,x,_){var f,s={};function w(t,e){if(t.width>e||t.height>e){if("data"in t)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+t.width+"x"+t.height+").");var i=e/Math.max(t.width,t.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(t.width*i),r.height=Math.floor(t.height*i),r.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+r.width+"x"+r.height),r}return t}function S(t){return Qe.isPowerOfTwo(t.width)&&Qe.isPowerOfTwo(t.height)}function A(t,e){return t.generateMipmaps&&e&&t.minFilter!==Vt&&t.minFilter!==Wt}function M(t,e,i,r){g.generateMipmap(t),y.get(e).__maxMipLevel=Math.log(Math.max(i,r))*Math.LOG2E}function E(t,e){if(!b.isWebGL2)return t;if(t===g.RGB){if(e===g.FLOAT)return g.RGB32F;if(e===g.HALF_FLOAT)return g.RGB16F;if(e===g.UNSIGNED_BYTE)return g.RGB8}if(t===g.RGBA){if(e===g.FLOAT)return g.RGBA32F;if(e===g.HALF_FLOAT)return g.RGBA16F;if(e===g.UNSIGNED_BYTE)return g.RGBA8}return t}function o(t){return t===Vt||t===Ht||t===$t?g.NEAREST:g.LINEAR}function P(t){var e=t.target;e.removeEventListener("dispose",P),function(t){var e=y.get(t);if(t.image&&e.__image__webglTextureCube)g.deleteTexture(e.__image__webglTextureCube);else{if(void 0===e.__webglInit)return;g.deleteTexture(e.__webglTexture)}y.remove(t)}(e),e.isVideoTexture&&delete s[e.id],_.memory.textures--}function a(t){var e=t.target;e.removeEventListener("dispose",a),function(t){var e=y.get(t),i=y.get(t.texture);if(!t)return;void 0!==i.__webglTexture&&g.deleteTexture(i.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var r=0;r<6;r++)g.deleteFramebuffer(e.__webglFramebuffer[r]),e.__webglDepthbuffer&&g.deleteRenderbuffer(e.__webglDepthbuffer[r]);else g.deleteFramebuffer(e.__webglFramebuffer),e.__webglDepthbuffer&&g.deleteRenderbuffer(e.__webglDepthbuffer);y.remove(t.texture),y.remove(t)}(e),_.memory.textures--}function c(t,e){var i,r,n,o=y.get(t);if(t.isVideoTexture&&(r=(i=t).id,n=_.render.frame,s[r]!==n&&(s[r]=n,i.update())),0<t.version&&o.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void function(t,e,i){void 0===t.__webglInit&&(t.__webglInit=!0,e.addEventListener("dispose",P),t.__webglTexture=g.createTexture(),_.memory.textures++);v.activeTexture(g.TEXTURE0+i),v.bindTexture(g.TEXTURE_2D,t.__webglTexture),g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,e.flipY),g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),g.pixelStorei(g.UNPACK_ALIGNMENT,e.unpackAlignment);var r=w(e.image,b.maxTextureSize);o=e,b.isWebGL2||o.wrapS===jt&&o.wrapT===jt&&(o.minFilter===Vt||o.minFilter===Wt)||!1!==S(r)||(r=(n=r)instanceof HTMLImageElement||n instanceof HTMLCanvasElement||n instanceof ImageBitmap?(void 0===f&&(f=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),f.width=Qe.floorPowerOfTwo(n.width),f.height=Qe.floorPowerOfTwo(n.height),f.getContext("2d").drawImage(n,0,0,f.width,f.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+n.width+"x"+n.height+"). Resized to "+f.width+"x"+f.height),f):n);var n;var o;var a=S(r),s=x.convert(e.format),c=x.convert(e.type),u=E(s,c);T(g.TEXTURE_2D,e,a);var h,l=e.mipmaps;if(e.isDepthTexture){if(u=g.DEPTH_COMPONENT,e.type===ee){if(!b.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");u=g.DEPTH_COMPONENT32F}else b.isWebGL2&&(u=g.DEPTH_COMPONENT16);e.format===pe&&u===g.DEPTH_COMPONENT&&e.type!==Jt&&e.type!==te&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),e.type=Jt,c=x.convert(e.type)),e.format===fe&&(u=g.DEPTH_STENCIL,e.type!==ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),e.type=ae,c=x.convert(e.type))),v.texImage2D(g.TEXTURE_2D,0,u,r.width,r.height,0,s,c,null)}else if(e.isDataTexture)if(0<l.length&&a){for(var p=0,d=l.length;p<d;p++)h=l[p],v.texImage2D(g.TEXTURE_2D,p,u,h.width,h.height,0,s,c,h.data);e.generateMipmaps=!1,t.__maxMipLevel=l.length-1}else v.texImage2D(g.TEXTURE_2D,0,u,r.width,r.height,0,s,c,r.data),t.__maxMipLevel=0;else if(e.isCompressedTexture){for(var p=0,d=l.length;p<d;p++)h=l[p],e.format!==ue&&e.format!==ce?-1<v.getCompressedTextureFormats().indexOf(s)?v.compressedTexImage2D(g.TEXTURE_2D,p,u,h.width,h.height,0,h.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):v.texImage2D(g.TEXTURE_2D,p,u,h.width,h.height,0,s,c,h.data);t.__maxMipLevel=l.length-1}else if(0<l.length&&a){for(var p=0,d=l.length;p<d;p++)h=l[p],v.texImage2D(g.TEXTURE_2D,p,u,s,c,h);e.generateMipmaps=!1,t.__maxMipLevel=l.length-1}else v.texImage2D(g.TEXTURE_2D,0,u,s,c,r),t.__maxMipLevel=0;A(e,a)&&M(g.TEXTURE_2D,e,r.width,r.height);t.__version=e.version,e.onUpdate&&e.onUpdate(e)}(o,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}v.activeTexture(g.TEXTURE0+e),v.bindTexture(g.TEXTURE_2D,o.__webglTexture)}function T(t,e,i){var r;if(i?(g.texParameteri(t,g.TEXTURE_WRAP_S,x.convert(e.wrapS)),g.texParameteri(t,g.TEXTURE_WRAP_T,x.convert(e.wrapT)),g.texParameteri(t,g.TEXTURE_MAG_FILTER,x.convert(e.magFilter)),g.texParameteri(t,g.TEXTURE_MIN_FILTER,x.convert(e.minFilter))):(g.texParameteri(t,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(t,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),e.wrapS===jt&&e.wrapT===jt||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),g.texParameteri(t,g.TEXTURE_MAG_FILTER,o(e.magFilter)),g.texParameteri(t,g.TEXTURE_MIN_FILTER,o(e.minFilter)),e.minFilter!==Vt&&e.minFilter!==Wt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),r=n.get("EXT_texture_filter_anisotropic")){if(e.type===ee&&null===n.get("OES_texture_float_linear"))return;if(e.type===ie&&null===(b.isWebGL2||n.get("OES_texture_half_float_linear")))return;(1<e.anisotropy||y.get(e).__currentAnisotropy)&&(g.texParameterf(t,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(e.anisotropy,b.getMaxAnisotropy())),y.get(e).__currentAnisotropy=e.anisotropy)}}function u(t,e,i,r){var n=x.convert(e.texture.format),o=x.convert(e.texture.type),a=E(n,o);v.texImage2D(r,0,a,e.width,e.height,0,n,o,null),g.bindFramebuffer(g.FRAMEBUFFER,t),g.framebufferTexture2D(g.FRAMEBUFFER,i,r,y.get(e.texture).__webglTexture,0),g.bindFramebuffer(g.FRAMEBUFFER,null)}function h(t,e){g.bindRenderbuffer(g.RENDERBUFFER,t),e.depthBuffer&&!e.stencilBuffer?(g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_COMPONENT16,e.width,e.height),g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,t)):e.depthBuffer&&e.stencilBuffer?(g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_STENCIL,e.width,e.height),g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,t)):g.renderbufferStorage(g.RENDERBUFFER,g.RGBA4,e.width,e.height),g.bindRenderbuffer(g.RENDERBUFFER,null)}function l(t){var e=y.get(t),i=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,e){if(e&&e.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(g.bindFramebuffer(g.FRAMEBUFFER,t),!e.depthTexture||!e.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");y.get(e.depthTexture).__webglTexture&&e.depthTexture.image.width===e.width&&e.depthTexture.image.height===e.height||(e.depthTexture.image.width=e.width,e.depthTexture.image.height=e.height,e.depthTexture.needsUpdate=!0),c(e.depthTexture,0);var i=y.get(e.depthTexture).__webglTexture;if(e.depthTexture.format===pe)g.framebufferTexture2D(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.TEXTURE_2D,i,0);else{if(e.depthTexture.format!==fe)throw new Error("Unknown depthTexture format");g.framebufferTexture2D(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.TEXTURE_2D,i,0)}}(e.__webglFramebuffer,t)}else if(i){e.__webglDepthbuffer=[];for(var r=0;r<6;r++)g.bindFramebuffer(g.FRAMEBUFFER,e.__webglFramebuffer[r]),e.__webglDepthbuffer[r]=g.createRenderbuffer(),h(e.__webglDepthbuffer[r],t)}else g.bindFramebuffer(g.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=g.createRenderbuffer(),h(e.__webglDepthbuffer,t);g.bindFramebuffer(g.FRAMEBUFFER,null)}this.setTexture2D=c,this.setTextureCube=function(t,e){var i=y.get(t);if(6===t.image.length)if(0<t.version&&i.__version!==t.version){i.__image__webglTextureCube||(t.addEventListener("dispose",P),i.__image__webglTextureCube=g.createTexture(),_.memory.textures++),v.activeTexture(g.TEXTURE0+e),v.bindTexture(g.TEXTURE_CUBE_MAP,i.__image__webglTextureCube),g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var r=t&&t.isCompressedTexture,n=t.image[0]&&t.image[0].isDataTexture,o=[],a=0;a<6;a++)o[a]=r||n?n?t.image[a].image:t.image[a]:w(t.image[a],b.maxCubemapSize);var s=o[0],c=S(s),u=x.convert(t.format),h=x.convert(t.type),l=E(u,h);for(T(g.TEXTURE_CUBE_MAP,t,c),a=0;a<6;a++)if(r)for(var p,d=o[a].mipmaps,f=0,m=d.length;f<m;f++)p=d[f],t.format!==ue&&t.format!==ce?-1<v.getCompressedTextureFormats().indexOf(u)?v.compressedTexImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+a,f,l,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):v.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+a,f,l,p.width,p.height,0,u,h,p.data);else n?v.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,l,o[a].width,o[a].height,0,u,h,o[a].data):v.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,l,u,h,o[a]);i.__maxMipLevel=r?d.length-1:0,A(t,c)&&M(g.TEXTURE_CUBE_MAP,t,s.width,s.height),i.__version=t.version,t.onUpdate&&t.onUpdate(t)}else v.activeTexture(g.TEXTURE0+e),v.bindTexture(g.TEXTURE_CUBE_MAP,i.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,e){v.activeTexture(g.TEXTURE0+e),v.bindTexture(g.TEXTURE_CUBE_MAP,y.get(t).__webglTexture)},this.setupRenderTarget=function(t){var e=y.get(t),i=y.get(t.texture);t.addEventListener("dispose",a),i.__webglTexture=g.createTexture(),_.memory.textures++;var r=!0===t.isWebGLRenderTargetCube,n=S(t);if(r){e.__webglFramebuffer=[];for(var o=0;o<6;o++)e.__webglFramebuffer[o]=g.createFramebuffer()}else e.__webglFramebuffer=g.createFramebuffer();if(r){for(v.bindTexture(g.TEXTURE_CUBE_MAP,i.__webglTexture),T(g.TEXTURE_CUBE_MAP,t.texture,n),o=0;o<6;o++)u(e.__webglFramebuffer[o],t,g.COLOR_ATTACHMENT0,g.TEXTURE_CUBE_MAP_POSITIVE_X+o);A(t.texture,n)&&M(g.TEXTURE_CUBE_MAP,t.texture,t.width,t.height),v.bindTexture(g.TEXTURE_CUBE_MAP,null)}else v.bindTexture(g.TEXTURE_2D,i.__webglTexture),T(g.TEXTURE_2D,t.texture,n),u(e.__webglFramebuffer,t,g.COLOR_ATTACHMENT0,g.TEXTURE_2D),A(t.texture,n)&&M(g.TEXTURE_2D,t.texture,t.width,t.height),v.bindTexture(g.TEXTURE_2D,null);t.depthBuffer&&l(t)},this.updateRenderTargetMipmap=function(t){var e=t.texture;if(A(e,S(t))){var i=t.isWebGLRenderTargetCube?g.TEXTURE_CUBE_MAP:g.TEXTURE_2D,r=y.get(e).__webglTexture;v.bindTexture(i,r),M(i,e,t.width,t.height),v.bindTexture(i,null)}}}function va(i,r,n){return{convert:function(t){var e;if(t===Ut)return i.REPEAT;if(t===jt)return i.CLAMP_TO_EDGE;if(t===Gt)return i.MIRRORED_REPEAT;if(t===Vt)return i.NEAREST;if(t===Ht)return i.NEAREST_MIPMAP_NEAREST;if(t===$t)return i.NEAREST_MIPMAP_LINEAR;if(t===Wt)return i.LINEAR;if(t===Xt)return i.LINEAR_MIPMAP_NEAREST;if(t===qt)return i.LINEAR_MIPMAP_LINEAR;if(t===Yt)return i.UNSIGNED_BYTE;if(t===re)return i.UNSIGNED_SHORT_4_4_4_4;if(t===ne)return i.UNSIGNED_SHORT_5_5_5_1;if(t===oe)return i.UNSIGNED_SHORT_5_6_5;if(t===Zt)return i.BYTE;if(t===Kt)return i.SHORT;if(t===Jt)return i.UNSIGNED_SHORT;if(t===Qt)return i.INT;if(t===te)return i.UNSIGNED_INT;if(t===ee)return i.FLOAT;if(t===ie){if(n.isWebGL2)return i.HALF_FLOAT;if(null!==(e=r.get("OES_texture_half_float")))return e.HALF_FLOAT_OES}if(t===se)return i.ALPHA;if(t===ce)return i.RGB;if(t===ue)return i.RGBA;if(t===he)return i.LUMINANCE;if(t===le)return i.LUMINANCE_ALPHA;if(t===pe)return i.DEPTH_COMPONENT;if(t===fe)return i.DEPTH_STENCIL;if(t===H)return i.FUNC_ADD;if(t===tt)return i.FUNC_SUBTRACT;if(t===it)return i.FUNC_REVERSE_SUBTRACT;if(t===ot)return i.ZERO;if(t===at)return i.ONE;if(t===st)return i.SRC_COLOR;if(t===ct)return i.ONE_MINUS_SRC_COLOR;if(t===ut)return i.SRC_ALPHA;if(t===ht)return i.ONE_MINUS_SRC_ALPHA;if(t===lt)return i.DST_ALPHA;if(t===pt)return i.ONE_MINUS_DST_ALPHA;if(t===dt)return i.DST_COLOR;if(t===ft)return i.ONE_MINUS_DST_COLOR;if(t===mt)return i.SRC_ALPHA_SATURATE;if((t===ge||t===ve||t===ye||t===be)&&null!==(e=r.get("WEBGL_compressed_texture_s3tc"))){if(t===ge)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===ve)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===ye)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===be)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===xe||t===_e||t===we||t===Se)&&null!==(e=r.get("WEBGL_compressed_texture_pvrtc"))){if(t===xe)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===_e)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===we)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===Se)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===Ae&&null!==(e=r.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((t===Me||t===Ee||t===Pe||t===Te||t===Ce||t===Ie||t===Oe||t===Le||t===Re||t===De||t===ke||t===Be||t===Ne||t===Fe)&&null!==(e=r.get("WEBGL_compressed_texture_astc")))return t;if(t===rt||t===nt){if(n.isWebGL2){if(t===rt)return i.MIN;if(t===nt)return i.MAX}if(null!==(e=r.get("EXT_blend_minmax"))){if(t===rt)return e.MIN_EXT;if(t===nt)return e.MAX_EXT}}if(t===ae){if(n.isWebGL2)return i.UNSIGNED_INT_24_8;if(null!==(e=r.get("WEBGL_depth_texture")))return e.UNSIGNED_INT_24_8_WEBGL}return 0}}}function ya(){ur.call(this),this.type="Group"}function ba(t,e,i,r){hr.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function xa(t){ba.call(this),this.cameras=t||[]}function _a(r){var s=this,c=null,u=null,h=null,l=[],p=new ei,d=new ei;"undefined"!=typeof window&&"VRFrameData"in window&&(u=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",t,!1));var f=new ei,m=new ii,g=new ri,v=new ba;v.bounds=new Si(0,0,.5,1),v.layers.enable(1);var y=new ba;y.bounds=new Si(.5,0,.5,1),y.layers.enable(2);var n,o,b=new xa([v,y]);function a(){return null!==c&&!0===c.isPresenting}function t(){if(a()){var t=c.getEyeParameters("left"),e=t.renderWidth,i=t.renderHeight;o=r.getPixelRatio(),n=r.getSize(),r.setDrawingBufferSize(2*e,i,1),w.start()}else s.enabled&&(r.setDrawingBufferSize(n.width,n.height,o),w.stop())}b.layers.enable(1),b.layers.enable(2);var x=[];function _(t){for(var e=navigator.getGamepads&&navigator.getGamepads(),i=0,r=0,n=e.length;i<n;i++){var o=e[i];if(o&&("Daydream Controller"===o.id||"Gear VR Controller"===o.id||"Oculus Go Controller"===o.id||"OpenVR Gamepad"===o.id||o.id.startsWith("Oculus Touch")||o.id.startsWith("Spatial Controller"))){if(r===t)return o;r++}}}this.enabled=!1,this.userHeight=1.6,this.getController=function(t){var e=l[t];return void 0===e&&((e=new ya).matrixAutoUpdate=!1,e.visible=!1,l[t]=e),e},this.getDevice=function(){return c},this.setDevice=function(t){void 0!==t&&(c=t),w.setContext(t)},this.setPoseTarget=function(t){void 0!==t&&(h=t)},this.getCamera=function(t){if(null===c)return t.position.set(0,s.userHeight,0),t;c.depthNear=t.near,c.depthFar=t.far,c.getFrameData(u);var e=c.stageParameters;e?p.fromArray(e.sittingToStandingTransform):p.makeTranslation(0,s.userHeight,0);var i=u.pose,r=null!==h?h:t;if(r.matrix.copy(p),r.matrix.decompose(r.position,r.quaternion,r.scale),null!==i.orientation&&(m.fromArray(i.orientation),r.quaternion.multiply(m)),null!==i.position&&(m.setFromRotationMatrix(p),g.fromArray(i.position),g.applyQuaternion(m),r.position.add(g)),r.updateMatrixWorld(),!1===c.isPresenting)return t;v.near=t.near,y.near=t.near,v.far=t.far,y.far=t.far,b.matrixWorld.copy(t.matrixWorld),b.matrixWorldInverse.copy(t.matrixWorldInverse),v.matrixWorldInverse.fromArray(u.leftViewMatrix),y.matrixWorldInverse.fromArray(u.rightViewMatrix),d.getInverse(p),v.matrixWorldInverse.multiply(d),y.matrixWorldInverse.multiply(d);var n=r.parent;null!==n&&(f.getInverse(n.matrixWorld),v.matrixWorldInverse.multiply(f),y.matrixWorldInverse.multiply(f)),v.matrixWorld.getInverse(v.matrixWorldInverse),y.matrixWorld.getInverse(y.matrixWorldInverse),v.projectionMatrix.fromArray(u.leftProjectionMatrix),y.projectionMatrix.fromArray(u.rightProjectionMatrix),b.projectionMatrix.copy(v.projectionMatrix);var o=c.getLayers();if(o.length){var a=o[0];null!==a.leftBounds&&4===a.leftBounds.length&&v.bounds.fromArray(a.leftBounds),null!==a.rightBounds&&4===a.rightBounds.length&&y.bounds.fromArray(a.rightBounds)}return function(){for(var t=0;t<l.length;t++){var e=l[t],i=_(t);if(void 0!==i&&void 0!==i.pose){if(null===i.pose)return;var r=i.pose;!1===r.hasPosition&&e.position.set(.2,-.6,-.05),null!==r.position&&e.position.fromArray(r.position),null!==r.orientation&&e.quaternion.fromArray(r.orientation),e.matrix.compose(e.position,e.quaternion,e.scale),e.matrix.premultiply(p),e.matrix.decompose(e.position,e.quaternion,e.scale),e.matrixWorldNeedsUpdate=!0,e.visible=!0;var n="Daydream Controller"===i.id?0:1;x[t]!==i.buttons[n].pressed&&(x[t]=i.buttons[n].pressed,!0===x[t]?e.dispatchEvent({type:"selectstart"}):(e.dispatchEvent({type:"selectend"}),e.dispatchEvent({type:"select"})))}else e.visible=!1}}(),b},this.getStandingMatrix=function(){return p},this.isPresenting=a;var w=new Ui;this.setAnimationLoop=function(t){w.setAnimationLoop(t)},this.submitFrame=function(){a()&&c.submitFrame()},this.dispose=function(){"undefined"!=typeof window&&window.removeEventListener("vrdisplaypresentchange",t)}}function wa(i){var r=i.context,e=null,p=null,d=null,f=null,m=[],g=[];function a(){return null!==p&&null!==d}var t=new ba;t.layers.enable(1),t.viewport=new Si;var n=new ba;n.layers.enable(2),n.viewport=new Si;var v=new xa([t,n]);function o(t){var e=m[g.indexOf(t.inputSource)];e&&e.dispatchEvent({type:t.type})}function s(){i.setFramebuffer(null),u.stop()}function c(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.getInverse(t.matrixWorld)}v.layers.enable(1),v.layers.enable(2),this.enabled=!1,this.getController=function(t){var e=m[t];return void 0===e&&((e=new ya).matrixAutoUpdate=!1,e.visible=!1,m[t]=e),e},this.getDevice=function(){return e},this.setDevice=function(t){void 0!==t&&(e=t),t instanceof XRDevice&&r.setCompatibleXRDevice(t)},this.setSession=function(t,e){null!==(p=t)&&(p.addEventListener("select",o),p.addEventListener("selectstart",o),p.addEventListener("selectend",o),p.addEventListener("end",s),p.baseLayer=new XRWebGLLayer(p,r),p.requestFrameOfReference(e.frameOfReferenceType).then(function(t){d=t,i.setFramebuffer(p.baseLayer.framebuffer),u.setContext(p),u.start()}),g=p.getInputSources(),p.addEventListener("inputsourceschange",function(){g=p.getInputSources(),console.log(g)}))},this.getCamera=function(t){if(a()){var e=t.parent,i=v.cameras;c(v,e);for(var r=0;r<i.length;r++)c(i[r],e);t.matrixWorld.copy(v.matrixWorld);for(var n=t.children,o=(r=0,n.length);r<o;r++)n[r].updateMatrixWorld(!0);return v}return t},this.isPresenting=a;var y=null;var u=new Ui;u.setAnimationLoop(function(t,e){if(null!==(f=e.getDevicePose(d)))for(var i=p.baseLayer,r=e.views,n=0;n<r.length;n++){var o=r[n],a=i.getViewport(o),s=f.getViewMatrix(o),c=v.cameras[n];c.matrix.fromArray(s).getInverse(c.matrix),c.projectionMatrix.fromArray(o.projectionMatrix),c.viewport.set(a.x,a.y,a.width,a.height),0===n&&(v.matrix.copy(c.matrix),v.projectionMatrix.copy(c.projectionMatrix))}for(n=0;n<m.length;n++){var u=m[n],h=g[n];if(h){var l=e.getInputPose(h,d);if(null!==l){u.matrix.elements=l.pointerMatrix,u.matrix.decompose(u.position,u.rotation,u.scale),u.visible=!0;continue}}u.visible=!1}y&&y(t)}),this.setAnimationLoop=function(t){y=t},this.dispose=function(){},this.getStandingMatrix=function(){return console.warn("THREE.WebXRManager: getStandingMatrix() is no longer needed."),new THREE.Matrix4},this.submitFrame=function(){}}function Sa(t){console.log("THREE.WebGLRenderer","95");var r=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),e=void 0!==t.context?t.context:null,i=void 0!==t.alpha&&t.alpha,n=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,c=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,u=void 0!==t.powerPreference?t.powerPreference:"default",d=null,j=null;this.domElement=r,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=Ct,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var G,S,V,H,h,$,l,A,M,f,y,p,m,g,E,P,T,v,W=this,b=!1,x=null,_=null,w=null,X=-1,C={geometry:null,program:null,wireframe:!1},q=null,Y=null,I=new Si,O=new Si,L=null,Z=0,R=r.width,K=r.height,J=1,D=new Si(0,0,R,K),k=new Si(0,0,R,K),B=!1,N=new Ii,Q=new On,tt=!1,et=!1,F=new ei,it=new ri;function z(){return null===_?J:1}try{var U={alpha:i,depth:n,stencil:o,antialias:a,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:u};if(r.addEventListener("webglcontextlost",at,!1),r.addEventListener("webglcontextrestored",st,!1),null===(G=e||r.getContext("webgl",U)||r.getContext("experimental-webgl",U)))throw null!==r.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===G.getShaderPrecisionFormat&&(G.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){console.error("THREE.WebGLRenderer: "+t.message)}function rt(){S=new Ln(G),(V=new In(G,S,t)).isWebGL2||(S.get("WEBGL_depth_texture"),S.get("OES_texture_float"),S.get("OES_texture_half_float"),S.get("OES_texture_half_float_linear"),S.get("OES_standard_derivatives"),S.get("OES_element_index_uint"),S.get("ANGLE_instanced_arrays")),S.get("OES_texture_float_linear"),v=new va(G,S,V),(H=new ma(G,S,v,V)).scissor(O.copy(k).multiplyScalar(J)),H.viewport(I.copy(D).multiplyScalar(J)),h=new kn(G),$=new Uo,l=new ga(G,S,H,$,V,v,h),A=new ji(G),M=new Rn(G,A,h),f=new Fn(M,h),E=new Nn(G),y=new zo(W,S,V),p=new Ho,m=new la,g=new Tn(W,H,f,s),P=new Cn(G,S,h,V),T=new Dn(G,S,h,V),h.programs=y.programs,W.context=G,W.capabilities=V,W.extensions=S,W.properties=$,W.renderLists=p,W.state=H,W.info=h}rt();var nt="xr"in navigator?new wa(W):new _a(W);this.vr=nt;var ot=new fa(W,f,V.maxTextureSize);function at(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function st(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1,rt()}function ct(t){var e,i=t.target;i.removeEventListener("dispose",ct),ut(e=i),$.remove(e)}function ut(t){var e=$.get(t).program;(t.program=void 0)!==e&&y.releaseProgram(e)}this.shadowMap=ot,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){var t=S.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=S.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(t){void 0!==t&&(J=t,this.setSize(R,K,!1))},this.getSize=function(){return{width:R,height:K}},this.setSize=function(t,e,i){nt.isPresenting()?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(R=t,K=e,r.width=t*J,r.height=e*J,!1!==i&&(r.style.width=t+"px",r.style.height=e+"px"),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(){return{width:R*J,height:K*J}},this.setDrawingBufferSize=function(t,e,i){R=t,K=e,J=i,r.width=t*i,r.height=e*i,this.setViewport(0,0,t,e)},this.getCurrentViewport=function(){return I},this.setViewport=function(t,e,i,r){D.set(t,K-e-r,i,r),H.viewport(I.copy(D).multiplyScalar(J))},this.setScissor=function(t,e,i,r){k.set(t,K-e-r,i,r),H.scissor(O.copy(k).multiplyScalar(J))},this.setScissorTest=function(t){H.setScissorTest(B=t)},this.getClearColor=function(){return g.getClearColor()},this.setClearColor=function(){g.setClearColor.apply(g,arguments)},this.getClearAlpha=function(){return g.getClearAlpha()},this.setClearAlpha=function(){g.setClearAlpha.apply(g,arguments)},this.clear=function(t,e,i){var r=0;(void 0===t||t)&&(r|=G.COLOR_BUFFER_BIT),(void 0===e||e)&&(r|=G.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=G.STENCIL_BUFFER_BIT),G.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,i,r){this.setRenderTarget(t),this.clear(e,i,r)},this.dispose=function(){r.removeEventListener("webglcontextlost",at,!1),r.removeEventListener("webglcontextrestored",st,!1),p.dispose(),m.dispose(),$.dispose(),f.dispose(),nt.dispose(),ft.stop()},this.renderBufferImmediate=function(t,e){H.initAttributes();var i=$.get(t);t.hasPositions&&!i.position&&(i.position=G.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=G.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=G.createBuffer()),t.hasColors&&!i.color&&(i.color=G.createBuffer());var r=e.getAttributes();t.hasPositions&&(G.bindBuffer(G.ARRAY_BUFFER,i.position),G.bufferData(G.ARRAY_BUFFER,t.positionArray,G.DYNAMIC_DRAW),H.enableAttribute(r.position),G.vertexAttribPointer(r.position,3,G.FLOAT,!1,0,0)),t.hasNormals&&(G.bindBuffer(G.ARRAY_BUFFER,i.normal),G.bufferData(G.ARRAY_BUFFER,t.normalArray,G.DYNAMIC_DRAW),H.enableAttribute(r.normal),G.vertexAttribPointer(r.normal,3,G.FLOAT,!1,0,0)),t.hasUvs&&(G.bindBuffer(G.ARRAY_BUFFER,i.uv),G.bufferData(G.ARRAY_BUFFER,t.uvArray,G.DYNAMIC_DRAW),H.enableAttribute(r.uv),G.vertexAttribPointer(r.uv,2,G.FLOAT,!1,0,0)),t.hasColors&&(G.bindBuffer(G.ARRAY_BUFFER,i.color),G.bufferData(G.ARRAY_BUFFER,t.colorArray,G.DYNAMIC_DRAW),H.enableAttribute(r.color),G.vertexAttribPointer(r.color,3,G.FLOAT,!1,0,0)),H.disableUnusedAttributes(),G.drawArrays(G.TRIANGLES,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,i,r,n,o){var a=n.isMesh&&n.normalMatrix.determinant()<0;H.setMaterial(r,a);var s=yt(t,e,r,n),c=!1;C.geometry===i.id&&C.program===s.id&&C.wireframe===(!0===r.wireframe)||(C.geometry=i.id,C.program=s.id,C.wireframe=!0===r.wireframe,c=!0),n.morphTargetInfluences&&(E.update(n,i,r,s),c=!0);var u,h=i.index,l=i.attributes.position,p=1;!0===r.wireframe&&(h=M.getWireframeAttribute(i),p=2);var d=P;null!==h&&(u=A.get(h),(d=T).setIndex(u)),c&&(!function(t,e,i){if(i&&i.isInstancedBufferGeometry&!V.isWebGL2&&null===S.get("ANGLE_instanced_arrays"))return console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");H.initAttributes();var r=i.attributes,n=e.getAttributes(),o=t.defaultAttributeValues;for(var a in n){var s=n[a];if(0<=s){var c=r[a];if(void 0!==c){var u=c.normalized,h=c.itemSize,l=A.get(c);if(void 0===l)continue;var p=l.buffer,d=l.type,f=l.bytesPerElement;if(c.isInterleavedBufferAttribute){var m=c.data,g=m.stride,v=c.offset;m&&m.isInstancedInterleavedBuffer?(H.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=m.meshPerAttribute*m.count)):H.enableAttribute(s),G.bindBuffer(G.ARRAY_BUFFER,p),G.vertexAttribPointer(s,h,d,u,g*f,v*f)}else c.isInstancedBufferAttribute?(H.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=c.meshPerAttribute*c.count)):H.enableAttribute(s),G.bindBuffer(G.ARRAY_BUFFER,p),G.vertexAttribPointer(s,h,d,u,0,0)}else if(void 0!==o){var y=o[a];if(void 0!==y)switch(y.length){case 2:G.vertexAttrib2fv(s,y);break;case 3:G.vertexAttrib3fv(s,y);break;case 4:G.vertexAttrib4fv(s,y);break;default:G.vertexAttrib1fv(s,y)}}}}H.disableUnusedAttributes()}(r,s,i),null!==h&&G.bindBuffer(G.ELEMENT_ARRAY_BUFFER,u.buffer));var f=1/0;null!==h?f=h.count:void 0!==l&&(f=l.count);var m=i.drawRange.start*p,g=i.drawRange.count*p,v=null!==o?o.start*p:0,y=null!==o?o.count*p:1/0,b=Math.max(m,v),x=Math.min(f,m+g,v+y)-1,_=Math.max(0,x-b+1);if(0!==_){if(n.isMesh)if(!0===r.wireframe)H.setLineWidth(r.wireframeLinewidth*z()),d.setMode(G.LINES);else switch(n.drawMode){case je:d.setMode(G.TRIANGLES);break;case 1:d.setMode(G.TRIANGLE_STRIP);break;case 2:d.setMode(G.TRIANGLE_FAN)}else if(n.isLine){var w=r.linewidth;void 0===w&&(w=1),H.setLineWidth(w*z()),n.isLineSegments?d.setMode(G.LINES):n.isLineLoop?d.setMode(G.LINE_LOOP):d.setMode(G.LINE_STRIP)}else n.isPoints?d.setMode(G.POINTS):n.isSprite&&d.setMode(G.TRIANGLES);i&&i.isInstancedBufferGeometry?0<i.maxInstancedCount&&d.renderInstances(i,b,_):d.render(b,_)}},this.compile=function(i,t){(j=m.get(i,t)).init(),i.traverse(function(t){t.isLight&&(j.pushLight(t),t.castShadow&&j.pushShadow(t))}),j.setupLights(t),i.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var e=0;e<t.material.length;e++)vt(t.material[e],i.fog,t);else vt(t.material,i.fog,t)})};var ht=null;var lt,pt,dt,ft=new Ui;function mt(t,e,i,r){for(var n=0,o=t.length;n<o;n++){var a=t[n],s=a.object,c=a.geometry,u=void 0===r?a.material:r,h=a.group;if(i.isArrayCamera)for(var l=(Y=i).cameras,p=0,d=l.length;p<d;p++){var f=l[p];if(s.layers.test(f.layers)){if("viewport"in f)H.viewport(I.copy(f.viewport));else{var m=f.bounds,g=m.x*R,v=m.y*K,y=m.z*R,b=m.w*K;H.viewport(I.set(g,v,y,b).multiplyScalar(J))}gt(s,e,f,c,u,h)}}else Y=null,gt(s,e,i,c,u,h)}}function gt(t,e,i,r,n,o){if(t.onBeforeRender(W,e,i,r,n,o),j=m.get(e,Y||i),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){H.setMaterial(n);var a=yt(i,e.fog,n,t);C.geometry=null,C.program=null,C.wireframe=!1,s=a,t.render(function(t){W.renderBufferImmediate(t,s)})}else W.renderBufferDirect(i,e.fog,r,n,t,o);var s;t.onAfterRender(W,e,i,r,n,o),j=m.get(e,Y||i)}function vt(t,e,i){var r=$.get(t),n=j.state.lights,o=j.state.shadowsArray,a=r.lightsHash,s=n.state.hash,c=y.getParameters(t,n.state,o,e,Q.numPlanes,Q.numIntersection,i),u=y.getProgramCode(t,c),h=r.program,l=!0;if(void 0===h)t.addEventListener("dispose",ct);else if(h.code!==u)ut(t);else if(a.stateID!==s.stateID||a.directionalLength!==s.directionalLength||a.pointLength!==s.pointLength||a.spotLength!==s.spotLength||a.rectAreaLength!==s.rectAreaLength||a.hemiLength!==s.hemiLength||a.shadowsLength!==s.shadowsLength)a.stateID=s.stateID,a.directionalLength=s.directionalLength,a.pointLength=s.pointLength,a.spotLength=s.spotLength,a.rectAreaLength=s.rectAreaLength,a.hemiLength=s.hemiLength,a.shadowsLength=s.shadowsLength,l=!1;else{if(void 0!==c.shaderID)return;l=!1}if(l){if(c.shaderID){var p=zi[c.shaderID];r.shader={name:t.type,uniforms:Ri.clone(p.uniforms),vertexShader:p.vertexShader,fragmentShader:p.fragmentShader}}else r.shader={name:t.type,uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};t.onBeforeCompile(r.shader,W),u=y.getProgramCode(t,c),h=y.acquireProgram(t,r.shader,c,u),r.program=h,t.program=h}var d=h.getAttributes();if(t.morphTargets)for(var f=t.numSupportedMorphTargets=0;f<W.maxMorphTargets;f++)0<=d["morphTarget"+f]&&t.numSupportedMorphTargets++;if(t.morphNormals)for(f=t.numSupportedMorphNormals=0;f<W.maxMorphNormals;f++)0<=d["morphNormal"+f]&&t.numSupportedMorphNormals++;var m=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=Q.numPlanes,r.numIntersection=Q.numIntersection,m.clippingPlanes=Q.uniform),r.fog=e,void 0===a&&(r.lightsHash=a={}),a.stateID=s.stateID,a.directionalLength=s.directionalLength,a.pointLength=s.pointLength,a.spotLength=s.spotLength,a.rectAreaLength=s.rectAreaLength,a.hemiLength=s.hemiLength,a.shadowsLength=s.shadowsLength,t.lights&&(m.ambientLightColor.value=n.state.ambient,m.directionalLights.value=n.state.directional,m.spotLights.value=n.state.spot,m.rectAreaLights.value=n.state.rectArea,m.pointLights.value=n.state.point,m.hemisphereLights.value=n.state.hemi,m.directionalShadowMap.value=n.state.directionalShadowMap,m.directionalShadowMatrix.value=n.state.directionalShadowMatrix,m.spotShadowMap.value=n.state.spotShadowMap,m.spotShadowMatrix.value=n.state.spotShadowMatrix,m.pointShadowMap.value=n.state.pointShadowMap,m.pointShadowMatrix.value=n.state.pointShadowMatrix);var g=r.program.getUniforms(),v=To.seqWithValue(g.seq,m);r.uniformsList=v}function yt(t,e,i,r){Z=0;var n=$.get(i),o=j.state.lights,a=n.lightsHash,s=o.state.hash;if(tt&&(et||t!==q)){var c=t===q&&i.id===X;Q.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,t,n,c)}!1===i.needsUpdate&&(void 0===n.program?i.needsUpdate=!0:i.fog&&n.fog!==e?i.needsUpdate=!0:(!i.lights||a.stateID===s.stateID&&a.directionalLength===s.directionalLength&&a.pointLength===s.pointLength&&a.spotLength===s.spotLength&&a.rectAreaLength===s.rectAreaLength&&a.hemiLength===s.hemiLength&&a.shadowsLength===s.shadowsLength)&&(void 0===n.numClippingPlanes||n.numClippingPlanes===Q.numPlanes&&n.numIntersection===Q.numIntersection)||(i.needsUpdate=!0)),i.needsUpdate&&(vt(i,e,r),i.needsUpdate=!1);var u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,P,T,C=!1,I=!1,O=!1,L=n.program,R=L.getUniforms(),D=n.shader.uniforms;if(H.useProgram(L.program)&&(O=I=C=!0),i.id!==X&&(X=i.id,I=!0),C||t!==q){if(R.setValue(G,"projectionMatrix",t.projectionMatrix),V.logarithmicDepthBuffer&&R.setValue(G,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),q!==(Y||t)&&(q=Y||t,O=I=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var k=R.map.cameraPosition;void 0!==k&&k.setValue(G,it.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&R.setValue(G,"viewMatrix",t.matrixWorldInverse)}if(i.skinning){R.setOptional(G,r,"bindMatrix"),R.setOptional(G,r,"bindMatrixInverse");var B=r.skeleton;if(B){var N=B.bones;if(V.floatVertexTextures){if(void 0===B.boneTexture){var F=Math.sqrt(4*N.length);F=Qe.ceilPowerOfTwo(F),F=Math.max(F,4);var z=new Float32Array(F*F*4);z.set(B.boneMatrices);var U=new Ei(z,F,F,ue,ee);U.needsUpdate=!0,B.boneMatrices=z,B.boneTexture=U,B.boneTextureSize=F}R.setValue(G,"boneTexture",B.boneTexture),R.setValue(G,"boneTextureSize",B.boneTextureSize)}else R.setOptional(G,B,"boneMatrices")}}return I&&(R.setValue(G,"toneMappingExposure",W.toneMappingExposure),R.setValue(G,"toneMappingWhitePoint",W.toneMappingWhitePoint),i.lights&&(T=O,(P=D).ambientLightColor.needsUpdate=T,P.directionalLights.needsUpdate=T,P.pointLights.needsUpdate=T,P.spotLights.needsUpdate=T,P.rectAreaLights.needsUpdate=T,P.hemisphereLights.needsUpdate=T),e&&i.fog&&(E=e,(M=D).fogColor.value=E.color,E.isFog?(M.fogNear.value=E.near,M.fogFar.value=E.far):E.isFogExp2&&(M.fogDensity.value=E.density)),i.isMeshBasicMaterial?bt(D,i):i.isMeshLambertMaterial?(bt(D,i),S=D,(A=i).emissiveMap&&(S.emissiveMap.value=A.emissiveMap)):i.isMeshPhongMaterial?(bt(D,i),i.isMeshToonMaterial?(xt(_=D,w=i),w.gradientMap&&(_.gradientMap.value=w.gradientMap)):xt(D,i)):i.isMeshStandardMaterial?(bt(D,i),i.isMeshPhysicalMaterial?(_t(b=D,x=i),b.reflectivity.value=x.reflectivity,b.clearCoat.value=x.clearCoat,b.clearCoatRoughness.value=x.clearCoatRoughness):_t(D,i)):i.isMeshDepthMaterial?(bt(D,i),v=D,(y=i).displacementMap&&(v.displacementMap.value=y.displacementMap,v.displacementScale.value=y.displacementScale,v.displacementBias.value=y.displacementBias)):i.isMeshDistanceMaterial?(bt(D,i),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(D,i)):i.isMeshNormalMaterial?(bt(D,i),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===wt&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===wt&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(D,i)):i.isLineBasicMaterial?(g=i,(m=D).diffuse.value=g.color,m.opacity.value=g.opacity,i.isLineDashedMaterial&&(f=i,(d=D).dashSize.value=f.dashSize,d.totalSize.value=f.dashSize+f.gapSize,d.scale.value=f.scale)):i.isPointsMaterial?(p=i,(l=D).diffuse.value=p.color,l.opacity.value=p.opacity,l.size.value=p.size*J,l.scale.value=.5*K,l.map.value=p.map,null!==p.map&&(!0===p.map.matrixAutoUpdate&&p.map.updateMatrix(),l.uvTransform.value.copy(p.map.matrix))):i.isSpriteMaterial?(h=i,(u=D).diffuse.value=h.color,u.opacity.value=h.opacity,u.rotation.value=h.rotation,u.map.value=h.map,null!==h.map&&(!0===h.map.matrixAutoUpdate&&h.map.updateMatrix(),u.uvTransform.value.copy(h.map.matrix))):i.isShadowMaterial&&(D.color.value=i.color,D.opacity.value=i.opacity),void 0!==D.ltc_1&&(D.ltc_1.value=Fi.LTC_1),void 0!==D.ltc_2&&(D.ltc_2.value=Fi.LTC_2),To.upload(G,n.uniformsList,D,W)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(To.upload(G,n.uniformsList,D,W),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(G,"center",r.center),R.setValue(G,"modelViewMatrix",r.modelViewMatrix),R.setValue(G,"normalMatrix",r.normalMatrix),R.setValue(G,"modelMatrix",r.matrixWorld),L}function bt(t,e){var i;t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=$.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?i=e.map:e.specularMap?i=e.specularMap:e.displacementMap?i=e.displacementMap:e.normalMap?i=e.normalMap:e.bumpMap?i=e.bumpMap:e.roughnessMap?i=e.roughnessMap:e.metalnessMap?i=e.metalnessMap:e.alphaMap?i=e.alphaMap:e.emissiveMap&&(i=e.emissiveMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}function xt(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===wt&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===wt&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function _t(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===wt&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===wt&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}ft.setAnimationLoop(function(t){nt.isPresenting()||ht&&ht(t)}),"undefined"!=typeof window&&ft.setContext(window),this.setAnimationLoop=function(t){ht=t,nt.setAnimationLoop(t),ft.start()},this.render=function(t,e,i,r){if(e&&e.isCamera){if(!b){C.geometry=null,C.program=null,C.wireframe=!1,X=-1,!(q=null)===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),nt.enabled&&(e=nt.getCamera(e)),(j=m.get(t,e)).init(),t.onBeforeRender(W,t,e,i),F.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),N.setFromMatrix(F),et=this.localClippingEnabled,tt=Q.init(this.clippingPlanes,et,e),(d=p.get(t,e)).init(),function t(e,i,r){if(!1===e.visible)return;var n=e.layers.test(i.layers);if(n)if(e.isLight)j.pushLight(e),e.castShadow&&j.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||N.intersectsSprite(e)){r&&it.setFromMatrixPosition(e.matrixWorld).applyMatrix4(F);var o=f.update(e),a=e.material;d.push(e,o,a,it.z,null)}}else if(e.isImmediateRenderObject)r&&it.setFromMatrixPosition(e.matrixWorld).applyMatrix4(F),d.push(e,null,e.material,it.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||N.intersectsObject(e))){r&&it.setFromMatrixPosition(e.matrixWorld).applyMatrix4(F);var o=f.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,c=0,u=s.length;c<u;c++){var h=s[c],l=a[h.materialIndex];l&&l.visible&&d.push(e,o,l,it.z,h)}else a.visible&&d.push(e,o,a,it.z,null)}var p=e.children;for(var c=0,u=p.length;c<u;c++)t(p[c],i,r)}(t,e,W.sortObjects),!0===W.sortObjects&&d.sort(),tt&&Q.beginShadows();var n=j.state.shadowsArray;ot.render(n,t,e),j.setupLights(e),tt&&Q.endShadows(),this.info.autoReset&&this.info.reset(),void 0===i&&(i=null),this.setRenderTarget(i),g.render(d,t,e,r);var o=d.opaque,a=d.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;o.length&&mt(o,t,e,s),a.length&&mt(a,t,e,s)}else o.length&&mt(o,t,e),a.length&&mt(a,t,e);i&&l.updateRenderTargetMipmap(i),H.buffers.depth.setTest(!0),H.buffers.depth.setMask(!0),H.buffers.color.setMask(!0),H.setPolygonOffset(!1),t.onAfterRender(W,t,e),nt.enabled&&nt.submitFrame(),j=d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.allocTextureUnit=function(){var t=Z;return t>=V.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+V.maxTextures),Z+=1,t},this.setTexture2D=(lt=!1,function(t,e){t&&t.isWebGLRenderTarget&&(lt||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),lt=!0),t=t.texture),l.setTexture2D(t,e)}),this.setTexture=(pt=!1,function(t,e){pt||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),pt=!0),l.setTexture2D(t,e)}),this.setTextureCube=(dt=!1,function(t,e){t&&t.isWebGLRenderTargetCube&&(dt||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),dt=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?l.setTextureCube(t,e):l.setTextureCubeDynamic(t,e)}),this.setFramebuffer=function(t){x=t},this.getRenderTarget=function(){return _},this.setRenderTarget=function(t){(_=t)&&void 0===$.get(t).__webglFramebuffer&&l.setupRenderTarget(t);var e=x,i=!1;if(t){var r=$.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(e=r[t.activeCubeFace],i=!0):e=r,I.copy(t.viewport),O.copy(t.scissor),L=t.scissorTest}else I.copy(D).multiplyScalar(J),O.copy(k).multiplyScalar(J),L=B;if(w!==e&&(G.bindFramebuffer(G.FRAMEBUFFER,e),w=e),H.viewport(I),H.scissor(O),H.setScissorTest(L),i){var n=$.get(t.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,n.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,i,r,n,o){if(t&&t.isWebGLRenderTarget){var a=$.get(t).__webglFramebuffer;if(a){var s=!1;a!==w&&(G.bindFramebuffer(G.FRAMEBUFFER,a),s=!0);try{var c=t.texture,u=c.format,h=c.type;if(u!==ue&&v.convert(u)!==G.getParameter(G.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Yt||v.convert(h)===G.getParameter(G.IMPLEMENTATION_COLOR_READ_TYPE)||h===ee&&(V.isWebGL2||S.get("OES_texture_float")||S.get("WEBGL_color_buffer_float"))||h===ie&&(V.isWebGL2?S.get("EXT_color_buffer_float"):S.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");G.checkFramebufferStatus(G.FRAMEBUFFER)===G.FRAMEBUFFER_COMPLETE?0<=e&&e<=t.width-r&&0<=i&&i<=t.height-n&&G.readPixels(e,i,r,n,v.convert(u),v.convert(h),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&G.bindFramebuffer(G.FRAMEBUFFER,w)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,i){var r=e.image.width,n=e.image.height,o=v.convert(e.format);this.setTexture2D(e,0),G.copyTexImage2D(G.TEXTURE_2D,i||0,o,t.x,t.y,r,n,0)},this.copyTextureToTexture=function(t,e,i,r){var n=e.image.width,o=e.image.height,a=v.convert(i.format),s=v.convert(i.type);this.setTexture2D(i,0),e.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,r||0,t.x,t.y,n,o,a,s,e.image.data):G.texSubImage2D(G.TEXTURE_2D,r||0,t.x,t.y,a,s,e.image)}}function Aa(t,e){this.name="",this.color=new ki(t),this.density=void 0!==e?e:25e-5}function Ma(t,e,i){this.name="",this.color=new ki(t),this.near=void 0!==e?e:1,this.far=void 0!==i?i:1e3}function Ea(){ur.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Pa(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Ta(t,e,i,r){this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===r}function Ca(t){wn.call(this),this.type="SpriteMaterial",this.color=new ki(16777215),this.map=null,this.rotation=0,this.lights=!1,this.transparent=!0,this.setValues(t)}function Ia(t){if(ur.call(this),this.type="Sprite",void 0===Wo){Wo=new $r;var e=new Pa(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Wo.setIndex([0,1,2,0,2,3]),Wo.addAttribute("position",new Ta(e,3,0,!1)),Wo.addAttribute("uv",new Ta(e,2,3,!1))}this.geometry=Wo,this.material=void 0!==t?t:new Ca,this.center=new ti(.5,.5)}function Oa(){ur.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function La(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new ei)}}function Ra(){ur.call(this),this.type="Bone"}function Da(t,e){Pn.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ei,this.bindMatrixInverse=new ei;var i=new La(this.initBones());this.bind(i,this.matrixWorld),this.normalizeSkinWeights()}function ka(t){wn.call(this),this.type="LineBasicMaterial",this.color=new ki(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(t)}function Ba(t,e,i){1===i&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead."),ur.call(this),this.type="Line",this.geometry=void 0!==t?t:new $r,this.material=void 0!==e?e:new ka({color:16777215*Math.random()})}function Na(t,e){Ba.call(this,t,e),this.type="LineSegments"}function Fa(t,e){Ba.call(this,t,e),this.type="LineLoop"}function za(t){wn.call(this),this.type="PointsMaterial",this.color=new ki(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function Ua(t,e){ur.call(this),this.type="Points",this.geometry=void 0!==t?t:new $r,this.material=void 0!==e?e:new za({color:16777215*Math.random()})}function ja(t,e,i,r,n,o,a,s,c){wi.call(this,t,e,i,r,n,o,a,s,c),this.generateMipmaps=!1}function Ga(t,e,i,r,n,o,a,s,c,u,h,l){wi.call(this,null,o,a,s,c,u,r,n,h,l),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Va(t,e,i,r,n,o,a,s,c){wi.call(this,t,e,i,r,n,o,a,s,c),this.needsUpdate=!0}function Ha(t,e,i,r,n,o,a,s,c,u){if((u=void 0!==u?u:pe)!==pe&&u!==fe)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&u===pe&&(i=Jt),void 0===i&&u===fe&&(i=ae),wi.call(this,null,r,n,o,a,s,u,i,c),this.image={width:t,height:e},this.magFilter=void 0!==a?a:Vt,this.minFilter=void 0!==s?s:Vt,this.flipY=!1,this.generateMipmaps=!1}function $a(t){$r.call(this),this.type="WireframeGeometry";var e,i,r,n,o,a,s,c,u,h,l=[],p=[0,0],d={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e<r;e++){var g=m[e];for(i=0;i<3;i++)s=g[f[i]],c=g[f[(i+1)%3]],p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[u=p[0]+","+p[1]]&&(d[u]={index1:p[0],index2:p[1]})}for(u in d)a=d[u],h=t.vertices[a.index1],l.push(h.x,h.y,h.z),h=t.vertices[a.index2],l.push(h.x,h.y,h.z)}else if(t&&t.isBufferGeometry){var v,y,b,x,_,w;if(h=new ri,null!==t.index){for(v=t.attributes.position,y=t.index,0===(b=t.groups).length&&(b=[{start:0,count:y.count,materialIndex:0}]),n=0,o=b.length;n<o;++n)for(r=(e=(x=b[n]).start)+x.count;e<r;e+=3)for(i=0;i<3;i++)s=y.getX(e+i),c=y.getX(e+(i+1)%3),p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[u=p[0]+","+p[1]]&&(d[u]={index1:p[0],index2:p[1]});for(u in d)a=d[u],h.fromBufferAttribute(v,a.index1),l.push(h.x,h.y,h.z),h.fromBufferAttribute(v,a.index2),l.push(h.x,h.y,h.z)}else for(e=0,r=(v=t.attributes.position).count/3;e<r;e++)for(i=0;i<3;i++)_=3*e+i,h.fromBufferAttribute(v,_),l.push(h.x,h.y,h.z),w=3*e+(i+1)%3,h.fromBufferAttribute(v,w),l.push(h.x,h.y,h.z)}this.addAttribute("position",new Ir(l,3))}function Wa(t,e,i){_r.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i},this.fromBufferGeometry(new Xa(t,e,i)),this.mergeVertices()}function Xa(t,e,i){$r.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:i};var r,n,o=[],a=[],s=[],c=[],u=new ri,h=new ri,l=new ri,p=new ri,d=new ri;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var f=e+1;for(r=0;r<=i;r++){var m=r/i;for(n=0;n<=e;n++){var g=n/e;t(g,m,h),a.push(h.x,h.y,h.z),0<=g-1e-5?(t(g-1e-5,m,l),p.subVectors(h,l)):(t(g+1e-5,m,l),p.subVectors(l,h)),0<=m-1e-5?(t(g,m-1e-5,l),d.subVectors(h,l)):(t(g,m+1e-5,l),d.subVectors(l,h)),u.crossVectors(p,d).normalize(),s.push(u.x,u.y,u.z),c.push(g,m)}}for(r=0;r<i;r++)for(n=0;n<e;n++){var v=r*f+n,y=r*f+n+1,b=(r+1)*f+n+1,x=(r+1)*f+n;o.push(v,y,x),o.push(y,b,x)}this.setIndex(o),this.addAttribute("position",new Ir(a,3)),this.addAttribute("normal",new Ir(s,3)),this.addAttribute("uv",new Ir(c,2))}function qa(t,e,i,r){_r.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:r},this.fromBufferGeometry(new Ya(t,e,i,r)),this.mergeVertices()}function Ya(r,o,t,e){$r.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:r,indices:o,radius:t,detail:e},t=t||1;var h=[],l=[];function a(t,e,i,r){var n,o,a=Math.pow(2,r),s=[];for(n=0;n<=a;n++){s[n]=[];var c=t.clone().lerp(i,n/a),u=e.clone().lerp(i,n/a),h=a-n;for(o=0;o<=h;o++)s[n][o]=0===o&&n===a?c:c.clone().lerp(u,o/h)}for(n=0;n<a;n++)for(o=0;o<2*(a-n)-1;o++){var l=Math.floor(o/2);o%2==0?(p(s[n][l+1]),p(s[n+1][l]),p(s[n][l])):(p(s[n][l+1]),p(s[n+1][l+1]),p(s[n+1][l]))}}function p(t){h.push(t.x,t.y,t.z)}function s(t,e){var i=3*t;e.x=r[i+0],e.y=r[i+1],e.z=r[i+2]}function d(t,e,i,r){r<0&&1===t.x&&(l[e]=t.x-1),0===i.x&&0===i.z&&(l[e]=r/2/Math.PI+.5)}function f(t){return Math.atan2(t.z,-t.x)}!function(t){for(var e=new ri,i=new ri,r=new ri,n=0;n<o.length;n+=3)s(o[n+0],e),s(o[n+1],i),s(o[n+2],r),a(e,i,r,t)}(e=e||0),function(t){for(var e=new ri,i=0;i<h.length;i+=3)e.x=h[i+0],e.y=h[i+1],e.z=h[i+2],e.normalize().multiplyScalar(t),h[i+0]=e.x,h[i+1]=e.y,h[i+2]=e.z}(t),function(){for(var t=new ri,e=0;e<h.length;e+=3){t.x=h[e+0],t.y=h[e+1],t.z=h[e+2];var i=f(t)/2/Math.PI+.5,r=(n=t,Math.atan2(-n.y,Math.sqrt(n.x*n.x+n.z*n.z))/Math.PI+.5);l.push(i,1-r)}var n;(function(){for(var t=new ri,e=new ri,i=new ri,r=new ri,n=new ti,o=new ti,a=new ti,s=0,c=0;s<h.length;s+=9,c+=6){t.set(h[s+0],h[s+1],h[s+2]),e.set(h[s+3],h[s+4],h[s+5]),i.set(h[s+6],h[s+7],h[s+8]),n.set(l[c+0],l[c+1]),o.set(l[c+2],l[c+3]),a.set(l[c+4],l[c+5]),r.copy(t).add(e).add(i).divideScalar(3);var u=f(r);d(n,c+0,t,u),d(o,c+2,e,u),d(a,c+4,i,u)}})(),function(){for(var t=0;t<l.length;t+=6){var e=l[t+0],i=l[t+2],r=l[t+4],n=Math.max(e,i,r),o=Math.min(e,i,r);.9<n&&o<.1&&(e<.2&&(l[t+0]+=1),i<.2&&(l[t+2]+=1),r<.2&&(l[t+4]+=1))}}()}(),this.addAttribute("position",new Ir(h,3)),this.addAttribute("normal",new Ir(h.slice(),3)),this.addAttribute("uv",new Ir(l,2)),0===e?this.computeVertexNormals():this.normalizeNormals()}function Za(t,e){_r.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ka(t,e)),this.mergeVertices()}function Ka(t,e){Ya.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ja(t,e){_r.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Qa(t,e)),this.mergeVertices()}function Qa(t,e){Ya.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ts(t,e){_r.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new es(t,e)),this.mergeVertices()}function es(t,e){var i=(1+Math.sqrt(5))/2;Ya.call(this,[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function is(t,e){_r.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new rs(t,e)),this.mergeVertices()}function rs(t,e){var i=(1+Math.sqrt(5))/2,r=1/i;Ya.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ns(t,e,i,r,n,o){_r.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new os(t,e,i,r,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function os(a,s,c,u,t){$r.call(this),this.type="TubeBufferGeometry",this.parameters={path:a,tubularSegments:s,radius:c,radialSegments:u,closed:t},s=s||64,c=c||1,u=u||8,t=t||!1;var h=a.computeFrenetFrames(s,t);this.tangents=h.tangents,this.normals=h.normals,this.binormals=h.binormals;var n,l,p=new ri,d=new ri,e=new ti,f=new ri,m=[],g=[],i=[],o=[];function r(t){f=a.getPointAt(t/s,f);var e=h.normals[t],i=h.binormals[t];for(l=0;l<=u;l++){var r=l/u*Math.PI*2,n=Math.sin(r),o=-Math.cos(r);d.x=o*e.x+n*i.x,d.y=o*e.y+n*i.y,d.z=o*e.z+n*i.z,d.normalize(),g.push(d.x,d.y,d.z),p.x=f.x+c*d.x,p.y=f.y+c*d.y,p.z=f.z+c*d.z,m.push(p.x,p.y,p.z)}}!function(){for(n=0;n<s;n++)r(n);r(!1===t?s:0),function(){for(n=0;n<=s;n++)for(l=0;l<=u;l++)e.x=n/s,e.y=l/u,i.push(e.x,e.y)}(),function(){for(l=1;l<=s;l++)for(n=1;n<=u;n++){var t=(u+1)*(l-1)+(n-1),e=(u+1)*l+(n-1),i=(u+1)*l+n,r=(u+1)*(l-1)+n;o.push(t,e,r),o.push(e,i,r)}}()}(),this.setIndex(o),this.addAttribute("position",new Ir(m,3)),this.addAttribute("normal",new Ir(g,3)),this.addAttribute("uv",new Ir(i,2))}function as(t,e,i,r,n,o,a){_r.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:n,q:o},void 0!==a&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new ss(t,e,i,r,n,o)),this.mergeVertices()}function ss(t,e,i,r,n,o){$r.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:r,p:n,q:o},t=t||1,e=e||.4,i=Math.floor(i)||64,r=Math.floor(r)||8,n=n||2,o=o||3;var a,s,c=[],u=[],h=[],l=[],p=new ri,d=new ri,f=new ri,m=new ri,g=new ri,v=new ri,y=new ri;for(a=0;a<=i;++a){var b=a/i*n*Math.PI*2;for(P(b,n,o,t,f),P(b+.01,n,o,t,m),v.subVectors(m,f),y.addVectors(m,f),g.crossVectors(v,y),y.crossVectors(g,v),g.normalize(),y.normalize(),s=0;s<=r;++s){var x=s/r*Math.PI*2,_=-e*Math.cos(x),w=e*Math.sin(x);p.x=f.x+(_*y.x+w*g.x),p.y=f.y+(_*y.y+w*g.y),p.z=f.z+(_*y.z+w*g.z),u.push(p.x,p.y,p.z),d.subVectors(p,f).normalize(),h.push(d.x,d.y,d.z),l.push(a/i),l.push(s/r)}}for(s=1;s<=i;s++)for(a=1;a<=r;a++){var S=(r+1)*(s-1)+(a-1),A=(r+1)*s+(a-1),M=(r+1)*s+a,E=(r+1)*(s-1)+a;c.push(S,A,E),c.push(A,M,E)}function P(t,e,i,r,n){var o=Math.cos(t),a=Math.sin(t),s=i/e*t,c=Math.cos(s);n.x=r*(2+c)*.5*o,n.y=r*(2+c)*a*.5,n.z=r*Math.sin(s)*.5}this.setIndex(c),this.addAttribute("position",new Ir(u,3)),this.addAttribute("normal",new Ir(h,3)),this.addAttribute("uv",new Ir(l,2))}function cs(t,e,i,r,n){_r.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:n},this.fromBufferGeometry(new us(t,e,i,r,n)),this.mergeVertices()}function us(t,e,i,r,n){$r.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:r,arc:n},t=t||1,e=e||.4,i=Math.floor(i)||8,r=Math.floor(r)||6,n=n||2*Math.PI;var o,a,s=[],c=[],u=[],h=[],l=new ri,p=new ri,d=new ri;for(o=0;o<=i;o++)for(a=0;a<=r;a++){var f=a/r*n,m=o/i*Math.PI*2;p.x=(t+e*Math.cos(m))*Math.cos(f),p.y=(t+e*Math.cos(m))*Math.sin(f),p.z=e*Math.sin(m),c.push(p.x,p.y,p.z),l.x=t*Math.cos(f),l.y=t*Math.sin(f),d.subVectors(p,l).normalize(),u.push(d.x,d.y,d.z),h.push(a/r),h.push(o/i)}for(o=1;o<=i;o++)for(a=1;a<=r;a++){var g=(r+1)*o+a-1,v=(r+1)*(o-1)+a-1,y=(r+1)*(o-1)+a,b=(r+1)*o+a;s.push(g,v,b),s.push(v,y,b)}this.setIndex(s),this.addAttribute("position",new Ir(c,3)),this.addAttribute("normal",new Ir(u,3)),this.addAttribute("uv",new Ir(h,2))}((pa.prototype=Object.create(wn.prototype)).constructor=pa).prototype.isMeshDepthMaterial=!0,pa.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},((da.prototype=Object.create(wn.prototype)).constructor=da).prototype.isMeshDistanceMaterial=!0,da.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},ya.prototype=Object.assign(Object.create(ur.prototype),{constructor:ya,isGroup:!0}),ba.prototype=Object.assign(Object.create(hr.prototype),{constructor:ba,isPerspectiveCamera:!0,copy:function(t,e){return hr.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*Qe.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*Qe.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*Qe.RAD2DEG*Math.atan(Math.tan(.5*Qe.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,r,n,o){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*Qe.DEG2RAD*this.fov)/this.zoom,i=2*e,r=this.aspect*i,n=-.5*r,o=this.view;if(null!==this.view&&this.view.enabled){var a=o.fullWidth,s=o.fullHeight;n+=o.offsetX*r/a,e-=o.offsetY*i/s,r*=o.width/a,i*=o.height/s}var c=this.filmOffset;0!==c&&(n+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,e,e-i,t,this.far)},toJSON:function(t){var e=ur.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}),xa.prototype=Object.assign(Object.create(ba.prototype),{constructor:xa,isArrayCamera:!0}),Aa.prototype.isFogExp2=!0,Aa.prototype.clone=function(){return new Aa(this.color,this.density)},Aa.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},Ma.prototype.isFog=!0,Ma.prototype.clone=function(){return new Ma(this.color,this.near,this.far)},Ma.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},Ea.prototype=Object.assign(Object.create(ur.prototype),{constructor:Ea,copy:function(t,e){return ur.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},toJSON:function(t){var e=ur.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}),Object.defineProperty(Pa.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Pa.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");return this.count=void 0!==t?t.length/this.stride:0,this.array=t,this},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){t*=this.stride,i*=e.stride;for(var r=0,n=this.stride;r<n;r++)this.array[t+r]=e.array[i+r];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}}),Object.defineProperties(Ta.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Ta.prototype,{isInterleavedBufferAttribute:!0,setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=r,this},setXYZW:function(t,e,i,r,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=r,this.data.array[t+3]=n,this}}),((Ca.prototype=Object.create(wn.prototype)).constructor=Ca).prototype.isSpriteMaterial=!0,Ca.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.rotation=t.rotation,this},Ia.prototype=Object.assign(Object.create(ur.prototype),{constructor:Ia,isSprite:!0,raycast:function(){var c=new ri,u=new ri,h=new ri,a=new ti,s=new ti,l=new ei,p=new ri,d=new ri,f=new ri;function m(t,e,i,r,n,o){a.subVectors(t,i).addScalar(.5).multiply(r),void 0!==n?(s.x=o*a.x-n*a.y,s.y=n*a.x+o*a.y):s.copy(a),t.copy(e),t.x+=s.x,t.y+=s.y,t.applyMatrix4(l)}return function(t,e){u.setFromMatrixScale(this.matrixWorld),l.getInverse(this.modelViewMatrix).premultiply(this.matrixWorld),h.setFromMatrixPosition(this.modelViewMatrix);var i,r,n=this.material.rotation;0!==n&&(r=Math.cos(n),i=Math.sin(n));var o=this.center;m(p.set(-.5,-.5,0),h,o,u,i,r),m(d.set(.5,-.5,0),h,o,u,i,r),m(f.set(.5,.5,0),h,o,u,i,r);var a=t.ray.intersectTriangle(p,d,f,!1,c);if(null!==a||(m(d.set(-.5,.5,0),h,o,u,i,r),null!==(a=t.ray.intersectTriangle(p,f,d,!1,c)))){var s=t.ray.origin.distanceTo(c);s<t.near||s>t.far||e.push({distance:s,point:c.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return ur.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}}),Oa.prototype=Object.assign(Object.create(ur.prototype),{constructor:Oa,copy:function(t){ur.prototype.copy.call(this,t,!1);for(var e=t.levels,i=0,r=e.length;i<r;i++){var n=e[i];this.addLevel(n.object.clone(),n.distance)}return this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var i=this.levels,r=0;r<i.length&&!(e<i[r].distance);r++);i.splice(r,0,{distance:e,object:t}),this.add(t)},getObjectForDistance:function(t){for(var e=this.levels,i=1,r=e.length;i<r&&!(t<e[i].distance);i++);return e[i-1].object},raycast:(Yo=new ri,function(t,e){Yo.setFromMatrixPosition(this.matrixWorld);var i=t.ray.origin.distanceTo(Yo);this.getObjectForDistance(i).raycast(t,e)}),update:(Xo=new ri,qo=new ri,function(t){var e=this.levels;if(1<e.length){Xo.setFromMatrixPosition(t.matrixWorld),qo.setFromMatrixPosition(this.matrixWorld);var i=Xo.distanceTo(qo);e[0].object.visible=!0;for(var r=1,n=e.length;r<n&&i>=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(;r<n;r++)e[r].object.visible=!1}}),toJSON:function(t){var e=ur.prototype.toJSON.call(this,t);e.object.levels=[];for(var i=this.levels,r=0,n=i.length;r<n;r++){var o=i[r];e.object.levels.push({object:o.object.uuid,distance:o.distance})}return e}}),Object.assign(La.prototype,{calculateInverses:function(){this.boneInverses=[];for(var t=0,e=this.bones.length;t<e;t++){var i=new ei;this.bones[t]&&i.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(i)}},pose:function(){var t,e,i;for(e=0,i=this.bones.length;e<i;e++)(t=this.bones[e])&&t.matrixWorld.getInverse(this.boneInverses[e]);for(e=0,i=this.bones.length;e<i;e++)(t=this.bones[e])&&(t.parent&&t.parent.isBone?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},update:(Zo=new ei,Ko=new ei,function(){for(var t=this.bones,e=this.boneInverses,i=this.boneMatrices,r=this.boneTexture,n=0,o=t.length;n<o;n++){var a=t[n]?t[n].matrixWorld:Ko;Zo.multiplyMatrices(a,e[n]),Zo.toArray(i,16*n)}void 0!==r&&(r.needsUpdate=!0)}),clone:function(){return new La(this.bones,this.boneInverses)},getBoneByName:function(t){for(var e=0,i=this.bones.length;e<i;e++){var r=this.bones[e];if(r.name===t)return r}}}),Ra.prototype=Object.assign(Object.create(ur.prototype),{constructor:Ra,isBone:!0}),Da.prototype=Object.assign(Object.create(Pn.prototype),{constructor:Da,isSkinnedMesh:!0,initBones:function(){var t,e,i,r,n=[];if(this.geometry&&void 0!==this.geometry.bones){for(i=0,r=this.geometry.bones.length;i<r;i++)e=this.geometry.bones[i],t=new Ra,n.push(t),t.name=e.name,t.position.fromArray(e.pos),t.quaternion.fromArray(e.rotq),void 0!==e.scl&&t.scale.fromArray(e.scl);for(i=0,r=this.geometry.bones.length;i<r;i++)-1!==(e=this.geometry.bones[i]).parent&&null!==e.parent&&void 0!==n[e.parent]?n[e.parent].add(n[i]):this.add(n[i])}return this.updateMatrixWorld(!0),n},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var t,e;if(this.geometry&&this.geometry.isGeometry)for(e=0;e<this.geometry.skinWeights.length;e++){var i=this.geometry.skinWeights[e];(t=1/i.manhattanLength())!==1/0?i.multiplyScalar(t):i.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){var r=new Si,n=this.geometry.attributes.skinWeight;for(e=0;e<n.count;e++)r.x=n.getX(e),r.y=n.getY(e),r.z=n.getZ(e),r.w=n.getW(e),(t=1/r.manhattanLength())!==1/0?r.multiplyScalar(t):r.set(1,0,0,0),n.setXYZW(e,r.x,r.y,r.z,r.w)}},updateMatrixWorld:function(t){Pn.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),((ka.prototype=Object.create(wn.prototype)).constructor=ka).prototype.isLineBasicMaterial=!0,ka.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this},Ba.prototype=Object.assign(Object.create(ur.prototype),{constructor:Ba,isLine:!0,computeLineDistances:(ea=new ri,ia=new ri,function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,i=[0],r=1,n=e.count;r<n;r++)ea.fromBufferAttribute(e,r-1),ia.fromBufferAttribute(e,r),i[r]=i[r-1],i[r]+=ea.distanceTo(ia);t.addAttribute("lineDistance",new Ir(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var o=t.vertices;for((i=t.lineDistances)[0]=0,r=1,n=o.length;r<n;r++)i[r]=i[r-1],i[r]+=o[r-1].distanceTo(o[r])}return this}),raycast:(Jo=new ei,Qo=new Mn,ta=new Ti,function(t,e){var i=t.linePrecision,r=i*i,n=this.geometry,o=this.matrixWorld;if(null===n.boundingSphere&&n.computeBoundingSphere(),ta.copy(n.boundingSphere),ta.applyMatrix4(o),!1!==t.ray.intersectsSphere(ta)){Jo.getInverse(o),Qo.copy(t.ray).applyMatrix4(Jo);var a=new ri,s=new ri,c=new ri,u=new ri,h=this&&this.isLineSegments?2:1;if(n.isBufferGeometry){var l=n.index,p=n.attributes.position.array;if(null!==l)for(var d=l.array,f=0,m=d.length-1;f<m;f+=h){var g=d[f],v=d[f+1];a.fromArray(p,3*g),s.fromArray(p,3*v),r<Qo.distanceSqToSegment(a,s,u,c)||(u.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(u))<t.near||x>t.far||e.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}else for(f=0,m=p.length/3-1;f<m;f+=h)a.fromArray(p,3*f),s.fromArray(p,3*f+3),r<Qo.distanceSqToSegment(a,s,u,c)||(u.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(u))<t.near||x>t.far||e.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}else if(n.isGeometry){var y=n.vertices,b=y.length;for(f=0;f<b-1;f+=h){var x;r<Qo.distanceSqToSegment(y[f],y[f+1],u,c)||(u.applyMatrix4(this.matrixWorld),(x=t.ray.origin.distanceTo(u))<t.near||x>t.far||e.push({distance:x,point:c.clone().applyMatrix4(this.matrixWorld),index:f,face:null,faceIndex:null,object:this}))}}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Na.prototype=Object.assign(Object.create(Ba.prototype),{constructor:Na,isLineSegments:!0,computeLineDistances:(ra=new ri,na=new ri,function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,i=[],r=0,n=e.count;r<n;r+=2)ra.fromBufferAttribute(e,r),na.fromBufferAttribute(e,r+1),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+ra.distanceTo(na);t.addAttribute("lineDistance",new Ir(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var o=t.vertices;for(i=t.lineDistances,r=0,n=o.length;r<n;r+=2)ra.copy(o[r]),na.copy(o[r+1]),i[r]=0===r?0:i[r-1],i[r+1]=i[r]+ra.distanceTo(na)}return this})}),Fa.prototype=Object.assign(Object.create(Ba.prototype),{constructor:Fa,isLineLoop:!0}),((za.prototype=Object.create(wn.prototype)).constructor=za).prototype.isPointsMaterial=!0,za.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this},Ua.prototype=Object.assign(Object.create(ur.prototype),{constructor:Ua,isPoints:!0,raycast:(oa=new ei,aa=new Mn,sa=new Ti,function(n,o){var a=this,t=this.geometry,s=this.matrixWorld,e=n.params.Points.threshold;if(null===t.boundingSphere&&t.computeBoundingSphere(),sa.copy(t.boundingSphere),sa.applyMatrix4(s),sa.radius+=e,!1!==n.ray.intersectsSphere(sa)){oa.getInverse(s),aa.copy(n.ray).applyMatrix4(oa);var i=e/((this.scale.x+this.scale.y+this.scale.z)/3),c=i*i,r=new ri,u=new ri;if(t.isBufferGeometry){var h=t.index,l=t.attributes.position.array;if(null!==h)for(var p=h.array,d=0,f=p.length;d<f;d++){var m=p[d];r.fromArray(l,3*m),y(r,m)}else{d=0;for(var g=l.length/3;d<g;d++)r.fromArray(l,3*d),y(r,d)}}else{var v=t.vertices;for(d=0,g=v.length;d<g;d++)y(v[d],d)}}function y(t,e){var i=aa.distanceSqToPoint(t);if(i<c){aa.closestPointToPoint(t,u),u.applyMatrix4(s);var r=n.ray.origin.distanceTo(u);if(r<n.near||r>n.far)return;o.push({distance:r,distanceToRay:Math.sqrt(i),point:u.clone(),index:e,face:null,object:a})}}}),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ja.prototype=Object.assign(Object.create(wi.prototype),{constructor:ja,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),((Ga.prototype=Object.create(wi.prototype)).constructor=Ga).prototype.isCompressedTexture=!0,((Va.prototype=Object.create(wi.prototype)).constructor=Va).prototype.isCanvasTexture=!0,((Ha.prototype=Object.create(wi.prototype)).constructor=Ha).prototype.isDepthTexture=!0,($a.prototype=Object.create($r.prototype)).constructor=$a,(Wa.prototype=Object.create(_r.prototype)).constructor=Wa,(Xa.prototype=Object.create($r.prototype)).constructor=Xa,(qa.prototype=Object.create(_r.prototype)).constructor=qa,(Ya.prototype=Object.create($r.prototype)).constructor=Ya,(Za.prototype=Object.create(_r.prototype)).constructor=Za,(Ka.prototype=Object.create(Ya.prototype)).constructor=Ka,(Ja.prototype=Object.create(_r.prototype)).constructor=Ja,(Qa.prototype=Object.create(Ya.prototype)).constructor=Qa,(ts.prototype=Object.create(_r.prototype)).constructor=ts,(es.prototype=Object.create(Ya.prototype)).constructor=es,(is.prototype=Object.create(_r.prototype)).constructor=is,(rs.prototype=Object.create(Ya.prototype)).constructor=rs,(ns.prototype=Object.create(_r.prototype)).constructor=ns,(os.prototype=Object.create($r.prototype)).constructor=os,(as.prototype=Object.create(_r.prototype)).constructor=as,(ss.prototype=Object.create($r.prototype)).constructor=ss,(cs.prototype=Object.create(_r.prototype)).constructor=cs,(us.prototype=Object.create($r.prototype)).constructor=us;var hs=function(t,e,i){i=i||2;var r,n,o,a,s,c,u,h=e&&e.length,l=h?e[0]*i:t.length,p=ls(t,0,l,i,!0),d=[];if(!p)return d;if(h&&(p=function(t,e,i,r){var n,o,a,s,c,u=[];for(n=0,o=e.length;n<o;n++)a=e[n]*r,s=n<o-1?e[n+1]*r:t.length,(c=ls(t,a,s,r,!1))===c.next&&(c.steiner=!0),u.push(_s(c));for(u.sort(ys),n=0;n<u.length;n++)bs(u[n],i),i=ps(i,i.next);return i}(t,e,p,i)),t.length>80*i){r=o=t[0],n=a=t[1];for(var f=i;f<l;f+=i)(s=t[f])<r&&(r=s),(c=t[f+1])<n&&(n=c),o<s&&(o=s),a<c&&(a=c);u=0!==(u=Math.max(o-r,a-n))?1/u:0}return ds(p,d,i,r,n,u),d};function ls(t,e,i,r,n){var o,a;if(n===0<function(t,e,i,r){for(var n=0,o=e,a=i-r;o<i;o+=r)n+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return n}(t,e,i,r))for(o=e;o<i;o+=r)a=Ts(o,t[o],t[o+1],a);else for(o=i-r;e<=o;o-=r)a=Ts(o,t[o],t[o+1],a);return a&&As(a,a.next)&&(Cs(a),a=a.next),a}function ps(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!As(r,r.next)&&0!==Ss(r.prev,r,r.next))r=r.next;else{if(Cs(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function ds(t,e,i,r,n,o,a){if(t){!a&&o&&function(t,e,i,r){var n=t;for(;null===n.z&&(n.z=xs(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next,n!==t;);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,o,a,s,c,u=1;do{for(i=t,o=t=null,a=0;i;){for(a++,r=i,e=s=0;e<u&&(s++,r=r.nextZ);e++);for(c=u;0<s||0<c&&r;)0!==s&&(0===c||!r||i.z<=r.z)?(i=(n=i).nextZ,s--):(r=(n=r).nextZ,c--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;i=r}o.nextZ=null,u*=2}while(1<a)}(n)}(t,r,n,o);for(var s,c,u=t;t.prev!==t.next;)if(s=t.prev,c=t.next,o?ms(t,r,n,o):fs(t))e.push(s.i/i),e.push(t.i/i),e.push(c.i/i),Cs(t),t=c.next,u=c.next;else if((t=c)===u){a?1===a?ds(t=gs(t,e,i),e,i,r,n,o,2):2===a&&vs(t,e,i,r,n,o):ds(ps(t),e,i,r,n,o,1);break}}}function fs(t){var e=t.prev,i=t,r=t.next;if(0<=Ss(e,i,r))return!1;for(var n=t.next.next;n!==t.prev;){if(ws(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&0<=Ss(n.prev,n,n.next))return!1;n=n.next}return!0}function ms(t,e,i,r){var n=t.prev,o=t,a=t.next;if(0<=Ss(n,o,a))return!1;for(var s=n.x<o.x?n.x<a.x?n.x:a.x:o.x<a.x?o.x:a.x,c=n.y<o.y?n.y<a.y?n.y:a.y:o.y<a.y?o.y:a.y,u=n.x>o.x?n.x>a.x?n.x:a.x:o.x>a.x?o.x:a.x,h=n.y>o.y?n.y>a.y?n.y:a.y:o.y>a.y?o.y:a.y,l=xs(s,c,e,i,r),p=xs(u,h,e,i,r),d=t.nextZ;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&ws(n.x,n.y,o.x,o.y,a.x,a.y,d.x,d.y)&&0<=Ss(d.prev,d,d.next))return!1;d=d.nextZ}for(d=t.prevZ;d&&d.z>=l;){if(d!==t.prev&&d!==t.next&&ws(n.x,n.y,o.x,o.y,a.x,a.y,d.x,d.y)&&0<=Ss(d.prev,d,d.next))return!1;d=d.prevZ}return!0}function gs(t,e,i){var r=t;do{var n=r.prev,o=r.next.next;!As(n,o)&&Ms(n,r,r.next,o)&&Es(n,o)&&Es(o,n)&&(e.push(n.i/i),e.push(r.i/i),e.push(o.i/i),Cs(r),Cs(r.next),r=t=o),r=r.next}while(r!==t);return r}function vs(t,e,i,r,n,o){var a,s,c=t;do{for(var u=c.next.next;u!==c.prev;){if(c.i!==u.i&&(s=u,(a=c).next.i!==s.i&&a.prev.i!==s.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Ms(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(a,s)&&Es(a,s)&&Es(s,a)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;for(;i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next,i!==t;);return r}(a,s))){var h=Ps(c,u);return c=ps(c,c.next),h=ps(h,h.next),ds(c,e,i,r,n,o),void ds(h,e,i,r,n,o)}u=u.next}c=c.next}while(c!==t)}function ys(t,e){return t.x-e.x}function bs(t,e){if(e=function(t,e){var i,r=e,n=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=n&&a<s){if((a=s)===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===a)return i.prev;var c,u=i,h=i.x,l=i.y,p=1/0;r=i.next;for(;r!==u;)n>=r.x&&r.x>=h&&n!==r.x&&ws(o<l?n:a,o,h,l,o<l?a:n,o,r.x,r.y)&&((c=Math.abs(o-r.y)/(n-r.x))<p||c===p&&r.x>i.x)&&Es(r,t)&&(i=r,p=c),r=r.next;return i}(t,e)){var i=Ps(e,t);ps(i,i.next)}}function xs(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function _s(t){for(var e=t,i=t;e.x<i.x&&(i=e),(e=e.next)!==t;);return i}function ws(t,e,i,r,n,o,a,s){return 0<=(n-a)*(e-s)-(t-a)*(o-s)&&0<=(t-a)*(r-s)-(i-a)*(e-s)&&0<=(i-a)*(o-s)-(n-a)*(r-s)}function Ss(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function As(t,e){return t.x===e.x&&t.y===e.y}function Ms(t,e,i,r){return!!(As(t,e)&&As(i,r)||As(t,r)&&As(i,e))||0<Ss(t,e,i)!=0<Ss(t,e,r)&&0<Ss(i,r,t)!=0<Ss(i,r,e)}function Es(t,e){return Ss(t.prev,t,t.next)<0?0<=Ss(t,e,t.next)&&0<=Ss(t,t.prev,e):Ss(t,e,t.prev)<0||Ss(t,t.next,e)<0}function Ps(t,e){var i=new Is(t.i,t.x,t.y),r=new Is(e.i,e.x,e.y),n=t.next,o=e.prev;return(t.next=e).prev=t,(i.next=n).prev=i,(r.next=i).prev=r,(o.next=r).prev=o,r}function Ts(t,e,i,r){var n=new Is(t,e,i);return r?(n.next=r.next,(n.prev=r).next.prev=n,r.next=n):(n.prev=n).next=n,n}function Cs(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Is(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Os={area:function(t){for(var e=t.length,i=0,r=e-1,n=0;n<e;r=n++)i+=t[r].x*t[n].y-t[n].x*t[r].y;return.5*i},isClockWise:function(t){return Os.area(t)<0},triangulateShape:function(t,e){var i=[],r=[],n=[];Ls(t),Rs(i,t);var o=t.length;e.forEach(Ls);for(var a=0;a<e.length;a++)r.push(o),o+=e[a].length,Rs(i,e[a]);var s=hs(i,r);for(a=0;a<s.length;a+=3)n.push(s.slice(a,a+3));return n}};function Ls(t){var e=t.length;2<e&&t[e-1].equals(t[0])&&t.pop()}function Rs(t,e){for(var i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}function Ds(t,e){_r.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new ks(t,e)),this.mergeVertices()}function ks(t,Z){$r.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:t,options:Z},t=Array.isArray(t)?t:[t];for(var K=this,J=[],Q=[],e=0,i=t.length;e<i;e++){r(t[e])}function r(t){var r=[],e=void 0!==Z.curveSegments?Z.curveSegments:12,c=void 0!==Z.steps?Z.steps:1,i=void 0!==Z.depth?Z.depth:100,n=void 0===Z.bevelEnabled||Z.bevelEnabled,o=void 0!==Z.bevelThickness?Z.bevelThickness:6,a=void 0!==Z.bevelSize?Z.bevelSize:o-2,u=void 0!==Z.bevelSegments?Z.bevelSegments:3,s=Z.extrudePath,h=void 0!==Z.UVGenerator?Z.UVGenerator:Bs;void 0!==Z.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),i=Z.amount);var l,p,d,f,m,g,v,y,b=!1;s&&(l=s.getSpacedPoints(c),n=!(b=!0),p=s.computeFrenetFrames(c,!1),d=new ri,f=new ri,m=new ri),n||(a=o=u=0);var x=t.extractPoints(e),_=x.shape,w=x.holes;if(!Os.isClockWise(_))for(_=_.reverse(),v=0,y=w.length;v<y;v++)g=w[v],Os.isClockWise(g)&&(w[v]=g.reverse());var S=Os.triangulateShape(_,w),A=_;for(v=0,y=w.length;v<y;v++)g=w[v],_=_.concat(g);function M(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}var E,P,T,C,I,O,L=_.length,R=S.length;function D(t,e,i){var r,n,o,a=t.x-e.x,s=t.y-e.y,c=i.x-t.x,u=i.y-t.y,h=a*a+s*s,l=a*u-s*c;if(Math.abs(l)>Number.EPSILON){var p=Math.sqrt(h),d=Math.sqrt(c*c+u*u),f=e.x-s/p,m=e.y+a/p,g=((i.x-u/d-f)*u-(i.y+c/d-m)*c)/(a*u-s*c),v=(r=f+a*g-t.x)*r+(n=m+s*g-t.y)*n;if(v<=2)return new ti(r,n);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?c>Number.EPSILON&&(y=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(u)&&(y=!0),y?(r=-s,n=a,o=Math.sqrt(h)):(r=a,n=s,o=Math.sqrt(h/2))}return new ti(r/o,n/o)}for(var k=[],B=0,N=A.length,F=N-1,z=B+1;B<N;B++,F++,z++)F===N&&(F=0),z===N&&(z=0),k[B]=D(A[B],A[F],A[z]);var U,j,G=[],V=k.concat();for(v=0,y=w.length;v<y;v++){for(g=w[v],U=[],B=0,F=(N=g.length)-1,z=B+1;B<N;B++,F++,z++)F===N&&(F=0),z===N&&(z=0),U[B]=D(g[B],g[F],g[z]);G.push(U),V=V.concat(U)}for(E=0;E<u;E++){for(T=E/u,C=o*Math.cos(T*Math.PI/2),P=a*Math.sin(T*Math.PI/2),B=0,N=A.length;B<N;B++)$((I=M(A[B],k[B],P)).x,I.y,-C);for(v=0,y=w.length;v<y;v++)for(g=w[v],U=G[v],B=0,N=g.length;B<N;B++)$((I=M(g[B],U[B],P)).x,I.y,-C)}for(P=a,B=0;B<L;B++)I=n?M(_[B],V[B],P):_[B],b?(f.copy(p.normals[0]).multiplyScalar(I.x),d.copy(p.binormals[0]).multiplyScalar(I.y),m.copy(l[0]).add(f).add(d),$(m.x,m.y,m.z)):$(I.x,I.y,0);for(j=1;j<=c;j++)for(B=0;B<L;B++)I=n?M(_[B],V[B],P):_[B],b?(f.copy(p.normals[j]).multiplyScalar(I.x),d.copy(p.binormals[j]).multiplyScalar(I.y),m.copy(l[j]).add(f).add(d),$(m.x,m.y,m.z)):$(I.x,I.y,i/c*j);for(E=u-1;0<=E;E--){for(T=E/u,C=o*Math.cos(T*Math.PI/2),P=a*Math.sin(T*Math.PI/2),B=0,N=A.length;B<N;B++)$((I=M(A[B],k[B],P)).x,I.y,i+C);for(v=0,y=w.length;v<y;v++)for(g=w[v],U=G[v],B=0,N=g.length;B<N;B++)I=M(g[B],U[B],P),b?$(I.x,I.y+l[c-1].y,l[c-1].x+C):$(I.x,I.y,i+C)}function H(t,e){var i,r;for(B=t.length;0<=--B;){(r=(i=B)-1)<0&&(r=t.length-1);var n=0,o=c+2*u;for(n=0;n<o;n++){var a=L*n,s=L*(n+1);X(e+i+a,e+r+a,e+r+s,e+i+s)}}}function $(t,e,i){r.push(t),r.push(e),r.push(i)}function W(t,e,i){q(t),q(e),q(i);var r=J.length/3,n=h.generateTopUV(K,J,r-3,r-2,r-1);Y(n[0]),Y(n[1]),Y(n[2])}function X(t,e,i,r){q(t),q(e),q(r),q(e),q(i),q(r);var n=J.length/3,o=h.generateSideWallUV(K,J,n-6,n-3,n-2,n-1);Y(o[0]),Y(o[1]),Y(o[3]),Y(o[1]),Y(o[2]),Y(o[3])}function q(t){J.push(r[3*t+0]),J.push(r[3*t+1]),J.push(r[3*t+2])}function Y(t){Q.push(t.x),Q.push(t.y)}!function(){var t=J.length/3;if(n){var e=0,i=L*e;for(B=0;B<R;B++)W((O=S[B])[2]+i,O[1]+i,O[0]+i);for(i=L*(e=c+2*u),B=0;B<R;B++)W((O=S[B])[0]+i,O[1]+i,O[2]+i)}else{for(B=0;B<R;B++)W((O=S[B])[2],O[1],O[0]);for(B=0;B<R;B++)W((O=S[B])[0]+L*c,O[1]+L*c,O[2]+L*c)}K.addGroup(t,J.length/3-t,0)}(),function(){var t=J.length/3,e=0;for(H(A,e),e+=A.length,v=0,y=w.length;v<y;v++)H(g=w[v],e),e+=g.length;K.addGroup(t,J.length/3-t,1)}()}this.addAttribute("position",new Ir(J,3)),this.addAttribute("uv",new Ir(Q,2)),this.computeVertexNormals()}((Ds.prototype=Object.create(_r.prototype)).constructor=Ds).prototype.toJSON=function(){var t=_r.prototype.toJSON.call(this);return Ns(this.parameters.shapes,this.parameters.options,t)},((ks.prototype=Object.create($r.prototype)).constructor=ks).prototype.toJSON=function(){var t=$r.prototype.toJSON.call(this);return Ns(this.parameters.shapes,this.parameters.options,t)};var Bs={generateTopUV:function(t,e,i,r,n){var o=e[3*i],a=e[3*i+1],s=e[3*r],c=e[3*r+1],u=e[3*n],h=e[3*n+1];return[new ti(o,a),new ti(s,c),new ti(u,h)]},generateSideWallUV:function(t,e,i,r,n,o){var a=e[3*i],s=e[3*i+1],c=e[3*i+2],u=e[3*r],h=e[3*r+1],l=e[3*r+2],p=e[3*n],d=e[3*n+1],f=e[3*n+2],m=e[3*o],g=e[3*o+1],v=e[3*o+2];return Math.abs(s-h)<.01?[new ti(a,1-c),new ti(u,1-l),new ti(p,1-f),new ti(m,1-v)]:[new ti(s,1-c),new ti(h,1-l),new ti(d,1-f),new ti(g,1-v)]}};function Ns(t,e,i){if(i.shapes=[],Array.isArray(t))for(var r=0,n=t.length;r<n;r++){var o=t[r];i.shapes.push(o.uuid)}else i.shapes.push(t.uuid);return void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON()),i}function Fs(t,e){_r.call(this),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new zs(t,e)),this.mergeVertices()}function zs(t,e){var i=(e=e||{}).font;if(!i||!i.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new _r;var r=i.generateShapes(t,e.size);e.depth=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),ks.call(this,r,e),this.type="TextBufferGeometry"}function Us(t,e,i,r,n,o,a){_r.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new js(t,e,i,r,n,o,a)),this.mergeVertices()}function js(t,e,i,r,n,o,a){$r.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:r,phiLength:n,thetaStart:o,thetaLength:a},t=t||1,e=Math.max(3,Math.floor(e)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var s,c,u=(o=void 0!==o?o:0)+(a=void 0!==a?a:Math.PI),h=0,l=[],p=new ri,d=new ri,f=[],m=[],g=[],v=[];for(c=0;c<=i;c++){var y=[],b=c/i;for(s=0;s<=e;s++){var x=s/e;p.x=-t*Math.cos(r+x*n)*Math.sin(o+b*a),p.y=t*Math.cos(o+b*a),p.z=t*Math.sin(r+x*n)*Math.sin(o+b*a),m.push(p.x,p.y,p.z),d.set(p.x,p.y,p.z).normalize(),g.push(d.x,d.y,d.z),v.push(x,1-b),y.push(h++)}l.push(y)}for(c=0;c<i;c++)for(s=0;s<e;s++){var _=l[c][s+1],w=l[c][s],S=l[c+1][s],A=l[c+1][s+1];(0!==c||0<o)&&f.push(_,w,A),(c!==i-1||u<Math.PI)&&f.push(w,S,A)}this.setIndex(f),this.addAttribute("position",new Ir(m,3)),this.addAttribute("normal",new Ir(g,3)),this.addAttribute("uv",new Ir(v,2))}function Gs(t,e,i,r,n,o){_r.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},this.fromBufferGeometry(new Vs(t,e,i,r,n,o)),this.mergeVertices()}function Vs(t,e,i,r,n,o){$r.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:o},t=t||.5,e=e||1,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,i=void 0!==i?Math.max(3,i):8;var a,s,c,u=[],h=[],l=[],p=[],d=t,f=(e-t)/(r=void 0!==r?Math.max(1,r):1),m=new ri,g=new ti;for(s=0;s<=r;s++){for(c=0;c<=i;c++)a=n+c/i*o,m.x=d*Math.cos(a),m.y=d*Math.sin(a),h.push(m.x,m.y,m.z),l.push(0,0,1),g.x=(m.x/e+1)/2,g.y=(m.y/e+1)/2,p.push(g.x,g.y);d+=f}for(s=0;s<r;s++){var v=s*(i+1);for(c=0;c<i;c++){var y=a=c+v,b=a+i+1,x=a+i+2,_=a+1;u.push(y,b,_),u.push(b,x,_)}}this.setIndex(u),this.addAttribute("position",new Ir(h,3)),this.addAttribute("normal",new Ir(l,3)),this.addAttribute("uv",new Ir(p,2))}function Hs(t,e,i,r){_r.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},this.fromBufferGeometry(new $s(t,e,i,r)),this.mergeVertices()}function $s(t,e,i,r){$r.call(this),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:r},e=Math.floor(e)||12,i=i||0,r=r||2*Math.PI,r=Qe.clamp(r,0,2*Math.PI);var n,o,a,s=[],c=[],u=[],h=1/e,l=new ri,p=new ti;for(o=0;o<=e;o++){var d=i+o*h*r,f=Math.sin(d),m=Math.cos(d);for(a=0;a<=t.length-1;a++)l.x=t[a].x*f,l.y=t[a].y,l.z=t[a].x*m,c.push(l.x,l.y,l.z),p.x=o/e,p.y=a/(t.length-1),u.push(p.x,p.y)}for(o=0;o<e;o++)for(a=0;a<t.length-1;a++){var g=n=a+o*t.length,v=n+t.length,y=n+t.length+1,b=n+1;s.push(g,v,b),s.push(v,y,b)}if(this.setIndex(s),this.addAttribute("position",new Ir(c,3)),this.addAttribute("uv",new Ir(u,2)),this.computeVertexNormals(),r===2*Math.PI){var x=this.attributes.normal.array,_=new ri,w=new ri,S=new ri;for(n=e*t.length*3,a=o=0;o<t.length;o++,a+=3)_.x=x[a+0],_.y=x[a+1],_.z=x[a+2],w.x=x[n+a+0],w.y=x[n+a+1],w.z=x[n+a+2],S.addVectors(_,w).normalize(),x[a+0]=x[n+a+0]=S.x,x[a+1]=x[n+a+1]=S.y,x[a+2]=x[n+a+2]=S.z}}function Ws(t,e){_r.call(this),this.type="ShapeGeometry","object"==typeof e&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new Xs(t,e)),this.mergeVertices()}function Xs(t,f){$r.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:f},f=f||12;var m=[],g=[],v=[],y=[],e=0,b=0;if(!1===Array.isArray(t))r(t);else for(var i=0;i<t.length;i++)r(t[i]),this.addGroup(e,b,i),e+=b,b=0;function r(t){var e,i,r,n=g.length/3,o=t.extractPoints(f),a=o.shape,s=o.holes;if(!1===Os.isClockWise(a))for(a=a.reverse(),e=0,i=s.length;e<i;e++)r=s[e],!0===Os.isClockWise(r)&&(s[e]=r.reverse());var c=Os.triangulateShape(a,s);for(e=0,i=s.length;e<i;e++)r=s[e],a=a.concat(r);for(e=0,i=a.length;e<i;e++){var u=a[e];g.push(u.x,u.y,0),v.push(0,0,1),y.push(u.x,u.y)}for(e=0,i=c.length;e<i;e++){var h=c[e],l=h[0]+n,p=h[1]+n,d=h[2]+n;m.push(l,p,d),b+=3}}this.setIndex(m),this.addAttribute("position",new Ir(g,3)),this.addAttribute("normal",new Ir(v,3)),this.addAttribute("uv",new Ir(y,2))}function qs(t,e){if(e.shapes=[],Array.isArray(t))for(var i=0,r=t.length;i<r;i++){var n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}function Ys(t,e){$r.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1;var i,r,n,o,a=[],s=Math.cos(Qe.DEG2RAD*e),c=[0,0],u={},h=["a","b","c"];t.isBufferGeometry?(o=new _r).fromBufferGeometry(t):o=t.clone(),o.mergeVertices(),o.computeFaceNormals();for(var l=o.vertices,p=o.faces,d=0,f=p.length;d<f;d++)for(var m=p[d],g=0;g<3;g++)i=m[h[g]],r=m[h[(g+1)%3]],c[0]=Math.min(i,r),c[1]=Math.max(i,r),void 0===u[n=c[0]+","+c[1]]?u[n]={index1:c[0],index2:c[1],face1:d,face2:void 0}:u[n].face2=d;for(n in u){var v=u[n];if(void 0===v.face2||p[v.face1].normal.dot(p[v.face2].normal)<=s){var y=l[v.index1];a.push(y.x,y.y,y.z),y=l[v.index2],a.push(y.x,y.y,y.z)}}this.addAttribute("position",new Ir(a,3))}function Zs(t,e,i,r,n,o,a,s){_r.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:r,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new Ks(t,e,i,r,n,o,a,s)),this.mergeVertices()}function Ks(v,y,b,x,_,t,w,S){$r.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:v,radiusBottom:y,height:b,radialSegments:x,heightSegments:_,openEnded:t,thetaStart:w,thetaLength:S};var A=this;v=void 0!==v?v:1,y=void 0!==y?y:1,b=b||1,x=Math.floor(x)||8,_=Math.floor(_)||1,t=void 0!==t&&t,w=void 0!==w?w:0,S=void 0!==S?S:2*Math.PI;var M=[],E=[],P=[],T=[],C=0,I=[],O=b/2,L=0;function e(t){var e,i,r,n=new ti,o=new ri,a=0,s=!0===t?v:y,c=!0===t?1:-1;for(i=C,e=1;e<=x;e++)E.push(0,O*c,0),P.push(0,c,0),T.push(.5,.5),C++;for(r=C,e=0;e<=x;e++){var u=e/x*S+w,h=Math.cos(u),l=Math.sin(u);o.x=s*l,o.y=O*c,o.z=s*h,E.push(o.x,o.y,o.z),P.push(0,c,0),n.x=.5*h+.5,n.y=.5*l*c+.5,T.push(n.x,n.y),C++}for(e=0;e<x;e++){var p=i+e,d=r+e;!0===t?M.push(d,d+1,p):M.push(d+1,d,p),a+=3}A.addGroup(L,a,!0===t?1:2),L+=a}!function(){var t,e,i=new ri,r=new ri,n=0,o=(y-v)/b;for(e=0;e<=_;e++){var a=[],s=e/_,c=s*(y-v)+v;for(t=0;t<=x;t++){var u=t/x,h=u*S+w,l=Math.sin(h),p=Math.cos(h);r.x=c*l,r.y=-s*b+O,r.z=c*p,E.push(r.x,r.y,r.z),i.set(l,o,p).normalize(),P.push(i.x,i.y,i.z),T.push(u,1-s),a.push(C++)}I.push(a)}for(t=0;t<x;t++)for(e=0;e<_;e++){var d=I[e][t],f=I[e+1][t],m=I[e+1][t+1],g=I[e][t+1];M.push(d,f,g),M.push(f,m,g),n+=6}A.addGroup(L,n,0),L+=n}(),!1===t&&(0<v&&e(!0),0<y&&e(!1)),this.setIndex(M),this.addAttribute("position",new Ir(E,3)),this.addAttribute("normal",new Ir(P,3)),this.addAttribute("uv",new Ir(T,2))}function Js(t,e,i,r,n,o,a){Zs.call(this,0,t,e,i,r,n,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function Qs(t,e,i,r,n,o,a){Ks.call(this,0,t,e,i,r,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function tc(t,e,i,r){_r.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new ec(t,e,i,r)),this.mergeVertices()}function ec(t,e,i,r){$r.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,o,a=[],s=[],c=[],u=[],h=new ri,l=new ti;for(s.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,n=3;o<=e;o++,n+=3){var p=i+o/e*r;h.x=t*Math.cos(p),h.y=t*Math.sin(p),s.push(h.x,h.y,h.z),c.push(0,0,1),l.x=(s[n]/t+1)/2,l.y=(s[n+1]/t+1)/2,u.push(l.x,l.y)}for(n=1;n<=e;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new Ir(s,3)),this.addAttribute("normal",new Ir(c,3)),this.addAttribute("uv",new Ir(u,2))}(Fs.prototype=Object.create(_r.prototype)).constructor=Fs,(zs.prototype=Object.create(ks.prototype)).constructor=zs,(Us.prototype=Object.create(_r.prototype)).constructor=Us,(js.prototype=Object.create($r.prototype)).constructor=js,(Gs.prototype=Object.create(_r.prototype)).constructor=Gs,(Vs.prototype=Object.create($r.prototype)).constructor=Vs,(Hs.prototype=Object.create(_r.prototype)).constructor=Hs,($s.prototype=Object.create($r.prototype)).constructor=$s,((Ws.prototype=Object.create(_r.prototype)).constructor=Ws).prototype.toJSON=function(){var t=_r.prototype.toJSON.call(this);return qs(this.parameters.shapes,t)},((Xs.prototype=Object.create($r.prototype)).constructor=Xs).prototype.toJSON=function(){var t=$r.prototype.toJSON.call(this);return qs(this.parameters.shapes,t)},(Ys.prototype=Object.create($r.prototype)).constructor=Ys,(Zs.prototype=Object.create(_r.prototype)).constructor=Zs,(Ks.prototype=Object.create($r.prototype)).constructor=Ks,(Js.prototype=Object.create(Zs.prototype)).constructor=Js,(Qs.prototype=Object.create(Ks.prototype)).constructor=Qs,(tc.prototype=Object.create(_r.prototype)).constructor=tc,(ec.prototype=Object.create($r.prototype)).constructor=ec;var ic=Object.freeze({WireframeGeometry:$a,ParametricGeometry:Wa,ParametricBufferGeometry:Xa,TetrahedronGeometry:Za,TetrahedronBufferGeometry:Ka,OctahedronGeometry:Ja,OctahedronBufferGeometry:Qa,IcosahedronGeometry:ts,IcosahedronBufferGeometry:es,DodecahedronGeometry:is,DodecahedronBufferGeometry:rs,PolyhedronGeometry:qa,PolyhedronBufferGeometry:Ya,TubeGeometry:ns,TubeBufferGeometry:os,TorusKnotGeometry:as,TorusKnotBufferGeometry:ss,TorusGeometry:cs,TorusBufferGeometry:us,TextGeometry:Fs,TextBufferGeometry:zs,SphereGeometry:Us,SphereBufferGeometry:js,RingGeometry:Gs,RingBufferGeometry:Vs,PlaneGeometry:qr,PlaneBufferGeometry:Yr,LatheGeometry:Hs,LatheBufferGeometry:$s,ShapeGeometry:Ws,ShapeBufferGeometry:Xs,ExtrudeGeometry:Ds,ExtrudeBufferGeometry:ks,EdgesGeometry:Ys,ConeGeometry:Js,ConeBufferGeometry:Qs,CylinderGeometry:Zs,CylinderBufferGeometry:Ks,CircleGeometry:tc,CircleBufferGeometry:ec,BoxGeometry:Wr,BoxBufferGeometry:Xr});function rc(t){wn.call(this),this.type="ShadowMaterial",this.color=new ki(0),this.transparent=!0,this.setValues(t)}function nc(t){An.call(this,t),this.type="RawShaderMaterial"}function oc(t){wn.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ki(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ki(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ke,this.normalScale=new ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function ac(t){oc.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function sc(t){wn.call(this),this.type="MeshPhongMaterial",this.color=new ki(16777215),this.specular=new ki(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ki(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ke,this.normalScale=new ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Mt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function cc(t){sc.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function uc(t){wn.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ke,this.normalScale=new ti(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function hc(t){wn.call(this),this.type="MeshLambertMaterial",this.color=new ki(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ki(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Mt,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function lc(t){ka.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}((rc.prototype=Object.create(wn.prototype)).constructor=rc).prototype.isShadowMaterial=!0,rc.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this},((nc.prototype=Object.create(An.prototype)).constructor=nc).prototype.isRawShaderMaterial=!0,((oc.prototype=Object.create(wn.prototype)).constructor=oc).prototype.isMeshStandardMaterial=!0,oc.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((ac.prototype=Object.create(oc.prototype)).constructor=ac).prototype.isMeshPhysicalMaterial=!0,ac.prototype.copy=function(t){return oc.prototype.copy.call(this,t),this.defines={PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearCoat=t.clearCoat,this.clearCoatRoughness=t.clearCoatRoughness,this},((sc.prototype=Object.create(wn.prototype)).constructor=sc).prototype.isMeshPhongMaterial=!0,sc.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((cc.prototype=Object.create(sc.prototype)).constructor=cc).prototype.isMeshToonMaterial=!0,cc.prototype.copy=function(t){return sc.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},((uc.prototype=Object.create(wn.prototype)).constructor=uc).prototype.isMeshNormalMaterial=!0,uc.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((hc.prototype=Object.create(wn.prototype)).constructor=hc).prototype.isMeshLambertMaterial=!0,hc.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((lc.prototype=Object.create(ka.prototype)).constructor=lc).prototype.isLineDashedMaterial=!0,lc.prototype.copy=function(t){return ka.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var pc=Object.freeze({ShadowMaterial:rc,SpriteMaterial:Ca,RawShaderMaterial:nc,ShaderMaterial:An,PointsMaterial:za,MeshPhysicalMaterial:ac,MeshStandardMaterial:oc,MeshPhongMaterial:sc,MeshToonMaterial:cc,MeshNormalMaterial:uc,MeshLambertMaterial:hc,MeshDepthMaterial:pa,MeshDistanceMaterial:da,MeshBasicMaterial:Sn,LineDashedMaterial:lc,LineBasicMaterial:ka,Material:wn}),dc={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function fc(t,e,i){var r=this,n=!1,o=0,a=0,s=void 0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){a++,!1===n&&void 0!==r.onStart&&r.onStart(t,o,a),n=!0},this.itemEnd=function(t){o++,void 0!==r.onProgress&&r.onProgress(t,o,a),o===a&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this}}var mc=new fc,gc={};function vc(t){this.manager=void 0!==t?t:mc}function yc(t){this.manager=void 0!==t?t:mc}function bc(t){this.manager=void 0!==t?t:mc}function xc(t){this.manager=void 0!==t?t:mc}function _c(){this.type="Curve",this.arcLengthDivisions=200}function wc(t,e,i,r,n,o,a,s){_c.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=i||1,this.yRadius=r||1,this.aStartAngle=n||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=a||!1,this.aRotation=s||0}function Sc(t,e,i,r,n,o){wc.call(this,t,e,i,i,r,n,o),this.type="ArcCurve"}function Ac(){var n=0,o=0,a=0,s=0;function u(t,e,i,r){a=-3*(n=t)+3*e-2*(o=i)-r,s=2*t-2*e+i+r}return{initCatmullRom:function(t,e,i,r,n){u(e,i,n*(i-t),n*(r-e))},initNonuniformCatmullRom:function(t,e,i,r,n,o,a){var s=(e-t)/n-(i-t)/(n+o)+(i-e)/o,c=(i-e)/o-(r-e)/(o+a)+(r-i)/a;u(e,i,s*=o,c*=o)},calc:function(t){var e=t*t;return n+o*t+a*e+s*(e*t)}}}Object.assign(vc.prototype,{load:function(a,t,e,i){void 0===a&&(a=""),void 0!==this.path&&(a=this.path+a),a=this.manager.resolveURL(a);var s=this,r=dc.get(a);if(void 0!==r)return s.manager.itemStart(a),setTimeout(function(){t&&t(r),s.manager.itemEnd(a)},0),r;if(void 0===gc[a]){var n=a.match(/^data:(.*?)(;base64)?,(.*)$/);if(n){var o=n[1],c=!!n[2],u=n[3];u=window.decodeURIComponent(u),c&&(u=window.atob(u));try{var h,l=(this.responseType||"").toLowerCase();switch(l){case"arraybuffer":case"blob":for(var p=new Uint8Array(u.length),d=0;d<u.length;d++)p[d]=u.charCodeAt(d);h="blob"===l?new Blob([p.buffer],{type:o}):p.buffer;break;case"document":var f=new DOMParser;h=f.parseFromString(u,o);break;case"json":h=JSON.parse(u);break;default:h=u}window.setTimeout(function(){t&&t(h),s.manager.itemEnd(a)},0)}catch(t){window.setTimeout(function(){i&&i(t),s.manager.itemEnd(a),s.manager.itemError(a)},0)}}else{gc[a]=[],gc[a].push({onLoad:t,onProgress:e,onError:i});var m=new XMLHttpRequest;for(var g in m.open("GET",a,!0),m.addEventListener("load",function(t){var e=this.response;dc.add(a,e);var i=gc[a];if(delete gc[a],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");for(var r=0,n=i.length;r<n;r++){(o=i[r]).onLoad&&o.onLoad(e)}s.manager.itemEnd(a)}else{for(r=0,n=i.length;r<n;r++){var o;(o=i[r]).onError&&o.onError(t)}s.manager.itemEnd(a),s.manager.itemError(a)}},!1),m.addEventListener("progress",function(t){for(var e=gc[a],i=0,r=e.length;i<r;i++){var n=e[i];n.onProgress&&n.onProgress(t)}},!1),m.addEventListener("error",function(t){var e=gc[a];delete gc[a];for(var i=0,r=e.length;i<r;i++){var n=e[i];n.onError&&n.onError(t)}s.manager.itemEnd(a),s.manager.itemError(a)},!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)m.setRequestHeader(g,this.requestHeader[g]);m.send(null)}return s.manager.itemStart(a),m}gc[a].push({onLoad:t,onProgress:e,onError:i})},setPath:function(t){return this.path=t,this},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),Object.assign(function(t){this.manager=void 0!==t?t:mc,this._parser=null}.prototype,{load:function(t,o,e,r){var a=this,s=[],c=new Ga;c.image=s;var n=new vc(this.manager);function i(i){n.load(t[i],function(t){var e=a._parser(t,!0);s[i]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(u+=1)&&(1===e.mipmapCount&&(c.minFilter=Wt),c.format=e.format,c.needsUpdate=!0,o&&o(c))},e,r)}if(n.setPath(this.path),n.setResponseType("arraybuffer"),Array.isArray(t))for(var u=0,h=0,l=t.length;h<l;++h)i(h);else n.load(t,function(t){var e=a._parser(t,!0);if(e.isCubemap)for(var i=e.mipmaps.length/e.mipmapCount,r=0;r<i;r++){s[r]={mipmaps:[]};for(var n=0;n<e.mipmapCount;n++)s[r].mipmaps.push(e.mipmaps[r*e.mipmapCount+n]),s[r].format=e.format,s[r].width=e.width,s[r].height=e.height}else c.image.width=e.width,c.image.height=e.height,c.mipmaps=e.mipmaps;1===e.mipmapCount&&(c.minFilter=Wt),c.format=e.format,c.needsUpdate=!0,o&&o(c)},e,r);return c},setPath:function(t){return this.path=t,this}}),Object.assign(function(t){this.manager=void 0!==t?t:mc,this._parser=null}.prototype,{load:function(t,i,e,r){var n=this,o=new Ei,a=new vc(this.manager);return a.setResponseType("arraybuffer"),a.load(t,function(t){var e=n._parser(t);e&&(void 0!==e.image?o.image=e.image:void 0!==e.data&&(o.image.width=e.width,o.image.height=e.height,o.image.data=e.data),o.wrapS=void 0!==e.wrapS?e.wrapS:jt,o.wrapT=void 0!==e.wrapT?e.wrapT:jt,o.magFilter=void 0!==e.magFilter?e.magFilter:Wt,o.minFilter=void 0!==e.minFilter?e.minFilter:qt,o.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.format&&(o.format=e.format),void 0!==e.type&&(o.type=e.type),void 0!==e.mipmaps&&(o.mipmaps=e.mipmaps),1===e.mipmapCount&&(o.minFilter=Wt),o.needsUpdate=!0,i&&i(o,e))},e,r),o}}),Object.assign(yc.prototype,{crossOrigin:"anonymous",load:function(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,o=dc.get(e);if(void 0!==o)return n.manager.itemStart(e),setTimeout(function(){t&&t(o),n.manager.itemEnd(e)},0),o;var a=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){a.removeEventListener("load",s,!1),a.removeEventListener("error",c,!1),dc.add(e,this),t&&t(this),n.manager.itemEnd(e)}function c(t){a.removeEventListener("load",s,!1),a.removeEventListener("error",c,!1),r&&r(t),n.manager.itemEnd(e),n.manager.itemError(e)}return a.addEventListener("load",s,!1),a.addEventListener("error",c,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),n.manager.itemStart(e),a.src=e,a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(bc.prototype,{crossOrigin:"anonymous",load:function(t,i,e,r){var n=new zn,o=new yc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);var a=0;function s(e){o.load(t[e],function(t){n.images[e]=t,6===++a&&(n.needsUpdate=!0,i&&i(n))},void 0,r)}for(var c=0;c<t.length;++c)s(c);return n},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(xc.prototype,{crossOrigin:"anonymous",load:function(i,r,t,e){var n=new wi,o=new yc(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(i,function(t){n.image=t;var e=0<i.search(/\.(jpg|jpeg)$/)||0===i.search(/^data\:image\/jpeg/);n.format=e?ce:ue,n.needsUpdate=!0,void 0!==r&&r(n)},t,e),n},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(_c.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i,r=[],n=this.getPoint(0),o=0;for(r.push(0),i=1;i<=t;i++)o+=(e=this.getPoint(i/t)).distanceTo(n),r.push(o),n=e;return this.cacheArcLengths=r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var i,r=this.getLengths(),n=0,o=r.length;i=e||t*r[o-1];for(var a,s=0,c=o-1;s<=c;)if((a=r[n=Math.floor(s+(c-s)/2)]-i)<0)s=n+1;else{if(!(0<a)){c=n;break}c=n-1}if(r[n=c]===i)return n/(o-1);var u=r[n];return(n+(i-u)/(r[n+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,i=t+1e-4;e<0&&(e=0),1<i&&(i=1);var r=this.getPoint(e);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var i,r,n,o=new ri,a=[],s=[],c=[],u=new ri,h=new ei;for(i=0;i<=t;i++)r=i/t,a[i]=this.getTangentAt(r),a[i].normalize();s[0]=new ri,c[0]=new ri;var l=Number.MAX_VALUE,p=Math.abs(a[0].x),d=Math.abs(a[0].y),f=Math.abs(a[0].z);for(p<=l&&(l=p,o.set(1,0,0)),d<=l&&(l=d,o.set(0,1,0)),f<=l&&o.set(0,0,1),u.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],u),c[0].crossVectors(a[0],s[0]),i=1;i<=t;i++)s[i]=s[i-1].clone(),c[i]=c[i-1].clone(),u.crossVectors(a[i-1],a[i]),u.length()>Number.EPSILON&&(u.normalize(),n=Math.acos(Qe.clamp(a[i-1].dot(a[i]),-1,1)),s[i].applyMatrix4(h.makeRotationAxis(u,n))),c[i].crossVectors(a[i],s[i]);if(!0===e)for(n=Math.acos(Qe.clamp(s[0].dot(s[t]),-1,1)),n/=t,0<a[0].dot(u.crossVectors(s[0],s[t]))&&(n=-n),i=1;i<=t;i++)s[i].applyMatrix4(h.makeRotationAxis(a[i],n*i)),c[i].crossVectors(a[i],s[i]);return{tangents:a,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){var t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),((wc.prototype=Object.create(_c.prototype)).constructor=wc).prototype.isEllipseCurve=!0,wc.prototype.getPoint=function(t,e){for(var i=e||new ti,r=2*Math.PI,n=this.aEndAngle-this.aStartAngle,o=Math.abs(n)<Number.EPSILON;n<0;)n+=r;for(;r<n;)n-=r;n<Number.EPSILON&&(n=o?0:r),!0!==this.aClockwise||o||(n===r?n=-r:n-=r);var a=this.aStartAngle+t*n,s=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){var u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),l=s-this.aX,p=c-this.aY;s=l*u-p*h+this.aX,c=l*h+p*u+this.aY}return i.set(s,c)},wc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},wc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t},wc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},((Sc.prototype=Object.create(wc.prototype)).constructor=Sc).prototype.isArcCurve=!0;var Mc=new ri,Ec=new Ac,Pc=new Ac,Tc=new Ac;function Cc(t,e,i,r){_c.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=e||!1,this.curveType=i||"centripetal",this.tension=r||.5}function Ic(t,e,i,r,n){var o=.5*(r-e),a=.5*(n-i),s=t*t;return(2*i-2*r+o+a)*(t*s)+(-3*i+3*r-2*o-a)*s+o*t+i}function Oc(t,e,i,r){return(a=1-t)*a*e+2*(1-(o=t))*o*i+(n=t)*n*r;var n,o,a}function Lc(t,e,i,r,n){return(u=1-t)*u*u*e+3*(c=1-(s=t))*c*s*i+3*(1-(a=t))*a*a*r+(o=t)*o*o*n;var o,a,s,c,u}function Rc(t,e,i,r){_c.call(this),this.type="CubicBezierCurve",this.v0=t||new ti,this.v1=e||new ti,this.v2=i||new ti,this.v3=r||new ti}function Dc(t,e,i,r){_c.call(this),this.type="CubicBezierCurve3",this.v0=t||new ri,this.v1=e||new ri,this.v2=i||new ri,this.v3=r||new ri}function kc(t,e){_c.call(this),this.type="LineCurve",this.v1=t||new ti,this.v2=e||new ti}function Bc(t,e){_c.call(this),this.type="LineCurve3",this.v1=t||new ri,this.v2=e||new ri}function Nc(t,e,i){_c.call(this),this.type="QuadraticBezierCurve",this.v0=t||new ti,this.v1=e||new ti,this.v2=i||new ti}function Fc(t,e,i){_c.call(this),this.type="QuadraticBezierCurve3",this.v0=t||new ri,this.v1=e||new ri,this.v2=i||new ri}function zc(t){_c.call(this),this.type="SplineCurve",this.points=t||[]}((Cc.prototype=Object.create(_c.prototype)).constructor=Cc).prototype.isCatmullRomCurve3=!0,Cc.prototype.getPoint=function(t,e){var i,r,n,o,a=e||new ri,s=this.points,c=s.length,u=(c-(this.closed?0:1))*t,h=Math.floor(u),l=u-h;if(this.closed?h+=0<h?0:(Math.floor(Math.abs(h)/c)+1)*c:0===l&&h===c-1&&(h=c-2,l=1),this.closed||0<h?i=s[(h-1)%c]:(Mc.subVectors(s[0],s[1]).add(s[0]),i=Mc),r=s[h%c],n=s[(h+1)%c],this.closed||h+2<c?o=s[(h+2)%c]:(Mc.subVectors(s[c-1],s[c-2]).add(s[c-1]),o=Mc),"centripetal"===this.curveType||"chordal"===this.curveType){var p="chordal"===this.curveType?.5:.25,d=Math.pow(i.distanceToSquared(r),p),f=Math.pow(r.distanceToSquared(n),p),m=Math.pow(n.distanceToSquared(o),p);f<1e-4&&(f=1),d<1e-4&&(d=f),m<1e-4&&(m=f),Ec.initNonuniformCatmullRom(i.x,r.x,n.x,o.x,d,f,m),Pc.initNonuniformCatmullRom(i.y,r.y,n.y,o.y,d,f,m),Tc.initNonuniformCatmullRom(i.z,r.z,n.z,o.z,d,f,m)}else"catmullrom"===this.curveType&&(Ec.initCatmullRom(i.x,r.x,n.x,o.x,this.tension),Pc.initCatmullRom(i.y,r.y,n.y,o.y,this.tension),Tc.initCatmullRom(i.z,r.z,n.z,o.z,this.tension));return a.set(Ec.calc(l),Pc.calc(l),Tc.calc(l)),a},Cc.prototype.copy=function(t){_c.prototype.copy.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Cc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);t.points=[];for(var e=0,i=this.points.length;e<i;e++){var r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},Cc.prototype.fromJSON=function(t){_c.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var r=t.points[e];this.points.push((new ri).fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},((Rc.prototype=Object.create(_c.prototype)).constructor=Rc).prototype.isCubicBezierCurve=!0,Rc.prototype.getPoint=function(t,e){var i=e||new ti,r=this.v0,n=this.v1,o=this.v2,a=this.v3;return i.set(Lc(t,r.x,n.x,o.x,a.x),Lc(t,r.y,n.y,o.y,a.y)),i},Rc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Rc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Rc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},((Dc.prototype=Object.create(_c.prototype)).constructor=Dc).prototype.isCubicBezierCurve3=!0,Dc.prototype.getPoint=function(t,e){var i=e||new ri,r=this.v0,n=this.v1,o=this.v2,a=this.v3;return i.set(Lc(t,r.x,n.x,o.x,a.x),Lc(t,r.y,n.y,o.y,a.y),Lc(t,r.z,n.z,o.z,a.z)),i},Dc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Dc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Dc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},((kc.prototype=Object.create(_c.prototype)).constructor=kc).prototype.isLineCurve=!0,kc.prototype.getPoint=function(t,e){var i=e||new ti;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},kc.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},kc.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},kc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},kc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},kc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},((Bc.prototype=Object.create(_c.prototype)).constructor=Bc).prototype.isLineCurve3=!0,Bc.prototype.getPoint=function(t,e){var i=e||new ri;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},Bc.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},Bc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Bc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Bc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},((Nc.prototype=Object.create(_c.prototype)).constructor=Nc).prototype.isQuadraticBezierCurve=!0,Nc.prototype.getPoint=function(t,e){var i=e||new ti,r=this.v0,n=this.v1,o=this.v2;return i.set(Oc(t,r.x,n.x,o.x),Oc(t,r.y,n.y,o.y)),i},Nc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Nc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Nc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},((Fc.prototype=Object.create(_c.prototype)).constructor=Fc).prototype.isQuadraticBezierCurve3=!0,Fc.prototype.getPoint=function(t,e){var i=e||new ri,r=this.v0,n=this.v1,o=this.v2;return i.set(Oc(t,r.x,n.x,o.x),Oc(t,r.y,n.y,o.y),Oc(t,r.z,n.z,o.z)),i},Fc.prototype.copy=function(t){return _c.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Fc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Fc.prototype.fromJSON=function(t){return _c.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},((zc.prototype=Object.create(_c.prototype)).constructor=zc).prototype.isSplineCurve=!0,zc.prototype.getPoint=function(t,e){var i=e||new ti,r=this.points,n=(r.length-1)*t,o=Math.floor(n),a=n-o,s=r[0===o?o:o-1],c=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set(Ic(a,s.x,c.x,u.x,h.x),Ic(a,s.y,c.y,u.y,h.y)),i},zc.prototype.copy=function(t){_c.prototype.copy.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var r=t.points[e];this.points.push(r.clone())}return this},zc.prototype.toJSON=function(){var t=_c.prototype.toJSON.call(this);t.points=[];for(var e=0,i=this.points.length;e<i;e++){var r=this.points[e];t.points.push(r.toArray())}return t},zc.prototype.fromJSON=function(t){_c.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,i=t.points.length;e<i;e++){var r=t.points[e];this.points.push((new ti).fromArray(r))}return this};var Uc=Object.freeze({ArcCurve:Sc,CatmullRomCurve3:Cc,CubicBezierCurve:Rc,CubicBezierCurve3:Dc,EllipseCurve:wc,LineCurve:kc,LineCurve3:Bc,QuadraticBezierCurve:Nc,QuadraticBezierCurve3:Fc,SplineCurve:zc});function jc(){_c.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Gc(t){jc.call(this),this.type="Path",this.currentPoint=new ti,t&&this.setFromPoints(t)}function Vc(t){Gc.call(this,t),this.uuid=Qe.generateUUID(),this.type="Shape",this.holes=[]}function Hc(t,e){ur.call(this),this.type="Light",this.color=new ki(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function $c(t,e,i){Hc.call(this,t,i),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ur.DefaultUp),this.updateMatrix(),this.groundColor=new ki(e)}function Wc(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new ti(512,512),this.map=null,this.matrix=new ei}function Xc(){Wc.call(this,new ba(50,1,.5,500))}function qc(t,e,i,r,n,o){Hc.call(this,t,e),this.type="SpotLight",this.position.copy(ur.DefaultUp),this.updateMatrix(),this.target=new ur,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==o?o:1,this.shadow=new Xc}function Yc(t,e,i,r){Hc.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==r?r:1,this.shadow=new Wc(new ba(90,1,.5,500))}function Zc(){Wc.call(this,new lr(-5,5,5,-5,.5,500))}function Kc(t,e){Hc.call(this,t,e),this.type="DirectionalLight",this.position.copy(ur.DefaultUp),this.updateMatrix(),this.target=new ur,this.shadow=new Zc}function Jc(t,e){Hc.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Qc(t,e,i,r){Hc.call(this,t,e),this.type="RectAreaLight",this.width=void 0!==i?i:10,this.height=void 0!==r?r:10}jc.prototype=Object.assign(Object.create(_c.prototype),{constructor:jc,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new kc(e,t))},getPoint:function(t){for(var e=t*this.getLength(),i=this.getCurveLengths(),r=0;r<i.length;){if(i[r]>=e){var n=i[r]-e,o=this.curves[r],a=o.getLength(),s=0===a?0:1-n/a;return o.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,i=0,r=this.curves.length;i<r;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;for(var e,i=[],r=0,n=this.curves;r<n.length;r++)for(var o=n[r],a=o&&o.isEllipseCurve?2*t:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?t*o.points.length:t,s=o.getPoints(a),c=0;c<s.length;c++){var u=s[c];e&&e.equals(u)||(i.push(u),e=u)}return this.autoClose&&1<i.length&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(t){_c.prototype.copy.call(this,t),this.curves=[];for(var e=0,i=t.curves.length;e<i;e++){var r=t.curves[e];this.curves.push(r.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){var t=_c.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(var e=0,i=this.curves.length;e<i;e++){var r=this.curves[e];t.curves.push(r.toJSON())}return t},fromJSON:function(t){_c.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(var e=0,i=t.curves.length;e<i;e++){var r=t.curves[e];this.curves.push((new Uc[r.type]).fromJSON(r))}return this}}),Gc.prototype=Object.assign(Object.create(jc.prototype),{constructor:Gc,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y)},moveTo:function(t,e){this.currentPoint.set(t,e)},lineTo:function(t,e){var i=new kc(this.currentPoint.clone(),new ti(t,e));this.curves.push(i),this.currentPoint.set(t,e)},quadraticCurveTo:function(t,e,i,r){var n=new Nc(this.currentPoint.clone(),new ti(t,e),new ti(i,r));this.curves.push(n),this.currentPoint.set(i,r)},bezierCurveTo:function(t,e,i,r,n,o){var a=new Rc(this.currentPoint.clone(),new ti(t,e),new ti(i,r),new ti(n,o));this.curves.push(a),this.currentPoint.set(n,o)},splineThru:function(t){var e=new zc([this.currentPoint.clone()].concat(t));this.curves.push(e),this.currentPoint.copy(t[t.length-1])},arc:function(t,e,i,r,n,o){var a=this.currentPoint.x,s=this.currentPoint.y;this.absarc(t+a,e+s,i,r,n,o)},absarc:function(t,e,i,r,n,o){this.absellipse(t,e,i,i,r,n,o)},ellipse:function(t,e,i,r,n,o,a,s){var c=this.currentPoint.x,u=this.currentPoint.y;this.absellipse(t+c,e+u,i,r,n,o,a,s)},absellipse:function(t,e,i,r,n,o,a,s){var c=new wc(t,e,i,r,n,o,a,s);if(0<this.curves.length){var u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)},copy:function(t){return jc.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=jc.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return jc.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Vc.prototype=Object.assign(Object.create(Gc.prototype),{constructor:Vc,getPointsHoles:function(t){for(var e=[],i=0,r=this.holes.length;i<r;i++)e[i]=this.holes[i].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){Gc.prototype.copy.call(this,t),this.holes=[];for(var e=0,i=t.holes.length;e<i;e++){var r=t.holes[e];this.holes.push(r.clone())}return this},toJSON:function(){var t=Gc.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(var e=0,i=this.holes.length;e<i;e++){var r=this.holes[e];t.holes.push(r.toJSON())}return t},fromJSON:function(t){Gc.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(var e=0,i=t.holes.length;e<i;e++){var r=t.holes[e];this.holes.push((new Gc).fromJSON(r))}return this}}),Hc.prototype=Object.assign(Object.create(ur.prototype),{constructor:Hc,isLight:!0,copy:function(t){return ur.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=ur.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),$c.prototype=Object.assign(Object.create(Hc.prototype),{constructor:$c,isHemisphereLight:!0,copy:function(t){return Hc.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Wc.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Xc.prototype=Object.assign(Object.create(Wc.prototype),{constructor:Xc,isSpotLightShadow:!0,update:function(t){var e=this.camera,i=2*Qe.RAD2DEG*t.angle,r=this.mapSize.width/this.mapSize.height,n=t.distance||e.far;i===e.fov&&r===e.aspect&&n===e.far||(e.fov=i,e.aspect=r,e.far=n,e.updateProjectionMatrix())}}),qc.prototype=Object.assign(Object.create(Hc.prototype),{constructor:qc,isSpotLight:!0,copy:function(t){return Hc.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Yc.prototype=Object.assign(Object.create(Hc.prototype),{constructor:Yc,isPointLight:!0,copy:function(t){return Hc.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Zc.prototype=Object.assign(Object.create(Wc.prototype),{constructor:Zc}),Kc.prototype=Object.assign(Object.create(Hc.prototype),{constructor:Kc,isDirectionalLight:!0,copy:function(t){return Hc.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Jc.prototype=Object.assign(Object.create(Hc.prototype),{constructor:Jc,isAmbientLight:!0}),Qc.prototype=Object.assign(Object.create(Hc.prototype),{constructor:Qc,isRectAreaLight:!0,copy:function(t){return Hc.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=Hc.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});var tu={arraySlice:function(t,e,i){return tu.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(i){for(var t=i.length,e=new Array(t),r=0;r!==t;++r)e[r]=r;return e.sort(function(t,e){return i[t]-i[e]}),e},sortedArray:function(t,e,i){for(var r=t.length,n=new t.constructor(r),o=0,a=0;a!==r;++o)for(var s=i[o]*e,c=0;c!==e;++c)n[a++]=t[s+c];return n},flattenJSON:function(t,e,i,r){for(var n=1,o=t[0];void 0!==o&&void 0===o[r];)o=t[n++];if(void 0!==o){var a=o[r];if(void 0!==a)if(Array.isArray(a))for(;void 0!==(a=o[r])&&(e.push(o.time),i.push.apply(i,a)),void 0!==(o=t[n++]););else if(void 0!==a.toArray)for(;void 0!==(a=o[r])&&(e.push(o.time),a.toArray(i,i.length)),void 0!==(o=t[n++]););else for(;void 0!==(a=o[r])&&(e.push(o.time),i.push(a)),void 0!==(o=t[n++]););}}};function eu(t,e,i,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function iu(t,e,i,r){eu.call(this,t,e,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function ru(t,e,i,r){eu.call(this,t,e,i,r)}function nu(t,e,i,r){eu.call(this,t,e,i,r)}function ou(t,e,i,r){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=tu.convertArray(e,this.TimeBufferType),this.values=tu.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}function au(t,e,i){ou.call(this,t,e,i)}function su(t,e,i,r){ou.call(this,t,e,i,r)}function cu(t,e,i,r){ou.call(this,t,e,i,r)}function uu(t,e,i,r){eu.call(this,t,e,i,r)}function hu(t,e,i,r){ou.call(this,t,e,i,r)}function lu(t,e,i,r){ou.call(this,t,e,i,r)}function pu(t,e,i,r){ou.call(this,t,e,i,r)}function du(t,e,i){this.name=t,this.tracks=i,this.duration=void 0!==e?e:-1,this.uuid=Qe.generateUUID(),this.duration<0&&this.resetDuration()}function fu(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return cu;case"vector":case"vector2":case"vector3":case"vector4":return pu;case"color":return su;case"quaternion":return hu;case"bool":case"boolean":return au;case"string":return lu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){var i=[],r=[];tu.flattenJSON(t.keys,i,r,"value"),t.times=i,t.values=r}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}function mu(t){this.manager=void 0!==t?t:mc,this.textures={}}function gu(t){this.manager=void 0!==t?t:mc}Object.assign(eu.prototype,{evaluate:function(t){var e=this.parameterPositions,i=this._cachedIndex,r=e[i],n=e[i-1];t:{e:{var o;i:{r:if(!(t<r)){for(var a=i+2;;){if(void 0===r){if(t<n)break r;return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,t,n)}if(i===a)break;if(n=r,t<(r=e[++i]))break e}o=e.length;break i}if(n<=t)break t;var s=e[1];t<s&&(i=2,n=s);for(a=i-2;;){if(void 0===n)return this._cachedIndex=0,this.beforeStart_(0,t,r);if(i===a)break;if(r=n,(n=e[--i-1])<=t)break e}o=i,i=0}for(;i<o;){var c=i+o>>>1;t<e[c]?o=c:i=c+1}if(r=e[i],void 0===(n=e[i-1]))return this._cachedIndex=0,this.beforeStart_(0,t,r);if(void 0===r)return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,n,t)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,t,r)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=t*r,o=0;o!==r;++o)e[o]=i[n+o];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(eu.prototype,{beforeStart_:eu.prototype.copySampleValue_,afterEnd_:eu.prototype.copySampleValue_}),iu.prototype=Object.assign(Object.create(eu.prototype),{constructor:iu,DefaultSettings_:{endingStart:ze,endingEnd:ze},intervalChanged_:function(t,e,i){var r=this.parameterPositions,n=t-2,o=t+1,a=r[n],s=r[o];if(void 0===a)switch(this.getSettings_().endingStart){case Ue:n=t,a=2*e-i;break;case 2402:a=e+r[n=r.length-2]-r[n+1];break;default:n=t,a=i}if(void 0===s)switch(this.getSettings_().endingEnd){case Ue:o=t,s=2*i-e;break;case 2402:s=i+r[o=1]-r[0];break;default:o=t-1,s=e}var c=.5*(i-e),u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(s-i),this._offsetPrev=n*u,this._offsetNext=o*u},interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,u=this._offsetPrev,h=this._offsetNext,l=this._weightPrev,p=this._weightNext,d=(i-e)/(r-e),f=d*d,m=f*d,g=-l*m+2*l*f-l*d,v=(1+l)*m+(-1.5-2*l)*f+(-.5+l)*d+1,y=(-1-p)*m+(1.5+p)*f+.5*d,b=p*m-p*f,x=0;x!==a;++x)n[x]=g*o[u+x]+v*o[c+x]+y*o[s+x]+b*o[h+x];return n}}),ru.prototype=Object.assign(Object.create(eu.prototype),{constructor:ru,interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,u=(i-e)/(r-e),h=1-u,l=0;l!==a;++l)n[l]=o[c+l]*h+o[s+l]*u;return n}}),nu.prototype=Object.assign(Object.create(eu.prototype),{constructor:nu,interpolate_:function(t){return this.copySampleValue_(t-1)}}),Object.assign(ou,{toJSON:function(t){var e,i=t.constructor;if(void 0!==i.toJSON)e=i.toJSON(t);else{e={name:t.name,times:tu.convertArray(t.times,Array),values:tu.convertArray(t.values,Array)};var r=t.getInterpolation();r!==t.DefaultInterpolation&&(e.interpolation=r)}return e.type=t.ValueTypeName,e}}),Object.assign(ou.prototype,{constructor:ou,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(t){return new nu(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new ru(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new iu(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case 2300:e=this.InterpolantFactoryMethodDiscrete;break;case 2301:e=this.InterpolantFactoryMethodLinear;break;case 2302:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,i=0,r=e.length;i!==r;++i)e[i]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,i=0,r=e.length;i!==r;++i)e[i]*=t;return this},trim:function(t,e){for(var i=this.times,r=i.length,n=0,o=r-1;n!==r&&i[n]<t;)++n;for(;-1!==o&&i[o]>e;)--o;if(++o,0!==n||o!==r){o<=n&&(n=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=tu.arraySlice(i,n,o),this.values=tu.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var i=this.times,r=this.values,n=i.length;0===n&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var o=null,a=0;a!==n;a++){var s=i[a];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,s),t=!1;break}if(null!==o&&s<o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,s,o),t=!1;break}o=s}if(void 0!==r&&tu.isTypedArray(r)){a=0;for(var c=r.length;a!==c;++a){var u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,o=t.length-1,a=1;a<o;++a){var s=!1,c=t[a];if(c!==t[a+1]&&(1!==a||c!==c[0]))if(r)s=!0;else for(var u=a*i,h=u-i,l=u+i,p=0;p!==i;++p){var d=e[u+p];if(d!==e[h+p]||d!==e[l+p]){s=!0;break}}if(s){if(a!==n){t[n]=t[a];var f=a*i,m=n*i;for(p=0;p!==i;++p)e[m+p]=e[f+p]}++n}}if(0<o){t[n]=t[o];for(f=o*i,m=n*i,p=0;p!==i;++p)e[m+p]=e[f+p];++n}return n!==t.length&&(this.times=tu.arraySlice(t,0,n),this.values=tu.arraySlice(e,0,n*i)),this}}),au.prototype=Object.assign(Object.create(ou.prototype),{constructor:au,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),su.prototype=Object.assign(Object.create(ou.prototype),{constructor:su,ValueTypeName:"color"}),cu.prototype=Object.assign(Object.create(ou.prototype),{constructor:cu,ValueTypeName:"number"}),uu.prototype=Object.assign(Object.create(eu.prototype),{constructor:uu,interpolate_:function(t,e,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(i-e)/(r-e),u=s+a;s!==u;s+=4)ii.slerpFlat(n,0,o,s-a,o,s,c);return n}}),hu.prototype=Object.assign(Object.create(ou.prototype),{constructor:hu,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new uu(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),lu.prototype=Object.assign(Object.create(ou.prototype),{constructor:lu,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),pu.prototype=Object.assign(Object.create(ou.prototype),{constructor:pu,ValueTypeName:"vector"}),Object.assign(du,{parse:function(t){for(var e=[],i=t.tracks,r=1/(t.fps||1),n=0,o=i.length;n!==o;++n)e.push(fu(i[n]).scale(r));return new du(t.name,t.duration,e)},toJSON:function(t){for(var e=[],i=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},n=0,o=i.length;n!==o;++n)e.push(ou.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(t,e,i,r){for(var n=e.length,o=[],a=0;a<n;a++){var s=[],c=[];s.push((a+n-1)%n,a,(a+1)%n),c.push(0,1,0);var u=tu.getKeyframeOrder(s);s=tu.sortedArray(s,1,u),c=tu.sortedArray(c,1,u),r||0!==s[0]||(s.push(n),c.push(c[0])),o.push(new cu(".morphTargetInfluences["+e[a].name+"]",s,c).scale(1/i))}return new du(t,-1,o)},findByName:function(t,e){var i=t;if(!Array.isArray(t)){var r=t;i=r.geometry&&r.geometry.animations||r.animations}for(var n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null},CreateClipsFromMorphTargetSequences:function(t,e,i){for(var r={},n=/^([\w-]*?)([\d]+)$/,o=0,a=t.length;o<a;o++){var s=t[o],c=s.name.match(n);if(c&&1<c.length){var u=r[l=c[1]];u||(r[l]=u=[]),u.push(s)}}var h=[];for(var l in r)h.push(du.CreateFromMorphTargetSequence(l,r[l],e,i));return h},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(t,e,i,r,n){if(0!==i.length){var o=[],a=[];tu.flattenJSON(i,o,a,r),0!==o.length&&n.push(new t(e,o,a))}},r=[],n=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c<s.length;c++){var u=s[c].keys;if(u&&0!==u.length)if(u[0].morphTargets){for(var h={},l=0;l<u.length;l++)if(u[l].morphTargets)for(var p=0;p<u[l].morphTargets.length;p++)h[u[l].morphTargets[p]]=-1;for(var d in h){var f=[],m=[];for(p=0;p!==u[l].morphTargets.length;++p){var g=u[l];f.push(g.time),m.push(g.morphTarget===d?1:0)}r.push(new cu(".morphTargetInfluence["+d+"]",f,m))}o=h.length*(a||1)}else{var v=".bones["+e[c].name+"]";i(pu,v+".position",u,"pos",r),i(hu,v+".quaternion",u,"rot",r),i(pu,v+".scale",u,"scl",r)}}return 0===r.length?null:new du(n,o,r)}}),Object.assign(du.prototype,{resetDuration:function(){for(var t=0,e=0,i=this.tracks.length;e!==i;++e){var r=this.tracks[e];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this},trim:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){for(var t=!0,e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}}),Object.assign(mu.prototype,{load:function(t,e,i,r){var n=this;new vc(n.manager).load(t,function(t){e(n.parse(JSON.parse(t)))},i,r)},setTextures:function(t){this.textures=t},parse:function(t){var e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}var r=new pc[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&r.specular.setHex(t.specular),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearCoat&&(r.clearCoat=t.clearCoat),void 0!==t.clearCoatRoughness&&(r.clearCoatRoughness=t.clearCoatRoughness),void 0!==t.uniforms&&(r.uniforms=t.uniforms),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.vertexColors&&(r.vertexColors=t.vertexColors),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.flatShading&&(r.flatShading=t.flatShading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.side&&(r.side=t.side),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(r.rotation=t.rotation),1!==t.linewidth&&(r.linewidth=t.linewidth),void 0!==t.dashSize&&(r.dashSize=t.dashSize),void 0!==t.gapSize&&(r.gapSize=t.gapSize),void 0!==t.scale&&(r.scale=t.scale),void 0!==t.polygonOffset&&(r.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(r.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(r.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(r.skinning=t.skinning),void 0!==t.morphTargets&&(r.morphTargets=t.morphTargets),void 0!==t.dithering&&(r.dithering=t.dithering),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=i(t.map)),void 0!==t.alphaMap&&(r.alphaMap=i(t.alphaMap),r.transparent=!0),void 0!==t.bumpMap&&(r.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale){var n=t.normalScale;!1===Array.isArray(n)&&(n=[n,n]),r.normalScale=(new ti).fromArray(n)}return void 0!==t.displacementMap&&(r.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=i(t.specularMap)),void 0!==t.envMap&&(r.envMap=i(t.envMap)),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.lightMap&&(r.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=i(t.gradientMap)),r}}),Object.assign(gu.prototype,{load:function(t,e,i,r){var n=this;new vc(n.manager).load(t,function(t){e(n.parse(JSON.parse(t)))},i,r)},parse:function(t){var e=new $r,i=t.data.index;if(void 0!==i){var r=new _u[i.type](i.array);e.setIndex(new wr(r,1))}var n=t.data.attributes;for(var o in n){var a=n[o];r=new _u[a.type](a.array);e.addAttribute(o,new wr(r,a.itemSize,a.normalized))}var s=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==s)for(var c=0,u=s.length;c!==u;++c){var h=s[c];e.addGroup(h.start,h.count,h.materialIndex)}var l=t.data.boundingSphere;if(void 0!==l){var p=new ri;void 0!==l.center&&p.fromArray(l.center),e.boundingSphere=new Ti(p,l.radius)}return e}});var vu,yu,bu,xu,_u={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function wu(){}wu.Handlers={handlers:[],add:function(t,e){this.handlers.push(t,e)},get:function(t){for(var e=this.handlers,i=0,r=e.length;i<r;i+=2){var n=e[i],o=e[i+1];if(n.test(t))return o}return null}},Object.assign(wu.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(t,e,i){for(var r=[],n=0;n<t.length;++n)r[n]=this.createMaterial(t[n],e,i);return r},createMaterial:(vu={NoBlending:q,NormalBlending:Y,AdditiveBlending:Z,SubtractiveBlending:K,MultiplyBlending:J,CustomBlending:Q},yu=new ki,bu=new xc,xu=new mu,function(t,u,h){var l={};function e(t,e,i,r,n){var o,a=u+t,s=wu.Handlers.get(a);null!==s?o=s.load(a):(bu.setCrossOrigin(h),o=bu.load(a)),void 0!==e&&(o.repeat.fromArray(e),1!==e[0]&&(o.wrapS=Ut),1!==e[1]&&(o.wrapT=Ut)),void 0!==i&&o.offset.fromArray(i),void 0!==r&&("repeat"===r[0]&&(o.wrapS=Ut),"mirror"===r[0]&&(o.wrapS=Gt),"repeat"===r[1]&&(o.wrapT=Ut),"mirror"===r[1]&&(o.wrapT=Gt)),void 0!==n&&(o.anisotropy=n);var c=Qe.generateUUID();return l[c]=o,c}var i={uuid:Qe.generateUUID(),type:"MeshLambertMaterial"};for(var r in t){var n=t[r];switch(r){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":i.name=n;break;case"blending":i.blending=vu[n];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",r,"is no longer supported.");break;case"colorDiffuse":i.color=yu.fromArray(n).getHex();break;case"colorSpecular":i.specular=yu.fromArray(n).getHex();break;case"colorEmissive":i.emissive=yu.fromArray(n).getHex();break;case"specularCoef":i.shininess=n;break;case"shading":"basic"===n.toLowerCase()&&(i.type="MeshBasicMaterial"),"phong"===n.toLowerCase()&&(i.type="MeshPhongMaterial"),"standard"===n.toLowerCase()&&(i.type="MeshStandardMaterial");break;case"mapDiffuse":i.map=e(n,t.mapDiffuseRepeat,t.mapDiffuseOffset,t.mapDiffuseWrap,t.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":i.emissiveMap=e(n,t.mapEmissiveRepeat,t.mapEmissiveOffset,t.mapEmissiveWrap,t.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":i.lightMap=e(n,t.mapLightRepeat,t.mapLightOffset,t.mapLightWrap,t.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":i.aoMap=e(n,t.mapAORepeat,t.mapAOOffset,t.mapAOWrap,t.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":i.bumpMap=e(n,t.mapBumpRepeat,t.mapBumpOffset,t.mapBumpWrap,t.mapBumpAnisotropy);break;case"mapBumpScale":i.bumpScale=n;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":i.normalMap=e(n,t.mapNormalRepeat,t.mapNormalOffset,t.mapNormalWrap,t.mapNormalAnisotropy);break;case"mapNormalFactor":i.normalScale=n;break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":i.specularMap=e(n,t.mapSpecularRepeat,t.mapSpecularOffset,t.mapSpecularWrap,t.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":i.metalnessMap=e(n,t.mapMetalnessRepeat,t.mapMetalnessOffset,t.mapMetalnessWrap,t.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":i.roughnessMap=e(n,t.mapRoughnessRepeat,t.mapRoughnessOffset,t.mapRoughnessWrap,t.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":i.alphaMap=e(n,t.mapAlphaRepeat,t.mapAlphaOffset,t.mapAlphaWrap,t.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":i.side=wt;break;case"doubleSided":i.side=et;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),i.opacity=n;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":i[r]=n;break;case"vertexColors":!0===n&&(i.vertexColors=2),"face"===n&&(i.vertexColors=1);break;default:console.error("THREE.Loader.createMaterial: Unsupported",r,n)}}return"MeshBasicMaterial"===i.type&&delete i.emissive,"MeshPhongMaterial"!==i.type&&delete i.specular,i.opacity<1&&(i.transparent=!0),xu.setTextures(l),xu.parse(i)})});var Su=function(t){var e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)};function Au(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:mc,this.withCredentials=!1}Object.assign(Au.prototype,{crossOrigin:"anonymous",load:function(o,a,t,e){var s=this,c=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:Su(o),i=new vc(this.manager);i.setWithCredentials(this.withCredentials),i.load(o,function(t){var e=JSON.parse(t),i=e.metadata;if(void 0!==i){var r=i.type;if(void 0!==r&&"object"===r.toLowerCase())return void console.error("THREE.JSONLoader: "+o+" should be loaded with THREE.ObjectLoader instead.")}var n=s.parse(e,c);a(n.geometry,n.materials)},t,e)},setCrossOrigin:function(t){return this.crossOrigin=t,this},setTexturePath:function(t){return this.texturePath=t,this},parse:function(t,e){void 0!==t.data&&(t=t.data),void 0!==t.scale?t.scale=1/t.scale:t.scale=1;var i=new _r;return function(t,e){function i(t,e){return t&1<<e}var r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,P,T=t.faces,C=t.vertices,I=t.normals,O=t.colors,L=t.scale,R=0;if(void 0!==t.uvs){for(r=0;r<t.uvs.length;r++)t.uvs[r].length&&R++;for(r=0;r<R;r++)e.faceVertexUvs[r]=[]}for(a=0,s=C.length;a<s;)(x=new ri).x=C[a++]*L,x.y=C[a++]*L,x.z=C[a++]*L,e.vertices.push(x);for(a=0,s=T.length;a<s;)if(d=i(p=T[a++],0),f=i(p,1),m=i(p,3),g=i(p,4),v=i(p,5),y=i(p,6),b=i(p,7),d){if((w=new pr).a=T[a],w.b=T[a+1],w.c=T[a+3],(S=new pr).a=T[a+1],S.b=T[a+2],S.c=T[a+3],a+=4,f&&(l=T[a++],w.materialIndex=l,S.materialIndex=l),o=e.faces.length,m)for(r=0;r<R;r++)for(E=t.uvs[r],e.faceVertexUvs[r][o]=[],e.faceVertexUvs[r][o+1]=[],n=0;n<4;n++)P=new ti(E[2*(h=T[a++])],E[2*h+1]),2!==n&&e.faceVertexUvs[r][o].push(P),0!==n&&e.faceVertexUvs[r][o+1].push(P);if(g&&(u=3*T[a++],w.normal.set(I[u++],I[u++],I[u]),S.normal.copy(w.normal)),v)for(r=0;r<4;r++)u=3*T[a++],M=new ri(I[u++],I[u++],I[u]),2!==r&&w.vertexNormals.push(M),0!==r&&S.vertexNormals.push(M);if(y&&(A=O[c=T[a++]],w.color.setHex(A),S.color.setHex(A)),b)for(r=0;r<4;r++)A=O[c=T[a++]],2!==r&&w.vertexColors.push(new ki(A)),0!==r&&S.vertexColors.push(new ki(A));e.faces.push(w),e.faces.push(S)}else{if((_=new pr).a=T[a++],_.b=T[a++],_.c=T[a++],f&&(l=T[a++],_.materialIndex=l),o=e.faces.length,m)for(r=0;r<R;r++)for(E=t.uvs[r],e.faceVertexUvs[r][o]=[],n=0;n<3;n++)P=new ti(E[2*(h=T[a++])],E[2*h+1]),e.faceVertexUvs[r][o].push(P);if(g&&(u=3*T[a++],_.normal.set(I[u++],I[u++],I[u])),v)for(r=0;r<3;r++)u=3*T[a++],M=new ri(I[u++],I[u++],I[u]),_.vertexNormals.push(M);if(y&&(c=T[a++],_.color.setHex(O[c])),b)for(r=0;r<3;r++)c=T[a++],_.vertexColors.push(new ki(O[c]));e.faces.push(_)}}(t,i),function(t,e){var i=void 0!==t.influencesPerVertex?t.influencesPerVertex:2;if(t.skinWeights)for(var r=0,n=t.skinWeights.length;r<n;r+=i){var o=t.skinWeights[r],a=1<i?t.skinWeights[r+1]:0,s=2<i?t.skinWeights[r+2]:0,c=3<i?t.skinWeights[r+3]:0;e.skinWeights.push(new Si(o,a,s,c))}if(t.skinIndices)for(r=0,n=t.skinIndices.length;r<n;r+=i){var u=t.skinIndices[r],h=1<i?t.skinIndices[r+1]:0,l=2<i?t.skinIndices[r+2]:0,p=3<i?t.skinIndices[r+3]:0;e.skinIndices.push(new Si(u,h,l,p))}e.bones=t.bones,e.bones&&0<e.bones.length&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}(t,i),function(t,e){var i=t.scale;if(void 0!==t.morphTargets)for(var r=0,n=t.morphTargets.length;r<n;r++){e.morphTargets[r]={},e.morphTargets[r].name=t.morphTargets[r].name,e.morphTargets[r].vertices=[];for(var o=e.morphTargets[r].vertices,a=t.morphTargets[r].vertices,s=0,c=a.length;s<c;s+=3){var u=new ri;u.x=a[s]*i,u.y=a[s+1]*i,u.z=a[s+2]*i,o.push(u)}}if(void 0!==t.morphColors&&0<t.morphColors.length){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var h=e.faces,l=t.morphColors[0].colors;for(r=0,n=h.length;r<n;r++)h[r].color.fromArray(l,3*r)}}(t,i),function(t,e){var i=[],r=[];void 0!==t.animation&&r.push(t.animation),void 0!==t.animations&&(t.animations.length?r=r.concat(t.animations):r.push(t.animations));for(var n=0;n<r.length;n++){var o=du.parseAnimation(r[n],e.bones);o&&i.push(o)}if(e.morphTargets){var a=du.CreateClipsFromMorphTargetSequences(e.morphTargets,10);i=i.concat(a)}0<i.length&&(e.animations=i)}(t,i),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:i}:{geometry:i,materials:wu.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}),Object.assign(function(t){this.manager=void 0!==t?t:mc,this.texturePath=""}.prototype,{crossOrigin:"anonymous",load:function(r,n,t,o){""===this.texturePath&&(this.texturePath=r.substring(0,r.lastIndexOf("/")+1));var a=this;new vc(a.manager).load(r,function(t){var e=null;try{e=JSON.parse(t)}catch(t){return void 0!==o&&o(t),void console.error("THREE:ObjectLoader: Can't parse "+r+".",t.message)}var i=e.metadata;void 0!==i&&void 0!==i.type&&"geometry"!==i.type.toLowerCase()?a.parse(e,n):console.error("THREE.ObjectLoader: Can't load "+r+". Use THREE.JSONLoader instead.")},t,o)},setTexturePath:function(t){return this.texturePath=t,this},setCrossOrigin:function(t){return this.crossOrigin=t,this},parse:function(t,e){var i=this.parseShape(t.shapes),r=this.parseGeometries(t.geometries,i),n=this.parseImages(t.images,function(){void 0!==e&&e(s)}),o=this.parseTextures(t.textures,n),a=this.parseMaterials(t.materials,o),s=this.parseObject(t.object,r,a);return t.animations&&(s.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(s),s},parseShape:function(t){var e={};if(void 0!==t)for(var i=0,r=t.length;i<r;i++){var n=(new Vc).fromJSON(t[i]);e[n.uuid]=n}return e},parseGeometries:function(t,e){var i={};if(void 0!==t)for(var r=new Au,n=new gu,o=0,a=t.length;o<a;o++){var s,c=t[o];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new ic[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new ic[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new ic[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new ic[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":s=new ic[c.type](c.radius,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new ic[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":s=new ic[c.type](c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new ic[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new ic[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new ic[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"LatheGeometry":case"LatheBufferGeometry":s=new ic[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":s=new ic[c.type](c.vertices,c.indices,c.radius,c.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var u=[],h=0,l=c.shapes.length;h<l;h++){var p=e[c.shapes[h]];u.push(p)}s=new ic[c.type](u,c.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(u=[],h=0,l=c.shapes.length;h<l;h++){p=e[c.shapes[h]];u.push(p)}var d=c.options.extrudePath;void 0!==d&&(c.options.extrudePath=(new Uc[d.type]).fromJSON(d)),s=new ic[c.type](u,c.options);break;case"BufferGeometry":s=n.parse(c);break;case"Geometry":s=r.parse(c,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}s.uuid=c.uuid,void 0!==c.name&&(s.name=c.name),!0===s.isBufferGeometry&&void 0!==c.userData&&(s.userData=c.userData),i[c.uuid]=s}return i},parseMaterials:function(t,e){var i={};if(void 0!==t){var r=new mu;r.setTextures(e);for(var n=0,o=t.length;n<o;n++){var a=t[n];if("MultiMaterial"===a.type){for(var s=[],c=0;c<a.materials.length;c++)s.push(r.parse(a.materials[c]));i[a.uuid]=s}else i[a.uuid]=r.parse(a)}}return i},parseAnimations:function(t){for(var e=[],i=0;i<t.length;i++){var r=t[i],n=du.parse(r);void 0!==r.uuid&&(n.uuid=r.uuid),e.push(n)}return e},parseImages:function(t,e){var i=this,r={};function n(t){return i.manager.itemStart(t),o.load(t,function(){i.manager.itemEnd(t)},void 0,function(){i.manager.itemEnd(t),i.manager.itemError(t)})}if(void 0!==t&&0<t.length){var o=new yc(new fc(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a<s;a++){var c=t[a],u=c.url;if(Array.isArray(u)){r[c.uuid]=[];for(var h=0,l=u.length;h<l;h++){var p=u[h],d=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(p)?p:i.texturePath+p;r[c.uuid].push(n(d))}}else{d=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c.url)?c.url:i.texturePath+c.url;r[c.uuid]=n(d)}}}return r},parseTextures:function(t,e){function i(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var r={};if(void 0!==t)for(var n=0,o=t.length;n<o;n++){var a,s=t[n];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===e[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image),(a=Array.isArray(e[s.image])?new zn(e[s.image]):new wi(e[s.image])).needsUpdate=!0,a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),void 0!==s.mapping&&(a.mapping=i(s.mapping,Eu)),void 0!==s.offset&&a.offset.fromArray(s.offset),void 0!==s.repeat&&a.repeat.fromArray(s.repeat),void 0!==s.center&&a.center.fromArray(s.center),void 0!==s.rotation&&(a.rotation=s.rotation),void 0!==s.wrap&&(a.wrapS=i(s.wrap[0],Pu),a.wrapT=i(s.wrap[1],Pu)),void 0!==s.format&&(a.format=s.format),void 0!==s.minFilter&&(a.minFilter=i(s.minFilter,Tu)),void 0!==s.magFilter&&(a.magFilter=i(s.magFilter,Tu)),void 0!==s.anisotropy&&(a.anisotropy=s.anisotropy),void 0!==s.flipY&&(a.flipY=s.flipY),r[s.uuid]=a}return r},parseObject:function(t,e,o){var i;function r(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function n(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],i=0,r=t.length;i<r;i++){var n=t[i];void 0===o[n]&&console.warn("THREE.ObjectLoader: Undefined material",n),e.push(o[n])}return e}return void 0===o[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),o[t]}}switch(t.type){case"Scene":i=new Ea,void 0!==t.background&&Number.isInteger(t.background)&&(i.background=new ki(t.background)),void 0!==t.fog&&("Fog"===t.fog.type?i.fog=new Ma(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(i.fog=new Aa(t.fog.color,t.fog.density)));break;case"PerspectiveCamera":i=new ba(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(i.focus=t.focus),void 0!==t.zoom&&(i.zoom=t.zoom),void 0!==t.filmGauge&&(i.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(i.filmOffset=t.filmOffset),void 0!==t.view&&(i.view=Object.assign({},t.view));break;case"OrthographicCamera":i=new lr(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(i.zoom=t.zoom),void 0!==t.view&&(i.view=Object.assign({},t.view));break;case"AmbientLight":i=new Jc(t.color,t.intensity);break;case"DirectionalLight":i=new Kc(t.color,t.intensity);break;case"PointLight":i=new Yc(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":i=new Qc(t.color,t.intensity,t.width,t.height);break;case"SpotLight":i=new qc(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":i=new $c(t.color,t.groundColor,t.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var a=r(t.geometry),s=n(t.material);i=a.bones&&0<a.bones.length?new Da(a,s):new Pn(a,s);break;case"LOD":i=new Oa;break;case"Line":i=new Ba(r(t.geometry),n(t.material),t.mode);break;case"LineLoop":i=new Fa(r(t.geometry),n(t.material));break;case"LineSegments":i=new Na(r(t.geometry),n(t.material));break;case"PointCloud":case"Points":i=new Ua(r(t.geometry),n(t.material));break;case"Sprite":i=new Ia(n(t.material));break;case"Group":i=new ya;break;default:i=new ur}if(i.uuid=t.uuid,void 0!==t.name&&(i.name=t.name),void 0!==t.matrix?(i.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(i.matrixAutoUpdate=t.matrixAutoUpdate),i.matrixAutoUpdate&&i.matrix.decompose(i.position,i.quaternion,i.scale)):(void 0!==t.position&&i.position.fromArray(t.position),void 0!==t.rotation&&i.rotation.fromArray(t.rotation),void 0!==t.quaternion&&i.quaternion.fromArray(t.quaternion),void 0!==t.scale&&i.scale.fromArray(t.scale)),void 0!==t.castShadow&&(i.castShadow=t.castShadow),void 0!==t.receiveShadow&&(i.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(i.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(i.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&i.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(i.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.frustumCulled&&(i.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(i.renderOrder=t.renderOrder),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.layers&&(i.layers.mask=t.layers),void 0!==t.children)for(var c=t.children,u=0;u<c.length;u++)i.add(this.parseObject(c[u],e,o));if("LOD"===t.type)for(var h=t.levels,l=0;l<h.length;l++){var p=h[l],d=i.getObjectByProperty("uuid",p.object);void 0!==d&&i.addLevel(d,p.distance)}return i}});var Mu,Eu={UVMapping:300,CubeReflectionMapping:Rt,CubeRefractionMapping:Dt,EquirectangularReflectionMapping:kt,EquirectangularRefractionMapping:Bt,SphericalReflectionMapping:Nt,CubeUVReflectionMapping:Ft,CubeUVRefractionMapping:zt},Pu={RepeatWrapping:Ut,ClampToEdgeWrapping:jt,MirroredRepeatWrapping:Gt},Tu={NearestFilter:Vt,NearestMipMapNearestFilter:Ht,NearestMipMapLinearFilter:$t,LinearFilter:Wt,LinearMipMapNearestFilter:Xt,LinearMipMapLinearFilter:qt};function Cu(){this.type="ShapePath",this.color=new ki,this.subPaths=[],this.currentPath=null}function Iu(t){this.type="Font",this.data=t}function Ou(t,e,i,r,n){var o=n.glyphs[t]||n.glyphs["?"];if(o){var a,s,c,u,h,l,p,d,f=new Cu;if(o.o)for(var m=o._cachedOutline||(o._cachedOutline=o.o.split(" ")),g=0,v=m.length;g<v;){switch(m[g++]){case"m":a=m[g++]*e+i,s=m[g++]*e+r,f.moveTo(a,s);break;case"l":a=m[g++]*e+i,s=m[g++]*e+r,f.lineTo(a,s);break;case"q":c=m[g++]*e+i,u=m[g++]*e+r,h=m[g++]*e+i,l=m[g++]*e+r,f.quadraticCurveTo(h,l,c,u);break;case"b":c=m[g++]*e+i,u=m[g++]*e+r,h=m[g++]*e+i,l=m[g++]*e+r,p=m[g++]*e+i,d=m[g++]*e+r,f.bezierCurveTo(h,l,p,d,c,u)}}return{offsetX:o.ha*e,path:f}}}Object.assign(Cu.prototype,{moveTo:function(t,e){this.currentPath=new Gc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e)},lineTo:function(t,e){this.currentPath.lineTo(t,e)},quadraticCurveTo:function(t,e,i,r){this.currentPath.quadraticCurveTo(t,e,i,r)},bezierCurveTo:function(t,e,i,r,n,o){this.currentPath.bezierCurveTo(t,e,i,r,n,o)},splineThru:function(t){this.currentPath.splineThru(t)},toShapes:function(t,e){function i(t){for(var e=[],i=0,r=t.length;i<r;i++){var n=t[i],o=new Vc;o.curves=n.curves,e.push(o)}return e}function r(t,e){for(var i=e.length,r=!1,n=i-1,o=0;o<i;n=o++){var a=e[n],s=e[o],c=s.x-a.x,u=s.y-a.y;if(Math.abs(u)>Number.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[n],u=-u),t.y<a.y||t.y>s.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var h=u*(t.x-a.x)-c*(t.y-a.y);if(0===h)return!0;if(h<0)continue;r=!r}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return r}var n=Os.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return i(o);var a,s,c,u=[];if(1===o.length)return s=o[0],(c=new Vc).curves=s.curves,u.push(c),u;var h=!n(o[0].getPoints());h=t?!h:h;var l,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v<y;v++)a=n(l=(s=o[v]).getPoints()),(a=t?!a:a)?(!h&&f[g]&&g++,f[g]={s:new Vc,p:l},f[g].s.curves=s.curves,h&&g++,m[g]=[]):m[g].push({h:s,p:l[0]});if(!f[0])return i(o);if(1<f.length){for(var b=!1,x=[],_=0,w=f.length;_<w;_++)d[_]=[];for(_=0,w=f.length;_<w;_++)for(var S=m[_],A=0;A<S.length;A++){for(var M=S[A],E=!0,P=0;P<f.length;P++)r(M.p,f[P].p)&&(_!==P&&x.push({froms:_,tos:P,hole:A}),E?(E=!1,d[P].push(M)):b=!0);E&&d[_].push(M)}0<x.length&&(b||(m=d))}v=0;for(var T=f.length;v<T;v++){c=f[v].s,u.push(c);for(var C=0,I=(p=m[v]).length;C<I;C++)c.holes.push(p[C].h)}return u}}),Object.assign(Iu.prototype,{isFont:!0,generateShapes:function(t,e){void 0===e&&(e=100);for(var i=[],r=function(t,e,i){for(var r=Array.from?Array.from(t):String(t).split(""),n=e/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*n,a=[],s=0,c=0,u=0;u<r.length;u++){var h=r[u];if("\n"===h)s=0,c-=o;else{var l=Ou(h,n,s,c,i);s+=l.offsetX,a.push(l.path)}}return a}(t,e,this.data),n=0,o=r.length;n<o;n++)Array.prototype.push.apply(i,r[n].toShapes());return i}}),Object.assign(function(t){this.manager=void 0!==t?t:mc}.prototype,{load:function(t,r,e,i){var n=this,o=new vc(this.manager);o.setPath(this.path),o.load(t,function(e){var i;try{i=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(e.substring(65,e.length-2))}var t=n.parse(i);r&&r(t)},e,i)},parse:function(t){return new Iu(t)},setPath:function(t){return this.path=t,this}});var Lu,Ru,Du,ku,Bu,Nu,Fu,zu,Uu,ju,Gu,Vu,Hu,$u,Wu,Xu,qu,Yu,Zu=function(){return void 0===Mu&&(Mu=new(window.AudioContext||window.webkitAudioContext)),Mu};function Ku(t){this.manager=void 0!==t?t:mc}function Ju(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ba,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ba,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Qu(t,e,i){ur.call(this),this.type="CubeCamera";var n=new ba(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new ri(1,0,0)),this.add(n);var o=new ba(90,1,t,e);o.up.set(0,-1,0),o.lookAt(new ri(-1,0,0)),this.add(o);var a=new ba(90,1,t,e);a.up.set(0,0,1),a.lookAt(new ri(0,1,0)),this.add(a);var s=new ba(90,1,t,e);s.up.set(0,0,-1),s.lookAt(new ri(0,-1,0)),this.add(s);var c=new ba(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new ri(0,0,1)),this.add(c);var u=new ba(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new ri(0,0,-1)),this.add(u);var r={format:ce,magFilter:Wt,minFilter:Wt};this.renderTarget=new Mi(i,i,r),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var i=this.renderTarget,r=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,i.activeCubeFace=0,t.render(e,n,i),i.activeCubeFace=1,t.render(e,o,i),i.activeCubeFace=2,t.render(e,a,i),i.activeCubeFace=3,t.render(e,s,i),i.activeCubeFace=4,t.render(e,c,i),i.texture.generateMipmaps=r,i.activeCubeFace=5,t.render(e,u,i),t.setRenderTarget(null)},this.clear=function(t,e,i,r){for(var n=this.renderTarget,o=0;o<6;o++)n.activeCubeFace=o,t.setRenderTarget(n),t.clear(e,i,r);t.setRenderTarget(null)}}function th(){ur.call(this),this.type="AudioListener",this.context=Zu(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function eh(t){ur.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.offset=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function ih(t){eh.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function rh(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function nh(t,e,i){this.binding=t,this.valueSize=i;var r,n=Float64Array;switch(e){case"quaternion":r=this._slerp;break;case"string":case"bool":n=Array,r=this._select;break;default:r=this._lerp}this.buffer=new n(4*i),this._mixBufferRegion=r,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}Object.assign(Ku.prototype,{load:function(t,i,e,r){var n=new vc(this.manager);n.setResponseType("arraybuffer"),n.load(t,function(t){var e=t.slice(0);Zu().decodeAudioData(e,function(t){i(t)})},e,r)}}),Object.assign(Ju.prototype,{update:(Uu=new ei,ju=new ei,function(t){if(Lu!==this||Ru!==t.focus||Du!==t.fov||ku!==t.aspect*this.aspect||Bu!==t.near||Nu!==t.far||Fu!==t.zoom||zu!==this.eyeSep){Lu=this,Ru=t.focus,Du=t.fov,ku=t.aspect*this.aspect,Bu=t.near,Nu=t.far,Fu=t.zoom;var e,i,r=t.projectionMatrix.clone(),n=(zu=this.eyeSep/2)*Bu/Ru,o=Bu*Math.tan(Qe.DEG2RAD*Du*.5)/Fu;ju.elements[12]=-zu,Uu.elements[12]=zu,e=-o*ku+n,i=o*ku+n,r.elements[0]=2*Bu/(i-e),r.elements[8]=(i+e)/(i-e),this.cameraL.projectionMatrix.copy(r),e=-o*ku-n,i=o*ku-n,r.elements[0]=2*Bu/(i-e),r.elements[8]=(i+e)/(i-e),this.cameraR.projectionMatrix.copy(r)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(ju),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Uu)})}),(Qu.prototype=Object.create(ur.prototype)).constructor=Qu,th.prototype=Object.assign(Object.create(ur.prototype),{constructor:th,getInput:function(){return this.gain},removeFilter:function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this},updateMatrixWorld:(Gu=new ri,Vu=new ii,Hu=new ri,$u=new ri,function(t){ur.prototype.updateMatrixWorld.call(this,t);var e=this.context.listener,i=this.up;this.matrixWorld.decompose(Gu,Vu,Hu),$u.set(0,0,-1).applyQuaternion(Vu),e.positionX?(e.positionX.setValueAtTime(Gu.x,this.context.currentTime),e.positionY.setValueAtTime(Gu.y,this.context.currentTime),e.positionZ.setValueAtTime(Gu.z,this.context.currentTime),e.forwardX.setValueAtTime($u.x,this.context.currentTime),e.forwardY.setValueAtTime($u.y,this.context.currentTime),e.forwardZ.setValueAtTime($u.z,this.context.currentTime),e.upX.setValueAtTime(i.x,this.context.currentTime),e.upY.setValueAtTime(i.y,this.context.currentTime),e.upZ.setValueAtTime(i.z,this.context.currentTime)):(e.setPosition(Gu.x,Gu.y,Gu.z),e.setOrientation($u.x,$u.y,$u.z,i.x,i.y,i.z))})}),eh.prototype=Object.assign(Object.create(ur.prototype),{constructor:eh,getOutput:function(){return this.gain},setNodeSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},setMediaElementSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this},setBuffer:function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.onended=this.onEnded.bind(this),t.playbackRate.setValueAtTime(this.playbackRate,this.startTime),this.startTime=this.context.currentTime,t.start(this.startTime,this.offset),this.isPlaying=!0,this.source=t,this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this.source.stop(),this.source.onended=null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.source.onended=null,this.offset=0,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(t){return t||(t=[]),!0===this.isPlaying?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(t){return this.setFilters(t?[t]:[])},setPlaybackRate:function(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this;console.warn("THREE.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},getVolume:function(){return this.gain.gain.value},setVolume:function(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}),ih.prototype=Object.assign(Object.create(eh.prototype),{constructor:ih,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(t){return this.panner.refDistance=t,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(t){return this.panner.rolloffFactor=t,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(t){return this.panner.distanceModel=t,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(t){return this.panner.maxDistance=t,this},setDirectionalCone:function(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this},updateMatrixWorld:(Wu=new ri,Xu=new ii,qu=new ri,Yu=new ri,function(t){ur.prototype.updateMatrixWorld.call(this,t);var e=this.panner;this.matrixWorld.decompose(Wu,Xu,qu),Yu.set(0,0,1).applyQuaternion(Xu),e.setPosition(Wu.x,Wu.y,Wu.z),e.setOrientation(Yu.x,Yu.y,Yu.z)})}),Object.assign(rh.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var t=0,e=this.getFrequencyData(),i=0;i<e.length;i++)t+=e[i];return t/e.length}}),Object.assign(nh.prototype,{accumulate:function(t,e){var i=this.buffer,r=this.valueSize,n=t*r+r,o=this.cumulativeWeight;if(0===o){for(var a=0;a!==r;++a)i[n+a]=i[a];o=e}else{var s=e/(o+=e);this._mixBufferRegion(i,n,0,s,r)}this.cumulativeWeight=o},apply:function(t){var e=this.valueSize,i=this.buffer,r=t*e+e,n=this.cumulativeWeight,o=this.binding;if(this.cumulativeWeight=0,n<1){var a=3*e;this._mixBufferRegion(i,r,a,1-n,e)}for(var s=e,c=e+e;s!==c;++s)if(i[s]!==i[s+e]){o.setValue(i,r);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,i=this.valueSize,r=3*i;t.getValue(e,r);for(var n=i,o=r;n!==o;++n)e[n]=e[r+n%i];this.cumulativeWeight=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_select:function(t,e,i,r,n){if(.5<=r)for(var o=0;o!==n;++o)t[e+o]=t[i+o]},_slerp:function(t,e,i,r){ii.slerpFlat(t,e,t,e,t,i,r)},_lerp:function(t,e,i,r,n){for(var o=1-r,a=0;a!==n;++a){var s=e+a;t[s]=t[s]*o+t[i+a]*r}}});var oh,ah,sh,ch,uh,hh,lh,ph,dh,fh,mh,gh,vh,yh,bh,xh,_h,wh,Sh,Ah,Mh,Eh,Ph,Th,Ch,Ih,Oh,Lh,Rh,Dh,kh,Bh,Nh,Fh,zh,Uh,jh="\\[\\]\\.:\\/";function Gh(t,e,i){var r=i||Vh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function Vh(t,e,i){this.path=e,this.parsedPath=i||Vh.parseTrackName(e),this.node=Vh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Hh(t,e,i){this._mixer=t,this._clip=e,this._localRoot=i||null;for(var r=e.tracks,n=r.length,o=new Array(n),a={endingStart:ze,endingEnd:ze},s=0;s!==n;++s){var c=r[s].createInterpolant(null);(o[s]=c).settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function $h(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Wh(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Xh(){$r.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function qh(t,e,i){Pa.call(this,t,e),this.meshPerAttribute=i||1}function Yh(t,e,i){wr.call(this,t,e),this.meshPerAttribute=i||1}function Zh(t,e){return t.distance-e.distance}function Kh(t,e,i,r){if(!1!==t.visible&&(t.raycast(e,i),!0===r))for(var n=t.children,o=0,a=n.length;o<a;o++)Kh(n[o],e,i,!0)}function Jh(t,e){this.min=void 0!==t?t:new ti(1/0,1/0),this.max=void 0!==e?e:new ti(-1/0,-1/0)}function Qh(t,e){this.start=void 0!==t?t:new ri,this.end=void 0!==e?e:new ri}function tl(t){ur.call(this),this.material=t,this.render=function(){}}function el(t,e,i,r){this.object=t,this.size=void 0!==e?e:1;var n=void 0!==i?i:16711680,o=void 0!==r?r:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=3*s.faces.length:s&&s.isBufferGeometry&&(a=s.attributes.normal.count);var c=new $r,u=new Ir(2*a*3,3);c.addAttribute("position",u),Na.call(this,c,new ka({color:n,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function il(t,e){ur.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;for(var i=new $r,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],n=0,o=1;n<32;n++,o++){var a=n/32*Math.PI*2,s=o/32*Math.PI*2;r.push(Math.cos(a),Math.sin(a),1,Math.cos(s),Math.sin(s),1)}i.addAttribute("position",new Ir(r,3));var c=new ka({fog:!1});this.cone=new Na(i,c),this.add(this.cone),this.update()}function rl(t){for(var e=function t(e){var i=[];e&&e.isBone&&i.push(e);for(var r=0;r<e.children.length;r++)i.push.apply(i,t(e.children[r]));return i}(t),i=new $r,r=[],n=[],o=new ki(0,0,1),a=new ki(0,1,0),s=0;s<e.length;s++){var c=e[s];c.parent&&c.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(o.r,o.g,o.b),n.push(a.r,a.g,a.b))}i.addAttribute("position",new Ir(r,3)),i.addAttribute("color",new Ir(n,3));var u=new ka({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0});Na.call(this,i,u),this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}function nl(t,e,i){this.light=t,this.light.updateMatrixWorld(),this.color=i;var r=new js(e,4,2),n=new Sn({wireframe:!0,fog:!1});Pn.call(this,r,n),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}function ol(t,e){ur.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;var i=new ka({fog:!1}),r=new $r;r.addAttribute("position",new wr(new Float32Array(15),3)),this.line=new Ba(r,i),this.add(this.line),this.update()}function al(t,e,i){ur.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;var r=new Qa(e);r.rotateY(.5*Math.PI),this.material=new Sn({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=2);var n=r.getAttribute("position"),o=new Float32Array(3*n.count);r.addAttribute("color",new wr(o,3)),this.add(new Pn(r,this.material)),this.update()}function sl(t,e,i,r){t=t||10,e=e||10,i=new ki(void 0!==i?i:4473924),r=new ki(void 0!==r?r:8947848);for(var n=e/2,o=t/e,a=t/2,s=[],c=[],u=0,h=0,l=-a;u<=e;u++,l+=o){s.push(-a,0,l,a,0,l),s.push(l,0,-a,l,0,a);var p=u===n?i:r;p.toArray(c,h),h+=3,p.toArray(c,h),h+=3,p.toArray(c,h),h+=3,p.toArray(c,h),h+=3}var d=new $r;d.addAttribute("position",new Ir(s,3)),d.addAttribute("color",new Ir(c,3));var f=new ka({vertexColors:2});Na.call(this,d,f)}function cl(t,e,i,r,n,o){t=t||10,e=e||16,i=i||8,r=r||64,n=new ki(void 0!==n?n:4473924),o=new ki(void 0!==o?o:8947848);var a,s,c,u,h,l,p,d=[],f=[];for(u=0;u<=e;u++)c=u/e*(2*Math.PI),a=Math.sin(c)*t,s=Math.cos(c)*t,d.push(0,0,0),d.push(a,0,s),p=1&u?n:o,f.push(p.r,p.g,p.b),f.push(p.r,p.g,p.b);for(u=0;u<=i;u++)for(p=1&u?n:o,l=t-t/i*u,h=0;h<r;h++)c=h/r*(2*Math.PI),a=Math.sin(c)*l,s=Math.cos(c)*l,d.push(a,0,s),f.push(p.r,p.g,p.b),c=(h+1)/r*(2*Math.PI),a=Math.sin(c)*l,s=Math.cos(c)*l,d.push(a,0,s),f.push(p.r,p.g,p.b);var m=new $r;m.addAttribute("position",new Ir(d,3)),m.addAttribute("color",new Ir(f,3));var g=new ka({vertexColors:2});Na.call(this,m,g)}function ul(t,e,i,r){this.object=t,this.size=void 0!==e?e:1;var n=void 0!==i?i:16776960,o=void 0!==r?r:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=s.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var c=new $r,u=new Ir(2*a*3,3);c.addAttribute("position",u),Na.call(this,c,new ka({color:n,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function hl(t,e,i){ur.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===e&&(e=1);var r=new $r;r.addAttribute("position",new Ir([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));var n=new ka({fog:!1});this.lightPlane=new Ba(r,n),this.add(this.lightPlane),(r=new $r).addAttribute("position",new Ir([0,0,0,0,0,1],3)),this.targetLine=new Ba(r,n),this.add(this.targetLine),this.update()}function ll(t){var e=new $r,i=new ka({color:16777215,vertexColors:1}),r=[],n=[],o={},a=new ki(16755200),s=new ki(16711680),c=new ki(43775),u=new ki(16777215),h=new ki(3355443);function l(t,e,i){p(t,i),p(e,i)}function p(t,e){r.push(0,0,0),n.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(r.length/3-1)}l("n1","n2",a),l("n2","n4",a),l("n4","n3",a),l("n3","n1",a),l("f1","f2",a),l("f2","f4",a),l("f4","f3",a),l("f3","f1",a),l("n1","f1",a),l("n2","f2",a),l("n3","f3",a),l("n4","f4",a),l("p","n1",s),l("p","n2",s),l("p","n3",s),l("p","n4",s),l("u1","u2",c),l("u2","u3",c),l("u3","u1",c),l("c","t",u),l("p","c",h),l("cn1","cn2",h),l("cn3","cn4",h),l("cf1","cf2",h),l("cf3","cf4",h),e.addAttribute("position",new Ir(r,3)),e.addAttribute("color",new Ir(n,3)),Na.call(this,e,i),this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}function pl(t,e){this.object=t,void 0===e&&(e=16776960);var i=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]),r=new Float32Array(24),n=new $r;n.setIndex(new wr(i,1)),n.addAttribute("position",new wr(r,3)),Na.call(this,n,new ka({color:e})),this.matrixAutoUpdate=!1,this.update()}function dl(t,e){this.type="Box3Helper",this.box=t;var i=void 0!==e?e:16776960,r=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]),n=new $r;n.setIndex(new wr(r,1)),n.addAttribute("position",new Ir([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),Na.call(this,n,new ka({color:i})),this.geometry.computeBoundingSphere()}function fl(t,e,i){this.type="PlaneHelper",this.plane=t,this.size=void 0===e?1:e;var r=void 0!==i?i:16776960,n=new $r;n.addAttribute("position",new Ir([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),n.computeBoundingSphere(),Ba.call(this,n,new ka({color:r}));var o=new $r;o.addAttribute("position",new Ir([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),o.computeBoundingSphere(),this.add(new Pn(o,new Sn({color:r,opacity:.2,transparent:!0,depthWrite:!1})))}function ml(t,e,i,r,n,o){ur.call(this),void 0===r&&(r=16776960),void 0===i&&(i=1),void 0===n&&(n=.2*i),void 0===o&&(o=.2*n),void 0===Bh&&((Bh=new $r).addAttribute("position",new Ir([0,0,0,0,1,0],3)),(Nh=new Ks(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(e),this.line=new Ba(Bh,new ka({color:r})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Pn(Nh,new Sn({color:r})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,n,o)}function gl(t){var e=[0,0,0,t=t||1,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new $r;i.addAttribute("position",new Ir(e,3)),i.addAttribute("color",new Ir([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var r=new ka({vertexColors:2});Na.call(this,i,r)}function vl(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Cc.call(this,t),this.type="catmullrom"}function yl(t){if("undefined"!=typeof window){var e=new RegExp(t+"=([^&#=]*)").exec(window.location.search);return e?decodeURIComponent(e[1]):void 0}}function bl(t,e){return void 0!==t?t:e}function xl(t,e){var i=Object.assign({},t);for(var r in e){void 0===t[r]&&(i[r]=e[r])}return i}function _l(t,e){for(var i in e){var r=e[i];void 0!==r&&(t[i]=r)}return t}function wl(){var t=window.location.protocol;return null===t.match(/http(s)?:/gi)?"http:":t}function Sl(){if("undefined"==typeof window)return!1;var t=window.navigator.userAgent;return/Opera|OPR/.test(t)?"Opera":/Chrome/i.test(t)?"Chrome":/Firefox/i.test(t)?"Firefox":/Mobile(\/.*)? Safari/i.test(t)?"Mobile Safari":/MSIE/i.test(t)?"Internet Explorer":!!/Safari/i.test(t)&&"Safari"}function Al(t){window.open(t,"_blank")||(window.location.href=t)}function Ml(t,e){if(void 0===e&&(e="download"),t){var i="Safari"===Sl(),r=/CriOS\/[\d]+/.test(window.navigator.userAgent),n=document.createElement("a");if("undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(t,e);else if((i||r)&&FileReader)if(t instanceof Blob){var o=new FileReader;o.onloadend=function(){s(o.result)},o.readAsDataURL(t)}else s(t);else{var a=!1;t instanceof Blob&&(t=URL.createObjectURL(t),a=!0),"download"in n?(n.style.display="hidden",document.body.appendChild(n),n.href=t,n.download=e,n.target="_blank",n.click(),document.body.removeChild(n)):Al(t),a&&window.URL.revokeObjectURL(t)}}function s(t){Al(r?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"))}}function El(t,e){return t<e?-1:e<t?1:0}function Pl(t,e,i){void 0===i&&(i=El);for(var r=0,n=t.length-1;r<=n;){var o=r+n>>1,a=i(e,t[o]);if(0<a)r=o+1;else{if(!(a<0))return o;n=o-1}}return-r-1}function Tl(t,e,i){var r=function(t,e){var i=t.length-1;if(t[i]<e)return-1;for(var r=0;r<=i;){var n=r+i>>1;t[n]>=e?i=n-1:r=n+1}return i+1}(t,e),n=function(t,e){if(t[0]>e)return-1;for(var i=0,r=t.length-1;i<=r;){var n=i+r>>1;t[n]>e?r=n-1:i=n+1}return i-1}(t,i);return-1===r||-1===n||n<r?0:n-r+1}function Cl(t){return t.sort().filter(function(t,e,i){return 0===e||t!==i[e-1]})}function Il(t){if(28672<t.length){for(var e=[],i=0;i<t.length;i+=28672)e.push(String.fromCharCode.apply(null,t.subarray(i,i+28672)));return e.join("")}return String.fromCharCode.apply(null,t)}function Ol(t,e){switch(t){case"int8":return new Int8Array(e);case"int16":return new Int16Array(e);case"int32":return new Int32Array(e);case"uint8":return new Uint8Array(e);case"uint16":return new Uint16Array(e);case"uint32":return new Uint32Array(e);case"float32":return new Float32Array(e);default:throw new Error("arrayType unknown: "+t)}}function Ll(t,e){return new(65535<e?Uint32Array:Uint16Array)(t)}function Rl(t){return t.buffer&&t.buffer instanceof ArrayBuffer?t.buffer:t}function Dl(t,e){return void 0===t?t=new e:Array.isArray(t)&&(t=(new e).fromArray(t)),t}function kl(t){return Dl(t,ri)}function Bl(t){return Dl(t,ei)}function Nl(t){return Dl(t,ii)}function Fl(t){return e=t,i=Float32Array,e instanceof i?e:new i(e);var e,i}function zl(t){return bl(t,"").toString().toLowerCase()}Object.assign(Gh.prototype,{getValue:function(t,e){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(t,e)},setValue:function(t,e){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(Vh,{Composite:Gh,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new Vh.Composite(t,e,i):new Vh(t,e,i)},sanitizeNodeName:(dh=new RegExp("["+jh+"]","g"),function(t){return t.replace(/\s/g,"_").replace(dh,"")}),parseTrackName:(oh="[^"+jh+"]",ah="[^"+jh.replace("\\.","")+"]",sh=/((?:WC+[\/:])*)/.source.replace("WC",oh),ch=/(WCOD+)?/.source.replace("WCOD",ah),uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",oh),hh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",oh),lh=new RegExp("^"+sh+ch+uh+hh+"$"),ph=["material","materials","bones"],function(t){var e=lh.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){var n=i.nodeName.substring(r+1);-1!==ph.indexOf(n)&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}),findNode:function(t,n){if(!n||""===n||"root"===n||"."===n||-1===n||n===t.name||n===t.uuid)return t;if(t.skeleton){var e=t.skeleton.getBoneByName(n);if(void 0!==e)return e}if(t.children){var o=function(t){for(var e=0;e<t.length;e++){var i=t[e];if(i.name===n||i.uuid===n)return i;var r=o(i.children);if(r)return r}return null},i=o(t.children);if(i)return i}return null}}),Object.assign(Vh.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)t[e++]=i[r]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++]},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var i=this.resolvedProperty,r=0,n=i.length;r!==n;++r)i[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,i=e.objectName,r=e.propertyName,n=e.propertyIndex;if(t||(t=Vh.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(i){var o=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(var a=0;a<t.length;a++)if(t[a].name===o){o=a;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==o){if(void 0===t[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[o]}}var s=t[r];if(void 0!==s){var c=this.Versioning.None;void 0!==t.needsUpdate?(c=this.Versioning.NeedsUpdate,this.targetObject=t):void 0!==t.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=t);var u=this.BindingType.Direct;if(void 0!==n){if("morphTargetInfluences"===r){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(a=0;a<this.node.geometry.morphAttributes.position.length;a++)if(t.geometry.morphAttributes.position[a].name===n){n=a;break}}else{if(!t.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(a=0;a<this.node.geometry.morphTargets.length;a++)if(t.geometry.morphTargets[a].name===n){n=a;break}}}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=n}else void 0!==s.fromArray&&void 0!==s.toArray?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][c]}else{var h=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+r+" but it wasn't found.",t)}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Vh.prototype,{_getValue_unbound:Vh.prototype.getValue,_setValue_unbound:Vh.prototype.setValue}),Object.assign(function(){var t=arguments;this.uuid=Qe.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var i=0,r=arguments.length;i!==r;++i)e[t[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var n=this;this.stats={objects:{get total(){return n._objects.length},get inUse(){return this.total-n.nCachedObjects_}},get bindingsPerObject(){return n._bindings.length}}}.prototype,{isAnimationObjectGroup:!0,add:function(){for(var t=arguments,e=this._objects,i=e.length,r=this.nCachedObjects_,n=this._indicesByUUID,o=this._paths,a=this._parsedPaths,s=this._bindings,c=s.length,u=void 0,h=0,l=arguments.length;h!==l;++h){var p=t[h],d=p.uuid,f=n[d];if(void 0===f){f=i++,n[d]=f,e.push(p);for(var m=0,g=c;m!==g;++m)s[m].push(new Vh(p,o[m],a[m]))}else if(f<r){u=e[f];var v=--r,y=e[v];e[n[y.uuid]=f]=y,e[n[d]=v]=p;for(m=0,g=c;m!==g;++m){var b=s[m],x=b[v],_=b[f];b[f]=x,void 0===_&&(_=new Vh(p,o[m],a[m])),b[v]=_}}else e[f]!==u&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=r},remove:function(){for(var t=arguments,e=this._objects,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,o=n.length,a=0,s=arguments.length;a!==s;++a){var c=t[a],u=c.uuid,h=r[u];if(void 0!==h&&i<=h){var l=i++,p=e[l];e[r[p.uuid]=h]=p,e[r[u]=l]=c;for(var d=0,f=o;d!==f;++d){var m=n[d],g=m[l],v=m[h];m[h]=g,m[l]=v}}}this.nCachedObjects_=i},uncache:function(){for(var t=arguments,e=this._objects,i=e.length,r=this.nCachedObjects_,n=this._indicesByUUID,o=this._bindings,a=o.length,s=0,c=arguments.length;s!==c;++s){var u=t[s].uuid,h=n[u];if(void 0!==h)if(delete n[u],h<r){var l=--r,p=e[l],d=e[y=--i];e[n[p.uuid]=h]=p,e[n[d.uuid]=l]=d,e.pop();for(var f=0,m=a;f!==m;++f){var g=(b=o[f])[l],v=b[y];b[h]=g,b[l]=v,b.pop()}}else{var y;e[n[(d=e[y=--i]).uuid]=h]=d,e.pop();for(f=0,m=a;f!==m;++f){var b;(b=o[f])[h]=b[y],b.pop()}}}this.nCachedObjects_=r},subscribe_:function(t,e){var i=this._bindingsIndicesByPath,r=i[t],n=this._bindings;if(void 0!==r)return n[r];var o=this._paths,a=this._parsedPaths,s=this._objects,c=s.length,u=this.nCachedObjects_,h=new Array(c);r=n.length,i[t]=r,o.push(t),a.push(e),n.push(h);for(var l=u,p=s.length;l!==p;++l){var d=s[l];h[l]=new Vh(d,t,e)}return h},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){var r=this._paths,n=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];o[e[t[a]]=i]=s,o.pop(),n[i]=n[a],n.pop(),r[i]=r[a],r.pop()}}}),Object.assign(Hh.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(t){return this._startTime=t,this},setLoop:function(t,e){return this.loop=t,this.repetitions=e,this},setEffectiveWeight:function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(t){return this._scheduleFading(t,0,1)},fadeOut:function(t){return this._scheduleFading(t,1,0)},crossFadeFrom:function(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){var r=this._clip.duration,n=t._clip.duration,o=n/r,a=r/n;t.warp(1,o,e),this.warp(a,1,e)}return this},crossFadeTo:function(t,e,i){return t.crossFadeFrom(this,e,i)},stopFading:function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},setEffectiveTimeScale:function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},syncWith:function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},halt:function(t){return this.warp(this._effectiveTimeScale,0,t)},warp:function(t,e,i){var r=this._mixer,n=r.time,o=this._timeScaleInterpolant,a=this.timeScale;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,c=o.sampleValues;return s[0]=n,s[1]=n+i,c[0]=t/a,c[1]=e/a,this},stopWarping:function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(t,e,i,r){if(this.enabled){var n=this._startTime;if(null!==n){var o=(t-n)*i;if(o<0||0===i)return;this._startTime=null,e=i*o}e*=this._updateTimeScale(t);var a=this._updateTime(e),s=this._updateWeight(t);if(0<s)for(var c=this._interpolants,u=this._propertyBindings,h=0,l=c.length;h!==l;++h)c[h].evaluate(a),u[h].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(t)[0];e*=r,t>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e},_updateTime:function(t){var e=this.time+t,i=this._clip.duration,r=this.loop,n=this._loopCount,o=2202===r;if(0===t)return-1===n?e:o&&1==(1&n)?i-e:e;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i<=e)e=i;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===n&&(0<=t?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),i<=e||e<0){var a=Math.floor(e/i);e-=i*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=0<t?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<t?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&n))return i-(this.time=e)}return this.time=e},_setEndings:function(t,e,i){var r=this._interpolantSettings;i?(r.endingStart=Ue,r.endingEnd=Ue):(r.endingStart=t?this.zeroSlopeAtStart?Ue:ze:2402,r.endingEnd=e?this.zeroSlopeAtEnd?Ue:ze:2402)},_scheduleFading:function(t,e,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=e,a[1]=n+t,s[1]=i,this}}),$h.prototype=Object.assign(Object.create(v.prototype),{constructor:$h,_bindAction:function(t,e){var i=t._localRoot||this._root,r=t._clip.tracks,n=r.length,o=t._propertyBindings,a=t._interpolants,s=i.uuid,c=this._bindingsByRootAndName,u=c[s];void 0===u&&(u={},c[s]=u);for(var h=0;h!==n;++h){var l=r[h],p=l.name,d=u[p];if(void 0!==d)o[h]=d;else{if(void 0!==(d=o[h])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=e&&e._propertyBindings[h].binding.parsedPath;++(d=new nh(Vh.create(i,p,f),l.ValueTypeName,l.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),o[h]=d}a[h].resultBuffer=d.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,e)}for(var n=t._propertyBindings,o=0,a=n.length;o!==a;++o){var s=n[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,i=0,r=e.length;i!==r;++i){var n=e[i];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,i){var r=this._actions,n=this._actionsByClip,o=n[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,n[e]=o;else{var a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=r.length,r.push(t),o.actionByRoot[i]=t},_removeInactiveAction:function(t){var e=this._actions,i=e[e.length-1],r=t._cacheIndex;e[i._cacheIndex=r]=i,e.pop(),t._cacheIndex=null;var n=t._clip.uuid,o=this._actionsByClip,a=o[n],s=a.knownActions,c=s[s.length-1],u=t._byClipCacheIndex;s[c._byClipCacheIndex=u]=c,s.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete o[n],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=t._propertyBindings,i=0,r=e.length;i!==r;++i){var n=e[i];0==--n.referenceCount&&this._removeInactiveBinding(n)}},_lendAction:function(t){var e=this._actions,i=t._cacheIndex,r=this._nActiveActions++,n=e[r];e[t._cacheIndex=r]=t,e[n._cacheIndex=i]=n},_takeBackAction:function(t){var e=this._actions,i=t._cacheIndex,r=--this._nActiveActions,n=e[r];e[t._cacheIndex=r]=t,e[n._cacheIndex=i]=n},_addInactiveBinding:function(t,e,i){var r=this._bindingsByRootAndName,n=r[e],o=this._bindings;void 0===n&&(n={},r[e]=n),(n[i]=t)._cacheIndex=o.length,o.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,i=t.binding,r=i.rootNode.uuid,n=i.path,o=this._bindingsByRootAndName,a=o[r],s=e[e.length-1],c=t._cacheIndex;e[s._cacheIndex=c]=s,e.pop(),delete a[n];t:{for(var u in a)break t;delete o[r]}},_lendBinding:function(t){var e=this._bindings,i=t._cacheIndex,r=this._nActiveBindings++,n=e[r];e[t._cacheIndex=r]=t,e[n._cacheIndex=i]=n},_takeBackBinding:function(t){var e=this._bindings,i=t._cacheIndex,r=--this._nActiveBindings,n=e[r];e[t._cacheIndex=r]=t,e[n._cacheIndex=i]=n},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,i=t[e];return void 0===i&&(t[(i=new ru(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e]=i),i},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,i=t.__cacheIndex,r=--this._nActiveControlInterpolants,n=e[r];e[t.__cacheIndex=r]=t,e[n.__cacheIndex=i]=n},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e){var i=e||this._root,r=i.uuid,n="string"==typeof t?du.findByName(i,t):t,o=null!==n?n.uuid:t,a=this._actionsByClip[o],s=null;if(void 0!==a){var c=a.actionByRoot[r];if(void 0!==c)return c;s=a.knownActions[0],null===n&&(n=s._clip)}if(null===n)return null;var u=new Hh(this,n,e);return this._bindAction(u,s),this._addInactiveAction(u,o,r),u},existingAction:function(t,e){var i=e||this._root,r=i.uuid,n="string"==typeof t?du.findByName(i,t):t,o=n?n.uuid:t,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[r]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,i=this._bindings,r=this._nActiveBindings;this._nActiveActions=0;for(var n=this._nActiveBindings=0;n!==e;++n)t[n].reset();for(n=0;n!==r;++n)i[n].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,i=this._nActiveActions,r=this.time+=t,n=Math.sign(t),o=this._accuIndex^=1,a=0;a!==i;++a){e[a]._update(r,t,n,o)}var s=this._bindings,c=this._nActiveBindings;for(a=0;a!==c;++a)s[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,i=t.uuid,r=this._actionsByClip,n=r[i];if(void 0!==n){for(var o=n.knownActions,a=0,s=o.length;a!==s;++a){var c=o[a];this._deactivateAction(c);var u=c._cacheIndex,h=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,e[h._cacheIndex=u]=h,e.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}},uncacheRoot:function(t){var e=t.uuid,i=this._actionsByClip;for(var r in i){var n=i[r].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}var o=this._bindingsByRootAndName[e];if(void 0!==o)for(var a in o){var s=o[a];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(t,e){var i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}),Wh.prototype.clone=function(){return new Wh(void 0===this.value.clone?this.value:this.value.clone())},Xh.prototype=Object.assign(Object.create($r.prototype),{constructor:Xh,isInstancedBufferGeometry:!0,copy:function(t){return $r.prototype.copy.call(this,t),this.maxInstancedCount=t.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)}}),qh.prototype=Object.assign(Object.create(Pa.prototype),{constructor:qh,isInstancedInterleavedBuffer:!0,copy:function(t){return Pa.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Yh.prototype=Object.assign(Object.create(wr.prototype),{constructor:Yh,isInstancedBufferAttribute:!0,copy:function(t){return wr.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Object.assign(function(t,e,i,r){this.ray=new Mn(t,e),this.near=i||0,this.far=r||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}.prototype,{linePrecision:1,set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize()):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e,i){var r=i||[];return Kh(t,this,r,e),r.sort(Zh),r},intersectObjects:function(t,e,i){var r=i||[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(var n=0,o=t.length;n<o;n++)Kh(t[n],this,r,e);return r.sort(Zh),r}}),Object.assign(function(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"==typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(t){return this.radius=t.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(Qe.clamp(t.y/this.radius,-1,1))),this}}),Object.assign(function(t,e,i){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==i?i:0,this}.prototype,{set:function(t,e,i){return this.radius=t,this.theta=e,this.y=i,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.radius=Math.sqrt(t.x*t.x+t.z*t.z),this.theta=Math.atan2(t.x,t.z),this.y=t.y,this}}),Object.assign(Jh.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:(mh=new ti,function(t,e){var i=mh.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new ti),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new ti),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new ti),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new ti),e.copy(t).clamp(this.min,this.max)},distanceToPoint:(fh=new ti,function(t){return fh.copy(t).clamp(this.min,this.max).sub(t).length()}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(Qh.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new ri),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new ri),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new ri),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(gh=new ri,vh=new ri,function(t,e){gh.subVectors(t,this.start),vh.subVectors(this.end,this.start);var i=vh.dot(vh),r=vh.dot(gh)/i;return e&&(r=Qe.clamp(r,0,1)),r}),closestPointToPoint:function(t,e,i){var r=this.closestPointToPointParameter(t,e);return void 0===i&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),i=new ri),this.delta(i).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),((tl.prototype=Object.create(ur.prototype)).constructor=tl).prototype.isImmediateRenderObject=!0,((el.prototype=Object.create(Na.prototype)).constructor=el).prototype.update=(yh=new ri,bh=new ri,xh=new ni,function(){var t=["a","b","c"];this.object.updateMatrixWorld(!0),xh.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,i=this.geometry.attributes.position,r=this.object.geometry;if(r&&r.isGeometry)for(var n=r.vertices,o=r.faces,a=0,s=0,c=o.length;s<c;s++)for(var u=o[s],h=0,l=u.vertexNormals.length;h<l;h++){var p=n[u[t[h]]],d=u.vertexNormals[h];yh.copy(p).applyMatrix4(e),bh.copy(d).applyMatrix3(xh).normalize().multiplyScalar(this.size).add(yh),i.setXYZ(a,yh.x,yh.y,yh.z),a+=1,i.setXYZ(a,bh.x,bh.y,bh.z),a+=1}else if(r&&r.isBufferGeometry){var f=r.attributes.position,m=r.attributes.normal;for(h=a=0,l=f.count;h<l;h++)yh.set(f.getX(h),f.getY(h),f.getZ(h)).applyMatrix4(e),bh.set(m.getX(h),m.getY(h),m.getZ(h)),bh.applyMatrix3(xh).normalize().multiplyScalar(this.size).add(yh),i.setXYZ(a,yh.x,yh.y,yh.z),a+=1,i.setXYZ(a,bh.x,bh.y,bh.z),a+=1}i.needsUpdate=!0}),((il.prototype=Object.create(ur.prototype)).constructor=il).prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},il.prototype.update=(_h=new ri,wh=new ri,function(){this.light.updateMatrixWorld();var t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),_h.setFromMatrixPosition(this.light.matrixWorld),wh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(wh.sub(_h)),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}),((rl.prototype=Object.create(Na.prototype)).constructor=rl).prototype.updateMatrixWorld=(Sh=new ri,Ah=new ei,Mh=new ei,function(t){var e=this.bones,i=this.geometry,r=i.getAttribute("position");Mh.getInverse(this.root.matrixWorld);for(var n=0,o=0;n<e.length;n++){var a=e[n];a.parent&&a.parent.isBone&&(Ah.multiplyMatrices(Mh,a.matrixWorld),Sh.setFromMatrixPosition(Ah),r.setXYZ(o,Sh.x,Sh.y,Sh.z),Ah.multiplyMatrices(Mh,a.parent.matrixWorld),Sh.setFromMatrixPosition(Ah),r.setXYZ(o+1,Sh.x,Sh.y,Sh.z),o+=2)}i.getAttribute("position").needsUpdate=!0,ur.prototype.updateMatrixWorld.call(this,t)}),((nl.prototype=Object.create(Pn.prototype)).constructor=nl).prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},nl.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)},((ol.prototype=Object.create(ur.prototype)).constructor=ol).prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},ol.prototype.update=function(){var t=.5*this.light.width,e=.5*this.light.height,i=this.line.geometry.attributes.position,r=i.array;r[0]=t,r[1]=-e,r[2]=0,r[3]=t,r[4]=e,r[5]=0,r[6]=-t,r[7]=e,r[8]=0,r[9]=-t,r[10]=-e,r[11]=0,r[12]=t,r[13]=-e,r[14]=0,i.needsUpdate=!0,void 0!==this.color?this.line.material.color.set(this.color):this.line.material.color.copy(this.light.color)},((al.prototype=Object.create(ur.prototype)).constructor=al).prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},al.prototype.update=(Eh=new ri,Ph=new ki,Th=new ki,function(){var t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var e=t.geometry.getAttribute("color");Ph.copy(this.light.color),Th.copy(this.light.groundColor);for(var i=0,r=e.count;i<r;i++){var n=i<r/2?Ph:Th;e.setXYZ(i,n.r,n.g,n.b)}e.needsUpdate=!0}t.lookAt(Eh.setFromMatrixPosition(this.light.matrixWorld).negate())}),(sl.prototype=Object.create(Na.prototype)).constructor=sl,(cl.prototype=Object.create(Na.prototype)).constructor=cl,((ul.prototype=Object.create(Na.prototype)).constructor=ul).prototype.update=(Ch=new ri,Ih=new ri,Oh=new ni,function(){this.object.updateMatrixWorld(!0),Oh.getNormalMatrix(this.object.matrixWorld);for(var t=this.object.matrixWorld,e=this.geometry.attributes.position,i=this.object.geometry,r=i.vertices,n=i.faces,o=0,a=0,s=n.length;a<s;a++){var c=n[a],u=c.normal;Ch.copy(r[c.a]).add(r[c.b]).add(r[c.c]).divideScalar(3).applyMatrix4(t),Ih.copy(u).applyMatrix3(Oh).normalize().multiplyScalar(this.size).add(Ch),e.setXYZ(o,Ch.x,Ch.y,Ch.z),o+=1,e.setXYZ(o,Ih.x,Ih.y,Ih.z),o+=1}e.needsUpdate=!0}),((hl.prototype=Object.create(ur.prototype)).constructor=hl).prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},hl.prototype.update=(Lh=new ri,Rh=new ri,Dh=new ri,function(){Lh.setFromMatrixPosition(this.light.matrixWorld),Rh.setFromMatrixPosition(this.light.target.matrixWorld),Dh.subVectors(Rh,Lh),this.lightPlane.lookAt(Dh),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Dh),this.targetLine.scale.z=Dh.length()}),((ll.prototype=Object.create(Na.prototype)).constructor=ll).prototype.update=function(){var c,u,h=new ri,l=new hr;function t(t,e,i,r){h.set(e,i,r).unproject(l);var n=u[t];if(void 0!==n)for(var o=c.getAttribute("position"),a=0,s=n.length;a<s;a++)o.setXYZ(n[a],h.x,h.y,h.z)}return function(){c=this.geometry,u=this.pointMap;l.projectionMatrix.copy(this.camera.projectionMatrix),t("c",0,0,-1),t("t",0,0,1),t("n1",-1,-1,-1),t("n2",1,-1,-1),t("n3",-1,1,-1),t("n4",1,1,-1),t("f1",-1,-1,1),t("f2",1,-1,1),t("f3",-1,1,1),t("f4",1,1,1),t("u1",.7,1.1,-1),t("u2",-.7,1.1,-1),t("u3",0,2,-1),t("cf1",-1,0,1),t("cf2",1,0,1),t("cf3",0,-1,1),t("cf4",0,1,1),t("cn1",-1,0,-1),t("cn2",1,0,-1),t("cn3",0,-1,-1),t("cn4",0,1,-1),c.getAttribute("position").needsUpdate=!0}}(),((pl.prototype=Object.create(Na.prototype)).constructor=pl).prototype.update=(kh=new Pi,function(t){if(void 0!==t&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&kh.setFromObject(this.object),!kh.isEmpty()){var e=kh.min,i=kh.max,r=this.geometry.attributes.position,n=r.array;n[0]=i.x,n[1]=i.y,n[2]=i.z,n[3]=e.x,n[4]=i.y,n[5]=i.z,n[6]=e.x,n[7]=e.y,n[8]=i.z,n[9]=i.x,n[10]=e.y,n[11]=i.z,n[12]=i.x,n[13]=i.y,n[14]=e.z,n[15]=e.x,n[16]=i.y,n[17]=e.z,n[18]=e.x,n[19]=e.y,n[20]=e.z,n[21]=i.x,n[22]=e.y,n[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}}),pl.prototype.setFromObject=function(t){return this.object=t,this.update(),this},((dl.prototype=Object.create(Na.prototype)).constructor=dl).prototype.updateMatrixWorld=function(t){var e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),ur.prototype.updateMatrixWorld.call(this,t))},((fl.prototype=Object.create(Ba.prototype)).constructor=fl).prototype.updateMatrixWorld=function(t){var e=-this.plane.constant;Math.abs(e)<1e-8&&(e=1e-8),this.scale.set(.5*this.size,.5*this.size,e),this.children[0].material.side=e<0?wt:G,this.lookAt(this.plane.normal),ur.prototype.updateMatrixWorld.call(this,t)},((ml.prototype=Object.create(ur.prototype)).constructor=ml).prototype.setDirection=(zh=new ri,function(t){.99999<t.y?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(zh.set(t.z,0,-t.x).normalize(),Fh=Math.acos(t.y),this.quaternion.setFromAxisAngle(zh,Fh))}),ml.prototype.setLength=function(t,e,i){void 0===e&&(e=.2*t),void 0===i&&(i=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()},ml.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},(gl.prototype=Object.create(Na.prototype)).constructor=gl,_c.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(_c.prototype),(t.prototype.constructor=t).prototype.getPoint=e,t},Object.assign(jc.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var e=new _r,i=0,r=t.length;i<r;i++){var n=t[i];e.vertices.push(new ri(n.x,n.y,n.z||0))}return e}}),Object.assign(Gc.prototype,{fromPoints:function(t){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}}),vl.prototype=Object.create(Cc.prototype),Object.assign(vl.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),sl.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},rl.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(wu.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Su(t)}}),Object.assign(Jh.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(Pi.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),Qh.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Object.assign(Qe,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),Qe.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),Qe.ceilPowerOfTwo(t)}}),Object.assign(ni.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(t){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(ei.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return void 0===Uh&&(Uh=new ri),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),Uh.setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(t){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,i,r,n,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,r,i,n,o)}}),Ci.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},ii.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(Mn.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(En.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}}),Object.assign(En,{barycoordFromPoint:function(t,e,i,r,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),En.getBarycoord(t,e,i,r,n)},normal:function(t,e,i,r){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),En.getNormal(t,e,i,r)}}),Object.assign(Vc.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Ds(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Ws(this,t)}}),Object.assign(ti.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(ri.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Si.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(_r.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}}),Object.assign(ur.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")}}),Object.defineProperties(ur.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(Oa.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(La.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Object.defineProperty(_c.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),ba.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Hc.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(wr.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")}}),Object.assign($r.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addDrawCall:function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}),Object.defineProperties($r.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.assign(ks.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}}),Object.defineProperties(Wh.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(wn.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new ki}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}}}),Object.defineProperties(sc.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(An.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(Sa.prototype,{animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")}}),Object.defineProperties(Sa.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(fa.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Ai.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Object.defineProperties(_a.prototype,{standing:{set:function(){console.warn("THREE.WebVRManager: .standing has been removed.")}}}),eh.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new Ku).load(t,function(t){e.setBuffer(t)}),this},rh.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Qu.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},xi.crossOrigin=void 0,xi.loadTexture=function(t,e,i,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var n=new xc;n.setCrossOrigin(this.crossOrigin);var o=n.load(t,i,void 0,r);return e&&(o.mapping=e),o},xi.loadTextureCube=function(t,e,i,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var n=new bc;n.setCrossOrigin(this.crossOrigin);var o=n.load(t,i,void 0,r);return e&&(o.mapping=e),o},xi.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},xi.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};var Ul=function(t){this.name=t,this._dict={}},jl={names:{configurable:!0}};function Gl(t){return.01745*t}Ul.prototype.add=function(t,e){this._dict[zl(t)]=e},Ul.prototype.get=function(t){return this._dict[zl(t)]},jl.names.get=function(){return Object.keys(this._dict)},Object.defineProperties(Ul.prototype,jl);var Vl="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),Hl=new Array(36);function $l(){for(var t,e=0,i=0;i<36;i++)8===i||13===i||18===i||23===i?Hl[i]="-":14===i?Hl[i]="4":(e<=2&&(e=33554432+16777216*Math.random()|0),t=15&e,e>>=4,Hl[i]=Vl[19===i?3&t|8:t]);return Hl.join("")}function Wl(t,e,i){return Math.max(e,Math.min(i,t))}function Xl(t){return Wl(t,0,100)}function ql(t,e,i){return t+(e-t)*i}function Yl(t,e,i,r,n,o){var a=(i-t)*o,s=(r-e)*o,c=n*n;return(2*e-2*i+a+s)*(n*c)+(-3*e+3*i-2*a-s)*c+a*n+e}function Zl(t,e,i){var r;return(i=Wl((i-(r=t))/(e-r),0,1))*i*(3-2*i)}var Kl="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Jl(t,e){return t(e={exports:{}},e.exports),e.exports}var Ql=Jl(function(Pt,Tt){(function(){var T,n,s,C,c,a,d,m,u,h,l,p,nt,I,f,r,t,i,e,ot,g,o,O,v,y,b,x,at,_,w,S,A,M,E,P,L,R,D,k,B,N,F,z,U,j,G,V,st,H,$,ct,W,X,q,ut,Y,Z,K,J,Q,tt,et,it,rt,ht,lt,pt,dt,ft,mt,gt,vt,yt,bt,xt,_t,wt,St,At,Mt,Et=[].slice;_t=function(){var i,t,e,r,n;for(i={},r=0,t=(n="Boolean Number String Function Array Date RegExp Undefined Null".split(" ")).length;r<t;r++)e=n[r],i["[object "+e+"]"]=e.toLowerCase();return function(t){var e;return e=Object.prototype.toString.call(t),i[e]||"object"}}(),V=function(t,e,i){return null==e&&(e=0),null==i&&(i=1),t<e&&(t=e),i<t&&(t=i),t},wt=function(t){return 3<=t.length?Array.prototype.slice.call(t):t[0]},g=function(t){var e,i;for(t._clipped=!1,t._unclipped=t.slice(0),e=i=0;i<3;e=++i)e<3?((t[e]<0||255<t[e])&&(t._clipped=!0),t[e]<0&&(t[e]=0),255<t[e]&&(t[e]=255)):3===e&&(t[e]<0&&(t[e]=0),1<t[e]&&(t[e]=1));return t._clipped||delete t._unclipped,t},C=Math.PI,gt=Math.round,O=Math.cos,at=Math.floor,ut=Math.pow,st=Math.log,yt=Math.sin,bt=Math.sqrt,I=Math.atan2,ct=Math.max,nt=Math.abs,d=2*C,c=C/3,n=C/180,a=180/C,(ot=function(){return arguments[0]instanceof T?arguments[0]:function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,arguments,function(){})}).default=ot,p=[],null!==Pt&&null!=Pt.exports&&(Pt.exports=ot),((null!==Tt?Tt:this).chroma=ot).version="1.3.7",l={},h=!(u=[]),T=function(){function t(){var t,e,i,r,n,o,a,s,c=arguments;for(this,e=[],a=0,r=arguments.length;a<r;a++)null!=(t=c[a])&&e.push(t);if(1<e.length&&(o=e[e.length-1]),null!=l[o])this._rgb=g(l[o](wt(e.slice(0,-1))));else{for(h||(u=u.sort(function(t,e){return e.p-t.p}),h=!0),s=0,n=u.length;s<n&&!(o=(i=u[s]).test.apply(i,e));s++);o&&(this._rgb=g(l[o].apply(l,e)))}null==this._rgb&&console.warn("unknown format: "+e),null==this._rgb&&(this._rgb=[0,0,0]),3===this._rgb.length&&this._rgb.push(1)}return t.prototype.toString=function(){return this.hex()},t.prototype.clone=function(){return ot(me._rgb)},t}(),ot._input=l,ot.brewer=i={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},function(){var t,e;for(t in e=[],i)e.push(i[t.toLowerCase()]=i[t])}(),ot.colors=St={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflower:"#6495ed",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},F=function(){var t,e,i,r,n,o,a;return r=(e=wt(arguments))[0],t=e[1],i=e[2],o=(r+16)/116,n=isNaN(t)?o:o+t/500,a=isNaN(i)?o:o-i/200,o=s.Yn*z(o),n=s.Xn*z(n),a=s.Zn*z(a),[Mt(3.2404542*n-1.5371385*o-.4985314*a),Mt(-.969266*n+1.8760108*o+.041556*a),i=Mt(.0556434*n-.2040259*o+1.0572252*a),3<e.length?e[3]:1]},Mt=function(t){return 255*(t<=.00304?12.92*t:1.055*ut(t,1/2.4)-.055)},z=function(t){return t>s.t1?t*t*t:s.t2*(t-s.t0)},s={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},it=function(){var t,e,i,r,n,o,a;return i=(r=wt(arguments))[0],e=r[1],t=r[2],o=(n=dt(i,e,t))[0],[116*(a=n[1])-16,500*(o-a),200*(a-n[2])]},ft=function(t){return(t/=255)<=.04045?t/12.92:ut((t+.055)/1.055,2.4)},At=function(t){return t>s.t3?ut(t,1/3):t/s.t2+s.t0},dt=function(){var t,e,i,r;return i=(r=wt(arguments))[0],e=r[1],t=r[2],i=ft(i),e=ft(e),t=ft(t),[At((.4124564*i+.3575761*e+.1804375*t)/s.Xn),At((.2126729*i+.7151522*e+.072175*t)/s.Yn),At((.0193339*i+.119192*e+.9503041*t)/s.Zn)]},ot.lab=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["lab"]),function(){})},l.lab=F,T.prototype.lab=function(){return it(this._rgb)},f=function(r){var t,e,i,n,o,a,s,c,u,h,l;return 2===(r=function(){var t,e,i;for(i=[],e=0,t=r.length;e<t;e++)n=r[e],i.push(ot(n));return i}()).length?(u=function(){var t,e,i;for(i=[],e=0,t=r.length;e<t;e++)n=r[e],i.push(n.lab());return i}(),o=u[0],a=u[1],t=function(i){var r,t;return t=function(){var t,e;for(e=[],r=t=0;t<=2;r=++t)e.push(o[r]+i*(a[r]-o[r]));return e}(),ot.lab.apply(ot,t)}):3===r.length?(h=function(){var t,e,i;for(i=[],e=0,t=r.length;e<t;e++)n=r[e],i.push(n.lab());return i}(),o=h[0],a=h[1],s=h[2],t=function(i){var r,t;return t=function(){var t,e;for(e=[],r=t=0;t<=2;r=++t)e.push((1-i)*(1-i)*o[r]+2*(1-i)*i*a[r]+i*i*s[r]);return e}(),ot.lab.apply(ot,t)}):4===r.length?(l=function(){var t,e,i;for(i=[],e=0,t=r.length;e<t;e++)n=r[e],i.push(n.lab());return i}(),o=l[0],a=l[1],s=l[2],c=l[3],t=function(i){var r,t;return t=function(){var t,e;for(e=[],r=t=0;t<=2;r=++t)e.push((1-i)*(1-i)*(1-i)*o[r]+3*(1-i)*(1-i)*i*a[r]+3*(1-i)*i*i*s[r]+i*i*i*c[r]);return e}(),ot.lab.apply(ot,t)}):5===r.length&&(e=f(r.slice(0,3)),i=f(r.slice(2,5)),t=function(t){return t<.5?e(2*t):i(2*(t-.5))}),t},ot.bezier=function(t){var e;return(e=f(t)).scale=function(){return ot.scale(e)},e},ot.cubehelix=function(a,s,c,u,h){var l,p,e;return null==a&&(a=300),null==s&&(s=-1.5),null==c&&(c=1),null==u&&(u=1),null==h&&(h=[0,1]),l=0,"array"===_t(h)?p=h[1]-h[0]:(p=0,h=[h,h]),(e=function(t){var e,i,r,n,o;return e=d*((a+120)/360+s*t),n=ut(h[0]+p*t,u),i=(0!==l?c[0]+t*l:c)*n*(1-n)/2,r=O(e),o=yt(e),ot(g([255*(n+i*(-.14861*r+1.78277*o)),255*(n+i*(-.29227*r-.90649*o)),255*(n+i*(1.97294*r))]))}).start=function(t){return null==t?a:(a=t,e)},e.rotations=function(t){return null==t?s:(s=t,e)},e.gamma=function(t){return null==t?u:(u=t,e)},e.hue=function(t){return null==t?c:("array"===_t(c=t)?0===(l=c[1]-c[0])&&(c=c[1]):l=0,e)},e.lightness=function(t){return null==t?h:("array"===_t(t)?p=(h=t)[1]-t[0]:(h=[t,t],p=0),e)},e.scale=function(){return ot.scale(e)},e.hue(c),e},ot.random=function(){var t,e;for("0123456789abcdef",t="#",e=0;e<6;++e)t+="0123456789abcdef".charAt(at(16*Math.random()));return new T(t)},p=[],P=function(t,e,i,r){var n,o,a,s;for(null==i&&(i=.5),null==r&&(r="rgb"),"object"!==_t(t)&&(t=ot(t)),"object"!==_t(e)&&(e=ot(e)),a=0,o=p.length;a<o;a++)if(r===(n=p[a])[0]){s=n[1](t,e,i,r);break}if(null==s)throw"color mode "+r+" is not supported";return s.alpha(t.alpha()+i*(e.alpha()-t.alpha()))},ot.interpolate=P,T.prototype.interpolate=function(t,e,i){return P(this,t,e,i)},ot.mix=P,T.prototype.mix=T.prototype.interpolate,l.rgb=function(){var t,e,i,r;for(t in i=[],e=wt(arguments))r=e[t],i.push(r);return i},ot.rgb=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["rgb"]),function(){})},T.prototype.rgb=function(t){return null==t&&(t=!0),t?this._rgb.map(Math.round).slice(0,3):this._rgb.slice(0,3)},T.prototype.rgba=function(t){return null==t&&(t=!0),t?[Math.round(this._rgb[0]),Math.round(this._rgb[1]),Math.round(this._rgb[2]),this._rgb[3]]:this._rgb.slice(0)},u.push({p:3,test:function(t){var e;return e=wt(arguments),"array"===_t(e)&&3===e.length?"rgb":4===e.length&&"number"===_t(e[3])&&0<=e[3]&&e[3]<=1?"rgb":void 0}}),l.lrgb=l.rgb,D=function(t,e,i,r){var n,o;return n=t._rgb,o=e._rgb,new T(bt(ut(n[0],2)*(1-i)+ut(o[0],2)*i),bt(ut(n[1],2)*(1-i)+ut(o[1],2)*i),bt(ut(n[2],2)*(1-i)+ut(o[2],2)*i),r)},m=function(t){var e,i,r,n,o;for(e=1/t.length,o=[0,0,0,0],r=0,i=t.length;r<i;r++)n=t[r]._rgb,o[0]+=ut(n[0],2)*e,o[1]+=ut(n[1],2)*e,o[2]+=ut(n[2],2)*e,o[3]+=n[3]*e;return o[0]=bt(o[0]),o[1]=bt(o[1]),o[2]=bt(o[2]),new T(o)},p.push(["lrgb",D]),ot.average=function(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f;if(null==e&&(e="rgb"),h=t.length,c=(t=t.map(function(t){return ot(t)})).splice(0,1)[0],"lrgb"===e)return m(t);for(u in o=[],s=a=0,d=c.get(e))d[u]=d[u]||0,o.push(isNaN(d[u])?0:1),"h"!==e.charAt(u)||isNaN(d[u])||(i=d[u]/180*C,a+=O(i),s+=yt(i));for(r=c.alpha(),p=0,l=t.length;p<l;p++)for(u in f=(n=t[p]).get(e),r+=n.alpha(),d)isNaN(f[u])||(o[u]+=1,"h"===e.charAt(u)?(i=f[u]/180*C,a+=O(i),s+=yt(i)):d[u]+=f[u]);for(u in d)if("h"===e.charAt(u)){for(i=I(s/o[u],a/o[u])/C*180;i<0;)i+=360;for(;360<=i;)i-=360;d[u]=i}else d[u]=d[u]/o[u];return ot(d,e).alpha(r/h)},w=function(t){var e,i;if(t.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return 4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]),[(i=parseInt(t,16))>>16,i>>8&255,255&i,1];if(t.match(/^#?([A-Fa-f0-9]{8})$/))return 9===t.length&&(t=t.substr(1)),[(i=parseInt(t,16))>>24&255,i>>16&255,i>>8&255,gt((255&i)/255*100)/100];if(null!=l.css&&(e=l.css(t)))return e;throw"unknown color: "+t},J=function(t,e){var i,r,n,o,a,s;return null==e&&(e="rgb"),a=t[0],n=t[1],r=t[2],i=t[3],a=Math.round(a),n=Math.round(n),r=Math.round(r),s=(s="000000"+(a<<16|n<<8|r).toString(16)).substr(s.length-6),o=(o="0"+gt(255*i).toString(16)).substr(o.length-2),"#"+function(){switch(e.toLowerCase()){case"rgba":return s+o;case"argb":return o+s;default:return s}}()},l.hex=function(t){return w(t)},ot.hex=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["hex"]),function(){})},T.prototype.hex=function(t){return null==t&&(t="rgb"),J(this._rgb,t)},u.push({p:4,test:function(t){if(1===arguments.length&&"string"===_t(t))return"hex"}}),M=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d;if(n=(t=wt(arguments))[0],h=t[1],a=t[2],0===h)c=r=e=255*a;else{for(i=[0,0,0],l=2*a-(p=a<.5?a*(1+h):a+h-a*h),(d=[0,0,0])[0]=(n/=360)+1/3,d[1]=n,d[2]=n-1/3,o=s=0;s<=2;o=++s)d[o]<0&&(d[o]+=1),1<d[o]&&(d[o]-=1),6*d[o]<1?i[o]=l+6*(p-l)*d[o]:2*d[o]<1?i[o]=p:3*d[o]<2?i[o]=l+(p-l)*(2/3-d[o])*6:i[o]=l;c=(u=[gt(255*i[0]),gt(255*i[1]),gt(255*i[2])])[0],r=u[1],e=u[2]}return 3<t.length?[c,r,e,t[3]]:[c,r,e]},tt=function(t,e,i){var r,n,o,a,s;return void 0!==t&&3<=t.length&&(t=(a=t)[0],e=a[1],i=a[2]),t/=255,e/=255,i/=255,o=Math.min(t,e,i),n=((ct=Math.max(t,e,i))+o)/2,ct===o?(s=0,r=Number.NaN):s=n<.5?(ct-o)/(ct+o):(ct-o)/(2-ct-o),t===ct?r=(e-i)/(ct-o):e===ct?r=2+(i-t)/(ct-o):i===ct&&(r=4+(t-e)/(ct-o)),(r*=60)<0&&(r+=360),[r,s,n]},ot.hsl=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["hsl"]),function(){})},l.hsl=M,T.prototype.hsl=function(){return tt(this._rgb)},E=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v;if(n=(t=wt(arguments))[0],m=t[1],v=t[2],v*=255,0===m)c=r=e=v;else switch(360===n&&(n=0),360<n&&(n-=360),n<0&&(n+=360),a=v*(1-m),s=v*(1-m*(i=(n/=60)-(o=at(n)))),g=v*(1-m*(1-i)),o){case 0:c=(u=[v,g,a])[0],r=u[1],e=u[2];break;case 1:c=(h=[s,v,a])[0],r=h[1],e=h[2];break;case 2:c=(l=[a,v,g])[0],r=l[1],e=l[2];break;case 3:c=(p=[a,s,v])[0],r=p[1],e=p[2];break;case 4:c=(d=[g,a,v])[0],r=d[1],e=d[2];break;case 5:c=(f=[v,a,s])[0],r=f[1],e=f[2]}return[c,r,e,3<t.length?t[3]:1]},et=function(){var t,e,i,r,n,o,a,s,c;return o=(a=wt(arguments))[0],i=a[1],t=a[2],n=Math.min(o,i,t),e=(ct=Math.max(o,i,t))-n,c=ct/255,0===ct?(r=Number.NaN,s=0):(s=e/ct,o===ct&&(r=(i-t)/e),i===ct&&(r=2+(t-o)/e),t===ct&&(r=4+(o-i)/e),(r*=60)<0&&(r+=360)),[r,s,c]},ot.hsv=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["hsv"]),function(){})},l.hsv=E,T.prototype.hsv=function(){return et(this._rgb)},X=function(t){return"number"===_t(t)&&0<=t&&t<=16777215?[t>>16,t>>8&255,255&t,1]:(console.warn("unknown num color: "+t),[0,0,0,1])},lt=function(){var t;return((t=wt(arguments))[0]<<16)+(t[1]<<8)+t[2]},ot.num=function(t){return new T(t,"num")},T.prototype.num=function(t){return null==t&&(t="rgb"),lt(this._rgb,t)},l.num=X,u.push({p:1,test:function(t){if(1===arguments.length&&"number"===_t(t)&&0<=t&&t<=16777215)return"num"}}),_=function(){var t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b;if(s=(i=wt(arguments))[0],n=i[1],e=i[2],a=a/100*255,t=255*(n/=100),0===n)l=a=r=e;else switch(360===s&&(s=0),360<s&&(s-=360),s<0&&(s+=360),h=(u=e*(1-n))+t*(1-(o=(s/=60)-(c=at(s)))),y=u+t*o,b=u+t,c){case 0:l=(p=[b,y,u])[0],a=p[1],r=p[2];break;case 1:l=(d=[h,b,u])[0],a=d[1],r=d[2];break;case 2:l=(f=[u,b,y])[0],a=f[1],r=f[2];break;case 3:l=(m=[u,h,b])[0],a=m[1],r=m[2];break;case 4:l=(g=[y,u,b])[0],a=g[1],r=g[2];break;case 5:l=(v=[b,u,h])[0],a=v[1],r=v[2]}return[l,a,r,3<i.length?i[3]:1]},K=function(){var t,e,i,r,n,o,a,s,c;return s=(c=wt(arguments))[0],n=c[1],e=c[2],a=Math.min(s,n,e),i=100*(r=(ct=Math.max(s,n,e))-a)/255,t=a/(255-r)*100,0===r?o=Number.NaN:(s===ct&&(o=(n-e)/r),n===ct&&(o=2+(e-s)/r),e===ct&&(o=4+(s-n)/r),(o*=60)<0&&(o+=360)),[o,i,t]},ot.hcg=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["hcg"]),function(){})},l.hcg=_,T.prototype.hcg=function(){return K(this._rgb)},v=function(t){var e,i,r,n,o,a,s,c;if(t=t.toLowerCase(),null!=ot.colors&&ot.colors[t])return w(ot.colors[t]);if(o=t.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=o.slice(1,4),n=a=0;a<=2;n=++a)s[n]=+s[n];s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(s=o.slice(1,5),n=c=0;c<=3;n=++c)s[n]=+s[n];else if(o=t.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=o.slice(1,4),n=e=0;e<=2;n=++e)s[n]=gt(2.55*s[n]);s[3]=1}else if(o=t.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(s=o.slice(1,5),n=i=0;i<=2;n=++i)s[n]=gt(2.55*s[n]);s[3]=+s[3]}else(o=t.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((r=o.slice(1,4))[1]*=.01,r[2]*=.01,(s=M(r))[3]=1):(o=t.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((r=o.slice(1,4))[1]*=.01,r[2]*=.01,(s=M(r))[3]=+o[4]);return s},Z=function(t){var e;return"rgb"===(e=t[3]<1?"rgba":"rgb")?e+"("+t.slice(0,3).map(gt).join(",")+")":"rgba"===e?e+"("+t.slice(0,3).map(gt).join(",")+","+t[3]+")":void 0},mt=function(t){return gt(100*t)/100},A=function(t,e){var i;return i=e<1?"hsla":"hsl",t[0]=mt(t[0]||0),t[1]=mt(100*t[1])+"%",t[2]=mt(100*t[2])+"%","hsla"===i&&(t[3]=e),i+"("+t.join(",")+")"},l.css=function(t){return v(t)},ot.css=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["css"]),function(){})},T.prototype.css=function(t){return null==t&&(t="rgb"),"rgb"===t.slice(0,3)?Z(this._rgb):"hsl"===t.slice(0,3)?A(this.hsl(),this.alpha()):void 0},l.named=function(t){return w(St[t])},u.push({p:5,test:function(t){if(1===arguments.length&&null!=St[t])return"named"}}),T.prototype.name=function(t){var e,i;for(i in arguments.length&&(St[t]&&(this._rgb=w(St[t])),this._rgb[3]=1),e=this.hex(),St)if(e===St[i])return i;return e},U=function(){var t,e,i,r;return i=(r=wt(arguments))[0],t=r[1],e=r[2],[i,O(e*=n)*t,yt(e)*t]},j=function(){var t,e,i,r,n,o,a,s,c;return a=(i=wt(arguments))[0],n=i[1],o=i[2],t=(s=U(a,n,o))[0],e=s[1],r=s[2],[(c=F(t,e,r))[0],c[1],r=c[2],3<i.length?i[3]:1]},N=function(){var t,e,i,r,n,o;return n=(o=wt(arguments))[0],t=o[1],e=o[2],i=bt(t*t+e*e),r=(I(e,t)*a+360)%360,0===gt(1e4*i)&&(r=Number.NaN),[n,i,r]},rt=function(){var t,e,i,r,n,o,a;return n=(o=wt(arguments))[0],i=o[1],e=o[2],r=(a=it(n,i,e))[0],t=a[1],e=a[2],N(r,t,e)},ot.lch=function(){var t;return t=wt(arguments),new T(t,"lch")},ot.hcl=function(){var t;return t=wt(arguments),new T(t,"hcl")},l.lch=j,l.hcl=function(){var t,e,i,r;return e=(r=wt(arguments))[0],t=r[1],i=r[2],j([i,t,e])},T.prototype.lch=function(){return rt(this._rgb)},T.prototype.hcl=function(){return rt(this._rgb).reverse()},Y=function(t){var e,i,r,n,o,a;return null==t&&(t="rgb"),o=(a=wt(arguments))[0],r=a[1],e=a[2],r/=255,e/=255,[(1-(o/=255)-(n=1-Math.max(o,Math.max(r,e))))*(i=n<1?1/(1-n):0),(1-r-n)*i,(1-e-n)*i,n]},o=function(){var t,e,i,r,n,o;return i=(e=wt(arguments))[0],n=e[1],o=e[2],r=e[3],t=4<e.length?e[4]:1,1===r?[0,0,0,t]:[1<=i?0:255*(1-i)*(1-r),1<=n?0:255*(1-n)*(1-r),1<=o?0:255*(1-o)*(1-r),t]},l.cmyk=function(){return o(wt(arguments))},ot.cmyk=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["cmyk"]),function(){})},T.prototype.cmyk=function(){return Y(this._rgb)},l.gl=function(){var t,i,e,r,n;for(r=function(){var t,e;for(i in e=[],t=wt(arguments))n=t[i],e.push(n);return e}.apply(this,arguments),t=e=0;e<=2;t=++e)r[t]*=255;return r},ot.gl=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["gl"]),function(){})},T.prototype.gl=function(){var t;return[(t=this._rgb)[0]/255,t[1]/255,t[2]/255,t[3]]},ht=function(t,e,i){var r;return t=(r=wt(arguments))[0],e=r[1],i=r[2],.2126*(t=H(t))+.7152*(e=H(e))+.0722*(i=H(i))},H=function(t){return(t/=255)<=.03928?t/12.92:ut((t+.055)/1.055,2.4)},B=function(t,e,i,r){var n,o;return n=t._rgb,o=e._rgb,new T(n[0]+i*(o[0]-n[0]),n[1]+i*(o[1]-n[1]),n[2]+i*(o[2]-n[2]),r)},p.push(["rgb",B]),T.prototype.luminance=function(n,o){var t,a,e,s;return null==o&&(o="rgb"),arguments.length?(e=this._rgb,0===n?e=[0,0,0,this._rgb[3]]:1===n?e=[255,255,255,this[3]]:(t=ht(this._rgb),1e-7,a=20,s=function(t,e){var i,r;return i=(r=t.interpolate(e,.5,o)).luminance(),Math.abs(n-i)<1e-7||!a--?r:n<i?s(t,r):s(r,e)},e=n<t?s(ot("black"),this).rgba():s(this,ot("white")).rgba()),ot(e).alpha(this.alpha())):ht(this._rgb)},xt=function(t){var e,i,r,n;return(n=t/100)<66?(r=255,i=-155.25485562709179-.44596950469579133*(i=n-2)+104.49216199393888*st(i),e=n<20?0:.8274096064007395*(e=n-10)-254.76935184120902+115.67994401066147*st(e)):(r=351.97690566805693+.114206453784165*(r=n-55)-40.25366309332127*st(r),i=325.4494125711974+.07943456536662342*(i=n-50)-28.0852963507957*st(i),e=255),[r,i,e]},pt=function(){var t,e,i,r,n,o,a;for(r=(n=wt(arguments))[0],n[1],t=n[2],i=1e3,e=4e4,.4;.4<e-i;)(o=xt(a=.5*(e+i)))[2]/o[0]>=t/r?e=a:i=a;return gt(a)},ot.temperature=ot.kelvin=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["temperature"]),function(){})},l.temperature=l.kelvin=l.K=xt,T.prototype.temperature=function(){return pt(this._rgb)},T.prototype.kelvin=T.prototype.temperature,ot.contrast=function(t,e){var i,r,n,o;return"string"!==(n=_t(t))&&"number"!==n||(t=new T(t)),"string"!==(o=_t(e))&&"number"!==o||(e=new T(e)),i=t.luminance(),(r=e.luminance())<i?(i+.05)/(r+.05):(r+.05)/(i+.05)},ot.distance=function(t,e,i){var r,n,o,a,s,c,u;for(n in null==i&&(i="lab"),"string"!==(s=_t(t))&&"number"!==s||(t=new T(t)),"string"!==(c=_t(e))&&"number"!==c||(e=new T(e)),o=t.get(i),a=e.get(i),u=0,o)u+=(r=(o[n]||0)-(a[n]||0))*r;return Math.sqrt(u)},ot.deltaE=function(t,e,i,r){var n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,P;for(null==i&&(i=1),null==r&&(r=1),"string"!==(y=_t(t))&&"number"!==y||(t=new T(t)),"string"!==(b=_t(e))&&"number"!==b||(e=new T(e)),n=(x=t.lab())[0],a=x[1],c=x[2],o=(_=e.lab())[0],s=_[1],u=_[2],h=bt(a*a+c*c),l=bt(s*s+u*u),S=n<16?.511:.040975*n/(1+.01765*n),w=.0638*h/(1+.0131*h)+.638,v=h<1e-6?0:180*I(c,a)/C;v<0;)v+=360;for(;360<=v;)v-=360;return A=164<=v&&v<=345?.56+nt(.2*O(C*(v+168)/180)):.36+nt(.4*O(C*(v+35)/180)),g=bt((p=h*h*h*h)/(p+1900)),bt((M=(n-o)/(i*S))*M+(E=(m=h-l)/(r*w))*E+((d=a-s)*d+(f=c-u)*f-m*m)/((P=w*(g*A+1-g))*P))},T.prototype.get=function(t){var e,i,r,n,o;return this,r=(n=t.split("."))[0],e=n[1],o=this[r](),e?-1<(i=r.indexOf(e))?o[i]:console.warn("unknown channel "+e+" in mode "+r):o},T.prototype.set=function(t,e){var i,r,n,o,a;if(this,n=(o=t.split("."))[0],i=o[1])if(a=this[n](),-1<(r=n.indexOf(i)))if("string"===_t(e))switch(e.charAt(0)){case"+":case"-":a[r]+=+e;break;case"*":a[r]*=+e.substr(1);break;case"/":a[r]/=+e.substr(1);break;default:a[r]=+e}else a[r]=e;else console.warn("unknown channel "+i+" in mode "+n);else a=e;return ot(a,n).alpha(this.alpha())},T.prototype.clipped=function(){return this._rgb._clipped||!1},T.prototype.alpha=function(t){return arguments.length?ot.rgb([this._rgb[0],this._rgb[1],this._rgb[2],t]):this._rgb[3]},T.prototype.darken=function(t){var e;return null==t&&(t=1),(e=this.lab())[0]-=s.Kn*t,ot.lab(e).alpha(this.alpha())},T.prototype.brighten=function(t){return null==t&&(t=1),this.darken(-t)},T.prototype.darker=T.prototype.darken,T.prototype.brighter=T.prototype.brighten,T.prototype.saturate=function(t){var e;return null==t&&(t=1),(e=this.lch())[1]+=t*s.Kn,e[1]<0&&(e[1]=0),ot.lch(e).alpha(this.alpha())},T.prototype.desaturate=function(t){return null==t&&(t=1),this.saturate(-t)},T.prototype.premultiply=function(){var t,e;return e=this.rgb(),t=this.alpha(),ot(e[0]*t,e[1]*t,e[2]*t,t)},W=function(t,e){return t*e/255},y=function(t,e){return e<t?e:t},G=function(t,e){return e<t?t:e},vt=function(t,e){return 255*(1-(1-t/255)*(1-e/255))},q=function(t,e){return e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255))},e=function(t,e){return 255*(1-(1-e/255)/(t/255))},b=function(t,e){return 255===t?255:255<(t=e/255*255/(1-t/255))?255:t},(r=function(t,e,i){if(!r[i])throw"unknown blend mode "+i;return r[i](t,e)}).normal=(t=function(n){return function(t,e){var i,r;return i=ot(e).rgb(),r=ot(t).rgb(),ot(n(i,r),"rgb")}})((x=function(o){return function(t,e){var i,r,n;for(n=[],i=r=0;r<=3;i=++r)n[i]=o(t[i],e[i]);return n}})(function(t,e){return t})),r.multiply=t(x(W)),r.screen=t(x(vt)),r.overlay=t(x(q)),r.darken=t(x(y)),r.lighten=t(x(G)),r.dodge=t(x(b)),r.burn=t(x(e)),ot.blend=r,ot.analyze=function(t){var e,i,r,n;for(r={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},i=0,e=t.length;i<e;i++)null==(n=t[i])||isNaN(n)||(r.values.push(n),r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.count+=1);return r.domain=[r.min,r.max],r.limits=function(t,e){return ot.limits(r,t,e)},r},ot.scale=function(h,t){var l,u,p,e,d,f,m,g,v,y,i,b,x,r,_,w,S,A,s,n,M;return v="rgb",y=ot("#ccc"),d=[r=0,1],x=[],l=!(b=[0,0]),i=!(p=[]),g=0,u={},_=!(e=!(m=1)),f=1,n=function(t){var e,i,r,n,o,a;if(null==t&&(t=["#fff","#000"]),null!=t&&"string"===_t(t)&&null!=ot.brewer&&(t=ot.brewer[t]||ot.brewer[t.toLowerCase()]||t),"array"===_t(t)){for(e=r=0,n=(t=t.slice(0)).length-1;0<=n?r<=n:n<=r;e=0<=n?++r:--r)i=t[e],"string"===_t(i)&&(t[e]=ot(i));for(e=a=x.length=0,o=t.length-1;0<=o?a<=o:o<=a;e=0<=o?++a:--a)x.push(e/(t.length-1))}return s(),p=t},S=function(t){var e,i;if(null!=l){for(i=l.length-1,e=0;e<i&&t>=l[e];)e++;return e-1}return 0},M=function(t){return t},A=function(t,e){var i,r,n,o,a,s,c;if(null==e&&(e=!1),isNaN(t))return y;if(c=e?t:l&&2<l.length?S(t)/(l.length-2):m!==g?(t-g)/(m-g):1,e||(c=M(c)),1!==f&&(c=ut(c,f)),c=b[0]+c*(1-b[0]-b[1]),c=Math.min(1,Math.max(0,c)),n=Math.floor(1e4*c),_&&u[n])i=u[n];else{if("array"===_t(p))for(r=o=0,s=x.length-1;0<=s?o<=s:s<=o;r=0<=s?++o:--o){if(c<=(a=x[r])){i=p[r];break}if(a<=c&&r===x.length-1){i=p[r];break}if(a<c&&c<x[r+1]){c=(c-a)/(x[r+1]-a),i=ot.interpolate(p[r],p[r+1],c,v);break}}else"function"===_t(p)&&(i=p(c));_&&(u[n]=i)}return i},s=function(){return u={}},n(h),(w=function(t){var e;return e=ot(A(t)),i&&e[i]?e[i]():e}).classes=function(t){var e;return null!=t?("array"===_t(t)?d=[(l=t)[0],t[t.length-1]]:(e=ot.analyze(d),l=0===t?[e.min,e.max]:ot.limits(e,"e",t)),w):l},w.domain=function(t){var e,i,r,n,o,a,s;if(!arguments.length)return d;if(g=t[0],m=t[t.length-1],x=[],r=p.length,t.length===r&&g!==m)for(o=0,n=t.length;o<n;o++)i=t[o],x.push((i-g)/(m-g));else for(e=s=0,a=r-1;0<=a?s<=a:a<=s;e=0<=a?++s:--s)x.push(e/(r-1));return d=[g,m],w},w.mode=function(t){return arguments.length?(v=t,s(),w):v},w.range=function(t,e){return n(t),w},w.out=function(t){return i=t,w},w.spread=function(t){return arguments.length?(r=t,w):r},w.correctLightness=function(t){return null==t&&(t=!0),e=t,s(),M=e?function(t){var e,i,r,n,o,a,s,c,u;for(e=A(0,!0).lab()[0],i=A(1,!0).lab()[0],s=i<e,r=A(t,!0).lab()[0],n=r-(o=e+(i-e)*t),c=0,u=1,a=20;.01<Math.abs(n)&&0<a--;)s&&(n*=-1),t+=n<0?.5*(u-(c=t)):.5*(c-(u=t)),r=A(t,!0).lab()[0],n=r-o;return t}:function(t){return t},w},w.padding=function(t){return null!=t?("number"===_t(t)&&(t=[t,t]),b=t,w):b},w.colors=function(e,i){var r,n,t,o,a,s,c,u;if(arguments.length<2&&(i="hex"),a=[],0===arguments.length)a=p.slice(0);else if(1===e)a=[w(.5)];else if(1<e)n=d[0],r=d[1]-n,a=function(){s=[];for(var t=0;0<=e?t<e:e<t;0<=e?t++:t--)s.push(t);return s}.apply(this).map(function(t){return w(n+t/(e-1)*r)});else{if(h=[],c=[],l&&2<l.length)for(t=u=1,o=l.length;1<=o?u<o:o<u;t=1<=o?++u:--u)c.push(.5*(l[t-1]+l[t]));else c=d;a=c.map(function(t){return w(t)})}return ot[i]&&(a=a.map(function(t){return t[i]()})),a},w.cache=function(t){return null!=t?(_=t,w):_},w.gamma=function(t){return null!=t?(f=t,w):f},w},null==ot.scales&&(ot.scales={}),ot.scales.cool=function(){return ot.scale([ot.hsl(180,1,.9),ot.hsl(250,.7,.4)])},ot.scales.hot=function(){return ot.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},ot.analyze=function(t,i,r){var n,e,o,a,s,c;if(s={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==r&&(r=function(){return!0}),n=function(t){null==t||isNaN(t)||(s.values.push(t),s.sum+=t,t<s.min&&(s.min=t),t>s.max&&(s.max=t),s.count+=1)},c=function(t,e){if(r(t,e))return null!=i&&"function"===_t(i)?n(i(t)):null!=i&&"string"===_t(i)||"number"===_t(i)?n(t[i]):n(t)},"array"===_t(t))for(a=0,o=t.length;a<o;a++)c(t[a]);else for(e in t)c(t[e],e);return s.domain=[s.min,s.max],s.limits=function(t,e){return ot.limits(s,t,e)},s},ot.limits=function(t,e,i){var r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,P,T,C,I,O,L,R,D,k,B,N,F,z,U,j,G,V,H,$,W,X,q,Y,Z,K,J,Q,tt,et,it,rt;if(null==e&&(e="equal"),null==i&&(i=7),"array"===_t(t)&&(t=ot.analyze(t)),P=t.min,ct=t.max,t.sum,it=t.values.sort(function(t,e){return t-e}),1===i)return[P,ct];if(M=[],"c"===e.substr(0,1)&&(M.push(P),M.push(ct)),"e"===e.substr(0,1)){for(M.push(P),w=R=1,N=i-1;1<=N?R<=N:N<=R;w=1<=N?++R:--R)M.push(P+w/i*(ct-P));M.push(ct)}else if("l"===e.substr(0,1)){if(P<=0)throw"Logarithmic scales are only possible for values > 0";for(T=Math.LOG10E*st(P),E=Math.LOG10E*st(ct),M.push(P),w=rt=1,F=i-1;1<=F?rt<=F:F<=rt;w=1<=F?++rt:--rt)M.push(ut(10,T+w/i*(E-T)));M.push(ct)}else if("q"===e.substr(0,1)){for(M.push(P),w=r=1,H=i-1;1<=H?r<=H:H<=r;w=1<=H?++r:--r)D=(it.length-1)*w/i,(k=at(D))===D?M.push(it[k]):(B=D-k,M.push(it[k]*(1-B)+it[k+1]*B));M.push(ct)}else if("k"===e.substr(0,1)){for(I=it.length,g=new Array(I),x=new Array(i),J=!0,O=0,y=null,(y=[]).push(P),w=n=1,$=i-1;1<=$?n<=$:$<=n;w=1<=$?++n:--n)y.push(P+w/i*(ct-P));for(y.push(ct);J;){for(S=o=0,W=i-1;0<=W?o<=W:W<=o;S=0<=W?++o:--o)x[S]=0;for(w=a=0,X=I-1;0<=X?a<=X:X<=a;w=0<=X?++a:--a){for(et=it[w],C=Number.MAX_VALUE,S=s=0,q=i-1;0<=q?s<=q:q<=s;S=0<=q?++s:--s)(_=nt(y[S]-et))<C&&(C=_,v=S);x[v]++,g[w]=v}for(L=new Array(i),S=c=0,Y=i-1;0<=Y?c<=Y:Y<=c;S=0<=Y?++c:--c)L[S]=null;for(w=u=0,Z=I-1;0<=Z?u<=Z:Z<=u;w=0<=Z?++u:--u)null===L[b=g[w]]?L[b]=it[w]:L[b]+=it[w];for(S=h=0,K=i-1;0<=K?h<=K:K<=h;S=0<=K?++h:--h)L[S]*=1/x[S];for(J=!1,S=l=0,z=i-1;0<=z?l<=z:z<=l;S=0<=z?++l:--l)if(L[S]!==y[w]){J=!0;break}y=L,200<++O&&(J=!1)}for(A={},S=p=0,U=i-1;0<=U?p<=U:U<=p;S=0<=U?++p:--p)A[S]=[];for(w=d=0,j=I-1;0<=j?d<=j:j<=d;w=0<=j?++d:--d)A[b=g[w]].push(it[w]);for(Q=[],S=f=0,G=i-1;0<=G?f<=G:G<=f;S=0<=G?++f:--f)Q.push(A[S][0]),Q.push(A[S][A[S].length-1]);for(Q=Q.sort(function(t,e){return t-e}),M.push(Q[0]),w=m=1,V=Q.length-1;m<=V;w=m+=2)tt=Q[w],isNaN(tt)||-1!==M.indexOf(tt)||M.push(tt)}return M},S=function(t,e,i){var r,n,o,a;return t=(r=wt(arguments))[0],e=r[1],i=r[2],isNaN(t)&&(t=0),(t/=360)<1/3?o=1-((n=(1-e)/3)+(a=(1+e*O(d*t)/O(c-d*t))/3)):t<2/3?n=1-((a=(1-e)/3)+(o=(1+e*O(d*(t-=1/3))/O(c-d*t))/3)):a=1-((o=(1-e)/3)+(n=(1+e*O(d*(t-=2/3))/O(c-d*t))/3)),[255*(a=V(i*a*3)),255*(o=V(i*o*3)),255*(n=V(i*n*3)),3<r.length?r[3]:1]},Q=function(){var t,e,i,r,n,o,a;return n=(o=wt(arguments))[0],e=o[1],t=o[2],d=2*Math.PI,n/=255,e/=255,t/=255,0===(a=1-Math.min(n,e,t)/(r=(n+e+t)/3))?i=0:(i=(n-e+(n-t))/2,i/=Math.sqrt((n-e)*(n-e)+(n-t)*(e-t)),i=Math.acos(i),e<t&&(i=d-i),i/=d),[360*i,a,r]},ot.hsi=function(){return function(t,e,i){i.prototype=t.prototype;var r=new i,n=t.apply(r,e);return Object(n)===n?n:r}(T,Et.call(arguments).concat(["hsi"]),function(){})},l.hsi=S,T.prototype.hsi=function(){return Q(this._rgb)},L=function(t,e,i,r){var n,o,a,s,c,u,h,l,p,d;return"hsl"===r?(p=t.hsl(),d=e.hsl()):"hsv"===r?(p=t.hsv(),d=e.hsv()):"hcg"===r?(p=t.hcg(),d=e.hcg()):"hsi"===r?(p=t.hsi(),d=e.hsi()):"lch"!==r&&"hcl"!==r||(r="hcl",p=t.hcl(),d=e.hcl()),"h"===r.substr(0,1)&&(o=p[0],h=p[1],s=p[2],a=d[0],l=d[1],c=d[2]),isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?n=Number.NaN:(n=a,1!==s&&0!==s||"hsv"===r||(u=l)):(n=o,1!==c&&0!==c||"hsv"===r||(u=h)):n=o+i*(o<a&&180<a-o?a-(o+360):a<o&&180<o-a?a+360-o:a-o),null==u&&(u=h+i*(l-h)),ot[r](n,u,s+i*(c-s))},k=function(t,e,i,r){var n,o;return n=t.num(),o=e.num(),ot.num(n+(o-n)*i,"num")},(p=p.concat(function(){var t,e,i,r;for(r=[],e=0,t=(i=["hsv","hsl","hsi","hcl","lch","hcg"]).length;e<t;e++)$=i[e],r.push([$,L]);return r}())).push(["num",k]),R=function(t,e,i,r){var n,o;return n=t.lab(),o=e.lab(),new T(n[0]+i*(o[0]-n[0]),n[1]+i*(o[1]-n[1]),n[2]+i*(o[2]-n[2]),r)},p.push(["lab",R])}).call(Kl)}).scale,tp={scale:"uniform",mode:"hcl",domain:[0,1],value:16777215,reverse:!1},ep=new ki,ip=function(t){void 0===t&&(t={}),this.parameters=xl(t,tp),"string"==typeof this.parameters.value&&(this.parameters.value=ep.set(this.parameters.value).getHex()),this.parameters.structure&&(this.atomProxy=this.parameters.structure.getAtomProxy())};ip.prototype.getScale=function(t){void 0===t&&(t={});var e=xl(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.reverse(),Ql(e.scale).mode(e.mode).domain(e.domain).out("num")},ip.prototype.colorToArray=function(t,e,i){return void 0===e&&(e=[]),void 0===i&&(i=0),e[i]=(t>>16&255)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(255&t)/255,e},ip.prototype.atomColorToArray=function(t,e,i){return this.colorToArray(this.atomColor?this.atomColor(t):0,e,i)},ip.prototype.bondColor=function(t,e){return this.atomProxy&&this.atomColor?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):0},ip.prototype.bondColorToArray=function(t,e,i,r){return this.colorToArray(this.bondColor(t,e),i,r)},ip.prototype.volumeColorToArray=function(t,e,i){return this.colorToArray(this.volumeColor?this.volumeColor(t):0,e,i)},ip.prototype.positionColorToArray=function(t,e,i){return this.colorToArray(this.positionColor?this.positionColor(t):0,e,i)};var rp,np,op=Jl(function(n){!function(t){function a(t,e,i,r,n){this._listener=e,this._isOnce=i,this.context=r,this._signal=t,this._priority=n||0}function r(t,e){if("function"!=typeof t)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))}function e(){this._bindings=[],this._prevParams=null;var t=this;this.dispatch=function(){e.prototype.dispatch.apply(t,arguments)}}e.prototype={VERSION:"1.0.0",memorize:!(a.prototype={active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,e=this._listener.apply(this.context,i),this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}}),_shouldPropagate:!0,active:!0,_registerListener:function(t,e,i,r){var n,o=this._indexOfListener(t,i);if(-1!==o){if((n=this._bindings[o]).isOnce()!==e)throw new Error("You cannot add"+(e?"":"Once")+"() then add"+(e?"Once":"")+"() the same listener without removing the relationship first.")}else n=new a(this,t,e,i,r),this._addBinding(n);return this.memorize&&this._prevParams&&n.execute(this._prevParams),n},_addBinding:function(t){for(var e=this._bindings.length;--e,this._bindings[e]&&t._priority<=this._bindings[e]._priority;);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){for(var i,r=this._bindings.length;r--;)if((i=this._bindings[r])._listener===t&&i.context===e)return r;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){return r(t,"add"),this._registerListener(t,!1,e,i)},addOnce:function(t,e,i){return r(t,"addOnce"),this._registerListener(t,!0,e,i)},remove:function(t,e){r(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(){for(var t=this._bindings.length;t--;)this._bindings[t]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(t){if(this.active){var e,i=Array.prototype.slice.call(arguments),r=this._bindings.length;if(this.memorize&&(this._prevParams=i),r)for(e=this._bindings.slice(),this._shouldPropagate=!0;e[--r]&&this._shouldPropagate&&!1!==e[r].execute(i););}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var i=e;i.Signal=e,n.exports?n.exports=i:t.signals=i}(Kl)}).Signal;(np=rp||(rp={}))[np.PROTEIN=1]="PROTEIN",np[np.NUCLEIC=2]="NUCLEIC",np[np.RNA=3]="RNA",np[np.DNA=4]="DNA",np[np.POLYMER=5]="POLYMER",np[np.WATER=6]="WATER",np[np.HELIX=7]="HELIX",np[np.SHEET=8]="SHEET",np[np.TURN=9]="TURN",np[np.BACKBONE=10]="BACKBONE",np[np.SIDECHAIN=11]="SIDECHAIN",np[np.ALL=12]="ALL",np[np.HETERO=13]="HETERO",np[np.ION=14]="ION",np[np.SACCHARIDE=15]="SACCHARIDE",np[np.SUGAR=15]="SUGAR",np[np.BONDED=16]="BONDED",np[np.RING=17]="RING",np[np.AROMATICRING=18]="AROMATICRING",np[np.METAL=19]="METAL",np[np.NONE=20]="NONE";var ap=["*","","ALL"],sp=["NONE"],cp=[rp.BACKBONE,rp.SIDECHAIN,rp.BONDED,rp.RING,rp.AROMATICRING,rp.METAL],up=[rp.POLYMER,rp.WATER],hp=["ALA","GLY","SER"],lp=["CYS","SER","THR"],pp=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],dp=["PHE","TRP","TYR","HIS"],fp=["ASN","GLN"],mp=["ASP","GLU"],gp=["ARG","HIS","LYS"],vp=["ARG","ASP","GLU","HIS","LYS"],yp=["ASN","ARG","ASP","CYS","GLY","GLN","GLU","HIS","LYS","SER","THR","TYR"],bp=["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL"],xp=["HIS","PHE","PRO","TRP","TYR"],_p=["ALA","GLY","ILE","LEU","VAL"];function wp(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===rp.BACKBONE&&!t.isBackbone())return!1;if(e.keyword===rp.SIDECHAIN&&!t.isSidechain())return!1;if(e.keyword===rp.BONDED&&!t.isBonded())return!1;if(e.keyword===rp.RING&&!t.isRing())return!1;if(e.keyword===rp.AROMATICRING&&!t.isAromatic())return!1;if(e.keyword===rp.HETERO&&!t.isHetero())return!1;if(e.keyword===rp.PROTEIN&&!t.isProtein())return!1;if(e.keyword===rp.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===rp.RNA&&!t.isRna())return!1;if(e.keyword===rp.DNA&&!t.isDna())return!1;if(e.keyword===rp.POLYMER&&!t.isPolymer())return!1;if(e.keyword===rp.WATER&&!t.isWater())return!1;if(e.keyword===rp.HELIX&&!t.isHelix())return!1;if(e.keyword===rp.SHEET&&!t.isSheet())return!1;if(e.keyword===rp.TURN&&!t.isTurn())return!1;if(e.keyword===rp.ION&&!t.isIon())return!1;if(e.keyword===rp.SACCHARIDE&&!t.isSaccharide())return!1;if(e.keyword===rp.METAL&&!t.isMetal())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&&Pl(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)return!1}else if(e.resno!==t.resno)return!1;return(void 0===e.inscode||e.inscode===t.inscode)&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function Sp(t,e){if(void 0===e.resname&&void 0===e.resno&&void 0===e.inscode&&void 0===e.sstruc&&void 0===e.model&&void 0===e.chainname&&void 0===e.atomindex&&(void 0===e.keyword||cp.includes(e.keyword)))return-1;if(void 0!==e.keyword){if(e.keyword===rp.HETERO&&!t.isHetero())return!1;if(e.keyword===rp.PROTEIN&&!t.isProtein())return!1;if(e.keyword===rp.NUCLEIC&&!t.isNucleic())return!1;if(e.keyword===rp.RNA&&!t.isRna())return!1;if(e.keyword===rp.DNA&&!t.isDna())return!1;if(e.keyword===rp.POLYMER&&!t.isPolymer())return!1;if(e.keyword===rp.WATER&&!t.isWater())return!1;if(e.keyword===rp.HELIX&&!t.isHelix())return!1;if(e.keyword===rp.SHEET&&!t.isSheet())return!1;if(e.keyword===rp.TURN&&!t.isTurn())return!1;if(e.keyword===rp.ION&&!t.isIon())return!1;if(e.keyword===rp.SACCHARIDE&&!t.isSaccharide())return!1}if(void 0!==e.atomindex&&0===Tl(e.atomindex,t.atomOffset,t.atomEnd))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)return!1}else if(e.resno!==t.resno)return!1;return(void 0===e.inscode||e.inscode===t.inscode)&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function Ap(t,e){if(!(void 0!==e.chainname||void 0!==e.model||void 0!==e.atomindex||void 0!==e.keyword&&up.includes(e.keyword)&&t.entity))return-1;if(void 0!==e.keyword){if(e.keyword===rp.POLYMER&&!t.entity.isPolymer())return!1;if(e.keyword===rp.WATER&&!t.entity.isWater())return!1}return(void 0===e.atomindex||0!==Tl(e.atomindex,t.atomOffset,t.atomEnd))&&((void 0===e.chainname||e.chainname===t.chainname)&&(void 0===e.model||e.model===t.modelIndex))}function Mp(t,e){return void 0===e.model&&void 0===e.atomindex?-1:(void 0===e.atomindex||0!==Tl(e.atomindex,t.atomOffset,t.atomEnd))&&(void 0===e.model||e.model===t.index)}function Ep(s,c){if(null===s)return!1;if(s.error)return!1;if(!s.rules||0===s.rules.length)return!1;for(var u=s.rules.length,h=!s.negate,l=!!s.negate,p=[],t=0;t<u;++t){var e=s.rules[t];e.hasOwnProperty("operator")&&(p[t]=Ep(e,c))}return function(t){for(var e="AND"===s.operator,i=!1,r=0;r<u;++r){var n=s.rules[r],o=void 0;if(n.hasOwnProperty("operator")){var a=p[r];if(-1===(o=!1!==a?a(t):-1)){i=!0;continue}if(!0===o){if(e)continue;return h}if(e)return l}else{if(n.keyword===rp.ALL){if(e)continue;return h}if(n.keyword===rp.NONE){if(e)continue;return l}if(-1!==(o=c(t,n))){if(!0===o){if(e)continue;return h}if(e)return l}else i=!0}}return i?-1:e?h:l}}function Pp(t,e){if(t.error)return t;if(!t.rules||0===t.rules.length)return t;var i=t.rules.length,r={operator:t.operator,rules:[]};t.hasOwnProperty("negate")&&(r.negate=t.negate);for(var n=0;n<i;++n){var o=t.rules[n];if(o.hasOwnProperty("operator")){var a=Pp(o,e);null!==a&&r.rules.push(a)}else e(o)||r.rules.push(o)}return 0<r.rules.length?t:null}function Tp(t,e){void 0===e&&(e=!1);var i=t;return e&&(i=Pp(t,function(t){return void 0!==t.keyword&&!cp.includes(t.keyword)||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.resname||(void 0!==t.resno||void 0!==t.sstruc))))})),Ep(i,wp)}function Cp(t,e){void 0===e&&(e=!1);var i=t;return e&&(i=Pp(t,function(t){return!(void 0===t.keyword||!cp.includes(t.keyword))||(void 0!==t.model||(void 0!==t.chainname||(void 0!==t.atomname||(void 0!==t.element||void 0!==t.altloc))))})),Ep(i,Sp)}function Ip(t,e){void 0===e&&(e=!1);var i=t;return e&&(i=Pp(t,function(t){return void 0!==t.keyword&&!up.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))))))})),Ep(i,Ap)}function Op(t,e){void 0===e&&(e=!1);var i=t;return e&&(i=Pp(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)))))))})),Ep(i,Mp)}var Lp=function(t){this.signals={stringChanged:new op},this.setString(t)},Rp={type:{configurable:!0}};Rp.type.get=function(){return"selection"},Lp.prototype.setString=function(t,e){if(void 0===t&&(t=this.string||""),t!==this.string){try{this.selection=function(t){var e={operator:void 0,rules:[]};if(!t)return e;var i,r,n=e,o=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());for(var a=t.split(/\s+/),s=function(t){i={operator:t,rules:[]},void 0===n?e=n=i:(n.rules.push(i),o.push(n),n=i)},c=function(t){r=n,void 0===(n=o.pop())&&(s(t),u(r))},u=function(t){n.rules.push(t)},h=!1,l=0;l<a.length;++l){var p=a[l],d=p.toUpperCase();if("("!==p)if(")"!==p){if(0<h)if("NOT"===d)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"!==d)if("OR"!==d)if("NOT"!==p.toUpperCase()){if(+d!=+d){var f=rp[d];if(void 0!==f){u({keyword:f});continue}}if("HYDROGEN"!==d)if("SMALL"!==d)if("NUCLEOPHILIC"!==d)if("HYDROPHOBIC"!==d)if("AROMATIC"!==d)if("AMIDE"!==d)if("ACIDIC"!==d)if("BASIC"!==d)if("CHARGED"!==d)if("POLAR"!==d)if("NONPOLAR"!==d)if("CYCLIC"!==d)if("ALIPHATIC"!==d)if("SIDECHAINATTACHED"!==d)if("LIGAND"!==d)if(-1===ap.indexOf(d))if("@"!==p.charAt(0))if("#"!==p.charAt(0))if("_"!==p.charAt(0))if("["!==p[0]||"]"!==p[p.length-1])if(1<=p.length&&p.length<=4&&"^"!==p[0]&&":"!==p[0]&&"."!==p[0]&&"%"!==p[0]&&"/"!==p[0]&&isNaN(parseInt(p)))u({resname:d});else{var m={operator:"AND",rules:[]},g=p.split("/");if(1<g.length&&g[1]){if(isNaN(parseInt(g[1])))throw new Error("model must be an integer");m.rules.push({model:parseInt(g[1])})}var v=g[0].split("%");1<v.length&&m.rules.push({altloc:v[1]});var y=v[0].split(".");if(1<y.length&&y[1]){if(4<y[1].length)throw new Error("atomname must be one to four characters");m.rules.push({atomname:y[1].substring(0,4).toUpperCase()})}var b=y[0].split(":");1<b.length&&b[1]&&m.rules.push({chainname:b[1]});var x=b[0].split("^");if(1<x.length&&m.rules.push({inscode:x[1]}),x[0]){var _=void 0,w=void 0;"-"===x[0][0]&&(x[0]=x[0].substr(1),_=!0),x[0].includes("--")&&(x[0]=x[0].replace("--","-"),w=!0);var S=x[0].split("-");if(1===S.length){var A=parseInt(S[0]);if(isNaN(A))throw new Error("resi must be an integer");_&&(A*=-1),m.rules.push({resno:A})}else{if(2!==S.length)throw new Error("resi range must contain one '-'");var M=S.map(function(t){return parseInt(t)});_&&(M[0]*=-1),w&&(M[1]*=-1),m.rules.push({resno:[M[0],M[1]]})}}if(1===m.rules.length)u(m.rules[0]);else{if(!(1<m.rules.length))throw new Error("empty selection chunk");u(m)}}else{var E=d.substr(1,p.length-2).split(","),P=1<E.length?E:E[0];u({resname:P})}else u({element:d.substr(1)});else console.error("# for element selection deprecated, use _"),u({element:d.substr(1)});else{var T=p.substr(1).split(",").map(function(t){return parseInt(t)});T.sort(function(t,e){return t-e}),u({atomindex:T})}else u({keyword:rp.ALL});else u({operator:"AND",rules:[{operator:"OR",rules:[{operator:"AND",rules:[{keyword:rp.HETERO},{negate:!0,operator:void 0,rules:[{keyword:rp.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{keyword:rp.POLYMER}]}]},{negate:!0,operator:void 0,rules:[{operator:"OR",rules:[{keyword:rp.WATER},{keyword:rp.ION}]}]}]});else u({operator:"OR",rules:[{keyword:rp.SIDECHAIN},{operator:"AND",negate:!1,rules:[{keyword:rp.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:rp.NUCLEIC},{operator:"OR",negate:!0,rules:[{atomname:"P"},{atomname:"OP1"},{atomname:"OP2"},{atomname:"O3'"},{atomname:"O3*"},{atomname:"O5'"},{atomname:"O5*"},{atomname:"C5'"},{atomname:"C5*"}]}]}]});else u({resname:_p});else u({resname:xp});else u({resname:bp});else u({resname:yp});else u({resname:vp});else u({resname:gp});else u({resname:mp});else u({resname:fp});else u({resname:dp});else u({resname:pp});else u({resname:lp});else u({resname:hp});else u({operator:"OR",rules:[{element:"H"},{element:"D"}]})}else h=1,s(),n.negate=!0;else"AND"===n.operator?c("OR"):n.operator="OR";else if("OR"===n.operator){var C=n.rules.pop();s("AND"),u(C)}else n.operator="AND"}else c(),n.negate&&c();else h=!1,s()}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}}var i=this.selection;this.string=t,this.test=Tp(i),this.residueTest=Cp(i),this.chainTest=Ip(i),this.modelTest=Op(i),this.atomOnlyTest=Tp(i,!0),this.residueOnlyTest=Cp(i,!0),this.chainOnlyTest=Ip(i,!0),this.modelOnlyTest=Op(i,!0),e||this.signals.stringChanged.dispatch(this.string)}},Lp.prototype.isAllSelection=function(){return ap.includes(this.string.toUpperCase())},Lp.prototype.isNoneSelection=function(){return sp.includes(this.string.toUpperCase())},Object.defineProperties(Lp.prototype,Rp);var Dp=function(e){function t(t){var n=this;e.call(this,t),this.colormakerList=[],this.selectionList=[],(t.dataList||[]).forEach(function(t){var e=t[0],i=t[1],r=t[2];void 0===r&&(r={}),Qp.hasScheme(e)?Object.assign(r,{scheme:e,structure:n.parameters.structure}):Object.assign(r,{scheme:"uniform",value:new ki(e).getHex()}),n.colormakerList.push(Qp.getScheme(r)),n.selectionList.push(new Lp(i))})}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){for(var e=0,i=this.selectionList.length;e<i;++e){var r=this.selectionList[e].test;if(r&&r(t))return this.colormakerList[e].atomColor(t)}return 16777215},t}(ip),kp={"":"",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",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",Set1:"[Q] Set1",Set2:"[Q] Set2",Set3:"[Q] Set3",Dark2:"[Q] Dark2",Paired:"[Q] Paired",Pastel1:"[Q] Pastel1",Pastel2:"[Q] Pastel2",Accent:"[Q] Accent",rainbow:"[?] Rainbow",rwb:"[?] Red-White-Blue"},Bp={"":"",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"},Np=function(){this.schemes={},this.userSchemes={}};Np.prototype.getScheme=function(t){var e=((t||{}).scheme||"").toLowerCase();return new(e in this.schemes?this.schemes[e]:e in this.userSchemes?this.userSchemes[e]:ip)(t)},Np.prototype.getSchemes=function(){var e={};return Object.keys(this.schemes).forEach(function(t){e[t]=t}),Object.keys(this.userSchemes).forEach(function(t){e[t]=t.split("|")[1]}),e},Np.prototype.getScales=function(){return kp},Np.prototype.getModes=function(){return Bp},Np.prototype.add=function(t,e){t=t.toLowerCase(),this.schemes[t]=e},Np.prototype.addScheme=function(t,e){return t instanceof ip||(t=this._createScheme(t)),this._addUserScheme(t,e)},Np.prototype._addUserScheme=function(t,e){e=e||"";var i=($l()+"|"+e).toLowerCase();return this.userSchemes[i]=t,i},Np.prototype.removeScheme=function(t){t=t.toLowerCase(),delete this.userSchemes[t]},Np.prototype._createScheme=function(e){var t=function(t){ip.call(this,t),e.call(this,t)};return(t.prototype=ip.prototype).constructor=ip,t},Np.prototype.addSelectionScheme=function(i,t){var e=function(e){function t(t){e.call(this,Object.assign({dataList:i},t))}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t}(Dp);return this._addUserScheme(e,t)},Np.prototype.hasScheme=function(t){return(t=t.toLowerCase())in this.schemes||t in this.userSchemes};var Fp=function(t){function e(){t.call(this,"parser")}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__hasObjName=function(t,e){var i=this.get(t);return i&&i.prototype.__objName===e},e.prototype.isTrajectory=function(t){return this.__hasObjName(t,"frames")},e.prototype.isStructure=function(t){return this.__hasObjName(t,"structure")},e.prototype.isVolume=function(t){return this.__hasObjName(t,"volume")},e.prototype.isSurface=function(t){return this.__hasObjName(t,"surface")},e.prototype.isBinary=function(t){var e=this.get(t);return e&&e.prototype.isBinary},e.prototype.isXml=function(t){var e=this.get(t);return e&&e.prototype.isXml},e.prototype.isJson=function(t){var e=this.get(t);return e&&e.prototype.isJson},e.prototype.getTrajectoryExtensions=function(){var e=this;return this.names.filter(function(t){return e.isTrajectory(t)})},e.prototype.getStructureExtensions=function(){var e=this;return this.names.filter(function(t){return e.isStructure(t)})},e.prototype.getVolumeExtensions=function(){var e=this;return this.names.filter(function(t){return e.isVolume(t)})},e.prototype.getSurfaceExtensions=function(){var e=this;return this.names.filter(function(t){return e.isSurface(t)})},e}(Ul);function zp(t){return Cl(function e(t){var i=t;return t.forEach(function(t){t.__deps&&Array.prototype.push.apply(i,e(t.__deps))}),i}(t)).map(function(t){return t.toString()}).join("\n\n\n")}function Up(t,e){var i="'use strict';\n\n"+zp(e);return i+="\n\n\nself.func = "+t.toString()+";",i+="\n\n\nself.onmessage = "+function(t){var e=t.data.__name,i=t.data.__postId;void 0===e?console.error("message __name undefined"):void 0===self.func?console.error("worker func undefined",e):self.func(t,function(e,t){e=e||{},void 0!==i&&(e.__postId=i);try{self.postMessage(e,t)}catch(t){console.error("self.postMessage:",t),self.postMessage(e)}})}.toString()+";",new Blob([i],{type:"application/javascript"})}var jp=function(){this.activeWorkerCount=0,this._funcDict={},this._depsDict={},this._blobDict={}};jp.prototype.add=function(t,e,i){this._funcDict[t]=e,this._depsDict[t]=i},jp.prototype.get=function(t){return this._blobDict[t]||(this._blobDict[t]=Up(this._funcDict[t],this._depsDict[t])),this._blobDict[t]};var Gp=Sl(),Vp=!1;try{var Hp=Object.defineProperty({},"passive",{get:function(){Vp=!0}});window.addEventListener("test",function(t){},Hp)}catch(t){}var $p="undefined"!=typeof window&&void 0!==window.orientation,Wp=!1;var Xp=!1;var qp,Yp={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)},Zp={color:"green",labelColor:"grey",labelAttachment:"bottom-center",labelSize:.7,labelZOffset:.5,labelYOffset:.1,labelBorder:!0,labelBorderColor:"lightgrey",labelBorderWidth:.25,lineOpacity:.8,linewidth:5,opacity:.6,labelUnit:"angstrom",arcVisible:!0,planeVisible:!1};de.Debug=!!(qp=yl("debug"))&&("string"!=typeof qp||/^1|true|t|yes|y$/i.test(qp));var Kp=["ngl","js"],Jp=new jp,Qp=new Np,td=new Ul("datasource"),ed=new Ul("representatation"),id=new Fp,rd=new Ul("shader"),nd=new Ul("decompressor"),od=new Ul("component"),ad=new Ul("buffer"),sd=new Ul("picker");var cd=function(t,e){void 0===e&&(e={}),this.chunkSize=10485760,this.newline="\n",this.__pointer=0,this.__partialLine="",this.compressed=bl(e.compressed,!1),this.binary=bl(e.binary,!1),this.json=bl(e.json,!1),this.xml=bl(e.xml,!1),this.src=t};cd.prototype.isBinary=function(){return this.binary||this.compressed},cd.prototype.read=function(){var i=this;return this._read().then(function(t){var e=i.compressed?nd.get(i.compressed):void 0;return i.compressed&&e?i.data=e(t):((i.binary||i.compressed)&&t instanceof ArrayBuffer&&(t=new Uint8Array(t)),i.data=t),i.data})},cd.prototype._chunk=function(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)},cd.prototype.chunk=function(t){var e=t+this.chunkSize;return this._chunk(t,e)},cd.prototype.peekLines=function(t){var e,i=this.data,r=i.length,n=this.isBinary()?this.newline.charCodeAt(0):this.newline,o=0;for(e=0;e<r&&(i[e]===n&&++o,o!==t);++e);var a=this._chunk(0,e+1);return this.chunkToLines(a,"",r<e).lines},cd.prototype.chunkCount=function(){return Math.floor(this.data.length/this.chunkSize)+1},cd.prototype.asText=function(){return this.isBinary()?Il(this.data):this.data},cd.prototype.chunkToLines=function(t,e,i){var r=this.newline;if(!this.isBinary()&&t.length===this.data.length)return{lines:t.split(r),partialLine:""};var n=[],o=this.isBinary()?Il(t):t,a=o.lastIndexOf(r);if(-1===a)e+=o;else{var s=e+o.substr(0,a);n=n.concat(s.split(r)),e=a===o.length-r.length?"":o.substr(a+r.length)}return i&&""!==e&&n.push(e),{lines:n,partialLine:e}},cd.prototype.nextChunk=function(){var t=this.__pointer;if(!(t>this.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},cd.prototype.nextChunkOfLines=function(){var t=this.nextChunk();if(void 0!==t){var e=this.__pointer>this.data.length,i=this.chunkToLines(t,this.__partialLine,e);return this.__partialLine=i.partialLine,i.lines}},cd.prototype.eachChunk=function(t){for(var e=this.chunkSize,i=this.data.length,r=this.chunkCount(),n=0;n<i;n+=e){t(this.chunk(n),Math.round(n/e),r)}},cd.prototype.eachChunkOfLines=function(o){var a=this;this.eachChunk(function(t,e,i){var r=e===i+1,n=a.chunkToLines(t,a.__partialLine,r);a.__partialLine=n.partialLine,o(n.lines,e,i)})},cd.prototype.dispose=function(){delete this.src};var ud=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._read=function(){var n=this;return new Promise(function(e,i){var t=n.src,r=new FileReader;r.onload=function(t){t.target&&e(t.target.result)},r.onerror=function(t){return i(t)},n.binary||n.compressed?r.readAsArrayBuffer(t):r.readAsText(t)})},e}(cd),hd=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._read=function(){var n=this;return new Promise(function(t,e){var i=n.src,r=new XMLHttpRequest;r.open("GET",i,!0),r.addEventListener("load",function(){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",function(t){return e("network error")},!1),n.isBinary()?r.responseType="arraybuffer":n.json?r.responseType="json":n.xml?r.responseType="document":r.responseType="text",r.send()})},e}(cd),ld=function(t,e){void 0===e&&(e={}),this.parameters=xl(e,{ext:"",compressed:!1,binary:id.isBinary(e.ext||""),name:"",dir:"",path:"",protocol:""});var i={compressed:this.parameters.compressed,binary:this.parameters.binary,json:id.isJson(this.parameters.ext),xml:id.isXml(this.parameters.ext)};"undefined"!=typeof File&&t instanceof File||"undefined"!=typeof Blob&&t instanceof Blob?this.streamer=new ud(t,i):this.streamer=new hd(t,i)},pd=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e),this.parserParams={voxelSize:e.voxelSize,firstModelOnly:e.firstModelOnly,asTrajectory:e.asTrajectory,cAlphaOnly:e.cAlphaOnly,name:this.parameters.name,path:this.parameters.path}}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.load=function(){return new(id.get(this.parameters.ext))(this.streamer,this.parserParams).parse()},t}(ld),dd=function(t,e,i){this.name=e,this.path=i,this.signals={elementAdded:new op,elementRemoved:new op,nameChanged:new op},this.type="Script",this.dir=i.substring(0,i.lastIndexOf("/")+1);try{this.fn=new Function("stage","__name","__path","__dir",t)}catch(t){Yp.error("Script compilation failed",t),this.fn=function(){}}};dd.prototype.run=function(i){var r=this;return new Promise(function(t,e){try{r.fn.apply(null,[i,r.name,r.path,r.dir]),t()}catch(t){Yp.error("Script.fn",t),e(t)}})};var fd=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.load=function(){var t=this;return this.streamer.read().then(function(){return new dd(t.streamer.asText(),t.parameters.name,t.parameters.path)})},e}(ld);function md(t){var e,i,r=nd.names,n="",o=(e=t instanceof File?t.name:t instanceof Blob?"":t).lastIndexOf("?"),a=-1!==o?e.substring(o):"",s=(e=e.substring(0,-1===o?e.length:o)).replace(/^.*[\\/]/,""),c=s.substring(0,s.lastIndexOf(".")),u=s.split("."),h=1<u.length?(u.pop()||"").toLowerCase():"",l=e.match(/^(.+):\/\/(.+)$/);l&&(n=l[1].toLowerCase(),e=l[2]||"");var p=e.substring(0,e.lastIndexOf("/")+1);if(r.includes(h)){i=h;var d=e.length-h.length-1;h=(e.substr(0,d).split(".").pop()||"").toLowerCase();var f=c.length-h.length-1;c=c.substr(0,f)}else i=!1;return{path:e,name:s,ext:h,base:c,dir:p,compressed:i,protocol:n,query:a,src:t}}function gd(t){var e=md(t),i=td.get(e.protocol);return i&&!(e=md(i.getUrl(e.src))).ext&&i.getExt&&(e.ext=i.getExt(t)),e}function vd(t,e){void 0===e&&(e={});var i,r=Object.assign(gd(t),e);return id.names.includes(r.ext)?i=new pd(r.src,r):Kp.includes(r.ext)&&(i=new fd(r.src,r)),i?i.load():Promise.reject(new Error("autoLoad: ext '"+r.ext+"' unknown"))}var yd=Jl(function(t,e){!function(){var f={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function m(t){return function(t,e){var i,r,n,o,a,s,c,u,h,l=1,p=t.length,d="";for(r=0;r<p;r++)if("string"==typeof t[r])d+=t[r];else if("object"==typeof t[r]){if((o=t[r]).keys)for(i=e[l],n=0;n<o.keys.length;n++){if(null==i)throw new Error(m('[sprintf] Cannot access property "%s" of undefined value "%s"',o.keys[n],o.keys[n-1]));i=i[o.keys[n]]}else i=o.param_no?e[o.param_no]:e[l++];if(f.not_type.test(o.type)&&f.not_primitive.test(o.type)&&i instanceof Function&&(i=i()),f.numeric_arg.test(o.type)&&"number"!=typeof i&&isNaN(i))throw new TypeError(m("[sprintf] expecting number but found %T",i));switch(f.number.test(o.type)&&(u=0<=i),o.type){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,o.width?parseInt(o.width):0);break;case"e":i=o.precision?parseFloat(i).toExponential(o.precision):parseFloat(i).toExponential();break;case"f":i=o.precision?parseFloat(i).toFixed(o.precision):parseFloat(i);break;case"g":i=o.precision?String(Number(i.toPrecision(o.precision))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=o.precision?i.substring(0,o.precision):i;break;case"t":i=String(!!i),i=o.precision?i.substring(0,o.precision):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=o.precision?i.substring(0,o.precision):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=o.precision?i.substring(0,o.precision):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase()}f.json.test(o.type)?d+=i:(!f.number.test(o.type)||u&&!o.sign?h="":(h=u?"+":"-",i=i.toString().replace(f.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",c=o.width-(h+i).length,a=o.width&&0<c?s.repeat(c):"",d+=o.align?h+i+a:"0"===s?h+a+i:a+h+i)}return d}(function(t){if(c[t])return c[t];var e,i=t,r=[],n=0;for(;i;){if(null!==(e=f.text.exec(i)))r.push(e[0]);else if(null!==(e=f.modulo.exec(i)))r.push("%");else{if(null===(e=f.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){n|=1;var o=[],a=e[2],s=[];if(null===(s=f.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(s[1]);""!==(a=a.substring(s[0].length));)if(null!==(s=f.key_access.exec(a)))o.push(s[1]);else{if(null===(s=f.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(s[1])}e[2]=o}else n|=2;if(3===n)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}i=i.substring(e[0].length)}return c[t]=r}(t),arguments)}function t(t,e){return m.apply(null,[t].concat(e||[]))}var c=Object.create(null);e.sprintf=m,e.vsprintf=t,"undefined"!=typeof window&&(window.sprintf=m,window.vsprintf=t)}()}).sprintf,bd=function(){};bd.prototype.getBlob=function(){return new Blob([this.getData()],{type:this.mimeType})},bd.prototype.download=function(t,e){t=bl(t,this.defaultName),e=bl(e,this.defaultExt),Ml(this.getBlob(),t+"."+e)};var xd=function(n){function t(t,e){n.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";var i,r=Object.assign({},e);this.renumberSerial=bl(r.renumberSerial,!0),this.remarks=(i=bl(r.remarks,[]),Array.isArray(i)?i:[i]),this.structure=t,this._records=[]}return n&&(t.__proto__=n),((t.prototype=Object.create(n&&n.prototype)).constructor=t).prototype._writeRecords=function(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()},t.prototype._writeTitle=function(){this._records.push(yd("TITLE %-74s",this.structure.name))},t.prototype._writeRemarks=function(){var e=this;this.remarks.forEach(function(t){e._records.push(yd("REMARK %-73s",t))}),this.structure.trajectory&&(this._records.push(yd("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(yd("REMARK %-73s","Frame "+this.structure.trajectory.frame)))},t.prototype._writeAtoms=function(){var n=this,o=1,e=1;this.structure.eachModel(function(t){n._records.push(yd("MODEL %-74d",e++)),t.eachAtom(function(t){var e=t.hetero?"HETATM%5d %-4s %3s %1s%4d    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s":"ATOM  %5d %-4s %3s %1s%4d    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s",i=n.renumberSerial?o:t.serial,r=t.atomname;1===r.length&&(r=" "+r),n._records.push(yd(e,i,r,t.resname,bl(t.chainname," "),t.resno,t.x,t.y,t.z,bl(t.occupancy,1),bl(t.bfactor,0),"",bl(t.element,""))),o+=1}),n._records.push(yd("%-80s","ENDMDL")),e+=1}),this._records.push(yd("%-80s","END"))},t.prototype.getString=function(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()},t.prototype.getData=function(){return this._writeRecords(),this._records.join("\n")},t}(bd),_d=function(e){function t(t){e.call(this),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=t,this._records=[]}e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t;var i={idString:{configurable:!0},titleString:{configurable:!0},countsString:{configurable:!0},chargeLines:{configurable:!0}};return i.idString.get=function(){return this.structure.id},i.titleString.get=function(){return"  "+this.structure.title},i.countsString.get=function(){return yd("%3i%3i  0  0  0  0  0  0  0  0999 V2000",this.structure.atomCount,this.structure.bondCount)},i.chargeLines.get=function(){var e=[];this.structure.eachAtom(function(t){null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])});for(var t=[],i=0;i<e.length;i+=8){for(var r=Math.min(8,e.length-i),n=yd("M  CHG%3i",r),o=i;o<i+r;o++)n+=yd(" %3i %3i",e[o][0]+1,e[o][1]);t.push(n)}return t},t.prototype.formatAtom=function(t){var e=0;null!=t.formalCharge&&0!==t.formalCharge&&(e=4-t.formalCharge);var i=yd("%10.4f%10.4f%10.4f %-3s 0%3i  0  0  0",t.x,t.y,t.z,t.element,e);if(48!==i.length)throw new Error("Incompatible atom for sdf format");return i},t.prototype.formatBond=function(t){return yd("%3i%3i%3i  0  0  0",t.atomIndex1+1,t.atomIndex2+1,t.bondOrder)},t.prototype._writeRecords=function(){this._records.length=0,this._writeHeader(),this._writeCTab(),this._writeFooter()},t.prototype._writeHeader=function(){this._records.push(this.idString,this.titleString,"")},t.prototype._writeCTab=function(){var e=this;this._records.push(this.countsString),this.structure.eachAtom(function(t){e._records.push(e.formatAtom(t))}),this.structure.eachBond(function(t){e._records.push(e.formatBond(t))}),this.chargeLines.forEach(function(t){e._records.push(t)}),this._records.push("M  END")},t.prototype._writeFooter=function(){this._records.push("$$$$")},t.prototype.getData=function(){return this._writeRecords(),this._records.join("\n")},Object.defineProperties(t.prototype,i),t}(bd),wd=[],Sd=function(t,e){void 0===e&&(e={}),this._mark=0,this._marks=[],this.offset=0;var i=!(this.littleEndian=!0);void 0===t&&(t=8192),"number"==typeof t?t=new ArrayBuffer(t):i=!0;var r=e.offset?e.offset>>>0:0,n=t.byteLength-r,o=r;t instanceof ArrayBuffer||(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+r),t=t.buffer),this._lastWrittenByte=i?n:0,this.buffer=t,this.length=n,this.byteLength=n,this.byteOffset=o,this._data=new DataView(this.buffer,o,n)};Sd.prototype.available=function(t){return void 0===t&&(t=1),this.offset+t<=this.length},Sd.prototype.isLittleEndian=function(){return this.littleEndian},Sd.prototype.setLittleEndian=function(){return this.littleEndian=!0,this},Sd.prototype.isBigEndian=function(){return!this.littleEndian},Sd.prototype.setBigEndian=function(){return this.littleEndian=!1,this},Sd.prototype.skip=function(t){return void 0===t&&(t=1),this.offset+=t,this},Sd.prototype.seek=function(t){return this.offset=t,this},Sd.prototype.mark=function(){return this._mark=this.offset,this},Sd.prototype.reset=function(){return this.offset=this._mark,this},Sd.prototype.pushMark=function(){return this._marks.push(this.offset),this},Sd.prototype.popMark=function(){var t=this._marks.pop();if(void 0===t)throw new Error("Mark stack empty");return this.seek(t),this},Sd.prototype.rewind=function(){return this.offset=0,this},Sd.prototype.ensureAvailable=function(t){if(void 0===t&&(t=1),!this.available(t)){var 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},Sd.prototype.readBoolean=function(){return 0!==this.readUint8()},Sd.prototype.readInt8=function(){return this._data.getInt8(this.offset++)},Sd.prototype.readUint8=function(){return this._data.getUint8(this.offset++)},Sd.prototype.readByte=function(){return this.readUint8()},Sd.prototype.readBytes=function(t){void 0===t&&(t=1);for(var e=new Uint8Array(t),i=0;i<t;i++)e[i]=this.readByte();return e},Sd.prototype.readInt16=function(){var t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t},Sd.prototype.readUint16=function(){var t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t},Sd.prototype.readInt32=function(){var t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t},Sd.prototype.readUint32=function(){var t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t},Sd.prototype.readFloat32=function(){var t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t},Sd.prototype.readFloat64=function(){var t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t},Sd.prototype.readChar=function(){return String.fromCharCode(this.readInt8())},Sd.prototype.readChars=function(t){void 0===t&&(t=1),wd.length=t;for(var e=0;e<t;e++)wd[e]=this.readChar();return wd.join("")},Sd.prototype.writeBoolean=function(t){return void 0===t&&(t=!1),this.writeUint8(t?255:0),this},Sd.prototype.writeInt8=function(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this},Sd.prototype.writeUint8=function(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this},Sd.prototype.writeByte=function(t){return this.writeUint8(t)},Sd.prototype.writeBytes=function(t){this.ensureAvailable(t.length);for(var e=0;e<t.length;e++)this._data.setUint8(this.offset++,t[e]);return this._updateLastWrittenByte(),this},Sd.prototype.writeInt16=function(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this},Sd.prototype.writeUint16=function(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this},Sd.prototype.writeInt32=function(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this},Sd.prototype.writeUint32=function(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this},Sd.prototype.writeFloat32=function(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this},Sd.prototype.writeFloat64=function(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this},Sd.prototype.writeChar=function(t){return this.writeUint8(t.charCodeAt(0))},Sd.prototype.writeChars=function(t){for(var e=0;e<t.length;e++)this.writeUint8(t.charCodeAt(e));return this},Sd.prototype.toArray=function(){return new Uint8Array(this.buffer,this.byteOffset,this._lastWrittenByte)},Sd.prototype._updateLastWrittenByte=function(){this.offset>this._lastWrittenByte&&(this._lastWrittenByte=this.offset)};var Ad=function(e){function t(t){e.call(this),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=t}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.getData=function(){var t=this.surface.index.length/3,e=new Sd(2*t+3*t*4*4+80+4);e.skip(80),e.writeUint32(t);for(var i=new ri,r=new ri,n=new ri,o=new ri,a=0;a<t;a++){var s=[this.surface.index[3*a],this.surface.index[3*a+1],this.surface.index[3*a+2]];r.fromArray(this.surface.normal,3*s[0]),n.fromArray(this.surface.normal,3*s[1]),o.fromArray(this.surface.normal,3*s[2]),i.addVectors(r,n).add(o).normalize(),e.writeFloat32(i.x),e.writeFloat32(i.y),e.writeFloat32(i.z);for(var c=0;c<3;c++)i.fromArray(this.surface.position,3*s[c]),e.writeFloat32(i.x),e.writeFloat32(i.y),e.writeFloat32(i.z);e.writeUint16(0)}return new DataView(e.buffer)},t}(bd),Md=function(){this.count=0,this.signals={countChanged:new op}};Md.prototype.clear=function(){this.change(-this.count)},Md.prototype.change=function(t){this.count+=t,this.signals.countChanged.dispatch(t,this.count),this.count<0&&Yp.warn("Counter.count below zero",this.count)},Md.prototype.increment=function(){this.change(1)},Md.prototype.decrement=function(){this.change(-1)},Md.prototype.listen=function(t){this.change(t.count),t.signals.countChanged.add(this.change,this)},Md.prototype.unlisten=function(t){var e=t.signals.countChanged;e.has(this.change,this)&&e.remove(this.change,this)},Md.prototype.onZeroOnce=function(t,e){var i=this;if(0===this.count)t.call(e);else{var r=function(){0===i.count&&(i.signals.countChanged.remove(r,i),t.call(e))};this.signals.countChanged.add(r,this)}},Md.prototype.dispose=function(){this.clear(),this.signals.countChanged.dispose()},rd.add("shader/BasicLine.vert","void main(){\n#include begin_vertex\n#include project_vertex\n}"),rd.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}"),rd.add("shader/Quad.vert","varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"),rd.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}");var Ed=function(){this.signals={updated:new op},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()};Ed.prototype.update=function(){this.startTime=this.end(),this.currentTime=this.startTime,this.signals.updated.dispatch()},Ed.prototype.begin=function(){this.startTime=window.performance.now(),this.lastFrames=this.frames},Ed.prototype.end=function(){var 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},rd.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"),rd.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}"),rd.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}"),rd.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"),rd.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < clipNear )\ndiscard;\n#endif"),rd.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"),rd.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"),rd.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),rd.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}");var Pd=/^(?!\/\/)\s*#include\s+(\S+)/gim,Td={};function Cd(t,e){void 0===e&&(e={});var i=t+"|";for(var r in e)i+=r+":"+e[r];if(!Td[i]){var n=function(t){if(void 0===t)return"";var e=[];for(var i in t){var r=t[i];r&&e.push("#define "+i+" "+r)}return e.join("\n")+"\n"}(e),o=rd.get("shader/"+t);if(!o)throw new Error("empty shader, '"+t+"'");o=o.replace(Pd,function(t,e){var i="shader/chunk/"+e+".glsl",r=rd.get(i)||Li[e];if(!r)throw new Error("empty chunk, '"+e+"'");return r}),Td[i]=n+o}return Td[i]}if("undefined"!=typeof WebGLRenderingContext){var Id=WebGLRenderingContext.prototype,Od=Id.getShaderParameter;Id.getShaderParameter=function(){return!de.Debug||Od.apply(this,arguments)};var Ld=Id.getShaderInfoLog;Id.getShaderInfoLog=function(){return de.Debug?Ld.apply(this,arguments):""};var Rd=Id.getProgramParameter;Id.getProgramParameter=function(t,e){return!de.Debug&&e===Id.LINK_STATUS||Rd.apply(this,arguments)};var Dd=Id.getProgramInfoLog;Id.getProgramInfoLog=function(){return de.Debug?Dd.apply(this,arguments):""}}var kd=[[[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]]];kd.forEach(function(t){t.forEach(function(t){t[0]*=.0625,t[1]*=.0625})});var Bd=function(t,e,i,r){this.canvas=document.createElement("canvas"),this._viewer=i,this._factor=bl(r.factor,2),this._antialias=bl(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)};Bd.prototype._renderTile=function(t){var e=this._viewer,i=this._width,r=this._height,n=this._factor,o=t%n*i,a=Math.floor(t/n)*r;if(e.camera.setViewOffset(i*n,r*n,o,a,i,r),e.render(),this._antialias){var s=Math.round((o+i)/2)-Math.round(o/2),c=Math.round((a+r)/2)-Math.round(a/2);this._ctx.drawImage(e.renderer.domElement,Math.round(o/2),Math.round(a/2),s,c)}else this._ctx.drawImage(e.renderer.domElement,Math.floor(o),Math.floor(a),Math.ceil(i),Math.ceil(r));"function"==typeof this._onProgress&&this._onProgress(t+1,this._n,!1)},Bd.prototype._finalize=function(){this._viewer.setSampling(this._viewerSampleLevel),this._viewer.camera.view=null,"function"==typeof this._onFinish&&this._onFinish(this._n+1,this._n,!1)},Bd.prototype.render=function(){for(var t=0;t<=this._n;++t)t===this._n?this._finalize():this._renderTile(t)},Bd.prototype.renderAsync=function(){for(var t=this,e=0,i=this._n,r=function(){e===i?t._finalize():t._renderTile(e),e+=1},n=0;n<=i;++n)setTimeout(r,0)};var Nd=2*Math.PI,Fd=(Math.PI,180/Math.PI);function zd(t,e,i,r,n){void 0===i&&(i=1),void 0===r&&(r=0);var o=n?n.length:t.length/i,a=0,s=0;if(n)for(var c=0;c<o;++c){var u=(t[n[c]*i+r]+e)%e/e*Nd-Math.PI;a+=Math.cos(u),s+=Math.sin(u)}else for(var h=r;h<o;h+=i){var l=(t[h]+e)%e/e*Nd-Math.PI;a+=Math.cos(l),s+=Math.sin(l)}return a/=o,s/=o,(Math.atan2(s,a)+Math.PI)/Nd*e}function Ud(t,e,i,r){void 0===r&&(r=0);for(var n=t.length,o=i||new Float32Array(n),a=0;a<n;a+=3)o[r+a+0]=(t[a+0]+e[a+0])/2,o[r+a+1]=(t[a+1]+e[a+1])/2,o[r+a+2]=(t[a+2]+e[a+2])/2;return o}function jd(t,e){for(var i=t.length,r=new Float32Array(i),n=0;n<i;n+=3)r[n+0]=e[n+0]-t[n+0],r[n+1]=e[n+1]-t[n+1],r[n+2]=e[n+2]-t[n+2];return r}function Gd(t,e,i){for(var r=i||new Float32Array(t),n=0;n<t;++n)r[n]=e;return r}function Vd(t,e,i,r,n){for(var o=n||new Float32Array(3*t),a=0;a<t;++a){var s=3*a;o[s+0]=e,o[s+1]=i,o[s+2]=r}return o}function Hd(t){for(var e=new Float32Array(t),i=0;i<t;++i)e[i]=i;return e}function $d(t,e,i,r){void 0===i&&(i=0);for(var n=r||new Float32Array(t*e),o=0;o<t;++o)for(var a=i+o*e,s=0;s<e;++s)n[a+s]=o;return n}function Wd(t,e){for(var i=t.length,r=new Float32Array(i*e),n=0;n<i;++n)for(var o=n*e,a=t[n],s=0;s<e;++s)r[o+s]=a;return r}function Xd(t,e,i,r,n){for(var o=0;o<n;++o)e[r+o]=t[i+o]}function qd(t,e,i,r){Xd(t,t,e,i,r)}function Yd(t){for(var e=-1/0,i=0,r=t.length;i<r;++i)t[i]>e&&(e=t[i]);return e}function Zd(t){for(var e=1/0,i=0,r=t.length;i<r;++i)t[i]<e&&(e=t[i]);return e}function Kd(t,e,i){void 0===e&&(e=1),void 0===i&&(i=0);for(var r=t.length,n=0,o=i;o<r;o+=e)n+=t[o];return n}function Jd(t,e,i){return void 0===e&&(e=1),void 0===i&&(i=0),Kd(t,e,i)/(t.length/e)}var Qd={trim:!1,factor:1,antialias:!1,transparent:!1,onProgress:void 0};function tf(o,r){void 0===r&&(r={});var t=xl(r,Qd),i=t.trim,e=t.factor,a=t.antialias,s=t.transparent,c=o.renderer,u=o.camera,h=c.getClearAlpha(),n=c.getClearColor();function l(t){void 0===t&&(t=!1);var i=e;a&&(i*=2),t&&(i=1/i),o.scene.traverse(function(t){var e=t.material;e&&e.linewidth&&(e.linewidth*=i),e&&e.uniforms&&e.uniforms.size&&void 0===e.uniforms.size.__seen&&(e.uniforms.size.value*=i,e.uniforms.size.__seen=!0),e&&e.uniforms&&e.uniforms.linewidth&&void 0===e.uniforms.linewidth.__seen&&(e.uniforms.linewidth.value*=i,e.uniforms.linewidth.__seen=!0)}),o.scene.traverse(function(t){var e=t.material;e&&e.uniforms&&e.uniforms.size&&delete e.uniforms.size.__seen,e&&e.uniforms&&e.uniforms.linewidth&&delete e.uniforms.linewidth.__seen})}function p(t){if(i){var e=n;return function(t,e,i,r,n){var o,a,s,c,u=t.height,h=t.width,l=t.getContext("2d").getImageData(0,0,h,u).data;for(s=!1,a=0;a<u;a++){for(o=0;o<h;o++)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var p=a;for(s=!1,o=0;o<h;o++){for(a=0;a<u;a++)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var d=o;for(s=!1,a=u-1;0<=a;a--){for(o=h-1;0<=o;o--)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var f=a;for(s=!1,o=h-1;0<=o;o--){for(a=u-1;0<=a;a--)if(l[c=4*(a*h+o)]!==e||l[c+1]!==i||l[c+2]!==r||l[c+3]!==n){s=!0;break}if(s)break}var m=o,g=document.createElement("canvas");return g.width=m-d,g.height=f-p,g.getContext("2d").drawImage(t,d,p,g.width,g.height,0,0,g.width,g.height),g}(t,s?0:255*e.r,s?0:255*e.g,s?0:255*e.b,s?0:255)}return t}function d(t,e,i){"function"==typeof r.onProgress&&r.onProgress(t,e,i)}return new Promise(function(i,r){var n=new Bd(c,u,o,{factor:e,antialias:a,onProgress:d,onFinish:function(t,e){p(n.canvas).toBlob(function(t){c.setClearAlpha(h),l(!0),o.requestRender(),d(e,e,!0),t?i(t):r("error creating image")},"image/png")}});c.setClearAlpha(s?0:1),l(),n.renderAsync()})}var ef=new ri,rf=new ei,nf=new ei;var of=new ti,af=new ei,sf=new ei;function cf(t,e){af.getInverse(e.projectionMatrix),sf.copy(e.projectionMatrix).transpose(),t.traverse(function(t){var e=t.material;if(e){var i=e.uniforms;i&&(i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(af),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(sf))}})}function uf(t,e,i){var r=t.createShader(i);return t.shaderSource(r,e),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS)?r:(console.log("error compiling shader "+r+": "+t.getShaderInfoLog(r)),t.deleteShader(r),null)}function hf(t,e){var i=t.getExtension(e);return i||console.log("extension '"+e+"' not available"),i}var lf=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function pf(t){var e=document.createElement("canvas");e.width=16,e.height=16,e.style.width="16px",e.style.height="16px";var i=e.getContext("webgl")||e.getContext("experimental-webgl");if(!i)return console.log("error creating webgl context for "+t),!1;hf(i,"OES_texture_float"),hf(i,"OES_texture_half_float"),hf(i,"WEBGL_color_buffer_float");var r=uf(i,"\nattribute vec4 a_position;\n\nvoid main() {\n  gl_Position = a_position;\n}",i.VERTEX_SHADER),n=uf(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||!n)return!1;var o,a,s,c,u,h=(a=[r,n],u=(o=i).createProgram(),a.forEach(function(t){return o.attachShader(u,t)}),s&&s.forEach(function(t,e){o.bindAttribLocation(u,c?c[e]:e,t)}),o.linkProgram(u),o.getProgramParameter(u,o.LINK_STATUS)?u:(console.log("error linking program: "+o.getProgramInfoLog(u)),o.deleteProgram(u),null));i.useProgram(h);var l=i.getAttribLocation(h,"a_position"),p=i.getUniformLocation(h,"u_color");if(!p)return console.log("error getting 'u_color' uniform location"),!1;var d=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,d),i.bufferData(i.ARRAY_BUFFER,lf,i.STATIC_DRAW),i.enableVertexAttribArray(l),i.vertexAttribPointer(l,2,i.FLOAT,!1,0,0);var f=i.createTexture(),m=new Uint8Array([255,255,255,255]);i.bindTexture(i.TEXTURE_2D,f),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,m);var g=i.createTexture();i.bindTexture(i.TEXTURE_2D,g),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);var v=i.createFramebuffer();if(i.bindFramebuffer(i.FRAMEBUFFER,v),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,g,0),i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return console.log("error creating framebuffer for "+t),!1;i.bindTexture(i.TEXTURE_2D,f),i.uniform4fv(p,[0,10,20,1]),i.drawArrays(i.TRIANGLES,0,6),i.bindTexture(i.TEXTURE_2D,g),i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(1,0,0,1),i.clear(i.COLOR_BUFFER_BIT),i.uniform4fv(p,[0,.1,.05,1]),i.drawArrays(i.TRIANGLES,0,6);var y=new Uint8Array(4);if(i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,y),0!==y[0]||y[1]<248||y[2]<248||y[3]<254)return console.log("not able to actually render to "+t+" texture"),!1;if(t===i.FLOAT){i.bindFramebuffer(i.FRAMEBUFFER,v);var b=new Float32Array(4);i.readPixels(0,0,1,1,i.RGBA,i.FLOAT,b);var x=i.getError();if(x)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,x)+"'"),!1}return!0}var df=new Float32Array(100),ff=new Uint8Array(100),mf=[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],gf=new ei;function vf(t,e,i,r,n){var o=n.uniforms,a=[];if(o.objectId&&(o.objectId.value=Wp?this.id:this.id/255,a.push("objectId")),(o.modelViewMatrixInverse||o.modelViewMatrixInverseTranspose||o.modelViewProjectionMatrix||o.modelViewProjectionMatrixInverse)&&this.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,this.matrixWorld),o.modelViewMatrixInverse&&(o.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix),a.push("modelViewMatrixInverse")),o.modelViewMatrixInverseTranspose&&(o.modelViewMatrixInverse?o.modelViewMatrixInverseTranspose.value.copy(o.modelViewMatrixInverse.value).transpose():o.modelViewMatrixInverseTranspose.value.getInverse(this.modelViewMatrix).transpose(),a.push("modelViewMatrixInverseTranspose")),o.modelViewProjectionMatrix&&(o.modelViewProjectionMatrix.value.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),a.push("modelViewProjectionMatrix")),o.modelViewProjectionMatrixInverse&&(o.modelViewProjectionMatrix?gf.copy(o.modelViewProjectionMatrix.value):gf.multiplyMatrices(i.projectionMatrix,this.modelViewMatrix),o.modelViewProjectionMatrixInverse.value.getInverse(gf),a.push("modelViewProjectionMatrixInverse")),a.length){var s=t.properties.get(n);if(s.program){var c=t.getContext(),u=s.program;c.useProgram(u.program);var h=u.getUniforms();a.forEach(function(t){h.setValue(c,t,o[t].value)})}}}var yf=function(t){if(this.boundingBox=new Pi,this.boundingBoxSize=new ri,this.boundingBoxLength=0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}},this.distVector=new ri,this.signals={ticked:new op,rendered:new op},"string"==typeof t){var 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{var i=this.container.getBoundingClientRect();this.width=i.width||1,this.height=i.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)):Yp.error("Viewer: could not initialize renderer")};yf.prototype._initParams=function(){this.parameters={fogColor:new ki(0),fogNear:50,fogFar:100,fogMode:"scene",fogScale:"relative",backgroundColor:new ki(0),cameraType:"perspective",cameraFov:40,cameraEyeSep:.3,cameraZ:-80,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",lightColor:new ki(14540253),lightIntensity:1,ambientColor:new ki(14540253),ambientIntensity:.2,sampleLevel:0}},yf.prototype._initCamera=function(){var t=new ri(0,0,0),e=this.width,i=this.height;this.perspectiveCamera=new ba(this.parameters.cameraFov,e/i),this.perspectiveCamera.position.z=this.parameters.cameraZ,this.perspectiveCamera.lookAt(t),this.orthographicCamera=new lr(e/-2,e/2,i/2,i/-2),this.orthographicCamera.position.z=this.parameters.cameraZ,this.orthographicCamera.lookAt(t),this.stereoCamera=new Ju,this.stereoCamera.aspect=.5,this.stereoCamera.eyeSep=this.parameters.cameraEyeSep;var r=this.parameters.cameraType;if("orthographic"===r)this.camera=this.orthographicCamera;else{if("perspective"!==r&&"stereo"!==r)throw new Error("Unknown cameraType '"+r+"'");this.camera=this.perspectiveCamera}this.camera.updateProjectionMatrix()},yf.prototype._initStats=function(){this.stats=new Ed},yf.prototype._initScene=function(){this.scene||(this.scene=new Ea,this.scene.name="scene"),this.rotationGroup=new ya,this.rotationGroup.name="rotationGroup",this.scene.add(this.rotationGroup),this.translationGroup=new ya,this.translationGroup.name="translationGroup",this.rotationGroup.add(this.translationGroup),this.modelGroup=new ya,this.modelGroup.name="modelGroup",this.translationGroup.add(this.modelGroup),this.pickingGroup=new ya,this.pickingGroup.name="pickingGroup",this.translationGroup.add(this.pickingGroup),this.backgroundGroup=new ya,this.backgroundGroup.name="backgroundGroup",this.translationGroup.add(this.backgroundGroup),this.helperGroup=new ya,this.helperGroup.name="helperGroup",this.translationGroup.add(this.helperGroup),this.scene.fog=new Ma(this.parameters.fogColor.getHex()),this.spotLight=new qc(this.parameters.lightColor.getHex(),this.parameters.lightIntensity),this.scene.add(this.spotLight),this.ambientLight=new Jc(this.parameters.ambientColor.getHex(),this.parameters.ambientIntensity),this.scene.add(this.ambientLight)},yf.prototype._initRenderer=function(){var t=window.devicePixelRatio,e=this.width,i=this.height;try{this.renderer=new Sa({preserveDrawingBuffer:!0,alpha:!0,antialias:!0})}catch(t){return!(this.wrapper.innerHTML='<div style="display:flex;align-items:center;justify-content:center;height:100%;"><p style="padding:15px;text-align:center;">Your browser/graphics card does not seem to support <a target="_blank" href="https://en.wikipedia.org/wiki/WebGL">WebGL</a>.<br/><br/>Find out how to get it <a target="_blank" href="http://get.webgl.org/">here</a>.</p></div>')}this.renderer.setPixelRatio(t),this.renderer.setSize(e,i),this.renderer.autoClear=!1,this.renderer.sortObjects=!0;var r,n,o=this.renderer.getContext();r=this.renderer.extensions.get("EXT_frag_depth"),Xp=r,this.renderer.extensions.get("OES_element_index_uint"),n=this.renderer.extensions.get("OES_texture_float")&&this.renderer.extensions.get("WEBGL_color_buffer_float")||this.renderer.extensions.get("OES_texture_float")&&pf(o.FLOAT),Wp=n,this.wrapper.appendChild(this.renderer.domElement);var a=e*t,s=i*t;this.renderer.extensions.get("OES_texture_float"),this.supportsHalfFloat=this.renderer.extensions.get("OES_texture_half_float")&&pf(36193),this.renderer.extensions.get("WEBGL_color_buffer_float"),de.Debug&&console.log(JSON.stringify({Browser:Gp,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":pf(o.FLOAT),"testTextureSupport HalfFloat":pf(36193),"this.supportsHalfFloat":this.supportsHalfFloat,SupportsReadPixelsFloat:Wp},null,2)),this.pickingTarget=new Ai(a,s,{minFilter:Vt,magFilter:Vt,stencilBuffer:!1,format:ue,type:Wp?ee:Yt}),this.pickingTarget.texture.generateMipmaps=!1,this.renderer.clearTarget(this.pickingTarget,!0,!0,!0),this.renderer.setRenderTarget(null),this.sampleTarget=new Ai(a,s,{minFilter:Wt,magFilter:Wt,format:ue}),this.holdTarget=new Ai(a,s,{minFilter:Vt,magFilter:Vt,format:ue,type:Yt}),this.compositeUniforms={tForeground:new Wh(this.sampleTarget.texture),scale:new Wh(1)},this.compositeMaterial=new An({uniforms:this.compositeUniforms,vertexShader:Cd("Quad.vert"),fragmentShader:Cd("Quad.frag"),premultipliedAlpha:!0,transparent:!0,blending:Z,depthTest:!1,depthWrite:!1}),this.compositeCamera=new lr(-1,1,1,-1,0,1),this.compositeScene=new Ea,this.compositeScene.name="compositeScene",this.compositeScene.add(new Pn(new qr(2,2),this.compositeMaterial))},yf.prototype._initHelper=function(){var 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 $r;i.setIndex(new wr(t,1)),i.addAttribute("position",new wr(e,3));var r=new An({uniforms:{uColor:{value:new ki("skyblue")}},vertexShader:Cd("BasicLine.vert"),fragmentShader:Cd("BasicLine.frag")});this.boundingBoxMesh=new Na(i,r),this.helperGroup.add(this.boundingBoxMesh)},yf.prototype.updateHelper=function(){var t=this.boundingBoxMesh.geometry.attributes.position,e=t.array,i=this.boundingBox,r=i.min,n=i.max;e[0]=n.x,e[1]=n.y,e[2]=n.z,e[3]=r.x,e[4]=n.y,e[5]=n.z,e[6]=r.x,e[7]=r.y,e[8]=n.z,e[9]=n.x,e[10]=r.y,e[11]=n.z,e[12]=n.x,e[13]=n.y,e[14]=r.z,e[15]=r.x,e[16]=n.y,e[17]=r.z,e[18]=r.x,e[19]=r.y,e[20]=r.z,e[21]=n.x,e[22]=r.y,e[23]=r.z,t.needsUpdate=!0,this.boundingBox.isEmpty()||this.boundingBoxMesh.geometry.computeBoundingSphere()},yf.prototype.add=function(e,t){var i=this;t?t.forEach(function(t){return i.addBuffer(e,t)}):this.addBuffer(e),e.parameters.background?(this.backgroundGroup.add(e.group),this.backgroundGroup.add(e.wireframeGroup)):(this.modelGroup.add(e.group),this.modelGroup.add(e.wireframeGroup)),e.pickable&&this.pickingGroup.add(e.pickingGroup),de.Debug&&this.updateHelper()},yf.prototype.addBuffer=function(e,i){function r(t){t instanceof ya?t.children.forEach(r):(t.userData.buffer=e,t.userData.instance=i,t.onBeforeRender=vf)}var t=e.getMesh();i&&t.applyMatrix(i.matrix),r(t),e.group.add(t);var n=e.getWireframeMesh();if(i&&(n.matrix.copy(t.matrix),n.position.copy(t.position),n.quaternion.copy(t.quaternion),n.scale.copy(t.scale)),r(n),e.wireframeGroup.add(n),e.pickable){var o=e.getPickingMesh();i&&(o.matrix.copy(t.matrix),o.position.copy(t.position),o.quaternion.copy(t.quaternion),o.scale.copy(t.scale)),r(o),e.pickingGroup.add(o)}i?this._updateBoundingBox(e.geometry,e.matrix,i.matrix):this._updateBoundingBox(e.geometry,e.matrix)},yf.prototype.remove=function(e){this.translationGroup.children.forEach(function(t){t.remove(e.group),t.remove(e.wireframeGroup)}),e.pickable&&this.pickingGroup.remove(e.pickingGroup),this.updateBoundingBox(),de.Debug&&this.updateHelper()},yf.prototype._updateBoundingBox=function(t,e,i){var n=this.boundingBox;function r(t,e,i){t.boundingBox||t.computeBoundingBox();var r=t.boundingBox.clone();e&&r.applyMatrix4(e),i&&r.applyMatrix4(i),r.min.equals(r.max)&&r.expandByScalar(5),n.union(r)}function o(t){var e,i;void 0!==t.geometry&&(t.userData.buffer&&(e=t.userData.buffer.matrix),t.userData.instance&&(i=t.userData.instance.matrix),r(t.geometry,e,i))}t?r(t,e,i):(n.makeEmpty(),this.modelGroup.traverse(o),this.backgroundGroup.traverse(o)),n.getSize(this.boundingBoxSize),this.boundingBoxLength=this.boundingBoxSize.length()},yf.prototype.updateBoundingBox=function(){this._updateBoundingBox(),de.Debug&&this.updateHelper()},yf.prototype.getPickingPixels=function(){var t=this.width,e=this.height,i=t*e*4,r=Wp?new Float32Array(i):new Uint8Array(i);return this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,0,0,t,e,r),r},yf.prototype.getImage=function(l){var p=this;return new Promise(function(t){if(l){var e=p,i=e.width,r=e.height,n=i*r*4,o=p.getPickingPixels();if(Wp){for(var a=new Uint8Array(n),s=0;s<n;++s)a[s]=Math.round(255*o[s]);o=a}var c=document.createElement("canvas");c.width=i,c.height=r;var u=c.getContext("2d"),h=u.getImageData(0,0,i,r);h.data.set(o),u.putImageData(h,0,0),c.toBlob(t,"image/png")}else p.renderer.domElement.toBlob(t,"image/png")})},yf.prototype.makeImage=function(t){return void 0===t&&(t={}),tf(this,t)},yf.prototype.setLight=function(t,e,i,r){var n=this.parameters;void 0!==t&&n.lightColor.set(t),void 0!==e&&(n.lightIntensity=e),void 0!==i&&n.ambientColor.set(i),void 0!==r&&(n.ambientIntensity=r),this.requestRender()},yf.prototype.setFog=function(t,e,i,r,n){var o=this.parameters;void 0!==t&&o.fogColor.set(t),void 0!==e&&(o.fogNear=e),void 0!==i&&(o.fogFar=i),void 0!==r&&(o.fogMode=r),void 0!==n&&(o.fogScale=n),this.requestRender()},yf.prototype.setBackground=function(t){var e=this.parameters;t&&e.backgroundColor.set(t),this.setFog(e.backgroundColor),this.renderer.setClearColor(e.backgroundColor,0),this.renderer.domElement.style.backgroundColor=e.backgroundColor.getStyle(),this.requestRender()},yf.prototype.setSampling=function(t){void 0!==t&&(this.parameters.sampleLevel=t,this.sampleLevel=t),this.requestRender()},yf.prototype.setCamera=function(t,e,i){var r=this.parameters;if(t&&(r.cameraType=t),e&&(r.cameraFov=e),i&&(r.cameraEyeSep=i),"orthographic"===r.cameraType)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("perspective"!==r.cameraType&&"stereo"!==r.cameraType)throw new Error("Unknown cameraType '"+r.cameraType+"'");this.camera!==this.perspectiveCamera&&(this.camera=this.perspectiveCamera,this.camera.position.copy(this.orthographicCamera.position),this.camera.up.copy(this.orthographicCamera.up))}this.perspectiveCamera.fov=r.cameraFov,this.stereoCamera.eyeSep=r.cameraEyeSep,this.camera.updateProjectionMatrix(),this.requestRender()},yf.prototype.setClip=function(t,e,i,r,n){var o=this.parameters;void 0!==t&&(o.clipNear=t),void 0!==e&&(o.clipFar=e),void 0!==i&&(o.clipDist=i),void 0!==r&&(o.clipMode=r),void 0!==n&&(o.clipScale=n),this.requestRender()},yf.prototype.setSize=function(t,e){this.width=t||1,this.height=e||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 i=window.devicePixelRatio;this.renderer.setPixelRatio(i),this.renderer.setSize(t,e);var r=this.width*i,n=this.height*i;this.pickingTarget.setSize(r,n),this.sampleTarget.setSize(r,n),this.holdTarget.setSize(r,n),this.requestRender()},yf.prototype.handleResize=function(){if(this.container===document.body)this.setSize(window.innerWidth,window.innerHeight);else{var t=this.container.getBoundingClientRect();this.setSize(t.width,t.height)}},yf.prototype.updateInfo=function(t){var e=this.info,i=e.memory,r=e.render;if(t)i.programs=0,i.geometries=0,i.textures=0,r.calls=0,r.vertices=0,r.points=0;else{var n=this.renderer.info,o=n.memory,a=n.render;i.geometries=o.geometries,i.textures=o.textures,r.calls+=a.calls,r.faces+=a.triangles,r.points+=a.points}},yf.prototype.animate=function(){if(this.signals.ticked.dispatch(this.stats),500<window.performance.now()-this.stats.startTime&&!this.isStill&&this.sampleLevel<3&&-1!==this.sampleLevel){var t=this.sampleLevel;this.sampleLevel=3,this.renderPending=!0,this.render(),this.isStill=!0,this.sampleLevel=t,de.Debug&&Yp.log("rendered still frame")}window.requestAnimationFrame(this.animate)},yf.prototype.pick=function(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);var i,r,n=0,o=Wp?df:ff;this.render(!0),this.renderer.readRenderTargetPixels(this.pickingTarget,t,e,5,5,o);for(var a=0;a<mf.length;a++){var s=4*mf[a],c=Math.round(o[s+3]),u=this.pickingGroup.getObjectById(c);u&&(i=u.userData.instance,r=u.userData.buffer.picking,n=Wp?Math.round(255*o[s])<<16&16711680|Math.round(255*o[s+1])<<8&65280|255&Math.round(255*o[s+2]):o[s]<<16|o[s+1]<<8|o[s+2])}return{pid:n,instance:i,picker:r}},yf.prototype.requestRender=function(){var t=this;this.renderPending||(22<window.performance.now()-this.stats.startTime&&(this.stats.begin(),this.isStill=!1),this.renderPending=!0,window.requestAnimationFrame(function(){t.render(),t.stats.update()}))},yf.prototype.updateZoom=function(){var t=Gl(this.perspectiveCamera.fov),e=2*Math.tan(t/2)*-this.camera.position.z;this.orthographicCamera.zoom=this.height/e},yf.prototype.__updateClipping=function(){var t=this.parameters;if(this.cDist=this.distVector.copy(this.camera.position).length(),this.cDist||(this.camera.position.set(0,0,t.cameraZ),this.cDist=Math.abs(t.cameraZ)),"absolute"===t.clipScale&&"absolute"===t.fogScale||(this.bRadius=Math.max(10,.5*this.boundingBoxLength),this.bRadius+=this.boundingBox.getCenter(this.distVector).length(),(this.bRadius===1/0||this.bRadius===-1/0||isNaN(this.bRadius))&&(this.bRadius=50)),"camera"==t.clipMode)this.camera.near=t.clipNear,this.camera.far=t.clipFar;else if("absolute"==t.clipScale)this.camera.near=this.cDist-t.clipNear,this.camera.far=this.cDist+t.clipFar;else{var e=(50-t.clipNear)/50,i=-(50-t.clipFar)/50;this.camera.near=this.cDist-this.bRadius*e,this.camera.far=this.cDist+this.bRadius*i}var r=this.scene.fog;if(r.color.set(t.fogColor),"camera"==t.fogMode)r.near=t.fogNear,r.far=t.fogFar;else if("absolute"==t.fogScale)r.near=this.cDist+t.fogNear,r.far=this.cDist+t.fogFar;else{var n=(50-t.fogNear)/50,o=-(50-t.fogFar)/50;r.near=this.cDist-this.bRadius*n,r.far=this.cDist+this.bRadius*o}"PerspectiveCamera"===this.camera.type?(this.camera.near=Math.max(.1,t.clipDist,this.camera.near),this.camera.far=Math.max(1,this.camera.far),r.near=Math.max(.1,r.near),r.far=Math.max(1,r.far)):"OrthographicCamera"===this.camera.type&&0<t.clipDist&&(this.camera.near=Math.max(t.clipDist,this.camera.near))},yf.prototype.__updateCamera=function(){var t,e,i,o,a,r,n,s,c,u,h,l,v,p=this.camera;p.updateMatrix(),p.updateMatrixWorld(!0),p.updateProjectionMatrix(),t=this.scene,e=p,i=this.renderer,o=this.cDist,a=this.bRadius,r=i.getSize(),n=r.width,s=r.height,c=s,u=i.getPixelRatio(),h="OrthographicCamera"===e.type,of.set(n,s),af.getInverse(e.projectionMatrix),sf.copy(e.projectionMatrix).transpose(),t.traverse(function(t){var e=t.material;if(e){var i=e.uniforms;if(i){if(e.clipNear){var r=(50-e.clipNear)/50,n=o-a*r;i.clipNear.value=n}i.canvasHeight&&(i.canvasHeight.value=c),i.resolution&&i.resolution.value.copy(of),i.pixelRatio&&(i.pixelRatio.value=u),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(af),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(sf),i.ortho&&(i.ortho.value=h)}}}),l=this.scene,v=p,l.traverseVisible(function(t){if(t instanceof Ua&&t.userData.buffer.parameters.sortParticles){var e=t.geometry.attributes,i=e.position.count;if(0!==i){var r,n,o,a,s,c,u;rf.multiplyMatrices(v.matrixWorldInverse,t.matrixWorld),nf.multiplyMatrices(v.projectionMatrix,rf),t.userData.sortData?(r=t.userData.sortData,o=r.__zArray,n=r.__sortArray,a=r.__cmpFn):(o=new Float32Array(i),n=new Uint32Array(i),r={__zArray:o,__sortArray:n,__cmpFn:a=function(t,e){var i=o[t],r=o[e];return r<i?1:i<r?-1:0}},t.userData.sortData=r);for(var h=0;h<i;++h)ef.fromArray(e.position.array,3*h),ef.applyMatrix4(nf),o[h]=-ef.z,n[h]=h;for(var l in function(r,t,e,i){void 0===e&&(e=0),t=t||function(t,e){return e<t?1:t<e?-1:0};var n,o,a,s=[],c=-1,u=e,h=i=(i||r.length)-1;function l(t,e){var i=r[t];r[t]=r[e],r[e]=i}for(;;)if(h-u<=25){for(var p=u+1;p<=h;++p){for(n=r[p],o=p-1;u<=o&&0<t(r[o],n);)r[o+1]=r[o],--o;r[o+1]=n}if(-1===c)break;h=s[c--],u=s[c--]}else{for(l(u+(a=h)>>1,o=u+1),0<t(r[u],r[h])&&l(u,h),0<t(r[o],r[h])&&l(o,h),0<t(r[u],r[o])&&l(u,o),n=r[o];;){for(;t(r[++o],n)<0;);for(;0<t(r[--a],n););if(a<o)break;l(o,a)}r[u+1]=r[a],r[a]=n,a-u<=h-o+1?(s[++c]=o,s[++c]=h,h=a-1):(s[++c]=u,s[++c]=a-1,u=o)}}(n,a),e){var p=e[l],d=p.array,f=p.itemSize;r[l]||(r[l]=new Float32Array(f*i)),u=r[l],r[l]=d;for(var m=0;m<i;++m){s=n[m];for(var g=0;g<f;++g)c=s*f+g,u[m*f+g]=d[c]}e[l].array=u,e[l].needsUpdate=!0}}}})},yf.prototype.__setVisibility=function(t,e,i,r){this.modelGroup.visible=t,this.pickingGroup.visible=e,this.backgroundGroup.visible=i,this.helperGroup.visible=r},yf.prototype.__updateLights=function(){this.spotLight.color.set(this.parameters.lightColor),this.spotLight.intensity=this.parameters.lightIntensity,this.distVector.copy(this.camera.position).setLength(100*this.boundingBoxLength),this.spotLight.position.copy(this.camera.position).add(this.distVector),this.ambientLight.color.set(this.parameters.ambientColor),this.ambientLight.intensity=this.parameters.ambientIntensity},yf.prototype.__renderPickingGroup=function(t){this.renderer.clearTarget(this.pickingTarget,!0,!0,!0),this.__setVisibility(!1,!0,!1,!1),this.renderer.render(this.scene,t,this.pickingTarget),this.updateInfo(),this.renderer.setRenderTarget(null)},yf.prototype.__renderModelGroup=function(t,e){e?this.renderer.clearTarget(e,!0,!0,!0):this.renderer.clear(),this.__setVisibility(!1,!1,!0,!1),this.renderer.render(this.scene,t,e),e?this.renderer.clearTarget(e,!1,!0,!1):this.renderer.clearDepth(),this.updateInfo(),this.__setVisibility(!0,!1,!1,de.Debug),this.renderer.render(this.scene,t,e),this.updateInfo()},yf.prototype.__renderSuperSample=function(t){var e=kd[Math.max(0,Math.min(this.sampleLevel,5))],i=1/e.length;this.compositeUniforms.tForeground.value=this.sampleTarget.texture;var r=this.sampleTarget.width,n=this.sampleTarget.height;"stereo"===this.parameters.cameraType&&(r/=2);for(var o=0;o<e.length;++o){var a=e[o];t.setViewOffset(r,n,a[0],a[1],r,n),t.updateProjectionMatrix(),cf(this.scene,t);var s=i;s+=1/32*((o+.5)/e.length-.5),this.compositeUniforms.scale.value=s,this.__renderModelGroup(t,this.sampleTarget),this.renderer.render(this.compositeScene,this.compositeCamera,this.holdTarget,0===o)}this.compositeUniforms.scale.value=1,this.compositeUniforms.tForeground.value=this.holdTarget.texture,t.clearViewOffset(),this.renderer.render(this.compositeScene,this.compositeCamera,null,!0)},yf.prototype.__renderStereo=function(t){void 0===t&&(t=!1);var e=this.stereoCamera;e.update(this.perspectiveCamera);var i=this.renderer,r=i.getSize();i.setScissorTest(!0),i.setScissor(0,0,r.width/2,r.height),i.setViewport(0,0,r.width/2,r.height),cf(this.scene,e.cameraL),this.__render(t,e.cameraL),i.setScissor(r.width/2,0,r.width/2,r.height),i.setViewport(r.width/2,0,r.width/2,r.height),cf(this.scene,e.cameraR),this.__render(t,e.cameraR),i.setScissorTest(!1),i.setViewport(0,0,r.width,r.height)},yf.prototype.__render=function(t,e){void 0===t&&(t=!1),t?this.lastRenderedPicking||this.__renderPickingGroup(e):0<this.sampleLevel&&"stereo"!==this.parameters.cameraType?this.__renderSuperSample(e):this.__renderModelGroup(e)},yf.prototype.render=function(t){void 0===t&&(t=!1),this.rendering?Yp.warn("'tried to call 'render' from within 'render'"):(this.rendering=!0,this.__updateClipping(),this.__updateCamera(),this.__updateLights(),this.updateInfo(!0),"stereo"===this.parameters.cameraType?this.__renderStereo(t):this.__render(t,this.camera),this.lastRenderedPicking=t,this.rendering=!1,this.renderPending=!1,this.signals.rendered.dispatch())},yf.prototype.clear=function(){Yp.log("scene cleared"),this.scene.remove(this.rotationGroup),this._initScene(),this.renderer.clear()},yf.prototype.dispose=function(){this.renderer.dispose()};function bf(t){var 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)}var xf=function(t,e){void 0===e&&(e={}),this.domElement=t,this.signals={moved:new op,scrolled:new op,dragged:new op,dropped:new op,clicked:new op,hovered:new op,doubleClicked:new op},this.position=new ti,this.prevPosition=new ti,this.down=new ti,this.canvasPosition=new ti,this.prevClickCP=new ti,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=bl(e.hoverTimeout,50),this.handleScroll=bl(e.handleScroll,!0),this.doubleClickSpeed=bl(e.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 i={passive:!1};document.addEventListener("mousewheel",this._onMousewheel,i),document.addEventListener("wheel",this._onMousewheel,i),document.addEventListener("MozMousePixelScroll",this._onMousewheel,i),document.addEventListener("mousemove",this._onMousemove,i),document.addEventListener("mousedown",this._onMousedown,i),document.addEventListener("mouseup",this._onMouseup,i),document.addEventListener("contextmenu",this._onContextmenu,i),document.addEventListener("touchstart",this._onTouchstart,i),document.addEventListener("touchend",this._onTouchend,i),document.addEventListener("touchmove",this._onTouchmove,i)},_f={key:{configurable:!0}};_f.key.get=function(){var t=0;return this.altKey&&(t+=1),this.ctrlKey&&(t+=2),this.metaKey&&(t+=4),this.shiftKey&&(t+=8),t},xf.prototype.setParameters=function(t){void 0===t&&(t={}),this.hoverTimeout=bl(t.hoverTimeout,this.hoverTimeout)},xf.prototype._listen=function(){var 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))),window.requestAnimationFrame(this._listen)},xf.prototype._onMousewheel=function(t){var e=this;if(t.target===this.domElement&&this.handleScroll){t.preventDefault(),this._setKeys(t);var i=0;i=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail/3:-t.deltaY/(t.deltaMode?.33:30),this.signals.scrolled.dispatch(i),setTimeout(function(){e.scrolled=!0},this.hoverTimeout)}},xf.prototype._onMousemove=function(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);var 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)},xf.prototype._onMousedown=function(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){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(0<e)return 1<<e-1}else if("button"in t){var i=t.button;if(1===i)return 4;if(2===i)return 2;if(0<=i)return 1<<i}}return 0}(t),this.pressed=!0,this._setCanvasPosition(t))},xf.prototype._onMouseup=function(t){t.target===this.domElement&&t.preventDefault(),this._setKeys(t);var e=this.canvasPosition;this._distance()<4&&(this.lastClicked=window.performance.now(),this.doubleClickPending&&this.prevClickCP.distanceTo(e)<4&&(this.signals.doubleClicked.dispatch(e.x,e.y),this.doubleClickPending=!1),this.signals.clicked.dispatch(e.x,e.y),this.doubleClickPending=!0,this.prevClickCP.copy(e)),this.which=void 0,this.buttons=void 0,this.pressed=void 0},xf.prototype._onContextmenu=function(t){t.target===this.domElement&&t.preventDefault()},xf.prototype._onTouchstart=function(t){if(t.target===this.domElement)switch(t.preventDefault(),this.pressed=!0,t.touches.length){case 1:this.moving=!1,this.hovering=!1,this.down.set(t.touches[0].pageX,t.touches[0].pageY),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);break;case 2:this.down.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),this.lastTouchDistance=bf(t)}},xf.prototype._onTouchend=function(t){t.target===this.domElement&&t.preventDefault(),this.which=void 0,this.buttons=void 0,this.pressed=void 0},xf.prototype._onTouchmove=function(t){switch(t.target===this.domElement?(t.preventDefault(),this.overElement=!0):this.overElement=!1,t.touches.length){case 1:this._setKeys(t),this.which=1,this.buttons=1,this.moving=!0,this.hovering=!1,this.lastMoved=window.performance.now(),this.prevPosition.copy(this.position),this.position.set(t.touches[0].pageX,t.touches[0].pageY),this._setCanvasPosition(t.touches[0]);var 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);break;case 2:var r=bf(t),n=r-this.lastTouchDistance;if(this.lastTouchDistance=r,this.prevPosition.copy(this.position),this.position.set((t.touches[0].pageX+t.touches[1].pageX)/2,(t.touches[0].pageY+t.touches[1].pageY)/2),2<Math.abs(n)&&this.handleScroll&&this.position.distanceTo(this.prevPosition)<2)this.which=0,this.buttons=0,this.signals.scrolled.dispatch(n/2);else{this.which=3,this.buttons=2;var o=this.prevPosition.x-this.position.x,a=this.prevPosition.y-this.position.y;this.signals.moved.dispatch(o,a),this.pressed&&this.signals.dragged.dispatch(o,a)}}},xf.prototype._distance=function(){return this.position.distanceTo(this.down)},xf.prototype._setCanvasPosition=function(t){var e,i,r=this.domElement.getBoundingClientRect();"offsetX"in t&&"offsetY"in t?(e=t.offsetX,i=t.offsetY):(e=t.clientX-r.left,i=t.clientY-r.top),this.canvasPosition.set(e,r.height-i)},xf.prototype._setKeys=function(t){this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey},xf.prototype.dispose=function(){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(xf.prototype,_f);var wf=new ei,Sf=new ei,Af=new ei,Mf=new ei,Ef=new ri,Pf=new ii,Tf=new ei,Cf=new ri,If=new ri,Of=function(t,e){void 0===e&&(e={}),this.stage=t,this.rotateSpeed=bl(e.rotateSpeed,2),this.zoomSpeed=bl(e.zoomSpeed,1.2),this.panSpeed=bl(e.panSpeed,1),this.viewer=t.viewer,this.mouse=t.mouseObserver,this.controls=t.viewerControls},Lf={component:{configurable:!0},atom:{configurable:!0}};Lf.component.get=function(){return this.stage.transformComponent},Lf.atom.get=function(){return this.stage.transformAtom},Of.prototype._setPanVector=function(t,e,i){void 0===i&&(i=0);var r=this.controls.getCanvasScaleFactor(i);Cf.set(t,e,0),Cf.multiplyScalar(this.panSpeed*r)},Of.prototype._getRotateXY=function(t,e){return[this.rotateSpeed*-t*.01,this.rotateSpeed*e*.01]},Of.prototype._transformPanVector=function(){this.component&&(Tf.extractRotation(this.component.transform),Tf.premultiply(this.viewer.rotationGroup.matrix),Tf.getInverse(Tf),Cf.applyMatrix4(Tf))},Of.prototype.zoom=function(t){this.controls.zoom(this.zoomSpeed*t*.02)},Of.prototype.pan=function(t,e){this._setPanVector(t,e),Tf.getInverse(this.viewer.rotationGroup.matrix),Cf.applyMatrix4(Tf),this.controls.translate(Cf)},Of.prototype.panComponent=function(t,e){this.component&&(this._setPanVector(t,e),this._transformPanVector(),this.component.position.add(Cf),this.component.updateMatrix())},Of.prototype.panAtom=function(t,e){this.atom&&this.component&&(this.atom.positionToVector3(If),If.add(this.viewer.translationGroup.position),If.applyMatrix4(this.viewer.rotationGroup.matrix),this._setPanVector(t,e,If.z),this._transformPanVector(),this.atom.positionAdd(Cf),this.component.updateRepresentations({position:!0}))},Of.prototype.rotate=function(t,e){var i=this._getRotateXY(t,e),r=i[0],n=i[1];wf.makeRotationX(n),Sf.makeRotationY(r),wf.multiply(Sf),this.controls.applyMatrix(wf)},Of.prototype.zRotate=function(t,e){var i=this.rotateSpeed*((-t+e)/-2)*.01;Af.makeRotationZ(i),this.controls.applyMatrix(Af)},Of.prototype.rotateComponent=function(t,e){if(this.component){var i=this._getRotateXY(t,e),r=i[0],n=i[1];Mf.extractRotation(this.component.transform),Mf.premultiply(this.viewer.rotationGroup.matrix),Mf.getInverse(Mf),Ef.set(1,0,0),Ef.applyMatrix4(Mf),wf.makeRotationAxis(Ef,n),Ef.set(0,1,0),Ef.applyMatrix4(Mf),Sf.makeRotationAxis(Ef,r),wf.multiply(Sf),Pf.setFromRotationMatrix(wf),this.component.quaternion.premultiply(Pf),this.component.updateMatrix()}},Object.defineProperties(Of.prototype,Lf);var Rf=new ri;var Df=function(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},kf={type:{configurable:!0},altKey:{configurable:!0},ctrlKey:{configurable:!0},metaKey:{configurable:!0},shiftKey:{configurable:!0},canvasPosition:{configurable:!0},component:{configurable:!0},object:{configurable:!0},position:{configurable:!0},closestBondAtom:{configurable:!0},closeAtom:{configurable:!0},arrow:{configurable:!0},atom:{configurable:!0},axes:{configurable:!0},bond:{configurable:!0},box:{configurable:!0},cone:{configurable:!0},clash:{configurable:!0},contact:{configurable:!0},cylinder:{configurable:!0},distance:{configurable:!0},ellipsoid:{configurable:!0},octahedron:{configurable:!0},point:{configurable:!0},mesh:{configurable:!0},slice:{configurable:!0},sphere:{configurable:!0},tetrahedron:{configurable:!0},torus:{configurable:!0},surface:{configurable:!0},unitcell:{configurable:!0},unknown:{configurable:!0},volume:{configurable:!0},wideline:{configurable:!0}};kf.type.get=function(){return this.picker.type},kf.altKey.get=function(){return this.mouse.altKey},kf.ctrlKey.get=function(){return this.mouse.ctrlKey},kf.metaKey.get=function(){return this.mouse.metaKey},kf.shiftKey.get=function(){return this.mouse.shiftKey},kf.canvasPosition.get=function(){return this.mouse.canvasPosition},kf.component.get=function(){return this.stage.getComponentsByObject(this.picker.data).list[0]},kf.object.get=function(){return this.picker.getObject(this.pid)},kf.position.get=function(){return this.picker.getPosition(this.pid,this.instance,this.component)},kf.closestBondAtom.get=function(){if("bond"===this.type&&this.bond){var t,e,i,r=this.bond,n=this.controls,o=this.canvasPosition,a=n.getPositionOnCanvas(r.atom1),s=n.getPositionOnCanvas(r.atom2);return e=a,i=s,(t=o).distanceTo(e)<t.distanceTo(i)?r.atom1:r.atom2}},kf.closeAtom.get=function(){var t=this.canvasPosition,e=this.closestBondAtom;if(e){var i=this.controls.getPositionOnCanvas(e);e.positionToVector3(Rf),this.instance&&Rf.applyMatrix4(this.instance.matrix),Rf.applyMatrix4(this.component.matrix);var r=this.controls.viewer;Rf.add(r.translationGroup.position),Rf.applyMatrix4(r.rotationGroup.matrix);var n=this.controls.getCanvasScaleFactor(Rf.z),o=this.component.getMaxRepresentationRadius(e.index);return t.distanceTo(i)<=o/n?e:void 0}},kf.arrow.get=function(){return this._objectIfType("arrow")},kf.atom.get=function(){return this._objectIfType("atom")},kf.axes.get=function(){return this._objectIfType("axes")},kf.bond.get=function(){return this._objectIfType("bond")},kf.box.get=function(){return this._objectIfType("box")},kf.cone.get=function(){return this._objectIfType("cone")},kf.clash.get=function(){return this._objectIfType("clash")},kf.contact.get=function(){return this._objectIfType("contact")},kf.cylinder.get=function(){return this._objectIfType("cylinder")},kf.distance.get=function(){return this._objectIfType("distance")},kf.ellipsoid.get=function(){return this._objectIfType("ellipsoid")},kf.octahedron.get=function(){return this._objectIfType("octahedron")},kf.point.get=function(){return this._objectIfType("point")},kf.mesh.get=function(){return this._objectIfType("mesh")},kf.slice.get=function(){return this._objectIfType("slice")},kf.sphere.get=function(){return this._objectIfType("sphere")},kf.tetrahedron.get=function(){return this._objectIfType("tetrahedron")},kf.torus.get=function(){return this._objectIfType("torus")},kf.surface.get=function(){return this._objectIfType("surface")},kf.unitcell.get=function(){return this._objectIfType("unitcell")},kf.unknown.get=function(){return this._objectIfType("unknown")},kf.volume.get=function(){return this._objectIfType("volume")},kf.wideline.get=function(){return this._objectIfType("wideline")},Df.prototype._objectIfType=function(t){return this.type===t?this.object:void 0},Df.prototype.getLabel=function(){var t=this.atom||this.closeAtom,e="nothing";return this.arrow?e=this.arrow.name:t?e="atom: "+t.qualifiedName()+" ("+t.structure.name+")":this.axes?e="axes":this.bond?e="bond: "+this.bond.atom1.qualifiedName()+" - "+this.bond.atom2.qualifiedName()+" ("+this.bond.structure.name+")":this.box?e=this.box.name:this.cone?e=this.cone.name:this.clash?e="clash: "+this.clash.clash.sele1+" - "+this.clash.clash.sele2:this.contact?e=this.contact.type+": "+this.contact.atom1.qualifiedName()+" - "+this.contact.atom2.qualifiedName()+" ("+this.contact.atom1.structure.name+")":this.cylinder?e=this.cylinder.name:this.distance?e="distance: "+this.distance.atom1.qualifiedName()+" - "+this.distance.atom2.qualifiedName()+" ("+this.distance.structure.name+")":this.ellipsoid?e=this.ellipsoid.name:this.octahedron?e=this.octahedron.name:this.point?e=this.point.name:this.mesh?e="mesh: "+(this.mesh.name||this.mesh.serial)+" ("+this.mesh.shape.name+")":this.slice?e="slice: "+this.slice.value.toPrecision(3)+" ("+this.slice.volume.name+")":this.sphere?e=this.sphere.name:this.surface?e="surface: "+this.surface.surface.name:this.tetrahedron?e=this.tetrahedron.name:this.torus?e=this.torus.name:this.unitcell?e="unitcell: "+this.unitcell.unitcell.spacegroup+" ("+this.unitcell.structure.name+")":this.unknown?e="unknown":this.volume?e="volume: "+this.volume.value.toPrecision(3)+" ("+this.volume.volume.name+")":this.wideline&&(e=this.wideline.name),e},Object.defineProperties(Df.prototype,kf);var Bf=function(t){this.stage=t,this.viewer=t.viewer};Bf.prototype.pick=function(t,e){var i=this.viewer.pick(t,e);if(i.picker&&"ignore"!==i.picker.type&&void 0!==i.pid){var r=i.picker.array;if(!(r&&i.pid>=r.length))return new Df(i,this.stage);console.error("pid >= picker.array.length")}};var Nf=new ii,Ff=new ri,zf=new ri,Uf=new ri,jf=new ri,Gf=new ei,Vf=new ri,Hf=new ei,$f=function(t){this.stage=t,this.signals={changed:new op},this.viewer=t.viewer},Wf={position:{configurable:!0},rotation:{configurable:!0}};Wf.position.get=function(){return this.viewer.translationGroup.position},Wf.rotation.get=function(){return this.viewer.rotationGroup.quaternion},$f.prototype.changed=function(){this.viewer.requestRender(),this.signals.changed.dispatch()},$f.prototype.getPositionOnCanvas=function(t,e){var i=Dl(e,ti),r=this.viewer;return Uf.copy(t).add(r.translationGroup.position).applyMatrix4(r.rotationGroup.matrix).project(r.camera),i.set((Uf.x+1)*r.width/2,(Uf.y+1)*r.height/2)},$f.prototype.getCanvasScaleFactor=function(t){void 0===t&&(t=0);var e=this.viewer.camera;if(e instanceof lr)return 1/e.zoom;t=-t,t+=e.position.z;var i=Gl(e.fov);return-2*t*Math.tan(i/2)/this.viewer.height},$f.prototype.getOrientation=function(t){var e=Bl(t);e.copy(this.viewer.rotationGroup.matrix);var i=-this.viewer.camera.position.z;return e.scale(jf.set(i,i,i)),e.setPosition(this.viewer.translationGroup.position),e},$f.prototype.orient=function(t){Bl(t).decompose(Ff,Nf,zf);var e=this.viewer;e.rotationGroup.setRotationFromQuaternion(Nf),e.translationGroup.position.copy(Ff),e.camera.position.z=-zf.z,e.updateZoom(),this.changed()},$f.prototype.translate=function(t){this.viewer.translationGroup.position.add(kl(t)),this.changed()},$f.prototype.center=function(t){this.viewer.translationGroup.position.copy(kl(t)).negate(),this.changed()},$f.prototype.zoom=function(t){this.distance(this.viewer.camera.position.z*(1-t))},$f.prototype.distance=function(t){this.viewer.camera.position.z=Math.min(-1,t),this.viewer.updateZoom(),this.changed()},$f.prototype.spin=function(t,e){Gf.getInverse(this.viewer.rotationGroup.matrix),Vf.copy(kl(t)).applyMatrix4(Gf),this.viewer.rotationGroup.rotateOnAxis(Vf,e),this.changed()},$f.prototype.rotate=function(t){this.viewer.rotationGroup.setRotationFromQuaternion(Nl(t)),this.changed()},$f.prototype.align=function(t){Hf.getInverse(Bl(t)),this.viewer.rotationGroup.setRotationFromMatrix(Hf),this.changed()},$f.prototype.applyMatrix=function(t){this.viewer.rotationGroup.applyMatrix(Bl(t)),this.changed()},Object.defineProperties($f.prototype,Wf);var Xf=function(t,e){for(var i,r=[],n=arguments.length-2;0<n--;)r[n]=arguments[n+2];this.pausedTime=-1,this.elapsedDuration=0,this.pausedDuration=0,this.ignoreGlobalToggle=!1,this._paused=!1,this._resolveList=[],this.duration=bl(t,1e3),this.controls=e,this.startTime=window.performance.now(),(i=this)._init.apply(i,r)},qf={done:{configurable:!0},paused:{configurable:!0}};qf.done.get=function(){return 1===this.alpha},qf.paused.get=function(){return this._paused},Xf.prototype.tick=function(t){if(!this._paused)return this.elapsedDuration=t.currentTime-this.startTime-this.pausedDuration,0===this.duration?this.alpha=1:this.alpha=Zl(0,1,this.elapsedDuration/this.duration),this._tick(t),this.done&&this._resolveList.forEach(function(t){return t()}),this.done},Xf.prototype.pause=function(t){t&&(this._hold=!0),-1===this.pausedTime&&(this.pausedTime=window.performance.now()),this._paused=!0},Xf.prototype.resume=function(t){!t&&this._hold||(this.pausedDuration+=window.performance.now()-this.pausedTime,this._paused=!1,this._hold=!1,this.pausedTime=-1)},Xf.prototype.toggle=function(){this._paused?this.resume():this.pause()},Xf.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise(function(t){return e._resolveList.push(t)})).then(t)},Object.defineProperties(Xf.prototype,qf);var Yf=function(n){function t(t,e){for(var i=[],r=arguments.length-2;0<r--;)i[r]=arguments[r+2];n.apply(this,[bl(t,1/0),e].concat(i))}return n&&(t.__proto__=n),((t.prototype=Object.create(n&&n.prototype)).constructor=t).prototype._init=function(t,e){Array.isArray(t)?this.axis=(new ri).fromArray(t):this.axis=bl(t,new ri(0,1,0)),this.angle=bl(e,.01)},t.prototype._tick=function(t){this.axis&&this.angle&&this.controls.spin(this.axis,this.angle*t.lastDuration/16)},t}(Xf),Zf=function(n){function t(t,e){for(var i=[],r=arguments.length-2;0<r--;)i[r]=arguments[r+2];n.apply(this,[bl(t,1/0),e].concat(i)),this.angleSum=0,this.direction=1}return n&&(t.__proto__=n),((t.prototype=Object.create(n&&n.prototype)).constructor=t).prototype._init=function(t,e,i){Array.isArray(t)?this.axis=(new ri).fromArray(t):this.axis=bl(t,new ri(0,1,0)),this.angleStep=bl(e,.01),this.angleEnd=bl(i,.2)},t.prototype._tick=function(t){if(this.axis&&this.angleStep&&this.angleEnd){var e=Zl(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)}},t}(Xf),Kf=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._init=function(t,e){this.moveFrom=kl(bl(t,new ri)),this.moveTo=kl(bl(e,new ri))},e.prototype._tick=function(){this.controls.position.lerpVectors(this.moveFrom,this.moveTo,this.alpha).negate(),this.controls.changed()},e}(Xf),Jf=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._init=function(t,e){this.zoomFrom=t,this.zoomTo=e},e.prototype._tick=function(){this.controls.distance(ql(this.zoomFrom,this.zoomTo,this.alpha))},e}(Xf),Qf=function(t){function e(){t.apply(this,arguments),this._currentRotation=new ii}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._init=function(t,e){this.rotateFrom=Nl(t),this.rotateTo=Nl(e),this._currentRotation=new ii},e.prototype._tick=function(){this._currentRotation.copy(this.rotateFrom).slerp(this.rotateTo,this.alpha),this.controls.rotate(this._currentRotation)},e}(Xf),tm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._init=function(t,e,i){this.valueFrom=t,this.valueTo=e,this.callback=i},e.prototype._tick=function(){this.callback(ql(this.valueFrom,this.valueTo,this.alpha))},e}(Xf),em=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype._init=function(t){this.callback=t},e.prototype._tick=function(){1===this.alpha&&this.callback()},e}(Xf),im=function(t){void 0===t&&(t=[]),this._resolveList=[],this._list=t},rm={done:{configurable:!0}};rm.done.get=function(){return this._list.every(function(t){return t.done})},im.prototype.then=function(t){var e=this;return(this.done?Promise.resolve():new Promise(function(t){e._resolveList.push(t),e._list.forEach(function(t){t.then(function(){e._resolveList.forEach(function(t){t()}),e._resolveList.length=0})})})).then(t)},Object.defineProperties(im.prototype,rm);var nm=function(t){this.stage=t,this.animationList=[],this.finishedList=[],this.viewer=t.viewer,this.controls=t.viewerControls},om={paused:{configurable:!0}};om.paused.get=function(){return this.animationList.every(function(t){return t.paused})},nm.prototype.add=function(t){return 0===t.duration?t.tick(this.viewer.stats):this.animationList.push(t),t},nm.prototype.remove=function(t){var e=this.animationList,i=e.indexOf(t);-1<i&&e.splice(i,1)},nm.prototype.run=function(t){for(var e=this.finishedList,i=this.animationList,r=i.length,n=0;n<r;++n){var o=i[n];o.tick(t)&&e.push(o)}var a=e.length;if(a){for(var s=0;s<a;++s)this.remove(e[s]);e.length=0}},nm.prototype.spin=function(t,e,i){return this.add(new Yf(i,this.controls,t,e))},nm.prototype.rock=function(t,e,i,r){return this.add(new Zf(r,this.controls,t,e,i))},nm.prototype.rotate=function(t,e){var i=this.viewer.rotationGroup.quaternion.clone();return this.add(new Qf(e,this.controls,i,t))},nm.prototype.move=function(t,e){var i=this.controls.position.clone().negate();return this.add(new Kf(e,this.controls,i,t))},nm.prototype.zoom=function(t,e){var i=this.viewer.camera.position.z;return this.add(new Jf(e,this.controls,i,t))},nm.prototype.zoomMove=function(t,e,i){return new im([this.move(t,i),this.zoom(e,i)])},nm.prototype.orient=function(t,e){var i=new ri,r=new ii,n=new ri;return Bl(t).decompose(i,r,n),new im([this.move(i.negate(),e),this.rotate(r,e),this.zoom(-n.x,e)])},nm.prototype.value=function(t,e,i,r){return this.add(new tm(r,this.controls,t,e,i))},nm.prototype.timeout=function(t,e){return this.add(new em(e,this.controls,t))},nm.prototype.spinComponent=function(t,e,i,r){return this.add(new Yf(r,t.controls,e,i))},nm.prototype.rockComponent=function(t,e,i,r,n){return this.add(new Zf(n,t.controls,e,i,r))},nm.prototype.moveComponent=function(t,e,i){var r=t.controls.position.clone().negate();return this.add(new Kf(i,t.controls,r,e))},nm.prototype.pause=function(){this.animationList.forEach(function(t){return t.pause()})},nm.prototype.resume=function(){this.animationList.forEach(function(t){return t.resume()})},nm.prototype.toggle=function(){this.paused?this.resume():this.pause()},nm.prototype.clear=function(){this.animationList.length=0},nm.prototype.dispose=function(){this.clear()},Object.defineProperties(nm.prototype,om);var am=function(t,e){if(this.fn=t,this.queue=[],this.pending=!1,this.next=this.next.bind(this),e){for(var i=0,r=e.length;i<r;++i)this.queue.push(e[i]);this.next()}};am.prototype.run=function(t){this.fn(t,this.next)},am.prototype.next=function(){var t=this,e=this.queue.shift();void 0!==e?(this.pending=!0,setTimeout(function(){return t.run(e)})):this.pending=!1},am.prototype.push=function(t){this.queue.push(t),this.pending||this.next()},am.prototype.kill=function(){this.queue.length=0},am.prototype.length=function(){return this.queue.length};var sm=function(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},colorScheme:{type:"select",update:"color",options:{}},colorScale:{type:"select",update:"color",options:Qp.getScales()},colorReverse:{type:"boolean",update:"color"},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:Qp.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 Md,this.queue=new am(this.make.bind(this)),this.bufferList=[],this.parameters.colorScheme&&(this.parameters.colorScheme.options=Qp.getSchemes()),this.toBePrepared=!1};sm.prototype.init=function(t){var e=t||{};this.clipNear=bl(e.clipNear,0),this.clipRadius=bl(e.clipRadius,0),this.clipCenter=bl(e.clipCenter,new ri),this.flatShaded=bl(e.flatShaded,!1),this.side=bl(e.side,"double"),this.opacity=bl(e.opacity,1),this.depthWrite=bl(e.depthWrite,!0),this.wireframe=bl(e.wireframe,!1),this.setColor(e.color,e),this.colorScheme=bl(e.colorScheme,"uniform"),this.colorScale=bl(e.colorScale,""),this.colorReverse=bl(e.colorReverse,!1),this.colorValue=bl(e.colorValue,9474192),this.colorDomain=bl(e.colorDomain,void 0),this.colorMode=bl(e.colorMode,"hcl"),this.visible=bl(e.visible,!0),this.quality=bl(e.quality,void 0),this.roughness=bl(e.roughness,.4),this.metalness=bl(e.metalness,0),this.diffuse=bl(e.diffuse,16777215),this.diffuseInterior=bl(e.diffuseInterior,!1),this.useInteriorColor=bl(e.useInteriorColor,!1),this.interiorColor=bl(e.interiorColor,2236962),this.interiorDarkening=bl(e.interiorDarkening,0),this.lazy=bl(e.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}},this.matrix=bl(e.matrix,new ei),this.disablePicking=bl(e.disablePicking,!1);var i=this.parameters;!0===i.sphereDetail&&(i.sphereDetail={type:"integer",max:3,min:0,rebuild:"impostor"}),!0===i.radialSegments&&(i.radialSegments={type:"integer",max:25,min:5,rebuild:"impostor"}),!0===i.openEnded&&(i.openEnded={type:"boolean",rebuild:"impostor",buffer:!0}),!0===i.disableImpostor&&(i.disableImpostor={type:"boolean",rebuild:!0}),"low"===e.quality?(i.sphereDetail&&(this.sphereDetail=0),i.radialSegments&&(this.radialSegments=5)):"medium"===e.quality?(i.sphereDetail&&(this.sphereDetail=1),i.radialSegments&&(this.radialSegments=10)):"high"===e.quality?(i.sphereDetail&&(this.sphereDetail=2),i.radialSegments&&(this.radialSegments=20)):(i.sphereDetail&&(this.sphereDetail=bl(e.sphereDetail,1)),i.radialSegments&&(this.radialSegments=bl(e.radialSegments,10))),i.openEnded&&(this.openEnded=bl(e.openEnded,!0)),i.disableImpostor&&(this.disableImpostor=bl(e.disableImpostor,!1))},sm.prototype.getColorParams=function(t){return Object.assign({scheme:this.colorScheme,scale:this.colorScale,reverse:this.colorReverse,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode},t)},sm.prototype.getBufferParams=function(t){return void 0===t&&(t={}),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)},sm.prototype.setColor=function(t,e){var i=Object.keys(Qp.getSchemes());if("string"==typeof t&&i.includes(t.toLowerCase()))e?e.colorScheme=t:this.setParameters({colorScheme:t});else if(void 0!==t){var r=new ki(t).getHex();e?(e.colorScheme="uniform",e.colorValue=r):this.setParameters({colorScheme:"uniform",colorValue:r})}return this},sm.prototype.prepare=function(t){},sm.prototype.create=function(){},sm.prototype.update=function(t){this.build()},sm.prototype.build=function(t){if(!this.lazy||this.visible&&this.opacity){if(!this.toBePrepared)return this.tasks.increment(),void this.make();0<this.queue.length()?(this.tasks.change(1-this.queue.length()),this.queue.kill()):this.tasks.increment(),this.queue.push(t||!1)}else this.lazyProps.build=!0},sm.prototype.make=function(t,e){var i=this;de.Debug&&Yp.time("Representation.make "+this.type);var r=function(){t?(i.update(t),i.viewer.requestRender(),i.tasks.decrement(),e&&e()):(i.clear(),i.create(),i.manualAttach||i.disposed||(de.Debug&&Yp.time("Representation.attach "+i.type),i.attach(function(){de.Debug&&Yp.timeEnd("Representation.attach "+i.type),i.tasks.decrement(),e&&e()}))),de.Debug&&Yp.timeEnd("Representation.make "+i.type)};this.toBePrepared?this.prepare(r):r()},sm.prototype.attach=function(t){this.setVisibility(this.visible),t()},sm.prototype.setVisibility=function(e,t){if(this.visible=e,this.visible&&this.opacity){var i=this.lazyProps,r=i.bufferParams,n=i.what;if(i.build)return i.build=!1,this.build(),this;(Object.keys(r).length||Object.keys(n).length)&&(i.bufferParams={},i.what={},this.updateParameters(r,n))}return this.bufferList.forEach(function(t){t.setVisibility(e)}),t||this.viewer.requestRender(),this},sm.prototype.setParameters=function(t,e,i){var r=this;void 0===e&&(e={}),void 0===i&&(i=!1);var n=t||{},o=this.parameters,a={};for(var s in this.opacity||void 0===n.opacity||(this.lazyProps.build?i=!(this.lazyProps.build=!1):(Object.assign(a,this.lazyProps.bufferParams),Object.assign(e,this.lazyProps.what),this.lazyProps.bufferParams={},this.lazyProps.what={})),this.setColor(n.color,n),n)if(void 0!==n[s]&&void 0!==o[s]&&(o[s].int&&(n[s]=parseInt(n[s])),o[s].float&&(n[s]=parseFloat(n[s])),n[s]!==r[s]||n[s].equals&&!n[s].equals(r[s]))){if(r[s]&&r[s].copy&&n[s].copy?r[s].copy(n[s]):r[s]&&r[s].set?r[s].set(n[s]):r[s]=n[s],o[s].buffer)if(!0===o[s].buffer)a[s]=n[s];else a[o[s].buffer]=n[s];o[s].update&&(e[o[s].update]=!0),!o[s].rebuild||"impostor"===o[s].rebuild&&Xp&&!r.disableImpostor||(i=!0)}return i?this.build():this.updateParameters(a,e),this},sm.prototype.updateParameters=function(e,t){if(void 0===e&&(e={}),this.lazy&&(!this.visible||!this.opacity)&&!1===e.hasOwnProperty("opacity"))return Object.assign(this.lazyProps.bufferParams,e),void Object.assign(this.lazyProps.what,t);this.bufferList.forEach(function(t){t.setParameters(e)}),Object.keys(t).length&&this.update(t),this.viewer.requestRender()},sm.prototype.getParameters=function(){var e=this,i={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(function(t){null!==e.parameters[t]&&(i[t]=e[t])}),i},sm.prototype.clear=function(){var e=this;this.bufferList.forEach(function(t){e.viewer.remove(t),t.dispose()}),this.bufferList.length=0,this.viewer.requestRender()},sm.prototype.dispose=function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()};var cm=function(r){var n=this;this.pending=0,this.postCount=0,this.onmessageDict={},this.onerrorDict={},this.name=r,this.blobUrl=window.URL.createObjectURL(Jp.get(r)),this.worker=new Worker(this.blobUrl),Jp.activeWorkerCount+=1,this.worker.onmessage=function(t){n.pending-=1;var e=t.data.__postId;de.Debug&&Yp.timeEnd("Worker.postMessage "+r+" #"+e);var i=n.onmessageDict[e];i&&i.call(n.worker,t),delete n.onmessageDict[e],delete n.onerrorDict[e]},this.worker.onerror=function(t){if(n.pending-=1,t.data){var e=t.data.__postId,i=n.onerrorDict[e];i?i.call(n.worker,t):Yp.error("Worker.onerror",e,r,t),delete n.onmessageDict[e],delete n.onerrorDict[e]}else Yp.error("Worker.onerror",r,t)}};cm.prototype.post=function(e,t,i,r){void 0===e&&(e={}),this.onmessageDict[this.postCount]=i,this.onerrorDict[this.postCount]=r,e.__name=this.name,e.__postId=this.postCount,e.__debug=de.Debug,de.Debug&&Yp.time("Worker.postMessage "+this.name+" #"+this.postCount);try{this.worker.postMessage(e,t)}catch(t){Yp.error("worker.post:",t),this.worker.postMessage(e)}return this.pending+=1,this.postCount+=1,this},cm.prototype.terminate=function(){this.worker?(this.worker.terminate(),window.URL.revokeObjectURL(this.blobUrl),Jp.activeWorkerCount-=1):Yp.log("no worker to terminate")};var um=function(t,e){void 0===e&&(e=2),this.pool=[],this.count=0,this.maxCount=Math.min(8,e),this.name=t};function hm(t){for(var e=t.length,i=e/3,r=0,n=0,o=0,a=0;a<e;a+=3)r+=t[a+0],n+=t[a+1],o+=t[a+2];return new ri(r/i,n/i,o/i)}function lm(t,e,i){return i?t.sub(i).projectOnVector(e).add(i):t.projectOnVector(e),t}function pm(t){for(var e=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],h=t[s+1],l=t[s+2];u<e&&(e=u),h<i&&(i=h),l<r&&(r=l),n<u&&(n=u),o<h&&(o=h),a<l&&(a=l)}return[gm([e,i,r]),gm([n,o,a])]}function dm(t,e){for(var i=0,r=e.length;i<r;i+=3){var n=e[i],o=e[i+1],a=e[i+2];e[i]=t[0]*n+t[4]*o+t[8]*a+t[12],e[i+1]=t[1]*n+t[5]*o+t[9]*a+t[13],e[i+2]=t[2]*n+t[6]*o+t[10]*a+t[14]}}function fm(t,e){for(var i=0,r=e.length;i<r;i+=3){var n=e[i],o=e[i+1],a=e[i+2];e[i]=t[0]*n+t[3]*o+t[6]*a,e[i+1]=t[1]*n+t[4]*o+t[7]*a,e[i+2]=t[2]*n+t[5]*o+t[8]*a}}function mm(t){for(var e=0,i=t.length;e<i;e+=3){var r=t[e],n=t[e+1],o=t[e+2],a=1/Math.sqrt(r*r+n*n+o*o);t[e]=r*a,t[e+1]=n*a,t[e+2]=o*a}}function gm(t){return new Float32Array(t||3)}function vm(t,e,i){var r=e[0],n=e[1],o=e[2],a=i[0],s=i[1],c=i[2];t[0]=n*c-o*s,t[1]=o*a-r*c,t[2]=r*s-n*a}function ym(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function bm(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2]}function xm(t,e,i){t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2]}function _m(t,e,i){void 0===i&&(i=0),t[0]=e[i],t[1]=e[i+1],t[2]=e[i+2]}function wm(t,e,i){void 0===i&&(i=0),e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2]}function Sm(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])}function Am(t,e,i){Mm(t,e,1/i)}function Mm(t,e,i){t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i}function Em(t,e){Mm(t,e,1/Sm(e))}function Pm(t,e,i){t[0]=e[0]-i,t[1]=e[1]-i,t[2]=e[2]-i}function Tm(t,e,i){t[0]=e[0]+i,t[1]=e[1]+i,t[2]=e[2]+i}function Cm(t,e){t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2])}function Im(t,e){t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2])}function Om(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}function Lm(t,e){void 0===e&&(e=9);for(var i=Math.floor(e/2),r=t.position1.length/3,n=3*(i*r),o=1/e,a=jd(t.position1,t.position2),s=new Float32Array(n),c=new Float32Array(n),u=new ri,h=0;h<r;++h){var l=3*h;u.set(a[l],a[l+1],a[l+2]);for(var p=t.position1[l],d=t.position1[l+1],f=t.position1[l+2],m=0;m<i;++m){var g=i*l+3*m,v=o*(2*m+1),y=o*(2*m+2);s[g]=p+u.x*v,s[g+1]=d+u.y*v,s[g+2]=f+u.z*v,c[g]=p+u.x*y,c[g+1]=d+u.y*y,c[g+2]=f+u.z*y}}var b=Ud(s,c),x=function(t,e){for(var i=t.length/3,r=new Float32Array(i*e*3),n=0;n<i;++n)for(var o=3*n,a=n*e*3,s=t[o+0],c=t[o+1],u=t[o+2],h=0;h<e;++h){var l=a+3*h;r[l+0]=s,r[l+1]=c,r[l+2]=u}return r}(t.color,i),_={position:b,position1:s,position2:c,color:x,color2:x};return t.radius&&(_.radius=Wd(t.radius,i)),t.picking&&t.picking.array&&(t.picking.array=Wd(t.picking.array,i),_.picking=t.picking),t.primitiveId&&(_.primitiveId=Wd(t.primitiveId,i)),_}function Rm(t,e){void 0===e&&(e=.1);for(var i=jd(t.position1,t.position2),r=[],n=[],o=[],a=t.radius?[]:void 0,s=t.picking?[]:void 0,c=t.primitiveId?[]:void 0,u=new ri,h=t.position1.length/3,l=0,p=0;p<h;++p){var d=3*p;u.set(i[d],i[d+1],i[d+2]);for(var f=u.length()/e,m=Math.floor(f/2),g=1/f,v=t.position1[d],y=t.position1[d+1],b=t.position1[d+2],x=0;x<m;++x){var _=3*l+3*x,w=g*(2*x+1),S=g*(2*x+2);r[_]=v+u.x*w,r[_+1]=y+u.y*w,r[_+2]=b+u.z*w,n[_]=v+u.x*S,n[_+1]=y+u.y*S,n[_+2]=b+u.z*S,t.color&&(o[_]=t.color[d],o[_+1]=t.color[d+1],o[_+2]=t.color[d+2]),a&&(a[l+x]=t.radius[p]),s&&(t.picking.array?s[l+x]=t.picking.array[p]:s[l+x]=p),c&&(c[l+x]=t.primitiveId[p])}l+=m}var A=new Float32Array(r),M=new Float32Array(n),E=Ud(A,M),P=new Float32Array(o),T={position:E,position1:A,position2:M,color:P,color2:P};return a&&(T.radius=new Float32Array(a)),s&&t.picking&&(t.picking.array=new Float32Array(s),T.picking=t.picking),c&&(T.primitiveId=new Float32Array(c)),T}function Dm(t,e){void 0===e&&(e=.1);for(var i=jd(t.position1,t.position2),r=[],n=[],o=[],a=t.radius?[]:void 0,s=t.picking?[]:void 0,c=t.primitiveId?[]:void 0,u=new ri,h=t.position1.length/3,l=e,p=!0,d=0,f=0,m=0,g=0;g<h;++g){var v=3*g,y=t.position1[v],b=t.position1[v+1],x=t.position1[v+2];u.set(i[v],i[v+1],i[v+2]);var _=u.length();p&&(r[f]=y,r[f+1]=b,r[f+2]=x);for(var w=l,S=1/_;w<_;){var A=p?n:r;A[f]=y+u.x*w*S,A[f+1]=b+u.y*w*S,A[f+2]=x+u.z*w*S,p&&(f=3*++d),p=!p,w+=l=e}p&&(n[f]=t.position2[v],n[f+1]=t.position2[v+1],n[f+2]=t.position2[v+2],f=3*++d),l=w-_;for(var M=m;M<d;M++){if(t.color){var E=3*M;o[E]=t.color[v],o[E+1]=t.color[v+1],o[E+2]=t.color[v+2]}a&&(a[M]=t.radius[g]),s&&(t.picking.array?s[M]=t.picking.array[g]:s[M]=g),c&&(c[M]=t.primitiveId[g])}m=d}if(!p&&0<h){var P=3*d;n[P]=t.position2[3*h-3],n[P+1]=t.position2[3*h-2],n[P+1]=t.position2[3*h-1]}var T=new Float32Array(r),C=new Float32Array(n),I=Ud(T,C),O=new Float32Array(o),L={position:I,position1:T,position2:C,color:O,color2:O};return a&&(L.radius=new Float32Array(a)),s&&t.picking&&(t.picking.array=new Float32Array(s),L.picking=t.picking),c&&(L.primitiveId=new Float32Array(c)),L}um.prototype.post=function(t,e,i,r){void 0===t&&(t={});var n=this.getNextWorker();return n?n.post(t,e,i,r):console.error("unable to get worker from pool"),this},um.prototype.terminate=function(){this.pool.forEach(function(t){t.terminate()})},um.prototype.getNextWorker=function(){for(var t,e=1/0,i=0;i<this.maxCount;++i){if(i>=this.count){t=new cm(this.name),this.pool.push(t),this.count+=1;break}var r=this.pool[i];if(0===r.pending){t=r;break}r.pending<e&&(e=r.pending,t=r)}return t},um.prototype.constructor=um,pm.__deps=[gm],Am.__deps=[Mm],Em.__deps=[Mm,Sm];var km=new ri,Bm=function(){},Nm={Picker:{configurable:!0},Buffer:{configurable:!0}};Nm.Picker.get=function(){return sd.get(this.type)},Nm.Buffer.get=function(){return ad.get(this.type)},Bm.getShapeKey=function(t){return this.type+t[0].toUpperCase()+t.substr(1)},Bm.expandBoundingBox=function(t,e){},Bm.valueToShape=function(t,e,i){var r,n,o=t._primitiveData[this.getShapeKey(e)];switch(this.fields[e]){case"v3":case"c":n=o,void 0!==(r=i).toArray?r=r.toArray():void 0!==r.x?r=[r.x,r.y,r.z]:void 0!==r.r&&(r=[r.r,r.g,r.b]),n.push.apply(n,r);break;default:o.push(i)}},Bm.objectToShape=function(e,i){var r=this;Object.keys(this.fields).forEach(function(t){r.valueToShape(e,t,i[t])}),this.valueToShape(e,"name",i.name),this.expandBoundingBox(e.boundingBox,i)},Bm.valueFromShape=function(t,e,i){var r=t._primitiveData[this.getShapeKey(i)];switch(this.fields[i]){case"v3":return(new ri).fromArray(r,3*e);case"c":return(new ki).fromArray(r,3*e);default:return r[e]}},Bm.objectFromShape=function(e,i){var r=this,t=this.valueFromShape(e,i,"name");void 0===t&&(t=this.type+": "+i+" ("+e.name+")");var n={shape:e,name:t};return Object.keys(this.fields).forEach(function(t){n[t]=r.valueFromShape(e,i,t)}),n},Bm.arrayFromShape=function(t,e){var i=t._primitiveData[this.getShapeKey(e)];switch(this.fields[e]){case"s":return i;default:return new Float32Array(i)}},Bm.dataFromShape=function(e){var i=this,r={};return this.Picker&&(r.picking=new this.Picker(e)),Object.keys(this.fields).forEach(function(t){r[t]=i.arrayFromShape(e,t)}),r},Bm.bufferFromShape=function(t,e){return new this.Buffer(this.dataFromShape(t),e)},Object.defineProperties(Bm,Nm),Bm.type="",Bm.fields={};var Fm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).positionFromShape=function(t,e){return this.valueFromShape(t,e,"position")},e.expandBoundingBox=function(t,e){t.expandByPoint(km.fromArray(e.position))},e}(Bm);Fm.type="sphere",Fm.fields={position:"v3",color:"c",radius:"f"};var zm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).positionFromShape=function(t,e){return this.valueFromShape(t,e,"position")},e.expandBoundingBox=function(t,e){t.expandByPoint(km.fromArray(e.position))},e}(Bm);zm.type="box",zm.fields={position:"v3",color:"c",size:"f",heightAxis:"v3",depthAxis:"v3"};var Um=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(zm);Um.type="octahedron";var jm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(zm);jm.type="tetrahedron";var Gm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).positionFromShape=function(t,e){var i=this.valueFromShape(t,e,"position1"),r=this.valueFromShape(t,e,"position2");return i.add(r).multiplyScalar(.5)},e.expandBoundingBox=function(t,e){t.expandByPoint(km.fromArray(e.position1)),t.expandByPoint(km.fromArray(e.position2))},e.bufferFromShape=function(t,e){void 0===e&&(e={});var i=this.dataFromShape(t);return"cylinder"===this.type&&e.dashedCylinder&&(i=Rm(i)),new this.Buffer(i,e)},e}(Bm);Gm.type="cylinder",Gm.fields={position1:"v3",position2:"v3",color:"c",radius:"f"};var Vm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(Gm);Vm.type="arrow";var Hm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(Gm);Hm.type="cone";var $m=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(Fm);$m.type="ellipsoid",$m.fields={position:"v3",color:"c",radius:"f",majorAxis:"v3",minorAxis:"v3"};var Wm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}($m);Wm.type="torus";var Xm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).positionFromShape=function(t,e){return this.valueFromShape(t,e,"position")},e.expandBoundingBox=function(t,e){t.expandByPoint(km.fromArray(e.position))},e}(Bm);Xm.type="text",Xm.fields={position:"v3",color:"c",size:"f",text:"s"};var qm=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).positionFromShape=function(t,e){return this.valueFromShape(t,e,"position")},e.expandBoundingBox=function(t,e){t.expandByPoint(km.fromArray(e.position))},e}(Bm);qm.type="point",qm.fields={position:"v3",color:"c"};var Ym=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).positionFromShape=function(t,e){var i=this.valueFromShape(t,e,"position1"),r=this.valueFromShape(t,e,"position2");return i.add(r).multiplyScalar(.5)},e.expandBoundingBox=function(t,e){t.expandByPoint(km.fromArray(e.position1)),t.expandByPoint(km.fromArray(e.position2))},e}(Bm);Ym.type="wideline",Ym.fields={position1:"v3",position2:"v3",color:"c"};var Zm=function(t,e){this.exp=3;var i=e||function(t){for(var e=t.x,i=t.y,r=t.z,n=new Pi,o=e.length,a=n.min,s=n.max,c=0;c<o;c++)a.x=Math.min(e[c],a.x),a.y=Math.min(i[c],a.y),a.z=Math.min(r[c],a.z),s.x=Math.max(e[c],s.x),s.y=Math.max(i[c],s.y),s.z=Math.max(r[c],s.z);return n}(t);this.minX=i.min.x,this.minY=i.min.y,this.minZ=i.min.z,this.boundX=1+(i.max.x-this.minX>>this.exp),this.boundY=1+(i.max.y-this.minY>>this.exp),this.boundZ=1+(i.max.z-this.minZ>>this.exp);for(var r=this.boundX*this.boundY*this.boundZ,n=void 0!==t.count?t.count:t.x.length,o=t.x,a=t.y,s=t.z,c=0,u=new Uint32Array(r),h=new Int32Array(n),l=0;l<n;++l){var p=o[l]-this.minX>>this.exp,d=a[l]-this.minY>>this.exp,f=s[l]-this.minZ>>this.exp,m=(p*this.boundY+d)*this.boundZ+f;1===(u[m]+=1)&&(c+=1),h[l]=m}for(var g=new Uint16Array(c),v=0,y=0;v<r;++v){var b=u[v];0<b&&(u[v]=y+1,g[y]=b,y+=1)}for(var x=new Uint32Array(c),_=1;_<c;++_)x[_]+=x[_-1]+g[_-1];for(var w=new Uint16Array(c),S=new Int32Array(n),A=0;A<n;++A){var M=u[h[A]];if(0<M){var E=M-1;S[x[E]+w[E]]=A,w[E]+=1}}this.grid=u,this.bucketCount=g,this.bucketOffset=x,this.bucketArray=S,this.xArray=o,this.yArray=a,this.zArray=s};Zm.prototype.within=function(t,e,i,r){var n=[];return this.eachWithin(t,e,i,r,function(t){return n.push(t)}),n},Zm.prototype.eachWithin=function(t,e,i,r,n){for(var o=r*r,a=Math.max(0,t-r-this.minX>>this.exp),s=Math.max(0,e-r-this.minY>>this.exp),c=Math.max(0,i-r-this.minZ>>this.exp),u=Math.min(this.boundX,1+(t+r-this.minX>>this.exp)),h=Math.min(this.boundY,1+(e+r-this.minY>>this.exp)),l=Math.min(this.boundZ,1+(i+r-this.minZ>>this.exp)),p=a;p<u;++p)for(var d=s;d<h;++d)for(var f=c;f<l;++f){var m=(p*this.boundY+d)*this.boundZ+f,g=this.grid[m];if(0<g)for(var v=g-1,y=this.bucketOffset[v],b=y+this.bucketCount[v],x=y;x<b;++x){var _=this.bucketArray[x],w=this.xArray[_]-t,S=this.yArray[_]-e,A=this.zArray[_]-i,M=w*w+S*S+A*A;M<=o&&n(_,M)}}};var Km=function(t){void 0===t&&(t=0),this._fields=this._defaultFields,this._init(0)};Km.prototype._init=function(t){this.length=t;for(var e=this.count=0,i=this._fields.length;e<i;++e){var r=this._fields[e],n=r[0],o=r[1],a=r[2];this._initField(n,o,a)}},Km.prototype._initField=function(t,e,i){this[t]=Ol(i,this.length*e)},Km.prototype.addField=function(t,e,i){this._fields.push([t,e,i]),this._initField(t,e,i)},Km.prototype.resize=function(t){this.length=Math.round(t||0),this.count=Math.min(this.count,this.length);for(var e=0,i=this._fields.length;e<i;++e){var r=this._fields[e][0],n=this._fields[e][1],o=this.length*n,a=new this[r].constructor(o);this[r].length>o?a.set(this[r].subarray(0,o)):a.set(this[r]),this[r]=a}},Km.prototype.growIfFull=function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},Km.prototype.copyFrom=function(t,e,i,r){for(var n=0,o=this._fields.length;n<o;++n)for(var a=this._fields[n][0],s=this._fields[n][1],c=this[a],u=t[a],h=0;h<r;++h)for(var l=s*(e+h),p=s*(i+h),d=0;d<s;++d)c[l+d]=u[p+d]},Km.prototype.copyWithin=function(t,e,i){for(var r=0,n=this._fields.length;r<n;++r)for(var o=this._fields[r][0],a=this._fields[r][1],s=this[o],c=0;c<i;++c)for(var u=a*(t+c),h=a*(e+c),l=0;l<a;++l)s[u+l]=s[h+l]},Km.prototype.sort=function(c){Yp.time("Store.sort");var u=this,h=new this.constructor(1);!function t(e,i){if(e<i){var r=Math.floor((e+i)/2),n=e,o=i;do{for(;c(n,r)<0;)n+=1;for(;0<c(o,r);)o-=1;n<=o&&(n===r?r=o:o===r&&(r=n),(a=n)!==(s=o)&&(h.copyFrom(u,0,a,1),u.copyWithin(a,s,1),u.copyFrom(h,s,0,1)),n+=1,o-=1)}while(n<=o);t(e,o),t(n,i)}var a,s}(0,this.count-1),Yp.timeEnd("Store.sort")},Km.prototype.clear=function(){this.count=0},Km.prototype.dispose=function(){delete this.length,delete this.count;for(var t=0,e=this._fields.length;t<e;++t){delete this[this._fields[t][0]]}};var Jm=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={_defaultFields:{configurable:!0}};return i._defaultFields.get=function(){return[["index1",1,"int32"],["index2",1,"int32"],["type",1,"int8"]]},e.prototype.addContact=function(t,e,i){this.growIfFull();var r=this.count;t<e?(this.index1[r]=t,this.index2[r]=e):(this.index2[r]=t,this.index1[r]=e),i&&(this.type[r]=i),this.count+=1},Object.defineProperties(e.prototype,i),e}(Km);function Qm(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}var tg=function(t,e){this.length=t,this._words=new Uint32Array(t+32>>>5),!0===e&&this.setAll()};function eg(t){for(var e=t.edgeCount,i=t.nodeCount,r=t.nodeArray1,n=t.nodeArray2,o=new Uint8Array(i),a=new Int32Array(i),s=0;s<e;++s)o[r[s]]+=1,o[n[s]]+=1;for(var c=1;c<i;++c)a[c]+=a[c-1]+o[c-1];for(var u=2*e,h=new Int32Array(u),l=0;l<u;++l)h[l]=-1;for(var p=0;p<e;++p){for(var d=r[p],f=n[p],m=a[d];-1!==h[m]&&m<u;)m+=1;h[m]=p;for(var g=a[f];-1!==h[g]&&g<u;)g+=1;h[g]=p}return{countArray:o,offsetArray:a,indexArray:h}}function ig(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),{type:t,group:e,x:0,y:0,z:0,atomSet:[]}}function rg(t,e){t.x+=e.x,t.y+=e.y,t.z+=e.z,t.atomSet.push(e.index)}function ng(t,e){var i=e.atomSet.length;if(0<i){var r=t.types,n=t.groups,o=t.centers,a=t.atomSets;r.push(e.type),n.push(e.group),o.x.push(e.x/i),o.y.push(e.y/i),o.z.push(e.z/i),a.push(e.atomSet)}}tg.prototype.get=function(t){return 0!=(this._words[t>>>5]&1<<t)},tg.prototype.set=function(t){this._words[t>>>5]|=1<<t},tg.prototype.clear=function(t){this._words[t>>>5]&=~(1<<t)},tg.prototype.flip=function(t){this._words[t>>>5]^=1<<t},tg.prototype._assignRange=function(t,e,i){if(!(e<t)){for(var r=this._words,n=!0===i?4294967295:0,o=t>>>5,a=e>>>5,s=o;s<a;++s)r[s]=n;var c=o<<5,u=a<<5;if(!0===i)if(e-t<32)for(var h=t,l=e+1;h<l;++h)r[h>>>5]|=1<<h;else{for(var p=t,d=c;p<d;++p)r[p>>>5]|=1<<p;for(var f=u,m=e+1;f<m;++f)r[f>>>5]|=1<<f}else if(e-t<32)for(var g=t,v=e+1;g<v;++g)r[g>>>5]&=~(1<<g);else{for(var y=t,b=c;y<b;++y)r[y>>>5]&=~(1<<y);for(var x=u,_=e+1;x<_;++x)r[x>>>5]&=~(1<<x)}return this}},tg.prototype.setRange=function(t,e){return this._assignRange(t,e,!0)},tg.prototype.clearRange=function(t,e){return this._assignRange(t,e,!1)},tg.prototype.setBits=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=this._words,r=t.length,n=0;n<r;++n){var o=t[n];i[o>>>5]|=1<<o}return this},tg.prototype.clearBits=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=this._words,r=t.length,n=0;n<r;++n){var o=t[n];i[o>>>5]&=~(1<<o)}return this},tg.prototype.setAll=function(){return this._assignRange(0,this.length-1,!0)},tg.prototype.clearAll=function(){return this._assignRange(0,this.length-1,!1)},tg.prototype.flipAll=function(){for(var t=this._words.length,e=this._words,i=32-this.length%32,r=0;r<t-1;++r)e[r]=~e[r];return e[t-1]=~(e[t-1]<<i)>>>i,this},tg.prototype._isRangeValue=function(t,e,i){if(!(e<t)){for(var r=this._words,n=!0===i?4294967295:0,o=t>>>5,a=e>>>5,s=o;s<a;++s)if(r[s]!==n)return!1;if(e-t<32){for(var c=t,u=e+1;c<u;++c)if(!!(r[c>>>5]&1<<c)!==i)return!1}else{for(var h=a<<5,l=t,p=o<<5<<5;l<p;++l)if(!!(r[l>>>5]&1<<l)!==i)return!1;for(var d=h,f=e+1;d<f;++d)if(!!(r[d>>>5]&1<<d)!==i)return!1}return!0}},tg.prototype.isRangeSet=function(t,e){return this._isRangeValue(t,e,!0)},tg.prototype.isRangeClear=function(t,e){return this._isRangeValue(t,e,!1)},tg.prototype.isAllSet=function(){return this._isRangeValue(0,this.length-1,!0)},tg.prototype.isAllClear=function(){return this._isRangeValue(0,this.length-1,!1)},tg.prototype.isSet=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=this._words,r=t.length,n=0;n<r;++n){var o=t[n];if(0==(i[o>>>5]&1<<o))return!1}return!0},tg.prototype.isClear=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=this._words,r=t.length,n=0;n<r;++n){var o=t[n];if(0!=(i[o>>>5]&1<<o))return!1}return!0},tg.prototype.isEqualTo=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)if(e[n]!==i[n])return!1;return!0},tg.prototype.getSize=function(){for(var t=this._words.length,e=this._words,i=0,r=0;r<t;++r)i+=Qm(e[r]);return i},tg.prototype.difference=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]=e[n]&~i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},tg.prototype.union=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]|=i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},tg.prototype.intersection=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)e[n]&=i[n];for(var o=e.length;o<r;++o)e[o]=0;return this},tg.prototype.intersects=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0;n<r;++n)if(0!=(e[n]&i[n]))return!0;return!1},tg.prototype.getIntersectionSize=function(t){for(var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=0,o=0;o<r;++o)n+=Qm(e[o]&i[o]);return n},tg.prototype.makeIntersection=function(t){var e=this._words,i=t._words,r=Math.min(e.length,i.length),n=new Uint32Array(r),o=Object.create(tg.prototype);o._words=n,o.length=Math.min(this.length,t.length);for(var a=0;a<r;++a)n[a]=e[a]&i[a];return o},tg.prototype.forEach=function(t){for(var e=this._words.length,i=this._words,r=0,n=0;n<e;++n)for(var o=i[n];0!==o;){var a=o&-o;t((n<<5)+Qm(a-1),r),o^=a,++r}},tg.prototype.toArray=function(){for(var t=this._words,e=new Array(this.getSize()),i=this._words.length,r=0,n=0;n<i;++n)for(var o=t[n];0!==o;){var a=o&-o;e[r++]=(n<<5)+Qm(a-1),o^=a}return e},tg.prototype.toString=function(){return"{"+this.toArray().join(",")+"}"},tg.prototype.toSeleString=function(){var t=this.toArray().join(",");return t?"@"+t:"NONE"},tg.prototype.clone=function(){var t=Object.create(tg.prototype);return t.length=this.length,t._words=new Uint32Array(this._words),t};var og=0,ag=["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"],sg=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],cg=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],ug=["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"],hg=["NON-POLYMER"].concat(["OTHER"],ug),lg=["h","g","i"],pg=["e","b"],dg=["s","t","l",""],fg={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},mg={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},gg={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},vg={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]},yg={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},bg={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]},xg=[0,0,0],_g={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"},wg=Object.keys(_g),Sg=["A","C","T","G","U","I"],Ag=["DA","DC","DT","DG","DU","DI"],Mg=["A","G","I","DA","DG","DI"],Eg=Sg.concat(Ag),Pg=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4","SPC"],Tg=["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"],Cg=["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"],Ig=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","H","H1","H2","H3","HA","HN","BB"],Og=["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*"],Lg={};function Rg(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}}Lg[1]={trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT"],backboneStart:"N",backboneEnd:"C"},Lg[2]={trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},Lg[3]={trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},Lg[4]={trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},Lg[5]={trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},Lg[6]={trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]},Lg[og]={};var Dg=new Map([[2,Gl(180)],[3,Gl(120)],[4,Gl(109.4721)],[6,Gl(90)]]);function kg(e,t){var i=[],r=new ri,n=new ri;return r.subVectors(t,e),e.eachBondedAtom(function(t){1!==t.number&&(n.subVectors(t,e),i.push(r.angleTo(n)))}),i}function Bg(e,t){var i=e.clone(),r=new ri;r.subVectors(t,e);var n=[new ri,new ri],o=0;if(e.eachBondedAtom(function(t){1<o||1!==t.number&&(i.index=t.index,n[o++].subVectors(t,e))}),1===o&&i.eachBondedAtom(function(t){1<o||1!==t.number&&t.index!==e.index&&n[o++].subVectors(t,e)}),2===o){var a=n[0].cross(n[1]);return Math.abs(Math.PI/2-a.angleTo(r))}}function Ng(t,s){var e=t.structure,i=e.atomCount,c=new Int8Array(i),u=new Int8Array(i),h=new Int8Array(i),l=new Int8Array(i);return e.eachAtom(function(t){var e=t.index,i=function(r,t){var e,i=r.bondToElementCount(1),n=r.formalCharge||0,o="always"===t.assignCharge||"auto"===t.assignCharge&&0===n,a="always"===t.assignH||"auto"===t.assignH&&0===i,s=r.bondCount,c=(e=0,r.eachBond(function(t){return e+=t.bondOrder}),e),u=function(e){var r=e.structure.getBondProxy(),t=e.number,n=8===t||7===t;if(n&&4===e.bondCount)return!1;var o=!1;return e.eachBond(function(t){if(1<t.bondOrder)o=!0;else if(n){var i=t.getOtherAtom(e);i.eachBond(function(t){if(1<t.bondOrder){var e=i.number;if((15===e||16===e)&&8===t.getOtherAtom(i).number)return;o=!0}},r)}}),o}(r),h=0<c-s,l=0,p=8;switch(r.number){case 1:o&&(0===s?(n=1,p=0):1===s&&(n=0,p=1));break;case 6:o&&(n=0),a&&(l=Math.max(0,4-c-Math.abs(n))),p=Rg(s+l+Math.max(0,-n));break;case 7:if(o)if(a)if(u&&c<4)n=s-i==1&&c-i==2?1:0;else{var d=!1;r.eachBondedAtom(function(t){(16===t.number||t.isMetal())&&(d=!0)}),n=d?0:1}else n=c-3;a&&(l=Math.max(0,3-c+n)),p=Rg(u&&!h?s+l-n:s+l+1-n);break;case 8:o&&(a||(n=c-2),1===c&&r.eachBondedAtom(function(i){i.eachBond(function(t){var e=t.getOtherAtom(i);e.index!==r.index&&8===e.number&&2===t.bondOrder&&(n=-1)})})),a&&(l=Math.max(0,2-c+n)),p=Rg(u&&!h?s+l-n+1:s+l-n+2);break;case 16:o&&(a||(n=c<=3&&!r.bondToElementCount(8)?c-2:0)),a&&c<2&&(l=Math.max(0,2-c+n)),c<=3&&(p=Rg(s+l-n+2));break;case 9:case 17:case 35:case 53:case 85:o&&(n=c-1);break;case 3:case 11:case 19:case 37:case 55:case 87:o&&(n=1-c);break;case 4:case 12:case 20:case 38:case 56:case 88:o&&(n=2-c);break;default:console.warn("Requested charge, protonation for an unhandled element",r.element)}return[n,l,l+i,p]}(t,s),r=i[0],n=i[1],o=i[2],a=i[3];c[e]=r,u[e]=n,h[e]=o,l[e]=a}),{charge:c,implicitH:u,totalH:h,idealGeometry:l}}function Fg(t){if(t["@valenceModel"])return t["@valenceModel"];var e=Ng(t,{assignCharge:"auto",assignH:"auto"});return t["@valenceModel"]=e}function zg(t){return 15===t.number&&t.bondToElementCount(8)===t.bondCount}var Ug=["ARG","HIS","LYS"],jg=["GLU","ASP"];function Gg(t,e,i){void 0===i&&(i={});for(var f=bl(i.maxIonicDist,Kg.maxIonicDist),r=bl(i.maxPiStackingDist,Kg.maxPiStackingDist),m=bl(i.maxPiStackingOffset,Kg.maxPiStackingOffset),g=bl(i.maxPiStackingAngle,Kg.maxPiStackingAngle),n=bl(i.maxCationPiDist,Kg.maxCationPiDist),v=bl(i.maxCationPiOffset,Kg.maxCationPiOffset),y=bl(i.masterModelIndex,Kg.masterModelIndex),o=Math.max(f+2,r,n),b=r*r,x=n*n,a=e.features,s=e.spatialHash,c=e.contactStore,u=e.featureSet,_=a.types,h=a.centers,w=a.atomSets,l=h.x,p=h.y,S=h.z,d=_.length,A=t.atomStore.x,M=t.atomStore.y,E=t.atomStore.z,P=t.getAtomProxy(),T=t.getAtomProxy(),C=new ri,I=new ri,O=new ri,L=new ri,R=new ri,D=new ri,k=new ri,B=function(t,e){C.set(A[t[0]],M[t[0]],E[t[0]]),I.set(A[t[1]],M[t[1]],E[t[1]]),O.set(A[t[2]],M[t[2]],E[t[2]]),L.subVectors(C,I),R.subVectors(C,O),e.crossVectors(L,R)},N=function(t,e,i){return C.set(l[t],p[t],S[t]),I.set(l[e],p[e],S[e]),C.sub(I).projectOnPlane(i).add(I).distanceTo(I)},F=function(t,e,i){u.setBits(t,e),c.addContact(t,e,i)},z=function(d){s.eachWithin(l[d],p[d],S[d],o,function(t,e){if(!(t<=d||(P.index=w[d][0],T.index=w[t][0],Qg(P,T,y)))){var i,r,n,o,a,s=_[d],c=_[t];if(a=c,2===(o=s)&&1===a||1===o&&2===a)(function(t,e,i){for(var r=t.length,n=e.length,o=0;o<r;++o){P.index=t[o];for(var a=0;a<n;++a)if(T.index=e[a],P.distanceTo(T)<=i)return!0}return!1})(w[d],w[t],f)&&F(d,t,1);else if(n=c,3===s&&3===n){if(e<=b){B(w[d],D),B(w[t],k);var u=57.29578*D.angleTo(k);Math.min(N(d,t,k),N(t,d,D))<=m&&(u<=g||180-g<=u?F(d,t,3):u<=g+90&&90-g<=u&&F(d,t,3))}}else if(r=c,(3===(i=s)&&1===r||1===i&&3===r)&&e<=x){var h=3===s?[d,t]:[t,d],l=h[0],p=h[1];B(w[l],D),N(p,l,D)<=v&&F(l,p,2)}}})},U=0;U<d;++U)z(U)}function Vg(t){return"HIS"===t.resname&&7==t.number&&t.isRing()}var Hg=[3,11,19,37,55,12,20,38,56,13,31,49,81,21,50,82,83,51,80];var $g=[17,35,53,85];var Wg=[7,8,16],Xg=[6,7,15,16];var qg=Gl(180),Yg=Gl(120);function Zg(t,e,i){return!Jg(t,e,i)&&(t.modelIndex!==e.modelIndex||t.altloc&&e.altloc&&t.altloc!==e.altloc)}var Kg={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 Jg(t,e,i){return t.modelIndex===i&&e.modelIndex!==i||e.modelIndex===i&&t.modelIndex!==i}function Qg(t,e,i){return!Jg(t,e,i)&&(t.modelIndex!==e.modelIndex||t.residueIndex===e.residueIndex||t.altloc&&e.altloc&&t.altloc!==e.altloc)}function tv(t){var e,s,i,c,r,u,n,h,o,a,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,P,T,C={types:[],groups:[],centers:{x:[],y:[],z:[]},atomSets:[]};return de.Debug&&Yp.time("calculateFeatures"),s=C,i=Fg((e=t).data).charge,c={},e.eachResidue(function(t){if(Ug.includes(t.resname)){var e=ig(1);t.eachAtom(function(t){7===t.number&&t.isSidechain()&&rg(e,t)}),ng(s,e)}else wg.includes(t.resname)||t.isNucleic()||(t.eachAtom(function(t){var e,i,r,n,o=!1,a=ig(1);n=0,6===(r=t).number&&3===r.bondCount&&3===r.bondToElementCount(7)&&r.eachBondedAtom(function(t){t.bondCount-t.bondToElementCount(1)==1&&++n}),2===n?(a.group=8,o=!0):(i=0,6===(e=t).number&&3===e.bondCount&&2===e.bondToElementCount(7)&&1===e.bondToElementCount(6)&&e.eachBondedAtom(function(t){t.bondCount-t.bondToElementCount(1)==1&&++i}),2===i&&(a.group=9,o=!0)),o&&(t.eachBondedAtom(function(t){7===t.number&&(c[t.index]=!0,rg(a,t))}),ng(s,a))}),t.eachAtom(function(t){var e=ig(1);0<i[t.index]&&(c[t.index]||(rg(e,t),ng(s,e)))}))}),u=C,n=Fg((r=t).data).charge,h={},r.eachResidue(function(t){if(jg.includes(t.resname)){var e=ig(2);t.eachAtom(function(t){8===t.number&&t.isSidechain()&&rg(e,t)}),ng(u,e)}else if(Eg.includes(t.resname)){var i=ig(2);t.eachAtom(function(t){zg(t)&&(i.group=6,t.eachBondedAtom(function(t){8===t.number&&rg(i,t)}),ng(u,i))})}else wg.includes(t.resname)||Eg.includes(t.resname)||(t.eachAtom(function(t){var e,i,r,n,o=!1,a=ig(2);16===(n=t).number&&3===n.bondToElementCount(8)?(a.group=4,o=!0):zg(t)?(a.group=6,o=!0):16===(r=t).number&&4===r.bondToElementCount(8)?(a.group=5,o=!0):(i=0,6===(e=t).number&&2===e.bondToElementCount(8)&&1===e.bondToElementCount(6)&&e.eachBondedAtom(function(t){8===t.number&&t.bondCount-t.bondToElementCount(1)==1&&++i}),2===i&&(a.group=10,o=!0)),o&&(t.eachBondedAtom(function(t){8===t.number&&(h[t.index]=!0,rg(a,t))}),ng(u,a))}),t.eachAtom(function(t){var e=ig(2);n[t.index]<0&&(h[t.index]||(rg(e,t),ng(u,e)))}))}),a=C,l=(o=t).getAtomProxy(),o.eachResidue(function(t){var e=t.getAromaticRings();if(e){var i=t.atomOffset;e.forEach(function(t){var e=ig(3);t.forEach(function(t){l.index=t+i,rg(e,l)}),ng(a,e)})}}),d=C,f=Fg((p=t).data),m=f.charge,g=f.implicitH,v=f.idealGeometry,p.eachAtom(function(t){var e=ig(5),i=t.number;if(8===i)rg(e,t),ng(d,e);else if(7===i){if(Vg(t))rg(e,t),ng(d,e);else if(m[t.index]<1){var r=t.bondCount+g[t.index],n=v[t.index];(4===n&&r<4||3===n&&r<3||2===n&&r<2)&&(rg(e,t),ng(d,e))}}else 16===i&&("CYS"!==t.resname&&"MET"!==t.resname&&-1!==t.formalCharge||(rg(e,t),ng(d,e)))}),b=C,x=Fg((y=t).data).totalH,y.eachAtom(function(t){var e=ig(4),i=t.number;Vg(t)?(rg(e,t),ng(b,e)):0<x[t.index]&&(7===i||8===i||16===i)&&(rg(e,t),ng(b,e))}),w=C,S=Fg((_=t).data).totalH,_.eachAtom(function(t){if(6===t.number&&0<S[t.index]&&(0<t.bondToElementCount(7)||0<t.bondToElementCount(8)||function(r){if(!r.isAromatic())return!1;var t=r.residueType.getRings();if(!t)return!1;var e=!1;return t.rings.forEach(function(t){e||t.some(function(t){return r.index-r.residueAtomOffset===t})&&(e=t.some(function(t){var e=r.residueType.atomTypeIdList[t],i=r.atomMap.get(e).number;return 7===i||8===i}))}),e}(t))){var e=ig(9);rg(e,t),ng(w,e)}}),A=C,t.eachAtom(function(t){var e=!1,i=!1,r=wg.includes(t.resname),n=Eg.includes(t.resname);if(r||n?r?8===t.number?["ASP","GLU","SER","THR","TYR","ASN","GLN"].includes(t.resname)&&t.isSidechain()?i=e=!0:t.isBackbone()&&(i=e=!0):16===t.number&&"CYS"===t.resname?i=e=!0:7===t.number&&"HIS"===t.resname&&t.isSidechain()&&(e=!0):n&&(8===t.number&&t.isBackbone()?i=e=!0:["N3","N4","N7"].includes(t.atomname)?e=!0:["O2","O4","O6"].includes(t.atomname)&&(i=e=!0)):t.isHalogen()||8===t.number||16===t.number?i=e=!0:7===t.number&&(e=!0),e){var o=ig(11);rg(o,t),ng(A,o)}if(i){var a=ig(10);rg(a,t),ng(A,a)}}),M=C,t.eachAtom(function(t){if(t.isTransitionMetal()||30===t.number||48===t.number){var e=ig(12);rg(e,t),ng(M,e)}else if(Hg.includes(t.number)){var i=ig(13);rg(i,t),ng(M,i)}}),E=C,t.eachAtom(function(t){var e=ig(8),i=!1;6===t.number?(i=!0,t.eachBondedAtom(function(t){var e=t.number;6!==e&&1!==e&&(i=!1)})):9===t.number&&(i=!0),i&&(rg(e,t),ng(E,e))}),P=C,t.eachAtom(function(t){if(Wg.includes(t.number)){var e=!1;if(t.eachBondedAtom(function(t){Xg.includes(t.number)&&(e=!0)}),e){var i=ig(7);rg(i,t),ng(P,i)}}}),T=C,t.eachAtom(function(t){if($g.includes(t.number)&&1===t.bondToElementCount(6)){var e=ig(6);rg(e,t),ng(T,e)}}),de.Debug&&Yp.timeEnd("calculateFeatures"),C}function ev(t,e){void 0===e&&(e=Kg);var i,r,n,o=tv(t),a=(r=(i=o).types,n=i.centers,{features:i,spatialHash:new Zm(n),contactStore:new Jm,featureSet:new tg(r.length,!1)});de.Debug&&Yp.time("calculateContacts"),Gg(t,a,e),function(t,e,i){void 0===i&&(i={});for(var r=bl(i.maxHbondDist,Kg.maxHbondDist),n=bl(i.maxHbondSulfurDist,Kg.maxHbondSulfurDist),A=Gl(bl(i.maxHbondAccAngle,Kg.maxHbondAccAngle)),M=Gl(bl(i.maxHbondDonAngle,Kg.maxHbondDonAngle)),E=Gl(bl(i.maxHbondAccPlaneAngle,Kg.maxHbondAccPlaneAngle)),P=Gl(bl(i.maxHbondDonPlaneAngle,Kg.maxHbondDonPlaneAngle)),T=bl(i.masterModelIndex,Kg.masterModelIndex),o=Math.max(r,n),C=r*r,a=e.features,s=e.spatialHash,I=e.contactStore,O=e.featureSet,L=a.types,c=a.centers,R=a.atomSets,u=c.x,h=c.y,l=c.z,p=L.length,D=Fg(t.data).idealGeometry,k=t.getAtomProxy(),B=t.getAtomProxy(),d=function(S){s.eachWithin(u[S],h[S],l[S],o,function(t,e){if(!(t<=S)){var i,r,n=L[S],o=L[t],a=(r=o,9===(i=n)&&5===r||5===i&&9===r);if(a||(c=o,5===(s=n)&&4===c||4===s&&5===c)){var s,c,u=5===o?[S,t]:[t,S],h=u[0],l=u[1];if(k.index=R[h][0],B.index=R[l][0],B.index!==k.index&&!Qg(k,B,T)&&!(16!==k.number&&16!==B.number&&C<e||k.connectedTo(B))){var p=kg(k,B),d=Dg.get(D[k.index])||Gl(120);if(!p.some(function(t){return Math.abs(d-t)>M})){if(3===D[k.index]){var f=Bg(k,B);if(void 0!==f&&P<f)return}var m=kg(B,k),g=Dg.get(D[B.index])||Gl(120);if(!m.some(function(t){return A<g-t})){if(3===D[B.index]){var v=Bg(B,k);if(void 0!==v&&E<v)return}O.setBits(h,l);var y,b,x,_,w=a?8:(_=b=B,(y=k).isWater()&&_.isWater()?9:(x=b,y.isBackbone()&&x.isBackbone()?10:4));I.addContact(h,l,w)}}}}}})},f=0;f<p;++f)d(f)}(t,a,e),function(t,e,i){void 0===i&&(i={});for(var r=bl(i.maxMetalDist,Kg.maxMetalDist),c=bl(i.masterModelIndex,Kg.masterModelIndex),n=e.features,o=e.spatialHash,u=e.contactStore,h=e.featureSet,l=n.types,a=n.centers,p=n.atomSets,d=a.x,f=a.y,m=a.z,s=l.length,g=t.getAtomProxy(),v=t.getAtomProxy(),y=function(s){o.eachWithin(d[s],f[s],m[s],r,function(t,e){if(!(t<=s||(g.index=p[s][0],v.index=p[t][0],Qg(g,v,c)))){var i=g.isMetal(),r=v.isMetal();if(i||r){var n,o,a=i?[l[s],l[t]]:[l[t],l[s]];o=a[1],(12===(n=a[0])?11===o||12===o:13===n?10===o:void 0)&&(h.setBits(s,t),u.addContact(s,t,7))}}})},b=0;b<s;++b)y(b)}(t,a,e),function(t,e,i){void 0===i&&(i={});for(var r=bl(i.maxHydrophobicDist,Kg.maxHydrophobicDist),o=bl(i.masterModelIndex,Kg.masterModelIndex),n=e.features,a=e.spatialHash,s=e.contactStore,c=e.featureSet,u=n.types,h=n.centers,l=n.atomSets,p=h.x,d=h.y,f=h.z,m=u.length,g=t.getAtomProxy(),v=t.getAtomProxy(),y=function(n){a.eachWithin(p[n],d[n],f[n],r,function(t,e){var i,r;t<=n||(g.index=l[n][0],v.index=l[t][0],Qg(g,v,o)||9===g.number&&9===v.number||g.connectedTo(v)||(i=u[n],r=u[t],8===i&&8===r&&(c.setBits(n,t),s.addContact(n,t,6))))})},b=0;b<m;++b)y(b)}(t,a,e),function(t,e,i){void 0===i&&(i={});for(var r=bl(i.maxHalogenBondDist,Kg.maxHalogenBondDist),h=Gl(bl(i.maxHalogenBondAngle,Kg.maxHalogenBondAngle)),l=bl(i.masterModelIndex,Kg.masterModelIndex),n=e.features,o=e.spatialHash,p=e.contactStore,d=e.featureSet,f=n.types,a=n.centers,m=n.atomSets,s=a.x,c=a.y,g=a.z,u=f.length,v=t.getAtomProxy(),y=t.getAtomProxy(),b=function(u){o.eachWithin(s[u],c[u],g[u],r,function(t,e){if(!(t<=u)&&(v.index=m[u][0],y.index=m[t][0],!Qg(v,y,l)&&(i=f[u],r=f[t],7===i&&6===r||6===i&&7===r))){var i,r,n=6===f[u]?[v,y]:[y,v],o=n[0],a=n[1],s=kg(o,a);if(1===s.length&&!(qg-s[0]>h)){var c=kg(a,o);0!==c.length&&(c.some(function(t){return h<Yg-t})||(d.setBits(u,t),p.addContact(u,t,5)))}}})},x=0;x<u;++x)b(x)}(t,a,e);var s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E,P,T,C,I,O,L,R,D,k,B,N,F,z,U,j,G,V,H,$,W,X,q,Y,Z,K,J,Q,tt=(c=(s=a).contactStore,u=eg({nodeArray1:c.index1,nodeArray2:c.index2,edgeCount:c.count,nodeCount:s.featureSet.length}),h=new tg(s.contactStore.count,!0),Object.assign({adjacencyList:u,contactSet:h},s));return function(t,e,i){void 0===i&&(i={}),de.Debug&&Yp.time("refineLineOfSight");var r=bl(i.lineOfSightDistFactor,Kg.lineOfSightDistFactor),a=bl(i.masterModelIndex,Kg.masterModelIndex),s=t.spatialHash,c=e.contactSet,n=e.contactStore,o=e.features,u=n.index1,h=n.index2,l=o.centers,p=o.atomSets,d=l.x,f=l.y,m=l.z,g=t.getAtomProxy(),v=t.getAtomProxy(),y=t.getAtomProxy(),b=new ri,x=new ri,_=3*r,w=r*r;c.forEach(function(i){b.set(d[u[i]],f[u[i]],m[u[i]]),x.set(d[h[i]],f[h[i]],m[h[i]]);var t=(b.x+x.x)/2,e=(b.y+x.y)/2,r=(b.z+x.z)/2,n=p[u[i]],o=p[h[i]];g.index=n[0],v.index=o[0],s.eachWithin(t,e,r,_,function(t,e){y.index=t,1!==y.number&&y.vdw*y.vdw*w>e&&!Zg(g,y,a)&&!Zg(v,y,a)&&!n.includes(t)&&!o.includes(t)&&1<b.distanceToSquared(y)&&1<x.distanceToSquared(y)&&(c.clear(i),de.Debug&&Yp.log("removing",g.qualifiedName(),v.qualifiedName(),"because",y.qualifiedName()))})}),de.Debug&&Yp.timeEnd("refineLineOfSight")}(t,tt,e),l=t,d=(p=tt).contactSet,f=p.contactStore,m=p.features,g=f.type,v=f.index1,y=f.index2,b=m.atomSets,x=l.getAtomProxy(),_=l.getAtomProxy(),w={},S=function(t,e,i){var r=w[i]||[1/0,-1],n=r[0],o=r[1];t<n?(-1!==o&&d.clear(o),w[i]=[t,e]):d.clear(e)},d.forEach(function(t){if(6===g[t]){x.index=b[v[t]][0],_.index=b[y[t]][0];var e=x.distanceTo(_);S(e,t,x.index+"|"+_.residueIndex),S(e,t,_.index+"|"+x.residueIndex)}}),e.refineSaltBridges&&(M=(A=tt).contactSet,E=A.contactStore,P=A.features,T=E.type,C=E.index1,I=E.index2,O=P.atomSets,L={},R=function(t,e){L[t]||(L[t]=[]),L[t].push(e)},M.forEach(function(e){1===T[e]&&(O[C[e]].forEach(function(t){return R(t,e)}),O[I[e]].forEach(function(t){return R(t,e)}))}),M.forEach(function(t){if(4===(e=T[t])||9===e||10===e){var e,i=L[O[C[t]][0]],r=L[O[I[t]][0]];if(i&&r)for(var n=i.length,o=0;o<n;++o)if(r.includes(i[o]))return void M.clear(t)}})),k=(D=tt).contactSet,B=D.contactStore,N=D.features,F=B.type,z=B.index1,U=B.index2,j=N.atomSets,G={},V=function(t,e){G[t]||(G[t]=[]),G[t].push(e)},k.forEach(function(e){3===F[e]&&(j[z[e]].forEach(function(t){return V(t,e)}),j[U[e]].forEach(function(t){return V(t,e)}))}),k.forEach(function(t){if(6===F[t]||2===F[t]){var e=G[j[z[t]][0]],i=G[j[U[t]][0]];if(e&&i)for(var r=e.length,n=0;n<r;++n)if(i.includes(e[n]))return void k.clear(t)}}),$=(H=tt).contactSet,W=H.contactStore,X=H.features,q=W.type,Y=W.index1,Z=W.index2,K=X.atomSets,J={},Q=function(t,e){J[t]||(J[t]=[]),J[t].push(e)},$.forEach(function(e){1===q[e]&&(K[Y[e]].forEach(function(t){return Q(t,e)}),K[Z[e]].forEach(function(t){return Q(t,e)}))}),$.forEach(function(t){if(7===q[t]){var e=J[K[Y[t]][0]],i=J[K[Z[t]][0]];if(e&&i)for(var r=e.length,n=0;n<r;++n)if(i.includes(e[n]))return void $.clear(e[n])}}),de.Debug&&Yp.timeEnd("calculateContacts"),tt}var iv={hydrogenBond:!0,hydrophobic:!0,halogenBond:!0,ionicInteraction:!0,metalCoordination:!0,cationPi:!0,piStacking:!0,weakHydrogenBond:!0,waterHydrogenBond:!0,backboneHydrogenBond:!0,radius:1,filterSele:""},rv=new ki;function nv(t,e,i){var a=xl(i,iv),s=[];a.hydrogenBond&&s.push(4),a.hydrophobic&&s.push(6),a.halogenBond&&s.push(5),a.ionicInteraction&&s.push(1),a.metalCoordination&&s.push(7),a.cationPi&&s.push(2),a.piStacking&&s.push(3),a.weakHydrogenBond&&s.push(8),a.waterHydrogenBond&&s.push(9),a.backboneHydrogenBond&&s.push(10);var c,r=t.features,n=t.contactSet,o=t.contactStore,u=r.centers,h=r.atomSets,l=u.x,p=u.y,d=u.z,f=o.index1,m=o.index2,g=o.type,v=[],y=[],b=[],x=[],_=[];return a.filterSele&&(c=Array.isArray(a.filterSele)?a.filterSele.map(function(t){return e.getAtomSet(new Lp(t))}):e.getAtomSet(new Lp(a.filterSele))),n.forEach(function(t){var e=g[t];if(s.includes(e)){if(c){var i=h[f[t]][0],r=h[m[t]][0];if(Array.isArray(c)){if(!(c[0].isSet(i)&&c[1].isSet(r)||c[1].isSet(i)&&c[0].isSet(r)))return}else if(!c.isSet(i)&&!c.isSet(r))return}var n=f[t],o=m[t];v.push(l[n],p[n],d[n]),y.push(l[o],p[o],d[o]),b.push.apply(b,function(t){switch(t){case 4:case 9:case 10:return rv.setHex(2851770).toArray();case 6:return rv.setHex(8421504).toArray();case 5:return rv.setHex(4259775).toArray();case 1:return rv.setHex(15779860).toArray();case 7:return rv.setHex(9191577).toArray();case 2:return rv.setHex(16744448).toArray();case 3:return rv.setHex(9220966).toArray();case 8:return rv.setHex(12967404).toArray();default:return rv.setHex(13421772).toArray()}}(e)),x.push(a.radius),_.push(t)}}),{position1:new Float32Array(v),position2:new Float32Array(y),color:new Float32Array(b),color2:new Float32Array(b),radius:new Float32Array(x),picking:new dv(_,t,e)}}var ov=function(t){this.array=t},av={type:{configurable:!0},data:{configurable:!0}};av.type.get=function(){return""},av.data.get=function(){return{}},ov.prototype.getIndex=function(t){return this.array?this.array[t]:t},ov.prototype.getObject=function(t){return{}},ov.prototype._applyTransformations=function(t,e,i){return e&&t.applyMatrix4(e.matrix),i&&t.applyMatrix4(i.matrix),t},ov.prototype._getPosition=function(t){return new ri},ov.prototype.getPosition=function(t,e,i){return this._applyTransformations(this._getPosition(t),e,i)},Object.defineProperties(ov.prototype,av);var sv=function(e){function t(t){e.call(this),this.shape=t}e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t;var i={primitive:{configurable:!0},data:{configurable:!0},type:{configurable:!0}};return i.primitive.get=function(){},i.data.get=function(){return this.shape},i.type.get=function(){return this.primitive.type},t.prototype.getObject=function(t){return this.primitive.objectFromShape(this.shape,this.getIndex(t))},t.prototype._getPosition=function(t){return this.primitive.positionFromShape(this.shape,this.getIndex(t))},Object.defineProperties(t.prototype,i),t}(ov),cv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Gm},Object.defineProperties(e.prototype,i),e}(sv),uv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Vm},Object.defineProperties(e.prototype,i),e}(sv),hv=function(i){function t(t,e){i.call(this,t),this.structure=e}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"atom"},e.data.get=function(){return this.structure},t.prototype.getObject=function(t){return this.structure.getAtomProxy(this.getIndex(t))},t.prototype._getPosition=function(t){return(new ri).copy(this.getObject(t))},Object.defineProperties(t.prototype,e),t}(ov),lv=function(e){function t(t){e.call(this),this.axes=t}e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t;var i={type:{configurable:!0},data:{configurable:!0}};return i.type.get=function(){return"axes"},i.data.get=function(){return this.axes},t.prototype.getObject=function(){return{axes:this.axes}},t.prototype._getPosition=function(){return this.axes.center.clone()},Object.defineProperties(t.prototype,i),t}(ov),pv=function(r){function t(t,e,i){r.call(this,t),this.structure=e,this.bondStore=i||e.bondStore}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"bond"},e.data.get=function(){return this.structure},t.prototype.getObject=function(t){var e=this.structure.getBondProxy(this.getIndex(t));return e.bondStore=this.bondStore,e},t.prototype._getPosition=function(t){var e=this.getObject(t);return(new ri).copy(e.atom1).add(e.atom2).multiplyScalar(.5)},Object.defineProperties(t.prototype,e),t}(ov),dv=function(r){function t(t,e,i){r.call(this,t),this.contacts=e,this.structure=i}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"contact"},e.data.get=function(){return this.contacts},t.prototype.getObject=function(t){var e=this.getIndex(t),i=this.contacts,r=i.features,n=i.contactStore,o=r.centers,a=r.atomSets,s=o.x,c=o.y,u=o.z,h=n.index1,l=n.index2,p=n.type,d=h[e],f=l[e];return{center1:new ri(s[d],c[d],u[d]),center2:new ri(s[f],c[f],u[f]),atom1:this.structure.getAtomProxy(a[d][0]),atom2:this.structure.getAtomProxy(a[f][0]),type:function(t){switch(t){case 4:case 9:case 10:return"hydrogen bond";case 6:return"hydrophobic contact";case 5:return"halogen bond";case 1:return"ionic interaction";case 7:return"metal coordination";case 2:return"cation-pi interaction";case 3:return"pi-pi stacking";case 8:return"weak hydrogen bond";default:return"unknown contact"}}(p[e])}},t.prototype._getPosition=function(t){var e=this.getObject(t),i=e.center1,r=e.center2;return(new ri).addVectors(i,r).multiplyScalar(.5)},Object.defineProperties(t.prototype,e),t}(ov),fv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Hm},Object.defineProperties(e.prototype,i),e}(sv),mv=function(r){function t(t,e,i){r.call(this,t),this.validation=e,this.structure=i}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"clash"},e.data.get=function(){return this.validation},t.prototype.getObject=function(t){var e=this.validation,i=this.getIndex(t);return{validation:e,index:i,clash:e.clashArray[i]}},t.prototype._getAtomProxyFromSele=function(t){var e=new Lp(t),i=this.structure.getAtomIndices(e)[0];return this.structure.getAtomProxy(i)},t.prototype._getPosition=function(t){var e=this.getObject(t).clash,i=this._getAtomProxyFromSele(e.sele1),r=this._getAtomProxyFromSele(e.sele2);return(new ri).copy(i).add(r).multiplyScalar(.5)},Object.defineProperties(t.prototype,e),t}(ov),gv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"distance"},Object.defineProperties(e.prototype,i),e}(pv),vv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return $m},Object.defineProperties(e.prototype,i),e}(sv),yv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Um},Object.defineProperties(e.prototype,i),e}(sv),bv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return zm},Object.defineProperties(e.prototype,i),e}(sv),xv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"ignore"},Object.defineProperties(e.prototype,i),e}(ov),_v=function(i){function t(t,e){i.call(this,t),this.mesh=e}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"mesh"},t.prototype.getObject=function(){var t=this.mesh;return{shape:this.shape,name:t.name,serial:t.serial}},t.prototype._getPosition=function(){return this.__position||(this.__position=hm(this.mesh.position)),this.__position},Object.defineProperties(t.prototype,e),t}(sv),wv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Fm},Object.defineProperties(e.prototype,i),e}(sv),Sv=function(i){function t(t,e){i.call(this,t),this.surface=e}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"surface"},e.data.get=function(){return this.surface},t.prototype.getObject=function(t){return{surface:this.surface,index:this.getIndex(t)}},t.prototype._getPosition=function(){return this.surface.center.clone()},Object.defineProperties(t.prototype,e),t}(ov),Av=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return jm},Object.defineProperties(e.prototype,i),e}(sv),Mv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Wm},Object.defineProperties(e.prototype,i),e}(sv),Ev=function(i){function t(t,e){i.call(this),this.unitcell=t,this.structure=e}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"unitcell"},e.data.get=function(){return this.unitcell},t.prototype.getObject=function(){return{unitcell:this.unitcell,structure:this.structure}},t.prototype._getPosition=function(){return this.unitcell.getCenter(this.structure)},Object.defineProperties(t.prototype,e),t}(ov),Pv=(function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};i.type.get=function(){return"unknown"},Object.defineProperties(e.prototype,i)}(ov),function(i){function t(t,e){i.call(this,t),this.volume=e}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},data:{configurable:!0}};return e.type.get=function(){return"volume"},e.data.get=function(){return this.volume},t.prototype.getObject=function(t){var e=this.volume,i=this.getIndex(t);return{volume:e,index:i,value:e.data[i]}},t.prototype._getPosition=function(t){var e=this.volume.position,i=this.getIndex(t);return new ri(e[3*i],e[3*i+1],e[3*i+2])},Object.defineProperties(t.prototype,e),t}(ov)),Tv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"slice"},Object.defineProperties(e.prototype,i),e}(Pv),Cv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return qm},Object.defineProperties(e.prototype,i),e}(sv),Iv=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={primitive:{configurable:!0}};return i.primitive.get=function(){return Ym},Object.defineProperties(e.prototype,i),e}(sv);function Ov(){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 Lv(){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 Rv(){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 Dv(I,P,T,C,d){var f,O,m,L,c,u,h,R=0,D=!1,k=!1,B=!1,l=P*T*C,N=P,F=P*T,z=new Int32Array(12),g=[],v=[],U=[],y=[],j=Ov(),G=Lv(),V=[[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 b(t,e,i){return t+(e-t)*i}function H(t,e,i){return F*(i=(i+h)%C)+N*(e=(e+u)%T)+(t=(t+c)%P)}function $(t,e,i,r,n,o,a){var s=3*t;if(O[s]<0){var c=(R-o)/(a-o),u=f,h=3*m;if(g[h+0]=i+c,g[h+1]=r,g[h+2]=n,!D){var l=3*t;v[h]=-b(u[l],u[l+3],c),v[h+1]=-b(u[l+1],u[l+4],c),v[h+2]=-b(u[l+2],u[l+5],c)}d&&(y[m]=d[t+Math.round(c)]),O[s]=m,z[e]=m,m+=1}else z[e]=O[s]}function W(t,e,i,r,n,o,a){var s=3*t+1;if(O[s]<0){var c=(R-o)/(a-o),u=f,h=3*m;if(g[h]=i,g[h+1]=r+c,g[h+2]=n,!D){var l=3*t,p=l+3*N;v[h]=-b(u[l],u[p],c),v[h+1]=-b(u[l+1],u[p+1],c),v[h+2]=-b(u[l+2],u[p+2],c)}d&&(y[m]=d[t+Math.round(c)*N]),O[s]=m,z[e]=m,m+=1}else z[e]=O[s]}function X(t,e,i,r,n,o,a){var s=3*t+2;if(O[s]<0){var c=(R-o)/(a-o),u=f,h=3*m;if(g[h]=i,g[h+1]=r,g[h+2]=n+c,!D){var l=3*t,p=l+3*F;v[h]=-b(u[l],u[p],c),v[h+1]=-b(u[l+1],u[p+1],c),v[h+2]=-b(u[l+2],u[p+2],c)}d&&(y[m]=d[t+Math.round(c)*F]),O[s]=m,z[e]=m,m+=1}else z[e]=O[s]}function q(t){var e=3*t;0===f[e]&&(f[e]=I[(t-1+l)%l]-I[(t+1)%l],f[e+1]=I[(t-N+l)%l]-I[(t+N)%l],f[e+2]=I[(t-F+l)%l]-I[(t+F)%l])}function Y(t,e,i,r,n){var o,a,s,c,u,h,l;B?(r=H(t,e,i),o=H(t+1,e,i),a=H(t,e+1,i),s=H(t,e,i+1),c=H(t+1,e+1,i),u=H(t+1,e,i+1),h=H(t,e+1,i+1),l=H(t+1,e+1,i+1)):(o=r+1,c=(a=r+N)+1,u=(s=r+F)+1,l=(h=a+F)+1);var p=0,d=I[r],f=I[o],m=I[a],g=I[c],v=I[s],y=I[u],b=I[h],x=I[l];d<R&&(p|=1),f<R&&(p|=2),m<R&&(p|=8),g<R&&(p|=4),v<R&&(p|=16),y<R&&(p|=32),b<R&&(p|=128),x<R&&(p|=64);var _=j[p];if(0===_)return 0;var w=t+1,S=e+1,A=i+1;1&_&&(D||(q(r),q(o)),$(r,0,t,e,i,d,f)),2&_&&(D||(q(o),q(c)),W(o,1,w,e,i,f,g)),4&_&&(D||(q(a),q(c)),$(a,2,t,S,i,m,g)),8&_&&(D||(q(r),q(a)),W(r,3,t,e,i,d,m)),16&_&&(D||(q(s),q(u)),$(s,4,t,e,A,v,y)),32&_&&(D||(q(u),q(l)),W(u,5,w,e,A,y,x)),64&_&&(D||(q(h),q(l)),$(h,6,t,S,A,b,x)),128&_&&(D||(q(s),q(h)),W(s,7,t,e,A,v,b)),256&_&&(D||(q(r),q(s)),X(r,8,t,e,i,d,v)),512&_&&(D||(q(o),q(u)),X(o,9,w,e,i,f,y)),1024&_&&(D||(q(c),q(l)),X(c,10,w,S,i,g,x)),2048&_&&(D||(q(a),q(h)),X(a,11,t,S,i,m,b));for(var M,E,P,T=p<<4,C=0;-1!==G[T+C];)M=G[T+C],E=G[T+C+1],P=G[T+C+2],k?(V[M][E]&n&&(U[L++]=z[M],U[L++]=z[E]),V[E][P]&n&&(U[L++]=z[E],U[L++]=z[P]),V[M][P]&n&&(U[L++]=z[M],U[L++]=z[P])):(U[L++]=z[E],U[L++]=z[M],U[L++]=z[P]),C+=3}function p(t,e,i,r,n,o){var a,s,c,u,h,l,p,d,f,m,g,v,y;if(t=void 0!==t?t:0,e=void 0!==e?e:0,i=void 0!==i?i:0,r=void 0!==r?r:P-1,n=void 0!==n?n:T-1,o=void 0!==o?o:C-1,B||(D?(t=Math.max(0,t),e=Math.max(0,e),i=Math.max(0,i),r=Math.min(P-1,r),n=Math.min(T-1,n),o=Math.min(C-1,o)):(t=Math.max(1,t),e=Math.max(1,e),i=Math.max(1,i),r=Math.min(P-2,r),n=Math.min(T-2,n),o=Math.min(C-2,o))),B)for(d=t-2,f=e-2,g=r+2,v=n+2,y=o+2,h=m=i-2;h<y;++h)for(u=f;u<v;++u)for(c=d;c<g;++c)s=3*H(c,u,h),O[s]=-1,O[s+1]=-1,O[s+2]=-1;else for(d=Math.max(0,t-2),f=Math.max(0,e-2),m=Math.max(0,i-2),g=Math.min(P,r+2),v=Math.min(T,n+2),y=Math.min(C,o+2),h=m;h<y;++h)for(p=F*h,u=f;u<v;++u)for(l=p+N*u,c=d;c<g;++c)O[a=3*(l+c)]=-1,O[a+1]=-1,O[a+2]=-1;if(!B){var b,x=t,_=e,w=i,S=r,A=n,M=o;for(b=!1,h=i;h<o;++h){for(u=e;u<n;++u){for(c=t;c<r;++c)if(I[a=P*T*h+P*u+c]>=R){w=h,b=!0;break}if(b)break}if(b)break}for(b=!1,u=e;u<n;++u){for(h=w;h<o;++h){for(c=t;c<r;++c)if(I[a=P*T*h+P*u+c]>=R){_=u,b=!0;break}if(b)break}if(b)break}for(b=!1,c=t;c<r;++c){for(u=_;u<n;++u){for(h=w;h<o;++h)if(I[a=P*T*h+P*u+c]>=R){x=c,b=!0;break}if(b)break}if(b)break}for(b=!1,h=o;i<=h;--h){for(u=n;e<=u;--u){for(c=r;t<=c;--c)if(I[a=P*T*h+P*u+c]>=R){M=h,b=!0;break}if(b)break}if(b)break}for(b=!1,u=n;e<=u;--u){for(h=M;i<=h;--h){for(c=r;t<=c;--c)if(I[a=P*T*h+P*u+c]>=R){A=u,b=!0;break}if(b)break}if(b)break}for(b=!1,c=r;t<=c;--c){for(u=A;e<=u;--u){for(h=M;i<=h;--h)if(I[a=P*T*h+P*u+c]>=R){S=c,b=!0;break}if(b)break}if(b)break}D?(t=Math.max(0,x-1),e=Math.max(0,_-1),i=Math.max(0,w-1),r=Math.min(P-1,S+1),n=Math.min(T-1,A+1),o=Math.min(C-1,M+1)):(t=Math.max(1,x-1),e=Math.max(1,_-1),i=Math.max(1,w-1),r=Math.min(P-2,S+1),n=Math.min(T-2,A+1),o=Math.min(C-2,M+1))}var E=15;for(h=i;h<o;++h,E&=-5)for(p=F*h,E|=2,u=e;u<n;++u,E&=-3)for(l=p+N*u,E|=1,c=t;c<r;++c,E&=-2)Y(c,u,h,a=l+c,E)}this.triangulate=function(t,e,i,r,n){R=t,k=r,B=n,(D=e||k)||f||(f=new Float32Array(3*l));var o=3*l;if(O&&O.length===o||(O=new Int32Array(o)),void(L=m=0)!==i){var a=i[0].map(Math.round),s=i[1].map(Math.round);c=P*Math.ceil(Math.abs(a[0])/P),u=T*Math.ceil(Math.abs(a[1])/T),h=C*Math.ceil(Math.abs(a[2])/C),p(a[0],a[1],a[2],s[0],s[1],s[2])}else c=u=h=0,p();return g.length=3*m,D||(v.length=3*m),U.length=L,d&&(y.length=m),{position:new Float32Array(g),normal:D?void 0:new Float32Array(v),index:Ll(U,g.length/3),atomindex:d?new Int32Array(y):void 0,contour:k}}}sd.add("arrow",uv),sd.add("box",bv),sd.add("cone",fv),sd.add("cylinder",cv),sd.add("ellipsoid",vv),sd.add("octahedron",yv),sd.add("sphere",wv),sd.add("tetrahedron",Av),sd.add("torus",Mv),sd.add("point",Cv),sd.add("wideline",Iv),Object.assign(Dv,{__deps:[Ov,Lv,Rv,Ll]});var kv=function(t,e){this.cols=t,this.rows=e,this.size=this.cols*this.rows,this.data=new Float32Array(this.size)};function Bv(t,e){for(var i=0,r=0,n=e.rows,o=e.cols,a=0,s=0,c=0,u=e.data,h=t.data;i<n;s+=1,a+=o,i++)for(c=s,r=0;r<o;c+=n,r++)h[c]=u[a+r]}function Nv(t,e,i){for(var r=0,n=0,o=0,a=0,s=0,c=0,u=0,h=e.cols,l=e.rows,p=i.rows,d=e.data,f=i.data,m=t.data,g=0;r<l;a+=h,r++)for(n=c=0;n<p;u++,n++){for(s=a,o=g=0;o<h;s++,c++,o++)g+=d[s]*f[c];m[u]=g}}function Fv(t,e,i){var r=t.data,n=e.data,o=i.data,a=n[0],s=n[1],c=n[2],u=n[3],h=n[4],l=n[5],p=n[6],d=n[7],f=n[8],m=o[0],g=o[1],v=o[2],y=o[3],b=o[4],x=o[5],_=o[6],w=o[7],S=o[8];r[0]=a*m+s*y+c*_,r[1]=a*g+s*b+c*w,r[2]=a*v+s*x+c*S,r[3]=u*m+h*y+l*_,r[4]=u*g+h*b+l*w,r[5]=u*v+h*x+l*S,r[6]=p*m+d*y+f*_,r[7]=p*g+d*b+f*w,r[8]=p*v+d*x+f*S}function zv(t){for(var e=t.rows,i=t.cols,r=t.data,n=new Array(i),o=0;o<i;++o)n[o]=0;for(var a=0,s=0;a<e;++a)for(var c=0;c<i;++c,++s)n[c]+=r[s];for(var u=0;u<i;++u)n[u]/=e;return n}function Uv(t,e){for(var i=t.rows,r=t.cols,n=t.data,o=0,a=0;o<i;++o)for(var s=0;s<r;++s,++a)n[a]-=e[s]}function jv(t,e,i,r){r=t[e],t[e]=t[i],t[i]=r}kv.prototype.copyTo=function(t){t.data.set(this.data)};var Gv=1.192092896e-7,Vv=1e-37;function Hv(t,e,i,r){var n=0,o=0,a=t.rows,s=t.cols,c=a,u=s;c<u&&(n=1,o=c,c=u,u=o);var h=new kv(c,c),l=new kv(1,u),p=new kv(u,u);if(0===n)Bv(h,t);else{for(o=0;o<s*a;o++)h.data[o]=t.data[o];for(;o<u*c;o++)h.data[o]=0}if(function(t,e,i,r,n,o,a,s){for(var c,u,h=2*Gv,l=Vv,p=0,d=0,f=0,m=0,g=Math.max(o,30),v=0,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,E=0,P=0,T=0,C=0,I=0,O=0,L=0,R=0,D=4660,k=0,B=0,N=0,F=new Float64Array(a<<3);p<a;p++){for(P=f=0;f<o;f++)P+=(A=t[p*e+f])*A;if(F[p]=P,r){for(f=0;f<a;f++)r[p*n+f]=0;r[p*n+p]=1}}for(;m<g;m++){for(p=_=0;p<a-1;p++)for(d=p+1;d<a;d++){for(v=p*e|0,y=d*e|0,O=F[p],L=0,R=F[d],f=2,L+=t[v]*t[y],L+=t[v+1]*t[y+1];f<o;f++)L+=t[v+f]*t[y+f];if(!(Math.abs(L)<=h*Math.sqrt(O*R))){for(c=L*=2,u=T=O-R,c=Math.abs(c),C=(u=Math.abs(u))<c?(u/=c,c*Math.sqrt(1+u*u)):0<u?(c/=u,u*Math.sqrt(1+c*c)):0,T<0?(I=.5*(C-T),w=L/(C*(S=Math.sqrt(I/C))*2)):S=L/(C*(w=Math.sqrt((C+T)/(2*C)))*2),R=O=0,f=2,M=w*t[v]+S*t[y],E=-S*t[v]+w*t[y],O+=(t[v]=M)*M,R+=(t[y]=E)*E,M=w*t[v+1]+S*t[y+1],E=-S*t[v+1]+w*t[y+1],O+=(t[v+1]=M)*M,R+=(t[y+1]=E)*E;f<o;f++)M=w*t[v+f]+S*t[y+f],E=-S*t[v+f]+w*t[y+f],O+=(t[v+f]=M)*M,R+=(t[y+f]=E)*E;if(F[p]=O,F[d]=R,_=1,r)for(x=d*n|0,f=2,M=w*r[b=p*n|0]+S*r[x],E=-S*r[b]+w*r[x],r[b]=M,r[x]=E,M=w*r[b+1]+S*r[x+1],E=-S*r[b+1]+w*r[x+1],r[b+1]=M,r[x+1]=E;f<a;f++)M=w*r[b+f]+S*r[x+f],E=-S*r[b+f]+w*r[x+f],r[b+f]=M,r[x+f]=E}}if(0===_)break}for(p=0;p<a;p++){for(P=f=0;f<o;f++)P+=(A=t[p*e+f])*A;F[p]=Math.sqrt(P)}for(p=0;p<a-1;p++){for(f=(d=p)+1;f<a;f++)F[d]<F[f]&&(d=f);if(p!==d&&(jv(F,p,d,P),r)){for(f=0;f<o;f++)jv(t,p*e+f,d*e+f,A);for(f=0;f<a;f++)jv(r,p*n+f,d*n+f,A)}}for(p=0;p<a;p++)i[p]=F[p];if(r)for(p=0;p<s;p++){for(P=p<a?F[p]:0;P<=l;){for(B=1/o,f=0;f<o;f++)k=0!=(256&(D=214013*D+2531011)>>16)?B:-B,t[p*e+f]=k;for(m=0;m<2;m++)for(d=0;d<p;d++){for(f=P=0;f<o;f++)P+=t[p*e+f]*t[d*e+f];for(f=N=0;f<o;f++)A=t[p*e+f]-P*t[d*e+f],t[p*e+f]=A,N+=Math.abs(A);for(N=N?1/N:0,f=0;f<o;f++)t[p*e+f]*=N}for(f=P=0;f<o;f++)P+=(A=t[p*e+f])*A;P=Math.sqrt(P)}for(S=1/P,f=0;f<o;f++)t[p*e+f]*=S}}(h.data,c,l.data,p.data,u,c,u,c),e){for(o=0;o<u;o++)e.data[o]=l.data[o];for(;o<s;o++)e.data[o]=0}0===n?(i&&Bv(i,h),r&&Bv(r,p)):(i&&Bv(i,p),r&&Bv(r,h))}function $v(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Wv(t,e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g){t[0]=e,t[4]=i,t[8]=r,t[12]=n,t[1]=o,t[5]=a,t[9]=s,t[13]=c,t[2]=u,t[6]=h,t[10]=l,t[14]=p,t[3]=d,t[7]=f,t[11]=m,t[15]=g}function Xv(t,e,i){var r=e[0],n=e[4],o=e[8],a=e[12],s=e[1],c=e[5],u=e[9],h=e[13],l=e[2],p=e[6],d=e[10],f=e[14],m=e[3],g=e[7],v=e[11],y=e[15],b=i[0],x=i[4],_=i[8],w=i[12],S=i[1],A=i[5],M=i[9],E=i[13],P=i[2],T=i[6],C=i[10],I=i[14],O=i[3],L=i[7],R=i[11],D=i[15];t[0]=r*b+n*S+o*P+a*O,t[4]=r*x+n*A+o*T+a*L,t[8]=r*_+n*M+o*C+a*R,t[12]=r*w+n*E+o*I+a*D,t[1]=s*b+c*S+u*P+h*O,t[5]=s*x+c*A+u*T+h*L,t[9]=s*_+c*M+u*C+h*R,t[13]=s*w+c*E+u*I+h*D,t[2]=l*b+p*S+d*P+f*O,t[6]=l*x+p*A+d*T+f*L,t[10]=l*_+p*M+d*C+f*R,t[14]=l*w+p*E+d*I+f*D,t[3]=m*b+g*S+v*P+y*O,t[7]=m*x+g*A+v*T+y*L,t[11]=m*_+g*M+v*C+y*R,t[15]=m*w+g*E+v*I+y*D}function qv(t,e,i,r){Wv(t,e,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1)}function Yv(t,e,i,r){Wv(t,1,0,0,e,0,1,0,i,0,0,1,r,0,0,0,1)}function Zv(t,e){var i=Math.cos(e),r=Math.sin(e);Wv(t,i,0,r,0,0,1,0,0,-r,0,i,0,0,0,0,1)}function Kv(){return new Float32Array([1,0,0,0,1,0,0,0,1])}function Jv(t,e){var i=gm([e[0],e[1],e[2]]),r=gm([e[4],e[5],e[6]]),n=gm([e[8],e[9],e[10]]),o=gm();vm(o,r,n),t[0]=o[0],t[1]=o[1],t[2]=o[2],vm(o,n,i),t[3]=o[0],t[4]=o[1],t[5]=o[2],vm(o,i,r),t[6]=o[0],t[7]=o[1],t[8]=o[2]}function Qv(t,e,i,r){i=i||1,r=r||!0;var n,o=t.length/3,a=e.length/3;r&&(n=new Float32Array(3*o));var s,c,u,h,l=new Float32Array(3*o),p=new Array(20);for(s=0;s<20;++s)p[s]=new Uint32Array(o);for(s=0;s<o;++s)p[0][s]=0;for(s=0;s<a;++s){var d=3*s,f=3*s+1,m=3*s+2;for(h=!0,u=p[c=0][e[d]];c<u;++c)if(e[f]===p[c+1][e[d]]){h=!1;break}for(h&&(p[0][e[d]]++,p[p[0][e[d]]][e[d]]=e[f]),h=!0,u=p[c=0][e[d]];c<u;++c)if(e[m]===p[c+1][e[d]]){h=!1;break}for(h&&(p[0][e[d]]++,p[p[0][e[d]]][e[d]]=e[m]),h=!0,u=p[c=0][e[f]];c<u;++c)if(e[d]===p[c+1][e[f]]){h=!1;break}for(h&&(p[0][e[f]]++,p[p[0][e[f]]][e[f]]=e[d]),h=!0,u=p[c=0][e[f]];c<u;++c)if(e[m]===p[c+1][e[f]]){h=!1;break}for(h&&(p[0][e[f]]++,p[p[0][e[f]]][e[f]]=e[m]),h=!0,c=0;c<p[0][e[m]];++c)if(e[d]===p[c+1][e[m]]){h=!1;break}for(h&&(p[0][e[m]]++,p[p[0][e[m]]][e[m]]=e[d]),h=!0,u=p[c=0][e[m]];c<u;++c)if(e[f]===p[c+1][e[m]]){h=!1;break}h&&(p[0][e[m]]++,p[p[0][e[m]]][e[m]]=e[f])}for(var g,v,y,b,x,_=0;_<i;++_){for(s=0;s<o;++s)if(g=3*s,(y=p[0][s])<3)l[g]=t[g],l[g+1]=t[g+1],l[g+2]=t[g+2];else if(3===y||4===y){for(l[g]=0,l[g+1]=0,c=l[g+2]=0;c<y;++c)v=3*p[c+1][s],l[g]+=t[v],l[g+1]+=t[v+1],l[g+2]+=t[v+2];l[g]+=.5*t[g],l[g+1]+=.5*t[g+1],l[g+2]+=.5*t[g+2],x=.5+y,l[g]/=x,l[g+1]/=x,l[g+2]/=x}else{for(l[g]=0,l[g+1]=0,c=l[g+2]=0;c<y;++c)v=3*p[c+1][s],l[g]+=t[v],l[g+1]+=t[v+1],l[g+2]+=t[v+2];l[g]+=1*t[g],l[g+1]+=1*t[g+1],l[g+2]+=1*t[g+2],b=1+y,l[g]/=b,l[g+1]/=b,l[g+2]/=b}if(t.set(l),r){ty(t,e,n);var w=3*o;for(g=0;g<w;g+=3)t[g]+=.75/4.5*-1*n[g],t[g+1]+=.75/4.5*-1*n[g+1],t[g+2]+=.75/4.5*-1*n[g+2]}}}function ty(t,e,i){var r,n;if(void 0===i)i=new Float32Array(t.length);else for(r=0,n=i.length;r<n;r++)i[r]=0;var o=new Float32Array(3),a=new Float32Array(3),s=new Float32Array(3),c=new Float32Array(3),u=new Float32Array(3);if(e)for(r=0,n=e.length;r<n;r+=3){var h=3*e[r],l=3*e[r+1],p=3*e[r+2];_m(o,t,h),_m(a,t,l),_m(s,t,p),bm(c,s,a),bm(u,o,a),vm(c,c,u),i[h]+=c[0],i[h+1]+=c[1],i[h+2]+=c[2],i[l]+=c[0],i[l+1]+=c[1],i[l+2]+=c[2],i[p]+=c[0],i[p+1]+=c[1],i[p+2]+=c[2]}else for(r=0,n=t.length;r<n;r+=9)_m(o,t,r),_m(a,t,r+3),_m(s,t,r+6),bm(c,s,a),bm(u,o,a),vm(c,c,u),i[r]=c[0],i[r+1]=c[1],i[r+2]=c[2],i[r+3]=c[0],i[r+4]=c[1],i[r+5]=c[2],i[r+6]=c[0],i[r+7]=c[1],i[r+8]=c[2];return mm(i),i}function ey(t){for(var e={},i=0,r=t.length;i<r;++i)e[t[i]]=!0;return e}function iy(t,e,i,r,n){var o=1/r*3;Pm(t,t,n+(o+=i)),Tm(e,e,n+o),Mm(t,t,r),Cm(t,t),Am(t,t,r),Mm(e,e,r),Im(e,e),Am(e,e,r);var a=new Float32Array(3);bm(a,e,t),Mm(a,a,r),Im(a,a),Tm(a,a,1);var s=256*Math.pow(10,6),c=a[0]*a[1]*a[2]*3;s<=c&&(Mm(t,t,r*=Math.pow(s/c,1/3)),Cm(t,t),Am(t,t,r),Mm(e,e,r),Im(e,e),Am(e,e,r),bm(a,e,t),Mm(a,a,r),Im(a,a),Tm(a,a,1));var u=new Float32Array(t);Om(u,u);var h=$v(),l=$v();Zv(l,Gl(90)),Xv(h,h,l);var p=$v();qv(p,-1/r,1/r,1/r),Xv(h,h,p);var d=$v();return Yv(d,-r*u[2],-r*u[1],-r*u[0]),Xv(h,h,d),{dim:a,tran:u,matrix:h,scaleFactor:r}}qv.__deps=[Wv],Yv.__deps=[Wv],Zv.__deps=[Wv],Jv.__deps=[gm,vm],Object.assign(Qv,{__deps:[ty]}),Object.assign(ty,{__deps:[bm,vm,_m,mm]}),Object.assign(iy,{__deps:[Gl,Pm,Tm,Am,Mm,Cm,Im,bm,Om,$v,Xv,Yv,qv,Zv]});var ry=function(t,e,i){this.name=t||"",this.path=e||"",this.info={},this.center=new ri,this.boundingBox=new Pi,i instanceof _r||i instanceof $r||i instanceof ya?this.fromGeometry(i):i&&(this.set(i.position,i.index,i.normal,i.color,i.atomindex,i.contour),this.boundingBox.setFromArray(i.position),this.boundingBox.getCenter(this.center))},ny={type:{configurable:!0}};function oy(t,e,i,r,n){var c=new Dv(t,e,i,r,n);this.getSurface=function(t,e,i,r,n,o){void 0===o&&(o=!1);var a=c.triangulate(t,e,i,n,o);if(e&&!n&&(Qv(a.position,a.index,e,!0),a.normal=ty(a.position,a.index)),r&&(dm(r,a.position),a.normal)){var s=Kv();Jv(s,r),fm(s,a.normal)}return a}}ny.type.get=function(){return"Surface"},ry.prototype.set=function(t,e,i,r,n,o){void 0===o&&(o=!1),this.position=t,this.index=e,this.normal=i,this.color=r,this.atomindex=n,this.size=t.length/3,this.contour=o},ry.prototype.fromGeometry=function(t){var e,i,r,n;if(de.Debug&&Yp.time("GeometrySurface.fromGeometry"),t instanceof _r?(t.computeVertexNormals(!0),e=(new $r).fromGeometry(t)):e=t instanceof $r?t:t[0],e.boundingBox||e.computeBoundingBox(),this.boundingBox.copy(e.boundingBox),this.boundingBox.getCenter(this.center),e instanceof $r){var o=e.attributes,a=!!o.normal&&o.normal.array;(!a||0===a[0]&&0===a[1]&&0===a[2])&&e.computeVertexNormals(),i=o.position.array,r=o.index?o.index.array:null,n=o.normal.array}this.set(i,r,n,void 0,void 0),de.Debug&&Yp.timeEnd("GeometrySurface.setGeometry")},ry.prototype.getPosition=function(){return this.position},ry.prototype.getColor=function(t){var e=t||{},i=(e.surface=this).size,r=new Float32Array(3*i),n=Qp.getScheme(e);if(n.volumeColor||"random"===e.scheme)for(var o=0;o<i;++o)n.volumeColorToArray(o,r,3*o);else if(n.positionColor)for(var a=new ri,s=this.position,c=0;c<i;++c){var u=3*c;a.set(s[u],s[u+1],s[u+2]),n.positionColorToArray(a,r,u)}else if(n.atomColor&&this.atomindex)for(var h=e.structure.getAtomProxy(),l=this.atomindex,p=0;p<i;++p)h.index=l[p],n.atomColorToArray(h,r,3*p);else{var d=new ki(e.value);Vd(i,d.r,d.g,d.b,r)}return r},ry.prototype.getPicking=function(t){return this.atomindex&&t?new hv(this.atomindex,t):new Sv(Hd(this.size),this)},ry.prototype.getNormal=function(){return this.normal},ry.prototype.getSize=function(t,e){return Gd(this.size,t*e)},ry.prototype.getIndex=function(){return this.index},ry.prototype.getFilteredIndex=function(t,e){if(t&&this.atomindex){for(var i=new Lp(t),r=e.getAtomSet(i),n=[],o=this.atomindex,a=this.index,s=a.length,c=this.contour?2:3,u=0,h=0;h<s;h+=c){for(var l=!0,p=0;p<c;p++){var d=o[a[h+p]];if(!r.get(d)){l=!1;break}}if(l)for(var f=0;f<c;f++,u++)n[u]=a[h+f]}return Ll(n,this.position.length/3)}return this.index},ry.prototype.getAtomindex=function(){return this.atomindex},ry.prototype.dispose=function(){},Object.defineProperties(ry.prototype,ny),Object.assign(oy,{__deps:[Qv,ty,Dv,dm,fm,Kv,Jv]}),Jp.add("surf",function(t,e){var i=t.data.args,r=t.data.params;if(i&&(self.volsurf=new oy(i[0],i[1],i[2],i[3],i[4])),r){var n=self.volsurf.getSurface(r.isolevel,r.smooth,r.box,r.matrix,r.contour,r.wrap),o=[n.position.buffer,n.index.buffer];n.normal&&o.push(n.normal.buffer),n.atomindex&&o.push(n.atomindex.buffer),e({sd:n,p:r},o)}},[oy]);var ay=function(t,e,i,r,n,o,a){this.name=t,this.path=e,this.matrix=new ei,this.normalMatrix=new ni,this.inverseMatrix=new ei,this.center=new ri,this.boundingBox=new Pi,this.setData(i,r,n,o,a)},sy={type:{configurable:!0},position:{configurable:!0},min:{configurable:!0},max:{configurable:!0},sum:{configurable:!0},mean:{configurable:!0},rms:{configurable:!0}};function cy(t){return"front"===t?G:"back"===t?wt:et}sy.type.get=function(){return"Volume"},ay.prototype.setData=function(t,e,i,r,n){this.nx=e||1,this.ny=i||1,this.nz=r||1,this.data=t||new Float32Array(1),this.setAtomindex(n),delete this._position,delete this._min,delete this._max,delete this._mean,delete this._rms,this.worker&&this.worker.terminate()},ay.prototype.setStats=function(t,e,i,r){this._min=t,this._max=e,this._mean=i,this._rms=r},ay.prototype.setMatrix=function(t){this.matrix.copy(t);var e=this.boundingBox,i=this.center,r=this.nx-1,n=this.ny-1,o=this.nz-1;e.makeEmpty(),e.expandByPoint(i.set(r,n,o)),e.expandByPoint(i.set(r,n,0)),e.expandByPoint(i.set(r,0,o)),e.expandByPoint(i.set(r,0,0)),e.expandByPoint(i.set(0,n,o)),e.expandByPoint(i.set(0,0,o)),e.expandByPoint(i.set(0,n,0)),e.expandByPoint(i.set(0,0,0)),e.applyMatrix4(this.matrix),e.getCenter(this.center);var a=this.matrix.elements,s=new ri(a[0],a[1],a[2]),c=new ri(a[4],a[5],a[6]),u=new ri(a[8],a[9],a[10]),h=new ri,l=this.normalMatrix.elements;h.crossVectors(c,u),l[0]=h.x,l[1]=h.y,l[2]=h.z,h.crossVectors(u,s),l[3]=h.x,l[4]=h.y,l[5]=h.z,h.crossVectors(s,c),l[6]=h.x,l[7]=h.y,l[8]=h.z,this.inverseMatrix.getInverse(this.matrix)},ay.prototype.setAtomindex=function(t){this.atomindex=t},ay.prototype.getBox=function(t,e,i){return i||(i=new Pi),i.set(t,t),i.expandByScalar(e),i.applyMatrix4(this.inverseMatrix),i.min.round(),i.max.round(),i},ay.prototype._getBox=function(t,e){if(t&&e){this.__box||(this.__box=new Pi);var i=this.getBox(t,e,this.__box);return[i.min.toArray(),i.max.toArray()]}},ay.prototype._makeSurface=function(t,e,i){var r=this.name+"@"+e.toPrecision(2),n=new ry(r,"",t);return n.info.isolevel=e,n.info.smooth=i,n.info.volume=this,n},ay.prototype.getSurface=function(t,e,i,r,n,o){void 0===o&&(o=!1),t=isNaN(t)?this.getValueForSigma(2):t,e=bl(e,0),void 0===this.volsurf&&(this.volsurf=new oy(this.data,this.nx,this.ny,this.nz,this.atomindex));var a=this._getBox(i,r),s=this.volsurf.getSurface(t,e,a,this.matrix.elements,n,o);return this._makeSurface(s,t,e)},ay.prototype.getSurfaceWorker=function(i,r,n,o,a,s,c){var u=this;if(i=isNaN(i)?this.getValueForSigma(2):i,r=r||0,window.hasOwnProperty("Worker")){void 0===this.workerPool&&(this.workerPool=new um("surf",2));var t={},e=this.workerPool.getNextWorker();0===e.postCount&&Object.assign(t,{args:[this.data,this.nx,this.ny,this.nz,this.atomindex]}),Object.assign(t,{params:{isolevel:i,smooth:r,box:this._getBox(n,o),matrix:this.matrix.elements,contour:a,wrap:s}}),e.post(t,void 0,function(t){var e=t.data.sd,i=t.data.p;c(u._makeSurface(e,i.isolevel,i.smooth))},function(t){console.warn("Volume.getSurfaceWorker error - trying without worker",t);var e=u.getSurface(i,r,n,o,a,s);c(e)})}else{var h=this.getSurface(i,r,n,o,a,s);c(h)}},ay.prototype.getValueForSigma=function(t){return this.mean+bl(t,2)*this.rms},ay.prototype.getSigmaForValue=function(t){return(bl(t,0)-this.mean)/this.rms},sy.position.get=function(){if(!this._position){for(var t=this.nz,e=this.ny,i=this.nx,r=new Float32Array(i*e*t*3),n=0,o=0;o<t;++o)for(var a=0;a<e;++a)for(var s=0;s<i;++s)r[n+0]=s,r[n+1]=a,r[n+2]=o,n+=3;dm(this.matrix.elements,r),this._position=r}return this._position},ay.prototype.getDataAtomindex=function(){return this.atomindex},ay.prototype.getDataPosition=function(){return this.position},ay.prototype.getDataColor=function(t){var e=t||{};e.volume=this,e.scale=e.scale||"Spectral",e.domain=e.domain||[this.min,this.max];for(var i=Qp.getScheme(e),r=this.position.length/3,n=new Float32Array(3*r),o=0;o<r;++o)i.volumeColorToArray(o,n,3*o);return n},ay.prototype.getDataPicking=function(){var t=Hd(this.position.length/3);return new Pv(t,this)},ay.prototype.getDataSize=function(t,e){var i,r=this.data,n=this.position.length/3;switch(t){case"value":i=new Float32Array(r);break;case"abs-value":i=new Float32Array(r);for(var o=0;o<n;++o)i[o]=Math.abs(i[o]);break;case"value-min":i=new Float32Array(r);for(var a=this.min,s=0;s<n;++s)i[s]-=a;break;case"deviation":i=new Float32Array(r);break;default:i=Gd(n,t)}if(1!==e)for(var c=0;c<n;++c)i[c]*=e;return i},sy.min.get=function(){return void 0===this._min&&(this._min=Zd(this.data)),this._min},sy.max.get=function(){return void 0===this._max&&(this._max=Yd(this.data)),this._max},sy.sum.get=function(){return void 0===this._sum&&(this._sum=Kd(this.data)),this._sum},sy.mean.get=function(){return void 0===this._mean&&(this._mean=Jd(this.data)),this._mean},sy.rms.get=function(){return void 0===this._rms&&(this._rms=function(t){for(var e=t.length,i=0,r=0;r<e;++r){var n=t[r];i+=n*n}return Math.sqrt(i/e)}(this.data)),this._rms},ay.prototype.clone=function(){var t=new ay(this.name,this.path,this.data,this.nx,this.ny,this.nz,this.atomindex);return t.matrix.copy(this.matrix),t.header=Object.assign({},this.header),t},ay.prototype.dispose=function(){this.workerPool&&this.workerPool.terminate()},Object.defineProperties(ay.prototype,sy),rd.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}"),rd.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}");var uy={f:1,v2:2,v3:3,c:3};function hy(t,e){t.matrix.copy(e),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixWorldNeedsUpdate=!0}var ly={opaqueBack:!1,side:"double",opacity:1,depthWrite:!0,clipNear:0,clipRadius:0,clipCenter:new ri,flatShaded:!1,wireframe:!1,roughness:.4,metalness:0,diffuse:16777215,diffuseInterior:!1,useInteriorColor:!1,interiorColor:14540253,interiorDarkening:0,forceTransparent:!1,matrix:new ei,disablePicking:!1,sortParticles:!1,background:!1},py={opaqueBack:{updateShader:!0},side:{updateShader:!0,property:!0},opacity:{uniform:!0},depthWrite:{property:!0},clipNear:{updateShader:!0,property:!0},clipRadius:{updateShader:!0,uniform:!0},clipCenter:{uniform:!0},flatShaded:{updateShader:!0},background:{updateShader:!0},wireframe:{updateVisibility:!0},roughness:{uniform:!0},metalness:{uniform:!0},diffuse:{uniform:!0},diffuseInterior:{updateShader:!0},useInteriorColor:{updateShader:!0},interiorColor:{uniform:!0},interiorDarkening:{uniform:!0},matrix:{}},dy=function(t,e){void 0===e&&(e={}),this.parameterTypes=py,this.geometry=new $r,this.indexVersion=0,this.wireframeIndexVersion=-1,this.group=new ya,this.wireframeGroup=new ya,this.pickingGroup=new ya,this.vertexShader="",this.fragmentShader="",this.isImpostor=!1,this.isText=!1,this.isSurface=!1,this.isPoint=!1,this.isLine=!1,this.dynamic=!0,this.visible=!0,this.wireframeIndexCount=0,this.parameters=xl(e,this.defaultParameters),this.uniforms=Ri.merge([Fi.common,{fogColor:{value:null},fogNear:{value:0},fogFar:{value:0},opacity:{value:this.parameters.opacity},clipNear:{value:0},clipRadius:{value:this.parameters.clipRadius},clipCenter:{value:this.parameters.clipCenter}},{emissive:{value:new ki(0)},roughness:{value:this.parameters.roughness},metalness:{value:this.parameters.metalness},interiorColor:{value:new ki(this.parameters.interiorColor)},interiorDarkening:{value:this.parameters.interiorDarkening}},Fi.lights]),this.uniforms.diffuse.value.set(this.parameters.diffuse),this.pickingUniforms={clipNear:{value:0},objectId:{value:0},opacity:{value:this.parameters.opacity}};var i=t.position||t.position1;this._positionDataSize=i?i.length/3:0,t.primitiveId||(t.primitiveId=Hd(this._positionDataSize)),this.addAttributes({position:{type:"v3",value:t.position},color:{type:"c",value:t.color},primitiveId:{type:"f",value:t.primitiveId}}),e.matrix&&(this.matrix=e.matrix),t.index&&this.initIndex(t.index),this.picking=t.picking,this.makeWireframeGeometry()},fy={defaultParameters:{configurable:!0},matrix:{configurable:!0},transparent:{configurable:!0},size:{configurable:!0},attributeSize:{configurable:!0},pickable:{configurable:!0}};fy.defaultParameters.get=function(){return ly},fy.matrix.set=function(t){this.setMatrix(t)},fy.matrix.get=function(){return this.group.matrix.clone()},fy.transparent.get=function(){return this.parameters.opacity<1||this.parameters.forceTransparent},fy.size.get=function(){return this._positionDataSize},fy.attributeSize.get=function(){return this.size},fy.pickable.get=function(){return!!this.picking&&!this.parameters.disablePicking},dy.prototype.setMatrix=function(t){hy(this.group,t),hy(this.wireframeGroup,t),hy(this.pickingGroup,t)},dy.prototype.initIndex=function(t){this.geometry.setIndex(new wr(t,1)),this.geometry.getIndex().setDynamic(this.dynamic)},dy.prototype.makeMaterial=function(){var t=cy(this.parameters.side),e=new An({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.parameters.depthWrite,lights:!0,fog:!0,side:t});e.vertexColors=2,e.extensions.derivatives=this.parameters.flatShaded,e.extensions.fragDepth=this.isImpostor;var i=new An({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:this.parameters.depthWrite,lights:!1,fog:!0,side:t});i.vertexColors=2;var r=new An({uniforms:this.pickingUniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:!1,depthWrite:this.parameters.depthWrite,lights:!1,fog:!1,side:t,blending:q});r.vertexColors=2,r.extensions.fragDepth=this.isImpostor,e.clipNear=this.parameters.clipNear,i.clipNear=this.parameters.clipNear,r.clipNear=this.parameters.clipNear,this.material=e,this.wireframeMaterial=i,this.pickingMaterial=r,this.updateShader()},dy.prototype.makeWireframeGeometry=function(){this.makeWireframeIndex();var t=this.geometry,e=this.wireframeIndex,i=new $r;i.attributes=t.attributes,e&&(i.setIndex(new wr(e,1).setDynamic(this.dynamic)),i.setDrawRange(0,this.wireframeIndexCount)),this.wireframeGeometry=i},dy.prototype.makeWireframeIndex=function(){var n=[];function t(t,e){if(e<t){var i=t;t=e,e=i}var r=n[t];return void 0===r?(n[t]=[e],!0):!r.includes(e)&&(r.push(e),!0)}var e=this.geometry,i=e.index;if(this.parameters.wireframe)if(i){var r,o=i.array,a=o.length;if(e.drawRange.count!==1/0&&(a=e.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*a)r=this.wireframeIndex;else r=Ll(2*a,e.attributes.position.count);for(var s=0,c=n.length=0;c<a;c+=3){var u=o[c+0],h=o[c+1],l=o[c+2];t(u,h)&&(r[s+0]=u,r[s+1]=h,s+=2),t(h,l)&&(r[s+0]=h,r[s+1]=l,s+=2),t(l,u)&&(r[s+0]=l,r[s+1]=u,s+=2)}this.wireframeIndex=r,this.wireframeIndexCount=s,this.wireframeIndexVersion=this.indexVersion}else{var p,d=e.attributes.position.count;p=this.wireframeIndex&&this.wireframeIndex.length>2*d?this.wireframeIndex:Ll(2*d,d);for(var f=0,m=0;f<d;f+=3)p[m+0]=f,p[m+1]=f+1,p[m+2]=f+1,p[m+3]=f+2,p[m+4]=f+2,p[m+5]=f,m+=6;this.wireframeIndex=p,this.wireframeIndexCount=2*d,this.wireframeIndexVersion=this.indexVersion}else this.wireframeIndex=new Uint16Array(0),this.wireframeIndexCount=0},dy.prototype.updateWireframeIndex=function(){if(this.wireframeGeometry&&this.wireframeIndex){if(this.wireframeGeometry.setDrawRange(0,1/0),this.wireframeIndexVersion<this.indexVersion&&this.makeWireframeIndex(),this.wireframeIndex.length>this.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new wr(this.wireframeIndex,1).setDynamic(this.dynamic));else{var t=this.wireframeGeometry.getIndex();t.set(this.wireframeIndex),t.needsUpdate=0<this.wireframeIndexCount,t.updateRange.count=this.wireframeIndexCount}this.wireframeGeometry.setDrawRange(0,this.wireframeIndexCount)}},dy.prototype.getRenderOrder=function(){var t=0;return this.isText?t=1:this.transparent&&(t=this.isSurface?3:2),t},dy.prototype._getMesh=function(t){this.material||this.makeMaterial();var e,i=this.geometry,r=this[t];return(e=this.isLine?new Na(i,r):this.isPoint?new Ua(i,r):new Pn(i,r)).frustumCulled=!1,e.renderOrder=this.getRenderOrder(),e},dy.prototype.getMesh=function(){return this._getMesh("material")},dy.prototype.getWireframeMesh=function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),(t=new Na(this.wireframeGeometry,this.wireframeMaterial)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},dy.prototype.getPickingMesh=function(){return this._getMesh("pickingMaterial")},dy.prototype.getShader=function(t,e){return Cd(t,this.getDefines(e))},dy.prototype.getVertexShader=function(t){return this.getShader(this.vertexShader,t)},dy.prototype.getFragmentShader=function(t){return this.getShader(this.fragmentShader,t)},dy.prototype.getDefines=function(t){var 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},dy.prototype.getParameters=function(){return this.parameters},dy.prototype.addUniforms=function(t){this.uniforms=Ri.merge([this.uniforms,t]),this.pickingUniforms=Ri.merge([this.pickingUniforms,t])},dy.prototype.addAttributes=function(t){for(var e in t){var i=void 0,r=t[e],n=this.attributeSize*uy[r.type];r.value?(n!==r.value.length&&Yp.error("attribute value has wrong length",e),i=r.value):i=Ol("float32",n),this.geometry.addAttribute(e,new wr(i,uy[r.type]).setDynamic(this.dynamic))}},dy.prototype.updateRenderOrder=function(){var e=this.getRenderOrder();function t(t){t.renderOrder=e}this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)},dy.prototype.updateShader=function(){var 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},dy.prototype.setParameters=function(t){var e=t,i=this.parameterTypes,r=this.parameters,n={},o={},a=!1,s=!1;for(var c in e){var u=e[c];void 0!==u&&(r[c]=u,void 0!==i[c]&&(i[c].property&&(!0!==i[c].property?n[i[c].property]=u:n[c]=u),i[c].uniform&&(!0!==i[c].uniform?o[i[c].uniform]=u:o[c]=u),i[c].updateShader&&(a=!0),i[c].updateVisibility&&(s=!0),this.dynamic&&"wireframe"===c&&!0===u&&this.updateWireframeIndex(),"flatShaded"===c&&(this.material.extensions.derivatives=this.parameters.flatShaded||this.isText),"forceTransparent"===c&&(n.transparent=this.transparent),"matrix"===c&&(this.matrix=u)))}this.setProperties(n),this.setUniforms(o),a&&this.updateShader(),s&&this.setVisibility(this.visible)},dy.prototype.setAttributes=function(t){var e=this.geometry,i=e.attributes;for(var r in t)if("picking"!==r){var n=t[r],o=n.length;if("index"===r){var a=e.getIndex();e.setDrawRange(0,1/0),o>a.array.length?e.setIndex(new wr(n,1).setDynamic(this.dynamic)):(a.set(n),a.needsUpdate=0<o,a.updateRange.count=o,e.setDrawRange(0,o)),this.indexVersion++,this.parameters.wireframe&&this.updateWireframeIndex()}else{var s=i[r];o>s.array.length?e.addAttribute(r,new wr(n,s.itemSize).setDynamic(this.dynamic)):(i[r].set(n),i[r].needsUpdate=0<o,i[r].updateRange.count=o)}}},dy.prototype.setUniforms=function(t){if(t){var e=this.material.uniforms,i=this.wireframeMaterial.uniforms,r=this.pickingMaterial.uniforms;for(var n in t)"opacity"===n&&this.setProperties({transparent:this.transparent}),void 0!==e[n]&&(e[n].value.isVector3?e[n].value.copy(t[n]):e[n].value.set?e[n].value.set(t[n]):e[n].value=t[n]),void 0!==i[n]&&(i[n].value.isVector3?i[n].value.copy(t[n]):i[n].value.set?i[n].value.set(t[n]):i[n].value=t[n]),void 0!==r[n]&&(r[n].value.isVector3?r[n].value.copy(t[n]):r[n].value.set?r[n].value.set(t[n]):r[n].value=t[n])}},dy.prototype.setProperties=function(t){if(t){var e=this.material,i=this.wireframeMaterial,r=this.pickingMaterial;for(var n in t){var o=n,a=t[o];"transparent"===o?this.updateRenderOrder():"side"===o&&(a=cy(a)),e[o]=a,i[o]=a,r[o]=a}e.needsUpdate=!0,i.needsUpdate=!0,r.needsUpdate=!0}},dy.prototype.setVisibility=function(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))},dy.prototype.dispose=function(){this.material&&this.material.dispose(),this.wireframeMaterial&&this.wireframeMaterial.dispose(),this.pickingMaterial&&this.pickingMaterial.dispose(),this.geometry.dispose(),this.wireframeGeometry&&this.wireframeGeometry.dispose()},dy.prototype.toJSON=function(){var t={};for(var e in this)"group"!==e&&"wireframeGroup"!==e&&"pickingGroup"!=e&&"picking"!==e&&(t[e]=this[e]);return t},Object.defineProperties(dy.prototype,fy);var my=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,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()}return i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t}(dy),gy=function(t){function e(){t.apply(this,arguments),this.isSurface=!0}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(my);function vy(t){t.visible=!0}function yy(t){t.visible=!1}var by=function(t){this.group=new ya,this.wireframeGroup=new ya,this.pickingGroup=new ya,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 ya,this.wireframeGroup=new ya,this.pickingGroup=new ya,this.matrix=t.matrix;var 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},xy={matrix:{configurable:!0},pickable:{configurable:!0},parameters:{configurable:!0}};xy.matrix.set=function(t){dy.prototype.setMatrix.call(this,t)},xy.matrix.get=function(){return this.group.matrix.clone()},xy.pickable.get=function(){return!!this.picking&&!this.parameters.disablePicking},xy.parameters.get=function(){return this.buffer.parameters},by.prototype.getParameters=function(){var t=Object.assign({},this.buffer.parameters);return t.side=this.side,t},by.prototype.getMesh=function(t){var 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 ya).add(i,e)},by.prototype.getWireframeMesh=function(){return this.buffer.getWireframeMesh()},by.prototype.getPickingMesh=function(){return this.getMesh(!0)},by.prototype.setAttributes=function(t){this.buffer.setAttributes(t)},by.prototype.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(this.frontMeshes.forEach(vy),this.backMeshes.forEach(yy)):"back"===t.side?(this.frontMeshes.forEach(yy),this.backMeshes.forEach(vy)):"double"===t.side&&(this.frontMeshes.forEach(vy),this.backMeshes.forEach(vy)),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)},by.prototype.setVisibility=function(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))},by.prototype.dispose=function(){this.frontBuffer.dispose(),this.backBuffer.dispose()},by.prototype.toJSON=function(){var t={};for(var e in this)["side","size","visible","matrix","parameters"].includes(e)&&(t[e]=this[e]);return t},Object.defineProperties(by.prototype,xy),rd.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}"),rd.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}");var _y=function(t){function e(){t.apply(this,arguments),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag"}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e}(dy),wy=function(r){function t(t,e,i){r.call(this,t,e,i),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 ay?(this.surface=void 0,this.volume=t):(this.surface=t,this.volume=void 0),this.boxCenter=new ri,this.__boxCenter=new ri,this.box=new Pi,this.__box=new Pi,this._position=new ri,this.setBox=function(){this._position.copy(e.translationGroup.position).negate(),this._position.equals(this.boxCenter)||this.setParameters({boxCenter:this._position})},this.toBePrepared=!0,this.viewer.signals.ticked.add(this.setBox,this),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"uniform"),e.colorValue=bl(e.colorValue,14540253),this.isolevelType=bl(e.isolevelType,"sigma"),this.isolevel=bl(e.isolevel,2),this.negateIsolevel=bl(e.negateIsolevel,!1),this.isolevelScroll=bl(e.isolevelScroll,!1),this.smooth=bl(e.smooth,0),this.background=bl(e.background,!1),this.opaqueBack=bl(e.opaqueBack,!0),this.boxSize=bl(e.boxSize,0),this.colorVolume=bl(e.colorVolume,void 0),this.contour=bl(e.contour,!1),this.useWorker=bl(e.useWorker,!0),this.wrap=bl(e.wrap,!1),r.prototype.init.call(this,e),this.build()},t.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},t.prototype.prepare=function(e){var t,i=this;if(this.volume)if(t="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,this.negateIsolevel&&(t*=-1),!this.surface||this.__isolevel!==t||this.__smooth!==this.smooth||this.__contour!==this.contour||this.__wrap!==this.wrap||this.__boxSize!==this.boxSize||0<this.boxSize&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=t,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 r=function(t){i.surface=t,e()};this.useWorker?this.volume.getSurfaceWorker(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap,r):r(this.volume.getSurface(t,this.smooth,this.boxCenter,this.boxSize,this.contour,this.wrap))}else e();else e()},t.prototype.create=function(){var t,e={position:this.surface.getPosition(),color:this.surface.getColor(this.getColorParams()),index:this.surface.getIndex()};if(this.contour)t=new _y(e,this.getBufferParams({wireframe:!1}));else{Object.assign(e,{normal:this.surface.getNormal(),picking:this.surface.getPicking()});var i=new gy(e,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));t=new by(i)}this.bufferList.push(t)},t.prototype.update=function(t){if(0!==this.bufferList.length){var 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)})}},t.prototype.setParameters=function(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),r.prototype.setParameters.call(this,t,e,i),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||0<this.boxSize&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!this.contour}),this},t.prototype.getColorParams=function(){var t=r.prototype.getColorParams.call(this);return t.volume=this.colorVolume,t},t.prototype.dispose=function(){this.viewer.signals.ticked.remove(this.setBox,this),r.prototype.dispose.call(this)},t}(sm),Sy=function(){};Sy.zoomScroll=function(t,e){t.trackballControls.zoom(e)},Sy.clipNearScroll=function(t,e){var i=t.getParameters();t.setParameters({clipNear:i.clipNear+e/10})},Sy.focusScroll=function(t,e){var i=2*t.getParameters().clipNear,r=Math.sign(e)*function(t,e,i){if(e<t)return t;var r=t/e;return((2*i-e)*r+(2*e-3*i))*r*r+i}((100-i)/10,5,.2);t.setFocus(i+r)},Sy.zoomFocusScroll=function(t,e){t.trackballControls.zoom(e);var i=t.viewer.camera.position.z;t.setFocus(100-Math.abs(i/8))},Sy.isolevelScroll=function(t,e){var r=Math.sign(e)/10;t.eachRepresentation(function(t,e){if(t.repr instanceof wy){var i=t.getParameters();i.isolevelScroll&&t.setParameters({isolevel:i.isolevel+r})}})},Sy.panDrag=function(t,e,i){t.trackballControls.pan(e,i)},Sy.rotateDrag=function(t,e,i){t.trackballControls.rotate(e,i)},Sy.zRotateDrag=function(t,e,i){t.trackballControls.zRotate(e,i)},Sy.zoomDrag=function(t,e,i){t.trackballControls.zoom((e+i)/-2)},Sy.zoomFocusDrag=function(t,e,i){t.trackballControls.zoom((e+i)/-2);var r=t.viewer.camera.position.z;t.setFocus(100-Math.abs(r/8))},Sy.panComponentDrag=function(t,e,i){t.trackballControls.panComponent(e,i)},Sy.panAtomDrag=function(t,e,i){t.trackballControls.panAtom(e,i)},Sy.rotateComponentDrag=function(t,e,i){t.trackballControls.rotateComponent(e,i)},Sy.movePick=function(t,e){e&&t.animationControls.move(e.position.clone())},Sy.tooltipPick=function(t,e){var i=t.tooltip;if(t.getParameters().tooltip&&e){var r=e.mouse.position;i.innerText=e.getLabel(),i.style.bottom=window.innerHeight-r.y+3+"px",i.style.left=r.x+3+"px",i.style.display="block"}else i.style.display="none"};var Ay={default:[["scroll",Sy.zoomScroll],["scroll-shift",Sy.focusScroll],["scroll-ctrl",Sy.isolevelScroll],["scroll-shift-ctrl",Sy.zoomFocusScroll],["drag-left",Sy.rotateDrag],["drag-right",Sy.panDrag],["drag-ctrl-left",Sy.panDrag],["drag-ctrl-right",Sy.zRotateDrag],["drag-shift-left",Sy.zoomDrag],["drag-middle",Sy.zoomFocusDrag],["drag-ctrl-shift-right",Sy.panComponentDrag],["drag-ctrl-shift-left",Sy.rotateComponentDrag],["clickPick-right",Sy.measurePick=function(t,e){if(e&&(e.atom||e.bond)){var i=e.atom||e.closestBondAtom;e.component.measurePick(i)}else t.measureClear()}],["clickPick-ctrl-left",Sy.measurePick],["clickPick-middle",Sy.movePick],["clickPick-left",Sy.movePick],["hoverPick",Sy.tooltipPick]],pymol:[["drag-left",Sy.rotateDrag],["drag-middle",Sy.panDrag],["drag-right",Sy.zoomDrag],["drag-shift-right",Sy.focusScroll],["clickPick-ctrl+shift-middle",Sy.movePick],["hoverPick",Sy.tooltipPick]],coot:[["scroll",Sy.isolevelScroll],["drag-left",Sy.rotateDrag],["drag-middle",Sy.panDrag],["drag-ctrl-left",Sy.panDrag],["drag-right",Sy.zoomFocusDrag],["drag-ctrl-right",Sy.focusScroll],["clickPick-middle",Sy.movePick],["hoverPick",Sy.tooltipPick]],astexviewer:[["drag-left",Sy.rotateDrag],["drag-ctrl-left",Sy.panDrag],["drag-shift-left",Sy.zoomDrag],["scroll",Sy.focusScroll],["clickPick-middle",Sy.movePick],["hoverPick",Sy.tooltipPick]]};function My(t){var e=t.split(/[-+]/),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");var r=0;e.includes("alt")&&(r+=1),e.includes("ctrl")&&(r+=2),e.includes("meta")&&(r+=4),e.includes("shift")&&(r+=8);var n=0;return e.includes("left")&&(n+=1),e.includes("right")&&(n+=2),e.includes("middle")&&(n+=4),[i,r,n]}var Ey=function(t,e){void 0===e&&(e={}),this.stage=t,this.actionList=[],this.mouse=t.mouseObserver,this.disabled=e.disabled||!1,this.preset(e.preset||"default")};Ey.prototype.run=function(e){for(var i=this,r=[],t=arguments.length-1;0<t--;)r[t]=arguments[t+1];if(!this.disabled){var n=this.mouse.key||0,o=this.mouse.buttons||0;this.actionList.forEach(function(t){t.type===e&&t.key===n&&t.button===o&&t.callback.apply(t,[i.stage].concat(r))})}},Ey.prototype.add=function(t,e){var i=My(t),r=i[0],n=i[1],o=i[2];this.actionList.push({type:r,key:n,button:o,callback:e})},Ey.prototype.remove=function(t,e){var i=t.includes("*"),r=My(t),n=r[0],o=r[1],a=r[2],s=this.actionList.filter(function(t){return!((t.type===n||i&&""===n)&&(t.key===o||i&&0===o)&&(t.button===a||i&&0===a)&&(t.callback===e||void 0===e))});this.actionList=s},Ey.prototype.preset=function(t){var e=this;this.clear(),(Ay[t]||[]).forEach(function(t){return e.add(t[0],t[1])})},Ey.prototype.clear=function(){this.actionList.length=0};var Py=function(){};Py.autoView=function(t){t.autoView(1e3)},Py.toggleAnimations=function(t){t.animationControls.toggle()},Py.toggleRock=function(t){t.toggleRock()};var Ty={default:[["i",Py.toggleSpin=function(t){t.toggleSpin()}],["k",Py.toggleRock],["p",Py.toggleAnimations],["a",Py.toggleAntialiasing=function(t){var e=t.getParameters();t.setParameters({sampleLevel:-1===e.sampleLevel?0:-1})}],["r",Py.autoView]]},Cy=function(t,e){void 0===e&&(e={}),this.stage=t,this.actionList=[],this.disabled=e.disabled||!1,this.preset(e.preset||"default")};Cy.prototype.run=function(e){var i=this;this.disabled||this.actionList.forEach(function(t){t.key===e&&t.callback(i.stage)})},Cy.prototype.add=function(t,e){this.actionList.push({key:t,callback:e})},Cy.prototype.remove=function(e,i){var t=this.actionList.filter(function(t){return!(t.key===e&&(t.callback===i||void 0===i))});this.actionList=t},Cy.prototype.preset=function(t){var e=this;this.clear(),(Ty[t]||[]).forEach(function(t){return e.add(t[0],t[1])})},Cy.prototype.clear=function(){this.actionList.length=0};var Iy=function(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)};Iy.prototype._onClick=function(t,e){var i=this.stage.pickingControls.pick(t,e);this.stage.signals.clicked.dispatch(i),this.controls.run("clickPick",i)},Iy.prototype._onHover=function(t,e){var 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)},Iy.prototype.dispose=function(){this.mouse.signals.clicked.remove(this._onClick,this),this.mouse.signals.hovered.remove(this._onHover,this)};var Oy=function(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)};Oy.prototype._onMove=function(){this.stage.tooltip.style.display="none"},Oy.prototype._onScroll=function(t){this.controls.run("scroll",t)},Oy.prototype._onDrag=function(t,e){this.controls.run("drag",t,e)},Oy.prototype._onClick=function(t,e){this.controls.run("click",t,e)},Oy.prototype._onDblclick=function(t,e){this.controls.run("doubleClick",t,e)},Oy.prototype._onHover=function(t,e){this.controls.run("hover",t,e)},Oy.prototype.dispose=function(){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)};var Ly=function(t){this.stage=t,this.viewer=t.viewer,this.animationControls=t.animationControls,this.viewer.signals.ticked.add(this._onTick,this)};Ly.prototype._onTick=function(t){this.animationControls.run(t)},Ly.prototype.dispose=function(){this.viewer.signals.ticked.remove(this._onTick,this)};var Ry=!!Vp&&{passive:!0},Dy=function(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,Ry),this.domElement.addEventListener("keydown",this._onKeydown),this.domElement.addEventListener("keyup",this._onKeyup),this.domElement.addEventListener("keypress",this._onKeypress)};Dy.prototype._onKeydown=function(){},Dy.prototype._onKeyup=function(){},Dy.prototype._onKeypress=function(t){var e;e="key"in KeyboardEvent.prototype?t.key:String.fromCharCode(t.which||t.keyCode),this.controls.run(e)},Dy.prototype._focusDomElement=function(){this.domElement.focus()},Dy.prototype.dispose=function(){this.domElement.removeEventListener("mousedown",this._focusDomElement),this.domElement.removeEventListener("touchstart",this._focusDomElement,Ry),this.domElement.removeEventListener("keydown",this._onKeypress),this.domElement.removeEventListener("keyup",this._onKeypress),this.domElement.removeEventListener("keypress",this._onKeypress)};var ky=function(t,e,i,r){void 0===r&&(r={}),this.component=t,this.position=e,this.offsetX=bl(r.offsetX,0),this.offsetY=bl(r.offsetY,0),this.visible=bl(r.visible,!0),this.stage=t.stage,this.viewer=t.stage.viewer,this._viewerPosition=new ri,this._updateViewerPosition(),this._canvasPosition=new ti,this._cameraPosition=new ri,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(i),this.updateVisibility(),this.viewer.signals.rendered.add(this._update,this),this.component.signals.matrixChanged.add(this._updateViewerPosition,this)};ky.prototype.setContent=function(t){var 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{var i=document.createElement("div");i.innerText=t,Object.assign(i.style,{backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.element.appendChild(i)}this._clientRect=this.element.getBoundingClientRect(),"none"===e&&(this.element.style.display=e)},ky.prototype.setVisibility=function(t){this.visible=t,this.updateVisibility()},ky.prototype.getVisibility=function(){return this.visible&&this.component.parameters.visible},ky.prototype.updateVisibility=function(){this.element.style.display=this.getVisibility()?"block":"none"},ky.prototype._updateViewerPosition=function(){this._viewerPosition.copy(this.position).applyMatrix4(this.component.matrix)},ky.prototype._update=function(){if(this.getVisibility()){var 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)t.display="none";else{t.display="block";var n=this._cameraPosition.length(),o=this.viewer.scene.fog;t.opacity=(1-Zl(o.near,o.far,n)).toString(),t.zIndex=Math.round(100*(o.far-n)).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"}}},ky.prototype.dispose=function(){this.viewer.wrapper.removeChild(this.element),this.viewer.signals.ticked.remove(this._update,this),this.component.signals.matrixChanged.remove(this._updateViewerPosition,this)};var By=new ei,Ny=new ri,Fy=new ii,zy=function(t){this.component=t,this.signals={changed:new op},this.stage=t.stage,this.viewer=t.stage.viewer},Uy={position:{configurable:!0},rotation:{configurable:!0}};Uy.position.get=function(){return this.component.position},Uy.rotation.get=function(){return this.component.quaternion},zy.prototype.changed=function(){this.component.updateMatrix(),this.viewer.requestRender(),this.signals.changed.dispatch()},zy.prototype.spin=function(t,e){By.getInverse(this.viewer.rotationGroup.matrix),Ny.copy(kl(t)).applyMatrix4(By),By.extractRotation(this.component.transform),By.premultiply(this.viewer.rotationGroup.matrix),By.getInverse(By),Ny.copy(kl(t)),Ny.applyMatrix4(By),By.makeRotationAxis(Ny,e),Fy.setFromRotationMatrix(By),this.component.quaternion.premultiply(Fy),this.changed()},Object.defineProperties(zy.prototype,Uy);var jy={"":"",vdw:"by vdW radius",covalent:"by covalent radius",sstruc:"by secondary structure",bfactor:"by bfactor",size:"size",data:"data",explicit:"explicit"},Gy=function(t){void 0===t&&(t={}),this.max=10,this.type=bl(t.type,"size"),this.scale=bl(t.scale,1),this.size=bl(t.size,1),this.data=bl(t.data,{})};Gy.prototype.atomRadius=function(t){var 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":var i=t.sstruc;e="h"===i?.25:"g"===i?.25:"i"===i?.25:"e"===i?.25:"b"===i?.25:Og.includes(t.atomname)?.4:.1;break;case"data":e=bl(this.data[t.index],1);break;case"explicit":null===(e=t.radius)&&(e=this.size);break;default:e=this.size}return Math.min(e*this.scale,this.max)},Gy.types=jy;var Vy=new ri(-1,-1,-1),Hy=new ei,$y=function(t){var e=t.rows,i=e/3,r=new kv(e,3),n=new kv(3,3),o=new kv(1,3),a=new kv(3,3),s=new kv(3,3),c=zv(t);Uv(t,c),Bv(r,t),Nv(n,r,r),Hv(n,o,a,s);var u=new ri(c[0],c[1],c[2]),h=new ri(a.data[0],a.data[3],a.data[6]),l=new ri(a.data[1],a.data[4],a.data[7]),p=new ri(a.data[2],a.data[5],a.data[8]),d=h.clone().multiplyScalar(Math.sqrt(o.data[0]/i)),f=l.clone().multiplyScalar(Math.sqrt(o.data[1]/i)),m=p.clone().multiplyScalar(Math.sqrt(o.data[2]/i));this.begA=u.clone().sub(d),this.endA=u.clone().add(d),this.begB=u.clone().sub(f),this.endB=u.clone().add(f),this.begC=u.clone().sub(m),this.endC=u.clone().add(m),this.center=u,this.vecA=d,this.vecB=f,this.vecC=m,this.normVecA=h,this.normVecB=l,this.normVecC=p};$y.prototype.getBasisMatrix=function(t){void 0===t&&(t=new ei);var e=t;return e.makeBasis(this.normVecB,this.normVecA,this.normVecC),e.determinant()<0&&e.scale(Vy),e},$y.prototype.getRotationQuaternion=function(t){void 0===t&&(t=new ii);var e=t;return e.setFromRotationMatrix(this.getBasisMatrix(Hy)),e.inverse()},$y.prototype.getProjectedScaleForAtoms=function(t){var s=-1/0,c=-1/0,u=-1/0,h=-1/0,l=-1/0,p=-1/0,d=new ri,f=new ri,m=this.center,g=this.normVecA,v=this.normVecB,y=this.normVecC;return t.eachAtom(function(t){lm(d.copy(t),g,m);var e=f.subVectors(d,m).normalize().dot(g),i=d.distanceTo(m);0<e?s<i&&(s=i):c<i&&(c=i),lm(d.copy(t),v,m);var r=f.subVectors(d,m).normalize().dot(v),n=d.distanceTo(m);0<r?u<n&&(u=n):h<n&&(h=n),lm(d.copy(t),y,m);var o=f.subVectors(d,m).normalize().dot(y),a=d.distanceTo(m);0<o?l<a&&(l=a):p<a&&(p=a)}),{d1a:s,d2a:u,d3a:l,d1b:-c,d2b:-h,d3b:-p}};var Wy=function(t,e,i,r){this.volume=t,this.setFilter(e,i,r)},Xy={header:{configurable:!0},matrix:{configurable:!0},normalMatrix:{configurable:!0},inverseMatrix:{configurable:!0},center:{configurable:!0},boundingBox:{configurable:!0},min:{configurable:!0},max:{configurable:!0},mean:{configurable:!0},rms:{configurable:!0}};Xy.header.get=function(){return this.volume.header},Xy.matrix.get=function(){return this.volume.matrix},Xy.normalMatrix.get=function(){return this.volume.normalMatrix},Xy.inverseMatrix.get=function(){return this.volume.inverseMatrix},Xy.center.get=function(){return this.volume.center},Xy.boundingBox.get=function(){return this.volume.boundingBox},Xy.min.get=function(){return this.volume.min},Xy.max.get=function(){return this.volume.max},Xy.mean.get=function(){return this.volume.mean},Xy.rms.get=function(){return this.volume.rms},Wy.prototype._getFilterHash=function(t,e,i){return JSON.stringify([t,e,i])},Wy.prototype.setFilter=function(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=bl(e,1/0),i=bl(i,!1);var r=this.volume.data,n=this.volume.position,o=this.volume.atomindex,a=this._getFilterHash(t,e,i);if(a!==this._filterHash){if(t===-1/0&&e===1/0)this.data=r,this.position=n,this.atomindex=o;else{var s=r.length;this._dataBuffer||(this._dataBuffer=new ArrayBuffer(4*s),this._positionBuffer=new ArrayBuffer(3*s*4),o&&(this._atomindexBuffer=new ArrayBuffer(4*s)));var c,u=new Float32Array(this._dataBuffer),h=new Float32Array(this._positionBuffer);o&&(c=new Uint32Array(this._atomindexBuffer));for(var l=0,p=0;p<s;++p){var d=3*p,f=r[p];if(!i&&t<=f&&f<=e||i&&(f<t||e<f)){var m=3*l;u[l]=f,h[m+0]=n[d+0],h[m+1]=n[d+1],h[m+2]=n[d+2],o&&c&&(c[l]=o[p]),l+=1}}this.data=new Float32Array(this._dataBuffer,0,l),this.position=new Float32Array(this._positionBuffer,0,3*l),o&&(this.atomindex=new Int32Array(this._atomindexBuffer,0,l))}this._filterHash=a}},Object.defineProperties(Wy.prototype,Xy),Wy.prototype.getValueForSigma=ay.prototype.getValueForSigma,Wy.prototype.getSigmaForValue=ay.prototype.getSigmaForValue,Wy.prototype.getDataAtomindex=ay.prototype.getDataAtomindex,Wy.prototype.getDataPosition=ay.prototype.getDataPosition,Wy.prototype.getDataColor=ay.prototype.getDataColor,Wy.prototype.getDataPicking=ay.prototype.getDataPicking,Wy.prototype.getDataSize=ay.prototype.getDataSize;var qy=function(t,e){var i=eg({nodeArray1:t.atomIndex1,nodeArray2:t.atomIndex2,edgeCount:t.count,nodeCount:e});this.countArray=i.countArray,this.offsetArray=i.offsetArray,this.indexArray=i.indexArray},Yy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={_defaultFields:{configurable:!0}};return i._defaultFields.get=function(){return[["atomIndex1",1,"int32"],["atomIndex2",1,"int32"],["bondOrder",1,"int8"]]},e.prototype.addBond=function(t,e,i){this.growIfFull();var r=this.count,n=t.index,o=e.index;n<o?(this.atomIndex1[r]=n,this.atomIndex2[r]=o):(this.atomIndex2[r]=n,this.atomIndex1[r]=o),i&&(this.bondOrder[r]=i),this.count+=1},e.prototype.addBondIfConnected=function(t,e,i){return!!t.connectedTo(e)&&(this.addBond(t,e,i),!0)},Object.defineProperties(e.prototype,i),e}(Km),Zy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={_defaultFields:{configurable:!0}};return i._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"]]},e.prototype.setAltloc=function(t,e){this.altloc[t]=e.charCodeAt(0)},e.prototype.getAltloc=function(t){var e=this.altloc[t];return e?String.fromCharCode(e):""},Object.defineProperties(e.prototype,i),e}(Km),Ky=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={_defaultFields:{configurable:!0}};return i._defaultFields.get=function(){return[["chainIndex",1,"uint32"],["atomOffset",1,"uint32"],["atomCount",1,"uint16"],["residueTypeId",1,"uint16"],["resno",1,"int32"],["sstruc",1,"uint8"],["inscode",1,"uint8"]]},e.prototype.setSstruc=function(t,e){this.sstruc[t]=e.charCodeAt(0)},e.prototype.getSstruc=function(t){var e=this.sstruc[t];return e?String.fromCharCode(e):""},e.prototype.setInscode=function(t,e){this.inscode[t]=e.charCodeAt(0)},e.prototype.getInscode=function(t){var e=this.inscode[t];return e?String.fromCharCode(e):""},Object.defineProperties(e.prototype,i),e}(Km),Jy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={_defaultFields:{configurable:!0}};return i._defaultFields.get=function(){return[["entityIndex",1,"uint16"],["modelIndex",1,"uint16"],["residueOffset",1,"uint32"],["residueCount",1,"uint32"],["chainname",4,"uint8"],["chainid",4,"uint8"]]},e.prototype.setChainname=function(t,e){var i=4*t;this.chainname[i]=e.charCodeAt(0),this.chainname[i+1]=e.charCodeAt(1),this.chainname[i+2]=e.charCodeAt(2),this.chainname[i+3]=e.charCodeAt(3)},e.prototype.getChainname=function(t){for(var e="",i=0;i<4;++i){var r=this.chainname[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e},e.prototype.setChainid=function(t,e){var i=4*t;this.chainid[i]=e.charCodeAt(0),this.chainid[i+1]=e.charCodeAt(1),this.chainid[i+2]=e.charCodeAt(2),this.chainid[i+3]=e.charCodeAt(3)},e.prototype.getChainid=function(t){for(var e="",i=0;i<4;++i){var r=this.chainid[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e},Object.defineProperties(e.prototype,i),e}(Km),Qy=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={_defaultFields:{configurable:!0}};return i._defaultFields.get=function(){return[["chainOffset",1,"uint32"],["chainCount",1,"uint32"]]},Object.defineProperties(e.prototype,i),e}(Km),tb=function(t){this.polymer=t,this.size=t.residueCount};tb.prototype.getCenterIterator=function(s){void 0===s&&(s=0);var c=this.getPosition().center,u=c.length/3,h=0,e=-1,l=[new ri,new ri,new ri,new ri];return{size:u,next:function(){var t=this.get(e);return e+=1,t},get:function(t){t=Math.min(u-1,Math.max(0,t));var e=l[h%4],i=3*t;if(e.fromArray(c,i),s){for(var r=Math.min(s,t,u-t-1),n=1;n<=r;++n){var o=3*n,a=(r+1-n)/(r+1);e.x+=a*c[i-o+0]+a*c[i+o+0],e.y+=a*c[i-o+1]+a*c[i+o+1],e.z+=a*c[i-o+2]+a*c[i+o+2]}e.x/=r+1,e.y/=r+1,e.z/=r+1}return h+=1,e},reset:function(){h=0,e=-1}}},tb.prototype.getColor=function(t){var e=this.polymer,i=e.structure,r=e.residueCount,n=e.residueIndexStart,o=new Float32Array(3*r),a=t||{};a.structure=i;for(var s=Qp.getScheme(a),c=i.getResidueProxy(),u=i.getAtomProxy(),h=0;h<r;++h)c.index=n+h,u.index=c.traceAtomIndex,s.atomColorToArray(u,o,3*h);return{color:o}},tb.prototype.getPicking=function(){for(var t=this.polymer,e=t.structure,i=t.residueCount,r=t.residueIndexStart,n=new Float32Array(i),o=e.getResidueProxy(),a=0;a<i;++a)o.index=r+a,n[a]=o.traceAtomIndex;return{picking:new hv(n,e)}},tb.prototype.getSize=function(t){for(var e=this.polymer,i=e.structure,r=e.residueCount,n=e.residueIndexStart,o=new Float32Array(r),a=new Gy(t),s=i.getResidueProxy(),c=i.getAtomProxy(),u=0;u<r;++u)s.index=n+u,c.index=s.traceAtomIndex,o[u]=a.atomRadius(c);return{size:o}},tb.prototype.getPosition=function(){for(var t=this.polymer,e=t.structure,i=t.residueCount,r=i-3,n=new Float32Array(3*i),o=new Float32Array(3*i),a=new Float32Array(i),s=new Float32Array(i),c=new Float32Array(i),u=new Float32Array(i),h=new Float32Array(3*i),l=new ri,p=new ri,d=new ri,f=new ri,m=new ri,g=new ri,v=new ri,y=new ri,b=new ri,x=new ri,_=new ri,w=new ri(0,0,0),S="trace",A=e.getAtomProxy(),M=e.getAtomProxy(t.getAtomIndexByType(0,S)),E=e.getAtomProxy(t.getAtomIndexByType(1,S)),P=e.getAtomProxy(t.getAtomIndexByType(2,S)),T=0;T<r;++T){A.index=M.index,M.index=E.index,E.index=P.index,P.index=t.getAtomIndexByType(T+3,S);var C=3*T;l.subVectors(M,A),p.subVectors(E,M),d.subVectors(P,E),f.subVectors(l,p),m.subVectors(p,d),b.crossVectors(f,m).normalize(),b.toArray(o,C),0<T&&(a[T]=b.angleTo(x));var I=Math.cos(f.angleTo(m));u[T]=180/Math.PI*Math.acos(I);var O=f.length(),L=m.length();s[T]=Math.sqrt(L*O)/Math.max(2,2*(1-I)),c[T]=Math.abs(p.dot(b)),g.copy(f).multiplyScalar(s[T]/O),v.copy(m).multiplyScalar(s[T]/L),g.subVectors(M,g),v.subVectors(E,v),g.toArray(n,C+3),v.toArray(n,C+6),_.subVectors(A,w),_.toArray(h,C),x.copy(b),w.copy(g)}g.fromArray(n,3),v.fromArray(n,6),b.subVectors(g,v).normalize(),A.index=t.getAtomIndexByType(0,S),w.copy(A),y.copy(A),lm(y,b,g),y.toArray(n,0),_.subVectors(w,g),_.toArray(h,0),g.fromArray(n,3*i-6),v.fromArray(n,3*i-9),b.subVectors(g,v).normalize(),A.index=t.getAtomIndexByType(i-1,S),w.copy(A),y.copy(A),lm(y,b,g),y.toArray(n,3*i-3);for(var R=i-3;R<i;++R)g.fromArray(n,3*R),A.index=t.getAtomIndexByType(R,S),w.copy(A),_.subVectors(w,g),_.toArray(h,3*R);var D=new Float32Array(i),k=new Float32Array(i),B=new Float32Array(i),N=new Float32Array(i);D[1]=s[0],k[1]=u[0],B[1]=s[0];for(var F=2;F<i-2;++F)D[F]=.5*(s[F-2]+s[F-1]),k[F]=.5*(u[F-2]+u[F-1]),B[F]=.5*(c[F-2]+c[F-1]),g.fromArray(o,3*(F-2)),v.fromArray(o,3*(F-1)),N[F]=180/Math.PI*Math.acos(Math.cos(g.angleTo(v)));D[i-2]=s[i-4],k[i-2]=u[i-4],B[i-2]=c[i-4];var z=new Float32Array(3*i);Xd(o,z,0,0,3),Xd(o,z,0,3,3);for(var U=2;U<i-2;++U)g.fromArray(o,3*(U-2)),v.fromArray(o,3*(U-1)),b.addVectors(v,g).multiplyScalar(.5).normalize(),b.toArray(z,3*U);return Xd(o,z,3*i-12,3*i-6,3),Xd(o,z,3*i-12,3*i-3,3),{center:n,axis:z,bending:N,radius:D,rise:B,twist:k,resdir:h}};var eb=function(t){this.polymer=t,this.helixorient=new tb(t),this.position=this.helixorient.getPosition()};eb.prototype.getAxis=function(t,e,i,r,n){t=t||30,e=e||2.5,i=void 0!==i&&i;var o=this.polymer,a=o.structure,s=o.residueCount,c=o.residueIndexStart,u=this.position,h=r||{};h.structure=a;for(var l,p,d=Qp.getScheme(h),f=new Gy(n),m=0,g=0,v=[],y=[],b=[],x=[],_=[],w=[],S=[],A=[],M=[],E=new Float32Array(3*s),P=new Float32Array(3*s),T=new ri,C=new ri,I=a.getResidueProxy(),O=a.getResidueProxy(),L=a.getAtomProxy(),R=new ri,D=new ri,k=!1,B=0;B<s;++B)if(I.index=c+B,R.fromArray(u.center,3*B),B===s-1?k=!0:(O.index=c+B+1,D.fromArray(u.center,3*B+3),i&&I.sstruc!==O.sstruc?k=!0:R.distanceTo(D)>e?k=!0:u.bending[B]>t&&(k=!0)),k){if(B-m<4){m=B,k=!1;continue}L.index=I.traceAtomIndex,E=u.axis.subarray(3*m+3,3*B),P=u.center.subarray(3*m,3*B+3),l=hm(E).normalize(),p=hm(P),T.fromArray(P),lm(T,l,p),C.fromArray(P,P.length-3),lm(C,l,p),l.subVectors(C,T),l.toArray(v,g),p.toArray(y,g),T.toArray(b,g),C.toArray(x,g),d.atomColorToArray(L,_,g),w.push(L.index),S.push(f.atomRadius(L)),A.push(c+m),M.push(c+B+1-m),g+=3,m=B,k=!1}var N=new Float32Array(w);return{axis:new Float32Array(v),center:new Float32Array(y),begin:new Float32Array(b),end:new Float32Array(x),color:new Float32Array(_),picking:new hv(N,a),size:new Float32Array(S),residueOffset:A,residueCount:M}};var ib=function(t){this.scoreFunction=t,this.content=[],this.scoreFunction=t};ib.prototype.push=function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},ib.prototype.pop=function(){var t=this.content[0],e=this.content.pop();return e&&0<this.content.length&&(this.content[0]=e,this.sinkDown(0)),t},ib.prototype.peek=function(){return this.content[0]},ib.prototype.remove=function(t){for(var e=this.content.length,i=0;i<e;i++)if(this.content[i]===t){var r=this.content.pop();return void(r&&i!==e-1&&(this.content[i]=r,this.scoreFunction(r)<this.scoreFunction(t)?this.bubbleUp(i):this.sinkDown(i)))}throw new Error("Node not found.")},ib.prototype.size=function(){return this.content.length},ib.prototype.bubbleUp=function(t){for(var e=this.content[t];0<t;){var i=Math.floor((t+1)/2)-1,r=this.content[i];if(!(this.scoreFunction(e)<this.scoreFunction(r)))break;this.content[i]=e,this.content[t]=r,t=i}},ib.prototype.sinkDown=function(t){for(var e=this.content.length,i=this.content[t],r=this.scoreFunction(i),n=0;;){var o=2*(t+1),a=o-1,s=null;if(a<e){var c=this.content[a];(n=this.scoreFunction(c))<r&&(s=a)}if(o<e){var u=this.content[o];this.scoreFunction(u)<(null===s?r:n)&&(s=o)}if(null===s)break;this.content[t]=this.content[s],this.content[s]=i,t=s}};var rb=function(t,e){this.points=t,this.metric=e,this.maxDepth=0,this.currentNode=0;for(var i=t.length/3,r=new Uint32Array(i),n=0;n<i;++n)r[n]=n;this.indices=r,this.nodes=new Int32Array(4*i),this.rootIndex=this.buildTree(0,-1,0,i)};rb.prototype.buildTree=function(t,e,i,r){t>this.maxDepth&&(this.maxDepth=t);var n=r-i;if(0===n)return-1;var o=4*this.currentNode,a=this.nodes;if(this.currentNode+=1,1===n)return a[o]=i,a[o+1]=-1,a[o+2]=-1,a[o+3]=e,o;for(var s,c,u,h,l,p=this.indices,d=this.points,f=i+Math.floor(n/2),m=t%3,g=i,v=r-1;g<v;){for(h=d[3*p[u=g+v>>1]+m],c=p[u],p[u]=p[v],p[v]=c,s=l=g;s<v;++s)d[3*p[s]+m]<h&&(c=p[l],p[l]=p[s],p[s]=c,++l);if(c=p[v],p[v]=p[l],p[l]=c,f===(u=l))break;f<u?v=u-1:g=u+1}return a[o]=f,a[o+1]=this.buildTree(t+1,o,i,f),a[o+2]=this.buildTree(t+1,o,f+1,r),a[o+3]=e,o},rb.prototype.getNodeDepth=function(t){var e=this.nodes[t+3];return-1===e?0:this.getNodeDepth(e)+1},rb.prototype.nearest=function(d,f,m){var g=this,v=new ib(function(t){return-t[1]}),y=this.nodes,b=this.points,x=this.indices,_=function(t){var e,i,r=g.getNodeDepth(t)%3,n=3*x[y[t]],o=[b[n+0],b[n+1],b[n+2]],a=g.metric(d,o);function s(t,e){v.push([t,e]),v.size()>f&&v.pop()}var c=y[t+1],u=y[t+2];if(-1!==u||-1!==c){e=-1===u?c:-1===c?u:d[r]<=b[n+r]?c:u,_(e),(v.size()<f||a<v.peek()[1])&&a<=m&&s(t,a);for(var h=[],l=0;l<3;l+=1)h[l]=l===r?d[l]:b[n+l];var p=g.metric(h,o);(v.size()<f||Math.abs(p)<v.peek()[1])&&Math.abs(p)<=m&&-1!==(i=e===c?u:c)&&_(i)}else(v.size()<f||a<v.peek()[1])&&a<=m&&s(t,a)};_(this.rootIndex);for(var t=[],e=0,i=Math.min(v.size(),f);e<i;e+=1)t.push(v.content[e]);return t},rb.prototype.verify=function(t,e){void 0===e&&(e=0);var i=1;if(void 0===t&&(t=this.rootIndex),-1===t)throw new Error("node is null");var r=e%3,n=this.nodes,o=this.points,a=this.indices,s=n[t+1],c=n[t+2];if(-1!==s){if(o[3*a[n[s]]+r]>o[3*a[n[t]]+r])throw new Error("left child is > parent!");i+=this.verify(s,e+1)}if(-1!==c){if(o[3*a[n[c]]+r]<o[3*a[n[t]]+r])throw new Error("right child is < parent!");i+=this.verify(c,e+1)}return i};var nb=function(t,e){void 0===e&&(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},ob={bondHash:{configurable:!0},entity:{configurable:!0},entityIndex:{configurable:!0},modelIndex:{configurable:!0},chainIndex:{configurable:!0},residue:{configurable:!0},residueIndex:{configurable:!0},sstruc:{configurable:!0},inscode:{configurable:!0},resno:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0},residueType:{configurable:!0},atomType:{configurable:!0},residueAtomOffset:{configurable:!0},resname:{configurable:!0},hetero:{configurable:!0},atomname:{configurable:!0},number:{configurable:!0},element:{configurable:!0},vdw:{configurable:!0},covalent:{configurable:!0},x:{configurable:!0},y:{configurable:!0},z:{configurable:!0},serial:{configurable:!0},bfactor:{configurable:!0},occupancy:{configurable:!0},altloc:{configurable:!0},partialCharge:{configurable:!0},radius:{configurable:!0},formalCharge:{configurable:!0},aromatic:{configurable:!0},bondCount:{configurable:!0}};function ab(t,e){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function sb(t,e){return Math.sqrt(ab(t,e))}ob.bondHash.get=function(){return this.structure.bondHash},ob.entity.get=function(){return this.structure.entityList[this.entityIndex]},ob.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},ob.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},ob.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndex]},ob.residue.get=function(){return console.warn("residue - might be expensive"),this.structure.getResidueProxy(this.residueIndex)},ob.residueIndex.get=function(){return this.atomStore.residueIndex[this.index]},ob.residueIndex.set=function(t){this.atomStore.residueIndex[this.index]=t},ob.sstruc.get=function(){return this.residueStore.getSstruc(this.residueIndex)},ob.inscode.get=function(){return this.residueStore.getInscode(this.residueIndex)},ob.resno.get=function(){return this.residueStore.resno[this.residueIndex]},ob.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},ob.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},ob.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.residueIndex])},ob.atomType.get=function(){return this.atomMap.get(this.atomStore.atomTypeId[this.index])},ob.residueAtomOffset.get=function(){return this.residueStore.atomOffset[this.residueIndex]},ob.resname.get=function(){return this.residueType.resname},ob.hetero.get=function(){return this.residueType.hetero},ob.atomname.get=function(){return this.atomType.atomname},ob.number.get=function(){return this.atomType.number},ob.element.get=function(){return this.atomType.element},ob.vdw.get=function(){return this.atomType.vdw},ob.covalent.get=function(){return this.atomType.covalent},ob.x.get=function(){return this.atomStore.x[this.index]},ob.x.set=function(t){this.atomStore.x[this.index]=t},ob.y.get=function(){return this.atomStore.y[this.index]},ob.y.set=function(t){this.atomStore.y[this.index]=t},ob.z.get=function(){return this.atomStore.z[this.index]},ob.z.set=function(t){this.atomStore.z[this.index]=t},ob.serial.get=function(){return this.atomStore.serial[this.index]},ob.serial.set=function(t){this.atomStore.serial[this.index]=t},ob.bfactor.get=function(){return this.atomStore.bfactor[this.index]},ob.bfactor.set=function(t){this.atomStore.bfactor[this.index]=t},ob.occupancy.get=function(){return this.atomStore.occupancy[this.index]},ob.occupancy.set=function(t){this.atomStore.occupancy[this.index]=t},ob.altloc.get=function(){return this.atomStore.getAltloc(this.index)},ob.altloc.set=function(t){this.atomStore.setAltloc(this.index,t)},ob.partialCharge.get=function(){return this.atomStore.partialCharge?this.atomStore.partialCharge[this.index]:null},ob.partialCharge.set=function(t){this.atomStore.partialCharge&&(this.atomStore.partialCharge[this.index]=t)},ob.radius.get=function(){return this.atomStore.radius?this.atomStore.radius[this.index]:null},ob.radius.set=function(t){this.atomStore.radius&&(this.atomStore.radius[this.index]=t)},ob.formalCharge.get=function(){return this.atomStore.formalCharge?this.atomStore.formalCharge[this.index]:null},ob.formalCharge.set=function(t){this.atomStore.formalCharge&&(this.atomStore.formalCharge[this.index]=t)},ob.aromatic.get=function(){return this.atomStore.aromatic?this.atomStore.aromatic[this.index]:this.residueType.isAromatic(this)?1:0},ob.aromatic.set=function(t){this.atomStore.aromatic&&(this.atomStore.aromatic[this.index]=t)},ob.bondCount.get=function(){return this.bondHash.countArray[this.index]},nb.prototype.eachBond=function(t,e){e=e||this.structure._bp;for(var i=this.index,r=this.bondHash,n=r.indexArray,o=r.countArray[i],a=r.offsetArray[i],s=0;s<o;++s)e.index=n[a+s],t(e)},nb.prototype.eachBondedAtom=function(e,t){var i=t||this.structure._ap,r=this.index;this.eachBond(function(t){i.index=r!==t.atomIndex1?t.atomIndex1:t.atomIndex2,e(i)}),this.index=r},nb.prototype.hasBondTo=function(e){var i=!1;return this.eachBondedAtom(function(t){e.index===t.index&&(i=!0)}),i},nb.prototype.bondToElementCount=function(e){var i=0,t=this.index;return this.eachBondedAtom(function(t){t.number===e&&(i+=1)}),this.index=t,i},nb.prototype.hasBondToElement=function(t){return 0<this.bondToElementCount(t)},nb.prototype.isBackbone=function(){var t=this.residueType.backboneIndexList;return 0<t.length&&t.includes(this.index-this.residueAtomOffset)},nb.prototype.isPolymer=function(){if(0<this.structure.entityList.length)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},nb.prototype.isSidechain=function(){return this.isPolymer()&&!this.isBackbone()},nb.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},nb.prototype.isTrace=function(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset},nb.prototype.isHetero=function(){return 1===this.residueType.hetero},nb.prototype.isProtein=function(){return 3===this.residueType.moleculeType},nb.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},nb.prototype.isRna=function(){return 4===this.residueType.moleculeType},nb.prototype.isDna=function(){return 5===this.residueType.moleculeType},nb.prototype.isWater=function(){return 1===this.residueType.moleculeType},nb.prototype.isIon=function(){return 2===this.residueType.moleculeType},nb.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},nb.prototype.isHelix=function(){return lg.includes(this.sstruc)},nb.prototype.isSheet=function(){return pg.includes(this.sstruc)},nb.prototype.isTurn=function(){return dg.includes(this.sstruc)&&this.isProtein()},nb.prototype.isBonded=function(){return 0!==this.bondHash.countArray[this.index]},nb.prototype.isRing=function(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]},nb.prototype.isAromatic=function(){return 1===this.aromatic},nb.prototype.isMetal=function(){return this.atomType.isMetal()},nb.prototype.isNonmetal=function(){return this.atomType.isNonmetal()},nb.prototype.isMetalloid=function(){return this.atomType.isMetalloid()},nb.prototype.isHalogen=function(){return this.atomType.isHalogen()},nb.prototype.isDiatomicNonmetal=function(){return this.atomType.isDiatomicNonmetal()},nb.prototype.isPolyatomicNonmetal=function(){return this.atomType.isPolyatomicNonmetal()},nb.prototype.isAlkaliMetal=function(){return this.atomType.isAlkaliMetal()},nb.prototype.isAlkalineEarthMetal=function(){return this.atomType.isAlkalineEarthMetal()},nb.prototype.isNobleGas=function(){return this.atomType.isNobleGas()},nb.prototype.isTransitionMetal=function(){return this.atomType.isTransitionMetal()},nb.prototype.isPostTransitionMetal=function(){return this.atomType.isPostTransitionMetal()},nb.prototype.isLanthanide=function(){return this.atomType.isLanthanide()},nb.prototype.isActinide=function(){return this.atomType.isActinide()},nb.prototype.getDefaultValence=function(){return this.atomType.getDefaultValence()},nb.prototype.getValenceList=function(){return this.atomType.getValenceList()},nb.prototype.getOuterShellElectronCount=function(){return this.atomType.getOuterShellElectronCount()},nb.prototype.distanceTo=function(t){var e=this.atomStore,i=t.atomStore,r=this.index,n=t.index,o=e.x[r]-i.x[n],a=e.y[r]-i.y[n],s=e.z[r]-i.z[n],c=o*o+a*a+s*s;return Math.sqrt(c)},nb.prototype.connectedTo=function(t){var e=this.atomStore,i=t.atomStore,r=this.index,n=t.index;if(e.altloc&&i.altloc){var o=e.altloc[r],a=i.altloc[n];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=e.x[r]-i.x[n],c=e.y[r]-i.y[n],u=e.z[r]-i.z[n],h=s*s+c*c+u*u;if(h<48&&this.isCg())return!0;if(isNaN(h))return!1;var l=this.covalent+t.covalent,p=l+.3,d=l-.5;return h<p*p&&d*d<h},nb.prototype.positionFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this},nb.prototype.positionToArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var 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},nb.prototype.positionToVector3=function(t){return void 0===t&&(t=new ri),t.x=this.x,t.y=this.y,t.z=this.z,t},nb.prototype.positionFromVector3=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},nb.prototype.positionAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},nb.prototype.positionSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},nb.prototype.getResidueBonds=function(t){void 0===t&&(t=!1);var e,i,r,n,o=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,u=s.atomIndices2;for(t||(n=[]),e=c.indexOf(a);-1!==e;){if(r=u[e]+o,!n)return r;n.push(r),e=c.indexOf(a,e+1)}for(i=u.indexOf(a);-1!==i;){if(r=c[i]+o,!n)return r;n.push(r),i=u.indexOf(a,i+1)}return n},nb.prototype.qualifiedName=function(t){void 0===t&&(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),1<this.structure.modelStore.count&&(e+="/"+this.modelIndex),e},nb.prototype.clone=function(){return new nb(this.structure,this.index)},nb.prototype.toObject=function(){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(nb.prototype,ob);var cb=new Float32Array(3),ub=function(t,e){void 0===e&&(e=!1),de.Debug&&Yp.time("Kdtree build");var i=e?ab:sb,r=new Float32Array(3*t.atomCount),n=new Uint32Array(t.atomCount),o=0;t.eachAtom(function(t){r[o+0]=t.x,r[o+1]=t.y,r[o+2]=t.z,n[o/3]=t.index,o+=3}),this.atomIndices=n,this.points=r,this.kdtree=new rb(r,i),de.Debug&&Yp.timeEnd("Kdtree build")};ub.prototype.nearest=function(t,e,i){t instanceof ri?t.toArray(cb):t instanceof nb&&t.positionToArray(cb);for(var r=this.kdtree.nearest(cb,e,i),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,s=[],c=0,u=r.length;c<u;++c){var h=r[c],l=h[0],p=h[1];s.push({index:a[n[o[l]]],distance:p})}return s};var hb={" ":"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"},lb={"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":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},pb=/^[1-9]$/;function db(t){var e="";return 0<t.length&&(e=":"+Cl(t).join(" OR :")),new Lp(e)}var fb=function(t){void 0===t&&(t=""),this.name=t,this.partList=[]},mb={type:{configurable:!0}};mb.type.get=function(){return"Assembly"},fb.prototype.addPart=function(t,e){var i=new gb(t,e);return this.partList.push(i),i},fb.prototype.getAtomCount=function(i){return this.partList.reduce(function(t,e){return t+e.getAtomCount(i)},0)},fb.prototype.getResidueCount=function(i){return this.partList.reduce(function(t,e){return t+e.getResidueCount(i)},0)},fb.prototype.getInstanceCount=function(){var e=0;return this.partList.forEach(function(t){e+=t.matrixList.length}),e},fb.prototype.isIdentity=function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new ei).equals(e.matrixList[0]))return!1;var i=[];return t.eachChain(function(t){i.push(t.chainname)}),i=Cl(i),e.chainList.length===i.length},fb.prototype.getBoundingBox=function(i){var r=new Pi;return this.partList.forEach(function(t){var e=t.getBoundingBox(i);r.expandByPoint(e.min),r.expandByPoint(e.max)}),r},fb.prototype.getCenter=function(t){return this.getBoundingBox(t).getCenter(new ri)},fb.prototype.getSelection=function(){var e=[];return this.partList.forEach(function(t){e=e.concat(t.chainList)}),db(e)},Object.defineProperties(fb.prototype,mb);var gb=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=[]),this.matrixList=t,this.chainList=e},vb={type:{configurable:!0}};vb.type.get=function(){return"AssemblyPart"},gb.prototype._getCount=function(t,e){var i=this,r=0;return t.eachChain(function(t){(0===i.chainList.length||i.chainList.includes(t.chainname))&&(r+=t[e])}),this.matrixList.length*r},gb.prototype.getAtomCount=function(t){return this._getCount(t,"atomCount")},gb.prototype.getResidueCount=function(t){return this._getCount(t,"residueCount")},gb.prototype.getBoundingBox=function(t){var e=new Pi,i=new Pi,r=this.getSelection(),n=t.getBoundingBox(r);return this.matrixList.forEach(function(t){i.copy(n).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)}),e},gb.prototype.getSelection=function(){return db(this.chainList)},gb.prototype.getView=function(t){var e=this.getSelection();return e?t.getView(e):t},gb.prototype.getInstanceList=function(){for(var t=[],e=0,i=this.matrixList.length;e<i;++e)t.push({id:e+1,name:e,matrix:this.matrixList[e]});return t},Object.defineProperties(gb.prototype,vb);var yb=function(t){this.structure=t,this.currentModelindex=null,this.currentChainid=null,this.currentResname=null,this.currentResno=null,this.currentInscode=void 0,this.currentHetero=null,this.previousResname="",this.previousHetero=null,this.ai=-1,this.ri=-1,this.ci=-1,this.mi=-1};function bb(t,e){if(e){de.Debug&&Yp.time("assignSecondaryStructure");var i=[];t.eachModel(function(t){t.eachChain(function(t){i.push(t.chainname)})});var c=i.slice().sort(),u=[];c.forEach(function(t){u.push(i.indexOf(t))});var l=e.helices.filter(function(t){return 0<=Pl(c,t[0])});l.sort(function(t,e){var i=t[0],r=e[0],n=t[1],o=e[1];if(i===r)return n===o?0:n<o?-1:1;var a=Pl(c,i),s=Pl(c,r);return u[a]<u[s]?-1:1});var p=t.residueStore;t.eachModel(function(t){var a=0,s=l.length;if(0!==s){var c=l[a],u=!1,h=!1;t.eachChain(function(t){var e=!1;if(t.chainname===c[0])for(var i=t.residueCount,r=t.residueOffset,n=r+i,o=r;o<n;++o)if(p.resno[o]===c[1]&&p.getInscode(o)===c[2]&&(u=!0),u&&(p.sstruc[o]=c[6],p.resno[o]===c[4]&&p.getInscode(o)===c[5]&&(u=!1,(a+=1)<s?(o=r-1,c=l[a],e=t.chainname!==c[0]):h=!0)),e||h)return})}});var d=e.sheets.filter(function(t){return 0<=Pl(c,t[0])});d.sort(function(t,e){var i=t[0],r=e[0];if(i===r)return 0;var n=Pl(c,i),o=Pl(c,r);return u[n]<u[o]?-1:1});var f="e".charCodeAt(0);t.eachModel(function(t){var a=0,s=d.length;if(0!==s){var c=d[a],u=!1,h=!1;t.eachChain(function(t){var e=!1;if(t.chainname===c[0])for(var i=t.residueCount,r=t.residueOffset,n=r+i,o=r;o<n;++o)if(p.resno[o]===c[1]&&p.getInscode(o)===c[2]&&(u=!0),u&&(p.sstruc[o]=f,p.resno[o]===c[4]&&p.getInscode(o)===c[5]&&(u=!1,(a+=1)<s?(o=r-1,c=d[a],e=t.chainname!==c[0]):h=!0)),e||h)return})}}),de.Debug&&Yp.timeEnd("assignSecondaryStructure")}}yb.prototype.addResidueType=function(t){for(var e=this.structure.atomStore,i=this.structure.residueStore,r=this.structure.residueMap,n=i.atomCount[t],o=i.atomOffset[t],a=new Array(n),s=0;s<n;++s)a[s]=e.atomTypeId[o+s];i.residueTypeId[t]=r.add(this.previousResname,a,this.previousHetero)},yb.prototype.addAtom=function(t,e,i,r,n,o,a,s){var c=this.structure.atomStore,u=this.structure.residueStore,h=this.structure.chainStore,l=this.structure.modelStore,p=!1,d=!1,f=!1;this.currentModelindex!==t?(f=d=p=!0,this.mi+=1,this.ci+=1,this.ri+=1):this.currentChainid!==i?(f=d=!0,this.ci+=1,this.ri+=1):this.currentResno===n&&this.currentResname===r&&this.currentInscode===s||(f=!0,this.ri+=1),this.ai+=1,p&&(l.growIfFull(),l.chainOffset[this.mi]=this.ci,l.chainCount[this.mi]=0,l.count+=1,h.modelIndex[this.ci]=this.mi),d&&(h.growIfFull(),h.setChainname(this.ci,e),h.setChainid(this.ci,i),h.residueOffset[this.ci]=this.ri,h.residueCount[this.ci]=0,h.count+=1,h.modelIndex[this.ci]=this.mi,l.chainCount[this.mi]+=1,u.chainIndex[this.ri]=this.ci),f&&(this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,0<this.ri&&this.addResidueType(this.ri-1),u.growIfFull(),u.resno[this.ri]=n,void 0!==a&&(u.sstruc[this.ri]=a.charCodeAt(0)),void 0!==s&&(u.inscode[this.ri]=s.charCodeAt(0)),u.atomOffset[this.ri]=this.ai,u.atomCount[this.ri]=0,u.count+=1,u.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,u.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=i,this.currentResname=r,this.currentResno=n,this.currentInscode=s,this.currentHetero=o},yb.prototype.finalize=function(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,-1<this.ri&&this.addResidueType(this.ri)};var xb,_b=(xb=function(t,e,i,r){for(var n=t.structure,o=t.residueIndexStart,a=n.getResidueProxy(),s=n.getResidueProxy(),c=n.getAtomProxy(),u=n.getAtomProxy(),h=Math.max(0,e-2);h<=e;++h)for(var l=2;l<5;++l)if(!(h+l>=t.residueCount)){a.index=o+h,s.index=o+h+l,c.index=a.traceAtomIndex,u.index=s.traceAtomIndex;var p=c.distanceTo(u);if(Math.abs(p-i[l-2])>r)return!1}return!0},function(t){de.Debug&&Yp.time("calculateSecondaryStructure"),t.eachPolymer(function(t){if(!(t.residueCount<4)){if(t.isCg())!function(t){for(var e=t.residueStore,i=t.residueIndexStart,r=new eb(t).position,n=new ri,o=new ri,a=0,s=t.residueCount;a<s;++a){n.fromArray(r.center,3*a),o.fromArray(r.center,3*a+3);var c=n.distanceTo(o);c<2&&1<c&&r.bending[a]<20&&(e.sstruc[i+a]="h".charCodeAt(0),e.sstruc[i+a+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){for(var e=t.residueStore,i=t.residueIndexStart,r=0,n=t.residueCount;r<n;++r){var o="c";xb(t,r,[5.45,5.18,6.37],2.1)?o="h":xb(t,r,[6.1,10.4,13],1.42)&&(o="e"),e.sstruc[i+r]=o.charCodeAt(0)}}(t)}var e,i=0;t.eachResidue(function(t){t.sstruc===e?i+=1:(1===i&&(t.index-=1,t.sstruc="c"),i=1,e=t.sstruc)})}}),de.Debug&&Yp.timeEnd("calculateSecondaryStructure")}),wb="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function Sb(t){for(var e=wb.length,i=t,r=0,n=wb[i%e];e<=i;)i=Math.floor(i/e),n+=wb[i%e],r+=1;return 5<=r&&Yp.warn("chainname overflow"),n}function Ab(t,a){void 0===a&&(a=!1),de.Debug&&Yp.time("calculateChainnames");var e=!0;if(t.eachChain(function(t){t.chainname&&(e=!1)}),e){var s=t.modelStore,c=t.chainStore,u=t.residueStore,h=t.getAtomProxy(),l=t.getAtomProxy(),p=0,d=0,f=0,m=0,g=[];1===u.count?g.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):t.eachResidueN(2,function(t,e){var i=!1,r=t.backboneType,n=e.backboneType,o=og;m=t.index,t.modelIndex!==e.modelIndex?i=!0:t.moleculeType!==e.moleculeType?i=!0:r!==o&&r===n&&(h.index=t.backboneEndAtomIndex,l.index=e.backboneStartAtomIndex,i=a?!h.hasBondTo(l):!h.connectedTo(l)),i||e.index!==u.count-1||(i=!0,m=e.index),i&&(g.push({mIndex:d,chainname:Sb(p),rStart:f,rCount:m-f+1}),p+=1,t.modelIndex!==e.modelIndex&&(p=0,d+=1),e.index===u.count-1&&m!==e.index&&g.push({mIndex:d,chainname:Sb(p),rStart:u.count-1,rCount:1}),f=e.index,m=e.index)}),c.count=0,g.forEach(function(t){!function(t,e,i,r){for(var n=c.count,o=0;o<r;++o)u.chainIndex[i+o]=n;c.growIfFull(),c.modelIndex[n]=t,c.setChainname(n,e),c.setChainid(n,e),c.residueOffset[n]=i,c.residueCount[n]=r,c.count+=1,s.chainCount[t]+=1}(t.mIndex,t.chainname,t.rStart,t.rCount)});var i=0;t.eachModel(function(t){s.chainOffset[t.index]=i,s.chainCount[t.index]-=1,i+=s.chainCount[t.index]})}de.Debug&&Yp.timeEnd("calculateChainnames")}function Mb(t){de.Debug&&Yp.time("calculateBonds"),Tb(t),Cb(t),de.Debug&&Yp.timeEnd("calculateBonds")}var Eb={"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 Pb(t,e,i){var r;return e=(r=e<i?[e,i]:[i,e])[0],i=r[1],wg.includes(t)&&"C"===e&&"O"===i?2:Eg.includes(t)&&"OP1"===e&&"P"===i?2:Eb[t+"|"+e+"|"+i]||1}function Tb(t,g){void 0===g&&(g=!1),de.Debug&&Yp.time("calculateBondsWithin");var v=t.bondStore,y=t.rungBondStore,b=t.getAtomSet(!1),x=t.getAtomProxy(),_=t.getAtomProxy(),w=t.getBondProxy(),S=g?null:function(t){de.Debug&&Yp.time("calculateAtomBondMap");var r=[];return t.eachBond(function(t){var e=t.atomIndex1,i=t.atomIndex2;void 0===r[e]&&(r[e]=[]),r[e][i]=t.index}),de.Debug&&Yp.timeEnd("calculateAtomBondMap"),r}(t);t.eachResidue(function(t){if(!g&&S){var e=t.atomCount,i=t.atomOffset;if(500<e)return void Yp.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var r=t.getBonds(),n=r.atomIndices1,o=r.atomIndices2,a=r.bondOrders,s=n.length,c=0;c<s;++c){var u=n[c],h=o[c],l=u+i,p=h+i,d=S[l];if(void 0!==d&&void 0!==d[p])w.index=d[p],a[t.residueType.getBondIndex(u,h)]=w.bondOrder;else x.index=l,_.index=p,v.addBond(x,_,a[c])}}var f=t.residueType.traceAtomIndex,m=t.residueType.rungEndAtomIndex;-1!==f&&-1!==m&&(x.index=t.traceAtomIndex,_.index=t.rungEndAtomIndex,y.addBond(x,_),b.set(x.index),b.set(_.index))}),t.atomSetDict.rung=b,de.Debug&&Yp.timeEnd("calculateBondsWithin")}function Cb(t,n,o){void 0===n&&(n=!1),void 0===o&&(o=!1),de.Debug&&Yp.time("calculateBondsBetween");var a=t.bondStore,s=t.backboneBondStore,c=t.getAtomSet(!1),u=t.getAtomProxy(),h=t.getAtomProxy();function e(t,e){var i=t.backboneType,r=e.backboneType;i!==og&&i===r&&(u.index=t.backboneEndAtomIndex,h.index=e.backboneStartAtomIndex,(o&&u.hasBondTo(h)||u.connectedTo(h))&&(n||a.addBond(u,h,1),u.index=t.traceAtomIndex,h.index=e.traceAtomIndex,s.addBond(u,h),c.set(u.index),c.set(h.index)))}0===s.count&&s.resize(t.residueStore.count),t.eachResidueN(2,e);var i=t.getResidueProxy(),r=t.getResidueProxy();if(t.eachChain(function(t){0!==t.residueCount&&(i.index=t.residueOffset,r.index=t.residueOffset+t.residueCount-1,e(r,i))}),t.atomSetDict.backbone=c,!n){de.Debug&&Yp.time("calculateBondsBetween inter");var l=t.spatialHash;t.eachResidue(function(t){t.backboneType!==og||t.isWater()||t.eachAtom(function(e){e.isMetal()||l.eachWithin(e.x,e.y,e.z,4,function(t){h.index=t,e.modelIndex!==h.modelIndex||e.residueIndex===h.residueIndex||h.isMetal()||a.addBondIfConnected(e,h,1)})})}),de.Debug&&Yp.timeEnd("calculateBondsBetween inter")}de.Debug&&Yp.timeEnd("calculateBondsBetween")}function Ib(t){if(t.unitcell){de.Debug&&Yp.time("buildUnitcellAssembly");var n=t.unitcell,o=t.center.clone().applyMatrix4(n.cartToFrac),a=o.clone().floor(),s=function(t){var e=lb[t],i={};if(void 0===e)return console.warn("spacegroup '"+t+"' not found in symop library"),i;for(var r=[],n=0,o=e.length;n<o;n+=3){for(var a=[],s=0;s<3;++s)a.push(hb[e[n+s]]);r.push(a)}return r.forEach(function(t){var s=0,e=(new ei).set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1),c=e.elements;i[t.toString()]=e,t.forEach(function(t){for(var e=!1,i=!1,r=0,n=t.length;r<n;++r){var o=t[r];if("-"===o)e=!0;else if("+"===o)e=!1;else if("/"===o)i=!0;else if("X"===o)c[0+s]=e?-1:1;else if("Y"===o)c[4+s]=e?-1:1;else if("Z"===o)c[8+s]=e?-1:1;else if(pb.test(o)){var a=parseInt(o);i?c[12+s]/=a:c[12+s]=a}else Yp.warn("getSymmetryOperations: unknown token '"+o+"'")}s+=1})}),i}(n.spacegroup),c=new ri,u=new ri,e=new fb("UNITCELL"),i=m(),r=[];if(t.biomolDict.NCS){r.push.apply(r,[new ei].concat(t.biomolDict.NCS.partList[0].matrixList));var h=[];i.forEach(function(e){r.forEach(function(t){h.push(e.clone().multiply(t))})}),e.addPart(h)}else e.addPart(i);var l=new ri,p=new fb("SUPERCELL"),d=Array.prototype.concat.call(m(l.set(1,0,0)),m(l.set(0,1,0)),m(l.set(0,0,1)),m(l.set(-1,0,0)),m(l.set(0,-1,0)),m(l.set(0,0,-1)),m(l.set(1,1,0)),m(l.set(1,0,1)),m(l.set(0,1,1)),m(l.set(-1,-1,0)),m(l.set(-1,0,-1)),m(l.set(0,-1,-1)),m(l.set(1,-1,-1)),m(l.set(1,1,-1)),m(l.set(1,-1,1)),m(l.set(-1,1,1)),m(l.set(-1,-1,1)),m(l.set(-1,1,-1)),m(l.set(0,1,-1)),m(l.set(0,-1,1)),m(l.set(1,0,-1)),m(l.set(-1,0,1)),m(l.set(1,-1,0)),m(l.set(-1,1,0)),m(),m(l.set(1,1,1)),m(l.set(-1,-1,-1)));if(t.biomolDict.NCS){var f=[];d.forEach(function(e){r.forEach(function(t){f.push(e.clone().multiply(t))})}),p.addPart(f)}else p.addPart(d);t.biomolDict.UNITCELL=e,t.biomolDict.SUPERCELL=p,de.Debug&&Yp.timeEnd("buildUnitcellAssembly")}function m(i){var r=[];return Object.keys(s).forEach(function(t){var e=s[t].clone();c.copy(o).applyMatrix4(e).floor(),u.setFromMatrixPosition(e),u.sub(c),u.add(a),i&&u.add(i),e.setPosition(u),e.multiplyMatrices(n.fracToCart,e),e.multiply(n.cartToFrac),r.push(e)}),r}}var Ob=["H","C","O","N","S","P"],Lb=["NA","CL","FE"];function Rb(t){var e=t.trim().toUpperCase();parseInt(e.charAt(0))&&(e=e.substr(1)),parseInt(e.charAt(0))&&(e=e.substr(1));var i=e.length;if(0===i)return"";if(1===i)return e;if(2===i){if(-1!==Lb.indexOf(e))return e;if(-1!==Ob.indexOf(e[0]))return e[0]}return 3<=i&&-1!==Ob.indexOf(e[0])?e[0]:""}function Db(t){var e=t.bondHash,m=e.countArray,g=e.offsetArray,v=e.indexArray,y=t.getBondProxy();t.eachResidue(function(t){var e=t.residueType;if(void 0===e.bonds){var u=t.atomOffset,h=[],l=[],p=[],d={},f=u+t.atomCount;t.eachAtom(function(t){for(var e=t.index,i=g[e],r=0,n=m[e];r<n;++r){y.index=v[i+r];var o=y.atomIndex1;if(!(o<u||f<=o)){var a=y.atomIndex2;if(!(a<u||f<=a)){if(a<o){var s=a;a=o,o=s}var c=o+"|"+a;void 0===d[c]&&(d[c]=!0,h.push(o-u),l.push(a-u),p.push(y.bondOrder))}}}}),e.bonds={atomIndices1:h,atomIndices2:l,bondOrders:p}}})}var kb=[3,11,19,37,55,87],Bb=[4,12,20,38,56,88],Nb=[6,15,16,34],Fb=[1,7,8,9,17,35,53],zb=[2,10,18,36,54,86],Ub=[13,30,31,48,49,50,80,81,82,83,84,85,112],jb=[5,14,32,33,51,52,85],Gb=[9,17,35,53,85],Vb=function(t,e,i){this.structure=t,this.atomname=e,i=i||Rb(e),this.element=i,this.number=fg[i]||0,this.vdw=mg[this.number]||2,this.covalent=gg[this.number]||1.6};Vb.prototype.getDefaultValence=function(){var t=vg[this.number];return t?t[0]:-1},Vb.prototype.getValenceList=function(){return vg[this.number]||[]},Vb.prototype.getOuterShellElectronCount=function(){return yg[this.number]||2},Vb.prototype.isMetal=function(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()},Vb.prototype.isNonmetal=function(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()},Vb.prototype.isMetalloid=function(){return jb.includes(this.number)},Vb.prototype.isHalogen=function(){return Gb.includes(this.number)},Vb.prototype.isDiatomicNonmetal=function(){return Fb.includes(this.number)},Vb.prototype.isPolyatomicNonmetal=function(){return Nb.includes(this.number)},Vb.prototype.isAlkaliMetal=function(){return kb.includes(this.number)},Vb.prototype.isAlkalineEarthMetal=function(){return Bb.includes(this.number)},Vb.prototype.isNobleGas=function(){return zb.includes(this.number)},Vb.prototype.isTransitionMetal=function(){var t=this.number;return 21<=t&&t<=29||39<=t&&t<=47||72<=t&&t<=79||104<=t&&t<=108},Vb.prototype.isPostTransitionMetal=function(){return Ub.includes(this.number)},Vb.prototype.isLanthanide=function(){return 57<=this.number&&this.number<=71},Vb.prototype.isActinide=function(){return 89<=this.number&&this.number<=103};var Hb=function(t){this.structure=t,this.dict={},this.list=[],this.structure=t};Hb.prototype.add=function(t,e){t=t.toUpperCase(),e=e?e.toUpperCase():Rb(t);var i=t+"|"+e,r=this.dict[i];if(void 0===r){var n=new Vb(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(n)}return r},Hb.prototype.get=function(t){return this.list[t]};var $b=function(t,e,i,r,n,o){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=n,this.bonds=o,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();var a=Lg[this.backboneType],s=Lg[this.backboneStartType],c=Lg[this.backboneEndType],u=this.getAtomIndexByName(a.trace);this.traceAtomIndex=bl(u,-1);var h=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=bl(h,-1);var l=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=bl(l,-1);var p=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=bl(p,-1);var d,f=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=bl(f,-1),d=Mg.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=bl(d,-1)};$b.prototype.getBackboneIndexList=function(){var t,e=[];switch(this.moleculeType){case 3:t=Ig;break;case 4:case 5:t=Og;break;default:return e}for(var i=this.structure.atomMap,r=this.atomTypeIdList,n=0,o=this.atomCount;n<o;++n){var a=i.get(r[n]);t.includes(a.atomname)&&e.push(n)}return e},$b.prototype.getMoleculeType=function(){return this.isProtein()?3:this.isRna()?4:this.isDna()?5:this.isWater()?1:this.isIon()?2:this.isSaccharide()?6:0},$b.prototype.getBackboneType=function(t){return this.hasProteinBackbone(t)?1:this.hasRnaBackbone(t)?2:this.hasDnaBackbone(t)?3:this.hasCgProteinBackbone(t)?4:this.hasCgRnaBackbone(t)?5:this.hasCgDnaBackbone(t)?6:og},$b.prototype.isProtein=function(){return this.chemCompType?ag.includes(this.chemCompType):this.hasAtomWithName("CA","C","N")||wg.includes(this.resname)},$b.prototype.isCg=function(){var t=this.backboneType;return 4===t||5===t||6===t},$b.prototype.isNucleic=function(){return this.isRna()||this.isDna()},$b.prototype.isRna=function(){return this.chemCompType?sg.includes(this.chemCompType):1!==this.hetero&&(this.hasAtomWithName(["P","O3'","O3*"],["C4'","C4*"],["O2'","O2*","F2'","F2*"])||Sg.includes(this.resname)&&this.hasAtomWithName(["O2'","O2*","F2'","F2*"]))},$b.prototype.isDna=function(){return this.chemCompType?cg.includes(this.chemCompType):1!==this.hetero&&(this.hasAtomWithName(["P","O3'","O3*"],["C3'","C3*"])&&!this.hasAtomWithName(["O2'","O2*","F2'","F2*"])||Ag.includes(this.resname))},$b.prototype.isHetero=function(){return 1===this.hetero},$b.prototype.isIon=function(){return Tg.includes(this.resname)},$b.prototype.isWater=function(){return Pg.includes(this.resname)},$b.prototype.isSaccharide=function(){return this.chemCompType?ug.includes(this.chemCompType):Cg.includes(this.resname)},$b.prototype.isStandardAminoacid=function(){return wg.includes(this.resname)},$b.prototype.isStandardBase=function(){return Eg.includes(this.resname)},$b.prototype.hasBackboneAtoms=function(t,e){var i=Lg[e];return-1===t?this.hasAtomWithName(i.trace,i.backboneEnd,i.direction1,i.direction2):0===t?this.hasAtomWithName(i.trace,i.direction1,i.direction2):1===t?this.hasAtomWithName(i.trace,i.backboneStart,i.direction1,i.direction2):this.hasAtomWithName(i.trace,i.backboneStart,i.backboneEnd,i.direction1,i.direction2)},$b.prototype.hasProteinBackbone=function(t){return this.isProtein()&&this.hasBackboneAtoms(t,1)},$b.prototype.hasRnaBackbone=function(t){return this.isRna()&&this.hasBackboneAtoms(t,2)},$b.prototype.hasDnaBackbone=function(t){return this.isDna()&&this.hasBackboneAtoms(t,3)},$b.prototype.hasCgProteinBackbone=function(t){return this.atomCount<7&&this.isProtein()&&this.hasBackboneAtoms(t,4)},$b.prototype.hasCgRnaBackbone=function(t){return this.atomCount<11&&this.isRna()&&this.hasBackboneAtoms(t,5)},$b.prototype.hasCgDnaBackbone=function(t){return this.atomCount<11&&this.isDna()&&this.hasBackboneAtoms(t,6)},$b.prototype.hasBackbone=function(t){return this.hasProteinBackbone(t)||this.hasRnaBackbone(t)||this.hasDnaBackbone(t)||this.hasCgProteinBackbone(t)||this.hasCgRnaBackbone(t)||this.hasCgDnaBackbone(t)},$b.prototype.getAtomIndexByName=function(t){var e=this.atomCount,i=this.structure.atomMap,r=this.atomTypeIdList;if(Array.isArray(t))for(var n=0;n<e;++n){var o=r[n];if(t.includes(i.get(o).atomname))return n}else for(var a=0;a<e;++a){var s=r[a];if(t===i.get(s).atomname)return a}},$b.prototype.hasAtomWithName=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var i=t.length,r=0;r<i;++r)if(void 0!==t[r]&&void 0===this.getAtomIndexByName(t[r]))return!1;return!0},$b.prototype.getBonds=function(t){return void 0===this.bonds&&(this.bonds=function(t){var e=t.structure,i=e.getAtomProxy(),r=e.getAtomProxy(),n=t.atomCount,o=t.atomOffset,a=o+n-1,s=[],c=[],u=[];if(500<n)de.Debug&&Yp.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(50<n)for(var h=new ub(t,!0),l=t.isCg()?1.2:2.3,p=o;p<a;++p){i.index=p;for(var d=i.covalent+l+.3,f=h.nearest(i,1/0,d*d),m=f.length,g=0;g<m;++g)r.index=f[g].index,i.index<r.index&&i.connectedTo(r)&&(s.push(i.index-o),c.push(r.index-o),u.push(Pb(i.resname,i.atomname,r.atomname)))}else for(var v=o;v<a;++v)for(var y=(i.index=v)+1;y<=a;++y)r.index=y,i.connectedTo(r)&&(s.push(v-o),c.push(y-o),u.push(Pb(i.resname,i.atomname,r.atomname)));return{atomIndices1:s,atomIndices2:c,bondOrders:u}}(t)),this.bonds},$b.prototype.getRings=function(){return void 0===this.rings&&this.calculateRings(),this.rings},$b.prototype.getBondGraph=function(){return void 0===this.bondGraph&&this.calculateBondGraph(),this.bondGraph},$b.prototype.getAromatic=function(t){return void 0===this.aromaticAtoms&&this.calculateAromatic(this.structure.getResidueProxy(t.residueIndex)),this.aromaticAtoms},$b.prototype.getAromaticRings=function(t){return void 0===this.aromaticRings&&this.calculateAromatic(t),this.aromaticRings},$b.prototype.calculateBondGraph=function(){for(var t=this.bondGraph={},e=this.getBonds(),i=e.atomIndices1.length,r=e.atomIndices1,n=e.atomIndices2,o=0;o<i;++o){var a=r[o],s=n[o];(t[a]=t[a]||[]).push(s),(t[s]=t[s]||[]).push(a)}},$b.prototype.calculateRings=function(){for(var t=function(t,e){for(var i={count:e,visited:new Int32Array(e),queue:new Int32Array(e),pred:new Int32Array(e),left:new Int32Array(Zb),right:new Int32Array(Zb),color:new Int32Array(e),currentColor:0,rings:[],atomRings:[],bonds:t},r=0;r<e;r++)i.visited[r]=-1,i.pred[r]=-1;return i}(this.getBondGraph(),this.atomCount),e=0;e<t.count;e++)0<=t.visited[e]||Yb(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}},$b.prototype.isAromatic=function(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]},$b.prototype.calculateAromatic=function(e){var i=this,r=this.aromaticAtoms=new Uint8Array(this.atomCount),t=this.getRings().rings,n=t.map(function(t){return function(t){if(t.some(function(t){return!Wb.includes(t.number)}))return!1;var e=0,i=new kv(3,t.length),r=i.data;return t.forEach(function(t){r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}),new $y(i).vecC.length()<Xb}(t.map(function(t){return i.structure.getAtomProxy(t+e.atomOffset)}))}),o=this.aromaticRings=[];t.forEach(function(t,e){n[e]&&(o.push(t),t.forEach(function(t){return r[t]=1}))})},$b.prototype.assignBondReferenceAtomIndices=function(){for(var t=this.getBondGraph(),e=this.getRings(),i=e.atomRings,r=e.rings,n=this.bonds,o=n.atomIndices1,a=n.atomIndices2,s=n.bondOrders,c=this.bondReferenceAtomIndices,u=n.atomIndices1.length,h=c.length=0;h<u;++h)if(!(s[h]<=1)){var l=void 0,p=o[h],d=a[h],f=i[p],m=i[d];if(f&&m)for(var g=0;g<f.length;g++)if(-1!==m.indexOf(f[g])){l=r[f[g]];break}if(1<t[p].length)for(var v=0;v<t[p].length;++v){var y=t[p][v];if(y!==d&&(void 0===l||-1!==l.indexOf(y))){c[h]=y;break}}else if(1<t[d].length)for(var b=0;b<t[d].length;++b){var x=t[d][b];if(x!==p&&(void 0===l||-1!==l.indexOf(x))){c[h]=x;break}}}},$b.prototype.getBondIndex=function(t,e){for(var i=this.bonds,r=i.atomIndices1,n=i.atomIndices2,o=r.indexOf(t),a=n.indexOf(e),s=a;-1!==o;){for(;-1!==a;){if(o===a)return o;a=n.indexOf(e,a+1)}o=r.indexOf(t,o+1),a=s}},$b.prototype.getBondReferenceAtomIndex=function(t,e){var i=this.getBondIndex(t,e);if(void 0!==i)return 0===this.bondReferenceAtomIndices.length&&this.assignBondReferenceAtomIndices(),this.bondReferenceAtomIndices[i]};var Wb=[5,6,7,8,14,15,16,32,33,50,51,83],Xb=.05;function qb(t,e,i){if(!(i<e)){for(var r=t.pred,n=t.color,o=t.left,a=t.right,s=++t.currentColor,c=e,u=0;u<Zb&&(n[c]=s,!((c=r[c])<0));u++);var h=0,l=0,p=!1,d=0;c=i;for(var f=0;f<Zb;f++){if(n[c]===s){d=c,p=!0;break}if((c=r[a[l++]=c])<0)break}if(p){c=e;for(var m=0;m<Zb&&d!==(o[h++]=c)&&!((c=r[c])<0);m++);for(var g=h+l,v=new Array(g),y=0,b=0;b<h;b++)v[y++]=o[b];for(var x=l-1;0<=x;x--)v[y++]=a[x];for(var _=t.rings.length,w=0;w<g;++w){var S=v[w];t.atomRings[S]?t.atomRings[S].push(_):t.atomRings[S]=[_]}t.rings.push(v)}}}function Yb(t,e){var i=t.bonds,r=t.visited,n=t.queue,o=t.pred;r[e]=1,n[0]=e;for(var a=0,s=1;a<s;){var c=n[a++];if(void 0!==i[c])for(var u=i[c].length,h=0;h<u;h++){var l=i[c][h];0<r[l]?o[l]!==c&&o[c]!==l&&qb(t,c,l):(r[l]=1,o[n[s++]=l]=c)}}}var Zb=4;var Kb=function(t){this.structure=t,this.dict={},this.list=[]};Kb.prototype.add=function(t,e,i,r,n){void 0===r&&(r=""),t=t.toUpperCase();var o,a,s=(o=i,void 0===(a=r)&&(a=""),t+"|"+e.join(",")+"|"+(o?1:0)+"|"+a),c=this.dict[s];if(void 0===c){var u=new $b(this.structure,t,e,i,r,n);c=this.list.length,this.dict[s]=c,this.list.push(u)}return c},Kb.prototype.get=function(t){return this.list[t]};var Jb=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.bondStore=t.bondStore,this._v12=new ri,this._v13=new ri,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()},Qb={atom1:{configurable:!0},atom2:{configurable:!0},atomIndex1:{configurable:!0},atomIndex2:{configurable:!0},bondOrder:{configurable:!0}};Qb.atom1.get=function(){return this.structure.getAtomProxy(this.atomIndex1)},Qb.atom2.get=function(){return this.structure.getAtomProxy(this.atomIndex2)},Qb.atomIndex1.get=function(){return this.bondStore.atomIndex1[this.index]},Qb.atomIndex1.set=function(t){this.bondStore.atomIndex1[this.index]=t},Qb.atomIndex2.get=function(){return this.bondStore.atomIndex2[this.index]},Qb.atomIndex2.set=function(t){this.bondStore.atomIndex2[this.index]=t},Qb.bondOrder.get=function(){return this.bondStore.bondOrder[this.index]},Qb.bondOrder.set=function(t){this.bondStore.bondOrder[this.index]=t},Jb.prototype.getOtherAtomIndex=function(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1},Jb.prototype.getOtherAtom=function(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))},Jb.prototype.getReferenceAtomIndex=function(){var t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex===e.residueIndex){var i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,n=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==n)return n+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}},Jb.prototype.calculateShiftDir=function(t){void 0===t&&(t=new ri);var e=this._ap1,i=this._ap2,r=this._ap3,n=this._v12,o=this._v13;e.index=this.atomIndex1,i.index=this.atomIndex2;var a=this.getReferenceAtomIndex();n.subVectors(e,i).normalize(),void 0!==a?(r.index=a,o.subVectors(e,r)):o.copy(e),o.normalize();var s=n.dot(o);return 1-Math.abs(s)<1e-5&&(o.set(1,0,0),s=n.dot(o),1-Math.abs(s)<1e-5&&(o.set(0,1,0),s=n.dot(o))),t.copy(o.sub(n.multiplyScalar(s))).normalize()},Jb.prototype.qualifiedName=function(){return this.atomIndex1+"="+this.atomIndex2},Jb.prototype.clone=function(){return new Jb(this.structure,this.index)},Jb.prototype.toObject=function(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}},Object.defineProperties(Jb.prototype,Qb);var tx=function(t,e){void 0===e&&(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},ex={entity:{configurable:!0},entityIndex:{configurable:!0},chain:{configurable:!0},chainIndex:{configurable:!0},atomOffset:{configurable:!0},atomCount:{configurable:!0},atomEnd:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0},resno:{configurable:!0},sstruc:{configurable:!0},inscode:{configurable:!0},residueType:{configurable:!0},resname:{configurable:!0},hetero:{configurable:!0},moleculeType:{configurable:!0},backboneType:{configurable:!0},backboneStartType:{configurable:!0},backboneEndType:{configurable:!0},traceAtomIndex:{configurable:!0},direction1AtomIndex:{configurable:!0},direction2AtomIndex:{configurable:!0},backboneStartAtomIndex:{configurable:!0},backboneEndAtomIndex:{configurable:!0},rungEndAtomIndex:{configurable:!0},x:{configurable:!0},y:{configurable:!0},z:{configurable:!0}};ex.entity.get=function(){return this.structure.entityList[this.entityIndex]},ex.entityIndex.get=function(){return this.chainStore.entityIndex[this.chainIndex]},ex.chain.get=function(){return this.structure.getChainProxy(this.chainIndex)},ex.chainIndex.get=function(){return this.residueStore.chainIndex[this.index]},ex.chainIndex.set=function(t){this.residueStore.chainIndex[this.index]=t},ex.atomOffset.get=function(){return this.residueStore.atomOffset[this.index]},ex.atomOffset.set=function(t){this.residueStore.atomOffset[this.index]=t},ex.atomCount.get=function(){return this.residueStore.atomCount[this.index]},ex.atomCount.set=function(t){this.residueStore.atomCount[this.index]=t},ex.atomEnd.get=function(){return this.atomOffset+this.atomCount-1},ex.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},ex.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},ex.chainid.get=function(){return this.chainStore.getChainid(this.chainIndex)},ex.resno.get=function(){return this.residueStore.resno[this.index]},ex.resno.set=function(t){this.residueStore.resno[this.index]=t},ex.sstruc.get=function(){return this.residueStore.getSstruc(this.index)},ex.sstruc.set=function(t){this.residueStore.setSstruc(this.index,t)},ex.inscode.get=function(){return this.residueStore.getInscode(this.index)},ex.inscode.set=function(t){this.residueStore.setInscode(this.index,t)},ex.residueType.get=function(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},ex.resname.get=function(){return this.residueType.resname},ex.hetero.get=function(){return this.residueType.hetero},ex.moleculeType.get=function(){return this.residueType.moleculeType},ex.backboneType.get=function(){return this.residueType.backboneType},ex.backboneStartType.get=function(){return this.residueType.backboneStartType},ex.backboneEndType.get=function(){return this.residueType.backboneEndType},ex.traceAtomIndex.get=function(){return this.residueType.traceAtomIndex+this.atomOffset},ex.direction1AtomIndex.get=function(){return this.residueType.direction1AtomIndex+this.atomOffset},ex.direction2AtomIndex.get=function(){return this.residueType.direction2AtomIndex+this.atomOffset},ex.backboneStartAtomIndex.get=function(){return this.residueType.backboneStartAtomIndex+this.atomOffset},ex.backboneEndAtomIndex.get=function(){return this.residueType.backboneEndAtomIndex+this.atomOffset},ex.rungEndAtomIndex.get=function(){return this.residueType.rungEndAtomIndex+this.atomOffset},ex.x.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount},ex.y.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount},ex.z.get=function(){for(var t=0,e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount},tx.prototype.eachAtom=function(t,e){var i=this.atomCount,r=this.atomOffset,n=this.structure._ap,o=r+i;if(e&&e.atomOnlyTest)for(var a=e.atomOnlyTest,s=r;s<o;++s)n.index=s,a(n)&&t(n);else for(var c=r;c<o;++c)n.index=c,t(n)},tx.prototype.positionToArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e+0]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},tx.prototype.isProtein=function(){return 3===this.residueType.moleculeType},tx.prototype.isNucleic=function(){var t=this.residueType.moleculeType;return 4===t||5===t},tx.prototype.isRna=function(){return 4===this.residueType.moleculeType},tx.prototype.isDna=function(){return 5===this.residueType.moleculeType},tx.prototype.isCg=function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},tx.prototype.isPolymer=function(){if(0<this.structure.entityList.length)return this.entity.isPolymer();var t=this.residueType.moleculeType;return 3===t||4===t||5===t},tx.prototype.isHetero=function(){return 1===this.residueType.hetero},tx.prototype.isWater=function(){return 1===this.residueType.moleculeType},tx.prototype.isIon=function(){return 2===this.residueType.moleculeType},tx.prototype.isSaccharide=function(){return 6===this.residueType.moleculeType},tx.prototype.isStandardAminoacid=function(){return this.residueType.isStandardAminoacid()},tx.prototype.isStandardBase=function(){return this.residueType.isStandardBase()},tx.prototype.isHelix=function(){return lg.includes(this.sstruc)},tx.prototype.isSheet=function(){return pg.includes(this.sstruc)},tx.prototype.isTurn=function(){return dg.includes(this.sstruc)&&this.isProtein()},tx.prototype.getAtomType=function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},tx.prototype.getResname1=function(){return _g[this.resname.toUpperCase()]||"X"},tx.prototype.getBackboneType=function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},tx.prototype.getAtomIndexByName=function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},tx.prototype.hasAtomWithName=function(t){return this.residueType.hasAtomWithName(t)},tx.prototype.getAtomnameList=function(){console.warn("getAtomnameList - might be expensive");for(var t=this.atomCount,e=this.atomOffset,i=new Array(t),r=0;r<t;++r)i[r]=this.getAtomType(e+r).atomname;return i},tx.prototype.connectedTo=function(t){var e=this.structure.getAtomProxy(this.backboneEndAtomIndex),i=this.structure.getAtomProxy(t.backboneStartAtomIndex);return!(!e||!i)&&e.connectedTo(i)},tx.prototype.getNextConnectedResidue=function(){var t=this.chainStore.residueOffset[this.chainIndex],e=this.chainStore.residueCount[this.chainIndex],i=this.index+1;if(i<t+e){var r=this.structure.getResidueProxy(i);if(this.connectedTo(r))return r}else if(i===t+e){var n=this.structure.getResidueProxy(t);if(this.connectedTo(n))return n}},tx.prototype.getPreviousConnectedResidue=function(t){var e=this.chainStore.residueOffset[this.chainIndex],i=this.index-1;if(e<=i){var r=bl(t,this.structure.getResidueProxy());if(r.index=i,r.connectedTo(this))return r}else if(i===e-1){var n=this.chainStore.residueCount[this.chainIndex],o=bl(t,this.structure.getResidueProxy());if(o.index=e+n-1,o.connectedTo(this))return o}},tx.prototype.getBonds=function(){return this.residueType.getBonds(this)},tx.prototype.getRings=function(){return this.residueType.getRings()},tx.prototype.getAromaticRings=function(){return this.residueType.getAromaticRings(this)},tx.prototype.qualifiedName=function(t){void 0===t&&(t=!1);var 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},tx.prototype.clone=function(){return new tx(this.structure,this.index)},tx.prototype.toObject=function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}},Object.defineProperties(tx.prototype,ex);var ix=function(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;var r=this.structure.getResidueProxy(this.residueIndexStart),n=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();var o=n.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=void 0!==o&&void 0!==o.getNextConnectedResidue(),this.isCyclic=n.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()},rx={chainIndex:{configurable:!0},modelIndex:{configurable:!0},chainname:{configurable:!0}};rx.chainIndex.get=function(){return this.residueStore.chainIndex[this.residueIndexStart]},rx.modelIndex.get=function(){return this.chainStore.modelIndex[this.chainIndex]},rx.chainname.get=function(){return this.chainStore.getChainname(this.chainIndex)},ix.prototype.isProtein=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},ix.prototype.isCg=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},ix.prototype.isNucleic=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},ix.prototype.getMoleculeType=function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},ix.prototype.getBackboneType=function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},ix.prototype.getAtomIndexByType=function(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));var i,r=this.__residueProxy;switch(r.index=this.residueIndexStart+t,e){case"trace":i=r.traceAtomIndex;break;case"direction1":i=r.direction1AtomIndex;break;case"direction2":i=r.direction2AtomIndex;break;default:i=r.getAtomIndexByName(e)}return i},ix.prototype.eachAtom=function(e,i){this.eachResidue(function(t){t.eachAtom(e,i)})},ix.prototype.eachAtomN=function(t,e,i){for(var r=this.residueCount,n=new Array(t),o=0;o<t;++o)n[o]=this.structure.getAtomProxy(this.getAtomIndexByType(o,i));e.apply(this,n);for(var a=t;a<r;++a){for(var s=1;s<t;++s)n[s-1].index=n[s].index;n[t-1].index=this.getAtomIndexByType(a,i),e.apply(this,n)}},ix.prototype.eachResidue=function(t){for(var e=this.structure.getResidueProxy(),i=this.residueCount,r=this.residueIndexStart,n=0;n<i;++n)e.index=r+n,t(e)},ix.prototype.qualifiedName=function(){var t=this.structure.getResidueProxy(this.residueIndexStart),e=this.structure.getResidueProxy(this.residueIndexEnd);return t.qualifiedName()+" - "+e.qualifiedName()},Object.defineProperties(ix.prototype,rx);var nx=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore},ox={entity:{configurable:!0},model:{configurable:!0},entityIndex:{configurable:!0},modelIndex:{configurable:!0},residueOffset:{configurable:!0},residueCount:{configurable:!0},residueEnd:{configurable:!0},atomOffset:{configurable:!0},atomEnd:{configurable:!0},atomCount:{configurable:!0},chainname:{configurable:!0},chainid:{configurable:!0}};ox.entity.get=function(){return this.structure.entityList[this.entityIndex]},ox.model.get=function(){return this.structure.getModelProxy(this.modelIndex)},ox.entityIndex.get=function(){return this.chainStore.entityIndex[this.index]},ox.entityIndex.set=function(t){this.chainStore.entityIndex[this.index]=t},ox.modelIndex.get=function(){return this.chainStore.modelIndex[this.index]},ox.modelIndex.set=function(t){this.chainStore.modelIndex[this.index]=t},ox.residueOffset.get=function(){return this.chainStore.residueOffset[this.index]},ox.residueOffset.set=function(t){this.chainStore.residueOffset[this.index]=t},ox.residueCount.get=function(){return this.chainStore.residueCount[this.index]},ox.residueCount.set=function(t){this.chainStore.residueCount[this.index]=t},ox.residueEnd.get=function(){return this.residueOffset+this.residueCount-1},ox.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},ox.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},ox.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},ox.chainname.get=function(){return this.chainStore.getChainname(this.index)},ox.chainname.set=function(t){this.chainStore.setChainname(this.index,t)},ox.chainid.get=function(){return this.chainStore.getChainid(this.index)},ox.chainid.set=function(t){this.chainStore.setChainid(this.index,t)},nx.prototype.eachAtom=function(e,i){this.eachResidue(function(t){t.eachAtom(e,i)},i)},nx.prototype.eachResidue=function(t,e){var i=this.residueCount,r=this.residueOffset,n=this.structure._rp,o=r+i;if(e&&e.test){var a=e.residueOnlyTest;if(a)for(var s=r;s<o;++s)n.index=s,a(n)&&t(n);else for(var c=r;c<o;++c)n.index=c,t(n)}else for(var u=r;u<o;++u)n.index=u,t(n)},nx.prototype.eachResidueN=function(t,e){var i=this.residueCount,r=this.residueOffset,n=r+i;if(!(i<t)){for(var o=new Array(t),a=0;a<t;++a)o[a]=this.structure.getResidueProxy(r+a);e.apply(this,o);for(var s=r+t;s<n;++s){for(var c=0;c<t;++c)o[c].index+=1;e.apply(this,o)}}},nx.prototype.eachPolymer=function(t,e){for(var i=0,r=0,n=e?e.residueOnlyTest:void 0,o=this.model.structure,a=this.residueCount,s=this.residueOffset,c=s+a,u=this.structure.getResidueProxy(),h=this.structure.getResidueProxy(s),l=this.structure.getAtomProxy(),p=this.structure.getAtomProxy(),d=!0,f=s+1;f<c;++f){u.index=h.index,h.index=f;var m=d?u.backboneEndType:u.backboneType,g=h.backboneType;d&&(i=u.index,d=!1),r=h.index,m!==og&&m===g?(l.index=u.backboneEndAtomIndex,p.index=h.backboneStartAtomIndex,l&&p&&l.connectedTo(p)&&(!n||n(u)&&n(h))||(1<u.index-i&&t(new ix(o,i,u.index)),i=r)):(m!==og&&1<u.index-i&&t(new ix(o,i,u.index)),i=r)}1<r-i&&this.structure.getResidueProxy(i).backboneEndType&&t(new ix(o,i,r))},nx.prototype.qualifiedName=function(){return":"+this.chainname+"/"+this.modelIndex},nx.prototype.clone=function(){return new nx(this.structure,this.index)},nx.prototype.toObject=function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}},Object.defineProperties(nx.prototype,ox);var ax=function(t,e){void 0===e&&(e=0),this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore},sx={chainOffset:{configurable:!0},chainCount:{configurable:!0},residueOffset:{configurable:!0},atomOffset:{configurable:!0},chainEnd:{configurable:!0},residueEnd:{configurable:!0},atomEnd:{configurable:!0},residueCount:{configurable:!0},atomCount:{configurable:!0}};sx.chainOffset.get=function(){return this.modelStore.chainOffset[this.index]},sx.chainOffset.set=function(t){this.modelStore.chainOffset[this.index]=t},sx.chainCount.get=function(){return this.modelStore.chainCount[this.index]},sx.chainCount.set=function(t){this.modelStore.chainCount[this.index]=t},sx.residueOffset.get=function(){return this.chainStore.residueOffset[this.chainOffset]},sx.atomOffset.get=function(){return this.residueStore.atomOffset[this.residueOffset]},sx.chainEnd.get=function(){return this.chainOffset+this.chainCount-1},sx.residueEnd.get=function(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},sx.atomEnd.get=function(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},sx.residueCount.get=function(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},sx.atomCount.get=function(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},ax.prototype.eachAtom=function(e,i){this.eachChain(function(t){t.eachAtom(e,i)},i)},ax.prototype.eachResidue=function(e,i){this.eachChain(function(t){t.eachResidue(e,i)},i)},ax.prototype.eachPolymer=function(e,i){if(i&&i.chainOnlyTest){var r=i.chainOnlyTest;this.eachChain(function(t){r(t)&&t.eachPolymer(e,i)})}else this.eachChain(function(t){t.eachPolymer(e,i)})},ax.prototype.eachChain=function(t,e){var i=this.chainCount,r=this.chainOffset,n=this.structure._cp,o=r+i;if(e&&e.test){var a=e.chainOnlyTest;if(a)for(var s=r;s<o;++s)n.index=s,a(n)&&t(n);else for(var c=r;c<o;++c)n.index=c,t(n)}else for(var u=r;u<o;++u)n.index=u,t(n)},ax.prototype.qualifiedName=function(){return"/"+this.index},ax.prototype.clone=function(){return new ax(this.structure,this.index)},ax.prototype.toObject=function(){return{index:this.index,chainOffset:this.chainOffset,chainCount:this.chainCount}},Object.defineProperties(ax.prototype,sx);var cx=function(t,e){void 0===t&&(t=""),void 0===e&&(e=""),this.signals={refreshed:new op},this.init(t,e)},ux={type:{configurable:!0}};cx.prototype.init=function(t,e){this.name=t,this.path=e,this.title="",this.id="",this.data={structure:this,"@spatialLookup":void 0,"@valenceModel":void 0},this.header={},this.extraData={},this.atomSetCache={},this.atomSetDict={},this.biomolDict={},this.entityList=[],this.unitcell=void 0,this.frames=[],this.boxes=[],this.validation=void 0,this.bondStore=new Yy(0),this.backboneBondStore=new Yy(0),this.rungBondStore=new Yy(0),this.atomStore=new Zy(0),this.residueStore=new Ky(0),this.chainStore=new Jy(0),this.modelStore=new Qy(0),this.atomMap=new Hb(this),this.residueMap=new Kb(this),this.bondHash=void 0,this.spatialHash=void 0,this.atomSet=void 0,this.bondSet=void 0,this.center=new ri,this.boundingBox=new Pi,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy()},ux.type.get=function(){return"Structure"},cx.prototype.finalizeAtoms=function(){this.atomSet=this.getAtomSet(),this.atomCount=this.atomStore.count,this.boundingBox=this.getBoundingBox(void 0,this.boundingBox),this.center=this.boundingBox.getCenter(new ri),this.spatialHash=new Zm(this.atomStore,this.boundingBox)},cx.prototype.finalizeBonds=function(){for(var t in this.bondSet=this.getBondSet(),this.bondCount=this.bondStore.count,this.bondHash=new qy(this.bondStore,this.atomStore.count),this.atomSetCache={},this.atomSetDict.rung||(this.atomSetDict.rung=this.getAtomSet(!1)),this.atomSetDict)this.atomSetCache["__"+t]=this.atomSetDict[t].clone()},cx.prototype.getBondProxy=function(t){return new Jb(this,t)},cx.prototype.getAtomProxy=function(t){return new nb(this,t)},cx.prototype.getResidueProxy=function(t){return new tx(this,t)},cx.prototype.getChainProxy=function(t){return new nx(this,t)},cx.prototype.getModelProxy=function(t){return new ax(this,t)},cx.prototype.getBondSet=function(){var t=this.bondStore.count,e=new tg(t),i=this.atomSet;if(i)if(i.isAllSet())e.setAll();else if(i.isAllClear())e.clearAll();else for(var r=this.getBondProxy(),n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index);else e.setAll();return e},cx.prototype.getBackboneBondSet=function(){var t=this.backboneBondStore.count,e=new tg(t),i=this.atomSetCache.__backbone;if(i){var r=this.getBondProxy();r.bondStore=this.backboneBondStore;for(var n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index)}else e.setAll();return e},cx.prototype.getRungBondSet=function(){var t=this.rungBondStore.count,e=new tg(t),i=this.atomSetCache.__rung;if(i){var r=this.getBondProxy();r.bondStore=this.rungBondStore;for(var n=0;n<t;++n)r.index=n,i.isSet(r.atomIndex1,r.atomIndex2)&&e.set(r.index)}else e.setAll();return e},cx.prototype.getAtomSet=function(t){var e=this.atomStore.count;if(void 0===t)return new tg(e,!0);if(t instanceof tg)return t;if(!0===t)return new tg(e,!0);if(t&&t.test){var i=t.string;if(i in this.atomSetCache)return this.atomSetCache[i];if(""===i)return new tg(e,!0);var r=new tg(e);return this.eachAtom(function(t){r.set(t.index)},t),this.atomSetCache[i]=r}return!1===t?new tg(e):new tg(e,!0)},cx.prototype.getAtomSetWithinSelection=function(t,e){var i=this.spatialHash,r=this.getAtomSet(!1),n=this.getAtomProxy();return i&&this.getAtomSet(t).forEach(function(t){n.index=t,i.within(n.x,n.y,n.z,e).forEach(function(t){r.set(t)})}),r},cx.prototype.getAtomSetWithinPoint=function(t,e){var i=t,r=this.getAtomSet(!1);return this.spatialHash&&this.spatialHash.within(i.x,i.y,i.z,e).forEach(function(t){r.set(t)}),r},cx.prototype.getAtomSetWithinVolume=function(t,e,i,r,n){var o=new Wy(t,i,r,n),a=o.getDataPosition(),s=a.length,c=o.matrix.getMaxScaleOnAxis(),u=this.getAtomSet(!1);if(!this.spatialHash)return u;for(var h=0;h<s;h+=3)this.spatialHash.within(a[h],a[h+1],a[h+2],c).forEach(function(t){u.set(t)});return u},cx.prototype.getAtomSetWithinGroup=function(t){var i=this.atomStore.residueIndex,r=this.getAtomSet(!1),n=this.getResidueProxy();return this.getAtomSet(t).forEach(function(t){n.index=i[t];for(var e=n.atomOffset;e<=n.atomEnd;++e)r.set(e)}),r},cx.prototype.getSelection=function(){return!1},cx.prototype.getStructure=function(){return this},cx.prototype.eachEntity=function(e,i){this.entityList.forEach(function(t){void 0!==i&&t.getEntityType()!==i||e(t)})},cx.prototype.eachBond=function(e,t){var i,r=this.getBondProxy();if(t&&t.test&&(i=this.getBondSet(),this.bondSet&&i.intersection(this.bondSet)),i)i.forEach(function(t){r.index=t,e(r)});else for(var n=this.bondStore.count,o=0;o<n;++o)r.index=o,e(r)},cx.prototype.eachAtom=function(e,i){if(i&&i.test)this.eachModel(function(t){t.eachAtom(e,i)},i);else for(var t=this.atomStore.count,r=this.getAtomProxy(),n=0;n<t;++n)r.index=n,e(r)},cx.prototype.eachResidue=function(t,e){if(e&&e.test){var i=this.modelStore.count,r=this.getModelProxy(),n=e.modelOnlyTest;if(n)for(var o=0;o<i;++o)r.index=o,n(r)&&r.eachResidue(t,e);else for(var a=0;a<i;++a)r.index=a,r.eachResidue(t,e)}else for(var s=this.residueStore.count,c=this.getResidueProxy(),u=0;u<s;++u)c.index=u,t(c)},cx.prototype.eachResidueN=function(t,e){var i=this.residueStore.count;if(!(i<t)){for(var r=new Array(t),n=0;n<t;++n)r[n]=this.getResidueProxy(n);e.apply(this,r);for(var o=t;o<i;++o){for(var a=0;a<t;++a)r[a].index+=1;e.apply(this,r)}}},cx.prototype.eachPolymer=function(e,i){if(i&&i.modelOnlyTest){var r=i.modelOnlyTest;this.eachModel(function(t){r(t)&&t.eachPolymer(e,i)})}else this.eachModel(function(t){t.eachPolymer(e,i)})},cx.prototype.eachChain=function(e,i){if(i&&i.test)this.eachModel(function(t){t.eachChain(e,i)});else for(var t=this.chainStore.count,r=this.getChainProxy(),n=0;n<t;++n)r.index=n,e(r)},cx.prototype.eachModel=function(t,e){var i=this.modelStore.count,r=this.getModelProxy();if(e&&e.test){var n=e.modelOnlyTest;if(n)for(var o=0;o<i;++o)r.index=o,n(r)&&t(r);else for(var a=0;a<i;++a)r.index=a,t(r)}else for(var s=0;s<i;++s)r.index=s,t(r)},cx.prototype.getAtomData=function(t){var e=Object.assign({},t);e.colorParams&&(e.colorParams.structure=this.getStructure());var r,n,i=e.what,o=bl(e.atomSet,this.atomSet),a={},s=this.getAtomProxy(),c=o.getSize();i&&!i.position||(a.position=new Float32Array(3*c)),i&&!i.color||!e.colorParams||(a.color=new Float32Array(3*c),n=Qp.getScheme(e.colorParams)),i&&!i.picking||(a.picking=new hv(new Float32Array(c),this.getStructure())),i&&!i.radius||(a.radius=new Float32Array(c),r=new Gy(e.radiusParams)),i&&!i.index||(a.index=new Uint32Array(c));var u=a.position,h=a.color,l=a.picking,p=a.radius,d=a.index;return o.forEach(function(t,e){var i=3*e;s.index=t,u&&s.positionToArray(u,i),h&&n.atomColorToArray(s,h,i),l&&(l.array[e]=t),p&&(p[e]=r.atomRadius(s)),d&&(d[e]=t)}),a},cx.prototype.getBondData=function(t){var e=Object.assign({},t);e.colorParams&&(e.colorParams.structure=this.getStructure());var i,r,n=e.what,o=bl(e.bondSet,this.bondSet),a=bl(e.multipleBond,"off"),s="off"!==a,c="offset"===a,u=bl(e.bondScale,.4),h=bl(e.bondSpacing,1),l={},p=this.getBondProxy();e.bondStore&&(p.bondStore=e.bondStore);var d,f=this.getAtomProxy(),m=this.getAtomProxy();if(s){var g=p.bondStore.bondOrder;d=0,o.forEach(function(t){d+=g[t]})}else d=o.getSize();n&&!n.position||(l.position1=new Float32Array(3*d),l.position2=new Float32Array(3*d)),n&&!n.color||!e.colorParams||(l.color=new Float32Array(3*d),l.color2=new Float32Array(3*d),r=Qp.getScheme(e.colorParams)),n&&!n.picking||(l.picking=new pv(new Float32Array(d),this.getStructure(),e.bondStore)),(!n||n.radius||s&&n.position)&&(i=new Gy(e.radiusParams)),n&&!n.radius||(l.radius=new Float32Array(d),e.radius2&&(l.radius2=new Float32Array(d)));var v,y,b,x,_,w,S=l.position1,A=l.position2,M=l.color,E=l.color2,P=l.picking,T=l.radius,C=l.radius2,I=0,O=new ri,L=new ri,R=new ri;return o.forEach(function(t){if(y=3*I,p.index=t,f.index=p.atomIndex1,m.index=p.atomIndex2,x=p.bondOrder,S)if(s&&1<x){var e=i.atomRadius(f);w=e*u/(.5*x),p.calculateShiftDir(R),c?(_=2*h*e,R.multiplyScalar(_),R.negate(),L.subVectors(m,f).multiplyScalar(Math.max(.1,_/1.88)),f.positionToArray(S,y),m.positionToArray(A,y),2<=x&&(O.addVectors(f,R).add(L).toArray(S,y+3),O.addVectors(m,R).sub(L).toArray(A,y+3),3<=x&&(O.subVectors(f,R).add(L).toArray(S,y+6),O.subVectors(m,R).sub(L).toArray(A,y+6)))):(_=(h-u)*e,R.multiplyScalar(_),2===x?(O.addVectors(f,R).toArray(S,y),O.subVectors(f,R).toArray(S,y+3),O.addVectors(m,R).toArray(A,y),O.subVectors(m,R).toArray(A,y+3)):3===x?(f.positionToArray(S,y),O.addVectors(f,R).toArray(S,y+3),O.subVectors(f,R).toArray(S,y+6),m.positionToArray(A,y),O.addVectors(m,R).toArray(A,y+3),O.subVectors(m,R).toArray(A,y+6)):(f.positionToArray(S,y),m.positionToArray(A,y)))}else f.positionToArray(S,y),m.positionToArray(A,y);if(M&&E&&(r.bondColorToArray(p,1,M,y),r.bondColorToArray(p,0,E,y),s&&1<x))for(v=1;v<x;++v)qd(M,y,b=3*v+y,3),qd(E,y,b,3);if(P&&P.array&&(P.array[I]=t,s&&1<x))for(v=1;v<x;++v)P.array[I+v]=t;if(T&&(T[I]=i.atomRadius(f),s&&1<x))for(w=T[I]*u/(c?1:.5*x),v=c?1:0;v<x;++v)T[I+v]=w;if(C&&(C[I]=i.atomRadius(m),s&&1<x))for(w=C[I]*u/(c?1:.5*x),v=c?1:0;v<x;++v)C[I+v]=w;I+=s?x:1}),l},cx.prototype.getBackboneAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__backbone},t),this.getAtomData(t)},cx.prototype.getBackboneBondData=function(t){return t=Object.assign({bondSet:this.getBackboneBondSet(),bondStore:this.backboneBondStore},t),this.getBondData(t)},cx.prototype.getRungAtomData=function(t){return t=Object.assign({atomSet:this.atomSetCache.__rung},t),this.getAtomData(t)},cx.prototype.getRungBondData=function(t){return t=Object.assign({bondSet:this.getRungBondSet(),bondStore:this.rungBondStore},t),this.getBondData(t)},cx.prototype.getBoundingBox=function(t,e){de.Debug&&Yp.time("getBoundingBox"),e=e||new Pi;var n=1/0,o=1/0,a=1/0,s=-1/0,c=-1/0,u=-1/0;return this.eachAtom(function(t){var e=t.x,i=t.y,r=t.z;e<n&&(n=e),i<o&&(o=i),r<a&&(a=r),s<e&&(s=e),c<i&&(c=i),u<r&&(u=r)},t),e.min.set(n,o,a),e.max.set(s,c,u),de.Debug&&Yp.timeEnd("getBoundingBox"),e},cx.prototype.getPrincipalAxes=function(t){de.Debug&&Yp.time("getPrincipalAxes");var e=0,i=new kv(3,this.atomCount),r=i.data;return this.eachAtom(function(t){r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3},t),de.Debug&&Yp.timeEnd("getPrincipalAxes"),new $y(i)},cx.prototype.atomCenter=function(t){return t?this.getBoundingBox(t).getCenter(new ri):this.center.clone()},cx.prototype.hasCoords=function(){if(void 0===this._hasCoords){var t=this.atomStore;this._hasCoords=0!==Zd(t.x)||0!==Yd(t.x)||0!==Zd(t.y)||0!==Yd(t.y)||0!==Zd(t.z)||0!==Yd(t.z)||t.count/this.modelStore.count==1}return this._hasCoords},cx.prototype.getSequence=function(t){var e=[],i=this.getResidueProxy();return this.eachAtom(function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())},t),e},cx.prototype.getAtomIndices=function(t){if(t&&t.string){var e=[];return this.eachAtom(function(t){e.push(t.index)},t),new Uint32Array(e)}return this.getAtomData({what:{index:!0}}).index},cx.prototype.getChainnameCount=function(t){var e=new Set;return this.eachChain(function(t){t.residueCount&&e.add(t.chainname)},t),e.size},cx.prototype.updatePosition=function(e){var i=0;this.eachAtom(function(t){t.positionFromArray(e,i),i+=3},void 0),this._hasCoords=void 0},cx.prototype.refreshPosition=function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Zm(this.atomStore,this.boundingBox)},cx.prototype.dispose=function(){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.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(cx.prototype,ux);var hx=new Pi,lx=[Vm,zm,Hm,Gm,$m,Um,Fm,jm,Xm,Wm,qm,Ym],px={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,lineWidth:2},dx=function(t,e){var i=this;void 0===t&&(t="shape"),void 0===e&&(e={}),this.boundingBox=new Pi,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=xl(e,px),lx.forEach(function(e){Object.keys(e.fields).forEach(function(t){i._primitiveData[e.getShapeKey(t)]=[]}),i._primitiveData[e.getShapeKey("name")]=[]})},fx={center:{configurable:!0},type:{configurable:!0}};dx.prototype.addBuffer=function(t){this.bufferList.push(t);var e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this},dx.prototype.addMesh=function(t,e,i,r,n){t=Fl(t),e=Fl(e),Array.isArray(i)&&(i=Ll(i,t.length)),r&&(r=Fl(r));var o={position:t,color:e,index:i,normal:r},a=new _v(this,Object.assign({serial:this.meshCount,name:n},o)),s=new my(Object.assign({picking:a},o));return this.bufferList.push(s),hx.setFromArray(t),this.boundingBox.union(hx),this.meshCount+=1,this},dx.prototype.addSphere=function(t,e,i,r){return Fm.objectToShape(this,{position:t,color:e,radius:i,name:r}),this},dx.prototype.addEllipsoid=function(t,e,i,r,n,o){return $m.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:n,name:o}),this},dx.prototype.addTorus=function(t,e,i,r,n,o){return Wm.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:n,name:o}),this},dx.prototype.addCylinder=function(t,e,i,r,n){return Gm.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:n}),this},dx.prototype.addCone=function(t,e,i,r,n){return Hm.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:n}),this},dx.prototype.addArrow=function(t,e,i,r,n){return Vm.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:n}),this},dx.prototype.addBox=function(t,e,i,r,n,o){return zm.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:n,name:o}),this},dx.prototype.addOctahedron=function(t,e,i,r,n,o){return Um.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:n,name:o}),this},dx.prototype.addTetrahedron=function(t,e,i,r,n,o){return jm.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:n,name:o}),this},dx.prototype.addText=function(t,e,i,r){return Xm.objectToShape(this,{position:t,color:e,size:i,text:r}),this},dx.prototype.addPoint=function(t,e,i){return qm.objectToShape(this,{position:t,color:e,name:i}),this},dx.prototype.addWideline=function(t,e,i,r){return Ym.objectToShape(this,{position1:t,position2:e,color:i,name:r}),this},dx.prototype.addLabel=function(t,e,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,i,r)},dx.prototype.getBufferList=function(){var e=this,i=[];return lx.forEach(function(t){e._primitiveData[t.getShapeKey("color")].length&&i.push(t.bufferFromShape(e,e.parameters))}),this.bufferList.concat(i)},dx.prototype.dispose=function(){var i=this;this.bufferList.forEach(function(t){t.dispose()}),this.bufferList.length=0,lx.forEach(function(e){Object.keys(e.fields).forEach(function(t){i._primitiveData[e.getShapeKey(t)].length=0}),i._primitiveData[e.getShapeKey("name")].length=0})},fx.center.get=function(){return this._center||(this._center=this.boundingBox.getCenter(new ri)),this._center},fx.type.get=function(){return"Shape"},Object.defineProperties(dx.prototype,fx);var mx=function(r){function t(t,e,i){Array.isArray(t)||(t=[t]),r.call(this,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)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){r.prototype.init.call(this,t),this.build()},t.prototype.create=function(){this.bufferList.push.apply(this.bufferList,this.buffer)},t.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t),t.setParameters(e.getBufferParams())}),this.setVisibility(this.visible),t()},t}(sm),gx=new ei,vx=new ni;var yx=function(y){function t(t,e,i){var r,n,o,a,s,c,u,h,l,p,d;void 0===e&&(e={}),y.call(this,(r=t,a=(n=i).attributes.position.array,s=n.index?n.index.array:void 0,c=r.position.length/3,u=a.length/3,h=c*u,l=new Float32Array(3*h),p=new Float32Array(3*h),d=new Float32Array(3*h),s&&(o=Ll(c*s.length,h)),{position:l,color:d,index:o,normal:p,primitiveId:r.primitiveId||$d(c,u),picking:r.picking}),e),this.updateNormals=!1;var f=i.attributes.position.array,m=i.attributes.normal.array,g=i.index?i.index.array:void 0;this.geoPosition=f,this.geoNormal=m,this.geoIndex=g,this.positionCount=t.position.length/3,this.geoPositionCount=f.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);var v=this.geometry.attributes;this.meshPosition=v.position.array,this.meshColor=v.color.array,this.meshNormal=v.normal.array,this.setAttributes(t),g&&(this.meshIndex=this.geometry.getIndex().array,this.makeIndex())}return y&&(t.__proto__=y),((t.prototype=Object.create(y&&y.prototype)).constructor=t).prototype.setAttributes=function(t,e){void 0===t&&(t={}),void 0===e&&(e=!1);var i,r,n,o,a,s,c,u,h,l=this.geometry.attributes,p=this.updateNormals;t.position&&(i=t.position,n=this.geoPosition,c=this.meshPosition,a=this.transformedGeoPosition,l.position.needsUpdate=!0,(p||e)&&(o=this.geoNormal,h=this.meshNormal,s=this.transformedGeoNormal,l.normal.needsUpdate=!0)),t.color&&(r=t.color,u=this.meshColor,l.color.needsUpdate=!0);for(var d=this.positionCount,f=this.geoPositionCount,m=0;m<d;++m){var g=void 0,v=void 0,y=m*f*3,b=3*m;if(i&&a&&c&&h&&n&&o&&(a.set(n),gx.makeTranslation(i[b],i[b+1],i[b+2]),this.applyPositionTransform(gx,m,b),dm(gx.elements,a),c.set(a,y),p&&s?(s.set(o),vx.getNormalMatrix(gx),fm(vx.elements,s),h.set(s,y)):e&&h.set(o,y)),r&&u)for(g=0;g<f;++g)u[v=y+3*g]=r[b],u[v+1]=r[b+1],u[v+2]=r[b+2]}},t.prototype.makeIndex=function(){var t=this.geoIndex,e=this.meshIndex;if(t)for(var i=this.positionCount,r=this.geoPositionCount,n=3*(t.length/3),o=0;o<i;++o){var a=o*n,s=a+n;e.set(t,a);for(var c=a;c<s;++c)e[c]+=o*r}},t}(my),bx=new ri,xx=Object.assign({sphereDetail:1},ly),_x=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e,new es(1,bl(e.sphereDetail,1))),this.setAttributes(t,!0)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return xx},t.prototype.applyPositionTransform=function(t,e){var i=this._radius[e];bx.set(i,i,i),t.scale(bx)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.radius&&(this._radius=t.radius),i.prototype.setAttributes.call(this,t,e)},Object.defineProperties(t.prototype,e),t}(yx);rd.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 transpose( 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 = transpose( 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}"),rd.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}");var wx=function(n){function t(t,e,i){void 0===i&&(i={}),n.call(this,e,i),this.index=Ll(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:t,value:null}}),this.setAttributes({primitiveId:Hd(this.size)})}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={attributeSize:{configurable:!0},indexSize:{configurable:!0}};return e.attributeSize.get=function(){return this.size*this.mappingSize},e.indexSize.get=function(){return this.size*this.mappingIndicesSize},t.prototype.addAttributes=function(t){var e={};for(var i in t){var r=t[i];e[i]={type:r.type,value:null}}n.prototype.addAttributes.call(this,e)},t.prototype.getAttributeIndex=function(t){return 3*t*this.mappingSize},t.prototype.setAttributes=function(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Ud(t.position1,t.position2));var e,i,r,n,o,a,s,c=this.size,u=this.mappingSize,h=this.geometry.attributes;for(var l in t)if("index"!==l&&"picking"!==l){i=t[l],r=(e=h[l]).itemSize,n=e.array;for(var p=0;p<c;++p){a=(o=p*r)*u;for(var d=0;d<u;++d){s=a+r*d;for(var f=0;f<r;++f)n[s+f]=i[o+f]}}e.needsUpdate=!0}},t.prototype.makeMapping=function(){for(var t=this.size,e=this.mapping,i=this.mappingSize,r=this.mappingItemSize,n=this.geometry.attributes.mapping.array,o=0;o<t;o++)n.set(e,o*r*i)},t.prototype.makeIndex=function(){for(var t=this.size,e=this.mappingSize,i=this.mappingIndices,r=this.mappingIndicesSize,n=this.index,o=0;o<t;o++){var a=o*r,s=o*e;n.set(i,a);for(var c=0;c<r;++c)n[a+c]+=s}},Object.defineProperties(t.prototype,e),t}(dy),Sx=new Float32Array([-1,1,-1,-1,1,1,1,-1]),Ax=new Uint16Array([0,1,2,1,3,2]),Mx=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,"v2",t,e)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return e.mapping.get=function(){return Sx},e.mappingIndices.get=function(){return Ax},e.mappingIndicesSize.get=function(){return 6},e.mappingSize.get=function(){return 4},e.mappingItemSize.get=function(){return 2},Object.defineProperties(t.prototype,e),t}(wx),Ex=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e),this.isImpostor=!0,this.vertexShader="SphereImpostor.vert",this.fragmentShader="SphereImpostor.frag",this.addUniforms({projectionMatrixInverse:{value:new ei},ortho:{value:0}}),this.addAttributes({radius:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}return i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t}(Mx),Px=(Object.assign({disableImpostor:!1},xx),function(t,e){return!Xp||e&&e.disableImpostor?new _x(t,e):new Ex(t,e)});ad.add("sphere",Px),rd.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}"),rd.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}");var Tx=Object.assign({pointSize:1,sizeAttenuation:!0,sortParticles:!1,alphaTest:.5,useTexture:!1,forceTransparent:!1,edgeBleach:0},ly),Cx=Object.assign({pointSize:{uniform:"size"},sizeAttenuation:{updateShader:!0},sortParticles:{},alphaTest:{updateShader:!0},useTexture:{updateShader:!0},forceTransparent:{},edgeBleach:{uniform:!0}},py),Ix=function(r){function t(t,e){void 0===e&&(e={}),r.call(this,t,e),this.parameterTypes=Cx,this.vertexShader="Point.vert",this.fragmentShader="Point.frag",this.isPoint=!0,this.addUniforms({size:{value:this.parameters.pointSize},canvasHeight:{value:1},pixelRatio:{value:1},map:{value:null}})}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return Tx},t.prototype.makeMaterial=function(){r.prototype.makeMaterial.call(this),this.makeTexture();var t=this.material,e=this.wireframeMaterial,i=this.pickingMaterial;t.uniforms.map.value=this.tex,t.needsUpdate=!0,e.uniforms.map.value=this.tex,e.needsUpdate=!0,i.uniforms.map.value=this.tex,i.needsUpdate=!0},t.prototype.makeTexture=function(){this.tex&&this.tex.dispose(),this.tex=function(t){for(var e,i,r=t||{},n=bl(r.width,256),o=bl(r.height,256),a=[n/2,o/2],s=Math.min(n/2,o/2),c=bl(r.delta,1/(s+1))*s,u=0,h=0,l=new Uint8Array(n*o*4),p=0,d=l.length;p<d;p+=4){var f=1-Zl(s-c,s,(e=a[0]-u,i=a[1]-h,Math.sqrt(e*e+i*i)));l[p]=255*f,l[p+1]=255*f,l[p+2]=255*f,l[p+3]=255*f,++u===n&&(u=0,h++)}var m=new Ei(l,n,o);return m.needsUpdate=!0,m}({delta:this.parameters.edgeBleach})},t.prototype.getDefines=function(t){var e=r.prototype.getDefines.call(this,t);return this.parameters.sizeAttenuation&&(e.USE_SIZEATTENUATION=1),this.parameters.useTexture&&(e.USE_MAP=1),0<this.parameters.alphaTest&&this.parameters.alphaTest<=1&&(e.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),e},t.prototype.setUniforms=function(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),r.prototype.setUniforms.call(this,t)},t.prototype.dispose=function(){r.prototype.dispose.call(this),this.tex&&this.tex.dispose()},Object.defineProperties(t.prototype,e),t}(dy);ad.add("point",Ix);var Ox=function(r){function t(t,e,i){r.call(this,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 ay?(this.surface=void 0,this.volume=new Wy(t)):(this.surface=t,this.volume=void 0),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"uniform"),e.colorValue=bl(e.colorValue,14540253),this.thresholdType=bl(e.thresholdType,"sigma"),this.thresholdMin=bl(e.thresholdMin,2),this.thresholdMax=bl(e.thresholdMax,1/0),this.thresholdOut=bl(e.thresholdOut,!1),this.dotType=bl(e.dotType,"point"),this.radius=bl(e.radius,.1),this.scale=bl(e.scale,1),this.pointSize=bl(e.pointSize,1),this.sizeAttenuation=bl(e.sizeAttenuation,!0),this.sortParticles=bl(e.sortParticles,!1),this.useTexture=bl(e.useTexture,!1),this.alphaTest=bl(e.alphaTest,.5),this.forceTransparent=bl(e.forceTransparent,!1),this.edgeBleach=bl(e.edgeBleach,0),r.prototype.init.call(this,e),this.build()},t.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},t.prototype.create=function(){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 n=this.surface;Object.assign(t,{position:n.getPosition(),color:n.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:n.getSize(this.radius,this.scale),picking:n.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Px(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Ix(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)},t.prototype.update=function(t){if(void 0===t&&(t={}),0!==this.bufferList.length){var 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)}},t.prototype.setParameters=function(t,e,i){return void 0===e&&(e={}),t&&void 0!==t.thresholdType&&this.volume instanceof ay&&("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||Xp&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,"sphere"!==this.dotType||Xp&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.scale=!0,"sphere"!==this.dotType||Xp&&!this.disableImpostor||(i=!0)),r.prototype.setParameters.call(this,t,e,i),this},t}(sm);rd.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}"),rd.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}");var Lx=new Uint16Array([0,1,2,1,3,2]),Rx=new Float32Array([0,1,0,0,1,1,1,0]),Dx=Object.assign({filter:"nearest",forceTransparent:!0},ly),kx=Object.assign({filter:{updateShader:!0,uniform:!0}},py),Bx=function(l){function t(t,e){l.call(this,{position:t.position,index:Lx,picking:t.picking},e),this.parameterTypes=kx,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";var i=t.imageData,r=t.width,n=t.height,o=new Ei(i,r,n);o.flipY=!0,this.tex=o;for(var a=i.length,s=new Uint8Array(a),c=0;c<a;c+=4){var u=c/4;s[c]=u>>16&255,s[c+1]=u>>8&255,s[c+2]=255&u}var h=new Ei(s,r,n);h.flipY=!0,h.minFilter=Vt,h.magFilter=Vt,this.pickingTex=h,this.addUniforms({map:{value:o},pickingMap:{value:h},mapSize:{value:new ti(r,n)}}),this.geometry.addAttribute("uv",new wr(Rx,2))}l&&(t.__proto__=l),(t.prototype=Object.create(l&&l.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return Dx},t.prototype.getDefines=function(t){var e=l.prototype.getDefines.call(this,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},t.prototype.updateTexture=function(){var t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=Vt,t.magFilter=Vt):"linear"===e?(t.minFilter=Wt,t.magFilter=Wt):(t.minFilter=Vt,t.magFilter=Vt),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0},t.prototype.makeMaterial=function(){l.prototype.makeMaterial.call(this),this.updateTexture();var t=this.material;t.uniforms.map.value=this.tex,t.blending=Y,t.needsUpdate=!0;var e=this.wireframeMaterial;e.uniforms.map.value=this.tex,e.blending=Y,e.needsUpdate=!0;var i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=Y,i.needsUpdate=!0},t.prototype.setUniforms=function(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),l.prototype.setUniforms.call(this,t)},Object.defineProperties(t.prototype,e),t}(dy),Nx=function(t,e){var i=e||{};this.dimension=bl(i.dimension,"x"),this.positionType=bl(i.positionType,"percent"),this.position=bl(i.position,30),this.thresholdType=bl(i.thresholdType,"sigma"),this.thresholdMin=bl(i.thresholdMin,-1/0),this.thresholdMax=bl(i.thresholdMax,1/0),this.normalize=bl(i.normalize,!1),this.volume=t};Nx.prototype.getPositionFromCoordinate=function(t){var e,i=this.dimension,r=this.volume,n=r.matrix,o=(new ri).setFromMatrixPosition(n)[i],a=(new ri).setFromMatrixScale(n)[i];return e="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-o)/(e/100)+1)/a)},Nx.prototype.getData=function(t){t=t||{};var e,n=this.volume,i=n.data,o=n.matrix;function r(t){return Math.round(t/100*(e-1))}function a(t,e,i,r){return 3*(i*n.ny*n.nx+e*n.nx+t)+r}e="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;var s,c,u,h,l,p=new Float32Array(12),d=new ri,f=0,m=0,g=0,v=n.nx,y=n.ny,b=n.nz;function x(t,e,i,r){d.set(t,e,i).applyMatrix4(o).toArray(p,r)}"x"===this.dimension?(u=r(n.nx),h=n.ny-1,l=n.nz-1,s=n.nz,c=n.ny,v=(f=u)+1,x(u,0,0,0),x(u,h,0,3),x(u,0,l,6),x(u,h,l,9)):"y"===this.dimension?(u=n.nx-1,h=r(n.ny),l=n.nz-1,s=n.nz,c=n.nx,y=(m=h)+1,x(0,h,0,0),x(u,h,0,3),x(0,h,l,6),x(u,h,l,9)):"z"===this.dimension&&(u=n.nx-1,h=n.ny-1,l=r(n.nz),s=n.nx,c=n.ny,b=(g=l)+1,x(0,0,l,0),x(0,h,l,3),x(u,0,l,6),x(u,h,l,9));var _,w,S=0,A=0,M=new Uint8Array(s*c*4),E=new Float32Array(s*c);"sigma"===this.thresholdType?(_=n.getValueForSigma(this.thresholdMin),w=n.getValueForSigma(this.thresholdMax)):(_=this.thresholdMin,w=this.thresholdMax);var P=Object.assign({},t.colorParams,{volume:n});this.normalize&&(P.domain=[0,1]);var T,C=Qp.getScheme(P),I=new Float32Array(3),O=C.getScale(),L=0,R=0;if(this.normalize){L=1/0,T=-1/0;for(var D=m;D<y;++D)for(var k=f;k<v;++k)for(var B=g;B<b;++B){var N=i[a(k,D,B,0)/3];N<L&&(L=N),T<N&&(T=N)}R=T-L}for(var F=m;F<y;++F)for(var z=f;z<v;++z)for(var U=g;U<b;++U){var j=a(z,F,U,0)/3,G=i[j];this.normalize&&(G=(G-L)/R),C.colorToArray(O(G),I),M[S]=Math.round(255*I[0]),M[S+1]=Math.round(255*I[1]),M[S+2]=Math.round(255*I[2]),M[S+3]=_<G&&G<w?255:0,E[A]=j,++A,S+=4}var V=new Tv(E,n);return{position:p,imageData:M,width:s,height:c,picking:V}};var Fx=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="slice",this.parameters=Object.assign({filter:{type:"select",buffer:!0,options:{nearest:"nearest",linear:"linear","cubic-bspline":"cubic-bspline","cubic-catmulrom":"cubic-catmulrom","cubic-mitchell":"cubic-mitchell"}},positionType:{type:"select",rebuild:!0,options:{percent:"percent",coordinate:"coordinate"}},position:{type:"range",step:.1,max:100,min:1,rebuild:!0},dimension:{type:"select",rebuild:!0,options:{x:"x",y:"y",z:"z"}},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},normalize:{type:"boolean",rebuild:!0}},this.parameters,{flatShaded:null,side:null,wireframe:null,linewidth:null,colorScheme:null,roughness:null,metalness:null,diffuse:null}),this.volume=t,this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=this.volume,i=t||{};i.colorDomain=bl(i.colorDomain,[e.min,e.max]),i.colorScheme=bl(i.colorScheme,"value"),i.colorScale=bl(i.colorScale,"Spectral"),this.colorScheme="value",this.dimension=bl(i.dimension,"x"),this.filter=bl(i.filter,"cubic-bspline"),this.positionType=bl(i.positionType,"percent"),this.position=bl(i.position,30),this.thresholdType=bl(i.thresholdType,"sigma"),this.thresholdMin=bl(i.thresholdMin,-1/0),this.thresholdMax=bl(i.thresholdMax,1/0),this.normalize=bl(i.normalize,!1),r.prototype.init.call(this,i),this.build()},t.prototype.attach=function(t){var e=this;this.bufferList.forEach(function(t){e.viewer.add(t)}),this.setVisibility(this.visible),t()},t.prototype.create=function(){var t=new Nx(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 Bx(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)},t}(sm);function zx(t){Yp.error("makeRepresentation: representation type "+t+" unknown")}var Ux={name:"some element",status:""},jx=function(t,e){void 0===e&&(e={}),this.stage=t,this.signals={statusChanged:new op,nameChanged:new op,disposed:new op},this.parameters=xl(e,this.defaultParameters),this.uuid=$l()},Gx={defaultParameters:{configurable:!0},name:{configurable:!0}};Gx.defaultParameters.get=function(){return Ux},Gx.name.get=function(){return this.parameters.name},jx.prototype.setStatus=function(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this},jx.prototype.setName=function(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this},jx.prototype.dispose=function(){this.signals.disposed.dispatch()},Object.defineProperties(jx.prototype,Gx);var Vx=Object.assign({visible:!0},Ux),Hx=function(n){function t(t,e,i,r){void 0===i&&(i={}),n.call(this,t,Object.assign({name:e.type},i)),this.parent=r,this.signals=Object.assign({visibilityChanged:new op,parametersChanged:new op},this.signals),this.setRepresentation(e)}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultParameters:{configurable:!0},visible:{configurable:!0},type:{configurable:!0}};return e.defaultParameters.get=function(){return Vx},e.visible.get=function(){return this.parameters.visible},e.type.get=function(){return"representation"},t.prototype.getType=function(){return this.repr.type},t.prototype.setRepresentation=function(t){this._disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()},t.prototype._disposeRepresentation=function(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())},t.prototype.dispose=function(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())},t.prototype.setVisibility=function(t){return this.parameters.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this},t.prototype.getVisibility=function(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible},t.prototype.toggleVisibility=function(){return this.setVisibility(!this.parameters.visible)},t.prototype.updateVisibility=function(){this.repr.setVisibility(this.getVisibility())},t.prototype.update=function(t){return this.repr.update(t),this},t.prototype.build=function(t){return this.repr.build(t),this},t.prototype.setSelection=function(t){var e=this.repr;return e.setSelection&&e.setSelection(t),this},t.prototype.setParameters=function(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this},t.prototype.getParameters=function(){return this.repr.getParameters()},t.prototype.setColor=function(t){return this.repr.setColor(t),this},Object.defineProperties(t.prototype,e),t}(jx),$x=new ei,Wx=new ri,Xx={name:"",status:"",visible:!0},qx=function(t,e,i){void 0===i&&(i={}),this.stage=t,this.object=e,this.signals={representationAdded:new op,representationRemoved:new op,visibilityChanged:new op,matrixChanged:new op,statusChanged:new op,nameChanged:new op,disposed:new op},this.reprList=[],this.annotationList=[],this.matrix=new ei,this.position=new ri,this.quaternion=new ii,this.scale=new ri(1,1,1),this.transform=new ei,this.parameters=xl(i,this.defaultParameters),this.uuid=$l(),this.viewer=t.viewer,this.controls=new zy(this)},Yx={defaultParameters:{configurable:!0},name:{configurable:!0},status:{configurable:!0},visible:{configurable:!0}};Yx.defaultParameters.get=function(){return Xx},Yx.name.get=function(){return this.parameters.name},Yx.status.get=function(){return this.parameters.status},Yx.visible.get=function(){return this.parameters.visible},qx.prototype.setPosition=function(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this},qx.prototype.setRotation=function(t){if(Array.isArray(t))if(3===t.length){var e=(new Gi).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof Gi?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this},qx.prototype.setScale=function(t){return this.scale.set(t,t,t),this.updateMatrix(),this},qx.prototype.setTransform=function(t){return this.transform.copy(t),this.updateMatrix(),this},qx.prototype.updateMatrix=function(){var e=this,t=this.getCenterUntransformed(Wx);this.matrix.makeTranslation(-t.x,-t.y,-t.z),$x.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply($x),$x.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply($x);var i=this.position;$x.makeTranslation(i.x+t.x,i.y+t.y,i.z+t.z),this.matrix.premultiply($x),this.matrix.premultiply(this.transform),this.reprList.forEach(function(t){t.setParameters({matrix:e.matrix})}),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)},qx.prototype.addAnnotation=function(t,e,i){var r=new ky(this,t,e,i);return this.annotationList.push(r),r},qx.prototype.eachAnnotation=function(t){this.annotationList.slice().forEach(t)},qx.prototype.removeAnnotation=function(t){var e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())},qx.prototype.removeAllAnnotations=function(){this.eachAnnotation(function(t){return t.dispose()}),this.annotationList.length=0},qx.prototype._addRepresentation=function(t,e,i,r){void 0===r&&(r=!1);var n=i||{},o=this.stage.getParameters();n.matrix=this.matrix.clone(),n.quality=n.quality||o.quality,n.disableImpostor=bl(n.disableImpostor,!o.impostor),n.useWorker=bl(n.useWorker,o.workerDefault),n.visible=bl(n.visible,!0);var a=Object.assign({},n,{visible:this.parameters.visible&&n.visible}),s=function(t,e,i,r){var n;if(de.Debug&&Yp.time("makeRepresentation "+t),e instanceof cx){if(!(n=ed.get(t)))return void zx(t)}else if(e instanceof ry)if("surface"===t)n=wy;else{if("dot"!==t)return void zx(t);n=Ox}else if(e instanceof ay)if("surface"===t)n=wy;else if("dot"===t)n=Ox;else{if("slice"!==t)return void zx(t);n=Fx}else if(e instanceof dx)n=mx,e=e.getBufferList();else{if("buffer"!==t)return void Yp.error("makeRepresentation: object "+e+" unknown");n=mx}var o=new n(e,i,r);return de.Debug&&Yp.timeEnd("makeRepresentation "+t),o}(t,e,this.viewer,a),c=new Hx(this.stage,s,n,this);return r||(this.reprList.push(c),this.signals.representationAdded.dispatch(c)),c},qx.prototype.addBufferRepresentation=function(t,e){return this._addRepresentation.call(this,"buffer",t,e)},qx.prototype.hasRepresentation=function(t){return-1!==this.reprList.indexOf(t)},qx.prototype.eachRepresentation=function(t){this.reprList.slice().forEach(t)},qx.prototype.removeRepresentation=function(t){var e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))},qx.prototype.updateRepresentations=function(e){this.reprList.forEach(function(t){return t.update(e)}),this.stage.viewer.requestRender()},qx.prototype.removeAllRepresentations=function(){this.eachRepresentation(function(t){return t.dispose()})},qx.prototype.dispose=function(){this.removeAllAnnotations(),this.removeAllRepresentations(),delete this.annotationList,delete this.reprList,this.signals.disposed.dispatch()},qx.prototype.setVisibility=function(t){return this.parameters.visible=t,this.eachRepresentation(function(t){return t.updateVisibility()}),this.eachAnnotation(function(t){return t.updateVisibility()}),this.signals.visibilityChanged.dispatch(t),this},qx.prototype.setStatus=function(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this},qx.prototype.setName=function(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this},qx.prototype.getBox=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];return(t=this).getBoxUntransformed.apply(t,e).clone().applyMatrix4(this.matrix)},qx.prototype.getCenter=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];return(t=this).getCenterUntransformed.apply(t,e).clone().applyMatrix4(this.matrix)},qx.prototype.getZoom=function(){for(var t,e=[],i=arguments.length;i--;)e[i]=arguments[i];return this.stage.getZoomForBox((t=this).getBox.apply(t,e))},qx.prototype.getBoxUntransformed=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return new Pi},qx.prototype.getCenterUntransformed=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return this.getBoxUntransformed().getCenter(new ri)},qx.prototype.autoView=function(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),bl(t,0))},Object.defineProperties(qx.prototype,Yx);var Zx=function(t){void 0===t&&(t=[]);for(var e=(this.list=t).length,i=0;i<e;++i){t[i].signals.disposed.add(this._remove,this)}},Kx={first:{configurable:!0}};Zx.prototype._remove=function(t){var e=this.list.indexOf(t);-1!==e&&this.list.splice(e,1)},Kx.first.get=function(){return 0<this.list.length?this.list[0]:void 0},Zx.prototype.forEach=function(t){return this.list.forEach(t),this},Zx.prototype.dispose=function(){return this.forEach(function(t){return t.dispose()})},Object.defineProperties(Zx.prototype,Kx);var Jx=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.setParameters=function(e){return this.forEach(function(t){return t.setParameters(e)})},e.prototype.setVisibility=function(e){return this.forEach(function(t){return t.setVisibility(e)})},e.prototype.setSelection=function(e){return this.forEach(function(t){return t.setSelection(e)})},e.prototype.setColor=function(e){return this.forEach(function(t){return t.setColor(e)})},e.prototype.update=function(e){return this.forEach(function(t){return t.update(e)})},e.prototype.build=function(e){return this.forEach(function(t){return t.build(e)})},e.prototype.dispose=function(t){return this.forEach(function(t){return t.dispose()})},e}(Zx),Qx=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Ux),t_=function(n){function t(t,e,i){var r=this;void 0===i&&(i={}),n.call(this,t,Object.assign({name:e.name},i)),this.trajectory=e,this.signals=Object.assign(this.signals,{frameChanged:new op,playerChanged:new op,countChanged:new op,parametersChanged:new op}),e.signals.frameChanged.add(function(t){r.signals.frameChanged.dispatch(t)}),e.signals.playerChanged.add(function(t){r.signals.playerChanged.dispatch(t)}),e.signals.countChanged.add(function(t){r.signals.countChanged.dispatch(t)}),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultParameters:{configurable:!0},type:{configurable:!0}};return e.defaultParameters.get=function(){return Qx},e.type.get=function(){return"trajectory"},t.prototype.setFrame=function(t){this.trajectory.setFrame(t)},t.prototype.setParameters=function(t){void 0===t&&(t={}),this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)},t.prototype.dispose=function(){this.trajectory.dispose(),n.prototype.dispose.call(this)},Object.defineProperties(t.prototype,e),t}(jx),e_=function(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1},i_={type:{configurable:!0}};i_.type.get=function(){return"Frames"},Object.defineProperties(e_.prototype,i_);var r_=function(t,e){var i,r;if(this.A=new kv(3,3),this.W=new kv(1,3),this.U=new kv(3,3),this.V=new kv(3,3),this.VH=new kv(3,3),this.R=new kv(3,3),this.tmp=new kv(3,3),this.c=new kv(3,3),t instanceof cx)i=t.atomCount;else{if(!(t instanceof Float32Array))return;i=t.length/3}if(e instanceof cx)r=e.atomCount;else{if(!(e instanceof Float32Array))return;r=e.length/3}var n=Math.min(i,r),o=new kv(3,n),a=new kv(3,n);this.coords1t=new kv(n,3),this.coords2t=new kv(n,3),this.transformationMatrix=new ei,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)};r_.prototype._superpose=function(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S;this.mean1=zv(t),this.mean2=zv(e),Uv(t,this.mean1),Uv(e,this.mean2),Bv(this.coords1t,t),Bv(this.coords2t,e),Nv(this.A,this.coords2t,this.coords1t),Hv(this.A,this.W,this.U,this.V),i=this.V,r=this.VH,n=i.data,o=r.data,a=n[4],s=n[8],c=n[5],u=n[7],h=n[0],l=h*a,p=h*c,d=n[3],f=n[1],m=d*f,g=n[2],v=d*g,y=n[6],_=1/(l*s-p*u-m*s+v*u+(b=y*f)*c-(x=y*g)*a),o[0]=(a*s-c*u)*_,o[1]=-(f*s-g*u)*_,o[2]=-(-f*c+g*a)*_,o[3]=-(d*s-c*y)*_,o[4]=(h*s-x)*_,o[5]=-(p-v)*_,o[6]=-(-d*u+a*y)*_,o[7]=-(h*u-b)*_,o[8]=(l-m)*_,Fv(this.R,this.U,this.VH),w=this.R,(S=w.data)[0]*S[4]*S[8]-S[0]*S[5]*S[7]-S[3]*S[1]*S[8]+S[3]*S[2]*S[7]+S[6]*S[1]*S[5]-S[6]*S[2]*S[4]<0&&(de.Debug&&Yp.log("R not a right handed system"),Fv(this.tmp,this.c,this.VH),Fv(this.R,this.U,this.tmp));var A=new kv(4,4),M=new kv(4,4),E=new kv(4,4),P=new kv(4,4),T=new kv(4,4),C=new kv(4,4),I=this.R.data,O=this.mean1,L=this.mean2;P.data.set([1,0,0,-O[0],0,1,0,-O[1],0,0,1,-O[2],0,0,0,1]),T.data.set([I[0],I[1],I[2],0,I[3],I[4],I[5],0,I[6],I[7],I[8],0,0,0,0,1]),C.data.set([1,0,0,L[0],0,1,0,L[1],0,0,1,L[2],0,0,0,1]),Bv(M,P),Nv(A,T,M),Bv(E,A),Nv(M,C,E),Bv(A,M),this.transformationMatrix.elements=A.data},r_.prototype.prepCoords=function(t,e,i,r){var n=0,o=e.data,a=3,s=3*i;if(r&&(s=4*i,a=4),t instanceof cx)t.eachAtom(function(t){n<s&&(o[n+0]=t.x,o[n+1]=t.y,o[n+2]=t.z,r&&(o[n+3]=1),n+=a)});else if(t instanceof Float32Array)for(;n<s;n+=a)n<s&&(o[n]=t[n],o[n+1]=t[n+1],o[n+2]=t[n+2],r&&(o[n+3]=1));else Yp.warn("prepCoords: input type unknown")},r_.prototype.transform=function(t){var e;if(t instanceof cx)e=t.atomCount;else{if(!(t instanceof Float32Array))return;e=t.length/3}var i=new kv(4,e),r=new kv(e,4);this.prepCoords(t,i,e,!0);var n=this.transformationMatrix,o=n.determinant();if(!o)return o;var a=new kv(4,4);a.data=n.elements,function(t,e,i){for(var r=0,n=0,o=0,a=0,s=0,c=0,u=0,h=0,l=e.cols,p=e.rows,d=i.cols,f=e.data,m=i.data,g=t.data,v=0;r<p;a+=l,r++)for(n=u=0;n<d;h++,u++,n++){for(c=u,s=a,o=v=0;o<l;s++,c+=d,o++)v+=f[s]*m[c];g[h]=v}}(r,i,a);var s=0,c=r.data;if(t instanceof cx){t.eachAtom(function(t){t.x=c[s],t.y=c[s+1],t.z=c[s+2],s+=4});var u=new ei;u.getInverse(n);var h=t.biomolDict;for(var l in h){if(h.hasOwnProperty(l))h[l].partList.forEach(function(t){t.matrixList.forEach(function(t){t.premultiply(n),t.multiply(u)})})}}else if(t instanceof Float32Array)for(var p=4*e;s<p;s+=4)t[s]=c[s],t[s+1]=c[s+1],t[s+2]=c[s+2];else Yp.warn("transform: input type unknown");return this.transformationMatrix};var n_={step:1,timeout:50,start:0,end:0,interpolateType:"",interpolateStep:5,mode:"loop",direction:"forward"},o_=function(t,e){var i=this;void 0===e&&(e={}),this.signals={startedRunning:new op,haltedRunning:new op},this._run=!1,this._previousTime=0,this._currentTime=0,this._currentStep=1,t.signals.playerChanged.add(function(t){t!==i&&i.pause()},this);var r=bl(t.frameCount,1);this.traj=t,this.parameters=xl(e,n_),this.parameters.end=Math.min(bl(e.end,r-1),r-1),this.parameters.step=bl(e.step,Math.ceil((r+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,t.signals.countChanged.add(function(t){i.parameters.end=Math.min(bl(i.parameters.end,t-1),t-1)},this),this._animate=this._animate.bind(this)},a_={isRunning:{configurable:!0}};a_.isRunning.get=function(){return this._run},o_.prototype.setParameters=function(t){void 0===t&&(t={}),_l(this.parameters,t),void 0!==t.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)},o_.prototype._animate=function(){if(this._run){this._currentTime=window.performance.now();var 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&&i<=t)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;var n=this._currentStep/(this.parameters.interpolateStep+1),o=this._currentFrame,a=o[0],s=o[1],c=o[2],u=o[3];r.setFrameInterpolated(a,s,c,u,n,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{var h=this._next();r.hasFrame(h)?(r.setFrame(h),this._previousTime=this._currentTime):r.loadFrame(h)}window.requestAnimationFrame(this._animate)}},o_.prototype._next=function(){var t,e=this.parameters;return((t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step)>e.end||t<e.start)&&("bounce"===e.direction&&("forward"===this._direction?this._direction="backward":this._direction="forward"),"once"===e.mode?(this.pause(),t="forward"===e.direction?e.end:"backward"===e.direction?e.start:"forward"===this._direction?e.start:e.end):"forward"===this._direction?(t=e.start,e.interpolateType&&(t=Math.min(e.end,t+e.step))):(t=e.end,e.interpolateType&&(t=Math.max(e.start,t-e.step)))),t},o_.prototype._nextInterpolated=function(){var t,e,i,r=this.parameters,n=this._next();return"forward"===this._direction?(t=Math.max(r.start,n-r.step),e=Math.max(r.start,n-2*r.step),i=Math.max(r.start,n-3*r.step)):(t=Math.min(r.end,n+r.step),e=Math.min(r.end,n+2*r.step),i=Math.min(r.end,n+3*r.step)),[n,t,e,i]},o_.prototype.toggle=function(){this._run?this.pause():this.play()},o_.prototype.play=function(){if(!this._run){this.traj.player!==this&&this.traj.setPlayer(this),this._currentStep=1;var t=this.parameters,e=this.traj.currentFrame,i=Math.ceil(e/t.step)*t.step;"forward"===t.direction&&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()}},o_.prototype.pause=function(){this._run=!1,this.signals.haltedRunning.dispatch()},o_.prototype.stop=function(){this.pause(),this.traj.setFrame(this.parameters.start)},Object.defineProperties(o_.prototype,a_);var s_=function(t,e,i){var r=this;void 0===i&&(i={}),this.signals={countChanged:new op,frameChanged:new op,playerChanged:new op},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=bl(i.deltaTime,0),this.timeOffset=bl(i.timeOffset,0),this.centerPbc=bl(i.centerPbc,!1),this.removePbc=bl(i.removePbc,!1),this.removePeriodicity=bl(i.removePeriodicity,!1),this.superpose=bl(i.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new Lp(bl(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add(function(){r.selectionIndices=r.structure.getAtomIndices(r.selection),r._resetCache(),r._saveInitialCoords(),r.setFrame(r._currentFrame)})},c_={frameCount:{configurable:!0},currentFrame:{configurable:!0}};c_.frameCount.get=function(){return this._frameCount},c_.currentFrame.get=function(){return this._currentFrame},s_.prototype._init=function(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new o_(this))},s_.prototype._loadFrameCount=function(){},s_.prototype.setStructure=function(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new Lp("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)},s_.prototype._saveInitialCoords=function(){var t=this;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,function(){return t._saveInitialCoords()})},s_.prototype._saveStructureCoords=function(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position},s_.prototype.setSelection=function(t){return this.selection.setString(t),this},s_.prototype._getIndices=function(t){var e=0,i=t.test,r=[];return i&&this.structure.eachAtom(function(t){i(t)&&r.push(e),e+=1}),r},s_.prototype._makeSuperposeCoords=function(){var t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);for(var e=this.initialCoords,i=this.coords2,r=0;r<t;r+=3){var n=3*this.selectionIndices[r/3];i[r+0]=e[n+0],i[r+1]=e[n+1],i[r+2]=e[n+2]}},s_.prototype._makeAtomIndices=function(){Yp.error("Trajectory._makeAtomIndices not implemented")},s_.prototype._resetCache=function(){this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this.initialCoords=new Float32Array(0)},s_.prototype.setParameters=function(t){void 0===t&&(t={});var e=!1;void 0!==t.centerPbc&&t.centerPbc!==this.centerPbc&&(this.centerPbc=t.centerPbc,e=!0),void 0!==t.removePeriodicity&&t.removePeriodicity!==this.removePeriodicity&&(this.removePeriodicity=t.removePeriodicity,e=!0),void 0!==t.removePbc&&t.removePbc!==this.removePbc&&(this.removePbc=t.removePbc,e=!0),void 0!==t.superpose&&t.superpose!==this.superpose&&(this.superpose=t.superpose,e=!0),this.deltaTime=bl(t.deltaTime,this.deltaTime),this.timeOffset=bl(t.timeOffset,this.timeOffset),e&&(this._resetCache(),this.setFrame(this._currentFrame))},s_.prototype.hasFrame=function(t){var e=this;return Array.isArray(t)?t.every(function(t){return!!e.frameCache[t]}):!!this.frameCache[t]},s_.prototype.setFrame=function(t,e){var i=this;return void 0===t||(this.inProgress=!0,-1===t||this.frameCache[t]?(this._updateStructure(t),e&&e()):this.loadFrame(t,function(){i._updateStructure(t),e&&e()})),this},s_.prototype._interpolate=function(t,e,i,r,n,o){var a,s=this.frameCache;a="spline"===o?function(t,e,i,r,n){for(var o=t.length,a=new Float32Array(o),s=0;s<o;s+=3){var c=s+1,u=s+2;a[s]=Yl(r[s],i[s],e[s],t[s],n,1),a[c]=Yl(r[c],i[c],e[c],t[c],n,1),a[u]=Yl(r[u],i[u],e[u],t[u],n,1)}return a}(s[t],s[e],s[i],s[r],n):function(t,e,i){for(var r=t.length,n=new Float32Array(r),o=0;o<r;o+=3){var a=o+1,s=o+2;n[o]=ql(e[o],t[o],i),n[a]=ql(e[a],t[a],i),n[s]=ql(e[s],t[s],i)}return n}(s[t],s[e],n),this.structure.updatePosition(a),this._currentFrame=t,this.signals.frameChanged.dispatch(t)},s_.prototype.setFrameInterpolated=function(t,e,i,r,n,o,a){var s=this;if(void 0===t)return this;var c=this.frameCache,u=[];return c[r]||u.push(r),c[i]||u.push(i),c[e]||u.push(e),c[t]||u.push(t),u.length?this.loadFrame(u,function(){s._interpolate(t,e,i,r,n,o),a&&a()}):(this._interpolate(t,e,i,r,n,o),a&&a()),this},s_.prototype.loadFrame=function(t,e){var i=this;Array.isArray(t)?t.forEach(function(t){i.loadQueue[t]||i.frameCache[t]||(i.loadQueue[t]=!0,i._loadFrame(t,function(){delete i.loadQueue[t]}))}):this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,function(){delete i.loadQueue[t],e&&e()}))},s_.prototype._loadFrame=function(t,e){Yp.error("Trajectory._loadFrame not implemented",t,e)},s_.prototype._updateStructure=function(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))},s_.prototype._doSuperpose=function(t){for(var e=3*this.selectionIndices.length,i=this.coords1,r=this.coords2,n=0;n<e;n+=3){var o=3*this.selectionIndices[n/3];i[n+0]=t[o+0],i[n+1]=t[o+1],i[n+2]=t[o+2]}new r_(i,r).transform(t)},s_.prototype._process=function(t,e,i,r){if(this._setFrameCount(r),e){if(0<this.backboneIndices.length&&this.centerPbc){var n=[e[0],e[4],e[8]];!function(t,e,i){if(0!==i[0]&&0!==i[8]&&0!==i[4])for(var r=t.length,n=i[0],o=i[1],a=i[2],s=-e[0]+n+n/2,c=-e[1]+o+o/2,u=-e[2]+a+a/2,h=0;h<r;h+=3)t[h+0]=(t[h+0]+s)%n,t[h+1]=(t[h+1]+c)%o,t[h+2]=(t[h+2]+u)%a}(i,(a=this.backboneIndices,[zd(s=i,(c=n)[0],3,0,a),zd(s,c[1],3,1,a),zd(s,c[2],3,2,a)]),n)}if(this.removePeriodicity)!function(t,e,i){if(0!==e[0]&&0!==e[8]&&0!==e[4]){for(var r=t.length,n=3;n<r;n+=3)for(var o=0;o<3;++o){var a=(t[n+o]-i[o])/e[3*o+o];.5<Math.abs(a)&&(t[n+o]-=e[3*o+o]*Math.round(a))}}}(i,e,[Jd(o=i,3,0),Jd(o,3,1),Jd(o,3,2)]);this.removePbc&&function(t,e){if(0!==e[0]&&0!==e[8]&&0!==e[4]){for(var i=t.length,r=3;r<i;r+=3)for(var n=0;n<3;++n){var o=t[r+n]-t[r-3+n];if(Math.abs(o)>.9*e[3*n+n])if(0<o)for(var a=0;a<3;++a)t[r+a]-=e[3*n+a];else for(var s=0;s<3;++s)t[r+s]+=e[3*n+s]}}}(i,e)}var o,a,s,c;0<this.selectionIndices.length&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1},s_.prototype._setFrameCount=function(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))},s_.prototype.dispose=function(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()},s_.prototype.setPlayer=function(t){this.player=t,this.signals.playerChanged.dispatch(t)},s_.prototype.getFrameTime=function(t){return this.timeOffset+t*this.deltaTime},Object.defineProperties(s_.prototype,c_);var u_=function(n){function t(t,e,i){var r=i||{};r.timeOffset=bl(r.timeOffset,t.timeOffset),r.deltaTime=bl(r.deltaTime,t.deltaTime),n.call(this,"",e,r),this.name=t.name,this.path=t.path,this.frames=t.coordinates,this.boxes=t.boxes,this._init(e)}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"frames"},t.prototype._makeAtomIndices=function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0},t.prototype._loadFrame=function(t,e){var i,r=this.frames[t];if(this.atomIndices){var n=this.atomIndices,o=n.length;i=new Float32Array(3*o);for(var a=0;a<o;++a){var s=3*a,c=3*n[a];i[s+0]=r[c+0],i[s+1]=r[c+1],i[s+2]=r[c+2]}}else i=new Float32Array(r);var u=this.boxes[t],h=this.frames.length;this._process(t,u,i,h),"function"==typeof e&&e()},t.prototype._loadFrameCount=function(){this.frames&&this._setFrameCount(this.frames.length)},Object.defineProperties(t.prototype,e),t}(s_),h_=function(r){function t(t,e,i){r.call(this,"",e,i),this._init(e)}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"structure"},t.prototype._makeAtomIndices=function(){this.structure.atomSet&&this.structure.atomSet.getSize()<this.structure.atomStore.count?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0},t.prototype._loadFrame=function(t,e){var i,r=this.structure,n=r.frames[t];if(this.atomIndices){var o=this.atomIndices,a=o.length;i=new Float32Array(3*a);for(var s=0;s<a;++s){var c=3*s,u=3*o[s];i[c+0]=n[u+0],i[c+1]=n[u+1],i[c+2]=n[u+2]}}else i=new Float32Array(n);var h=r.boxes[t],l=r.frames.length;this._process(t,h,i,l),"function"==typeof e&&e()},t.prototype._loadFrameCount=function(){this._setFrameCount(this.structure.frames.length)},Object.defineProperties(t.prototype,e),t}(s_),l_=function(r){function t(t,e,i){r.call(this,t,e,i),this._init(e)}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"remote"},t.prototype._makeAtomIndices=function(){var t=[];if("StructureView"===this.structure.type){for(var e=this.structure.getAtomIndices(),i=e.length,r=e[0],n=e[0],o=1;o<i;++o){var a=e[o];n+1<a&&(t.push([r,n+1]),r=a),n=a}t.push([r,n+1])}else t.push([0,this.atomCount]);this.atomIndices=t},t.prototype._loadFrame=function(n,o){var a=this,s=new XMLHttpRequest,c=de.TrajectoryDatasource.getFrameUrl(this.trajPath,n),t=de.TrajectoryDatasource.getFrameParams(this.trajPath,this.atomIndices);s.open("POST",c,!0),s.responseType="arraybuffer",s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),s.addEventListener("load",function(){var t=s.response;if(t){var e=new Int32Array(t,0,1)[0],i=new Float32Array(t,8,9),r=new Float32Array(t,44);a._process(n,i,r,e),"function"==typeof o&&o()}else Yp.error("empty arrayBuffer for '"+c+"'")},!1),s.send(t)},t.prototype._loadFrameCount=function(){var t=this,e=new XMLHttpRequest,i=de.TrajectoryDatasource.getCountUrl(this.trajPath);e.open("GET",i,!0),e.addEventListener("load",function(){t._setFrameCount(parseInt(e.response))},!1),e.send()},Object.defineProperties(t.prototype,e),t}(s_);cx.prototype.getView=function(t){return new p_(this,t)};var p_=function(i){function t(t,e){i.call(this),this.structure=t,this.selection=e,this.center=new ri,this.boundingBox=new Pi,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()}i&&(t.__proto__=i);var e={type:{configurable:!0},name:{configurable:!0},path:{configurable:!0},title:{configurable:!0},id:{configurable:!0},data:{configurable:!0},atomSetDict:{configurable:!0},biomolDict:{configurable:!0},entityList:{configurable:!0},unitcell:{configurable:!0},frames:{configurable:!0},boxes:{configurable:!0},validation:{configurable:!0},bondStore:{configurable:!0},backboneBondStore:{configurable:!0},rungBondStore:{configurable:!0},atomStore:{configurable:!0},residueStore:{configurable:!0},chainStore:{configurable:!0},modelStore:{configurable:!0},atomMap:{configurable:!0},residueMap:{configurable:!0},bondHash:{configurable:!0},spatialHash:{configurable:!0},_hasCoords:{configurable:!0}};return((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.init=function(){},e.type.get=function(){return"StructureView"},e.name.get=function(){return this.structure.name},e.path.get=function(){return this.structure.path},e.title.get=function(){return this.structure.title},e.id.get=function(){return this.structure.id},e.data.get=function(){return this.structure.data},e.atomSetDict.get=function(){return this.structure.atomSetDict},e.biomolDict.get=function(){return this.structure.biomolDict},e.entityList.get=function(){return this.structure.entityList},e.unitcell.get=function(){return this.structure.unitcell},e.frames.get=function(){return this.structure.frames},e.boxes.get=function(){return this.structure.boxes},e.validation.get=function(){return this.structure.validation},e.bondStore.get=function(){return this.structure.bondStore},e.backboneBondStore.get=function(){return this.structure.backboneBondStore},e.rungBondStore.get=function(){return this.structure.rungBondStore},e.atomStore.get=function(){return this.structure.atomStore},e.residueStore.get=function(){return this.structure.residueStore},e.chainStore.get=function(){return this.structure.chainStore},e.modelStore.get=function(){return this.structure.modelStore},e.atomMap.get=function(){return this.structure.atomMap},e.residueMap.get=function(){return this.structure.residueMap},e.bondHash.get=function(){return this.structure.bondHash},e.spatialHash.get=function(){return this.structure.spatialHash},e._hasCoords.get=function(){return this.structure._hasCoords},e._hasCoords.set=function(t){this.structure._hasCoords=t},t.prototype.refresh=function(){de.Debug&&Yp.time("StructureView.refresh"),this.atomSetCache={};var t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){for(var e in this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone(),this.atomSetDict){var i=this.atomSetDict[e];this.atomSetCache["__"+e]=i.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){for(var r in this.atomSet=new tg(t.atomCount),this.bondSet=new tg(t.bondCount),this.atomSetDict)this.atomSetCache["__"+r]=new tg(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{for(var n in this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet(),this.atomSetDict){var o=this.atomSetDict[n];this.atomSetCache["__"+n]=o.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new ri)}de.Debug&&Yp.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()},t.prototype.setSelection=function(t){this.selection=t,this.refresh()},t.prototype.getSelection=function(t){var e=[];t&&t.string&&e.push(t.string);var i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);var r="";return 0<e.length&&(r="( "+e.join(" ) AND ( ")+" )"),new Lp(r)},t.prototype.getStructure=function(){return this.structure.getStructure()},t.prototype.eachBond=function(t,e){this.structure.eachBond(t,this.getSelection(e))},t.prototype.eachAtom=function(e,t){var i=this.getAtomProxy(),r=this.getAtomSet(t),n=this.atomStore.count;if(r.getSize()<n)r.forEach(function(t){i.index=t,e(i)});else for(var o=0;o<n;++o)i.index=o,e(i)},t.prototype.eachResidue=function(t,e){this.structure.eachResidue(t,this.getSelection(e))},t.prototype.eachResidueN=function(t,e){console.error("StructureView.eachResidueN() not implemented")},t.prototype.eachChain=function(t,e){this.structure.eachChain(t,this.getSelection(e))},t.prototype.eachModel=function(t,e){this.structure.eachModel(t,this.getSelection(e))},t.prototype.getAtomSet=function(t,e){void 0===e&&(e=!1);var i=this.structure.getAtomSet(t);return!e&&this.atomSet&&(i=i.makeIntersection(this.atomSet)),i},t.prototype.getAtomIndices=function(t){return this.structure.getAtomIndices(this.getSelection(t))},t.prototype.refreshPosition=function(){return this.structure.refreshPosition()},t.prototype.dispose=function(){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(t.prototype,e),t}(cx),d_=[[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]];function f_(i,t){var r,n=0,o={};return t.forEach(function(t){r=0;var e={};t.forEach(function(t){e[i[r++]]=t}),o[i[n++]]=e}),o}var m_={blosum62:f_("ARNDCQEGHILKMFPSTWYVBZ?",[[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]]),blosum62x:f_("ACDEFGHIKLMNPQRSTVWY",d_)},g_=function(t,e,i,r,n){void 0===i&&(i=-10),void 0===r&&(r=-1),void 0===n&&(n="blosum62"),this.seq1=t,this.seq2=e,this.gapPenalty=i,this.gapExtensionPenalty=r,n&&(this.substMatrix=m_[n])};function v_(t,e,i,r,n){var o,a,s,c,u;if(void 0===i&&(i=!1),void 0===r&&(r=""),void 0===n&&(n=""),i){var h=t,l=e;r&&n&&(h=t.getView(new Lp(r)),l=e.getView(new Lp(n)));var p,d,f=h.getSequence(),m=l.getSequence(),g=new g_(f.join(""),m.join(""));g.calc(),g.trace(),a=o=0,s=g.ali1.length;for(var v=[],y=[],b=0;b<s;++b){var x=g.ali1[b],_=g.ali2[b];d=p=0,"-"===x?y[a]=!1:(y[a]=!0,p=1),"-"===_?v[o]=!1:(v[o]=!0,d=1),o+=p,a+=d}var w=[],S=[],A=h.getAtomProxy(),M=l.getAtomProxy();o=0,h.eachResidue(function(t){void 0!==t.traceAtomIndex&&t.traceAtomIndex===t.getAtomIndexByName("CA")&&(v[o]&&(A.index=t.getAtomIndexByName("CA"),w.push(A.x,A.y,A.z)),o+=1)}),o=0,l.eachResidue(function(t){void 0!==t.traceAtomIndex&&t.traceAtomIndex===t.getAtomIndexByName("CA")&&(y[o]&&(M.index=t.getAtomIndexByName("CA"),S.push(M.x,M.y,M.z)),o+=1)}),c=new Float32Array(w),u=new Float32Array(S)}else{c=t.getView(new Lp(r+" and .CA")),u=e.getView(new Lp(n+" and .CA"))}var E=new r_(c,u).transform(t);return t.refreshPosition(),E}g_.prototype.initMatrices=function(){var t=this;this.n=this.seq1.length,this.m=this.seq2.length,this.score=void 0,this.ali="",this.S=[],this.V=[],this.H=[];for(var e=0;e<=this.n;++e){t.S[e]=[],t.V[e]=[],t.H[e]=[];for(var i=0;i<=this.m;++i)t.S[e][i]=0,t.V[e][i]=0,t.H[e][i]=0}for(var r=0;r<=this.n;++r)t.S[r][0]=t.gap(0),t.H[r][0]=-1/0;for(var n=0;n<=this.m;++n)t.S[0][n]=t.gap(0),t.V[0][n]=-1/0;this.S[0][0]=0},g_.prototype.gap=function(t){return this.gapPenalty+t*this.gapExtensionPenalty},g_.prototype.makeScoreFn=function(){var n=this.seq1,o=this.seq2,a=this.substMatrix;return a?function(t,e){var i=n[t],r=o[e];try{return a[i][r]}catch(t){return-4}}:(Yp.warn("Alignment: no subst matrix"),function(t,e){return n[t]===o[e]?5:-3})},g_.prototype.calc=function(){de.Debug&&Yp.time("Alignment.calc"),this.initMatrices();for(var t,e,i,r,n,o=this.gap(0),a=this.makeScoreFn(),s=this.gapExtensionPenalty,c=this.V,u=this.H,h=this.S,l=this.n,p=this.m,d=1;d<=l;++d){e=h[d-1],t=c[d-1],i=c[d],r=u[d],n=h[d];for(var f=1;f<=p;++f)i[f]=Math.max(e[f]+o,t[f]+s),r[f]=Math.max(n[f-1]+o,r[f-1]+s),n[f]=Math.max(e[f-1]+a(d-1,f-1),i[f],r[f])}de.Debug&&Yp.timeEnd("Alignment.calc"),de.Debug&&Yp.log(this.S,this.V,this.H)},g_.prototype.trace=function(){var t=this;de.Debug&&Yp.time("Alignment.trace"),this.ali1="",this.ali2="";var e,i=this.makeScoreFn(),r=this.n,n=this.m;for(this.S[r][n]>=this.V[r][n]?(e="S",this.score=this.S[r][n]):this.V[r][n]>=this.H[r][n]?(e="V",this.score=this.V[r][n]):(e="H",this.score=this.H[r][n]),de.Debug&&Yp.log("Alignment: SCORE",this.score),de.Debug&&Yp.log("Alignment: S, V, H",this.S[r][n],this.V[r][n],this.H[r][n]);0<r&&0<n;)"S"===e?t.S[r][n]===t.S[r-1][n-1]+i(r-1,n-1)?(t.ali1=t.seq1[r-1]+t.ali1,t.ali2=t.seq2[n-1]+t.ali2,--r,--n,e="S"):t.S[r][n]===t.V[r][n]?e="V":t.S[r][n]===t.H[r][n]?e="H":(--r,--n):"V"===e?t.V[r][n]===t.V[r-1][n]+t.gapExtensionPenalty?(t.ali1=t.seq1[r-1]+t.ali1,t.ali2="-"+t.ali2,--r,e="V"):t.V[r][n]===t.S[r-1][n]+t.gap(0)?(t.ali1=t.seq1[r-1]+t.ali1,t.ali2="-"+t.ali2,--r,e="S"):--r:"H"===e?t.H[r][n]===t.H[r][n-1]+t.gapExtensionPenalty?(t.ali1="-"+t.ali1,t.ali2=t.seq2[n-1]+t.ali2,--n,e="H"):t.H[r][n]===t.S[r][n-1]+t.gap(0)?(t.ali1="-"+t.ali1,t.ali2=t.seq2[n-1]+t.ali2,--n,e="S"):--n:Yp.error("Alignment: no matrix");for(;0<r;)t.ali1=t.seq1[r-1]+t.ali1,t.ali2="-"+t.ali2,--r;for(;0<n;)t.ali1="-"+t.ali1,t.ali2=t.seq2[n-1]+t.ali2,--n;de.Debug&&Yp.timeEnd("Alignment.trace"),de.Debug&&Yp.log([this.ali1,this.ali2])};var y_=Object.assign({sele:"",defaultAssembly:""},Xx),b_=function(c){function t(t,e,i){var r,n,o,a,s;void 0===i&&(i={}),c.call(this,t,e,Object.assign({name:e.name},i)),this.structure=e,this.trajList=[],this.signals=Object.assign(this.signals,{trajectoryAdded:new op,trajectoryRemoved:new op,defaultAssemblyChanged:new op}),this.initSelection(this.parameters.sele),this.pickBuffer=(r=4,o=n=0,a=[],{has:function(t){return-1!==a.indexOf(t)},get:function(t){return a[t]},push:function(t){a[n]=t,n=(r+n+1)%r,++o},get count(){return o},get data(){return a.slice(0,Math.min(o,r))},clear:function(){n=o=0,a.length=0}}),this.pickDict=(s={},{has:function(t){return void 0!==s[JSON.stringify(t)]},add:function(t,e){s[JSON.stringify(t)]=e},del:function(t){delete s[JSON.stringify(t)]},get values(){return Object.keys(s).map(function(t){return s[t]})}}),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Zp.opacity,color:Zp.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Zp,!0),this.angleRepresentation=this.addRepresentation("angle",Zp,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Zp,!0),this.measureRepresentations=new Jx([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly)}c&&(t.__proto__=c),(t.prototype=Object.create(c&&c.prototype)).constructor=t;var e={defaultParameters:{configurable:!0},type:{configurable:!0}};return e.defaultParameters.get=function(){return y_},e.type.get=function(){return"structure"},t.prototype.initSelection=function(t){var e=this;this.selection=new Lp(t),this.structureView=new p_(this.structure,this.selection),this.selection.signals.stringChanged.add(function(){e.structureView.setSelection(e.selection),e.rebuildRepresentations(),e.rebuildTrajectories()})},t.prototype.setSelection=function(t){return this.parameters.sele=t,this.selection.setString(t),this},t.prototype.setDefaultAssembly=function(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){var e={defaultAssembly:t};this.reprList.forEach(function(t){return t.setParameters(e)}),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this},t.prototype.rebuildRepresentations=function(){this.reprList.forEach(function(t){t.build()}),this.measureRepresentations.build()},t.prototype.rebuildTrajectories=function(){var e=this;this.trajList.forEach(function(t){t.trajectory.setStructure(e.structureView)})},t.prototype.updateRepresentations=function(t){c.prototype.updateRepresentations.call(this,t),this.measureRepresentations.update(t)},t.prototype.addRepresentation=function(t,e,i){var r=this;void 0===e&&(e={}),void 0===i&&(i=!1),e.defaultAssembly=this.parameters.defaultAssembly;var n=this._addRepresentation(t,this.structureView,e,i);return i||n.signals.parametersChanged.add(function(){return r.measureUpdate()}),n},t.prototype.addTrajectory=function(t,e){var i=this;void 0===t&&(t=""),void 0===e&&(e={});var r,n,o,a=(r=t,n=this.structureView,o=e,r&&r instanceof e_?new u_(r,n,o):!r&&n.frames?new h_(r,n,o):new l_(r,n,o));a.signals.frameChanged.add(function(){i.updateRepresentations({position:!0})});var s=new t_(this.stage,a,e);return this.trajList.push(s),this.signals.trajectoryAdded.dispatch(s),s},t.prototype.removeTrajectory=function(t){var e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)},t.prototype.dispose=function(){this.trajList.slice().forEach(function(t){return t.dispose()}),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),c.prototype.dispose.call(this)},t.prototype.autoView=function(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),bl(e,0))},t.prototype.getBoxUntransformed=function(t){return t?this.structureView.getBoundingBox(new Lp(t)):this.structureView.boundingBox},t.prototype.getCenterUntransformed=function(t){return t&&"string"==typeof t?this.structure.atomCenter(new Lp(t)):this.structure.center},t.prototype.superpose=function(t,e,i,r){return v_(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this},t.prototype.getMaxRepresentationRadius=function(t){var i=0,r=this.structure.getAtomProxy(t);return this.eachRepresentation(function(t){if(t.getVisibility()){var e=t.repr;i=Math.max(e.getAtomRadius(r),i)}}),i},t.prototype.measurePick=function(t){var e=this.pickBuffer.count;if(this.lastPick===t.index&&1<=e){if(1<e){var i=this.pickBuffer.data,r=this.pickBuffer.data.sort();this.pickDict.has(r)?this.pickDict.del(r):this.pickDict.add(r,i),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter(function(t){return 2===t.length})}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter(function(t){return 3===t.length})}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter(function(t){return 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()},t.prototype.measureClear=function(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")},t.prototype.measureBuild=function(){var t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})},t.prototype.measureUpdate=function(){var i=this,t=this.pickBuffer.data,r={};t.forEach(function(t){var e=Math.max(.1,i.getMaxRepresentationRadius(t));r[t]=e*(2.3-Zl(.1,2,e))}),this.spacefillRepresentation.setSelection(t.length?"@"+t.join(","):"none"),this.spacefillRepresentation.setParameters({radiusData:r})},t.prototype.measureData=function(){var t=this.pickDict.values;return{distance:t.filter(function(t){return 2===t.length}),angle:t.filter(function(t){return 3===t.length}),dihedral:t.filter(function(t){return 4===t.length})}},t.prototype.removeAllMeasurements=function(t){var i=this.pickDict,r=i.values,e=function(e){r.filter(function(t){return t.length===e}).forEach(function(t){return i.del(t.slice().sort())})};(!t||1&t)&&e(2),(!t||2&t)&&e(3),(!t||4&t)&&e(4),this.measureBuild()},t.prototype.removeMeasurement=function(t){this.pickDict.del(t.slice().sort()),this.measureBuild()},t.prototype.addMeasurement=function(t){if(!(t.length<2||4<t.length)){var e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}},Object.defineProperties(t.prototype,e),t}(qx);od.add("structure",b_),od.add("structureview",b_);var x_=function(r){function t(t,e,i){void 0===i&&(i={}),r.call(this,t,e,Object.assign({name:e.name},i)),this.surface=e}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"surface"},t.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.surface,e)},t.prototype.getBoxUntransformed=function(){return this.surface.boundingBox},t.prototype.getCenterUntransformed=function(){return this.surface.center},t.prototype.dispose=function(){this.surface.dispose(),r.prototype.dispose.call(this)},Object.defineProperties(t.prototype,e),t}(qx);od.add("surface",x_);var __=function(r){function t(t,e,i){void 0===i&&(i={}),r.call(this,t,e,Object.assign({name:e.name},i)),this.volume=e}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"volume"},t.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.volume,e)},t.prototype.getBoxUntransformed=function(){return this.volume.boundingBox},t.prototype.getCenterUntransformed=function(){return this.volume.center},t.prototype.dispose=function(){this.volume.dispose(),r.prototype.dispose.call(this)},Object.defineProperties(t.prototype,e),t}(qx);od.add("volume",__);var w_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.addRepresentation=function(e,i){return this.forEach(function(t){return t.addRepresentation(e,i)})},e.prototype.autoView=function(e){return this.forEach(function(t){return t.autoView(e)})},e}(Zx);function S_(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}var A_=new ri,M_={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,fogMode:"scene",fogScale:"relative",cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"},E_=function(t,e){void 0===e&&(e={}),this.signals={parametersChanged:new op,fullscreenChanged:new op,componentAdded:new op,componentRemoved:new op,clicked:new op,hovered:new op},this.tasks=new Md,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new yf(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 xf(this.viewer.renderer.domElement),this.viewerControls=new $f(this),this.trackballControls=new Of(this),this.pickingControls=new Bf(this),this.animationControls=new nm(this),this.mouseControls=new Ey(this),this.keyControls=new Cy(this),this.pickingBehavior=new Iy(this),this.mouseBehavior=new Oy(this),this.animationBehavior=new Ly(this),this.keyBehavior=new Dy(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=xl(e,M_),this.setParameters(this.parameters),this.viewer.animate())};E_.prototype.setParameters=function(t){void 0===t&&(t={}),_l(this.parameters,t);var e=t,i=this.parameters,r=this.viewer,n=this.trackballControls;return void 0!==e.quality&&this.setQuality(i.quality),void 0!==e.impostor&&this.setImpostor(i.impostor),void 0!==e.rotateSpeed&&(n.rotateSpeed=i.rotateSpeed),void 0!==e.zoomSpeed&&(n.zoomSpeed=i.zoomSpeed),void 0!==e.panSpeed&&(n.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,i.fogMode,i.fogScale),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},E_.prototype.log=function(t){console.log("STAGE LOG",t),this.logList.push(t)},E_.prototype.getParameters=function(){return Object.assign({},this.parameters)},E_.prototype.defaultFileRepresentation=function(t){if(t instanceof b_){var e,i,r;t.setSelection("/0");var n=t.structure;if(n.biomolDict.BU1){var o=n.biomolDict.BU1;e=o.getAtomCount(n),i=o.getResidueCount(n),r=o.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=n.getModelProxy(0).atomCount,i=n.getModelProxy(0).residueCount,r=1;var a=e;$p&&(a*=4);var s=n.atomStore.count/n.residueStore.count<2;s&&(a*=10);var c="chainname",u="RdYlBu",h=!1;if(1===n.getChainnameCount(new Lp("polymer and /0"))&&(c="residueindex",u="spectral",h=!0),de.Debug&&console.log(a,e,r,s),i/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(5<r&&15e3<a||7e5<a){var l=Math.min(1.5,Math.max(.1,2e3/(a/r)));s&&(l=Math.min(l,.15)),t.addRepresentation("surface",{colorScheme:c,colorScale:u,colorReverse:h,sele:"polymer",surfaceType:"sas",probeRadius:1.4,scaleFactor:l,useWorker:!1})}else 25e4<a?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,lineOnly:!0}):1e5<a?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):8e4<a?t.addRepresentation("backbone",{colorScheme:c,colorScale:u,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:u,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),a<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:u,colorReverse:h,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 x_?t.addRepresentation("surface"):t instanceof __&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)},E_.prototype.loadFile=function(t,e){var i=this;void 0===e&&(e={});var r=Object.assign({},this.defaultFileParams,e),n=md(t).name;this.tasks.increment(),this.log("loading file '"+n+"'");var o=bl(r.ext,md(t).ext);return(id.isTrajectory(o)?Promise.reject(new Error("loadFile: ext '"+o+"' is a trajectory and must be loaded into a structure component")):vd(t,r)).then(function(t){i.log("loaded '"+n+"'");var e=i.addComponentFromObject(t,r);return r.defaultRepresentation&&i.defaultFileRepresentation(e),i.tasks.decrement(),e},function(t){i.tasks.decrement();var e="error loading file: '"+t+"'";throw i.log(e),e})},E_.prototype.loadScript=function(t){var i=this,r=md(t).name;return this.log("loading script '"+r+"'"),vd(t).then(function(t){i.tasks.increment(),i.log("running script '"+r+"'"),t.run(i).then(function(){i.tasks.decrement(),i.log("finished script '"+r+"'")}),i.log("called script '"+r+"'")},function(t){i.tasks.decrement();var e="errored script '"+r+"' \""+t+'"';throw i.log(e),e})},E_.prototype.addComponent=function(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):Yp.warn("Stage.addComponent: no component given")},E_.prototype.addComponentFromObject=function(t,e){void 0===e&&(e={});var i=od.get(t.type);if(i){var r=new i(this,t,e);return this.addComponent(r),r}Yp.warn("no component for object type",t.type)},E_.prototype.removeComponent=function(t){var e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))},E_.prototype.removeAllComponents=function(){var e=this;this.compList.slice().forEach(function(t){return e.removeComponent(t)})},E_.prototype.handleResize=function(){this.viewer.handleResize()},E_.prototype.setSize=function(t,e){var i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())},E_.prototype.toggleFullscreen=function(t){if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var e=this;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))}else Yp.log("fullscreen mode (currently) not possible");function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&e.lastFullscreenElement){var 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)}}},E_.prototype.setSpin=function(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)},E_.prototype.setRock=function(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)},E_.prototype.toggleSpin=function(){this.setSpin(this.spinAnimation.paused)},E_.prototype.toggleRock=function(){this.setRock(this.rockAnimation.paused)},E_.prototype.setFocus=function(t){var e=Wl(t/2,0,49.9),i=100-e,r=(i-e)/2;"scene"==this.parameters.clipMode&&this.setParameters({clipNear:e,clipFar:i}),"scene"==this.parameters.fogMode&&this.setParameters({fogNear:Xl(i-r),fogFar:Xl(i+r)})},E_.prototype.getZoomForBox=function(t){var e=t.getSize(A_),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z),n=i+Math.sqrt(r),o=Gl(this.viewer.perspectiveCamera.fov),a=this.viewer.width,s=this.viewer.height,c=s<a?1:a/s;return n=Math.abs(.5*n/c/Math.sin(o/2)),-(n+=this.parameters.clipDist)},E_.prototype.getBox=function(){return this.viewer.boundingBox},E_.prototype.getZoom=function(){return this.getZoomForBox(this.getBox())},E_.prototype.getCenter=function(t){return this.getBox().getCenter(t||new ri)},E_.prototype.autoView=function(t){this.animationControls.zoomMove(this.getCenter(),this.getZoom(),bl(t,0))},E_.prototype.makeImage=function(t){var r=this;return void 0===t&&(t={}),new Promise(function(e,i){r.tasks.onZeroOnce(function(){r.tasks.increment(),r.viewer.makeImage(t).then(function(t){r.tasks.decrement(),e(t)}).catch(function(t){r.tasks.decrement(),i(t)})})})},E_.prototype.setImpostor=function(i){this.parameters.impostor=i;var r=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(t){if(r.includes(t.getType())){var e=t.getParameters();e.disableImpostor=!i,t.build(e)}})},E_.prototype.setQuality=function(i){this.parameters.quality=i;var r=["tube","cartoon","ribbon","trace","rope"],n=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation(function(t){var e=t.getParameters();if(!r.includes(t.getType())){if(!n.includes(t.getType()))return;if(!e.disableImpostor)return void(t.repr.quality=i)}e.quality=i,t.build(e)})},E_.prototype.eachComponent=function(e,i){this.compList.slice().forEach(function(t){void 0!==i&&i!==t.type||e(t)})},E_.prototype.eachRepresentation=function(i,r){this.eachComponent(function(e){e.reprList.slice().forEach(function(t){void 0!==r&&r!==t.getType()||i(t,e)})})},E_.prototype.getComponentsByName=function(e){var i=[];return this.eachComponent(function(t){(void 0===e||S_(e,t))&&i.push(t)}),new w_(i)},E_.prototype.getComponentsByObject=function(e){var i=[];return this.eachComponent(function(t){t.object===e&&i.push(t)}),new w_(i)},E_.prototype.getRepresentationsByName=function(i){var r=[];return this.eachRepresentation(function(t,e){(void 0===i||S_(i,t))&&r.push(t)}),new Jx(r)},E_.prototype.measureClear=function(){this.eachComponent(function(t){return t.measureClear()},"structure")},E_.prototype.measureUpdate=function(){this.eachComponent(function(t){return t.measureUpdate()},"structure")},E_.prototype.dispose=function(){this.tasks.dispose(),this.viewer.dispose()};var P_=function(r){function t(t,e,i){void 0===i&&(i={}),r.call(this,t,e,Object.assign({name:e.name},i)),this.shape=e}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"shape"},t.prototype.addRepresentation=function(t,e){return void 0===e&&(e={}),this._addRepresentation(t,this.shape,e)},t.prototype.getBoxUntransformed=function(){return this.shape.boundingBox},t.prototype.getCenterUntransformed=function(){return this.shape.center},t.prototype.dispose=function(){this.shape.dispose(),r.prototype.dispose.call(this)},Object.defineProperties(t.prototype,e),t}(qx);od.add("shape",P_);var T_=function(i){function t(t){var e=this;i.call(this,t),t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=bl(t.reverse,!0)),this.scalePerModel={},t.structure.eachModel(function(t){e.parameters.domain=[t.atomOffset,t.atomEnd],e.scalePerModel[t.index]=e.getScale()})}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.index)},t}(ip);Qp.add("atomindex",T_);var C_=function(n){function t(t){if(n.call(this,t),t.scale||(this.parameters.scale="OrRd"),!t.domain){var e,i=1/0,r=-1/0;t.sele&&(e=new Lp(t.sele)),t.structure.eachAtom(function(t){var e=t.bfactor;i=Math.min(i,e),r=Math.max(r,e)},e),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}return n&&(t.__proto__=n),((t.prototype=Object.create(n&&n.prototype)).constructor=t).prototype.atomColor=function(t){return this.bfactorScale(t.bfactor)},t}(ip);Qp.add("bfactor",C_);var I_=function(e){function t(t){var r=this;e.call(this,t),this.chainidDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel(function(t){var e=0,i={};t.eachChain(function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)}),r.parameters.domain=[0,e-1],r.chainidDictPerModel[t.index]=i,r.scalePerModel[t.index]=r.getScale()})}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){var e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])},t}(ip);Qp.add("chainid",I_);var O_=function(i){function t(t){var e=this;i.call(this,t),this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel(function(t){e.parameters.domain=[t.chainOffset,t.chainEnd],e.scalePerModel[t.index]=e.getScale()})}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.atomColor=function(t){return this.scalePerModel[t.modelIndex](t.chainIndex)},t}(ip);Qp.add("chainindex",O_);var L_=function(e){function t(t){var r=this;e.call(this,t),this.chainnameDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel(function(t){var e=0,i={};t.eachChain(function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)}),r.parameters.domain=[0,e-1],r.chainnameDictPerModel[t.index]=i,r.scalePerModel[t.index]=r.getScale()})}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){var e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])},t}(ip);Qp.add("chainname",L_);var R_=function(i){function t(t){i.call(this,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]});var e=t.structure.validation;e&&(this.rsrzDict=e.rsrzDict,this.rsccDict=e.rsccDict)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.atomColor=function(t){var e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;var i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);var r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192},t}(ip);Qp.add("densityfit",R_);var D_={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}},k_=1.04;var B_=function(i){function t(t){var r=this;i.call(this,t),this.delta=new ri,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);var n=[];t.structure.eachAtom(function(t){var e;if(r.charges[t.index]=(null!==(e=t).partialCharge?e.partialCharge:e.isProtein()&&(D_[e.resname]&&D_[e.resname][e.atomname]||D_.backbone[e.atomname])||0)*t.occupancy,"N"===t.atomname){if(3<=t.bondCount)return;if(t.bondToElementCount(1))return;var i=function(t,e){void 0===e&&(e=new ri);var i=!1,r=!1,n=!1;return e.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom(function(t){if(!i)return"H"===t.atomname?(e.set(t.x,t.y,t.z),void(i=!0)):void(r||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,e.sub(t)):(e.sub(t),r=!0))}),i?e:r&&n?(e.normalize(),e.multiplyScalar(k_),e.add(t),e):void 0}(t);void 0!==i&&(n.push(i),r.hCharges.push(.25*t.occupancy))}});var e=t.structure.getBoundingBox();e.expandByScalar(k_),this.hStore=function(t){for(var e=t.length,i=new Float32Array(e),r=new Float32Array(e),n=new Float32Array(e),o=0;o<t.length;o++){var a=t[o];i[o]=a.x,r[o]=a.y,n[o]=a.z}return{x:i,y:r,z:n,count:e}}(n),this.hHash=new Zm(this.hStore,e),this.hash=new Zm(t.structure.atomStore,e)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.positionColor=function(t){var r=this.charges,n=this.hCharges,o=0;return this.hash.eachWithin(t.x,t.y,t.z,12,function(t,e){var i=r[t];0!==i&&(o+=i/e)}),this.hHash.eachWithin(t.x,t.y,t.z,12,function(t,e){var i=n[t];0!==i&&(o+=i/e)}),this.scale(332*o)},t}(ip);Qp.add("electrostatic",B_);var N_={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},F_=function(e){function t(t){t.value=bl(t.value,N_.C),e.call(this,t)}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){var e=t.element;return"C"===e?this.parameters.value:N_[e]||16777215},t}(ip);Qp.add("element",F_);var z_=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="Spectral"),t.domain||(this.parameters.domain=[0,t.structure.entityList.length-1]),this.entityindexScale=this.getScale()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){return this.entityindexScale(t.entityIndex)},t}(ip);Qp.add("entityindex",z_);var U_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.atomColor=function(t){var 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}},e}(ip);Qp.add("entitytype",U_);var j_=function(i){function t(t){i.call(this,t),this.geoAtomDict={},this.geoDict={};var e=t.structure.validation;e&&(this.geoAtomDict=e.geoAtomDict,this.geoDict=e.geoDict)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.atomColor=function(t){var e,i=t.resno+"";t.inscode&&(i+="^"+t.inscode),t.chainname&&(i+=":"+t.chainname),i+="/"+t.modelIndex;var r,n=this.geoAtomDict[i];if(void 0!==n){var o=n[t.atomname]||0;r=o,e=16843009*((r=(858993459&(r-=r>>1&1431655765))+(r>>2&858993459))+(r>>4)&252645135)>>24}else e=this.geoDict[i]||0;return 0===e?2188972:1===e?16703627:2===e?16018755:3<=e?10813478:9474192},t}(ip);Qp.add("geoquality",j_);var G_=function(a){function t(t){a.call(this,t),this.resHF={},t.scale||(this.parameters.scale="RdYlGn");for(var e in bg)this.resHF[e]=bg[e][0];if(this.defaultResidueHydrophobicity=xg[0],!t.domain){var i=1/0,r=-1/0;for(var n in this.resHF){var o=this.resHF[n];i=Math.min(i,o),r=Math.max(r,o)}this.parameters.domain=[i,0,r]}this.hfScale=this.getScale()}return a&&(t.__proto__=a),((t.prototype=Object.create(a&&a.prototype)).constructor=t).prototype.atomColor=function(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)},t}(ip);Qp.add("hydrophobicity",G_);var V_=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="rainbow"),t.domain||(this.parameters.domain=[0,t.structure.modelStore.count]),this.modelindexScale=this.getScale()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){return this.modelindexScale(t.modelIndex)},t}(ip);Qp.add("modelindex",V_);var H_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.atomColor=function(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}},e}(ip);Qp.add("moleculetype",H_);var $_=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="PuBu"),t.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){return this.occupancyScale(t.occupancy)},t}(ip);Qp.add("occupancy",$_);var W_=function(e){function t(t){e.call(this,t),t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){return this.partialchargeScale(t.partialCharge||0)},t}(ip);function X_(){return 16777215*Math.random()}Qp.add("partialcharge",W_);var q_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.atomColor=function(){return X_()},e.prototype.volumeColor=function(){return X_()},e.prototype.positionColor=function(){return X_()},e}(ip);Qp.add("random",q_);var Y_=function(i){function t(t){i.call(this,t),this.rciDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});var e=t.structure.validation;e&&(this.rciDict=e.rciDict)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.atomColor=function(t){var e="["+t.resname+"]"+t.resno;t.chainname&&(e+=":"+t.chainname);var i=this.rciDict[e];return void 0!==i?this.rciScale(i):9474192},t}(ip);Qp.add("randomcoilindex",Y_);var Z_=function(i){function t(t){var e=this;i.call(this,t),this.scalePerChain={},t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=bl(t.reverse,!0)),t.structure.eachChain(function(t){e.parameters.domain=[t.residueOffset,t.residueEnd],e.scalePerChain[t.index]=e.getScale()})}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.atomColor=function(t){return this.scalePerChain[t.chainIndex](t.residueIndex)},t}(ip);Qp.add("residueindex",Z_);var K_={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},J_=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.atomColor=function(t){return K_[t.resname]||16711935},e}(ip);Qp.add("resname",J_);var Q_=16711808,tw=10485888,ew=6291584,iw=16762880,rw=6324479,nw=16777215,ow=11403518,aw=16580962,sw=10921722,cw=function(e){function t(t){e.call(this,t),this.residueProxy=t.structure.getResidueProxy()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.atomColor=function(t){var e=t.sstruc,i=this.residueProxy;return"h"===e?Q_:"g"===e?tw:"i"===e?ew:"e"===e||"b"===e?iw:"t"===e?rw:(i.index=t.residueIndex,i.isDna()?ow:i.isRna()?aw:i.isSaccharide()?sw:i.isProtein()||"s"===e||"l"===e?nw:8421504)},t}(ip);Qp.add("sstruc",cw);var uw=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.atomColor=function(){return this.parameters.value},e.prototype.bondColor=function(){return this.parameters.value},e.prototype.valueColor=function(){return this.parameters.value},e.prototype.volumeColor=function(){return this.parameters.value},e}(ip);Qp.add("uniform",uw);var hw=function(e){function t(t){e.call(this,t),this.valueScale=this.getScale()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.volumeColor=function(t){return this.valueScale(this.parameters.volume.data[t])},t}(ip);Qp.add("value",hw);var lw=function(e){function t(t){e.call(this,t),this.vec=new ri,this.valueScale=this.getScale()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.positionColor=function(t){var e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;var i=this.vec,r=e.data,n=e.nx,o=e.ny,a=n*o;i.copy(t),i.applyMatrix4(e.inverseMatrix);var s=Math.floor(i.x),c=Math.floor(i.y),u=Math.floor(i.z),h=(u*o+c)*n+s,l=h+1,p=h+n,d=h+a,f=p+1,m=d+1,g=p+a,v=g+1,y=r[h],b=r[l],x=r[p],_=r[d],w=r[f],S=r[m],A=r[g],M=r[v],E=i.x-s,P=i.y-c,T=i.z-u,C=ql(y,b,E),I=ql(_,S,E),O=ql(x,w,E),L=ql(A,M,E),R=ql(ql(C,O,P),ql(I,L,P),T);return this.valueScale(R)},t}(ip);Qp.add("volume",lw);var pw=function(o){function t(t,e,i){var r=i||{};if(o.call(this,t,e,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Gy.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 Lp(r.sele),this.dataList=[],this.structure=t,this.structureView=this.structure.getView(this.selection),t.biomolDict){var n={default:"default","":t.unitcell?"AU":"FULL"};Object.keys(t.biomolDict).forEach(function(t){n[t]=t}),this.parameters.assembly={type:"select",options:n,rebuild:!0}}else this.parameters.assembly=null}o&&(t.__proto__=o),(t.prototype=Object.create(o&&o.prototype)).constructor=t;var e={defaultScale:{configurable:!0}};return e.defaultScale.get=function(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}},t.prototype.init=function(t){var e=this,i=t||{};i.colorScheme=bl(i.colorScheme,"element"),this.setRadius(i.radius,i),this.radiusType=bl(i.radiusType,"vdw"),this.radiusData=bl(i.radiusData,{}),this.radiusSize=bl(i.radiusSize,1),this.radiusScale=bl(i.radiusScale,1),this.assembly=bl(i.assembly,"default"),this.defaultAssembly=bl(i.defaultAssembly,""),"auto"===i.quality&&(i.quality=this.getQuality()),o.prototype.init.call(this,i),this.selection.signals.stringChanged.add(function(){e.build()}),this.build()},t.prototype.setRadius=function(t,e){var i=Object.keys(jy);return"string"==typeof t&&i.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this},t.prototype.getAssembly=function(){var t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]},t.prototype.getQuality=function(){var t,e=this.structureView,i=this.getAssembly();return t=i?i.getAtomCount(e):e.atomCount,$p&&(t*=4),e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"},t.prototype.create=function(){var n=this;if(0!==this.structureView.atomCount)if(this.structureView.hasCoords()){this.needsBuild=!1;var t=this.getAssembly();if(t)t.partList.forEach(function(t,e){var i=t.getView(n.structureView);if(0!==i.atomCount){var r=n.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),n.dataList.push(r))}});else{var e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}else this.needsBuild=!0},t.prototype.update=function(e){var i=this;!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach(function(t){0<t.bufferList.length&&i.updateData(e,t)},this):Object.assign(this.lazyProps.what,e)},t.prototype.updateData=function(t,e){this.build()},t.prototype.getColorParams=function(){return Object.assign({},o.prototype.getColorParams.call(this),{structure:this.structure})},t.prototype.getRadiusParams=function(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}},t.prototype.getAtomParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)},t.prototype.getBondParams=function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)},t.prototype.getAtomRadius=function(t){return this.structureView.atomSet.isSet(t.index)?new Gy(this.getRadiusParams()).atomRadius(t):0},t.prototype.setSelection=function(t,e){return this.selection.setString(t,e),this},t.prototype.setParameters=function(t,e,i){void 0===e&&(e={}),void 0===i&&(i=!1);var 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,Xp&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),o.prototype.setParameters.call(this,r,e,i),this},t.prototype.getParameters=function(){return Object.assign(o.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},t.prototype.attach=function(t){var i=this.viewer,r=this.bufferList;this.dataList.forEach(function(e){e.bufferList.forEach(function(t){r.push(t),i.add(t,e.instanceList)})}),this.setVisibility(this.visible),t()},t.prototype.clear=function(){this.dataList.length=0,o.prototype.clear.call(this)},t.prototype.dispose=function(){this.structureView.dispose(),delete this.structure,delete this.structureView,o.prototype.dispose.call(this)},Object.defineProperties(t.prototype,e),t}(sm),dw=function(r){function t(t,e,i){r.call(this,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})}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};this.labelVisible=bl(e.labelVisible,!0),this.labelSize=bl(e.labelSize,2),this.labelColor=bl(e.labelColor,16777215),this.labelFontFamily=bl(e.labelFontFamily,"sans-serif"),this.labelFontStyle=bl(e.labelFontstyle,"normal"),this.labelFontWeight=bl(e.labelFontWeight,"bold"),this.labelsdf=bl(e.labelsdf,"Chrome"===Gp),this.labelXOffset=bl(e.labelXOffset,0),this.labelYOffset=bl(e.labelYOffset,0),this.labelZOffset=bl(e.labelZOffset,.5),this.labelAttachment=bl(e.labelAttachment,"bottom-left"),this.labelBorder=bl(e.labelBorder,!1),this.labelBorderColor=bl(e.labelBorderColor,"lightgrey"),this.labelBorderWidth=bl(e.labelBorderWidth,.15),this.labelBackground=bl(e.labelBackground,!1),this.labelBackgroundColor=bl(e.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=bl(e.labelBackgroundMargin,.5),this.labelBackgroundOpacity=bl(e.labelBackgroundOpacity,1),this.labelFixedSize=bl(e.labelFixedSize,!1),this.lineOpacity=bl(e.lineOpacity,1),this.linewidth=bl(e.linewidth,2),r.prototype.init.call(this,e)},t.prototype.update=function(t){t.position?this.build():r.prototype.update.call(this,t)},t.prototype.updateData=function(t,e){var i={};if(t&&!t.labelSize||Object.assign(i,{size:Gd(this.n,this.labelSize)}),!t||t.labelColor){var r=new ki(this.labelColor);Object.assign(i,{color:Vd(this.n,r.r,r.g,r.b)})}this.textBuffer.setAttributes(i)},t.prototype.setParameters=function(t,e,i){return void 0===e&&(e={}),void 0===i&&(i=!1),t&&t.labelSize&&(e.labelSize=!0),t&&(t.labelColor||0===t.labelColor)&&(e.labelColor=!0),r.prototype.setParameters.call(this,t,e,i),t&&void 0!==t.opacity&&this.textBuffer.setParameters({opacity:1}),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this},t.prototype.setVisibility=function(t,e){return r.prototype.setVisibility.call(this,t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),e||this.viewer.requestRender(),this},t.prototype.getLabelBufferParams=function(t){return void 0===t&&(t={}),r.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:!0,visible:this.labelVisible},t,{opacity:1}))},t.prototype.getAtomRadius=function(){return 0},t}(pw);function fw(a,t){var s=a.getAtomProxy(),c=new Lp,e=t.length;if(0===e)return new Float32Array(0);var u=t[0].length,h=a.getAtomSet(),l=new Float32Array(e*u*3),p=0;return t.forEach(function(t){for(var e=!1,i=0;i<u;i++){var r=t[i];if("number"==typeof r&&Number.isInteger(r)){if(!h.get(r)){e=!0;break}s.index=r}else{c.setString(r);var n=a.getAtomIndices(c);if(!n.length){e=!0;break}s.index=n[0]}var o=p+3*i;l[o++]=s.x,l[o++]=s.y,l[o++]=s.z}e||(p+=3*u)}),l.subarray(0,p)}function mw(t,e,i,r,n){var o=Math.cos(n),a=Math.sin(n);t[0]=e[0]+i[0]*o+r[0]*a,t[1]=e[1]+i[1]*o+r[1]*a,t[2]=e[2]+i[2]*o+r[2]*a}function gw(t,e,i,r,n,o,a){for(var s=0;s<e;s++){for(var c=0;c<i;c++)r[c]=t[c*e+s];vw(r,n,o,a,i);for(var u=0;u<i;u++)t[u*e+s]=n[u]}for(var h=0;h<i;h++){for(var l=0;l<e;l++)r[l]=t[h*e+l];vw(r,n,o,a,e);for(var p=0;p<e;p++)t[h*e+p]=Math.sqrt(n[p])}}function vw(t,e,i,r,n){r[i[0]=0]=Number.MIN_SAFE_INTEGER,r[1]=Number.MAX_SAFE_INTEGER;for(var o=1,a=0;o<n;o++){for(var s=(t[o]+o*o-(t[i[a]]+i[a]*i[a]))/(2*o-2*i[a]);s<=r[a];)a--,s=(t[o]+o*o-(t[i[a]]+i[a]*i[a]))/(2*o-2*i[a]);i[++a]=o,r[a]=s,r[a+1]=Number.MAX_SAFE_INTEGER}for(var c=0,u=0;c<n;c++){for(;r[u+1]<c;)u++;e[c]=(c-i[u])*(c-i[u])+t[i[u]]}}rd.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}"),rd.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}");var yw={};var bw={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024},xw=function(t){void 0===t&&(t={}),this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=xl(t,bw);var e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;var i=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),r=this.maxWidth=e.width/4,n=this.canvas=document.createElement("canvas");n.width=r,n.height=i;var o=this.context=this.canvas.getContext("2d");o.font=e.style+" "+e.variant+" "+e.weight+" "+e.size+"px "+e.font,o.fillStyle="black",o.textAlign="left",o.textBaseline="bottom",o.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(var a=32;a<=126;++a)this.map(String.fromCharCode(a));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new Va(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0};xw.prototype.map=function(t){var 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]},xw.prototype.get=function(t){return this.mapped[t]||this.placeholder},xw.prototype.draw=function(t){var e=this.parameters,i=this.lineHeight,r=e.outline,n=this.context,o=this.maxWidth,a=r,s=i-e.outline,c=n.measureText(t),u=Math.min(o,Math.ceil(c.width+2*a+1)),h=u*i;n.clearRect(0,0,u,i),n.fillText(t,a,s);for(var l=n.getImageData(0,0,u,i),p=l.data,d=0;d<h;d++){var f=l.data[4*d+3]/255;this.gridOuter[d]=1===f?0:0===f?Number.MAX_SAFE_INTEGER:Math.pow(Math.max(0,.5-f),2),this.gridInner[d]=1===f?Number.MAX_SAFE_INTEGER:0===f?0:Math.pow(Math.max(0,f-.5),2)}gw(this.gridOuter,u,i,this.f,this.d,this.v,this.z),gw(this.gridInner,u,i,this.f,this.d,this.v,this.z);for(var m=0;m<h;m++){var g=this.gridOuter[m]-this.gridInner[m];p[4*m+3]=Math.max(0,Math.min(255,Math.round(255-255*(g/this.radius+this.cutoff))))}n.putImageData(l,0,0),this.scratchW=u,this.scratchH=i};var _w=Object.assign({fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"bold",fontSize:36,xOffset:0,yOffset:0,zOffset:.5,attachment:"bottom-left",showBorder:!1,borderColor:"lightgrey",borderWidth:.15,showBackground:!1,backgroundColor:"lightgrey",backgroundMargin:.5,backgroundOpacity:1,forceTransparent:!0,fixedSize:!1},ly),ww=Object.assign({fontFamily:{uniform:!0},fontStyle:{uniform:!0},fontWeight:{uniform:!0},fontSize:{uniform:!0},xOffset:{uniform:!0},yOffset:{uniform:!0},zOffset:{uniform:!0},showBorder:{uniform:!0},borderColor:{uniform:!0},borderWidth:{uniform:!0},backgroundColor:{uniform:!0},backgroundOpacity:{uniform:!0},fixedSize:{updateShader:!0}},py);function Sw(t,e){for(var i=t.position.length/3,r=0,n=0;n<i;++n)r+=t.text[n].length;return e.showBackground&&(r+=i),r}var Aw=function(n){function t(t,e){void 0===e&&(e={}),n.call(this,{position:new Float32Array(3*Sw(t,e)),color:new Float32Array(3*Sw(t,e)),picking:new xv},e),this.parameterTypes=ww,this.alwaysTransparent=!0,this.hasWireframe=!1,this.isText=!0,this.vertexShader="SDFFont.vert",this.fragmentShader="SDFFont.frag",this.text=t.text,this.positionCount=t.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:!1},showBorder:{value:this.parameters.showBorder},borderColor:{value:new ki(this.parameters.borderColor)},borderWidth:{value:this.parameters.borderWidth},backgroundColor:{value:new ki(this.parameters.backgroundColor)},backgroundOpacity:{value:this.parameters.backgroundOpacity},canvasHeight:{value:1},pixelRatio:{value:1}}),this.addAttributes({inputTexCoord:{type:"v2",value:null},inputSize:{type:"f",value:null}}),this.setAttributes(t),this.makeTexture(),this.makeMapping()}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return _w},t.prototype.makeMaterial=function(){n.prototype.makeMaterial.call(this);var t=this.texture,e=this.material;e.transparent=!0,e.extensions.derivatives=!0,e.lights=!1,e.uniforms.fontTexture.value=t,e.needsUpdate=!0;var i=this.wireframeMaterial;i.transparent=!0,i.extensions.derivatives=!0,i.lights=!1,i.uniforms.fontTexture.value=t,i.needsUpdate=!0;var r=this.pickingMaterial;r.extensions.derivatives=!0,r.lights=!1,r.uniforms.fontTexture.value=t,r.needsUpdate=!0},t.prototype.setAttributes=function(t){var e,i,r,n,o,a;void 0===t&&(t={});var s=this.text,c=this.geometry.attributes;t.position&&(e=t.position,n=c.position.array,c.position.needsUpdate=!0),t.size&&(i=t.size,o=c.inputSize.array,c.inputSize.needsUpdate=!0),t.color&&(r=t.color,a=c.color.array,c.color.needsUpdate=!0);for(var u,h,l,p,d=this.positionCount,f=0,m=0;m<d;++m)for(h=3*m,p=s[m].length,this.parameters.showBackground&&(p+=1),l=0;l<p;++l,++f)for(var g=0;g<4;g++)u=4*f*3+3*g,e&&(n[u]=e[h],n[u+1]=e[h+1],n[u+2]=e[h+2]),i&&(o[4*f+g]=i[m]),r&&(a[u]=r[h],a[u+1]=r[h+1],a[u+2]=r[h+2])},t.prototype.makeTexture=function(){var t,e;this.textAtlas=(t={font:this.parameters.fontFamily,style:this.parameters.fontStyle,weight:this.parameters.fontWeight,size:this.parameters.fontSize},e=JSON.stringify(t),void 0===yw[e]&&(yw[e]=new xw(t)),yw[e]),this.texture=this.textAtlas.texture},t.prototype.makeMapping=function(){for(var t,e,i,r,n,o,a,s,c=this.textAtlas,u=this.text,h=this.parameters.attachment,l=c.lineHeight*this.parameters.backgroundMargin*.1-10,p=this.geometry.attributes,d=p.inputTexCoord.array,f=p.mapping.array,m=this.positionCount,g=0,v=0;v<m;++v){for(r=0,o=(i=u[v]).length,n=0;n<o;++n)r+=(t=c.get(i[n])).w-2*c.parameters.outline;for(s=h.startsWith("top")?c.lineHeight/1.25:h.startsWith("middle")?c.lineHeight/2.5:0,a=h.endsWith("right")?r:h.endsWith("center")?r/2:0,a+=c.parameters.outline,s+=c.parameters.outline,this.parameters.showBackground&&(f[(e=2*g*4)+0]=-c.lineHeight/6-a-l,f[e+1]=c.lineHeight-s+l,f[e+2]=-c.lineHeight/6-a-l,f[e+3]=0-s-l,f[e+4]=r+c.lineHeight/6-a+2*c.parameters.outline+l,f[e+5]=c.lineHeight-s+l,f[e+6]=r+c.lineHeight/6-a+2*c.parameters.outline+l,f[e+7]=0-s-l,d[e+0]=10,d[e+2]=10,d[e+4]=10,d[e+6]=10,g+=1),n=r=0;n<o;++n,++g){t=c.get(i[n]),f[(e=2*g*4)+0]=r-a,f[e+1]=t.h-s,f[e+2]=r-a,f[e+3]=0-s,f[e+4]=r+t.w-a,f[e+5]=t.h-s,f[e+6]=r+t.w-a,f[e+7]=0-s;var y=c.parameters.width,b=c.parameters.height,x=[t.x/y,t.y/b,t.x/y,(t.y+t.h)/b,(t.x+t.w)/y,t.y/b,(t.x+t.w)/y,(t.y+t.h)/b];d.set(x,e),r+=t.w-2*c.parameters.outline}}p.inputTexCoord.needsUpdate=!0,p.mapping.needsUpdate=!0},t.prototype.getDefines=function(t){var e=n.prototype.getDefines.call(this,t);return this.parameters.fixedSize&&(e.FIXED_SIZE=1),e},t.prototype.setUniforms=function(t){!t||void 0===t.fontFamily&&void 0===t.fontStyle&&void 0===t.fontWeight&&void 0===t.fontSize||(this.makeTexture(),this.makeMapping(),this.texture.needsUpdate=!0,t.fontTexture=this.texture),n.prototype.setUniforms.call(this,t)},Object.defineProperties(t.prototype,e),t}(Mx);ad.add("text",Aw),rd.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}"),rd.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}");var Mw=Object.assign({linewidth:2},ly),Ew=Object.assign({linewidth:{uniform:!0}},py),Pw=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e),this.parameterTypes=Ew,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!t.color2&&t.color&&(t.color2=t.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new ti},projectionMatrixInverse:{value:new ei}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(t),this.makeMapping()}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return Mw},t.prototype.setParameters=function(t){i.prototype.setParameters.call(this,t)},Object.defineProperties(t.prototype,e),t}(Mx);ad.add("wideline",Pw);var Tw=function(a){function t(t,e,i){a.call(this,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)}return a&&(t.__proto__=a),((t.prototype=Object.create(a&&a.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.side=bl(e.side,"double"),e.opacity=bl(e.opacity,.5),this.atomTriple=bl(e.atomTriple,[]),this.arcVisible=bl(e.arcVisible,!0),this.sectorVisible=bl(e.sectorVisible,!0),this.vectorVisible=bl(e.vectorVisible,!0),a.prototype.init.call(this,e)},t.prototype.createData=function(t){if(t.atomCount&&this.atomTriple.length){var e,i,r=function(d,t){void 0===t&&(t={});for(var f=bl(t.angleStep,Math.PI/90),e=d.length/9,m=new Float32Array(e),g=new Float32Array(3*e),v=new Array(e),y=new Float32Array(6*e),b=new Float32Array(6*e),x=new Array(e),_=new Array(e),w=new Array(e),S=0,A=gm(),M=gm(),E=gm(),P=gm(),T=gm(),C=gm(),I=gm(),O=gm(),L=gm(),i=function(t){var e=9*t;_m(A,d,e),_m(M,d,e+3),_m(E,d,e+6);var i=6*t;wm(A,y,i),wm(M,b,i),wm(M,y,i+3),wm(E,b,i+3),bm(P,A,M),bm(T,E,M),Em(P,P),Em(T,T),vm(C,P,T);var r=Sm(C),n=ym(P,T),o=m[t]=Math.atan2(r,n);v[t]=(Fd*o).toFixed(1)+String.fromCharCode(176),0===Sm(C)&&(C[0]=1,C[1]=0,C[2]=0),vm(I,C,P),Em(I,I),mw(O,M,P,I,o/2),wm(O,g,3*t);var a=Math.ceil(o/f),s=new Float32Array(9*a);w[t]=s;var c=new Float32Array(3*a),u=new Float32Array(3*a);x[t]=c,_[t]=u,xm(L,M,P);for(var h=function(t,e){var i=9*e,r=3*e;wm(M,s,i),wm(L,s,i+3),wm(L,c,r),mw(L,M,P,I,t),wm(L,s,i+6),wm(L,u,r)},l=0,p=f;p<o;p+=f)h(p,l),l++;h(o,l),S+=a},r=0;r<e;r++)i(r);for(var n=3*S,o=9*S,a=new Float32Array(n),s=new Float32Array(n),c=new Float32Array(o),u=0,h=0,l=0;l<e;l++){var p=x[l],R=_[l];Xd(p,a,0,h,p.length),Xd(R,s,0,h,R.length),h+=p.length;var D=w[l];Xd(D,c,0,u,D.length),u+=D.length}return{labelPosition:g,labelText:v,vectorPosition1:y,vectorPosition2:b,arcPosition1:a,arcPosition2:s,sectorPosition:c}}((e=t,i=this.atomTriple,function(e){for(var t=[],i=e.length/9,r=0;r<i;r++){for(var n=!0,o=r;o<r+3;o+=3)e[o]===e[o+3]&&e[o+1]===e[o+4]&&e[o+2]===e[o+5]&&(n=!1);n&&t.push(r)}var a=new Float32Array(9*t.length),s=0;return t.forEach(function(t){Xd(e,a,9*t,9*s,9),s++}),a}(fw(e,i)))),n=this.n=r.labelPosition.length/3,o=new ki(this.labelColor);this.textBuffer=new Aw({position:r.labelPosition,size:Gd(n,this.labelSize),color:Vd(n,o.r,o.g,o.b),text:r.labelText},this.getLabelBufferParams());var a=new ki(this.colorValue);return this.vectorBuffer=new Pw(Dm({position1:r.vectorPosition1,position2:r.vectorPosition2,color:Vd(2*n,a.r,a.g,a.b),color2:Vd(2*n,a.r,a.g,a.b)}),this.getBufferParams({linewidth:this.linewidth,visible:this.vectorVisible,opacity:this.lineOpacity})),this.arcLength=r.arcPosition1.length/3,this.arcBuffer=new Pw(Dm({position1:r.arcPosition1,position2:r.arcPosition2,color:Vd(this.arcLength,a.r,a.g,a.b),color2:Vd(this.arcLength,a.r,a.g,a.b)}),this.getBufferParams({linewidth:this.linewidth,visible:this.arcVisible,opacity:this.lineOpacity})),this.sectorLength=r.sectorPosition.length/3,this.sectorBuffer=new my({position:r.sectorPosition,color:Vd(this.sectorLength,a.r,a.g,a.b)},this.getBufferParams({visible:this.sectorVisible})),{bufferList:[this.textBuffer,this.vectorBuffer,this.arcBuffer,this.sectorBuffer]}}},t.prototype.updateData=function(t,e){a.prototype.updateData.call(this,t,e);var i={},r={},n={};if(t.color){var o=new ki(this.colorValue);Object.assign(i,{color:Vd(2*this.n,o.r,o.g,o.b),color2:Vd(2*this.n,o.r,o.g,o.b)}),Object.assign(r,{color:Vd(this.arcLength,o.r,o.g,o.b),color2:Vd(this.arcLength,o.r,o.g,o.b)}),Object.assign(n,{color:Vd(this.sectorLength,o.r,o.g,o.b)})}this.vectorBuffer.setAttributes(i),this.arcBuffer.setAttributes(r),this.sectorBuffer.setAttributes(n)},t.prototype.setParameters=function(t){return a.prototype.setParameters.call(this,t,{},!1),!t||void 0===t.vectorVisible&&void 0===t.arcVisible&&void 0===t.sectorVisible||this.setVisibility(this.visible),t&&t.lineOpacity&&(this.vectorBuffer.setParameters({opacity:t.lineOpacity}),this.arcBuffer.setParameters({opacity:t.lineOpacity})),t&&void 0!==t.opacity&&(this.vectorBuffer.setParameters({opacity:this.lineOpacity}),this.arcBuffer.setParameters({opacity:this.lineOpacity})),t&&t.linewidth&&(this.vectorBuffer.setParameters({linewidth:t.linewidth}),this.arcBuffer.setParameters({linewidth:t.linewidth})),this},t.prototype.setVisibility=function(t,e){return a.prototype.setVisibility.call(this,t,!0),this.vectorBuffer&&this.vectorBuffer.setVisibility(this.vectorVisible&&this.visible),this.arcBuffer&&this.arcBuffer.setVisibility(this.arcVisible&&this.visible),this.sectorBuffer&&this.sectorBuffer.setVisibility(this.sectorVisible&&this.visible),e||this.viewer.requestRender(),this},t}(dw);ed.add("angle",Tw);var Cw=new ri,Iw=new ri,Ow=new ri,Lw=new ri(0,1,0),Rw=Object.assign({radialSegments:1,openEnded:!0},ly);function Dw(t){void 0===t&&(t={});var e=bl(t.radialSegments,10),i=bl(t.openEnded,!0),r=(new ei).makeRotationX(Math.PI/2),n=new Ks(1,1,1,e,1,i);return n.applyMatrix(r),n}var kw=function(n){function t(t,e){void 0===e&&(e={}),n.call(this,function(t,e){void 0===e&&(e={});var i=Dw(e),r=t.position1.length,n=i.attributes.position.array.length/3,o=r/3,a=new Float32Array(2*o*n);return $d(o,n,0,a),$d(o,n,o*n,a),{position:new Float32Array(2*r),color:new Float32Array(2*r),primitiveId:a,picking:t.picking}}(t,e),e,Dw(e)),this.updateNormals=!0;var i=t.position1.length,r=t.radius.length;this.__center=new Float32Array(i),this._position=new Float32Array(2*i),this._color=new Float32Array(2*i),this._from=new Float32Array(2*i),this._to=new Float32Array(2*i),this._radius=new Float32Array(2*r),this.setAttributes(t,!0)}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return Rw},t.prototype.applyPositionTransform=function(t,e,i){Iw.fromArray(this._from,i),Ow.fromArray(this._to,i),t.lookAt(Iw,Ow,Lw);var r=this._radius[e];Cw.set(r,r,Iw.distanceTo(Ow)),t.scale(Cw)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={});var i={};t.position1&&t.position2&&(Ud(t.position1,t.position2,this.__center),Ud(t.position1,this.__center,this._position),Ud(this.__center,t.position2,this._position,t.position1.length),this._from.set(t.position1),this._from.set(this.__center,t.position1.length),this._to.set(this.__center),this._to.set(t.position2,this.__center.length),i.position=this._position),t.color&&t.color2&&(this._color.set(t.color),this._color.set(t.color2,t.color.length),i.color=this._color),t.radius&&(this._radius.set(t.radius),this._radius.set(t.radius,t.radius.length),i.radius=this._radius),n.prototype.setAttributes.call(this,i,e)},Object.defineProperties(t.prototype,e),t}(yx);rd.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}"),rd.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 );\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}");var Bw=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Nw=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),Fw=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,"v3",t,e)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return e.mapping.get=function(){return Bw},e.mappingIndices.get=function(){return Nw},e.mappingIndicesSize.get=function(){return 12},e.mappingSize.get=function(){return 6},e.mappingItemSize.get=function(){return 3},Object.defineProperties(t.prototype,e),t}(wx),zw=Object.assign({openEnded:!1},ly),Uw=Object.assign({openEnded:{updateShader:!0}},py),jw=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e),this.parameterTypes=Uw,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new ei},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()}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return zw},t.prototype.getDefines=function(t){var e=i.prototype.getDefines.call(this,t);return this.parameters.openEnded||(e.CAP=1),e},Object.defineProperties(t.prototype,e),t}(Fw),Gw=(Object.assign({disableImpostor:!1},Rw,zw),function(t,e){return void 0===e&&(e={}),!t.color2&&t.color&&(t.color2=t.color),!Xp||e&&e.disableImpostor?new kw(t,e):new jw(t,e)});ad.add("cylinder",Gw);var Vw=function(r){function t(t,e,i){r.call(this,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)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.radiusSize=bl(e.radiusSize,.5),e.colorValue=bl(e.colorValue,"lightgreen"),e.useInteriorColor=bl(e.useInteriorColor,!0),this.showAxes=bl(e.showAxes,!0),this.showBox=bl(e.showBox,!1),r.prototype.init.call(this,e)},t.prototype.getPrincipalAxes=function(){var t,e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)},t.prototype.getAxesData=function(t){var r=this.getPrincipalAxes(),e=new ki(this.colorValue),i=0,n=0;this.showAxes&&(i+=6,n+=3),this.showBox&&(i+=8,n+=12);var o=new Float32Array(3*i),a=Vd(i,e.r,e.g,e.b),s=Gd(i,this.radiusSize),c=new Float32Array(3*n),u=new Float32Array(3*n),h=Vd(n,e.r,e.g,e.b),l=Gd(n,this.radiusSize),p=0;if(this.showAxes){var d=function(t,e){t.toArray(o,2*p),e.toArray(o,2*p+3),t.toArray(c,p),e.toArray(u,p),p+=3};d(r.begA,r.endA),d(r.begB,r.endB),d(r.begC,r.endC)}if(this.showBox){var f=new ri,m=r.getProjectedScaleForAtoms(t),g=m.d1a,v=m.d2a,y=m.d3a,b=m.d1b,x=m.d2b,_=m.d3b,w=2*p,S=function(t,e,i){f.copy(r.center).addScaledVector(r.normVecA,t).addScaledVector(r.normVecB,e).addScaledVector(r.normVecC,i),f.toArray(o,w),w+=3};S(g,v,y),S(g,v,_),S(g,x,_),S(g,x,y),S(b,x,_),S(b,x,y),S(b,v,y),S(b,v,_);var A=p,M=function(t,e){f.fromArray(o,2*p+3*t).toArray(c,A),f.fromArray(o,2*p+3*e).toArray(u,A),A+=3};M(0,1),M(0,3),M(0,6),M(1,2),M(1,7),M(2,3),M(2,4),M(3,5),M(4,5),M(4,7),M(5,6),M(6,7)}var E=new lv(r);return{vertex:{position:o,color:a,radius:s,picking:E},edge:{position1:c,position2:u,color:h,color2:h,radius:l,picking:E}}},t.prototype.create=function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new Px(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Gw(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]})},t.prototype.createData=function(t){},t.prototype.updateData=function(t,e){var i=this.getAxesData(e.sview),r={},n={};t&&!t.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(n,{position1:i.edge.position1,position2:i.edge.position2})),t&&!t.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(n,{color:i.edge.color,color2:i.edge.color})),t&&!t.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(n,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(n)},t}(pw);ed.add("axes",Vw);var Hw=function(r){function t(t,e,i){r.call(this,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)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.radiusType=bl(e.radiusType,"size"),e.radiusSize=bl(e.radiusSize,.15),e.useInteriorColor=bl(e.useInteriorColor,!0),this.aspectRatio=bl(e.aspectRatio,2),this.lineOnly=bl(e.lineOnly,!1),this.cylinderOnly=bl(e.cylinderOnly,!1),this.multipleBond=bl(e.multipleBond,"off"),this.bondSpacing=bl(e.bondSpacing,1),this.bondScale=bl(e.bondScale,.4),this.linewidth=bl(e.linewidth,2),r.prototype.init.call(this,e)},t.prototype.getAtomRadius=function(t){return this.aspectRatio*r.prototype.getAtomRadius.call(this,t)},t.prototype.getAtomParams=function(t,e){var i=r.prototype.getAtomParams.call(this,t,e);return i.radiusParams.scale*=this.aspectRatio,i},t.prototype.getAtomData=function(t,e,i){return t.getAtomData(this.getAtomParams(e,i))},t.prototype.getBondParams=function(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},e),r.prototype.getBondParams.call(this,t,e)},t.prototype.getBondData=function(t,e,i){return t.getBondData(this.getBondParams(e,i))},t.prototype.createData=function(t){var e=[];if(this.lineOnly)this.lineBuffer=new Pw(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{var i=new Gw(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(i),!this.cylinderOnly){var r=new Px(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(r)}}return{bufferList:e}},t.prototype.updateData=function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var i=this.getBondData(e.sview,t);if(this.lineOnly){var 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 n={};if(t&&!t.position||Object.assign(n,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(n,{color:i.color,color2:i.color2}),t&&!t.radius||Object.assign(n,{radius:i.radius}),e.bufferList[0].setAttributes(n),!this.cylinderOnly){var o=this.getAtomData(e.sview,t),a={};t&&!t.position||Object.assign(a,{position:o.position}),t&&!t.color||Object.assign(a,{color:o.color}),t&&!t.radius||Object.assign(a,{radius:o.radius}),e.bufferList[1].setAttributes(a)}}},t.prototype.setParameters=function(t){void 0===t&&(t={});var e=!1,i={};return(t.aspectRatio||t.bondSpacing||t.bondScale)&&(Object.assign(i,{radius:!0}),Xp&&!this.disableImpostor||(e=!0)),r.prototype.setParameters.call(this,t,i,e),this},t}(pw);ed.add("ball+stick",Hw);var $w=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.aspectRatio=bl(e.aspectRatio,1),e.radiusSize=bl(e.radiusSize,.25),r.prototype.init.call(this,e)},t.prototype.getAtomRadius=function(t){return t.isTrace()?r.prototype.getAtomRadius.call(this,t):0},t.prototype.getAtomData=function(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))},t.prototype.getBondData=function(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))},t}(Hw);ed.add("backbone",$w);var Ww=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.aspectRatio=bl(e.aspectRatio,1),e.radiusSize=bl(e.radiusSize,.3),r.prototype.init.call(this,e)},t.prototype.getAtomData=function(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))},t.prototype.getBondData=function(t,e,i){var r=this.getBondParams(e,i);return Object.assign(r.colorParams,{rung:!0}),t.getRungBondData(r)},t}(Hw);ed.add("base",Ww);var Xw=function(t,e){this.m=t,this.tension=e,this.dt=1/this.m,this.delta=1e-4,this.vec1=new ri,this.vec2=new ri,this.vDir=new ri,this.vTan=new ri,this.vNorm=new ri,this.vBin=new ri,this.m2=Math.ceil(this.m/2)};Xw.prototype.interpolateToArr=function(t,e,i,r,n,o,a){o[a+0]=Yl(t.x,e.x,i.x,r.x,n,this.tension),o[a+1]=Yl(t.y,e.y,i.y,r.y,n,this.tension),o[a+2]=Yl(t.z,e.z,i.z,r.z,n,this.tension)},Xw.prototype.interpolateToVec=function(t,e,i,r,n,o){o.x=Yl(t.x,e.x,i.x,r.x,n,this.tension),o.y=Yl(t.y,e.y,i.y,r.y,n,this.tension),o.z=Yl(t.z,e.z,i.z,r.z,n,this.tension)},Xw.prototype.interpolatePosition=function(t,e,i,r,n,o){for(var a=0;a<this.m;++a){var s=o+3*a,c=this.dt*a;this.interpolateToArr(t,e,i,r,c,n,s)}},Xw.prototype.interpolateTangent=function(t,e,i,r,n,o){for(var a=this,s=0;s<this.m;++s){var c=a.dt*s,u=c-a.delta,h=c+a.delta,l=o+3*s;u<0&&(u=0),1<h&&(h=1),a.interpolateToVec(t,e,i,r,u,a.vec1),a.interpolateToVec(t,e,i,r,h,a.vec2),a.vec2.sub(a.vec1).normalize(),a.vec2.toArray(n,l)}},Xw.prototype.vectorSubdivide=function(t,e,i,r,n){for(var o,a=e.next(),s=e.next(),c=e.next(),u=e.size,h=u-1,l=r||0,p=0;p<h;++p)o=a,a=s,s=c,c=e.next(),t.apply(this,[o,a,s,c,i,l]),l+=3*this.m;n&&(o=e.get(u-2),a=e.get(u-1),s=e.get(0),c=e.get(1),t.apply(this,[o,a,s,c,i,l]),l+=3*this.m)},Xw.prototype.getPosition=function(t,e,i,r){t.reset(),this.vectorSubdivide(this.interpolatePosition,t,e,i,r);var n=t.size-1,o=n*this.m*3;r&&(o+=3*this.m);var a=t.get(r?0:n);e[o]=a.x,e[o+1]=a.y,e[o+2]=a.z},Xw.prototype.getTangent=function(t,e,i,r){t.reset(),this.vectorSubdivide(this.interpolateTangent,t,e,i,r);var n=(t.size-1)*this.m*3;r&&(n+=3*this.m),Xd(e,e,n-3,n,3)},Xw.prototype.interpolateNormalDir=function(t,e,i,r,n,o,a,s,c,u,h,l,p){for(var d=this,f=0;f<this.m;++f){var m=l+3*f;p&&(m+=3*d.m2);var g=d.dt*f;d.interpolateToVec(t,e,i,r,g,d.vec1),d.interpolateToVec(n,o,a,s,g,d.vec2),d.vDir.subVectors(d.vec2,d.vec1).normalize(),d.vTan.fromArray(c,m),d.vBin.crossVectors(d.vDir,d.vTan).normalize(),d.vBin.toArray(h,m),d.vNorm.crossVectors(d.vTan,d.vBin).normalize(),d.vNorm.toArray(u,m)}},Xw.prototype.interpolateNormal=function(t,e,i,r,n){for(var o=0;o<this.m;++o){var a=n+3*o;t.copy(this.vNorm),this.vTan.fromArray(e,a),this.vBin.crossVectors(t,this.vTan).normalize(),this.vBin.toArray(r,a),this.vNorm.crossVectors(this.vTan,this.vBin).normalize(),this.vNorm.toArray(i,a)}},Xw.prototype.getNormal=function(t,e,i,r,n,o){this.vNorm.set(0,0,1);for(var a=t-1,s=n||0,c=0;c<a;++c)this.interpolateNormal(this.vDir,e,i,r,s),s+=3*this.m;o&&(this.interpolateNormal(this.vDir,e,i,r,s),s+=3*this.m),this.vBin.toArray(r,s),this.vNorm.toArray(i,s)},Xw.prototype.getNormalDir=function(t,e,i,r,n,o,a,s){t.reset(),e.reset();var c=new ri,u=new ri,h=new ri,l=new ri,p=new ri,d=(new ri).copy(t.next()),f=(new ri).copy(t.next()),m=(new ri).copy(t.next()),g=new ri,v=(new ri).copy(e.next()),y=(new ri).copy(e.next()),b=(new ri).copy(e.next());this.vNorm.set(0,0,1);for(var x=t.size,_=x-1,w=o||0,S=0;S<_;++S)p.copy(d),d.copy(f),f.copy(m),m.copy(t.next()),g.copy(v),v.copy(y),y.copy(b),b.copy(e.next()),0===S?(c.subVectors(g,p),u.subVectors(v,d),c.dot(u)<0&&(u.multiplyScalar(-1),v.addVectors(d,u)),h.subVectors(y,f),u.dot(h)<0&&(h.multiplyScalar(-1),y.addVectors(f,h))):h.copy(l),l.subVectors(b,m),h.dot(l)<0&&(l.multiplyScalar(-1),b.addVectors(m,l)),this.interpolateNormalDir(p,d,f,m,g,v,y,b,i,r,n,w,s),w+=3*this.m;if(a&&(p.copy(t.get(x-2)),d.copy(t.get(x-1)),f.copy(t.get(0)),m.copy(t.get(1)),g.copy(e.get(x-2)),v.copy(e.get(x-1)),y.copy(e.get(0)),b.copy(e.get(1)),h.copy(l),l.subVectors(b,m),h.dot(l)<0&&(l.multiplyScalar(-1),b.addVectors(m,l)),this.interpolateNormalDir(p,d,f,m,g,v,y,b,i,r,n,w,s),w+=3*this.m),s){this.vBin.fromArray(n,3*this.m2),this.vNorm.fromArray(r,3*this.m2);for(var A=0;A<this.m2;++A)this.vBin.toArray(n,3*A),this.vNorm.toArray(r,3*A)}else this.vBin.toArray(n,w),this.vNorm.toArray(r,w)},Xw.prototype.interpolateColor=function(t,e,i,r,n){var o,a;for(o=0;o<this.m2;++o)a=n+3*o,i.apply(this,[t,r,a]);for(o=this.m2;o<this.m;++o)a=n+3*o,i.apply(this,[e,r,a])},Xw.prototype.getColor=function(t,e,i,r,n){var o;t.reset(),t.next();for(var a=t.next(),s=t.size,c=s-1,u=r||0,h=0;h<c;++h)o=a,a=t.next(),this.interpolateColor(o,a,e,i,u),u+=3*this.m;n&&(o=t.get(s-1),a=t.get(0),this.interpolateColor(o,a,e,i,u),u+=3*this.m),i[u]=i[u-3],i[u+1]=i[u-2],i[u+2]=i[u-1]},Xw.prototype.interpolatePicking=function(t,e,i,r,n){var o;for(o=0;o<this.m2;++o)r[n+o]=i.apply(this,[t]);for(o=this.m2;o<this.m;++o)r[n+o]=i.apply(this,[e])},Xw.prototype.getPicking=function(t,e,i,r,n){var o;t.reset(),t.next();for(var a=t.next(),s=t.size,c=s-1,u=r||0,h=0;h<c;++h)o=a,a=t.next(),this.interpolatePicking(o,a,e,i,u),u+=this.m;n&&(o=t.get(s-1),a=t.get(0),this.interpolatePicking(o,a,e,i,u),u+=this.m),i[u]=i[u-1]},Xw.prototype.interpolateSize=function(t,e,i,r,n){for(var o=i.apply(this,[t]),a=i.apply(this,[e]),s=0;s<this.m;++s){var c=s/this.m;r[n+s]=(1-c)*o+c*a}},Xw.prototype.getSize=function(t,e,i,r,n){var o;t.reset(),t.next();for(var a=t.next(),s=t.size,c=s-1,u=r||0,h=0;h<c;++h)o=a,a=t.next(),this.interpolateSize(o,a,e,i,u),u+=this.m;n&&(o=t.get(s-1),a=t.get(0),this.interpolateSize(o,a,e,i,u),u+=this.m),i[u]=i[u-1]};var qw=function(t,e){this.polymer=t,this.size=t.residueCount;var i=e||{};this.directional=i.directional||!1,this.positionIterator=i.positionIterator||!1,this.subdiv=i.subdiv||1,this.smoothSheet=i.smoothSheet||!1,i.tension?this.tension=i.tension:this.tension=this.polymer.isNucleic()?.5:.9,this.interpolator=new Xw(this.subdiv,this.tension)};qw.prototype.getAtomIterator=function(r,n){var o=this.polymer,t=o.structure,a=o.residueCount,s=0,e=-1,c=[t.getAtomProxy(),t.getAtomProxy(),t.getAtomProxy(),t.getAtomProxy()],u=[new ri,new ri,new ri,new ri];var h=t.getAtomProxy(),l=t.getAtomProxy();function i(t){var e=c[s%4];if(e.index=o.getAtomIndexByType(t,r),n&&0<t&&t<a&&"e"===e.sstruc){var i=u[s%4];return h.index=o.getAtomIndexByType(t+1,r),l.index=o.getAtomIndexByType(t-1,r),i.addVectors(h,l).add(e).add(e).multiplyScalar(.25),s+=1,i}return s+=1,e}return{size:a,next:function(){var t=i(e);return e+=1,t},get:i,reset:function(){s=0,e=-1}}},qw.prototype.getSubdividedColor=function(t){var e=this.subdiv,i=this.polymer,r=(i.residueCount-1)*e*3+3;i.isCyclic&&(r+=3*e);var n=new Float32Array(r),o=this.getAtomIterator("trace"),a=t||{};a.structure=i.structure;var s=Qp.getScheme(a);return this.interpolator.getColor(o,function(t,e,i){s.atomColorToArray(t,e,i)},n,0,i.isCyclic),{color:n}},qw.prototype.getSubdividedPicking=function(){var t=this.subdiv,e=this.polymer,i=(e.residueCount-1)*t+1;e.isCyclic&&(i+=t);var r=e.structure,n=this.getAtomIterator("trace"),o=new Float32Array(i);return this.interpolator.getPicking(n,function(t){return t.index},o,0,e.isCyclic),{picking:new hv(o,r)}},qw.prototype.getSubdividedPosition=function(){return{position:this.getPosition()}},qw.prototype.getSubdividedOrientation=function(){var t=this.getTangent(),e=this.getNormals(t);return{tangent:t,normal:e.normal,binormal:e.binormal}},qw.prototype.getSubdividedSize=function(t){var e=this.subdiv,i=this.polymer,r=(i.residueCount-1)*e+1;i.isCyclic&&(r+=e);var n=new Float32Array(r),o=this.getAtomIterator("trace"),a=new Gy(t);return this.interpolator.getSize(o,function(t){return a.atomRadius(t)},n,0,i.isCyclic),{size:n}},qw.prototype.getPosition=function(){var t=this.subdiv,e=this.polymer,i=(e.residueCount-1)*t*3+3;e.isCyclic&&(i+=3*t);var r=new Float32Array(i),n=this.positionIterator||this.getAtomIterator("trace",this.smoothSheet);return this.interpolator.getPosition(n,r,0,e.isCyclic),r},qw.prototype.getTangent=function(){var t=this.subdiv,e=this.polymer,i=(this.size-1)*t*3+3;e.isCyclic&&(i+=3*t);var r=new Float32Array(i),n=this.positionIterator||this.getAtomIterator("trace",this.smoothSheet);return this.interpolator.getTangent(n,r,0,e.isCyclic),r},qw.prototype.getNormals=function(t){var e=this.subdiv,i=this.polymer,r=i.isProtein(),n=this.size,o=(n-1)*e*3+3;i.isCyclic&&(o+=3*e);var a=new Float32Array(o),s=new Float32Array(o);if(this.directional&&!this.polymer.isCg()){var c=this.getAtomIterator("direction1"),u=this.getAtomIterator("direction2");this.interpolator.getNormalDir(c,u,t,a,s,0,i.isCyclic,r)}else this.interpolator.getNormal(n,t,a,s,0,i.isCyclic);return{normal:a,binormal:s}};var Yw=new ri,Zw=new ri,Kw=Object.assign({radialSegments:4,capped:!1,aspectRatio:1},ly);var Jw=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,function(t,e){void 0===e&&(e={});var i=bl(e.radialSegments,4),r=bl(e.capped,!1),n=r?i:0,o=r?i-2:0,a=t.position.length/3,s=a*i*3+2*n*3,c=2*(a-1)*i*3+2*o*3;return{position:new Float32Array(s),color:new Float32Array(s),index:Ll(c,s/3),normal:new Float32Array(s),picking:t.picking}}(t,e),e),this.capVertices=this.parameters.capped?this.parameters.radialSegments:0,this.capTriangles=this.parameters.capped?this.parameters.radialSegments-2:0,this.size2=t.position.length/3,t.primitiveId=Hd(this.size2),this.setAttributes(t),this.makeIndex()}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return Kw},t.prototype.setAttributes=function(t){void 0===t&&(t={});var e,i,r,n,o,a,s,c,u,h,l,p,d,f=this.parameters.aspectRatio,m=this.size2,g=m-1,v=this.parameters.radialSegments,y=this.geometry.attributes;t.position&&(e=t.position,i=t.normal,r=t.binormal,n=t.tangent,a=t.size,c=y.position.array,h=y.normal.array,y.position.needsUpdate=!0,y.normal.needsUpdate=!0),t.color&&(o=t.color,u=y.color.array,y.color.needsUpdate=!0),t.primitiveId&&(s=t.primitiveId,l=y.primitiveId.array,y.primitiveId.needsUpdate=!0);var b=0,x=0,_=0,w=0,S=0,A=0,M=0,E=0,P=0,T=0,C=[],I=[],O=[],L=[],R=[],D=[];if(e)for(var k=0;k<v;++k){var B=k/v*2*Math.PI;C[k]=f*Math.cos(B),I[k]=Math.sin(B),O[k]=f*Math.cos(B-.01),L[k]=Math.sin(B-.01),R[k]=f*Math.cos(B+.01),D[k]=Math.sin(B+.01)}for(var N=0;N<m;++N){d=(p=3*N)*v,e&&n&&i&&r&&a&&(Yw.set(n[p],n[p+1],n[p+2]),x=i[p],_=i[p+1],w=i[p+2],S=r[p],A=r[p+1],M=r[p+2],E=e[p],P=e[p+1],T=e[p+2],b=a[N]);for(var F=0;F<v;++F){var z=d+3*F;if(e){var U=-b*C[F],j=b*I[F],G=-b*O[F],V=b*L[F],H=-b*R[F],$=b*D[F];c[z]=E+U*x+j*S,c[z+1]=P+U*_+j*A,c[z+2]=T+U*w+j*M,Zw.set(H*x+$*S-(G*x+V*S),H*_+$*A-(G*_+V*A),H*w+$*M-(G*w+V*M)).cross(Yw),h[z]=Zw.x,h[z+1]=Zw.y,h[z+2]=Zw.z}o&&(u[z]=o[p],u[z+1]=o[p+1],u[z+2]=o[p+2]),s&&(l[N*v+F]=s[N])}}d=3*m*v;for(var W=p=0;W<v;++W){var X=p+3*W,q=d+3*W;e&&n&&(c[q]=c[X],c[q+1]=c[X+1],c[q+2]=c[X+2],h[q]=n[p],h[q+1]=n[p+1],h[q+2]=n[p+2]),o&&(u[q]=u[X],u[q+1]=u[X+1],u[q+2]=u[X+2]),s&&(l[m*v+W]=l[0+W])}p=3*(m-1)*v,d=3*(m+1)*v;for(var Y=0;Y<v;++Y){var Z=p+3*Y,K=d+3*Y;e&&n&&(c[K]=c[Z],c[K+1]=c[Z+1],c[K+2]=c[Z+2],h[K]=n[3*g],h[K+1]=n[3*g+1],h[K+2]=n[3*g+2]),o&&(u[K]=u[Z],u[K+1]=u[Z+1],u[K+2]=u[Z+2]),s&&(l[(m+1)*v+Y]=l[(m-1)*v+Y])}},t.prototype.makeIndex=function(){for(var t,e,i=this.geometry.getIndex().array,r=this.size2,n=r-1,o=this.capTriangles,a=this.parameters.radialSegments,s=this.parameters.radialSegments+1,c=0;c<n;++c)for(var u=c*a*3*2,h=c*a,l=(c+1)*a,p=0;p<a;++p)i[e=u+3*p*2]=h+p,i[e+1]=h+(p+1)%a,i[e+2]=l+p,i[e+3]=l+p,i[e+4]=h+(p+1)%a,i[e+5]=l+(p+1)%a;for(var d=[0],f=1;f<s/2;++f)d.push(f),a-f!==f&&d.push(a-f);e=n*a*3*2,t=r*a;for(var m=0;m<d.length-2;++m)m%2==0?(i[e+3*m+0]=t+d[m+0],i[e+3*m+1]=t+d[m+1],i[e+3*m+2]=t+d[m+2]):(i[e+3*m+0]=t+d[m+2],i[e+3*m+1]=t+d[m+1],i[e+3*m+2]=t+d[m+0]);e=n*a*3*2+3*o,t=r*a+a;for(var g=0;g<d.length-2;++g)g%2==0?(i[e+3*g+0]=t+d[g+0],i[e+3*g+1]=t+d[g+1],i[e+3*g+2]=t+d[g+2]):(i[e+3*g+0]=t+d[g+2],i[e+3*g+1]=t+d[g+1],i[e+3*g+2]=t+d[g+0])},Object.defineProperties(t.prototype,e),t}(my),Qw=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="cartoon",this.parameters=Object.assign({aspectRatio:{type:"number",precision:1,max:10,min:1,rebuild:!0},subdiv:{type:"integer",max:50,min:1,rebuild:!0},radialSegments:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},capped:{type:"boolean",rebuild:!0},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"chainname"),e.colorScale=bl(e.colorScale,"RdYlBu"),e.radiusType=bl(e.radiusType,"sstruc"),e.radiusScale=bl(e.radiusScale,.7),e.useInteriorColor=bl(e.useInteriorColor,!0),this.aspectRatio=bl(e.aspectRatio,5),this.tension=bl(e.tension,NaN),this.capped=bl(e.capped,!0),this.smoothSheet=bl(e.smoothSheet,!1),"low"===e.quality?(this.subdiv=3,this.radialSegments=6):"medium"===e.quality?this.subdiv=6:"high"===e.quality?this.subdiv=12:this.subdiv=bl(e.subdiv,6),r.prototype.init.call(this,e)},t.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:1!==this.aspectRatio,smoothSheet:this.smoothSheet},t)},t.prototype.getSpline=function(t){return new qw(t,this.getSplineParams())},t.prototype.getAspectRatio=function(t){return t.isCg()?1:this.aspectRatio},t.prototype.getAtomRadius=function(t){return t.isTrace()?r.prototype.getAtomRadius.call(this,t):0},t.prototype.createData=function(t){var c=this,u=[],h=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){h.push(t);var e=c.getSpline(t),i=c.getAspectRatio(t),r=e.getSubdividedPosition(),n=e.getSubdividedOrientation(),o=e.getSubdividedColor(c.getColorParams()),a=e.getSubdividedPicking(),s=e.getSubdividedSize(c.getRadiusParams());u.push(new Jw(Object.assign({},r,n,o,a,s),c.getBufferParams({radialSegments:c.radialSegments,aspectRatio:i,capped:c.capped})))}},t.getSelection()),{bufferList:u,polymerList:h}},t.prototype.updateData=function(t,e){de.Debug&&Yp.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i<r;++i){var n={},o=e.polymerList[i],a=this.getSpline(o),s=this.getAspectRatio(o);if(Object.assign(e.bufferList[i],{aspectRatio:s}),t.position||t.radius){var c=a.getSubdividedPosition(),u=a.getSubdividedOrientation(),h=a.getSubdividedSize(this.getRadiusParams(s));n.position=c.position,n.normal=u.normal,n.binormal=u.binormal,n.tangent=u.tangent,n.size=h.size}if(t.color){var l=a.getSubdividedColor(this.getColorParams());n.color=l.color}if(t.picking){var p=a.getSubdividedPicking();n.picking=p.picking}e.bufferList[i].setAttributes(n)}de.Debug&&Yp.timeEnd(this.type+" repr update")},t.prototype.setParameters=function(t){var e={};return t&&t.aspectRatio&&(e.radius=!0),t&&t.tension&&(e.position=!0),r.prototype.setParameters.call(this,t,e,!1),this},t}(pw);ed.add("cartoon",Qw);var tS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="contact",this.parameters=Object.assign({hydrogenBond:{type:"boolean",rebuild:!0},weakHydrogenBond:{type:"boolean",rebuild:!0},waterHydrogenBond:{type:"boolean",rebuild:!0},backboneHydrogenBond:{type:"boolean",rebuild:!0},hydrophobic:{type:"boolean",rebuild:!0},halogenBond:{type:"boolean",rebuild:!0},ionicInteraction:{type:"boolean",rebuild:!0},metalCoordination:{type:"boolean",rebuild:!0},cationPi:{type:"boolean",rebuild:!0},piStacking:{type:"boolean",rebuild:!0},filterSele:{type:"text",rebuild:!0},labelVisible:{type:"boolean",rebuild:!0},labelFixedSize:{type:"boolean",buffer:"fixedSize"},labelSize:{type:"number",precision:3,max:10,min:.001,rebuild:!0},labelUnit:{type:"select",rebuild:!0,options:{"":"",angstrom:"angstrom",nm:"nm"}},maxHydrophobicDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxHbondDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxHbondSulfurDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxHbondAccAngle:{type:"integer",max:180,min:0,rebuild:!0},maxHbondDonAngle:{type:"integer",max:180,min:0,rebuild:!0},maxHbondAccPlaneAngle:{type:"integer",max:90,min:0,rebuild:!0},maxHbondDonPlaneAngle:{type:"integer",max:90,min:0,rebuild:!0},maxPiStackingDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxPiStackingOffset:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxPiStackingAngle:{type:"integer",max:180,min:0,rebuild:!0},maxCationPiDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxCationPiOffset:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxIonicDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxHalogenBondDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},maxHalogenBondAngle:{type:"integer",max:180,min:0,rebuild:!0},maxMetalDist:{type:"number",precision:1,max:10,min:.1,rebuild:!0},refineSaltBridges:{type:"boolean",rebuild:!0},masterModelIndex:{type:"integer",max:1e3,min:-1,rebuild:!0},lineOfSightDistFactor:{type:"number",precision:1,max:10,min:0,rebuild:!0},radialSegments:!0,disableImpostor:!0},this.parameters),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.radiusSize=bl(e.radiusSize,.05),e.useInteriorColor=bl(e.useInteriorColor,!0),this.hydrogenBond=bl(e.hydrogenBond,!0),this.weakHydrogenBond=bl(e.weakHydrogenBond,!1),this.waterHydrogenBond=bl(e.waterHydrogenBond,!1),this.backboneHydrogenBond=bl(e.backboneHydrogenBond,!1),this.hydrophobic=bl(e.hydrophobic,!1),this.halogenBond=bl(e.halogenBond,!0),this.ionicInteraction=bl(e.ionicInteraction,!0),this.metalCoordination=bl(e.metalCoordination,!0),this.cationPi=bl(e.cationPi,!0),this.piStacking=bl(e.piStacking,!0),this.filterSele=bl(e.filterSele,""),this.labelVisible=bl(e.labelVisible,!1),this.labelFixedSize=bl(e.labelFixedSize,!1),this.labelSize=bl(e.labelSize,2),this.labelUnit=bl(e.labelUnit,""),this.maxHydrophobicDist=bl(e.maxHydrophobicDist,4),this.maxHbondDist=bl(e.maxHbondDist,3.5),this.maxHbondSulfurDist=bl(e.maxHbondSulfurDist,4.1),this.maxHbondAccAngle=bl(e.maxHbondAccAngle,45),this.maxHbondDonAngle=bl(e.maxHbondDonAngle,45),this.maxHbondAccPlaneAngle=bl(e.maxHbondAccPlaneAngle,90),this.maxHbondDonPlaneAngle=bl(e.maxHbondDonPlaneAngle,30),this.maxPiStackingDist=bl(e.maxPiStackingDist,5.5),this.maxPiStackingOffset=bl(e.maxPiStackingOffset,2),this.maxPiStackingAngle=bl(e.maxPiStackingAngle,30),this.maxCationPiDist=bl(e.maxCationPiDist,6),this.maxCationPiOffset=bl(e.maxCationPiOffset,2),this.maxIonicDist=bl(e.maxIonicDist,5),this.maxHalogenBondDist=bl(e.maxHalogenBondDist,3.5),this.maxHalogenBondAngle=bl(e.maxHalogenBondAngle,30),this.maxMetalDist=bl(e.maxMetalDist,3),this.refineSaltBridges=bl(e.refineSaltBridges,!0),this.masterModelIndex=bl(e.masterModelIndex,-1),this.lineOfSightDistFactor=bl(e.lineOfSightDistFactor,1),r.prototype.init.call(this,e)},t.prototype.getAtomRadius=function(){return 0},t.prototype.getContactData=function(t){var e={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},i={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};return nv(ev(t,e),t,i)},t.prototype.createData=function(t){var e=this.getContactData(t),i=[new Gw(Lm(e),this.getBufferParams({sphereDetail:1,dullInterior:!0,disableImpostor:this.disableImpostor}))];if(this.labelVisible){var r={size:this.labelSize,unit:this.labelUnit};i.push(new Aw(function(t,e){for(var i=Ud(t.position1,t.position2),r=[],n=jd(t.position1,t.position2),o=n.length/3,a=0;a<o;a++){var s=3*a,c=Math.sqrt(Math.pow(n[s],2)+Math.pow(n[s+1],2)+Math.pow(n[s+2],2));switch(e.unit){case"angstrom":r[a]=c.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[a]=(c/10).toFixed(2)+" nm";break;default:r[a]=c.toFixed(2)}}return{position:i,size:Gd(i.length/3,e.size),color:t.color,text:r}}(e,r),{fixedSize:this.labelFixedSize}))}return{bufferList:i}},t}(pw);ed.add("contact",tS);var eS=function(a){function t(t,e,i){a.call(this,t,e,i),this.type="dihedral",this.parameters=Object.assign({atomQuad:{type:"hidden",rebuild:!0},extendLine:{type:"boolean",rebuild:!0,default:!0},lineVisible:{type:"boolean",default:!0},planeVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}return a&&(t.__proto__=a),((t.prototype=Object.create(a&&a.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.side=bl(e.side,"double"),e.opacity=bl(e.opacity,.5),this.atomQuad=bl(e.atomQuad,[]),this.extendLine=bl(e.extendLine,!0),this.lineVisible=bl(e.lineVisible,!0),this.planeVisible=bl(e.planeVisible,!0),this.sectorVisible=bl(e.sectorVisible,!0),a.prototype.init.call(this,e)},t.prototype.createData=function(t){if(t.atomCount&&this.atomQuad.length){var e=function(m,g){void 0===g&&(g={});for(var v=bl(g.angleStep,Math.PI/90),t=m.length,e=m.length/12,y=new Float32Array(e),b=new Float32Array(3*e),x=new Array(e),_=new Array(e),w=new Array(e),S=new Array(e),A=new Array(e),M=0,E=0,P=0,T=gm(),C=gm(),I=gm(),O=gm(),L=gm(),R=gm(),D=gm(),k=gm(),B=gm(),N=gm(),F=gm(),z=gm(),U=gm(),j=gm(),G=gm(),V=0,i=function(t){if(_m(T,m,t),_m(C,m,t+3),_m(I,m,t+6),_m(O,m,t+9),bm(L,T,C),bm(R,I,C),0!==Sm(R)){bm(D,O,I),Mm(k,R,.5),xm(B,C,k),Em(L,L),Em(R,R),Em(D,D),bm(k,T,B);var e=0<ym(k,R);bm(k,O,B);var i=ym(k,R)<0;if(Mm(k,R,ym(R,L)),bm(N,L,k),Mm(k,R,ym(R,D)),bm(F,D,k),0!==Sm(N)&&0!==Sm(F)){Em(N,N),Em(F,F);var r=y[V]=Math.acos(ym(N,F));x[V]=(Fd*r).toFixed(1)+String.fromCharCode(176),vm(j,N,R),Em(j,j),ym(j,F)<0&&Om(j,j),mw(k,B,N,j,r/2),wm(k,b,3*V);var n=Math.ceil(r/v),o=n+(g.extendLine?4:2),a=g.extendLine?36:0,s=new Float32Array(3*o),c=new Float32Array(3*o),u=new Float32Array(9*n),h=new Float32Array(a);_[V]=s,w[V]=c,S[V]=u,A[V]=h,g.extendLine&&(e?(bm(k,T,I),Em(k,k),Mm(z,k,1/ym(N,k)),xm(z,z,I)):(Mm(z,L,1/ym(N,L)),xm(z,z,C)),i?(bm(k,O,C),Em(k,k),Mm(U,k,1/ym(F,k)),xm(U,U,C)):(Mm(U,D,1/ym(F,D)),xm(U,U,I))),xm(G,B,N);var l=0;g.extendLine?(wm(T,s,l),wm(z,c,l),wm(z,s,l+=3),wm(G,c,l),l+=3,wm(z,h,0),wm(G,h,3),wm(e?I:C,h,6),wm(e?I:C,h,9),wm(G,h,12),wm(B,h,15)):(wm(B,s,l),wm(G,c,l),l+=3);for(var p=function(t,e){var i=9*e;wm(B,u,i),wm(G,u,i+3),wm(G,s,l),mw(G,B,N,j,t),wm(G,u,i+6),wm(G,c,l),l+=3},d=0,f=v;f<r;f+=v)p(f,d++);p(r,d++),g.extendLine?(wm(G,s,3*(o-2)),wm(U,c,3*(o-2)),wm(U,s,3*(o-1)),wm(O,c,3*(o-1)),wm(U,h,18),wm(G,h,21),wm(i?C:I,h,24),wm(i?C:I,h,27),wm(G,h,30),wm(B,h,33)):(wm(G,s,l),wm(B,c,l),l+=3),M+=3*o,E+=9*n,P+=a,V+=1}}},r=0;r<t;r+=12)i(r);for(var n=V,o=new Float32Array(M),a=new Float32Array(M),s=new Float32Array(E),c=new Float32Array(P),u=0,h=0,l=0,p=0;p<n;p++){var d=_[p],f=w[p],H=S[p],$=A[p];Xd(d,o,0,u,d.length),Xd(f,a,0,u,f.length),Xd(H,s,0,h,H.length),Xd($,c,0,l,$.length),u+=d.length,h+=H.length,l+=$.length}return{labelPosition:b.subarray(0,3*n),labelText:x.slice(0,n),linePosition1:o,linePosition2:a,planePosition:c,sectorPosition:s}}(fw(t,this.atomQuad),{extendLine:this.extendLine}),i=this.n=e.labelText.length,r=new ki(this.labelColor);this.textBuffer=new Aw({position:e.labelPosition,size:Gd(i,this.labelSize),color:Vd(i,r.r,r.g,r.b),text:e.labelText},this.getLabelBufferParams());var n=new ki(this.colorValue);this.lineLength=e.linePosition1.length/3;var o=Vd(this.lineLength,n.r,n.g,n.b);return this.lineBuffer=new Pw(Dm({position1:e.linePosition1,position2:e.linePosition2,color:o,color2:o}),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),this.planeLength=e.planePosition.length/3,this.planeBuffer=new my({position:e.planePosition,color:Vd(this.planeLength,n.r,n.g,n.b)},this.getBufferParams({visible:this.planeVisible})),this.sectorLength=e.sectorPosition.length/3,this.sectorBuffer=new my({position:e.sectorPosition,color:Vd(this.sectorLength,n.r,n.g,n.b)},this.getBufferParams({visible:this.sectorVisible})),{bufferList:[this.textBuffer,this.lineBuffer,this.planeBuffer,this.sectorBuffer]}}},t.prototype.updateData=function(t,e){a.prototype.updateData.call(this,t,e);var i={},r={},n={};if(t.color){var o=new ki(this.colorValue);Object.assign(i,{color:Vd(this.lineLength,o.r,o.g,o.b),color2:Vd(this.lineLength,o.r,o.g,o.b)}),Object.assign(r,{color:Vd(this.planeLength,o.r,o.g,o.b)}),Object.assign(n,{color:Vd(this.sectorLength,o.r,o.g,o.b)})}this.lineBuffer.setAttributes(i),this.planeBuffer.setAttributes(r),this.sectorBuffer.setAttributes(n)},t.prototype.setParameters=function(t){return a.prototype.setParameters.call(this,t,{},!1),!t||void 0===t.lineVisible&&void 0===t.sectorVisible&&void 0===t.planeVisible||this.setVisibility(this.visible),t&&t.lineOpacity&&this.lineBuffer.setParameters({opacity:t.lineOpacity}),t&&void 0!==t.opacity&&this.lineBuffer.setParameters({opacity:this.lineOpacity}),t&&t.linewidth&&this.lineBuffer.setParameters({linewidth:t.linewidth}),this},t.prototype.setVisibility=function(t,e){return a.prototype.setVisibility.call(this,t,!0),this.lineBuffer&&this.lineBuffer.setVisibility(this.lineVisible&&this.visible),this.planeBuffer&&this.planeBuffer.setVisibility(this.planeVisible&&this.visible),this.sectorBuffer&&this.sectorBuffer.setVisibility(this.sectorVisible&&this.visible),e||this.viewer.requestRender(),this},t}(dw);ed.add("dihedral",eS);var iS=function(o){function t(t,e,i){o.call(this,t,e,i),this.type="distance",this.parameters=Object.assign({radialSegments:!0,openEnded:!0,disableImpostor:!0,labelUnit:{type:"select",rebuild:!0,options:{"":"",angstrom:"angstrom",nm:"nm"}},useCylinder:{type:"boolean",rebuild:!0},atomPair:{type:"hidden",rebuild:!0}},this.parameters),this.init(i)}return o&&(t.__proto__=o),((t.prototype=Object.create(o&&o.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.linewidth=bl(e.linewidth,5),e.radiusType=bl(e.radiusType,"size"),e.radiusSize=bl(e.radiusSize,.2),this.labelUnit=bl(e.labelUnit,""),this.useCylinder=bl(e.useCylinder,!1),this.atomPair=bl(e.atomPair,[]),o.prototype.init.call(this,e)},t.prototype.getDistanceData=function(c,t){var u=this,e=t.length,h=new Array(e),l=new Float32Array(3*e),p=new Lp,d=new Lp,f=new Yy,m=c.getAtomProxy(),g=c.getAtomProxy(),v=0,y=c.getAtomSet();t.forEach(function(t,e){var i=t[0],r=t[1];if("number"==typeof i&&Number.isInteger(i)&&"number"==typeof r&&Number.isInteger(r)){if(!y.get(i)||!y.get(r))return void(v+=1);m.index=i,g.index=r}else{p.setString(i),d.setString(r);var n=c.getAtomIndices(p),o=c.getAtomIndices(d);if(!n.length||!o.length)return void(v+=1);m.index=n[0],g.index=o[0]}f.addBond(m,g,1),e-=v;var a=m.distanceTo(g);switch(u.labelUnit){case"angstrom":h[e]=a.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":h[e]=(a/10).toFixed(2)+" nm";break;default:h[e]=a.toFixed(2)}var s=3*e;l[s+0]=(m.x+g.x)/2,l[s+1]=(m.y+g.y)/2,l[s+2]=(m.z+g.z)/2}),0<v&&(e-=v,l=l.subarray(0,3*e));var i=new tg(f.count,!0);return{text:h,position:l,bondSet:i,bondStore:f}},t.prototype.getBondData=function(t,e,i){var r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new gv(r.picking.array,r.picking.structure,i.bondStore)),r},t.prototype.createData=function(t){if(t.atomCount&&this.atomPair.length){var e=this.atomPair.length,i=new ki(this.labelColor),r=this.getDistanceData(t,this.atomPair);this.textBuffer=new Aw({position:r.position,size:Gd(e,this.labelSize),color:Vd(e,i.r,i.g,i.b),text:r.text},this.getLabelBufferParams());var 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 Gw(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Pw(Rm(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]}}},t.prototype.updateData=function(t,e){o.prototype.updateData.call(this,t,e);var i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),n={};t&&!t.color||Object.assign(n,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(n,{radius:r.radius}),this.distanceBuffer.setAttributes(n)},t.prototype.setParameters=function(t){return o.prototype.setParameters.call(this,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},t}(dw);function rS(t){return 2*(t.position.length/3)*3}ed.add("distance",iS);var nS=Object.assign({scale:1,color:"grey"},ly),oS=function(n){function t(t,e){void 0===e&&(e={}),n.call(this,{position:new Float32Array(rS(t)),color:new Float32Array(rS(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";var i=new ki(this.parameters.color),r=this.geometry.attributes;Vd(rS(t)/3,i.r,i.g,i.b,r.color.array),this.setAttributes(t)}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return nS},t.prototype.setAttributes=function(t){void 0===t&&(t={});var e,i,r,n=this.geometry.attributes;t.position&&t.vector&&(e=t.position,i=t.vector,r=n.position.array,n.position.needsUpdate=!0);var o=this.size/2,a=this.parameters.scale;if(e&&i)for(var s=0;s<o;s++){var c=2*s*3,u=3*s;r[c+0]=e[u+0],r[c+1]=e[u+1],r[c+2]=e[u+2],r[c+3]=e[u+0]+i[u+0]*a,r[c+4]=e[u+1]+i[u+1]*a,r[c+5]=e[u+2]+i[u+2]*a}},Object.defineProperties(t.prototype,e),t}(dy),aS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="helixorient",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"sstruc"),e.radiusType=bl(e.radiusType,"size"),e.radiusSize=bl(e.radiusSize,.15),e.radiusScale=bl(e.radiusScale,1),e.useInteriorColor=bl(e.useInteriorColor,!0),r.prototype.init.call(this,e)},t.prototype.createData=function(t){var a=this,s=[],c=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){c.push(t);var e=new tb(t),i=e.getPosition(),r=e.getColor(a.getColorParams()),n=e.getSize(a.getRadiusParams()),o=e.getPicking();s.push(new Px({position:i.center,color:r.color,radius:n.size,picking:o.picking},a.getBufferParams({sphereDetail:a.sphereDetail,disableImpostor:a.disableImpostor,dullInterior:!0})),new oS({position:i.center,vector:i.axis},a.getBufferParams({color:"skyblue",scale:1})),new oS({position:i.center,vector:i.resdir},a.getBufferParams({color:"lightgreen",scale:1})))}},t.getSelection()),{bufferList:s,polymerList:c}},t.prototype.updateData=function(t,e){de.Debug&&Yp.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i<r;++i){var n=3*i,o={},a=e.polymerList[i],s=new tb(a);if(t.position){var c=s.getPosition();Object.assign(o,{position:c.center}),e.bufferList[n+1].setAttributes({position:c.center,vector:c.axis}),e.bufferList[n+2].setAttributes({position:c.center,vector:c.resdir})}e.bufferList[n].setAttributes(o)}de.Debug&&Yp.timeEnd(this.type+" repr update")},t}(pw);ed.add("helixorient",aS);var sS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="licorice",this.parameters=Object.assign({},this.parameters,{aspectRatio:null})}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.aspectRatio=1,r.prototype.init.call(this,e)},t}(Hw);ed.add("licorice",sS),rd.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}"),rd.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 );\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}");var cS=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]),uS=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]),hS=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,"v3",t,e)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={mapping:{configurable:!0},mappingIndices:{configurable:!0},mappingIndicesSize:{configurable:!0},mappingSize:{configurable:!0},mappingItemSize:{configurable:!0}};return e.mapping.get=function(){return cS},e.mappingIndices.get=function(){return uS},e.mappingIndicesSize.get=function(){return 36},e.mappingSize.get=function(){return 8},e.mappingItemSize.get=function(){return 3},Object.defineProperties(t.prototype,e),t}(wx),lS=Object.assign({shrink:.14},ly),pS=Object.assign({shrink:{uniform:!0}},py),dS=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e),this.parameterTypes=pS,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new ei},modelViewProjectionMatrixInverse:{value:new ei},modelViewMatrixInverseTranspose:{value:new ei},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()}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return lS},Object.defineProperties(t.prototype,e),t}(hS),fS=(Object.assign({disableImpostor:!1},Rw,lS),function(t,e){return void 0===e&&(e={}),!Xp||e&&e.disableImpostor?(t.radius=function(t,e){for(var i=t.length,r=new Float32Array(i),n=0;n<i;n++)r[n]=Math.min(t[n],e[n]);return r}(t.radius,t.radius2),new kw(t,e)):new dS(t,e)}),mS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="hyperball",this.parameters=Object.assign({shrink:{type:"number",precision:3,max:1,min:.001,buffer:!0}},this.parameters,{multipleBond:null,bondSpacing:null})}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.radiusScale=bl(e.radiusScale,.2),e.radiusType=bl(e.radiusType,"vdw"),e.useInteriorColor=bl(e.useInteriorColor,!0),this.shrink=bl(e.shrink,.12),r.prototype.init.call(this,e)},t.prototype.getBondParams=function(t,e){return t&&!t.radius||(e=Object.assign({radius2:!0},e)),r.prototype.getBondParams.call(this,t,e)},t.prototype.createData=function(t){var e=new Px(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));return this.__center=new Float32Array(3*t.bondCount),{bufferList:[e,new fS(t.getBondData(this.getBondParams()),this.getBufferParams({shrink:this.shrink,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))]}},t.prototype.updateData=function(t,e){var i=e.sview.getAtomData(this.getAtomParams()),r=e.sview.getBondData(this.getBondParams()),n={},o={};if(!t||t.position){Object.assign(n,{position:i.position});var a=r.position1,s=r.position2;Object.assign(o,{position:Ud(a,s,this.__center),position1:a,position2:s})}t&&!t.color||(Object.assign(n,{color:i.color}),Object.assign(o,{color:r.color,color2:r.color2})),t&&!t.radius||(Object.assign(n,{radius:i.radius}),Object.assign(o,{radius:r.radius,radius2:r.radius2})),e.bufferList[0].setAttributes(n),e.bufferList[1].setAttributes(o)},t}(sS);ed.add("hyperball",mS);var gS=function(t,e,i){void 0===e&&(e={}),void 0===i&&(i=""),this.type=t,this.text=e,this.format=i};gS.prototype.atomLabel=function(t){var e;switch(this.type){case"atomname":e=t.atomname;break;case"atomindex":e=""+t.index;break;case"occupancy":e=t.occupancy.toFixed(2);break;case"bfactor":e=t.bfactor.toFixed(2);break;case"serial":e=""+t.serial;break;case"element":e=t.element;break;case"atom":e=t.atomname+"|"+t.index;break;case"resname":e=t.resname;break;case"resno":e=""+t.resno;break;case"res":e=""+(_g[t.resname.toUpperCase()]||t.resname)+t.resno;break;case"residue":var i=_g[t.resname.toUpperCase()];e=i&&!t.inscode?""+i+t.resno:"["+t.resname+"]"+t.resno+t.inscode;break;case"text":e=this.text[t.index];break;case"format":e=yd(this.format,t);break;default:e=t.qualifiedName()}return void 0===e?"":e},gS.types={"":"",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 vS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="label",this.parameters=Object.assign({labelType:{type:"select",options:gS.types,rebuild:!0},labelText:{type:"hidden",rebuild:!0},labelFormat:{type:"text",rebuild:!0},labelGrouping:{type:"select",options:{atom:"atom",residue:"residue"},rebuild:!0},fontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:!0},fontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:!0},fontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:!0},xOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},yOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},zOffset:{type:"number",precision:1,max:20,min:-20,buffer:!0},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:!0},showBorder:{type:"boolean",buffer:!0},borderColor:{type:"color",buffer:!0},borderWidth:{type:"number",precision:2,max:.3,min:0,buffer:!0},showBackground:{type:"boolean",rebuild:!0},backgroundColor:{type:"color",buffer:!0},backgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},backgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:!0},fixedSize:{type:"boolean",buffer:!0}},this.parameters,{side:null,flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null,diffuse:null}),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};this.labelType=bl(e.labelType,"res"),this.labelText=bl(e.labelText,{}),this.labelFormat=bl(e.labelFormat,""),this.labelGrouping=bl(e.labelGrouping,"atom"),this.fontFamily=bl(e.fontFamily,"sans-serif"),this.fontStyle=bl(e.fontStyle,"normal"),this.fontWeight=bl(e.fontWeight,"bold"),this.xOffset=bl(e.xOffset,0),this.yOffset=bl(e.yOffset,0),this.zOffset=bl(e.zOffset,.5),this.attachment=bl(e.attachment,"bottom-left"),this.showBorder=bl(e.showBorder,!1),this.borderColor=bl(e.borderColor,"lightgrey"),this.borderWidth=bl(e.borderWidth,.15),this.showBackground=bl(e.showBackground,!1),this.backgroundColor=bl(e.backgroundColor,"lightgrey"),this.backgroundMargin=bl(e.backgroundMargin,.5),this.backgroundOpacity=bl(e.backgroundOpacity,1),this.fixedSize=bl(e.fixedSize,!1),r.prototype.init.call(this,e)},t.prototype.getTextData=function(t,i){var e,r,n,o,a,s,c,u=this.getAtomParams(i),h=new gS(this.labelType,this.labelText,this.labelFormat);if("atom"===this.labelGrouping){var l=t.getAtomData(u);e=l.position,r=l.radius,n=l.color,i&&!i.text||(o=[],t.eachAtom(function(t){return o.push(h.atomLabel(t))}))}else if("residue"===this.labelGrouping){i&&!i.position||(a=[]),i&&!i.color||(c=[]),i&&!i.radius||(s=[]),i&&!i.text||(o=[]),u.colorParams&&(u.colorParams.structure=t.getStructure());var p=Qp.getScheme(u.colorParams),d=new Gy(u.radiusParams),f=t.getAtomProxy(),m=0;t.eachResidue(function(t){var e=3*m;t.isProtein()||t.isNucleic()?(f.index=t.traceAtomIndex,i&&!i.position||f.positionToArray(a,e)):(f.index=t.atomOffset,i&&!i.position||t.positionToArray(a,e)),i&&!i.color||p.atomColorToArray(f,c,e),i&&!i.radius||(s[m]=d.atomRadius(f)),i&&!i.text||o.push(h.atomLabel(f)),++m}),i&&!i.position||(e=new Float32Array(a)),i&&!i.color||(n=new Float32Array(c)),i&&!i.radius||(r=new Float32Array(s))}return{position:e,size:r,color:n,text:o}},t.prototype.createData=function(t){return{bufferList:[new Aw(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}))]}},t.prototype.updateData=function(t,e){e.bufferList[0].setAttributes(this.getTextData(e.sview,t))},t.prototype.getAtomRadius=function(){return 0},t}(pw);ed.add("label",vS);var yS=function(r){function t(t,e,i){r.call(this,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)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};this.multipleBond=bl(e.multipleBond,"off"),this.bondSpacing=bl(e.bondSpacing,1),this.linewidth=bl(e.linewidth,2),this.lines=bl(e.lines,!0),this.crosses=bl(e.crosses,"lone"),this.crossSize=bl(e.crossSize,.4),r.prototype.init.call(this,e)},t.prototype.getAtomRadius=function(t){return.1},t.prototype.getBondParams=function(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},e),r.prototype.getBondParams.call(this,t,e)},t.prototype._crossData=function(t,e){if(!t||t.position||t.color){var i,r,n,o,a={};"lone"===this.crosses&&Object.assign(a,{atomSet:(i=e,r=i.getAtomSet(),n=i.getBondSet(),o=i.getBondProxy(),n.forEach(function(t){o.index=t,r.clear(o.atomIndex1),r.clear(o.atomIndex2)}),r)});var s,c=e.getAtomData(this.getAtomParams(t,a)),u={},h=c.position,l=c.color,p=c.picking,d=(h||l).length,f=3*d,m=new Float32Array(0),g=new Float32Array(0),v=new Float32Array(0),y=new Float32Array(0),b=new Float32Array(0);t&&!t.position||(m=u.position1=new Float32Array(f),g=u.position2=new Float32Array(f),s=this.crossSize/2),t&&!t.color||(v=u.color=new Float32Array(f),y=u.color2=new Float32Array(f)),t&&!t.picking||(b=new Float32Array(3*c.picking.array.length));for(var x=0;x<d;x++){var _=3*x,w=3*_;if(!t||t.position){var S=h[_],A=h[_+1],M=h[_+2];m[w]=S-s,m[w+1]=A,m[w+2]=M,g[w]=S+s,g[w+1]=A,g[w+2]=M,m[w+3]=S,m[w+4]=A-s,m[w+5]=M,g[w+3]=S,g[w+4]=A+s,g[w+5]=M,m[w+6]=S,m[w+7]=A,m[w+8]=M-s,g[w+6]=S,g[w+7]=A,g[w+8]=M+s}if(!t||t.color)for(var E=w+9,P=w;P<E;P+=3)v[P]=y[P]=l[_],v[P+1]=y[P+1]=l[_+1],v[P+2]=y[P+2]=l[_+2];t&&!t.picking||(b[_]=b[_+1]=b[_+2]=p.array[x])}return t&&!t.picking||(u.picking=new hv(b,p.structure)),u}},t.prototype.createData=function(t){var e={position:!0,color:!0,picking:!0},i=[];if(this.lines){var r=t.getBondData(this.getBondParams(e)),n=new Pw(r,this.getBufferParams({linewidth:this.linewidth}));i.push(n)}if("off"!==this.crosses){var o=new Pw(this._crossData(e,t),this.getBufferParams({linewidth:this.linewidth}));i.push(o)}return{bufferList:i}},t.prototype.updateData=function(t,e){var i=0;if(this.lines){var r=e.sview.getBondData(this.getBondParams(t)),n={};t&&!t.position||Object.assign(n,{position1:r.position1,position2:r.position2}),t&&!t.color||Object.assign(n,{color:r.color,color2:r.color2}),e.bufferList[i++].setAttributes(n)}if("off"!==this.crosses){var o=this._crossData(t,e.sview),a={};t&&!t.position||Object.assign(a,{position1:o.position1,position2:o.position2}),t&&!t.color||Object.assign(a,{color:o.color,color2:o.color2}),e.bufferList[i++].setAttributes(a)}},t.prototype.setParameters=function(t){var e={};return t&&(t.bondSpacing||t.crossSize)&&Object.assign(e,{position:!0}),r.prototype.setParameters.call(this,t,e,!1),this},t}(pw);function bS(t,r,n,e,s){var c=new(e=e||Int32Array)(t*r*n*(s=s||1));function u(t,e,i){return((t*r+e)*n+i)*s}return{data:c,index:u,set:function(t,e,i){for(var r=[],n=arguments.length-3;0<n--;)r[n]=arguments[n+3];for(var o=u(t,e,i),a=0;a<s;++a)c[o+a]=r[a]},toArray:function(t,e,i,r,n){void 0===r&&(r=[]),void 0===n&&(n=0);for(var o=u(t,e,i),a=0;a<s;++a)r[n+a]=c[o+a]},fromArray:function(t,e,i,r,n){void 0===n&&(n=0);for(var o=u(t,e,i),a=0;a<s;++a)c[o+a]=r[n+a]},copy:function(t){c.set(t.data)}}}function xS(C,I,c){var p=ey(I),t=pm(C);0===C.length&&(t[0].set([0,0,0]),t[1].set([0,0,0]));var d,O,g,L,R,D,u,k,B,N,v,F,z,w,U,h=t[0],l=t[1];var j=1,P=2,S=4,A=[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])];function f(t){var e,i,r,n,o,a,s,c,u,h;for(var l in p)if(e=parseFloat(l),!B[l]){for(a=(s=t?(e+d)*O+.5:e*O+.5)*s,c=Math.floor(s)+1,u=new Int32Array(c*c),i=h=0;i<c;++i)for(r=0;r<c;++r)a<(n=i*i+r*r)?u[h]=-1:(o=Math.sqrt(a-n),u[h]=Math.floor(o)),++h;N[l]=c,B[l]=u}}function m(t){var e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b=3*t,x=t;e=Math.floor(.5+O*(C[b]+k[0])),i=Math.floor(.5+O*(C[b+1]+k[1])),r=Math.floor(.5+O*(C[b+2]+k[2]));var _,w=I[x],S=B[w],A=0,M=R*D,E=N[w];for(h=0;h<E;++h)for(l=0;l<E;++l){if(-1!==(_=S[A]))for(g=-1;g<2;++g)for(v=-1;v<2;++v)for(y=-1;y<2;++y)if(0!==g&&0!==v&&0!==y)for(s=g*h,u=y*l,p=0;p<=_;++p)if(f=i+(c=p*v),m=r+u,!((d=e+s)<0||f<0||m<0||L<=d||R<=f||D<=m)){var P=d*M+f*D+m;if(F)if(z[P]&j){if(z[P]&j){var T=U[P];T!==b&&s*s+c*c+u*u<(n=e+s-Math.floor(.5+O*(C[T]+k[0])))*n+(o=i+c-Math.floor(.5+O*(C[T+1]+k[1])))*o+(a=r+u-Math.floor(.5+O*(C[T+2]+k[2])))*a&&(U[P]=t)}}else z[P]|=j,U[P]=t;else z[P]|=j}A++}}function y(t){var e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x=3*t,_=t,w=0;e=Math.floor(.5+O*(C[x]+k[0])),i=Math.floor(.5+O*(C[x+1]+k[1])),r=Math.floor(.5+O*(C[x+2]+k[2]));var S=I[_],A=R*D;for(d=0,b=N[S];d<b;++d)for(f=0;f<b;++f){if(-1!==B[S][w])for(g=-1;g<2;++g)for(v=-1;v<2;++v)for(y=-1;y<2;++y)if(0!==g&&0!==v&&0!==y)for(s=g*d,u=y*f,m=0;m<=B[S][w];++m)if(l=i+(c=m*v),p=r+u,!((h=e+s)<0||l<0||p<0||L<=h||R<=l||D<=p)){var M=h*A+l*D+p;if(z[M]&P){if(F){var E=U[M];s*s+c*c+u*u<(n=Math.floor(.5+O*(C[E]+k[0])))*n+(o=Math.floor(.5+O*(C[E+1]+k[1])))*o+(a=Math.floor(.5+O*(C[E+2]+k[2])))*a&&(U[M]=t)}}else z[M]|=P,F&&(U[M]=t)}w++}}function b(t,e,i,r){var n,o,a,s,c,u,h,l,p,d,f,m,g=new Uint16Array(3),v=0;if(0===i)return v;var y=-1,b=-1,x=-1,_=R*D;for(h=0,p=i;h<p;h+=3)for(n=t[h],o=t[h+1],a=t[h+2],e.toArray(n,o,a,g),l=0;l<6;++l)y=n+(m=A[l])[0],b=o+m[1],x=a+m[2],y<L&&-1<y&&b<R&&-1<b&&x<D&&-1<x&&(z[f=y*_+D*b+x]&j&&!(z[f]&P)?(e.fromArray(y,b,x,g),d=(s=y-g[0])*s+(c=b-g[1])*c+(u=x-g[2])*u,w[f]=d,z[f]|=P,z[f]|=S,r[v]=y,r[v+1]=b,r[v+2]=x,v+=3):z[f]&j&&z[f]&P&&(d=(s=y-g[0])*s+(c=b-g[1])*c+(u=x-g[2])*u)<w[f]&&(e.fromArray(y,b,x,g),w[f]=d,z[f]&S||(z[f]|=S,r[v]=y,r[v+1]=b,r[v+2]=x,v+=3)));for(h=0,p=i;h<p;h+=3)for(n=t[h],o=t[h+1],a=t[h+2],e.toArray(n,o,a,g),l=6;l<18;l++)y=n+(m=A[l])[0],b=o+m[1],x=a+m[2],y<L&&-1<y&&b<R&&-1<b&&x<D&&-1<x&&(z[f=y*_+D*b+x]&j&&!(z[f]&P)?(e.fromArray(y,b,x,g),d=(s=y-g[0])*s+(c=b-g[1])*c+(u=x-g[2])*u,w[f]=d,z[f]|=P,z[f]|=S,r[v]=y,r[v+1]=b,r[v+2]=x,v+=3):z[f]&j&&z[f]&P&&(d=(s=y-g[0])*s+(c=b-g[1])*c+(u=x-g[2])*u)<w[f]&&(e.fromArray(y,b,x,g),w[f]=d,z[f]&S||(z[f]|=S,r[v]=y,r[v+1]=b,r[v+2]=x,v+=3)));for(h=0,p=i;h<p;h+=3)for(n=t[h],o=t[h+1],a=t[h+2],e.toArray(n,o,a,g),l=18;l<26;l++)y=n+(m=A[l])[0],b=o+m[1],x=a+m[2],y<L&&-1<y&&b<R&&-1<b&&x<D&&-1<x&&(z[f=y*_+D*b+x]&j&&!(z[f]&P)?(e.fromArray(y,b,x,g),d=(s=y-g[0])*s+(c=b-g[1])*c+(u=x-g[2])*u,w[f]=d,z[f]|=P,z[f]|=S,r[v]=y,r[v+1]=b,r[v+2]=x,v+=3):z[f]&j&&z[f]&P&&(d=(s=y-g[0])*s+(c=b-g[1])*c+(u=x-g[2])*u)<w[f]&&(e.fromArray(y,b,x,g),w[f]=d,z[f]&S||(z[f]|=S,r[v]=y,r[v+1]=b,r[v+2]=x,v+=3)));return v}this.getVolume=function(t,e,i,r,n){console.time("EDTSurface.getVolume");var o="vws"!==t;!function(t,e,i,r,n){d=e||1.4,O=i||2,F=n||!0;var o=0;for(var a in p)o=Math.max(o,a);var s=iy(h,l,o,O,t?d:0);L=s.dim[0],R=s.dim[1],D=s.dim[2],u=s.matrix,k=s.tran,O=s.scaleFactor,B={},N={},f(t),v=d*O,g=r||d/O,z=new Uint8Array(L*R*D),t&&(w=new Float64Array(L*R*D)),F&&(U=new Int32Array(L*R*D))}(o,e,i,r,n),function(t){var e,i;for(console.time("EDTSurface fillvoxels"),e=0,i=z.length;e<i;++e)z[e]=0,t&&(w[e]=-1),F&&(U[e]=-1);for(e=0,i=C.length/3;e<i;++e)m(e);for(e=0,i=z.length;e<i;++e)z[e]&j&&(z[e]|=P);console.timeEnd("EDTSurface fillvoxels")}(o),function(){var t,e,i,r=R*D;for(t=0;t<L;++t)for(e=0;e<D;++e)for(i=0;i<R;++i){var n=t*r+i*D+e;if(z[n]&j)for(var o=0;o<26;){var a=t+A[o][0],s=e+A[o][2],c=i+A[o][1];if(-1<a&&a<L&&-1<c&&c<R&&-1<s&&s<D&&!(z[a*r+c*D+s]&j)){z[n]|=S;break}o++}}}(),"ms"!==t&&"ses"!==t||function(){var t,e,i,r;console.time("EDTSurface fastdistancemap");var n,o=bS(L,R,D,Uint16Array,3),a=R*D,s=v*v,c=0;for(t=0;t<L;++t)for(e=0;e<R;++e)for(i=0;i<D;++i)z[n=t*a+e*D+i]&=~P,z[n]&j&&z[n]&S&&(o.set(t,e,i,t,e,i),w[n]=0,z[n]|=P,c+=1);var u=new Int32Array(3*c),h=0,l=new Int32Array(3*c),p=0;for(t=0;t<L;++t)for(e=0;e<R;++e)for(i=0;i<D;++i)z[n=t*a+e*D+i]&S&&(u[h]=t,u[h+1]=e,u[h+2]=i,h+=3,z[n]&=~S);do{for(p=b(u,o,h,l),t=h=0,r=p;t<r;t+=3)n=a*l[t]+D*l[t+1]+l[t+2],z[n]&=~S,w[n]<=1.0404*s&&(u[h]=l[t],u[h+1]=l[t+1],u[h+2]=l[t+2],h+=3)}while(0<h);var d,f=g*g,m=new Uint16Array(3);for(t=0;t<L;++t)for(e=0;e<R;++e)for(i=0;i<D;++i)z[n=t*a+e*D+i]&=~S,z[n]&j&&(z[n]&P&&!(z[n]&P&&w[n]>=f)||(z[n]|=S,F&&z[n]&P&&(o.toArray(t,e,i,m),d=m[0]*a+m[1]*D+m[2],U[n]=U[d])));console.timeEnd("EDTSurface fastdistancemap")}(),"ses"===t&&(f(!1),function(){var t,e;for(t=0,e=z.length;t<e;++t)z[t]&=~P;for(t=0,e=C.length/3;t<e;++t)y(t)}()),function(t){var e,i=z.length;if("vws"===t)for(e=0;e<i;++e)z[e]&=~S,z[e]=z[e]&P?1:0;else if("ms"===t)for(e=0;e<i;++e)z[e]&=~P,z[e]&S&&(z[e]|=P),z[e]&=~S,z[e]=z[e]&P?1:0;else if("ses"===t)for(e=0;e<i;++e)z[e]&S&&z[e]&P?z[e]&=~S:z[e]&S&&!(z[e]&P)&&(z[e]|=P),z[e]=z[e]&P?1:0;else if("sas"===t)for(e=0;e<i;++e)z[e]&=~S,z[e]=z[e]&P?1:0}(t);for(var a=0,s=U.length;a<s;++a)U[a]=c[U[a]];return console.timeEnd("EDTSurface.getVolume"),{data:z,nx:D,ny:R,nz:L,atomindex:U}},this.getSurface=function(t,e,i,r,n,o,a){var s=this.getVolume(t,e,i,r,n);return new oy(s.data,s.nx,s.ny,s.nz,s.atomindex).getSurface(1,o,void 0,u,a)}}function _S(C,I,O,L,t,e,i){var r=C.length,R=t[0],D=t[1],k=t[2],n=e[0],o=e[1],a=e[2];function B(t,e){return Math.floor((t-e)/i)}for(var s,c,u,N=B(n,R)+1,F=B(o,D)+1,z=B(a,k)+1,h=N*F*z,U=F*z,l=[],p=0;p<r;p++){var d=(s=C[p],c=I[p],u=O[p],(B(s,R)*F+B(c,D))*z+B(u,k));void 0===l[d]?l[d]=[p]:l[d].push(p)}var j=new Uint32Array(h),G=new Uint16Array(h),V=new Uint32Array(r),f=0,m=0;for(p=0;p<h;p++){var g=j[p]=f,v=l[p];if(void 0!==v)for(var y=0;y<v.length;y++)V[f]=v[y],f++;var b=f-g;m<(G[p]=b)&&(m=b)}return{neighbourListLength:27*m+1,withinRadii:function(t,e,i,r,n){for(var o=0,a=B(t,R),s=B(e,D),c=B(i,k),u=Math.max(0,a-1),h=Math.max(0,s-1),l=Math.max(0,c-1),p=Math.min(N,a+2),d=Math.min(F,s+2),f=Math.min(z,c+2),m=u;m<p;++m)for(var g=m*U,v=h;v<d;++v)for(var y=v*z,b=l;b<f;++b)for(var x=g+y+b,_=j[x],w=_+G[x],S=_;S<w;S++){var A=V[S],M=C[A]-t,E=I[A]-e,P=O[A]-i,T=L[A]+r;M*M+E*E+P*P<=T*T&&(n[o++]=V[S])}n[o]=-1}}}function wS(u,c,r){for(var R=c.length,F=new Float32Array(R),z=new Float32Array(R),U=new Float32Array(R),t=0;t<R;t++){var e=3*t;F[t]=u[e],z[t]=u[e+1],U[t]=u[e+2]}var i=pm(u);0===u.length&&(i[0].set([0,0,0]),i[1].set([0,0,0]));var j,D,h,l,G,V,H,$,p,W,X,q,Y,Z,K,J,k,B,Q,tt=i[0],d=i[1],et=-1,it=new Float32Array([0,0,0]),rt=new Float32Array([0,0,0]),nt=new Float32Array([0,0,0]),ot=new Float32Array([0,0,0]);function n(t,e,i,r){l=bl(t,1.4),G=bl(e,2),V=bl(i,!0),H=bl(r,30),j=new Float32Array(R),D=new Float32Array(R);for(var n=0;n<j.length;++n){var o=c[n]+l;j[n]=o,D[n]=o*o}for(var a=h=0;a<j.length;++a)j[a]>h&&(h=j[a]);var s;s=iy(tt,d,h,G,0),G=s.scaleFactor,$=s.dim,p=s.matrix,Q=Math.max(5,2+Math.floor(l*G)),W=Gd($[0]*$[1]*$[2],-1001),X=new Int32Array(W.length),q=new Float32Array($[0]),Y=new Float32Array($[1]),Z=new Float32Array($[2]),f(q,tt[0],1/G),f(Y,tt[1],1/G),f(Z,tt[2],1/G),function(){var t=0,e=2*Math.PI/H;J=new Float32Array(H),K=new Float32Array(H);for(var i=0;i<H;i++)J[i]=Math.cos(t),K[i]=Math.sin(t),t+=e}(),k=_S(F,z,U,j,tt,d,2.01*h),B=new Int32Array(k.neighbourListLength),et=-1}function f(t,e,i){for(var r=0;r<t.length;r++)t[r]=e+i*r}function at(t,e,i,r,n){var o;if(-1!==et){if((o=et)!==r&&o!==n&&s(o,t,e,i))return o;et=-1}var a=0;for(o=B[a];0<=o;){if(o!==r&&o!==n&&s(o,t,e,i))return et=o;o=B[++a]}return et=-1}function s(t,e,i,r){var n=3*t,o=D[t],a=u[n]-e,s=u[n+1]-i,c=u[n+2]-r;return a*a+s*s+c*c<o}function o(t,e){var i,r,n=j[t],o=j[e],a=it[0]=F[e]-F[t],s=it[1]=z[e]-z[t],c=it[2]=U[e]-U[t],u=a*a+s*s+c*c,h=Math.sqrt(u),l=n*((n*n+h*h-o*o)/(2*n*h));Em(it,it),r=it,(i=nt)[0]=i[1]=i[2]=1,0!==r[0]?i[0]=(r[1]+r[2])/-r[0]:0!==r[1]?i[1]=(r[0]+r[2])/-r[1]:0!==r[2]&&(i[2]=(r[0]+r[1])/-r[2]),Em(nt,nt),vm(ot,it,nt),Em(ot,ot);var p=Math.sqrt(n*n-l*l);Mm(nt,nt,p),Mm(ot,ot,p),Mm(it,it,l),rt[0]=it[0]+F[t],rt[1]=it[1]+z[t],rt[2]=it[2]+U[t],et=-1;for(var d=Q,f=0;f<H;f++){var m=J[f],g=K[f],v=rt[0]+m*nt[0]+g*ot[0],y=rt[1]+m*nt[1]+g*ot[1],b=rt[2]+m*nt[2]+g*ot[2];if(-1===at(v,y,b,t,e))for(var x=Math.floor(G*(v-tt[0])),_=Math.floor(G*(y-tt[1])),w=Math.floor(G*(b-tt[2])),S=Math.max(0,x-d),A=Math.max(0,_-d),M=Math.max(0,w-d),E=Math.min($[0],x+d+2),P=Math.min($[1],_+d+2),T=Math.min($[2],w+d+2),C=S;C<E;C++){a=v-q[C];for(var I=$[1]*$[2]*C,O=A;O<P;O++)for(var L=a*a+(s=y-Y[O])*s,R=I+$[2]*O,D=M;D<T;D++){u=L+(c=b-Z[D])*c;var k=D+R,B=W[k];if(0<B&&u<B*B&&(W[k]=Math.sqrt(u),V)){var N=a*it[0]+s*it[1]+c*it[2];X[k]=N<0?e:t}}}}}function m(t,e,i){console.time("AVSurface.getVolume"),console.time("AVSurface.init"),n(t,e,i),console.timeEnd("AVSurface.init"),console.time("AVSurface.projectPoints"),function(){for(var t=0;t<R;t++){var e=F[t],i=z[t],r=U[t],n=j[t],o=D[t];k.withinRadii(e,i,r,n,B);for(var a=Math.ceil(n*G),s=Math.floor(G*(e-tt[0])),c=Math.floor(G*(i-tt[1])),u=Math.floor(G*(r-tt[2])),h=Math.max(0,s-a),l=Math.max(0,c-a),p=Math.max(0,u-a),d=Math.min($[0],s+a+2),f=Math.min($[1],c+a+2),m=Math.min($[2],u+a+2),g=h;g<d;g++)for(var v=q[g]-e,y=$[1]*$[2]*g,b=l;b<f;b++)for(var x=Y[b]-i,_=v*v+x*x,w=y+$[2]*b,S=p;S<m;S++){var A=Z[S]-r,M=_+A*A;if(M<o){var E=S+w;W[E]<0&&(W[E]=-W[E]);var P=Math.sqrt(M),T=n/P,C=v*T,I=x*T,O=A*T;if(-1===at(C+=e,I+=i,O+=r,t,-1)){var L=n-P;L<W[E]&&(W[E]=L,V&&(X[E]=t))}}}}}(),console.timeEnd("AVSurface.projectPoints"),console.time("AVSurface.projectTorii"),function(){for(var t=0;t<R;t++){k.withinRadii(F[t],z[t],U[t],j[t],B);for(var e=0,i=B[e];0<=i;)t<i&&o(t,i),i=B[++e]}}(),console.timeEnd("AVSurface.projectTorii"),function(){for(var t=0;t<W.length;t++)W[t]<0&&(W[t]=0)}(),function(){for(var t=0;t<X.length;t++)X[t]=r[X[t]]}(),console.timeEnd("AVSurface.getVolume")}this.getSurface=function(t,e,i,r,n,o,a){return m(e,i,n),new oy(W,$[2],$[1],$[0],X).getSurface(e,!1,void 0,p,a)}}ed.add("line",yS),Object.assign(xS,{__deps:[iy,ey,oy,pm,bS]}),Object.assign(wS,{__deps:[iy,oy,Gd,pm,Mm,vm,Em,_S,bl]}),Jp.add("molsurf",function(t,e){var i=t.data.args,r=t.data.params;if(i&&r){var n=new("av"===r.type?wS:xS)(i.coordList,i.radiusList,i.indexList).getSurface(r.type,r.probeRadius,r.scaleFactor,r.cutoff,!0,r.smooth,r.contour),o=[n.position.buffer,n.index.buffer];n.normal&&o.push(n.normal.buffer),n.atomindex&&o.push(n.atomindex.buffer),e({sd:n,p:r},o)}},[xS,wS]);var SS=function(t){this.structure=t};SS.prototype._getAtomData=function(t){return this.structure.getAtomData({what:{position:!0,radius:!0,index:!0},radiusParams:bl(t.radiusParams,{type:"vdw",scale:1})})},SS.prototype._makeSurface=function(t,e){var i=new ry(e.name,"",t);return i.info.type=e.type,i.info.probeRadius=e.probeRadius,i.info.scaleFactor=e.scaleFactor,i.info.smooth=e.smooth,i.info.cutoff=e.cutoff,i},SS.prototype.getSurface=function(t){var e=t||{},i=this._getAtomData(t),r=i.position,n=i.radius,o=i.index,a=new("av"===e.type?wS:xS)(r,n,o).getSurface(e.type,e.probeRadius,e.scaleFactor,e.cutoff,!0,e.smooth,e.contour);return this._makeSurface(a,e)},SS.prototype.getSurfaceWorker=function(t,i){var r=this,n=Object.assign({},t);if(window.hasOwnProperty("Worker")){void 0===this.worker&&(this.worker=new cm("molsurf"));var e=this._getAtomData(t),o=e.position,a=e.radius,s=e.index,c={args:{coordList:o,radiusList:a,indexList:s},params:n},u=[o.buffer,a.buffer,s.buffer];this.worker.post(c,u,function(t){i(r._makeSurface(t.data.sd,n))},function(t){console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),r.worker.terminate(),r.worker=void 0;var e=r.getSurface(n);i(e)})}else{var h=this.getSurface(n);i(h)}},SS.prototype.dispose=function(){this.worker&&this.worker.terminate()};var AS=function(n){function t(t,e,i){var r=this;n.call(this,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(function(){r.__forceNewMolsurf=!0}),this.toBePrepared=!0,this.init(i)}return n&&(t.__proto__=n),((t.prototype=Object.create(n&&n.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"uniform"),e.colorValue=bl(e.colorValue,14540253),e.disablePicking=bl(e.disablePicking,!0),this.surfaceType=bl(e.surfaceType,"ms"),this.probeRadius=bl(e.probeRadius,1.4),this.smooth=bl(e.smooth,2),this.scaleFactor=bl(e.scaleFactor,2),this.cutoff=bl(e.cutoff,0),this.contour=bl(e.contour,!1),this.background=bl(e.background,!1),this.opaqueBack=bl(e.opaqueBack,!0),this.filterSele=bl(e.filterSele,""),this.colorVolume=bl(e.colorVolume,void 0),this.useWorker=bl(e.useWorker,!0),n.prototype.init.call(this,t)},t.prototype.prepareData=function(t,e,i){var r=this.__infoList[e];if(r||(r={},this.__infoList[e]=r),r.molsurf&&r.sele===t.selection.string)i(e);else{if(this.filterSele){var n=t.structure.getView(new Lp(this.filterSele)),o=n.boundingBox.getSize(new ri),a=Math.max(o.x,o.y,o.z),s=t.getAtomSetWithinPoint(n.center,a/2+6);t=t.getView(new Lp(t.getAtomSetWithinSelection(s,3).toSeleString()))}r.sele=t.selection.string,r.molsurf=new SS(t);var c=this.getSurfaceParams(),u=function(t){r.surface=t,i(e)};this.useWorker?r.molsurf.getSurfaceWorker(c,u):u(r.molsurf.getSurface(c))}},t.prototype.prepare=function(t){var r=this;if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach(function(t){t.molsurf.dispose()}),this.__infoList.length=0),0!==this.structureView.atomCount){var n=function(){r.__sele=r.selection.string,r.__surfaceParams=JSON.stringify(r.getSurfaceParams()),r.__forceNewMolsurf=!1,t()},e="default"===this.assembly?this.defaultAssembly:this.assembly,o=this.structure.biomolDict[e];o?o.partList.forEach(function(t,e){var i=t.getView(r.structureView);r.prepareData(i,e,function(t){t===o.partList.length-1&&n()})}):this.prepareData(this.structureView,0,n)}else t()},t.prototype.createData=function(t,e){var i=this.__infoList[e],r=i.surface,n={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},o=[];if(r.contour){var a=new _y(n,this.getBufferParams({wireframe:!1}));o.push(a)}else{Object.assign(n,{normal:r.getNormal(),picking:r.getPicking(t.getStructure())});var s=new gy(n,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1})),c=new by(s);o.push(c)}return{bufferList:o,info:i}},t.prototype.updateData=function(t,e){var 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)},t.prototype.setParameters=function(t,e,i){return void 0===e&&(e={}),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),n.prototype.setParameters.call(this,t,e,i),this},t.prototype.getSurfaceParams=function(t){return void 0===t&&(t={}),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)},t.prototype.getColorParams=function(){var t=n.prototype.getColorParams.call(this);return t.volume=this.colorVolume,t},t.prototype.getAtomRadius=function(){return 0},t.prototype.clear=function(){n.prototype.clear.call(this)},t.prototype.dispose=function(){this.__infoList.forEach(function(t){t.molsurf.dispose()}),this.__infoList.length=0,n.prototype.dispose.call(this)},t}(pw);ed.add("surface",AS);var MS=function(r){function t(t,e,i){r.call(this,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)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};this.pointSize=bl(e.pointSize,1),this.sizeAttenuation=bl(e.sizeAttenuation,!0),this.sortParticles=bl(e.sortParticles,!1),this.useTexture=bl(e.useTexture,!1),this.alphaTest=bl(e.alphaTest,.5),this.forceTransparent=bl(e.forceTransparent,!1),this.edgeBleach=bl(e.edgeBleach,0),r.prototype.init.call(this,e)},t.prototype.createData=function(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Ix(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}},t.prototype.updateData=function(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)},t.prototype.getAtomRadius=function(){return.1},t}(pw);ed.add("point",MS),rd.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}");var ES=new Uint16Array([0,1,2,1,3,2]);function PS(t){return 3*(4*(t.position.length/3-1))}var TS=function(o){function t(t,e){void 0===e&&(e={}),o.call(this,{position:new Float32Array(PS(t)),color:new Float32Array(PS(t)),index:Ll(PS(t),PS(t)/3),normal:new Float32Array(PS(t)),picking:t.picking},e),this.vertexShader="Ribbon.vert";var i=t.position.length/3-1,r=4*i,n=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(n)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),t.primitiveId=Hd(i),this.setAttributes(t),this.makeIndex()}return o&&(t.__proto__=o),((t.prototype=Object.create(o&&o.prototype)).constructor=t).prototype.setAttributes=function(t){void 0===t&&(t={});var e,i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x=this.size/4,_=this.geometry.attributes;t.position&&(e=t.position,s=_.position.array,_.position.needsUpdate=!0),t.normal&&(i=t.normal,c=_.normal.array,_.normal.needsUpdate=!0),t.size&&(r=t.size,u=_.size.array,_.size.needsUpdate=!0),t.dir&&(n=t.dir,h=_.dir.array,_.dir.needsUpdate=!0),t.color&&(o=t.color,l=_.color.array,_.color.needsUpdate=!0),t.primitiveId&&(a=t.primitiveId,p=_.primitiveId.array,_.primitiveId.needsUpdate=!0);var w=r?r[0]:null;for(d=0;d<x;++d){for(m=(y=3*d)*4,v=4*d,e&&(s[m]=s[m+3]=e[y],s[m+1]=s[m+4]=e[y+1],s[m+2]=s[m+5]=e[y+2],s[m+6]=s[m+9]=e[y+3],s[m+7]=s[m+10]=e[y+4],s[m+8]=s[m+11]=e[y+5]),i&&(c[m]=c[m+3]=-i[y],c[m+1]=c[m+4]=-i[y+1],c[m+2]=c[m+5]=-i[y+2],c[m+6]=c[m+9]=-i[y+3],c[m+7]=c[m+10]=-i[y+4],c[m+8]=c[m+11]=-i[y+5]),f=0;f<4;++f)g=m+3*f,o&&(l[g]=o[y],l[g+1]=o[y+1],l[g+2]=o[y+2]),a&&(p[v+f]=a[d]);r&&(b=r[d],w!==r[d]?(u[v]=w,u[v+1]=w):(u[v]=b,u[v+1]=b),u[v+2]=b,w=u[v+3]=b),n&&(h[m]=n[y],h[m+1]=n[y+1],h[m+2]=n[y+2],h[m+3]=-n[y],h[m+4]=-n[y+1],h[m+5]=-n[y+2],h[m+6]=n[y+3],h[m+7]=n[y+4],h[m+8]=n[y+5],h[m+9]=-n[y+3],h[m+10]=-n[y+4],h[m+11]=-n[y+5])}},t.prototype.makeIndex=function(){for(var t=this.geometry.getIndex().array,e=t.length/4/3,i=0;i<e;++i){var r=6*i,n=4*i;t.set(ES,r);for(var o=0;o<6;++o)t[r+o]+=n}},t}(my),CS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="ribbon",this.parameters=Object.assign({subdiv:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters,{side:null,wireframe:null,linewidth:null}),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"chainname"),e.colorScale=bl(e.colorScale,"RdYlBu"),e.radiusType=bl(e.radiusType,"sstruc"),e.radiusScale=bl(e.radiusScale,4),"low"===e.quality?this.subdiv=3:"medium"===e.quality?this.subdiv=6:"high"===e.quality?this.subdiv=12:this.subdiv=bl(e.subdiv,6),this.tension=bl(e.tension,NaN),this.smoothSheet=bl(e.smoothSheet,!1),r.prototype.init.call(this,e)},t.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:!0,smoothSheet:this.smoothSheet},t)},t.prototype.getAtomRadius=function(t){return t.isTrace()?r.prototype.getAtomRadius.call(this,t):0},t.prototype.createData=function(t){var s=this,c=[],u=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){u.push(t);var e=new qw(t,s.getSplineParams()),i=e.getSubdividedPosition(),r=e.getSubdividedOrientation(),n=e.getSubdividedColor(s.getColorParams()),o=e.getSubdividedPicking(),a=e.getSubdividedSize(s.getRadiusParams());c.push(new TS({position:i.position,normal:r.binormal,dir:r.normal,color:n.color,size:a.size,picking:o.picking},s.getBufferParams()))}},t.getSelection()),{bufferList:c,polymerList:u}},t.prototype.updateData=function(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i<r;++i){var n={},o=new qw(e.polymerList[i],this.getSplineParams());if(t.position){var a=o.getSubdividedPosition(),s=o.getSubdividedOrientation();Object.assign(n,{position:a.position,normal:s.binormal,dir:s.normal})}if(t.radius||t.scale){var c=o.getSubdividedSize(this.getRadiusParams());Object.assign(n,{size:c.size})}if(t.color){var u=o.getSubdividedColor(this.getColorParams());Object.assign(n,{color:u.color})}e.bufferList[i].setAttributes(n)}},t.prototype.setParameters=function(t){var e={};return t&&t.tension&&Object.assign(e,{position:!0}),r.prototype.setParameters.call(this,t,e,!1),this},t}(pw);ed.add("ribbon",CS);var IS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="rocket",this.parameters=Object.assign({localAngle:{type:"integer",max:180,min:0,rebuild:!0},centerDist:{type:"number",precision:1,max:10,min:0,rebuild:!0},ssBorder:{type:"boolean",rebuild:!0},radialSegments:!0,openEnded:!0,disableImpostor:!0},this.parameters),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"sstruc"),e.radiusSize=bl(e.radiusSize,1.5),e.radiusScale=bl(e.radiusScale,1),e.openEnded=bl(e.openEnded,!1),e.useInteriorColor=bl(e.useInteriorColor,!0),this.localAngle=bl(e.localAngle,30),this.centerDist=bl(e.centerDist,2.5),this.ssBorder=bl(e.ssBorder,!1),r.prototype.init.call(this,e)},t.prototype.createData=function(t){var r=this,n=0,o=[],a=[];this.structure.eachPolymer(function(t){if(!(t.residueCount<4||t.isNucleic())){var e=new eb(t),i=e.getAxis(r.localAngle,r.centerDist,r.ssBorder,r.getColorParams(),r.getRadiusParams());n+=i.size.length,o.push(i),a.push(e)}},t.getSelection());var e={begin:new Float32Array(3*n),end:new Float32Array(3*n),size:new Float32Array(n),color:new Float32Array(3*n),picking:{}},i=new Float32Array(n),s=0;return o.forEach(function(t){e.begin.set(t.begin,3*s),e.end.set(t.end,3*s),e.size.set(t.size,s),e.color.set(t.color,3*s),i.set(t.picking.array,s),s+=t.size.length}),n&&(e.picking=new hv(i,t.getStructure())),{bufferList:[new Gw({position1:e.begin,position2:e.end,color:e.color,color2:e.color,radius:e.size,picking:e.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:o,helixbundleList:a,axisData:e}},t.prototype.updateData=function(i,r){var n=this;if((i=i||{}).position)this.build();else{var t={};if(i.color||i.radius){var o=0;r.helixbundleList.forEach(function(t){var e=t.getAxis(n.localAngle,n.centerDist,n.ssBorder,n.getColorParams(),n.getRadiusParams());i.color&&r.axisData.color.set(e.color,3*o),(i.radius||i.scale)&&r.axisData.size.set(e.size,o),o+=e.size.length}),i.color&&Object.assign(t,{color:r.axisData.color,color2:r.axisData.color}),(i.radius||i.scale)&&Object.assign(t,{radius:r.axisData.size})}r.bufferList[0].setAttributes(t)}},t}(pw);ed.add("rocket",IS);var OS=function(r){function t(t,e,i){r.call(this,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})}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.aspectRatio=1,e.tension=bl(e.tension,.5),e.radiusScale=bl(e.radiusScale,5),e.smoothSheet=!1,this.smooth=bl(e.smooth,2),r.prototype.init.call(this,e)},t.prototype.getSpline=function(t){var e=new tb(t);return new qw(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))},t}(Qw);ed.add("rope",OS);var LS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.useInteriorColor=bl(e.useInteriorColor,!0),r.prototype.init.call(this,e)},t.prototype.createData=function(t){return{bufferList:[new Px(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}},t.prototype.updateData=function(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)},t}(pw);function RS(t){return 3*(t.position.length/3-1)*2}ed.add("spacefill",LS);var DS=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,{position:new Float32Array(RS(t)),color:new Float32Array(RS(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(t)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.setAttributes=function(t){var e,i,r,n,o=this.geometry.attributes;if(t.position&&(e=t.position,r=o.position.array,o.position.needsUpdate=!0),t.color&&(i=t.color,n=o.color.array,o.color.needsUpdate=!0),e||i)for(var a,s,c=this.size-1,u=0;u<c;++u)s=(a=3*u)*2,e&&(r[s]=e[a],r[s+1]=e[a+1],r[s+2]=e[a+2],r[s+3]=e[a+3],r[s+4]=e[a+4],r[s+5]=e[a+5]),i&&(n[s]=i[a],n[s+1]=i[a+1],n[s+2]=i[a+2],n[s+3]=i[a+3],n[s+4]=i[a+4],n[s+5]=i[a+5]);else Yp.warn("TraceBuffer.prototype.setAttributes no data")},t}(dy),kS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="trace",this.parameters=Object.assign({subdiv:{type:"integer",max:50,min:1,rebuild:!0},tension:{type:"number",precision:1,max:1,min:.1},smoothSheet:{type:"boolean",rebuild:!0}},this.parameters,{flatShaded:null,side:null,wireframe:null}),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorScheme=bl(e.colorScheme,"chainname"),e.colorScale=bl(e.colorScale,"RdYlBu"),"low"===e.quality?this.subdiv=3:"medium"===e.quality?this.subdiv=6:"high"===e.quality?this.subdiv=12:this.subdiv=bl(e.subdiv,6),this.tension=bl(e.tension,NaN),this.smoothSheet=bl(e.smoothSheet,!1),r.prototype.init.call(this,e)},t.prototype.getSplineParams=function(t){return Object.assign({subdiv:this.subdiv,tension:this.tension,directional:!1,smoothSheet:this.smoothSheet},t)},t.prototype.getAtomRadius=function(t){return t.isTrace()?.1:0},t.prototype.createData=function(t){var n=this,o=[],a=[];return this.structure.eachPolymer(function(t){if(!(t.residueCount<4)){a.push(t);var e=new qw(t,n.getSplineParams()),i=e.getSubdividedPosition(),r=e.getSubdividedColor(n.getColorParams());o.push(new DS(Object.assign({},i,r),n.getBufferParams()))}},t.getSelection()),{bufferList:o,polymerList:a}},t.prototype.updateData=function(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i<r;++i){var n={},o=new qw(e.polymerList[i],this.getSplineParams());if(t.position){var a=o.getSubdividedPosition();Object.assign(n,{position:a.position})}if(t.color){var s=o.getSubdividedColor(this.getColorParams());Object.assign(n,{color:s.color})}e.bufferList[i].setAttributes(n)}},t.prototype.setParameters=function(t){var e={};return t&&t.tension&&Object.assign(e,{position:!0}),r.prototype.setParameters.call(this,t,e,!1),this},t}(pw);ed.add("trace",kS);var BS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="tube",this.parameters=Object.assign({},this.parameters,{aspectRatio:null})}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.aspectRatio=1,e.radiusScale=bl(e.radiusScale,2),"low"===e.quality&&(this.radialSegments=5),r.prototype.init.call(this,e)},t.prototype.getSplineParams=function(){return r.prototype.getSplineParams.call(this,{directional:!1})},t}(Qw);ed.add("tube",BS);var NS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="unitcell",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0},this.parameters,{assembly:null}),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{},i=.5;this.structure.unitcell&&(i=Math.cbrt(this.structure.unitcell.volume)/200),e.radiusSize=bl(e.radiusSize,i),e.colorValue=bl(e.colorValue,"orange"),e.useInteriorColor=bl(e.useInteriorColor,!0),r.prototype.init.call(this,e)},t.prototype.getUnitcellData=function(t){return t.unitcell.getData(t)},t.prototype.create=function(){var t=this.structureView.getStructure();if(t.unitcell){var e=this.getUnitcellData(t);this.sphereBuffer=new Px(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Gw(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}},t.prototype.createData=function(t){},t.prototype.updateData=function(t,e){var i=e.sview.getStructure();if(i.unitcell){var r=this.getUnitcellData(i),n={},o={};t&&!t.position||(Object.assign(n,{position:r.vertex.position}),Object.assign(o,{position1:r.edge.position1,position2:r.edge.position2})),t&&!t.color||(Object.assign(n,{color:r.vertex.color}),Object.assign(o,{color:r.edge.color,color2:r.edge.color2})),t&&!t.radius||(Object.assign(n,{radius:r.vertex.radius}),Object.assign(o,{radius:r.edge.radius})),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(o)}},t}(pw);ed.add("unitcell",NS);var FS=function(r){function t(t,e,i){r.call(this,t,e,i),this.type="validation",this.parameters=Object.assign({},this.parameters,{radiusType:null,radiusSize:null,radiusScale:null}),this.init(i)}return r&&(t.__proto__=r),((t.prototype=Object.create(r&&r.prototype)).constructor=t).prototype.init=function(t){var e=t||{};e.colorValue=bl(e.colorValue,"#f0027f"),e.useInteriorColor=bl(e.useInteriorColor,!0),r.prototype.init.call(this,e)},t.prototype.createData=function(t){if(t.validation){var e=t.validation.getClashData({structure:t,color:this.colorValue});return{bufferList:[new Gw(e,this.getBufferParams({openEnded:!1}))]}}},t}(pw);ed.add("validation",FS);var zS=new ri,US=new ri,jS=new ri,GS=new ri(0,1,0);var VS=Object.assign({radialSegments:60,openEnded:!1},ly),HS=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,{position:new Float32Array(t.position1.length),color:t.color,picking:t.picking},e,function(t){void 0===t&&(t={});var e=new Qs(1,1,bl(t.radialSegments,60),1,bl(t.openEnded,!1));return e.applyMatrix((new ei).makeRotationX(-Math.PI/2)),e}(e)),this.updateNormals=!0,this._position=new Float32Array(t.position1.length),this.setAttributes(t,!0)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return VS},t.prototype.applyPositionTransform=function(t,e,i){US.fromArray(this._position1,i),jS.fromArray(this._position2,i),t.lookAt(US,jS,GS);var r=this._radius[e];zS.set(r,r,US.distanceTo(jS)),t.scale(zS)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.position1&&t.position2&&(Ud(t.position1,t.position2,this._position),this._position1=t.position1,this._position2=t.position2,t.position=this._position),t.radius&&(this._radius=t.radius),i.prototype.setAttributes.call(this,t,e)},Object.defineProperties(t.prototype,e),t}(yx);ad.add("cone",HS);var $S=function(t){void 0===t&&(t=[]),this.geometryList=t};$S.prototype.computeBoundingBox=function(){var e=this;this.boundingBox?this.boundingBox.empty():this.boundingBox=new Pi,this.geometryList.forEach(function(t){t.boundingBox||t.computeBoundingBox(),e.boundingBox.union(t.boundingBox)})};var WS=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},ly),XS=function(t,e){void 0===e&&(e={}),this.group=new ya,this.wireframeGroup=new ya,this.pickingGroup=new ya,this.visible=!0,this.parameters=xl(e,this.defaultParameters),this.splitPosition=new Float32Array(t.position1.length),this.cylinderRadius=new Float32Array(t.radius.length);var i=this.makeAttributes(t),r={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new Gw(i.cylinder,r),this.coneBuffer=new HS(i.cone,r),this.geometry=new $S([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=bl(e.matrix,new ei),this.picking=t.picking},qS={defaultParameters:{configurable:!0},matrix:{configurable:!0},pickable:{configurable:!0}};qS.defaultParameters.get=function(){return WS},qS.matrix.set=function(t){dy.prototype.setMatrix.call(this,t)},qS.matrix.get=function(){return this.group.matrix.clone()},qS.pickable.get=function(){return!!this.picking},XS.prototype.makeAttributes=function(t){void 0===t&&(t={});var e,i,r=this.splitPosition,n=this.cylinderRadius,o=this.parameters.aspectRatio,a={},s={};if(t.radius){for(e=0,i=n.length;e<i;++e)n[e]=t.radius[e]/o;a.radius=n,s.radius=t.radius}if(t.position1&&t.position2){var c=new ri,u=new ri,h=new ri,l=new ri;for(e=0,i=r.length;e<i;e+=3){c.fromArray(t.position1,e),u.fromArray(t.position2,e),h.subVectors(c,u);var p=h.length(),d=n[e/3]*o*2,f=Math.min(p,d);h.setLength(f),l.copy(u).add(h),l.toArray(r,e)}a.position1=t.position1,a.position2=r,s.position1=r,s.position2=t.position2}return t.color&&(a.color=t.color,a.color2=t.color,s.color=t.color),{cylinder:a,cone:s}},XS.prototype.getMesh=function(){return(new ya).add(this.cylinderBuffer.getMesh(),this.coneBuffer.getMesh())},XS.prototype.getWireframeMesh=function(){return(new ya).add(this.cylinderBuffer.getWireframeMesh(),this.coneBuffer.getWireframeMesh())},XS.prototype.getPickingMesh=function(){return(new ya).add(this.cylinderBuffer.getPickingMesh(),this.coneBuffer.getPickingMesh())},XS.prototype.setAttributes=function(t){void 0===t&&(t={});var e=this.makeAttributes(t);this.cylinderBuffer.setAttributes(e.cylinder),this.coneBuffer.setAttributes(e.cone)},XS.prototype.setParameters=function(t){void 0===t&&(t={}),(t=Object.assign({},t))&&void 0!==t.matrix&&(this.matrix=t.matrix),delete t.matrix,t&&void 0!==t.wireframe&&(this.parameters.wireframe=t.wireframe,this.setVisibility(this.visible)),this.cylinderBuffer.setParameters(t),this.coneBuffer.setParameters(t)},XS.prototype.setVisibility=function(t){dy.prototype.setVisibility.call(this,t)},XS.prototype.dispose=function(){this.cylinderBuffer.dispose(),this.coneBuffer.dispose()},Object.defineProperties(XS.prototype,qS),ad.add("arrow",XS);var YS=new ri,ZS=new ri,KS=new ri,JS=new ri(0,0,0),QS=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e,new Xr(1,1,1)),this.updateNormals=!0,this.setAttributes(t,!0)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.applyPositionTransform=function(t,e,i){ZS.fromArray(this._heightAxis,i),KS.fromArray(this._depthAxis,i),t.lookAt(JS,ZS,KS),YS.set(this._size[e],KS.length(),ZS.length()),t.scale(YS)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.size&&(this._size=t.size),t.heightAxis&&(this._heightAxis=t.heightAxis),t.depthAxis&&(this._depthAxis=t.depthAxis),i.prototype.setAttributes.call(this,t,e)},t}(yx);ad.add("box",QS);var tA=new ri,eA=new ri,iA=new ri,rA=new ri(0,0,0),nA=Object.assign({sphereDetail:2},ly),oA=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e,new es(1,bl(e.sphereDetail,2))),this.updateNormals=!0,this.setAttributes(t,!0)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return nA},t.prototype.applyPositionTransform=function(t,e,i){eA.fromArray(this._majorAxis,i),iA.fromArray(this._minorAxis,i),t.lookAt(rA,eA,iA),tA.set(this._radius[e],iA.length(),eA.length()),t.scale(tA)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.radius&&(this._radius=t.radius),t.majorAxis&&(this._majorAxis=t.majorAxis),t.minorAxis&&(this._minorAxis=t.minorAxis),i.prototype.setAttributes.call(this,t,e)},Object.defineProperties(t.prototype,e),t}(yx);ad.add("ellipsoid",oA);var aA=new ri,sA=new ri,cA=new ri,uA=new ri(0,0,0),hA=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e,new Qa(1,0)),this.updateNormals=!0,this.setAttributes(t,!0)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.applyPositionTransform=function(t,e,i){sA.fromArray(this._heightAxis,i),cA.fromArray(this._depthAxis,i),t.lookAt(uA,sA,cA),aA.set(this._size[e],cA.length(),sA.length()),t.scale(aA)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.size&&(this._size=t.size),t.heightAxis&&(this._heightAxis=t.heightAxis),t.depthAxis&&(this._depthAxis=t.depthAxis),i.prototype.setAttributes.call(this,t,e)},t}(yx);ad.add("octahedron",hA);var lA=new ri,pA=new ri,dA=new ri,fA=new ri(0,0,0),mA=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e,new Ka(1,0)),this.updateNormals=!0,this.setAttributes(t,!0)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).prototype.applyPositionTransform=function(t,e,i){pA.fromArray(this._heightAxis,i),dA.fromArray(this._depthAxis,i),t.lookAt(fA,pA,dA),lA.set(this._size[e],dA.length(),pA.length()),t.scale(lA)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.size&&(this._size=t.size),t.heightAxis&&(this._heightAxis=t.heightAxis),t.depthAxis&&(this._depthAxis=t.depthAxis),i.prototype.setAttributes.call(this,t,e)},t}(yx);ad.add("tetrahedron",mA);var gA=new ri,vA=new ri,yA=new ri,bA=new ri(0,0,0),xA=Object.assign({radiusRatio:.2,radialSegments:16,tubularSegments:32},ly),_A=function(i){function t(t,e){void 0===e&&(e={}),i.call(this,t,e,new us(1,bl(e.radiusRatio,.2),bl(e.radialSegments,16),bl(e.tubularSegments,32))),this.updateNormals=!0,this.setAttributes(t,!0)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={defaultParameters:{configurable:!0}};return e.defaultParameters.get=function(){return xA},t.prototype.applyPositionTransform=function(t,e,i){vA.fromArray(this._majorAxis,i),yA.fromArray(this._minorAxis,i),t.lookAt(bA,vA,yA);var r=this._radius[e];gA.set(r,r,r),t.scale(gA)},t.prototype.setAttributes=function(t,e){void 0===t&&(t={}),t.radius&&(this._radius=t.radius),t.majorAxis&&(this._majorAxis=t.majorAxis),t.minorAxis&&(this._minorAxis=t.minorAxis),i.prototype.setAttributes.call(this,t,e)},Object.defineProperties(t.prototype,e),t}(yx);ad.add("torus",_A);var wA=function(t,e){var i=e||{};this.streamer=t,this.name=bl(i.name,""),this.path=bl(i.path,"")},SA={type:{configurable:!0},__objName:{configurable:!0},isBinary:{configurable:!0},isJson:{configurable:!0},isXml:{configurable:!0}};SA.type.get=function(){return""},SA.__objName.get=function(){return""},SA.isBinary.get=function(){return!1},SA.isJson.get=function(){return!1},SA.isXml.get=function(){return!1},wA.prototype.parse=function(){var t=this;return this.streamer.read().then(function(){return t._beforeParse(),t._parse(),t._afterParse(),t[t.__objName]})},wA.prototype._parse=function(){},wA.prototype._beforeParse=function(){},wA.prototype._afterParse=function(){de.Debug&&Yp.log(this[this.__objName])},Object.defineProperties(wA.prototype,SA);var AA=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.firstModelOnly=bl(i.firstModelOnly,!1),this.asTrajectory=bl(i.asTrajectory,!1),this.cAlphaOnly=bl(i.cAlphaOnly,!1),this.structure=new cx(this.name,this.path),this.structureBuilder=new yb(this.structure)}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0}};return e.type.get=function(){return"structure"},e.__objName.get=function(){return"structure"},Object.defineProperties(t.prototype,e),t}(wA);var MA=function(e,i,t,r,n){void 0===t&&(t=""),void 0===n&&(n=[]),this.structure=e,this.index=i,this.description=t,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=n).forEach(function(t){e.chainStore.entityIndex[t]=i})},EA={type:{configurable:!0}};EA.type.get=function(){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)},MA.prototype.getEntityType=function(){return this.entityType},MA.prototype.isPolymer=function(){return 1===this.entityType},MA.prototype.isNonPolymer=function(){return 2===this.entityType},MA.prototype.isMacrolide=function(){return 3===this.entityType},MA.prototype.isWater=function(){return 4===this.entityType},MA.prototype.eachChain=function(e){var i=this.structure.getChainProxy();this.chainIndexList.forEach(function(t){i.index=t,e(i)})},Object.defineProperties(MA.prototype,EA);var PA={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"},TA=function(t){void 0===t&&(t=PA),this.cartToFrac=new ei,this.fracToCart=new ei,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;var e=Gl(this.alpha),i=Gl(this.beta),r=Gl(this.gamma),n=Math.cos(e),o=Math.cos(i),a=Math.cos(r),s=Math.sin(i),c=Math.sin(r);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){var u=this.a*this.b*c/this.volume,h=(o*a-n)/(s*c);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*c,0,0,this.c*o,-this.c*s*h,1/u,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(t.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)};TA.prototype.getPosition=function(t){var r=new Float32Array(24);if(t.unitcell){var n=t.unitcell,o=t.center.clone().applyMatrix4(n.cartToFrac).floor(),a=new ri,s=0,e=function(t,e,i){a.set(t,e,i).add(o).applyMatrix4(n.fracToCart).toArray(r,s),s+=3};e(0,0,0),e(1,0,0),e(0,1,0),e(0,0,1),e(1,1,0),e(1,0,1),e(0,1,1),e(1,1,1)}return r},TA.prototype.getCenter=function(t){return function(t,e){void 0===e&&(e=new ri);for(var i=t.length,r=0;r<i;r+=3)e.x+=t[r],e.y+=t[r+1],e.z+=t[r+2];return e.divideScalar(i/3),e}(this.getPosition(t))},TA.prototype.getData=function(t,e){void 0===e&&(e={});var i=bl(e.colorValue,"orange"),r=bl(e.radius,Math.cbrt(this.volume)/200),n=new ki(i),o=new ri,a=this.getPosition(t),s=Vd(8,n.r,n.g,n.b),c=Gd(8,r),u=new Float32Array(36),h=new Float32Array(36),l=Vd(12,n.r,n.g,n.b),p=Gd(12,r),d=0;function f(t,e){o.fromArray(a,3*t).toArray(u,d),o.fromArray(a,3*e).toArray(h,d),d+=3}f(0,1),f(0,2),f(0,3),f(1,4),f(1,5),f(2,6),f(3,5),f(4,7),f(5,7),f(2,4),f(7,6),f(3,6);var m=new Ev(this,t);return{vertex:{position:a,color:s,radius:c,picking:m},edge:{position1:u,position2:h,color:l,color2:l,radius:p,picking:m}}};var CA={1:"h",2:"h",3:"i",4:"h",5:"g",6:"h",7:"h",8:"h",9:"h",10:"h",0:"h"},IA=["DAL","DAR","DSG","DAS","DCY","DGL","DGN","DHI","DIL","DLE","DLY","MED","DPN","DPR","DSN","DTH","DTR","DTY","DVA","DNE"],OA=["MOL_ID","MOLECULE","CHAIN","FRAGMENT","SYNONYM","EC","ENGINEERED","MUTATION","OTHER_DETAILS"],LA=/\s+/;function RA(t,e,i){var r=""+t;return e&&(r+=":"+e),i&&(r+="^"+i),r}var DA=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.hex=bl(i.hex,!1)}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0}};return e.type.get=function(){return"pdb"},t.prototype._parse=function(){de.Debug&&Yp.time("PdbParser._parse "+this.name);var it=!1,t=this.streamer.peekLines(1)[0],e=t.substr(62,4),i=t.substr(72,4);e===i&&i.trim()&&(it=!0);var rt,nt,ot,at,st,ct,ut,ht,lt,pt,dt,ft,mt,gt,vt,yt,bt,xt,_t,wt,St,At,Mt,Et,Pt,Tt,Ct,It,Ot,Lt,Rt,Dt,kt,Bt="pqr"===this.type,Nt="pdbqt"===this.type,Ft=this.structure,zt=this.structureBuilder,Ut=this.hex,jt=10,Gt=10,Vt=this.firstModelOnly,Ht=this.asTrajectory,$t=this.cAlphaOnly,Wt=Ft.frames,Xt=Ft.boxes,qt=!1,Yt=Ft.biomolDict,Zt={},Kt={},Jt={},Qt=[],te={},ee={},ie={},re={},r={helices:[],sheets:[]},ne=r.helices,oe=r.sheets,ae=Ft.atomMap,se=Ft.atomStore;se.resize(Math.round(this.streamer.data.length/80)),(Bt||Nt)&&se.addField("partialCharge",1,"float32"),Bt&&se.addField("radius",1,"float32");var ce=Ft.getAtomProxy(),ue=Ft.getAtomProxy(),he=0,le=0,pe=!0;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r,n=t;n<e;++n)if(ct=i[n],"ATOM  "===(ut=ct.substr(0,6))||"HETATM"===ut){if(pe&&(Ht?(qt?(rt=new Float32Array(3*se.count),Wt.push(rt)):rt=[],nt=0):Vt||(Zt={}),Ct=(Tt=1).toString(),pe=!(It=!0)),Vt&&0<le)continue;var o=void 0,a=void 0,s=void 0,c=void 0,u=void 0;if(Bt){if(u=10===(c=ct.split(LA)).length?1:0,gt=c[2],$t&&"CA"!==gt)continue;o=parseFloat(c[6-u]),a=parseFloat(c[7-u]),s=parseFloat(c[8-u])}else{if(gt=ct.substr(12,4).trim(),$t&&"CA"!==gt)continue;o=parseFloat(ct.substr(30,8)),a=parseFloat(ct.substr(38,8)),s=parseFloat(ct.substr(46,8))}if(Ht){var h=3*nt;if(rt[h+0]=o,rt[h+1]=a,rt[h+2]=s,nt+=1,qt)continue}var l=void 0;Bt?(ht=parseInt(c[1]),l="",vt="H"===ct[0]?1:0,lt=u?"":c[4],pt=parseInt(c[5-u]),mt="",dt=c[3],bt="",ft=1):(ht=parseInt(ct.substr(6,5),jt),Ut&&99999===ht&&(jt=16),vt="H"===ct[0]?1:0,lt=ct[21].trim(),pt=parseInt(ct.substr(22,4),Gt),Ut&&9999===pt&&(Gt=16),mt=ct[26].trim(),dt=ct.substr(17,4).trim()||"MOL",yt=parseFloat(ct.substr(60,6)),bt=ct[16].trim(),ft=parseFloat(ct.substr(54,6)),it||(Nt?l=ct.substr(12,2).trim():(l=ct.substr(76,2).trim(),lt||(lt=ct.substr(72,4).trim())))),se.growIfFull(),se.atomTypeId[he]=ae.add(gt,l),se.x[he]=o,se.y[he]=a,se.z[he]=s,se.serial[he]=ht,se.altloc[he]=bt.charCodeAt(0),se.occupancy[he]=isNaN(ft)?0:ft,Bt?(se.partialCharge[he]=parseFloat(c[9-u]),se.radius[he]=parseFloat(c[10-u])):(se.bfactor[he]=isNaN(yt)?0:yt,Nt&&(se.partialCharge[he]=parseFloat(ct.substr(70,6))));var p=RA(pt,lt,mt);!vt||ee[p]||IA.includes(dt)?It||Ot===lt||(Ct=(Tt+=1).toString()):Ot===lt&&Rt===dt&&(Pg.includes(dt)||Lt===pt&&Dt===mt)||(Ct=(Tt+=1).toString(),Lt=pt,Rt=dt,Dt=mt),zt.addAtom(le,lt,Ct,dt,pt,vt,void 0,mt),Zt[ht]=he,he+=1,It=!1,Ot=lt}else if("CONECT"===ut){var d=Zt[parseInt(ct.substr(6,5))],f=[11,16,21,26],m={};if(void 0===d)continue;for(var g=0;g<4;++g){var v=parseInt(ct.substr(f[g],5));if(!Number.isNaN(v)&&void 0!==(v=Zt[v]))if(d<v?(ce.index=d,ue.index=v):(ce.index=v,ue.index=d),void 0!==m[v])Ft.bondStore.bondOrder[m[v]]+=1;else{var y=ce.index+"|"+ue.index;void 0===Jt[y]&&(Jt[y]=!0,m[v]=Ft.bondStore.count,Ft.bondStore.addBond(ce,ue,1))}}}else if("HELIX "===ut){xt=ct[19].trim(),_t=parseInt(ct.substr(21,4)),wt=ct[25].trim(),St=ct[31].trim(),At=parseInt(ct.substr(33,4)),Mt=ct[37].trim();var b=parseInt(ct.substr(39,1));b=(CA[b]||CA[0]).charCodeAt(0),ne.push([xt,_t,wt,St,At,Mt,b])}else if("SHEET "===ut)xt=ct[21].trim(),_t=parseInt(ct.substr(22,4)),wt=ct[26].trim(),St=ct[32].trim(),At=parseInt(ct.substr(33,4)),Mt=ct[37].trim(),oe.push([xt,_t,wt,St,At,Mt]);else if("HETNAM"===ut)te[ct.substr(11,3)]=ct.substr(15).trim();else if("SEQRES"===ut){var x=ct[11].trim();x!==kt&&(re[x]=[],kt=x),(r=re[x]).push.apply(r,ct.substr(19).trim().split(LA))}else if("MODRES"===ut){var _=ct.substr(12,3).trim(),w=ct[16].trim(),S=ct[22].trim(),A=parseInt(ct.substr(18,4).trim()),M=RA(A,w,S);ee[M]={resname:_,chainname:w,inscode:S,resno:A}}else if("COMPND"===ut){var E=ct.substr(10,70).trim(),P=E.indexOf(":"),T=E.substring(0,P),C=void 0;OA.includes(T)?(Pt=T,C=E.substring(P+2)):C=E,C=C.replace(/;$/,""),"MOL_ID"===Pt?(Et={chainList:[],name:""},Qt.push(Et)):"MOLECULE"===Pt?(Et.name&&(Et.name+=" "),Et.name+=C):"CHAIN"===Pt&&Array.prototype.push.apply(Et.chainList,C.split(/\s*,\s*/))}else if(ct.startsWith("TER")){var I=Ft.getChainProxy(Ft.chainStore.count-1);ie[I.chainname]=I.index,Ct=(Tt+=1).toString(),It=!0}else if("REMARK"===ut&&"350"===ct.substr(7,3)){if("BIOMOLECULE:"===ct.substr(11,12)){var O=ct.substr(23).trim();/^(0|[1-9][0-9]*)$/.test(O)&&(O="BU"+O),ot=new fb(O),Yt[O]=ot}else if("BIOMT"===ct.substr(13,5)){var L=ct.split(/\s+/),R=parseInt(ct[18])-1;0===R&&(st=new ei,at.matrixList.push(st));var D=st.elements;D[0+R]=parseFloat(L[4]),D[4+R]=parseFloat(L[5]),D[8+R]=parseFloat(L[6]),D[12+R]=parseFloat(L[7])}else if("APPLY THE FOLLOWING TO CHAINS:"===ct.substr(11,30)||"                   AND CHAINS:"===ct.substr(11,30)){"APPLY"===ct.substr(11,5)&&(at=ot.addPart());for(var k=ct.substr(41,30).split(","),B=0,N=k.length;B<N;++B){var F=k[B].trim();F&&at.chainList.push(F)}}}else if("HEADER"===ut)Ft.id=ct.substr(62,4);else if("TITLE "===ut)Ft.title+=(Ft.title?" ":"")+ct.substr(10,70).trim();else if("MODEL "===ut)pe=!0;else if("ENDMDL"===ut||"END"===ct.trim()){if(pe)continue;Ht&&!qt&&(Wt.push(new Float32Array(rt)),qt=!0),le+=1,pe=!0}else if("MTRIX"===ct.substr(0,5)){if("1"===ct[59])continue;ot&&"NCS"===ot.name||(ot=new fb("NCS"),Yt.NCS=ot,at=ot.addPart());var z=ct.split(/\s+/),U=parseInt(ct[5])-1;0===U&&(st=new ei,at.matrixList.push(st));var j=st.elements;j[0+U]=parseFloat(z[2]),j[4+U]=parseFloat(z[3]),j[8+U]=parseFloat(z[4]),j[12+U]=parseFloat(z[5])}else if("ORIGX"===ct.substr(0,5)){Kt.origx||(Kt.origx=new ei);var G=ct.split(/\s+/),V=parseInt(ct[5])-1,H=Kt.origx.elements;H[0+V]=parseFloat(G[1]),H[4+V]=parseFloat(G[2]),H[8+V]=parseFloat(G[3]),H[12+V]=parseFloat(G[4])}else if("SCALE"===ct.substr(0,5)){Kt.scale||(Kt.scale=new ei);var $=ct.split(/\s+/),W=parseInt(ct[5])-1,X=Kt.scale.elements;X[0+W]=parseFloat($[1]),X[4+W]=parseFloat($[2]),X[8+W]=parseFloat($[3]),X[12+W]=parseFloat($[4])}else if("CRYST1"===ut){var q=parseFloat(ct.substr(6,9)),Y=parseFloat(ct.substr(15,9)),Z=parseFloat(ct.substr(24,9)),K=parseFloat(ct.substr(33,7)),J=parseFloat(ct.substr(40,7)),Q=parseFloat(ct.substr(47,7)),tt=ct.substr(55,11).trim(),et=new Float32Array(9);et[0]=q,et[4]=Y,et[8]=Z,Xt.push(et),0===le&&(Kt.a=q,Kt.b=Y,Kt.c=Z,Kt.alpha=K,Kt.beta=J,Kt.gamma=Q,Kt.spacegroup=tt)}}(0,t.length,t)}),zt.finalize();var n=Qt.length;if(n){Ft.eachChain(function(t){t.entityIndex=n}),Qt.forEach(function(t,e){var i=t.chainList.map(function(t){return ie[t]});Ft.entityList.push(new MA(Ft,e,t.name,"polymer",i))});var o=Qt.length,a=Ft.getResidueProxy(),s={};Ft.eachChain(function(t){t.entityIndex===n&&(a.index=t.residueOffset,s[a.resname]||(s[a.resname]=[]),s[a.resname].push(t.index))}),Object.keys(s).forEach(function(t){var e=s[t],i="non-polymer",r=te[t]||t;Pg.includes(t)&&(i=r="water"),Ft.entityList.push(new MA(Ft,o,r,i,e)),o+=1})}void 0!==Kt.a?Ft.unitcell=new TA(Kt):Ft.unitcell=void 0,(ne.length||oe.length)&&bb(Ft,r),Ft.finalizeAtoms(),it||Ab(Ft),Mb(Ft),Ft.finalizeBonds(),ne.length||oe.length||_b(Ft),Ib(Ft),de.Debug&&Yp.timeEnd("PdbParser._parse "+this.name)},Object.defineProperties(t.prototype,e),t}(AA);id.add("pdb",DA),id.add("pdb1",DA),id.add("ent",DA);var kA=/\s+/,BA=/'((?:(?!'\s).)*)'|"((?:(?!"\s).)*)"|(\S+)/g,NA=/"/g,FA=/^['"]+|['"]+$/g;function zA(t){return!t||t[0]!==t[t.length-1]||"'"!==t[0]&&'"'!==t[0]?t:t.substring(1,t.length-1)}function UA(e,t){Array.isArray(e[t])||Object.keys(e).forEach(function(t){e[t]=[e[t]]})}function jA(t){return"?"!==t}function GA(t,e){return jA(t)?t:e}function VA(t){switch(t.toLowerCase()){case"?":case"sing":return 1;case"doub":return 2;case"trip":return 3;case"quad":return 4}return 0}var HA=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"cif"},e.prototype._parse=function(){Yp.time("CifParser._parse "+this.name);var R,D,k,B,N,F,z,U,j,G,V,H,$,W,X,q,Y,Z,K,J,Q,tt=this.structure,et=this.structureBuilder,it=this.firstModelOnly,rt=this.asTrajectory,nt=this.cAlphaOnly,ot=tt.frames,at={},st={},ct={},ut=!1,ht=null,lt=!1,pt=!1,dt=!1,ft=[],mt=null,gt=null,vt=null,yt=null,bt=[],xt=tt.atomMap,_t=tt.atomStore;_t.resize(this.streamer.data.length/100);var wt,St=0,At=0;if(this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r)if(k=i[r],((B=k.trim())||ut||pt)&&"#"!==B[0])if("data_"===B.substring(0,5))at.data=B.substring(5).trim();else if(";"===B[0])ut?(pt?(mt===ft.length&&(mt=0),ft[mt].push(ht),mt+=1):!1===vt?at[gt]=ht:at[gt][vt]=ht,ut=!1,ht=null):(ut=!0,ht=B.substring(1));else if("loop_"===B)dt=pt=!0,ft.length=0,bt.length=0,mt=0;else if("_"===B[0]){var n,o,a;if(pt&&!dt&&(pt=!1),pt)o=(n=B.split("."))[0].substring(1),a=n[1],1===n.length?(a=!1,at[o]||(at[o]=[]),ft.push(at[o])):(at[o]||(at[o]={}),at[o][a]?de.Debug&&Yp.warn(o,a,"already exists"):(at[o][a]=[],ft.push(at[o][a]),bt.push(a))),gt=o,vt=a,yt=!0;else{var s=B.match(BA),c=s[0],u=s[1];o=(n=c.split("."))[0].substring(1),a=n[1],1===n.length?(a=!1,at[o]=u):(at[o]||(at[o]={}),at[o][a]?de.Debug&&Yp.warn(o,a,"already exists"):at[o][a]=u),u||(lt=!0),gt=o,vt=a}}else if(ut)ht+=k;else if(pt){if(!B)continue;if("atom_site"===gt){var h=B.split(kA);yt&&(N=bt.indexOf("auth_asym_id"),F=bt.indexOf("auth_seq_id"),z=bt.indexOf("label_atom_id"),U=bt.indexOf("label_comp_id"),j=bt.indexOf("label_asym_id"),G=bt.indexOf("label_entity_id"),V=bt.indexOf("label_alt_id"),Y=bt.indexOf("Cartn_x"),Z=bt.indexOf("Cartn_y"),K=bt.indexOf("Cartn_z"),$=bt.indexOf("id"),W=bt.indexOf("type_symbol"),H=bt.indexOf("group_PDB"),J=bt.indexOf("B_iso_or_equiv"),X=bt.indexOf("pdbx_PDB_model_num"),q=bt.indexOf("pdbx_PDB_ins_code"),Q=bt.indexOf("occupancy"),yt=!1,wt=parseInt(h[X]),rt&&(R=[],D=0));var l=parseInt(h[X]);if(wt!==l&&(rt&&(0===At&&ot.push(new Float32Array(R)),R=new Float32Array(3*_t.count),ot.push(R),D=0),At+=1),wt=l,it&&0<At)continue;var p=h[z].replace(NA,"");if(nt&&"CA"!==p)continue;var d=parseFloat(h[Y]),f=parseFloat(h[Z]),m=parseFloat(h[K]);if(rt){var g=3*D;if(R[g+0]=d,R[g+1]=f,R[g+2]=m,D+=1,0<At)continue}var v=h[U],y=parseInt(h[F]),b=h[q];b="?"===b?"":b;var x=h[N],_=h[j],w="H"===h[H][0]?1:0,S=h[W],A=parseFloat(h[J]),M=parseFloat(h[Q]),E=h[V];if(E="."===E?"":E,_t.growIfFull(),_t.atomTypeId[St]=xt.add(p,S),_t.x[St]=d,_t.y[St]=f,_t.z[St]=m,_t.serial[St]=parseInt(h[$]),_t.bfactor[St]=isNaN(A)?0:A,_t.occupancy[St]=isNaN(M)?0:M,_t.altloc[St]=E.charCodeAt(0),et.addAtom(At,x,_,v,y,w,void 0,b),de.Debug){var P=st[_];void 0!==P&&P!==x&&de.Debug&&Yp.warn(P,x)}st[_]=x;var T=h[G];ct[T]||(ct[T]=new Set),ct[T].add(tt.chainStore.count-1),St+=1}else{var C=B.match(BA),I=C.length;mt===ft.length&&(mt=0);for(var O=0;O<I;++O)ft[mt+O].push(C[O]);mt+=I}dt=!1}else if("'"===B[0]&&"'"===B[B.length-1]){var L=B.substring(1,B.length-1);!1===vt?at[gt]=L:at[gt][vt]=L}else lt?!1===vt?at[gt]=B:at[gt][vt]=B:de.Debug&&Yp.log("CifParser._parse: unknown state",B);else lt=pt=ut=!1,ft.length=0,yt=vt=gt=mt=null,bt.length=0}(0,t.length,t)}),at.chem_comp&&at.chem_comp_atom)!function(t,e,i){var r,n,o=e.atomStore,a=e.atomMap,s=t.chem_comp,c=t.chem_comp_atom,u=t.chem_comp_bond;s&&(s.name&&(e.title=s.name.trim().replace(FA,"")),s.id&&(e.id=s.id.trim().replace(FA,"")));var h={};if(c){var l,p,d,f;for(UA(c,"comp_id"),n=c.comp_id.length,r=0;r<n;++r)o.growIfFull(),l=c.atom_id[r].replace(NA,""),p=c.type_symbol[r],h[l]=r,o.atomTypeId[r]=a.add(l,p),o.x[r]=c.model_Cartn_x[r],o.y[r]=c.model_Cartn_y[r],o.z[r]=c.model_Cartn_z[r],o.serial[r]=r,d=c.pdbx_component_comp_id[r],f=c.pdbx_residue_numbering?c.pdbx_residue_numbering[r]:1,i.addAtom(0,"","",d,f,!0);for(r=0;r<n;++r){var m=r+n;o.growIfFull(),l=c.atom_id[r].replace(NA,""),p=c.type_symbol[r],o.atomTypeId[m]=a.add(l,p),o.x[m]=c.pdbx_model_Cartn_x_ideal[r],o.y[m]=c.pdbx_model_Cartn_y_ideal[r],o.z[m]=c.pdbx_model_Cartn_z_ideal[r],o.serial[m]=m,d=c.pdbx_component_comp_id[r],f=c.pdbx_residue_numbering?c.pdbx_residue_numbering[r]:1,i.addAtom(1,"","",d,f,!0)}}if(c&&u){var g,v,y;UA(u,"comp_id"),n=u.comp_id.length;var b=c.comp_id.length,x=e.getAtomProxy(),_=e.getAtomProxy();for(r=0;r<n;++r)g=u.atom_id_1[r].replace(NA,""),v=u.atom_id_2[r].replace(NA,""),y=VA(u.value_order[r]),x.index=h[g],_.index=h[v],e.bondStore.growIfFull(),e.bondStore.addBond(x,_,y),x.index+=b,_.index+=b,e.bondStore.growIfFull(),e.bondStore.addBond(x,_,y)}}(at,tt,et),et.finalize(),tt.finalizeAtoms(),tt.finalizeBonds(),Db(tt);else if(at.atom_site_type_symbol&&at.atom_site_label&&at.atom_site_fract_x)!function(t,e,c){var u=e.atomStore,i=e.atomMap;t.data&&(e.id=t.data,e.name=t.data),e.unitcell=new TA({a:parseFloat(t.cell_length_a),b:parseFloat(t.cell_length_b),c:parseFloat(t.cell_length_c),alpha:parseFloat(t.cell_angle_alpha),beta:parseFloat(t.cell_angle_beta),gamma:parseFloat(t.cell_angle_gamma),spacegroup:zA(t["symmetry_space_group_name_H-M"])});for(var h=new ri,r=new ri,l=t.atom_site_type_symbol.length,n=0;n<l;++n){u.growIfFull();var o=t.atom_site_label[n],a=t.atom_site_type_symbol[n];u.atomTypeId[n]=i.add(o,a),h.set(t.atom_site_fract_x[n],t.atom_site_fract_y[n],t.atom_site_fract_z[n]),h.applyMatrix4(e.unitcell.fracToCart),r.add(h),u.x[n]=h.x,u.y[n]=h.y,u.z[n]=h.z,t.atom_site_occupancy&&(u.occupancy[n]=parseFloat(t.atom_site_occupancy[n])),u.serial[n]=n,c.addAtom(0,"","","HET",1,!0)}r.divideScalar(l),e.center=r,Ib(e);var p=new ri,d=new ri,f=e.biomolDict.SUPERCELL.partList[0].matrixList,m=l;function g(t){return i.get(u.atomTypeId[t]).covalent}for(var v=new ei,s=function(a){var s=g(a);h.set(u.x[a],u.y[a],u.z[a]),f.forEach(function(t){if(!v.equals(t)){p.copy(h),p.applyMatrix4(t);for(var e=0;e<l;++e){d.set(u.x[e],u.y[e],u.z[e]);var i=p.distanceToSquared(d),r=g(e)+s,n=r+.3,o=r-.5;if(i<n*n&&o*o<i)return u.growIfFull(),u.atomTypeId[m]=u.atomTypeId[a],u.x[m]=p.x,u.y[m]=p.y,u.z[m]=p.z,u.occupancy[m]=u.occupancy[a],u.serial[m]=m,u.altloc[m]="A".charCodeAt(0),c.addAtom(0,"","","HET",1,!0),void(m+=1)}}})},y=0;y<l;++y)s(y)}(at,tt,et),et.finalize(),tt.finalizeAtoms(),Mb(tt),tt.finalizeBonds();else{var t=function(t,e,i){var r,n,o,a,s=[],c=[],u=t.struct_conf;if(u)for(UA(u,"id"),r=0,n=u.beg_auth_seq_id.length;r<n;++r){var h=parseInt(u.pdbx_PDB_helix_class[r]);Number.isNaN(h)||(o=u.pdbx_beg_PDB_ins_code[r],a=u.pdbx_end_PDB_ins_code[r],s.push([i[u.beg_label_asym_id[r]],parseInt(u.beg_auth_seq_id[r]),GA(o,""),i[u.end_label_asym_id[r]],parseInt(u.end_auth_seq_id[r]),GA(a,""),(CA[h]||CA[0]).charCodeAt(0)]))}var l=t.struct_sheet_range;if(l)for(UA(l,"id"),r=0,n=l.beg_auth_seq_id.length;r<n;++r)o=l.pdbx_beg_PDB_ins_code[r],a=l.pdbx_end_PDB_ins_code[r],c.push([i[l.beg_label_asym_id[r]],parseInt(l.beg_auth_seq_id[r]),GA(o,""),i[l.end_label_asym_id[r]],parseInt(l.end_auth_seq_id[r]),GA(a,"")]);return!(!u&&!l)&&{helices:s,sheets:c}}(at,0,st);if(function(t,e,p){var o={},d=e.biomolDict;if(t.pdbx_struct_oper_list){var n=t.pdbx_struct_oper_list;UA(n,"id"),n.id.forEach(function(t,e){var i=new ei,r=i.elements;r[0]=parseFloat(n["matrix[1][1]"][e]),r[1]=parseFloat(n["matrix[1][2]"][e]),r[2]=parseFloat(n["matrix[1][3]"][e]),r[4]=parseFloat(n["matrix[2][1]"][e]),r[5]=parseFloat(n["matrix[2][2]"][e]),r[6]=parseFloat(n["matrix[2][3]"][e]),r[8]=parseFloat(n["matrix[3][1]"][e]),r[9]=parseFloat(n["matrix[3][2]"][e]),r[10]=parseFloat(n["matrix[3][3]"][e]),r[3]=parseFloat(n["vector[1]"][e]),r[7]=parseFloat(n["vector[2]"][e]),r[11]=parseFloat(n["vector[3]"][e]),i.transpose(),o[t]=i})}if(t.pdbx_struct_assembly_gen){var f=t.pdbx_struct_assembly_gen;UA(f,"assembly_id");var m=function(t){var n={};return t.replace(/[()']/g,"").split(",").forEach(function(t){if(t.includes("-"))for(var e=t.split("-"),i=parseInt(e[0]),r=parseInt(e[1]);i<=r;++i)n[i]=o[i];else n[t]=o[t]}),n};f.assembly_id.forEach(function(t,e){var r={},i=f.oper_expression[e].replace(/['"]\(|['"]/g,"");if(i.includes(")(")||0<i.indexOf("(")){i=i.split("(");var n=m(i[0]),o=m(i[1]);Object.keys(n).forEach(function(i){Object.keys(o).forEach(function(t){var e=new ei;e.multiplyMatrices(n[i],o[t]),r[i+"x"+t]=e})})}else r=m(i);var a=[];for(var s in r)a.push(r[s]);var c=t;/^(0|[1-9][0-9]*)$/.test(c)&&(c="BU"+c);for(var u=f.asym_id_list[e].split(","),h=0,l=u.length;h<l;++h)u[h]=p[u[h]];void 0===d[c]&&(d[c]=new fb(c)),d[c].addPart(a,u)})}if(t.struct_ncs_oper){var a=t.struct_ncs_oper;UA(a,"id"),d.NCS=new fb("NCS");var s=d.NCS.addPart();a.id.forEach(function(t,e){if("given"!==a.code[e]){var i=new ei,r=i.elements;r[0]=parseFloat(a["matrix[1][1]"][e]),r[1]=parseFloat(a["matrix[1][2]"][e]),r[2]=parseFloat(a["matrix[1][3]"][e]),r[4]=parseFloat(a["matrix[2][1]"][e]),r[5]=parseFloat(a["matrix[2][2]"][e]),r[6]=parseFloat(a["matrix[2][3]"][e]),r[8]=parseFloat(a["matrix[3][1]"][e]),r[9]=parseFloat(a["matrix[3][2]"][e]),r[10]=parseFloat(a["matrix[3][3]"][e]),r[3]=parseFloat(a["vector[1]"][e]),r[7]=parseFloat(a["vector[2]"][e]),r[11]=parseFloat(a["vector[3]"][e]),i.transpose(),s.matrixList.push(i)}}),0===s.matrixList.length&&delete d.NCS}var i={};if(t.cell){var r=t.cell,c=parseFloat(r.length_a),u=parseFloat(r.length_b),h=parseFloat(r.length_c),l=new Float32Array(9);l[0]=c,l[4]=u,l[8]=h,e.boxes.push(l),i.a=c,i.b=u,i.c=h,i.alpha=parseFloat(r.angle_alpha),i.beta=parseFloat(r.angle_beta),i.gamma=parseFloat(r.angle_gamma)}t.symmetry&&(i.spacegroup=zA(t.symmetry["space_group_name_H-M"]));var g=new ei;if(t.database_PDB_matrix){var v=t.database_PDB_matrix,y=g.elements;y[0]=parseFloat(v["origx[1][1]"]),y[1]=parseFloat(v["origx[1][2]"]),y[2]=parseFloat(v["origx[1][3]"]),y[4]=parseFloat(v["origx[2][1]"]),y[5]=parseFloat(v["origx[2][2]"]),y[6]=parseFloat(v["origx[2][3]"]),y[8]=parseFloat(v["origx[3][1]"]),y[9]=parseFloat(v["origx[3][2]"]),y[10]=parseFloat(v["origx[3][3]"]),y[3]=parseFloat(v["origx_vector[1]"]),y[7]=parseFloat(v["origx_vector[2]"]),y[11]=parseFloat(v["origx_vector[3]"]),g.transpose(),i.origx=g}var b=new ei;if(t.atom_sites){var x=t.atom_sites,_=b.elements;_[0]=parseFloat(x["fract_transf_matrix[1][1]"]),_[1]=parseFloat(x["fract_transf_matrix[1][2]"]),_[2]=parseFloat(x["fract_transf_matrix[1][3]"]),_[4]=parseFloat(x["fract_transf_matrix[2][1]"]),_[5]=parseFloat(x["fract_transf_matrix[2][2]"]),_[6]=parseFloat(x["fract_transf_matrix[2][3]"]),_[8]=parseFloat(x["fract_transf_matrix[3][1]"]),_[9]=parseFloat(x["fract_transf_matrix[3][2]"]),_[10]=parseFloat(x["fract_transf_matrix[3][3]"]),_[3]=parseFloat(x["fract_transf_vector[1]"]),_[7]=parseFloat(x["fract_transf_vector[2]"]),_[11]=parseFloat(x["fract_transf_vector[3]"]),b.transpose(),i.scale=b}void 0!==i.a?e.unitcell=new TA(i):e.unitcell=void 0}(at,tt,st),function(t,e,i){var r=t.struct_conn;if(r){UA(r,"id");for(var n=/"/g,o=e.getAtomProxy(),a=e.getAtomProxy(),s={},c=0,u=r.id.length;c<u;++c){var h=r.conn_type_id[c];if("hydrog"!==h&&"mismat"!==h&&"saltbr"!==h&&"1_555"===r.ptnr1_symmetry[c]&&"1_555"===r.ptnr2_symmetry[c]){var l=r.pdbx_ptnr1_PDB_ins_code[c],p=r.pdbx_ptnr1_label_alt_id[c],d=r.ptnr1_auth_seq_id[c]+(jA(l)?"^"+l:"")+":"+i[r.ptnr1_label_asym_id[c]]+"."+r.ptnr1_label_atom_id[c].replace(n,"")+(jA(p)?"%"+p:""),f=s[d];if(!f){var m=new Lp(d);if(m.selection.error){de.Debug&&Yp.warn("invalid selection for connection",d);continue}f=e.getAtomIndices(m),s[d]=f}var g=r.pdbx_ptnr2_PDB_ins_code[c],v=r.pdbx_ptnr2_label_alt_id[c],y=r.ptnr2_auth_seq_id[c]+(jA(g)?"^"+g:"")+":"+i[r.ptnr2_label_asym_id[c]]+"."+r.ptnr2_label_atom_id[c].replace(n,"")+(jA(v)?"%"+v:""),b=s[y];if(!b){var x=new Lp(y);if(x.selection.error){de.Debug&&Yp.warn("invalid selection for connection",y);continue}b=e.getAtomIndices(x),s[y]=b}var _=f.length,w=b.length;if(w<_){var S=_;_=w,w=S;var A=f;f=b,b=A}if(0!==_&&0!==w)for(var M=0;M<w;++M)o.index=f[M%_],a.index=b[M],o&&a?e.bondStore.addBond(o,a,VA(r.pdbx_value_order[c])):Yp.log("atoms for connection not found");else de.Debug&&Yp.warn("no atoms found for",d,y)}}}}(at,tt,st),function(t,e,i){if(t.entity){UA(t.entity,"id");for(var r=t.entity,n=r.id.length,o=0;o<n;++o){var a=r.pdbx_description[o],s=r.type[o],c=Array.from(i[r.id[o]]);e.entityList[o]=new MA(e,o,a,s,c)}}}(at,tt,ct),at.struct&&at.struct.title&&(tt.title=at.struct.title.trim().replace(FA,"")),at.entry&&at.entry.id&&(tt.id=at.entry.id.trim().replace(FA,"")),at.pdbx_audit_revision_history){if(at.pdbx_audit_revision_history.revision_date){UA(at.pdbx_audit_revision_history,"revision_date");var e=at.pdbx_audit_revision_history.revision_date.filter(jA);e.length&&(tt.header.releaseDate=e[0])}if(at.pdbx_database_status.recvd_initial_deposition_date){UA(at.pdbx_database_status,"recvd_initial_deposition_date");var i=at.pdbx_database_status.recvd_initial_deposition_date.filter(jA);i.length&&(tt.header.depositionDate=i[0])}}else if(at.database_PDB_rev){if(at.database_PDB_rev.date){UA(at.database_PDB_rev,"date");var r=at.database_PDB_rev.date.filter(jA);r.length&&(tt.header.releaseDate=r[0])}if(at.database_PDB_rev.date_original){UA(at.database_PDB_rev,"date_original");var n=at.database_PDB_rev.date_original.filter(jA);n.length&&(tt.header.depositionDate=n[0])}}at.reflns&&at.reflns.d_resolution_high?jA(at.reflns.d_resolution_high)&&(tt.header.resolution=parseFloat(at.reflns.d_resolution_high)):at.refine&&at.refine.ls_d_res_high&&jA(at.refine.ls_d_res_high)&&(tt.header.resolution=parseFloat(at.refine.ls_d_res_high)),at.refine&&at.refine.ls_R_factor_R_free&&jA(at.refine.ls_R_factor_R_free)&&(tt.header.rFree=parseFloat(at.refine.ls_R_factor_R_free)),at.refine&&at.refine.ls_R_factor_R_work&&jA(at.refine.ls_R_factor_R_work)&&(tt.header.rWork=parseFloat(at.refine.ls_R_factor_R_work)),at.exptl&&at.exptl.method&&(UA(at.exptl,"method"),tt.header.experimentalMethods=at.exptl.method.map(function(t){return t.replace(FA,"")})),et.finalize(),tt.finalizeAtoms(),Mb(tt),tt.finalizeBonds(),t?bb(tt,t):_b(tt),Ib(tt),tt.extraData.cif=at}de.Debug&&Yp.timeEnd("CifParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("cif",HA),id.add("mcif",HA),id.add("mmcif",HA);var $A=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"gro"},e.prototype._parse=function(){de.Debug&&Yp.time("GroParser._parse "+this.name);var p,d,t=this.structure,f=this.structureBuilder,m=this.firstModelOnly,g=this.asTrajectory,v=this.cAlphaOnly,y=t.frames,b=t.boxes,e=this.streamer.peekLines(3);t.title=e[0].trim();var x,_,w,S,A=5+(e[2].length-e[2].lastIndexOf(".")-1),M=20,E=20+A,P=20+2*A,T=parseInt(e[1]),C=T+3,I=t.atomMap,O=t.atomStore;O.resize(T);var L=0,R=0,D=0;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=++D-1,o=i[r];if(o)if(n%C==0)g&&(p=new Float32Array(3*T),y.push(p),d=0);else if(n%C==1);else if(n%C==C-1){var a=o.trim().split(/\s+/),s=new Float32Array(9);if(s[0]=10*parseFloat(a[0]),s[4]=10*parseFloat(a[1]),s[8]=10*parseFloat(a[2]),b.push(s),m)return;R+=1}else{if(x=o.substr(10,5).trim(),v&&"CA"!==x)continue;var c=10*parseFloat(o.substr(M,A)),u=10*parseFloat(o.substr(E,A)),h=10*parseFloat(o.substr(P,A));if(g){var l=3*d;if(p[l+0]=c,p[l+1]=u,p[l+2]=h,d+=1,C<n)continue}_=o.substr(5,5).trim(),w=parseInt(o.substr(0,5)),S=parseInt(o.substr(15,5)),O.growIfFull(),O.atomTypeId[L]=I.add(x),O.x[L]=c,O.y[L]=u,O.z[L]=h,O.serial[L]=S,f.addAtom(R,"","",_,w,0,"l"),L+=1}}}(0,t.length,t)}),f.finalize(),t.finalizeAtoms(),Ab(t),Mb(t),t.finalizeBonds(),_b(t),de.Debug&&Yp.timeEnd("GroParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("gro",$A);var WA=["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 XA(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function qA(t){return XA(DataView,t)}function YA(t){return XA(Int8Array,t)}function ZA(t){return XA(Int32Array,t,4)}function KA(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,n=0;r<i;++r,n+=2)e[r]=t[n]<<8^t[n+1]<<0;return e}function JA(t,e){var i=t.length/4;e||(e=new Int32Array(i));for(var r=0,n=0;r<i;++r,n+=4)e[r]=t[n]<<24^t[n+1]<<16^t[n+2]<<8^t[n+3]<<0;return e}function QA(t,e,i){var r=t.length,n=1/e;i||(i=new Float32Array(r));for(var o=0;o<r;++o)i[o]=t[o]*n;return i}function tM(t,e){var i,r;if(!e){var n=0;for(i=0,r=t.length;i<r;i+=2)n+=t[i+1];e=new t.constructor(n)}var o=0;for(i=0,r=t.length;i<r;i+=2)for(var a=t[i],s=t[i+1],c=0;c<s;++c)e[o]=a,++o;return e}function eM(t,e){var i=t.length;e||(e=new t.constructor(i)),i&&(e[0]=t[0]);for(var r=1;r<i;++r)e[r]=t[r]+e[r-1];return e}function iM(t,e){var i,r,n=t instanceof Int8Array?127:32767,o=-n-1,a=t.length;if(!e){var s=0;for(i=0;i<a;++i)t[i]<n&&t[i]>o&&++s;e=new Int32Array(s)}for(r=i=0;i<a;){for(var c=0;t[i]===n||t[i]===o;)c+=t[i],++i;c+=t[i],++i,e[r]=c,++r}return e}function rM(t,e,i){return QA(iM(t,ZA(i)),e,i)}function nM(t,e,i){var r,n,o,a=iM(t,ZA(i));return n=e,o=XA(Float32Array,r=a,4),QA(eM(r,ZA(o)),n,o)}function oM(n){var o=0,r=new DataView(n.buffer);function a(t){for(var e={},i=0;i<t;i++){e[h()]=h()}return e}function s(t){var e=n.subarray(o,o+t);return o+=t,e}function c(t){var e=n.subarray(o,o+t);o+=t;if(65535<t){for(var i=[],r=0;r<e.length;r+=65535)i.push(String.fromCharCode.apply(null,e.subarray(r,r+65535)));return i.join("")}return String.fromCharCode.apply(null,e)}function u(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=h();return e}function h(){var t,e,i=n[o];if(0==(128&i))return o++,i;if(128==(240&i))return o++,a(e=15&i);if(144==(240&i))return o++,u(e=15&i);if(160==(224&i))return o++,c(e=31&i);if(224==(224&i))return t=r.getInt8(o),o++,t;switch(i){case 192:return o++,null;case 194:return o++,!1;case 195:return o++,!0;case 196:return e=r.getUint8(o+1),o+=2,s(e);case 197:return e=r.getUint16(o+1),o+=3,s(e);case 198:return e=r.getUint32(o+1),o+=5,s(e);case 202:return t=r.getFloat32(o+1),o+=5,t;case 203:return t=r.getFloat64(o+1),o+=9,t;case 204:return t=n[o+1],o+=2,t;case 205:return t=r.getUint16(o+1),o+=3,t;case 206:return t=r.getUint32(o+1),o+=5,t;case 208:return t=r.getInt8(o+1),o+=2,t;case 209:return t=r.getInt16(o+1),o+=3,t;case 210:return t=r.getInt32(o+1),o+=5,t;case 217:return e=r.getUint8(o+1),o+=2,c(e);case 218:return e=r.getUint16(o+1),o+=3,c(e);case 219:return e=r.getUint32(o+1),o+=5,c(e);case 220:return e=r.getUint16(o+1),o+=3,u(e);case 221:return e=r.getUint32(o+1),o+=5,u(e);case 222:return e=r.getUint16(o+1),o+=3,a(e);case 223:return e=r.getUint32(o+1),o+=5,a(e)}throw new Error("Unknown type 0x"+i.toString(16))}return h()}function aM(t,e,i,r){switch(t){case 1:return function(t,e){var i=t.length;e||(e=new Float32Array(i/4));for(var r=qA(e),n=qA(t),o=0,a=0,s=i/4;o<s;++o,a+=4)r.setFloat32(a,n.getFloat32(a),!0);return e}(e);case 2:return YA(e);case 3:return KA(e);case 4:return JA(e);case 5:return XA(Uint8Array,e);case 6:return tM(JA(e),new Uint8Array(i));case 7:return tM(JA(e));case 8:return eM(tM(JA(e)),s);case 9:return n=JA(e),o=JA(r)[0],QA(tM(n,ZA(a)),o,a);case 10:return nM(KA(e),JA(r)[0]);case 11:return QA(KA(e),JA(r)[0]);case 12:return rM(KA(e),JA(r)[0]);case 13:return rM(YA(e),JA(r)[0]);case 14:return iM(KA(e));case 15:return iM(YA(e))}var n,o,a,s}function sM(c,t){var u=(t=t||{}).ignoreFields,h={};return WA.forEach(function(t){var e,i,r,n,o,a=!!u&&-1!==u.indexOf(t),s=c[t];a||void 0===s||(s instanceof Uint8Array?h[t]=aM.apply(null,(i=qA(e=s),r=i.getInt32(0),n=i.getInt32(4),o=e.subarray(8,12),[r,e=e.subarray(12),n,o])):h[t]=s)}),h}var cM={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)},uM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"mmtf"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){var t,e,i,r,n;de.Debug&&Yp.time("MmtfParser._parse "+this.name);var o,a,s,c,u,h,l=this.structure,p=sM(oM(this.streamer.data));if(["depositionDate","releaseDate","resolution","rFree","rWork","experimentalMethods"].forEach(function(t){void 0!==p[t]&&(l.header[t]=p[t])}),l.id=p.structureId,l.title=p.title,l.atomStore.addField("formalCharge",1,"int8"),this.firstModelOnly||this.asTrajectory){for(u=1,t=s=0,e=c=p.chainsPerModel[0];t<e;++t)s+=p.groupsPerChain[t];for(t=a=0,e=s;t<e;++t)a+=(n=p.groupList[p.groupTypeList[t]]).atomNameList.length;o=p.numBonds,h=[c]}else o=p.numBonds,a=p.numAtoms,s=p.numGroups,c=p.numChains,u=p.numModels,h=p.chainsPerModel;if(o+=s,this.asTrajectory)for(t=0,e=p.numModels;t<e;++t){var d=new Float32Array(3*a),f=a*t;for(i=0;i<a;++i){var m=3*i,g=i+f;d[m]=p.xCoordList[g],d[m+1]=p.yCoordList[g],d[m+2]=p.zCoordList[g]}l.frames.push(d)}var v=new Uint32Array(o),y=new Uint32Array(o),b=new Uint8Array(o),x=new Uint32Array(a),_=new Int8Array(a),w=new Uint32Array(s),S=new Uint32Array(s),A=new Uint16Array(s),M=new Uint16Array(c),E=new Uint32Array(c),P=new Uint32Array(c),T=new Uint32Array(u),C=new Uint32Array(u),I=0;for(t=0,e=u;t<e;++t){var O=h[t];for(T[t]=I,C[t]=O,i=0;i<O;++i)M[i+I]=t;I+=O}var L=p.groupsPerChain,R=0;for(t=0,e=c;t<e;++t){var D=L[t];for(E[t]=R,P[t]=D,i=0;i<D;++i)w[i+R]=t;R+=D}var k=0,B=0;for(t=0,e=s;t<e;++t){var N=(n=p.groupList[p.groupTypeList[t]]).atomNameList.length,F=n.formalChargeList,z=n.bondAtomList,U=n.bondOrderList;for(i=0,r=U.length;i<r;++i)v[B]=k+z[2*i],y[B]=k+z[2*i+1],b[B]=U[i],B+=1;for(S[t]=k,A[t]=N,i=0;i<N;++i)x[k]=t,_[k]=F[i],k+=1}var j=p.bondAtomList;if(j)for(p.bondOrderList&&b.set(p.bondOrderList,B),t=0,e=j.length;t<e;t+=2){var G=j[t],V=j[t+1];G<a&&V<a&&(v[B]=G,y[B]=V,B+=1)}l.bondStore.length=b.length,l.bondStore.count=B,l.bondStore.atomIndex1=v,l.bondStore.atomIndex2=y,l.bondStore.bondOrder=b,l.atomStore.length=a,l.atomStore.count=a,l.atomStore.residueIndex=x,l.atomStore.atomTypeId=new Uint16Array(a),l.atomStore.x=p.xCoordList.subarray(0,a),l.atomStore.y=p.yCoordList.subarray(0,a),l.atomStore.z=p.zCoordList.subarray(0,a),l.atomStore.serial=p.atomIdList.subarray(0,a),l.atomStore.bfactor=p.bFactorList.subarray(0,a),l.atomStore.altloc=p.altLocList.subarray(0,a),l.atomStore.occupancy=p.occupancyList.subarray(0,a),l.atomStore.formalCharge=_,l.residueStore.length=s,l.residueStore.count=s,l.residueStore.chainIndex=w,l.residueStore.residueTypeId=p.groupTypeList,l.residueStore.atomOffset=S,l.residueStore.atomCount=A,l.residueStore.resno=p.groupIdList.subarray(0,s),l.residueStore.sstruc=p.secStructList.subarray(0,s),l.residueStore.inscode=p.insCodeList.subarray(0,s),l.chainStore.length=c,l.chainStore.count=c,l.chainStore.entityIndex=new Uint16Array(c),l.chainStore.modelIndex=M,l.chainStore.residueOffset=E,l.chainStore.residueCount=P,l.chainStore.chainname=p.chainNameList.subarray(0,4*c),l.chainStore.chainid=p.chainIdList.subarray(0,4*c),l.modelStore.length=u,l.modelStore.count=u,l.modelStore.chainOffset=T,l.modelStore.chainCount=C;var H={};for(t=0,e=p.groupList.length;t<e;++t){var $=p.groupList[t],W=[];for(i=0,r=$.atomNameList.length;i<r;++i){var X=$.elementList[i].toUpperCase(),q=$.atomNameList[i];W.push(l.atomMap.add(q,X))}var Y=$.chemCompType.toUpperCase(),Z=hg.includes(Y),K=$.bondOrderList.length,J=new Array(K),Q=new Array(K);for(i=0;i<K;++i)J[i]=$.bondAtomList[2*i],Q[i]=$.bondAtomList[2*i+1];var tt={atomIndices1:J,atomIndices2:Q,bondOrders:$.bondOrderList};H[t]=l.residueMap.add($.groupName,W,Z,Y,tt)}for(t=0,e=s;t<e;++t)l.residueStore.residueTypeId[t]=H[l.residueStore.residueTypeId[t]];for(t=0,e=l.atomStore.count;t<e;++t){var et=l.atomStore.residueIndex[t],it=l.residueMap.list[l.residueStore.residueTypeId[et]],rt=l.residueStore.atomOffset[et];l.atomStore.atomTypeId[t]=it.atomTypeIdList[t-rt]}if(p.secStructList){var nt=p.secStructList.length;for(t=0,e=l.residueStore.count;t<e;++t){var ot=cM[l.residueStore.sstruc[t%nt]];void 0!==ot&&(l.residueStore.sstruc[t]=ot)}}if(p.entityList&&p.entityList.forEach(function(t,e){l.entityList[e]=new MA(l,e,t.description,t.type,t.chainIndexList)}),p.bioAssemblyList&&p.bioAssemblyList.forEach(function(t,e){var i=e+1,n=new fb(""+i);l.biomolDict["BU"+i]=n;var o={};t.transformList.forEach(function(t){var e=(new ei).fromArray(t.matrix).transpose(),i=t.chainIndexList.map(function(t){for(var e="",i=0;i<4;++i){var r=p.chainNameList[4*t+i];if(!r)break;e+=String.fromCharCode(r)}return e}),r=o[i.toString()];r?r.matrixList.push(e):o[i.toString()]=n.addPart([e],i)})}),p.ncsOperatorList){var at=new fb("NCS"),st=at.addPart();p.ncsOperatorList.forEach(function(t){var e=(new ei).fromArray(t).transpose();st.matrixList.push(e)}),0<st.matrixList.length&&(l.biomolDict.NCS=at)}var ct=p.unitCell;ct&&Array.isArray(ct)&&ct[0]?l.unitcell=new TA({a:ct[0],b:ct[1],c:ct[2],alpha:ct[3],beta:ct[4],gamma:ct[5],spacegroup:p.spaceGroup}):l.unitcell=void 0,Cb(l,!0),Tb(l,!0),l.finalizeAtoms(),l.finalizeBonds(),Ib(l),de.Debug&&Yp.timeEnd("MmtfParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("mmtf",uM);var hM=/\s+/,lM={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0},pM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"mol2"},e.prototype._parse=function(){de.Debug&&Yp.time("Mol2Parser._parse "+this.name);var b,x,_=this.structure,w=this.structureBuilder,S=this.firstModelOnly,A=this.asTrajectory,M=_.frames,E=!1,P=_.atomMap,T=_.atomStore;T.resize(Math.round(this.streamer.data.length/60)),T.addField("partialCharge",1,"float32");var C=0,I=0,O=0,L=-1,R=0,D=0,k=1,B=2,N=3,F=_.getAtomProxy(),z=_.getAtomProxy();this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r].trim();if(""!==n&&"#"!==n[0])if("@"===n[0])"@<TRIPOS>MOLECULE"===n?(D=k,I=0,++L):"@<TRIPOS>ATOM"===n?(D=B,O=T.count,A&&(x=0,b=new Float32Array(3*R),M.push(b),0<L&&(E=!0))):D="@<TRIPOS>BOND"===n?N:0;else if(D===k){if(0===I)_.title=n,_.id=n;else if(1===I){var o=n.split(hM);R=parseInt(o[0])}++I}else if(D===B){var a=n.split(hM);if(S&&0<L)continue;var s=parseFloat(a[2]),c=parseFloat(a[3]),u=parseFloat(a[4]);if(A){var h=3*x;if(b[h+0]=s,b[h+1]=c,b[h+2]=u,x+=1,E)continue}var l=a[0],p=a[1],d=a[5].split(".")[0],f=a[6]?parseInt(a[6]):1,m=a[7]?a[7]:"",g=a[8]?parseFloat(a[8]):0;T.growIfFull(),T.atomTypeId[C]=P.add(p,d),T.x[C]=s,T.y[C]=c,T.z[C]=u,T.serial[C]=l,T.partialCharge[C]=g,w.addAtom(L,"","",m,f,1),C+=1}else if(D===N){if(S&&0<L)continue;if(A&&0<L)continue;var v=n.split(hM);F.index=parseInt(v[1])-1+O,z.index=parseInt(v[2])-1+O;var y=lM[v[3]];_.bondStore.addBond(F,z,y)}}}(0,t.length,t)}),w.finalize(),_.finalizeAtoms(),Ab(_),Tb(_,!0),Cb(_,!0),_.finalizeBonds(),Db(_),_b(_),de.Debug&&Yp.timeEnd("Mol2Parser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("mol2",pM);var dM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"pdbqt"},Object.defineProperties(e.prototype,i),e}(DA);id.add("pdbqt",dM);var fM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"pqr"},Object.defineProperties(e.prototype,i),e}(DA);id.add("pqr",fM);var mM=/> <(.+)>/,gM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"sdf"},e.prototype._parse=function(){de.Debug&&Yp.time("SdfParser._parse "+this.name);var v=this.structure,y=this.structureBuilder,b=this.firstModelOnly,x=this.asTrajectory,t=this.streamer.peekLines(2);v.id=t[0].trim(),v.title=t[1].trim();var _,w,S=v.frames,A=!1,M=v.atomMap,E=v.atomStore;E.resize(Math.round(this.streamer.data.length/50)),E.addField("formalCharge",1,"int8");var P,T,C,I,O,L,R,D=v.getAtomProxy(),k=v.getAtomProxy(),B=0,N=0,F=0,z=0,U=[],j=!1,G={};v.extraData.sdf=U,this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r];if("$$$$"===n.substr(0,4))N=-1,++F,z=E.count,U.push(G),j=!(G={});else if(3===N)T=parseInt(n.substr(0,3)),C=parseInt(n.substr(3,3)),R=(L=O=(I=4)+T)+C,x&&(w=0,_=new Float32Array(3*T),S.push(_),0<F&&(A=!0));else if(I<=N&&N<O){if(b&&0<F)continue;var o=parseFloat(n.substr(0,10)),a=parseFloat(n.substr(10,10)),s=parseFloat(n.substr(20,10));if(x){var c=3*w;if(_[c+0]=o,_[c+1]=a,_[c+2]=s,w+=1,A)continue}var u=n.substr(31,3).trim(),h=u+(B+1);E.growIfFull(),E.atomTypeId[B]=M.add(h,u),E.x[B]=o,E.y[B]=a,E.z[B]=s,E.serial[B]=B,E.formalCharge[B]=0,y.addAtom(F,"","","HET",1,1),B+=1}else if(L<=N&&N<R){if(b&&0<F)continue;if(x&&0<F)continue;D.index=parseInt(n.substr(0,3))-1+z,k.index=parseInt(n.substr(3,3))-1+z;var l=parseInt(n.substr(6,3));v.bondStore.addBond(D,k,l)}else if(n.match(/M {2}CHG/))for(var p=parseInt(n.substr(6,3)),d=0,f=10;d<p;++d,f+=8){var m=parseInt(n.substr(f,3))-1+z,g=parseInt(n.substr(f+4,3));E.formalCharge[m]=g}else(P=n.match(mM))?(j=P[1],G[j]=[]):!1!==j&&n&&G[j].push(n);++N}}(0,t.length,t)}),y.finalize(),v.finalizeAtoms(),v.finalizeBonds(),Db(v),de.Debug&&Yp.timeEnd("SdfParser._parse "+this.name)},e.prototype._postProcess=function(){Db(this.structure)},Object.defineProperties(e.prototype,i),e}(AA);id.add("sdf",gM),id.add("sd",gM),id.add("mol",gM);function vM(t,e,i){return parseInt(t.substr(e,i).trim())}var yM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"prmtop"},e.prototype._parse=function(){de.Debug&&Yp.time("PrmtopParser._parse "+this.name);var t=this.structure,e=this.structureBuilder,i=t.atomMap,E=t.atomStore;E.addField("partialCharge",1,"float32"),E.addField("radius",1,"float32");var P,T,C,I,O,L,R,D,k,B,N,F=[],z={},U=["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"];U.forEach(function(t){z[t]=0}),this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r],o=n.trim();if(o)if(n.startsWith("%FORMAT"));else if(n.startsWith("%FLAG")){var a=n.substr(5).trim();B=0,"TITLE"===a?k=0:"POINTERS"===a?k=1:"ATOM_NAME"===a?k=2:"CHARGE"===a?k=3:"MASS"===a?k=4:"RESIDUE_LABEL"===a?k=5:"RESIDUE_POINTER"===a?k=6:"BONDS_INC_HYDROGEN"===a?(N=0,k=7):"BONDS_WITHOUT_HYDROGEN"===a?(N=z.NBONH,k=8):k="RADII"===a?9:void 0}else if(0===k)F.push(o);else if(1===k){for(var s=Math.min(B+10,32),c=0;B<s;++c,++B)z[U[B]]=parseInt(n.substr(8*c,8).trim());P=new Array(z.NATOM),T=new Float32Array(z.NATOM),C=new Float32Array(z.NATOM),E.resize(z.NATOM);var u=z.NBONH+z.MBONA;I=new Uint32Array(u),O=new Uint32Array(u),L=new Uint8Array(u),R=new Array(z.NRES),D=new Uint32Array(z.NRES)}else if(2===k)for(var h=Math.min(B+20,z.NATOM),l=0;B<h;++l,++B)P[B]=n.substr(4*l,4).trim();else if(3===k)for(var p=Math.min(B+5,z.NATOM),d=0;B<p;++d,++B)T[B]=parseFloat(n.substr(16*d,16))/18.2223;else if(4===k);else if(5===k)for(var f=Math.min(B+20,z.NRES),m=0;B<f;++m,++B)R[B]=n.substr(4*m,4).trim();else if(6===k)for(var g=Math.min(B+10,z.NRES),v=0;B<g;++v,++B)D[B]=vM(n,8*v,8);else if(7===k)for(var y=Math.min(B+10,3*z.NBONH),b=0;B<y;++b,++B){var x=B%3;0===x&&(I[N]=vM(n,8*b,8)/3),1===x&&(O[N]=vM(n,8*b,8)/3,L[N]=1,++N)}else if(8===k)for(var _=Math.min(B+10,3*z.MBONA),w=0;B<_;++w,++B){var S=B%3;0===S&&(I[N]=vM(n,8*w,8)/3),1===S&&(O[N]=vM(n,8*w,8)/3,L[N]=1,++N)}else if(9===k)for(var A=Math.min(B+5,z.NATOM),M=0;B<A;++M,++B)C[B]=parseFloat(n.substr(16*M,16))}}(0,t.length,t)}),t.title=F.join(" ");for(var r=z.NATOM,n=0,o=R[0],a=1,s=0;s<r;++s)s+1===D[n+1]&&(o=R[++n],a=n+1),E.atomTypeId[s]=i.add(P[s]),E.serial[s]=s+1,e.addAtom(0,"","",o,a);E.partialCharge.set(T),E.radius.set(C),t.bondStore.length=L.length,t.bondStore.count=L.length,t.bondStore.atomIndex1=I,t.bondStore.atomIndex2=O,t.bondStore.bondOrder=L,e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),Tb(t,!0),Cb(t,!0,!0),Ab(t,!0),Db(t),de.Debug&&Yp.timeEnd("PrmtopParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("prmtop",yM),id.add("parm7",yM);var bM=/\s+/,xM=/(^\*|REMARK)*/,_M=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"psf"},e.prototype._parse=function(){de.Debug&&Yp.time("PsfParser._parse "+this.name);var t=this.structure,v=this.structureBuilder,y=t.atomMap,b=t.atomStore;b.addField("partialCharge",1,"float32");var x,_,w,S,A,M,E=[],P=0,T=0,C=0;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r].trim();if(n)if(2===x){var o=n.split(bM),a=parseInt(o[0]),s=o[1],c=parseInt(o[2]),u=o[3],h=o[4],l=parseFloat(o[6]);s!==w&&(_=Sb(T),++T),b.growIfFull(),b.atomTypeId[P]=y.add(h),b.serial[P]=a,b.partialCharge[P]=l,v.addAtom(0,_,_,u,c),P+=1,w=s}else if(3===x)for(var p=n.split(bM),d=0,f=p.length;d<f;d+=2)S[C]=parseInt(p[d])-1,A[C]=parseInt(p[d+1])-1,M[C]=1,C+=1;else if(1===x)E.push(n.replace(xM,"").trim());else if(4===x);else if(5===x);else if(6===x);else if(n.includes("!NATOM")){x=2;var m=parseInt(n.split(bM)[0]);b.resize(m)}else if(n.includes("!NBOND")){x=3;var g=parseInt(n.split(bM)[0]);S=new Uint32Array(g),A=new Uint32Array(g),M=new Uint8Array(g)}else n.includes("!NTITLE")?x=1:n.includes("!NTHETA")?x=4:n.includes("!NPHI")?x=5:n.includes("!NIMPHI")&&(x=6);else x=void 0}}(0,t.length,t)}),t.title=E.join(" "),t.bondStore.length=M.length,t.bondStore.count=C,t.bondStore.atomIndex1=S,t.bondStore.atomIndex2=A,t.bondStore.bondOrder=M,v.finalize(),t.finalizeAtoms(),t.finalizeBonds(),Tb(t,!0),Cb(t,!0,!0),Db(t),de.Debug&&Yp.timeEnd("PsfParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("psf",_M);var wM=/\[ (.+) \]/,SM=/\s+/,AM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"top"},e.prototype._parse=function(){de.Debug&&Yp.time("TopParser._parse "+this.name);var d=this.structure,s=this.structureBuilder,c=d.atomMap,u=d.bondStore,h=d.atomStore;h.addField("partialCharge",1,"float32");var f,m,g=[],v={};this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r],o=n.trim();if(o&&"*"!==o[0]&&";"!==o[0]){if(o.startsWith("#include"))throw new Error("TopParser: #include statements not allowed");var a=n.match(wM);if(null===a){var s=o.indexOf(";");if(-1!==s&&(o=o.substring(0,s).trim()),2===m){var c=o.split(SM)[0];v[c]=f}else if(3===m){var u=o.split(SM);f.atoms.push([parseInt(u[2]),u[3],u[4],parseFloat(u[6])])}else if(4===m){var h=o.split(SM);f.bonds.push([parseInt(h[0]),parseInt(h[1])])}else if(0===m)d.title=o;else if(1===m){var l=o.split(SM);g.push([l[0],parseInt(l[1])])}}else{var p=a[1];"moleculetype"===p?(m=2,f={atoms:[],bonds:[]}):m="atoms"===p?3:"bonds"===p?4:"system"===p?0:"molecules"===p?1:void 0}}}}(0,t.length,t)});var n=0,o=0;g.forEach(function(t){var e=t[0],i=t[1],r=v[e];n+=i*r.atoms.length,o+=i*r.bonds.length}),h.resize(n),u.resize(o);var l,p=0,y=0,b=0,x=0,_=0,w=0;g.forEach(function(t){for(var e=t[0],i=t[1],r=v[e],a=Sb(x),n=function(t){l=-1;var o=Pg.includes(e)?a:Sb(b);r.atoms.forEach(function(t){var e=t[0],i=t[1],r=t[2],n=t[3];e!==l&&++y,h.atomTypeId[p]=c.add(r),h.serial[p]=p+1,h.partialCharge[p]=n,s.addAtom(0,a,o,i,y+1),++p,l=e}),r.bonds.forEach(function(t){u.atomIndex1[_]=w+t[0]-1,u.atomIndex2[_]=w+t[1]-1,++_}),++b,w+=r.atoms.length},o=0;o<i;++o)n();++x}),u.count=o,s.finalize(),d.finalizeAtoms(),d.finalizeBonds(),Tb(d,!0),Cb(d,!0,!0),Db(d),de.Debug&&Yp.timeEnd("TopParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(AA);id.add("top",AM);var MM=function(i){function t(t,e){i.call(this,t,e),this.frames=new e_(this.name,this.path)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0}};return e.type.get=function(){return"trajectory"},e.__objName.get=function(){return"frames"},Object.defineProperties(t.prototype,e),t}(wA),EM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"dcd"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("DcdParser._parse "+this.name);var t=Rl(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,n=i.boxes,o={},a=0,s=new Int32Array(t,0,23),c=s[0]!==e.getInt32(0);if(84!==s[0])for(var u=t.byteLength,h=0;h<u;h+=4)e.setFloat32(h,e.getFloat32(h),!0);84!==s[0]&&Yp.error("dcd bad format, header block start"),"CORD"!==String.fromCharCode(e.getUint8(4),e.getUint8(5),e.getUint8(6),e.getUint8(7))&&Yp.error("dcd bad format, format string");var l=!1,p=!1,d=!1;0!==s[22]&&(l=!0,0!==s[12]&&(p=!0),1===s[13]&&(d=!0)),o.NSET=s[2],o.ISTART=s[3],o.NSAVC=s[4],o.NAMNF=s[10],o.DELTA=l?e.getFloat32(44,c):e.getFloat64(44,c),84!==s[22]&&Yp.error("dcd bad format, header block end"),a=a+84+8;var f=e.getInt32(a,c),m=a+1;if((f-4)%80!=0&&Yp.error("dcd bad format, title block start"),o.TITLE=Il(new Uint8Array(t,m,f)),e.getInt32(m+f+4-1,c)!==f&&Yp.error("dcd bad format, title block end"),a=a+f+8,4!==e.getInt32(a,c)&&Yp.error("dcd bad format, natom block start"),o.NATOM=e.getInt32(a+4,c),4!==e.getInt32(a+8,c)&&Yp.error("dcd bad format, natom block end"),a=a+4+8,0<o.NAMNF)Yp.error("dcd format with fixed atoms unsupported, aborting");else{for(var g=o.NATOM,v=4*g,y=0,b=o.NSET;y<b;++y){if(p){a+=4;var x=new Float32Array(9);x[0]=e.getFloat64(a,c),x[4]=e.getFloat64(a+16,c),x[8]=e.getFloat64(a+40,c),n.push(x),a+=48,a+=4}for(var _=new Float32Array(3*g),w=0;w<3;++w){e.getInt32(a,c)!==v&&Yp.error("dcd bad format, coord block start",y,w),a+=4;for(var S=new Float32Array(t,a,g),A=0;A<g;++A)_[3*A+w]=S[A];a+=v,e.getInt32(a,c)!==v&&Yp.error("dcd bad format, coord block end",y,w),a+=4}if(r.push(_),d)a+=4+e.getInt32(a,c)+4}o.DELTA&&(i.deltaTime=20.45482949774598*o.DELTA),1<=o.ISTART&&(i.timeOffset=(o.ISTART-1)*i.deltaTime),de.Debug&&Yp.timeEnd("DcdParser._parse "+this.name)}},Object.defineProperties(e.prototype,i),e}(MM);function PM(t,e){if(t)throw new TypeError("Not a valid NetCDF v3.x file: "+e)}function TM(t){t.offset%4!=0&&t.skip(4-t.offset%4)}function CM(t){var e=t.readUint32(),i=t.readChars(e);return TM(t),i}id.add("dcd",EM);var IM={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function OM(t){switch(Number(t)){case IM.BYTE:return"byte";case IM.CHAR:return"char";case IM.SHORT:return"short";case IM.INT:return"int";case IM.FLOAT:return"float";case IM.DOUBLE:return"double";default:return"undefined"}}function LM(t){switch(Number(t)){case IM.BYTE:case IM.CHAR:return 1;case IM.SHORT:return 2;case IM.INT:case IM.FLOAT:return 4;case IM.DOUBLE:return 8;default:return-1}}function RM(t){switch(String(t)){case"byte":return IM.BYTE;case"char":return IM.CHAR;case"short":return IM.SHORT;case"int":return IM.INT;case"float":return IM.FLOAT;case"double":return IM.DOUBLE;default:return-1}}function DM(t,e){if(1!==t){for(var i=new Array(t),r=0;r<t;r++)i[r]=e();return i}return e()}function kM(t,e,i){switch(e){case IM.BYTE:return t.readBytes(i);case IM.CHAR:return function(t){if(0===t.charCodeAt(t.length-1))return t.substring(0,t.length-1);return t}(t.readChars(i));case IM.SHORT:return DM(i,t.readInt16.bind(t));case IM.INT:return DM(i,t.readInt32.bind(t));case IM.FLOAT:return DM(i,t.readFloat32.bind(t));case IM.DOUBLE:return DM(i,t.readFloat64.bind(t));default:return void PM(!0,"non valid type "+e)}}var BM=0,NM=10,FM=11,zM=12;function UM(t,e){var i={recordDimension:{length:t.readUint32()}};i.version=e;var r=function(t){var e,i,r,n=t.readUint32();{if(n===BM)return PM(t.readUint32()!==BM,"wrong empty tag for list of dimensions"),[];PM(n!==NM,"wrong tag for list of dimensions");var o=t.readUint32();e=new Array(o);for(var a=0;a<o;a++){var s=CM(t),c=t.readUint32();0===c&&(i=a,r=s),e[a]={name:s,size:c}}return{dimensions:e,recordId:i,recordName:r}}}(t);i.recordDimension.id=r.recordId,i.recordDimension.name=r.recordName,i.dimensions=r.dimensions,i.globalAttributes=jM(t);var n=function(t,e,i){var r,n=t.readUint32(),o=0;{if(n===BM)return PM(t.readUint32()!==BM,"wrong empty tag for list of variables"),[];PM(n!==FM,"wrong tag for list of variables");var a=t.readUint32();r=new Array(a);for(var s=0;s<a;s++){for(var c=CM(t),u=t.readUint32(),h=new Array(u),l=0;l<u;l++)h[l]=t.readUint32();var p=jM(t),d=t.readUint32();PM(d<1&&6<d,"non valid type "+d);var f=t.readUint32(),m=t.readUint32();2===i&&(PM(0<m,"offsets larger than 4GB not supported"),m=t.readUint32()),h[0]===e&&(o+=f),r[s]={name:c,dimensions:h,attributes:p,type:OM(d),size:f,offset:m,record:h[0]===e}}}return{variables:r,recordStep:o}}(t,r.recordId,e);return i.variables=n.variables,i.recordDimension.recordStep=n.recordStep,i}function jM(t){var e,i=t.readUint32();if(i===BM)return PM(t.readUint32()!==BM,"wrong empty tag for list of attributes"),[];PM(i!==zM,"wrong tag for list of attributes");var r=t.readUint32();e=new Array(r);for(var n=0;n<r;n++){var o=CM(t),a=t.readUint32();PM(a<1||6<a,"non valid type "+a);var s=kM(t,a,t.readUint32());TM(t),e[n]={name:o,type:OM(a),value:s}}return e}var GM=function(t){var e=new Sd(t);e.setBigEndian(),PM("CDF"!==e.readChars(3),"should start with CDF");var i=e.readByte();PM(2<i,"unknown version"),this.header=UM(e,i),this.buffer=e},VM={version:{configurable:!0},recordDimension:{configurable:!0},dimensions:{configurable:!0},globalAttributes:{configurable:!0},variables:{configurable:!0}};VM.version.get=function(){return 1===this.header.version?"classic format":"64-bit offset format"},VM.recordDimension.get=function(){return this.header.recordDimension},VM.dimensions.get=function(){return this.header.dimensions},VM.globalAttributes.get=function(){return this.header.globalAttributes},VM.variables.get=function(){return this.header.variables},GM.prototype.hasDataVariable=function(e){return-1!==this.header.variables.findIndex(function(t){return t.name===e})},GM.prototype.getDataVariable=function(e){var t;return PM(void 0===(t="string"==typeof e?this.header.variables.find(function(t){return t.name===e}):e),"variable not found"),this.buffer.seek(t.offset),t.record?function(t,e,i){for(var r=RM(e.type),n=e.size?e.size/LM(r):1,o=i.length,a=new Array(o),s=i.recordStep,c=0;c<o;c++){var u=t.offset;a[c]=kM(t,r,n),t.seek(u+s)}return a}(this.buffer,t,this.header.recordDimension):function(t,e){for(var i=RM(e.type),r=e.size/LM(i),n=new Array(r),o=0;o<r;o++)n[o]=kM(t,i,1);return n}(this.buffer,t)},Object.defineProperties(GM.prototype,VM);var HM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"nctraj"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("NctrajParser._parse "+this.name);var t=new GM(this.streamer.data),e=this.frames,i=e.coordinates,r=e.boxes,n=e.times;t.getDataVariable("coordinates").forEach(function(t){i.push(new Float32Array(t))}),t.hasDataVariable("cell_lengths")&&t.getDataVariable("cell_lengths").forEach(function(t){r.push(new Float32Array(t))}),t.hasDataVariable("time")&&t.getDataVariable("time").forEach(function(t){n.push(t)}),1<=n.length&&(e.timeOffset=n[0]),2<=n.length&&(e.deltaTime=n[1]-n[0]),de.Debug&&Yp.timeEnd("NctrajParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(MM);id.add("nctraj",HM),id.add("ncdf",HM),id.add("nc",HM);var $M=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"trr"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("TrrParser._parse "+this.name);for(var t=Rl(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,n=i.boxes,o=i.times,a=0;;){a+=8;var s=e.getInt32(a);a+=4,a+=s;var c=e.getInt32(a+8),u=e.getInt32(a+12),h=e.getInt32(a+16),l=e.getInt32(a+28),p=e.getInt32(a+32),d=e.getInt32(a+36),f=e.getInt32(a+40);a+=52;var m=c/9,g=3*f;if(8===m?o.push(e.getFloat64(a)):o.push(e.getFloat32(a)),a+=2*m,c){var v=new Float32Array(9);if(8===m)for(var y=0;y<9;++y)v[y]=10*e.getFloat64(a),a+=8;else for(var b=0;b<9;++b)v[b]=10*e.getFloat32(a),a+=4;n.push(v)}if(a+=u,a+=h,l){var x=void 0;if(8===m){x=new Float32Array(g);for(var _=0;_<g;++_)x[_]=10*e.getFloat64(a),a+=8}else{for(var w=new Uint32Array(t,a,g),S=0;S<g;++S){var A=w[S];w[S]=(255&A)<<24|(65280&A)<<8|A>>8&65280|A>>24&255}x=new Float32Array(t,a,g);for(var M=0;M<g;++M)x[M]*=10,a+=4}r.push(x)}if(a+=p,(a+=d)>=t.byteLength)break}1<=o.length&&(i.timeOffset=o[0]),2<=o.length&&(i.deltaTime=o[1]-o[0]),de.Debug&&Yp.timeEnd("TrrParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(MM);id.add("trr",$M);var WM=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 XM(t){for(var e=1,i=0;e<=t&&i<32;)i++,e<<=1;return i}var qM=new Uint8Array(32);function YM(t,e){var i=1,r=0;qM[0]=1;for(var n=0;n<t;n++){var o=void 0,a=0;for(o=0;o<i;o++)a+=qM[o]*e[n],qM[o]=255&a,a>>=8;for(;0!==a;)qM[o++]=255&a,a>>=8;i=o}var s=1;for(i--;qM[i]>=s;)r++,s*=2;return r+8*i}function ZM(t,e,i,r){for(var n=(1<<i)-1,o=r[1],a=r[2],s=t[0],c=0;8<=i;)c|=(a=a<<8|e[s++])>>o<<i-8,i-=8;return 0<i&&(o<i&&(o+=8,a=a<<8|e[s++]),c|=a>>(o-=i)&(1<<i)-1),c&=n,t[0]=s,t[1]=o,t[2]=a,c}var KM=new Int32Array(32);function JM(t,e,i,r,n,o,a){var s=0;for(KM[1]=0,KM[2]=0,KM[3]=0;8<r;)KM[s++]=ZM(t,e,8,a),r-=8;0<r&&(KM[s++]=ZM(t,e,r,a));for(var c=i-1;0<c;c--){for(var u=0,h=s-1;0<=h;h--){var l=(u=u<<8|KM[h])/n[c]|0;u-=(KM[h]=l)*n[c]}o[c]=u}o[0]=KM[0]|KM[1]<<8|KM[2]<<16|KM[3]<<24}var QM=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"xtc"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("XtcParser._parse "+this.name);for(var t=Rl(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,n=i.boxes,o=i.times,a=new Int32Array(6),s=new Int32Array(3),c=new Int32Array(3),u=new Uint32Array(3),h=new Float32Array(3),l=new Float32Array(3),p=0,d=new Int32Array(3),f=new Uint32Array(d.buffer);;){var m=void 0,g=e.getInt32(p+4);p+=12;var v=3*g;o.push(e.getFloat32(p)),p+=4;for(var y=new Float32Array(9),b=0;b<9;++b)y[b]=10*e.getFloat32(p),p+=4;if(n.push(y),g<=9){m=new Float32Array(g);for(var x=0;x<g;++x)m[x]=e.getFloat32(p),p+=4}else{d[0]=d[1]=d[2]=0,s[0]=s[1]=s[2]=0,u[0]=u[1]=u[2]=0,c[0]=c[1]=c[2]=0,h[0]=h[1]=h[2]=0,l[0]=l[1]=l[2]=0,m=new Float32Array(v);var _=0,w=e.getInt32(p);p+=4;var S=e.getFloat32(p);p+=4,a[0]=e.getInt32(p),a[1]=e.getInt32(p+4),a[2]=e.getInt32(p+8),a[3]=e.getInt32(p+12),a[4]=e.getInt32(p+16),a[5]=e.getInt32(p+20),s[0]=a[3]-a[0]+1,s[1]=a[4]-a[1]+1,s[2]=a[5]-a[2]+1,p+=24;var A=void 0;16777215<(s[0]|s[1]|s[2])?(c[0]=XM(s[0]),c[1]=XM(s[1]),c[2]=XM(s[2]),A=0):A=YM(3,s);var M=e.getInt32(p);p+=4;var E=M-1,P=WM[E=E<9?9:E]/2|0,T=WM[M]/2|0;u[0]=u[1]=u[2]=WM[M];var C=4*Math.ceil(e.getInt32(p)/4);p+=4;var I=1/S,O=0,L=0,R=new Uint8Array(t,p);for(h[0]=h[1]=h[2]=0;L<w;){0===A?(h[0]=ZM(d,R,c[0],f),h[1]=ZM(d,R,c[1],f),h[2]=ZM(d,R,c[2],f)):JM(d,R,3,A,s,h,f),L++,h[0]+=a[0],h[1]+=a[1],h[2]+=a[2],l[0]=h[0],l[1]=h[1],l[2]=h[2];var D=0;if(1===ZM(d,R,1,f)&&(O=ZM(d,R,5,f),O-=D=O%3,D--),0<O){h[0]=h[1]=h[2]=0;for(var k=0;k<O;k+=3){if(JM(d,R,3,M,u,h,f),L++,h[0]+=l[0]-T,h[1]+=l[1]-T,h[2]+=l[2]-T,0===k){var B=h[0];h[0]=l[0],l[0]=B,B=h[1],h[1]=l[1],l[1]=B,B=h[2],h[2]=l[2],l[2]=B,m[_++]=l[0]*I,m[_++]=l[1]*I,m[_++]=l[2]*I}else l[0]=h[0],l[1]=h[1],l[2]=h[2];m[_++]=h[0]*I,m[_++]=h[1]*I,m[_++]=h[2]*I}}else m[_++]=h[0]*I,m[_++]=h[1]*I,m[_++]=h[2]*I;if(M+=D,D<0?(T=P,P=9<M?WM[M-1]/2|0:0):0<D&&(P=T,T=WM[M]/2|0),u[0]=u[1]=u[2]=WM[M],0===u[0]||0===u[1]||0===u[2])return void console.error("(xdrfile error) Undefined error.")}p+=C}for(var N=0;N<v;N++)m[N]*=10;if(r.push(m),p>=t.byteLength)break}1<=o.length&&(i.timeOffset=o[0]),2<=o.length&&(i.deltaTime=o[1]-o[0]),de.Debug&&Yp.timeEnd("XtcParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(MM);id.add("xtc",QM);var tE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.volume=new ay(this.name,this.path),this.voxelSize=bl(i.voxelSize,1)}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0}};return e.type.get=function(){return"volume"},e.__objName.get=function(){return"volume"},t.prototype._afterParse=function(){this.volume.setMatrix(this.getMatrix()),r.prototype._afterParse.call(this)},t.prototype.getMatrix=function(){return new ei},Object.defineProperties(t.prototype,e),t}(wA),eE=/\s+/,iE=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,rE=.529177210859,nE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"cube"},e.prototype._parse=function(){de.Debug&&Yp.time("CubeParser._parse "+this.name);var t=this.volume,r=this.streamer.peekLines(6),c={},e=rE*this.voxelSize;function i(t,e){var i=r[t].trim().split(eE)[e];return parseFloat(i)}c.atomCount=Math.abs(i(2,0)),c.originX=i(2,1)*rE,c.originY=i(2,2)*rE,c.originZ=i(2,3)*rE,c.NVX=i(3,0),c.NVY=i(4,0),c.NVZ=i(5,0),c.basisX=new ri(i(3,1),i(3,2),i(3,3)).multiplyScalar(e),c.basisY=new ri(i(4,1),i(4,2),i(4,3)).multiplyScalar(e),c.basisZ=new ri(i(5,1),i(5,2),i(5,3)).multiplyScalar(e);var u=new Float32Array(c.NVX*c.NVY*c.NVZ),h=0,l=0,p=0<i(2,0)?0:1;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r].trim();if(""!==n&&l>=c.atomCount+6+p)for(var o=n.match(iE),a=0,s=o.length;a<s;++a)u[h]=parseFloat(o[a]),++h;++l}}(0,t.length,t)}),t.header=c,t.setData(u,c.NVZ,c.NVY,c.NVX),de.Debug&&Yp.timeEnd("CubeParser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=new ei;return e.multiply((new ei).makeTranslation(t.originX,t.originY,t.originZ)),e.multiply((new ei).makeBasis(t.basisZ,t.basisY,t.basisX)),e},Object.defineProperties(e.prototype,i),e}(tE);id.add("cub",nE),id.add("cube",nE);var oE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"dsn6"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("Dsn6Parser._parse "+this.name);var t,e,i=this.volume,r={},n=Rl(this.streamer.data),o=new Int16Array(n),a=new Uint8Array(n),s=String.fromCharCode.apply(null,a.subarray(0,512));if(s.startsWith(":-)"))r.xStart=parseInt(s.substr(10,5)),r.yStart=parseInt(s.substr(15,5)),r.zStart=parseInt(s.substr(20,5)),r.xExtent=parseInt(s.substr(32,5)),r.yExtent=parseInt(s.substr(38,5)),r.zExtent=parseInt(s.substr(42,5)),r.xRate=parseInt(s.substr(52,5)),r.yRate=parseInt(s.substr(58,5)),r.zRate=parseInt(s.substr(62,5)),r.xlen=parseFloat(s.substr(73,10))*this.voxelSize,r.ylen=parseFloat(s.substr(83,10))*this.voxelSize,r.zlen=parseFloat(s.substr(93,10))*this.voxelSize,r.alpha=parseFloat(s.substr(103,10)),r.beta=parseFloat(s.substr(113,10)),r.gamma=parseFloat(s.substr(123,10)),t=parseFloat(s.substr(138,12))/100,e=parseInt(s.substr(155,8)),r.sigma=100*parseFloat(s.substr(170,12));else{if(100!==o[18])for(var c=0,u=o.length;c<u;++c){var h=o[c];o[c]=(255&h)<<8|h>>8&255}r.xStart=o[0],r.yStart=o[1],r.zStart=o[2],r.xExtent=o[3],r.yExtent=o[4],r.zExtent=o[5],r.xRate=o[6],r.yRate=o[7],r.zRate=o[8];var l=1/o[17],p=l*this.voxelSize;r.xlen=o[9]*p,r.ylen=o[10]*p,r.zlen=o[11]*p,r.alpha=o[12]*l,r.beta=o[13]*l,r.gamma=o[14]*l,t=o[15]/100,e=o[16],r.gamma=o[14]*l}i.header=r,de.Debug&&Yp.log(r,t,e);for(var d=new Float32Array(r.xExtent*r.yExtent*r.zExtent),f=512,m=Math.ceil(r.xExtent/8),g=Math.ceil(r.yExtent/8),v=Math.ceil(r.zExtent/8),y=0;y<v;++y)for(var b=0;b<g;++b)for(var x=0;x<m;++x)for(var _=0;_<8;++_)for(var w=8*y+_,S=0;S<8;++S)for(var A=8*b+S,M=0;M<8;++M){var E=8*x+M;if(!(E<r.xExtent&&A<r.yExtent&&w<r.zExtent)){f+=8-M;break}d[(E*r.yExtent+A)*r.zExtent+w]=(a[f]-e)/t,++f}i.setData(d,r.zExtent,r.yExtent,r.xExtent),r.sigma&&i.setStats(void 0,void 0,void 0,r.sigma),de.Debug&&Yp.timeEnd("Dsn6Parser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],r=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[[],e,i,r],o=[0,t.xRate,t.yRate,t.zRate],a=[0,1,2,3],s=new ei;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.multiply((new ei).makeRotationY(Gl(90))),s.multiply((new ei).makeTranslation(-t.zStart,t.yStart,t.xStart)),s.multiply((new ei).makeScale(-1,1,1)),s},Object.defineProperties(e.prototype,i),e}(tE);id.add("dsn6",oE),id.add("brix",oE);var aE=/\s+/,sE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"dx"},e.prototype._parse=function(){de.Debug&&Yp.time("DxParser._parse "+this.name);var t=this.volume,e=this.streamer.peekLines(30),i=this.parseHeaderLines(e),r=this.volume.header,c=i.dataLineStart,u=r.nx*r.ny*r.nz,h=new Float32Array(u),l=0,p=0;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){if(l<u&&c<p){var n=i[r].trim();if(""!==n)for(var o=n.split(aE),a=0,s=o.length;a<s;++a)h[l]=parseFloat(o[a]),++l}++p}}(0,t.length,t)}),t.setData(h,r.nz,r.ny,r.nx),de.Debug&&Yp.timeEnd("DxParser._parse "+this.name)},e.prototype.parseHeaderLines=function(t){for(var e={},i=t.length,r=0,n=0,o=0,a=0;a<i;++a){var s=void 0,c=t[a];if(c.startsWith("object 1"))s=c.split(aE),e.nx=parseInt(s[5]),e.ny=parseInt(s[6]),e.nz=parseInt(s[7]);else if(c.startsWith("origin"))s=c.split(aE),e.xmin=parseFloat(s[1]),e.ymin=parseFloat(s[2]),e.zmin=parseFloat(s[3]);else if(c.startsWith("delta"))s=c.split(aE),0===o?e.hx=parseFloat(s[1])*this.voxelSize:1===o?e.hy=parseFloat(s[2])*this.voxelSize:2===o&&(e.hz=parseFloat(s[3])*this.voxelSize),o+=1;else if(c.startsWith("object 3")){r=a,n+=c.length+1;break}n+=c.length+1}return this.volume.header=e,{dataLineStart:r,headerByteCount:n}},e.prototype.getMatrix=function(){var t=this.volume.header,e=new ei;return e.multiply((new ei).makeRotationY(Gl(90))),e.multiply((new ei).makeTranslation(-t.zmin,t.ymin,t.xmin)),e.multiply((new ei).makeScale(-t.hz,t.hy,t.hx)),e},Object.defineProperties(e.prototype,i),e}(tE);id.add("dx",sE);var cE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"dxbin"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("DxbinParser._parse "+this.name);for(var t=Rl(this.streamer.data),e=function(t,e,i){void 0===e&&(e=10485760),void 0===i&&(i="\n");for(var r="",n=[],o=0;o<t.length;o+=e){var a=Il(t.subarray(o,o+e)),s=a.lastIndexOf(i);if(-1===s)r+=a;else{var c=r+a.substr(0,s);n=n.concat(c.split(i)),r=s===a.length-i.length?"":a.substr(s+i.length)}}return""!==r&&n.push(r),n}(new Uint8Array(t,0,1e3)),i=this.parseHeaderLines(e),r=this.volume.header,n=i.headerByteCount,o=r.nx*r.ny*r.nz,a=new DataView(t),s=new Float32Array(o),c=0;c<o;++c)s[c]=a.getFloat64(8*c+n,!0);this.volume.setData(s,r.nz,r.ny,r.nx),de.Debug&&Yp.timeEnd("DxbinParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(sE);id.add("dxbin",cE);var uE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},isBinary:{configurable:!0}};return i.type.get=function(){return"mrc"},i.isBinary.get=function(){return!0},e.prototype._parse=function(){de.Debug&&Yp.time("MrcParser._parse "+this.name);var t,e=this.volume,i={},r=Rl(this.streamer.data),n=new Int32Array(r,0,56),o=new Float32Array(r,0,56),a=new DataView(r);if(i.MAP=String.fromCharCode(a.getUint8(208),a.getUint8(209),a.getUint8(210),a.getUint8(211)),i.MACHST=[a.getUint8(212),a.getUint8(213)],17===i.MACHST[0]&&17===i.MACHST[1])for(var s=r.byteLength,c=0;c<s;c+=4)a.setFloat32(c,a.getFloat32(c),!0);if(i.NX=n[0],i.NY=n[1],i.NZ=n[2],i.MODE=n[3],i.NXSTART=n[4],i.NYSTART=n[5],i.NZSTART=n[6],i.MX=n[7],i.MY=n[8],i.MZ=n[9],i.xlen=o[10]*this.voxelSize,i.ylen=o[11]*this.voxelSize,i.zlen=o[12]*this.voxelSize,i.alpha=o[13],i.beta=o[14],i.gamma=o[15],i.MAPC=n[16],i.MAPR=n[17],i.MAPS=n[18],i.DMIN=o[19],i.DMAX=o[20],i.DMEAN=o[21],i.ISPG=n[22],i.NSYMBT=n[23],i.LSKFLG=n[24],i.originX=o[49],i.originY=o[50],i.originZ=o[51],i.ARMS=o[54],2===(e.header=i).MODE)t=new Float32Array(r,1024+i.NSYMBT,i.NX*i.NY*i.NZ);else if(0===i.MODE){if(t=new Float32Array(new Int8Array(r,1024+i.NSYMBT,i.NX*i.NY*i.NZ)),-128===n[39]&&127===n[40])for(var u=(i.DMAX-i.DMIN)/255,h=.5*(i.DMIN+i.DMAX+u),l=0,p=t.length;l<p;++l)t[l]=u*t[l]+h}else Yp.error("MrcParser unknown mode",i.MODE);e.setData(t,i.NX,i.NY,i.NZ),0!==i.ARMS&&e.setStats(i.DMIN,i.DMAX,i.DMEAN,i.ARMS),de.Debug&&Yp.timeEnd("MrcParser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=[t.xlen,0,0],i=[t.ylen*Math.cos(Math.PI/180*t.gamma),t.ylen*Math.sin(Math.PI/180*t.gamma),0],r=[t.zlen*Math.cos(Math.PI/180*t.beta),t.zlen*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.zlen*t.zlen*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[[],e,i,r],o=[0,t.MX,t.MY,t.MZ],a=[0,t.MAPC,t.MAPR,t.MAPS],s=new ei;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.setPosition(new ri(t.originX,t.originY,t.originZ)),s.multiply((new ei).makeTranslation(t.NXSTART,t.NYSTART,t.NZSTART)),s},Object.defineProperties(e.prototype,i),e}(tE);id.add("mrc",uE),id.add("ccp4",uE),id.add("map",uE);var hE=/\s+/;function lE(t){return t.trim().split(hE).map(parseFloat)}var pE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"xplor"},e.prototype._parse=function(){de.Debug&&Yp.time("XplorParser._parse "+this.name);var t,e=this.volume,i=this.streamer.peekLines(8),u={},h=(t=i[2].startsWith("REMARKS")?parseInt(i[1].substring(0,8))+2:5)+3,r=lE(i[t]);u.NA=r[0],u.AMIN=r[1],u.AMAX=r[2],u.NB=r[3],u.BMIN=r[4],u.BMAX=r[5],u.NC=r[6],u.CMIN=r[7],u.CMAX=r[8];var n=lE(i[t+1]);u.a=n[0]*this.voxelSize,u.b=n[1]*this.voxelSize,u.c=n[2]*this.voxelSize,u.alpha=n[3],u.beta=n[4],u.gamma=n[5];var o=u.AMAX-u.AMIN+1,a=u.BMAX-u.BMIN+1,s=u.CMAX-u.CMIN+1,l=o*a*s,p=new Float32Array(l),d=Math.ceil(1+o*a/6),f=0,m=0;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r];if(h<=m&&(m-h)%d!=0&&f<l)for(var o=0;o<6;++o){var a=parseFloat(n.substr(12*o,12));if(isNaN(a))break;p[f++]=a}else if(f===l){var s=n.trim();if(s&&"-9999"!==s){var c=lE(n);u.RAVE=c[0],u.RSIGMA=c[1]}}++m}}(0,t.length,t)}),e.header=u,e.setData(p,o,a,s),0!==u.RAVE&&1!==u.RSIGMA&&e.setStats(void 0,void 0,u.RAVE,u.RSIGMA),de.Debug&&Yp.timeEnd("XplorParser._parse "+this.name)},e.prototype.getMatrix=function(){var t=this.volume.header,e=[t.a,0,0],i=[t.b*Math.cos(Math.PI/180*t.gamma),t.b*Math.sin(Math.PI/180*t.gamma),0],r=[t.c*Math.cos(Math.PI/180*t.beta),t.c*(Math.cos(Math.PI/180*t.alpha)-Math.cos(Math.PI/180*t.gamma)*Math.cos(Math.PI/180*t.beta))/Math.sin(Math.PI/180*t.gamma),0];r[2]=Math.sqrt(t.c*t.c*Math.sin(Math.PI/180*t.beta)*Math.sin(Math.PI/180*t.beta)-r[1]*r[1]);var n=[[],e,i,r],o=[0,t.NA,t.NB,t.NC],a=[0,1,2,3],s=new ei;return s.set(n[a[1]][0]/o[a[1]],n[a[2]][0]/o[a[2]],n[a[3]][0]/o[a[3]],0,n[a[1]][1]/o[a[1]],n[a[2]][1]/o[a[2]],n[a[3]][1]/o[a[3]],0,n[a[1]][2]/o[a[1]],n[a[2]][2]/o[a[2]],n[a[3]][2]/o[a[3]],0,0,0,0,1),s.multiply((new ei).makeTranslation(t.AMIN,t.BMIN,t.CMIN)),s},Object.defineProperties(e.prototype,i),e}(tE);function dE(t,e,i){var r,n,o;t/=360,e/=100,i/=100;var a=Math.floor(6*t),s=6*t-a,c=i*(1-e),u=i*(1-s*e),h=i*(1-(1-s)*e);switch(a%6){case 0:r=i,n=h,o=c;break;case 1:r=u,n=i,o=c;break;case 2:r=c,n=i,o=h;break;case 3:r=c,n=u,o=i;break;case 4:r=h,n=c,o=i;break;case 5:r=i,n=c,o=u}return[r,n,o]}id.add("xplor",pE),id.add("cns",pE);var fE={red:dE(0,100,100),orange:dE(20,100,100),gold:dE(40,100,100),yellow:dE(60,100,100),lime:dE(80,100,100),green:dE(120,80,100),sea:dE(150,100,100),cyan:dE(180,100,85),sky:dE(210,75,95),blue:dE(240,70,100),purple:dE(275,75,100),magenta:dE(300,95,100),hotpink:dE(335,100,100),pink:dE(350,55,100),peach:dE(25,75,100),lilac:dE(275,55,100),pinktint:dE(340,30,100),peachtint:dE(25,50,100),yellowtint:dE(60,50,100),greentint:dE(135,40,100),bluetint:dE(220,40,100),lilactint:dE(275,35,100),white:dE(0,0,100),gray:dE(0,0,50),brown:dE(20,45,75),deadwhite:[1,1,1],deadblack:[0,0,0],invisible:[0,0,0]},mE=/[\s,]+/,gE=/[^{}\s]*{[^{}]+}|[^{}\s]+/g,vE=/^{+|}+$/g,yE=/^['"]+|['"]+$/g,bE=/\s*=\s*/g;function xE(t){for(var e,i,r,n=[],o=(t=t.replace(bE,"=")).match(gE),a=1;a<o.length;++a){var s=o[a];if("{"===s[0])e=s.substring(1,s.length-1);else{var c=s.split("=");2===c.length&&("color"===c[0]?i=fE[c[1]]:"width"===c[0]?r=parseInt(c[1]):"master"===c[0]&&n.push(c[1].replace(vE,"")))}}return{listName:e,listColor:i,listMasters:n,listWidth:r}}function _E(t){for(var e,i,r,n=(t=t.trim()).indexOf("{"),o=t.indexOf("}"),a=t.substr(o+1).split(mE),s=t.substr(n+1,o-1),c=[parseFloat(a[a.length-3]),parseFloat(a[a.length-2]),parseFloat(a[a.length-1])],u=4;u<=a.length;u++){var h=a[a.length-u];h in fE&&(e=fE[a[a.length-u]]),h.startsWith("width")&&(i=parseInt(h.substring(5))),h.startsWith("r=")&&(r=parseFloat(h.split("=")[1]))}return{label:s,position:c,color:e,radius:r,width:i}}function wE(t){var e=t.indexOf("{"),i=t.indexOf("}");return t.substring(-1!==e?e+1:0,-1!==i?i:void 0).trim()}function SE(t){for(var e,i={},r=(t=t.replace(bE,"=")).match(gE),n=1;n<r.length;++n){var o=r[n];if("{"===o[0])e=o.substring(1,o.length-1);else{var a=o.split("=");2===a.length?i[a[0]]=a[1].replace(vE,""):i[a[0]]=!0}}return[e,i]}var AE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0},__objName:{configurable:!0}};return i.type.get=function(){return"kin"},i.__objName.get=function(){return"kinemage"},e.prototype._parse=function(){de.Debug&&Yp.time("KinParser._parse "+this.name);var ut={kinemage:void 0,onewidth:void 0,"1viewid":void 0,pdbfile:void 0,texts:[],text:"",captions:[],caption:"",groupDict:{},subgroupDict:{},masterDict:{},pointmasterDict:{},dotLists:[],vectorLists:[],ballLists:[],ribbonLists:[]};this.kinemage=ut;var ht,lt,pt,dt,ft,mt,gt,vt,yt,bt,xt,_t,wt,St,At,Mt,Et,Pt,Tt,Ct,It,Ot,Lt,Rt=!1,Dt="",kt=!1,Bt="",Nt=!1,Ft="",zt=!1,Ut="",jt=!1,Gt=!1;if(this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var r=t;r<e;++r){var n=i[r];if("@"===n[0]&&(Gt=jt=zt=Nt=kt=Rt=!1),n)if(n.startsWith("@dotlist")){var o=xE(n),a=o.listColor,s=o.listName,c=o.listMasters;Rt=!0,Dt="",lt=[],pt=[],dt=[],ht=a,ut.dotLists.push({name:s,masterArray:c,labelArray:lt,positionArray:pt,colorArray:dt})}else if(n.startsWith("@vectorlist")){var u=xE(n),h=u.listMasters,l=u.listName,p=u.listWidth,d=u.listColor;h&&h.forEach(function(t){ut.masterDict[t]||(ut.masterDict[t]={indent:!1,visible:!1})}),kt=!0,Bt="",mt=ft=null,yt=[],bt=[],xt=[],_t=[],wt=[],St=[],gt=d,vt=[],p&&vt.push(p),ut.vectorLists.push({name:l,masterArray:h,label1Array:yt,label2Array:bt,position1Array:xt,position2Array:_t,color1Array:wt,color2Array:St,width:vt})}else if(n.startsWith("@balllist")){var f=xE(n),m=f.listName,g=f.listColor,v=f.listMasters;v&&v.forEach(function(t){ut.masterDict[t]||(ut.masterDict[t]={indent:!1,visible:!1})}),Nt=!0,Ft="",Et=[],At=[],Pt=[],Tt=[],Mt=g,ut.ballLists.push({name:m,masterArray:v,labelArray:Et,radiusArray:At,positionArray:Pt,colorArray:Tt})}else if(n.startsWith("@ribbonlist")){var y=xE(n),b=y.listMasters,x=y.listName,_=y.listColor;b&&b.forEach(function(t){ut.masterDict[t]||(ut.masterDict[t]={indent:!1,visible:!1})}),zt=!0,Ut="",It=[],Ot=[],Lt=[],Ct=_,ut.ribbonLists.push({name:x,masterArray:b,labelArray:It,positionArray:Ot,colorArray:Lt})}else if(n.startsWith("@text"))jt=!0,ut.texts.push(n.substr(5));else if(n.startsWith("@caption"))Gt=!0,ut.captions.push(n.substr(8));else if(Rt){var w=_E(n),S=w.label,A=w.color,M=w.position;'"'===S?S=Dt:Dt=S,void 0===A&&(A=ht),lt.push(S),pt.push.apply(pt,M),dt.push.apply(dt,A)}else if(kt){var E=n.indexOf("{"),P=n.indexOf("{",E+1),T=void 0,C=void 0;-1===P?C=T=n:(T=n.substr(0,P),C=n.substr(P));var I=_E(T),O=I.label,L=I.color,R=I.width,D=I.position;if('"'===O?O=Bt:Bt=O,void 0===L&&(L=gt),R&&vt.push(R),yt.push(O),xt.push.apply(xt,D),wt.push.apply(wt,L),-1===P&&ft)bt.push(Bt),_t.push.apply(_t,ft),St.push.apply(St,mt),Bt=O,ft=D,mt=L;else{var k=_E(C),B=k.label,N=k.color,F=k.position;'"'===B?B=Bt:Bt=B,void 0===N&&(N=gt),bt.push(B),_t.push.apply(_t,F),St.push.apply(St,N),ft=F,mt=N}}else if(Nt){var z=_E(n),U=z.label,j=z.radius,G=z.color,V=z.position;'"'===U?U=Ft:Ft=U,void 0===j&&(j=1),void 0===G&&(G=Mt),Et.push(U),At.push(j),Pt.push.apply(Pt,V),Tt.push.apply(Tt,G)}else if(zt){var H=_E(n),$=H.label,W=H.color,X=H.position;'"'===$?$=Ut:Ut=$,void 0===W&&(W=Ct),It.push($),Ot.push.apply(Ot,X),Lt.push.apply(Lt,W)}else if(jt)ut.texts.push(n);else if(Gt)ut.captions.push(n);else if(n.startsWith("@kinemage"))ut.kinemage=parseInt(n.substr(9).trim());else if(n.startsWith("@onewidth"))ut.onewidth=!0;else if(n.startsWith("@1viewid"))ut["1viewid"]=wE(n);else if(n.startsWith("@pdbfile"))ut.pdbfile=wE(n);else if(n.startsWith("@group")){var q=SE(n),Y=q[0],Z=q[1];for(var K in ut.groupDict[Y]||(ut.groupDict[Y]={dominant:!1,animate:!1}),Z)ut.groupDict[Y][K]=Z[K]}else if(n.startsWith("@subgroup")){var J=SE(n),Q=J[0],tt=J[1];for(var et in ut.subgroupDict[Q]||(ut.subgroupDict[Q]={dominant:!1,animate:!1,master:void 0}),tt)ut.subgroupDict[Q][et]=tt[et]}else if(n.startsWith("@master")){var it=wE(n),rt=-1===(ct=(st=n).indexOf("}"))?void 0:st.substr(ct+1).trim();ut.masterDict[it]||(ut.masterDict[it]={indent:!1,visible:!1}),"on"===rt?ut.masterDict[it].visible=!0:"off"===rt?ut.masterDict[it].visible=!1:"indent"===rt&&(ut.masterDict[it].indent=!0)}else if(n.startsWith("@pointmaster")){var nt=SE(n),ot=nt[0],at=nt[1];ut.pointmasterDict[ot]={id:Object.keys(at)[0].replace(yE,"")}}else console.log(n);else zt=Nt=kt=Rt=!1}var st,ct}(0,t.length,t)}),ut.text=ut.texts.join("\n").trim(),ut.caption=ut.captions.join("\n").trim(),ut.ribbonLists){var e=[];ut.ribbonLists.forEach(function(t){e.push(function(t){for(var e=t.labelArray,i=t.positionArray,r=t.colorArray,n=[],o=0;o<3*(e.length-2);++o)n[o]=e[o-2*Math.floor(o/3)];for(var a=[],s=0;s<9*(i.length/3-2);++s)a[s]=i[s-6*Math.floor(s/9)];for(var c=[],u=0;u<9*(r.length/3-2);++u)c[u]=r[u-6*Math.floor(u/9)];return{name:t.name,masterArray:t.masterArray,labelArray:n,positionArray:a,colorArray:c}}(t))}),ut.ribbonLists=e}de.Debug&&Yp.timeEnd("KinParser._parse "+this.name)},Object.defineProperties(e.prototype,i),e}(wA);id.add("kin",AE);var ME=function(i){function t(t,e){i.call(this,t,e),this.loader=this.getLoader(),this.surface=new ry(this.name,this.path)}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0}};return e.type.get=function(){return"surface"},e.__objName.get=function(){return"surface"},t.prototype._parse=function(){var t=this.loader.parse(this.streamer.asText());this.surface.fromGeometry(t)},Object.defineProperties(t.prototype,e),t}(wA),EE=function(){this.regexp={vertex_pattern:/^v\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,normal_pattern:/^vn\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,uv_pattern:/^vt\s+([\d.+\-eE]+)\s+([\d.+\-eE]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /}};EE.prototype={constructor:EE,setPath:function(t){this.path=t},_createParserState:function(){var t={objects:[],object:{},vertices:[],normals:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);this.object={name:t||"",geometry:{vertices:[],normals:[]},fromDeclaration:!1!==e},this.objects.push(this.object)},parseVertexIndex:function(t,e){var i=parseInt(t,10);return 3*(0<=i?i-1:i+e/3)},parseNormalIndex:function(t,e){var i=parseInt(t,10);return 3*(0<=i?i-1:i+e/3)},addVertex:function(t,e,i){var r=this.vertices,n=this.object.geometry.vertices;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[i+0]),n.push(r[i+1]),n.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,n=this.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[e+0]),n.push(r[e+1]),n.push(r[e+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2])},addFace:function(t,e,i,r,n,o,a,s){var c,u=this.vertices.length,h=this.parseVertexIndex(t,u),l=this.parseVertexIndex(e,u),p=this.parseVertexIndex(i,u);if(void 0===r?this.addVertex(h,l,p):(c=this.parseVertexIndex(r,u),this.addVertex(h,l,c),this.addVertex(l,p,c)),void 0!==n){var d=this.normals.length;h=this.parseNormalIndex(n,d),l=n===o?h:this.parseNormalIndex(o,d),p=n===a?h:this.parseNormalIndex(a,d),void 0===r?this.addNormal(h,l,p):(c=this.parseNormalIndex(s,d),this.addNormal(h,l,c),this.addNormal(l,p,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,r=t.length;i<r;i++)this.addVertexLine(this.parseVertexIndex(t[i],e))}};return t.startObject("",!1),t},parse:function(t){var e,i,r=this,n=this._createParserState();-1!==t.indexOf("\r\n")&&(t=t.replace(/\r\n/g,"\n")),-1!==t.indexOf("\\\n")&&(t=t.replace(/\\\n/g,""));var o=t.split("\n"),a="",s="",c="",u=[],h="function"==typeof"".trimLeft;for(e=0,i=o.length;e<i;e++)if(a=o[e],0!==(a=h?a.trimLeft():a.trim()).length&&"#"!==(s=a.charAt(0)))if("v"===s){if(" "===(c=a.charAt(1))&&null!==(u=r.regexp.vertex_pattern.exec(a)))n.vertices.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));else if("n"===c&&null!==(u=r.regexp.normal_pattern.exec(a)))n.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));else if("t"!==c||null===r.regexp.uv_pattern.exec(a))throw new Error("Unexpected vertex/normal/uv line: '"+a+"'")}else if("f"===s)if(null!==(u=r.regexp.face_vertex_uv_normal.exec(a)))n.addFace(u[1],u[4],u[7],u[10],u[3],u[6],u[9],u[12]);else if(null!==r.regexp.face_vertex_uv.exec(a));else if(null!==(u=r.regexp.face_vertex_normal.exec(a)))n.addFace(u[1],u[3],u[5],u[7],u[2],u[4],u[6],u[8]);else{if(null===(u=r.regexp.face_vertex.exec(a)))throw new Error("Unexpected face line: '"+a+"'");n.addFace(u[1],u[2],u[3],u[4])}else if("l"===s){var l=a.substring(1).trim().split(" "),p=[],d=[];if(-1===a.indexOf("/"))p=l;else for(var f=0,m=l.length;f<m;f++){var g=l[f].split("/");""!==g[0]&&p.push(g[0]),""!==g[1]&&d.push(g[1])}n.addLineGeometry(p,d)}else if(null!==(u=r.regexp.object_pattern.exec(a))){var v=u[0].substr(1).trim();n.startObject(v)}else if(r.regexp.material_use_pattern.test(a));else if(r.regexp.material_library_pattern.test(a));else if(null===r.regexp.smoothing_pattern.exec(a)){if("\0"===a)continue;throw new Error("Unexpected line: '"+a+"'")}var y=[];for(e=0,i=n.objects.length;e<i;e++){var b=n.objects[e].geometry;if(0!==b.vertices.length){var x=new $r;x.addAttribute("position",new wr(new Float32Array(b.vertices),3)),0<b.normals.length?x.addAttribute("normal",new wr(new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};var PE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"obj"},e.prototype.getLoader=function(){return new EE},Object.defineProperties(e.prototype,i),e}(ME);id.add("obj",PE);var TE=function(){this.propertyNameMapping={}};TE.prototype={constructor:TE,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r<t.byteLength;r++)i+=String.fromCharCode(e[r]);return i},isASCII:function(t){return"ascii"===this.parseHeader(this.bin2str(t)).format},parse:function(t){return t instanceof ArrayBuffer?this.isASCII(t)?this.parseASCII(this.bin2str(t)):this.parseBinary(t):this.parseASCII(t)},parseHeader:function(t){var e="",i=0,r=/ply([\s\S]*)end_header\s/.exec(t);null!==r&&(e=r[1],i=r[0].length);var n,o,a,s,c,u,h={comments:[],elements:[],headerLength:i},l=e.split("\n");for(var p=0;p<l.length;p++){var d=l[p];if(""!==(d=d.trim()))switch(o=(a=d.split(/\s+/)).shift(),d=a.join(" "),o){case"format":h.format=a[0],h.version=a[1];break;case"comment":h.comments.push(d);break;case"element":void 0!==n&&h.elements.push(n),(n={}).name=a[0],n.count=parseInt(a[1]),n.properties=[];break;case"property":n.properties.push((s=a,c=this.propertyNameMapping,u=void 0,"list"===(u={type:s[0]}).type?(u.name=s[3],u.countType=s[1],u.itemType=s[2]):u.name=s[1],u.name in c&&(u.name=c[u.name]),u));break;default:console.log("unhandled",o,a)}}return void 0!==n&&h.elements.push(n),h},parseASCIINumber:function(t,e){switch(e){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(t);case"float":case"double":case"float32":case"float64":return parseFloat(t)}},parseASCIIElement:function(t,e){for(var i=e.split(/\s+/),r={},n=0;n<t.length;n++)if("list"===t[n].type){for(var o=[],a=this.parseASCIINumber(i.shift(),t[n].countType),s=0;s<a;s++)o.push(this.parseASCIINumber(i.shift(),t[n].itemType));r[t[n].name]=o}else r[t[n].name]=this.parseASCIINumber(i.shift(),t[n].type);return r},parseASCII:function(t){var e,i=new _r,r=this.parseHeader(t),n="";null!==(e=/end_header\s([\s\S]*)$/.exec(t))&&(n=e[1]);var o=n.split("\n"),a=0,s=0;i.useColor=!1;for(var c=0;c<o.length;c++){var u=o[c];if(""!==(u=u.trim())){s>=r.elements[a].count&&(a++,s=0);var h=this.parseASCIIElement(r.elements[a].properties,u);this.handleElement(i,r.elements[a].name,h),s++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e<t.faces.length;e++)t.faces[e].vertexColors=[t.colors[t.faces[e].a],t.colors[t.faces[e].b],t.colors[t.faces[e].c]];t.elementsNeedUpdate=!0}return t.computeBoundingSphere(),t},handleElement:function(t,e,i){if("vertex"===e){if(t.vertices.push(new ri(i.x,i.y,i.z)),"red"in i&&"green"in i&&"blue"in i){t.useColor=!0;var r=new ki;r.setRGB(i.red/255,i.green/255,i.blue/255),t.colors.push(r)}}else if("face"===e){var n=i.vertex_indices;3===n.length?t.faces.push(new pr(n[0],n[1],n[2])):4===n.length&&t.faces.push(new pr(n[0],n[1],n[3]),new pr(n[1],n[2],n[3]))}},binaryRead:function(t,e,i,r){switch(i){case"int8":case"char":return[t.getInt8(e),1];case"uint8":case"uchar":return[t.getUint8(e),1];case"int16":case"short":return[t.getInt16(e,r),2];case"uint16":case"ushort":return[t.getUint16(e,r),2];case"int32":case"int":return[t.getInt32(e,r),4];case"uint32":case"uint":return[t.getUint32(e,r),4];case"float32":case"float":return[t.getFloat32(e,r),4];case"float64":case"double":return[t.getFloat64(e,r),8]}},binaryReadElement:function(t,e,i,r){for(var n,o={},a=0,s=0;s<i.length;s++)if("list"===i[s].type){var c=[],u=(n=this.binaryRead(t,e+a,i[s].countType,r))[0];a+=n[1];for(var h=0;h<u;h++)n=this.binaryRead(t,e+a,i[s].itemType,r),c.push(n[0]),a+=n[1];o[i[s].name]=c}else n=this.binaryRead(t,e+a,i[s].type,r),o[i[s].name]=n[0],a+=n[1];return[o,a]},parseBinary:function(t){for(var e,i=new _r,r=this.parseHeader(this.bin2str(t)),n="binary_little_endian"===r.format,o=new DataView(t,r.headerLength),a=0,s=0;s<r.elements.length;s++)for(var c=0;c<r.elements[s].count;c++){a+=(e=this.binaryReadElement(o,a,r.elements[s].properties,n))[1];var u=e[0];this.handleElement(i,r.elements[s].name,u)}return this.postProcess(i)}};var CE=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var i={type:{configurable:!0}};return i.type.get=function(){return"ply"},e.prototype.getLoader=function(){return new TE},Object.defineProperties(e.prototype,i),e}(ME);id.add("ply",CE);var IE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.delimiter=bl(i.delimiter,","),this.comment=bl(i.comment,"#"),this.columnNames=bl(i.columnNames,!1),this.table={name:this.name,path:this.path,columnNames:[],data:[]}}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0}};return e.type.get=function(){return"csv"},e.__objName.get=function(){return"table"},t.prototype._parse=function(){var o=this,a=this.table.data,s=new RegExp("\\s*"+this.delimiter+"\\s*"),c=0;this.streamer.eachChunkOfLines(function(t){for(var e=t.length,i=0;i<e;++i){var r=t[i].trim();if(!r.startsWith(o.comment)){var n=r.split(s);0===c?o.table.columnNames=n:r&&a.push(n),++c}}})},Object.defineProperties(t.prototype,e),t}(wA);id.add("csv",IE);var OE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.string=bl(i.string,!1),this.json={name:this.name,path:this.path,data:{}}}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0},isJson:{configurable:!0}};return e.type.get=function(){return"json"},e.__objName.get=function(){return"json"},e.isJson.get=function(){return!0},t.prototype._parse=function(){this.streamer.isBinary()||this.string?this.json.data=JSON.parse(this.streamer.asText()):this.json.data=this.streamer.data},Object.defineProperties(t.prototype,e),t}(wA);id.add("json",OE);var LE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.msgpack={name:this.name,path:this.path,data:void 0}}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0},isBinary:{configurable:!0}};return e.type.get=function(){return"msgpack"},e.__objName.get=function(){return"msgpack"},e.isBinary.get=function(){return!0},t.prototype._parse=function(){de.Debug&&Yp.time("MsgpackParser._parse "+this.name),this.msgpack.data=oM(this.streamer.data),de.Debug&&Yp.timeEnd("MsgpackParser._parse "+this.name)},Object.defineProperties(t.prototype,e),t}(wA);id.add("msgpack",LE);var RE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.netcdf={name:this.name,path:this.path,data:void 0}}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0},isBinary:{configurable:!0}};return e.type.get=function(){return"netcdf"},e.__objName.get=function(){return"netcdf"},e.isBinary.get=function(){return!0},t.prototype._parse=function(){de.Debug&&Yp.time("NetcdfParser._parse "+this.name),this.netcdf.data=new GM(this.streamer.data),de.Debug&&Yp.timeEnd("NetcdfParser._parse "+this.name)},Object.defineProperties(t.prototype,e),t}(wA);id.add("netcdf",RE);var DE=function(i){function t(t,e){i.call(this,t,e),this.text={name:this.name,path:this.path,data:""}}i&&(t.__proto__=i),(t.prototype=Object.create(i&&i.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0}};return e.type.get=function(){return"text"},e.__objName.get=function(){return"text"},t.prototype._parse=function(){this.text.data=this.streamer.asText()},Object.defineProperties(t.prototype,e),t}(wA);id.add("txt",DE),id.add("text",DE);var kE=/^['"]|['"]$/g,BE=/^<([\w-:.]+)\s*/,NE=/^([^<]*)/,FE=/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/;function zE(i){return i=i.trim().replace(/<!--[\s\S]*?-->/g,""),{declaration:function(){if(s(/^<\?xml\s*/)){for(var t={attributes:{}};!c()&&!u("?>");){var e=a();if(!e)return t;t.attributes[e.name]=e.value}return s(/\?>\s*/),t}}(),root:function t(){var e=s(BE);if(e){for(var i,r,n={name:e[1],attributes:{},children:[]};!(c()||u(">")||u("?>")||u("/>"));){var o=a();if(!o)return n;n.attributes[o.name]=o.value}if(s(/^\s*\/>\s*/))return n;for(s(/\??>\s*/),n.content=(i=s(NE))?i[1]:"";r=t();)n.children.push(r);return s(/^<\/[\w-:.]+>\s*/),n}}()};function a(){var t,e=s(FE);if(e)return{name:e[1],value:(t=e[2],t.replace(kE,""))}}function s(t){var e=i.match(t);if(e)return i=i.slice(e[0].length),e}function c(){return 0===i.length}function u(t){return 0===i.indexOf(t)}}var UE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.useDomParser=bl(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={type:{configurable:!0},__objName:{configurable:!0},isXml:{configurable:!0}};return e.type.get=function(){return"xml"},e.__objName.get=function(){return"xml"},e.isXml.get=function(){return!0},t.prototype.__xmlParser=function(t){return zE(t)},t.prototype.__domParser=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")},t.prototype._parse=function(){de.Debug&&Yp.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.Debug&&Yp.timeEnd("XmlParser._parse "+this.name)},Object.defineProperties(t.prototype,e),t}(wA);function jE(t,e){var i=t.getNamedItem(e);return null!==i?i.value:""}function GE(t,e,i){void 0===i&&(i=!1);var r=jE(t,"icode").trim(),n=jE(t,"chain").trim(),o=jE(t,"altcode"),a=jE(t,"resnum");return r&&(a+="^"+r),n&&(a+=":"+n),e&&(a+="."+e),i&&o.trim()&&(a+="%"+o),a+="/"+(parseInt(jE(t,"model"))-1)}function VE(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function HE(t,e){return null!==t&&t.value===e}function $E(t,e,i){for(var r=0,n=e.getElementsByTagName("clash"),o=0,a=n.length;o<a;++o)if(t[jE(n[o].attributes,"cid")]){r+=1;break}return 0<e.getElementsByTagName("angle-outlier").length&&(r+=1),0<e.getElementsByTagName("bond-outlier").length&&(r+=1),0<e.getElementsByTagName("plane-outlier").length&&(r+=1),HE(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),HE(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),HE(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}id.add("xml",UE);var WE=function(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"},XE={type:{configurable:!0}};XE.type.get=function(){return"validation"},WE.prototype.fromXml=function(t){de.Debug&&Yp.time("Validation.fromXml");var e,i,r,n=this.rsrzDict,o=this.rsccDict,a=this.rciDict,s=this.clashDict,c=this.clashArray,u=this.geoDict,h=this.geoAtomDict,l=this.atomDict,p=t.getElementsByTagName("Entry");if(1===p.length){var d=p[0].getElementsByTagName("chemical_shift_list");if(1===d.length)for(var f=d[0].getElementsByTagName("random_coil_index"),m=0,g=f.length;m<g;++m){var v=f[m].attributes;a[(r=void 0,i=jE(e=v,"chain").trim(),r="["+jE(e,"rescode")+"]"+jE(e,"resnum"),i&&(r+=":"+i),r)]=parseFloat(jE(v,"value"))}}var y=t.getElementsByTagName("ModelledSubgroup"),b={},x=[];de.Debug&&Yp.time("Validation.fromXml#clashDict");for(var _=0,w=y.length;_<w;++_){var S=y[_],A=S.attributes,M=GE(A);null!==A.getNamedItem("rsrz")&&(n[M]=parseFloat(jE(A,"rsrz"))),null!==A.getNamedItem("rscc")&&(o[M]=parseFloat(jE(A,"rscc")));var E=t.createAttribute("sele");E.value=M,A.setNamedItem(E);for(var P=S.getElementsByTagName("clash"),T=0,C=P.length;T<C;++T){var I=P[T].attributes,O=jE(I,"atom");if("H"!==Rb(O)){var L=jE(I,"cid"),R=GE(A,O,!0);if(l[R]=!0,void 0===b[L])b[L]={sele1:R,res1:M};else{var D=b[L];D.res1!==M&&(D.sele2=R,D.res2=M,x.push(D.res1,M),s[L]=D,c.push(D))}}}}de.Debug&&Yp.timeEnd("Validation.fromXml#clashDict");for(var k=0,B=y.length;k<B;++k){var N=y[k],F=N.attributes,z=jE(F,"sele");if("."!==jE(F,"seq")){var U=$E(s,N,F);0<U&&(u[z]=U)}else{var j=N.getElementsByTagName("clash"),G=N.getElementsByTagName("mog-bond-outlier"),V=N.getElementsByTagName("mog-angle-outlier");if(0<G.length||0<V.length||0<j.length){var H={};h[z]=H;for(var $=0,W=j.length;$<W;++$){var X=j[$].attributes;s[jE(X,"cid")]&&VE(H,jE(X,"atom"),1)}for(var q=0,Y=G.length;q<Y;++q){jE(G[q].attributes,"atoms").split(",").forEach(function(t){VE(H,t,2)})}for(var Z=0,K=V.length;Z<K;++Z){jE(V[Z].attributes,"atoms").split(",").forEach(function(t){VE(H,t,4)})}}}}this.clashSele=x.length?x.join(" OR "):"NONE",de.Debug&&Yp.timeEnd("Validation.fromXml")},WE.prototype.getClashData=function(t){de.Debug&&Yp.time("Validation.getClashData");var e=t||{},i=e.structure,o=i.atomSet,r=new ki(bl(e.color,"#f0027f")),a=i.getAtomProxy(),s=i.getAtomProxy(),c=new ri,u=new ri,h=new ri,n=this.clashArray,l=n.length,p=new Float32Array(3*l),d=new Float32Array(3*l),f=Vd(l,r.r,r.g,r.b),m=new Float32Array(l),g=new Float32Array(l);de.Debug&&Yp.time("Validation.getClashData#atomDict");var v=this.atomDict;i.eachAtom(function(t){var e,i,r,n,o,a,s=(i=(e=t).inscode,r=e.chainname,n=e.atomname,o=e.altloc,a=e.resno+"",i&&(a+="^"+i),r&&(a+=":"+r),n&&(a+="."+n),o&&(a+="%"+o),a+="/"+e.modelIndex);!0===v[s]&&(v[s]=t.index)}),de.Debug&&Yp.timeEnd("Validation.getClashData#atomDict");var y=0;return n.forEach(function(t,e){if(a.index=v[t.sele1],s.index=v[t.sele2],void 0!==a.index&&void 0!==s.index&&o.isSet(a.index,s.index)){c.subVectors(s,a).setLength(a.vdw),u.copy(a).add(c),c.subVectors(a,s).setLength(s.vdw),h.copy(s).add(c);var i=a.distanceTo(s)/2,r=Math.sqrt(a.vdw*a.vdw-i*i),n=Math.sqrt(s.vdw*s.vdw-i*i);u.toArray(p,3*y),h.toArray(d,3*y),m[y]=(r+n)/2,g[y]=e,++y}}),de.Debug&&Yp.timeEnd("Validation.getClashData"),{position1:p.subarray(0,3*y),position2:d.subarray(0,3*y),color:f.subarray(0,3*y),color2:f.subarray(0,3*y),radius:m.subarray(0,y),picking:new mv(g.subarray(0,y),this,i)}},Object.defineProperties(WE.prototype,XE);var qE=function(r){function t(t,e){var i=e||{};r.call(this,t,i),this.useDomParser=!0,this.validation=new WE(this.name,this.path)}r&&(t.__proto__=r),(t.prototype=Object.create(r&&r.prototype)).constructor=t;var e={__objName:{configurable:!0},isXml:{configurable:!0}};return e.__objName.get=function(){return"validation"},e.isXml.get=function(){return!0},t.prototype._parse=function(){r.prototype._parse.call(this),de.Debug&&Yp.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),de.Debug&&Yp.timeEnd("ValidationParser._parse "+this.name)},Object.defineProperties(t.prototype,e),t}(UE);function YE(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)}function ZE(t,e,i,r,n){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+r),n);else for(var o=0;o<r;o++)t[n+o]=e[i+o]}function KE(t,e,i,r){for(var n=65535&t|0,o=t>>>16&65535|0,a=0;0!==i;){for(i-=a=2e3<i?2e3:i;o=o+(n=n+e[r++]|0)|0,--a;);n%=65521,o%=65521}return n|o<<16|0}id.add("validation",qE);var JE=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 QE(t,e,i,r){var n=JE,o=r+i;t^=-1;for(var a=r;a<o;a++)t=t>>>8^n[255&(t^e[a])];return-1^t}var tP=30,eP=12;function iP(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E;i=t.state,r=t.next_in,M=t.input,n=r+(t.avail_in-5),o=t.next_out,E=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),c=i.dmax,u=i.wsize,h=i.whave,l=i.wnext,p=i.window,d=i.hold,f=i.bits,m=i.lencode,g=i.distcode,v=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;t:do{f<15&&(d+=M[r++]<<f,f+=8,d+=M[r++]<<f,f+=8),b=m[d&v];e:for(;;){if(d>>>=x=b>>>24,f-=x,0===(x=b>>>16&255))E[o++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(d&(1<<x)-1)];continue e}if(32&x){i.mode=eP;break t}t.msg="invalid literal/length code",i.mode=tP;break t}_=65535&b,(x&=15)&&(f<x&&(d+=M[r++]<<f,f+=8),_+=d&(1<<x)-1,d>>>=x,f-=x),f<15&&(d+=M[r++]<<f,f+=8,d+=M[r++]<<f,f+=8),b=g[d&y];i:for(;;){if(d>>>=x=b>>>24,f-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(d&(1<<x)-1)];continue i}t.msg="invalid distance code",i.mode=tP;break t}if(w=65535&b,f<(x&=15)&&(d+=M[r++]<<f,(f+=8)<x&&(d+=M[r++]<<f,f+=8)),c<(w+=d&(1<<x)-1)){t.msg="invalid distance too far back",i.mode=tP;break t}if(d>>>=x,f-=x,(x=o-a)<w){if(h<(x=w-x)&&i.sane){t.msg="invalid distance too far back",i.mode=tP;break t}if(A=p,(S=0)===l){if(S+=u-x,x<_){for(_-=x;E[o++]=p[S++],--x;);S=o-w,A=E}}else if(l<x){if(S+=u+l-x,(x-=l)<_){for(_-=x;E[o++]=p[S++],--x;);if(S=0,l<_){for(_-=x=l;E[o++]=p[S++],--x;);S=o-w,A=E}}}else if(S+=l-x,x<_){for(_-=x;E[o++]=p[S++],--x;);S=o-w,A=E}for(;2<_;)E[o++]=A[S++],E[o++]=A[S++],E[o++]=A[S++],_-=3;_&&(E[o++]=A[S++],1<_&&(E[o++]=A[S++]))}else{for(S=o-w;E[o++]=E[S++],E[o++]=E[S++],E[o++]=E[S++],2<(_-=3););_&&(E[o++]=E[S++],1<_&&(E[o++]=E[S++]))}break}}break}}while(r<n&&o<s);r-=_=f>>3,d&=(1<<(f-=_<<3))-1,t.next_in=r,t.next_out=o,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=o<s?s-o+257:257-(o-s),i.hold=d,i.bits=f}var rP=15,nP=852,oP=592,aP=0,sP=1,cP=2,uP=[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],hP=[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],lP=[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],pP=[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];function dP(t,e,i,r,n,o,a,s){var c,u,h,l,p,d,f,m,g,v=s.bits,y=0,b=0,x=0,_=0,w=0,S=0,A=0,M=0,E=0,P=0,T=null,C=0,I=new Uint16Array(rP+1),O=new Uint16Array(rP+1),L=null,R=0;for(y=0;y<=rP;y++)I[y]=0;for(b=0;b<r;b++)I[e[i+b]]++;for(w=v,_=rP;1<=_&&0===I[_];_--);if(_<w&&(w=_),0===_)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(x=1;x<_&&0===I[x];x++);for(w<x&&(w=x),y=M=1;y<=rP;y++)if(M<<=1,(M-=I[y])<0)return-1;if(0<M&&(t===aP||1!==_))return-1;for(O[1]=0,y=1;y<rP;y++)O[y+1]=O[y]+I[y];for(b=0;b<r;b++)0!==e[i+b]&&(a[O[e[i+b]]++]=b);if(t===aP?(T=L=a,d=19):t===sP?(T=uP,C-=257,L=hP,R-=257,d=256):(T=lP,L=pP,d=-1),y=x,p=o,A=b=P=0,h=-1,l=(E=1<<(S=w))-1,t===sP&&nP<E||t===cP&&oP<E)return 1;for(;;){for(f=y-A,a[b]<d?(m=0,g=a[b]):a[b]>d?(m=L[R+a[b]],g=T[C+a[b]]):(m=96,g=0),c=1<<y-A,x=u=1<<S;n[p+(P>>A)+(u-=c)]=f<<24|m<<16|g|0,0!==u;);for(c=1<<y-1;P&c;)c>>=1;if(0!==c?(P&=c-1,P+=c):P=0,b++,0==--I[y]){if(y===_)break;y=e[i+a[b]]}if(w<y&&(P&l)!==h){for(0===A&&(A=w),p+=x,M=1<<(S=y-A);S+A<_&&!((M-=I[S+A])<=0);)S++,M<<=1;if(E+=1<<S,t===sP&&nP<E||t===cP&&oP<E)return 1;n[h=P&l]=w<<24|S<<16|p-o|0}}return 0!==P&&(n[p+P]=y-A<<24|64<<16|0),s.bits=w,0}var fP=0,mP=1,gP=2,vP=4,yP=5,bP=6,xP=0,_P=1,wP=2,SP=-2,AP=-3,MP=-4,EP=-5,PP=8,TP=1,CP=2,IP=3,OP=4,LP=5,RP=6,DP=7,kP=8,BP=9,NP=10,FP=11,zP=12,UP=13,jP=14,GP=15,VP=16,HP=17,$P=18,WP=19,XP=20,qP=21,YP=22,ZP=23,KP=24,JP=25,QP=26,tT=27,eT=28,iT=29,rT=30,nT=31,oT=32,aT=852,sT=592;function cT(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function uT(){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 hT(t){var e,i,r;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,(i=t)&&i.state?(r=i.state,i.total_in=i.total_out=r.total=0,i.msg="",r.wrap&&(i.adler=1&r.wrap),r.mode=TP,r.last=0,r.havedict=0,r.dmax=32768,r.head=null,r.hold=0,r.bits=0,r.lencode=r.lendyn=new Int32Array(aT),r.distcode=r.distdyn=new Int32Array(sT),r.sane=1,r.back=-1,xP):SP):SP}function lT(t,e){var i,r,n,o,a,s;return t?(r=new uT,(t.state=r).window=null,o=e,(i=(n=t)&&n.state?(s=n.state,o<0?(a=0,o=-o):(a=1+(o>>4),o<48&&(o&=15)),o&&(o<8||15<o)?SP:(null!==s.window&&s.wbits!==o&&(s.window=null),s.wrap=a,s.wbits=o,hT(n))):SP)!==xP&&(t.state=null),i):SP}var pT,dT,fT=!0;function mT(t){if(fT){var e;for(pT=new Int32Array(512),dT=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(dP(mP,t.lens,0,288,pT,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;dP(gP,t.lens,0,32,dT,0,t.work,{bits:5}),fT=!1}t.lencode=pT,t.lenbits=9,t.distcode=dT,t.distbits=5}function gT(t,e,i,r){var n,o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),r>=o.wsize?(ZE(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(r<(n=o.wsize-o.wnext)&&(n=r),ZE(o.window,e,i-r,n,o.wnext),(r-=n)?(ZE(o.window,e,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0}function vT(t,e){var i,r,n,o,a,s,c,u,h,l,p,d,f,m,g,v,y,b,x,_,w,S,A,M,E=0,P=new Uint8Array(4),T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return SP;(i=t.state).mode===zP&&(i.mode=UP),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,r=t.input,s=t.avail_in,u=i.hold,h=i.bits,l=s,p=c,S=xP;t:for(;;)switch(i.mode){case TP:if(0===i.wrap){i.mode=UP;break}for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(2&i.wrap&&35615===u){P[i.check=0]=255&u,P[1]=u>>>8&255,i.check=QE(i.check,P,2,0),h=u=0,i.mode=CP;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",i.mode=rT;break}if((15&u)!==PP){t.msg="unknown compression method",i.mode=rT;break}if(h-=4,w=8+(15&(u>>>=4)),0===i.wbits)i.wbits=w;else if(w>i.wbits){t.msg="invalid window size",i.mode=rT;break}i.dmax=1<<w,t.adler=i.check=1,i.mode=512&u?NP:zP,h=u=0;break;case CP:for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(i.flags=u,(255&i.flags)!==PP){t.msg="unknown compression method",i.mode=rT;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=rT;break}i.head&&(i.head.text=u>>8&1),512&i.flags&&(P[0]=255&u,P[1]=u>>>8&255,i.check=QE(i.check,P,2,0)),h=u=0,i.mode=IP;case IP:for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.head&&(i.head.time=u),512&i.flags&&(P[0]=255&u,P[1]=u>>>8&255,P[2]=u>>>16&255,P[3]=u>>>24&255,i.check=QE(i.check,P,4,0)),h=u=0,i.mode=OP;case OP:for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.head&&(i.head.xflags=255&u,i.head.os=u>>8),512&i.flags&&(P[0]=255&u,P[1]=u>>>8&255,i.check=QE(i.check,P,2,0)),h=u=0,i.mode=LP;case LP:if(1024&i.flags){for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.length=u,i.head&&(i.head.extra_len=u),512&i.flags&&(P[0]=255&u,P[1]=u>>>8&255,i.check=QE(i.check,P,2,0)),h=u=0}else i.head&&(i.head.extra=null);i.mode=RP;case RP:if(1024&i.flags&&(s<(d=i.length)&&(d=s),d&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),ZE(i.head.extra,r,o,d,w)),512&i.flags&&(i.check=QE(i.check,r,d,o)),s-=d,o+=d,i.length-=d),i.length))break t;i.length=0,i.mode=DP;case DP:if(2048&i.flags){if(0===s)break t;for(d=0;w=r[o+d++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w)),w&&d<s;);if(512&i.flags&&(i.check=QE(i.check,r,d,o)),s-=d,o+=d,w)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=kP;case kP:if(4096&i.flags){if(0===s)break t;for(d=0;w=r[o+d++],i.head&&w&&i.length<65536&&(i.head.comment+=String.fromCharCode(w)),w&&d<s;);if(512&i.flags&&(i.check=QE(i.check,r,d,o)),s-=d,o+=d,w)break t}else i.head&&(i.head.comment=null);i.mode=BP;case BP:if(512&i.flags){for(;h<16;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u!==(65535&i.check)){t.msg="header crc mismatch",i.mode=rT;break}h=u=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=zP;break;case NP:for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}t.adler=i.check=cT(u),h=u=0,i.mode=FP;case FP:if(0===i.havedict)return t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,wP;t.adler=i.check=1,i.mode=zP;case zP:if(e===yP||e===bP)break t;case UP:if(i.last){u>>>=7&h,h-=7&h,i.mode=tT;break}for(;h<3;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}switch(i.last=1&u,h-=1,3&(u>>>=1)){case 0:i.mode=jP;break;case 1:if(mT(i),i.mode=XP,e===bP){u>>>=2,h-=2;break t}break;case 2:i.mode=HP;break;case 3:t.msg="invalid block type",i.mode=rT}u>>>=2,h-=2;break;case jP:for(u>>>=7&h,h-=7&h;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if((65535&u)!=(u>>>16^65535)){t.msg="invalid stored block lengths",i.mode=rT;break}if(i.length=65535&u,h=u=0,i.mode=GP,e===bP)break t;case GP:i.mode=VP;case VP:if(d=i.length){if(s<d&&(d=s),c<d&&(d=c),0===d)break t;ZE(n,r,o,d,a),s-=d,o+=d,c-=d,a+=d,i.length-=d;break}i.mode=zP;break;case HP:for(;h<14;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(i.nlen=257+(31&u),u>>>=5,h-=5,i.ndist=1+(31&u),u>>>=5,h-=5,i.ncode=4+(15&u),u>>>=4,h-=4,286<i.nlen||30<i.ndist){t.msg="too many length or distance symbols",i.mode=rT;break}i.have=0,i.mode=$P;case $P:for(;i.have<i.ncode;){for(;h<3;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.lens[T[i.have++]]=7&u,u>>>=3,h-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=dP(fP,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid code lengths set",i.mode=rT;break}i.have=0,i.mode=WP;case WP:for(;i.have<i.nlen+i.ndist;){for(;v=(E=i.lencode[u&(1<<i.lenbits)-1])>>>16&255,y=65535&E,!((g=E>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(y<16)u>>>=g,h-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u>>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=rT;break}w=i.lens[i.have-1],d=3+(3&u),u>>>=2,h-=2}else if(17===y){for(M=g+3;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}h-=g,w=0,d=3+(7&(u>>>=g)),u>>>=3,h-=3}else{for(M=g+7;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}h-=g,w=0,d=11+(127&(u>>>=g)),u>>>=7,h-=7}if(i.have+d>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=rT;break}for(;d--;)i.lens[i.have++]=w}}if(i.mode===rT)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=rT;break}if(i.lenbits=9,A={bits:i.lenbits},S=dP(mP,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid literal/lengths set",i.mode=rT;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=dP(gP,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){t.msg="invalid distances set",i.mode=rT;break}if(i.mode=XP,e===bP)break t;case XP:i.mode=qP;case qP:if(6<=s&&258<=c){t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,iP(t,p),a=t.next_out,n=t.output,c=t.avail_out,o=t.next_in,r=t.input,s=t.avail_in,u=i.hold,h=i.bits,i.mode===zP&&(i.back=-1);break}for(i.back=0;v=(E=i.lencode[u&(1<<i.lenbits)-1])>>>16&255,y=65535&E,!((g=E>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(v&&0==(240&v)){for(b=g,x=v,_=y;v=(E=i.lencode[_+((u&(1<<b+x)-1)>>b)])>>>16&255,y=65535&E,!(b+(g=E>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}u>>>=b,h-=b,i.back+=b}if(u>>>=g,h-=g,i.back+=g,i.length=y,0===v){i.mode=QP;break}if(32&v){i.back=-1,i.mode=zP;break}if(64&v){t.msg="invalid literal/length code",i.mode=rT;break}i.extra=15&v,i.mode=YP;case YP:if(i.extra){for(M=i.extra;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.length+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=ZP;case ZP:for(;v=(E=i.distcode[u&(1<<i.distbits)-1])>>>16&255,y=65535&E,!((g=E>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(0==(240&v)){for(b=g,x=v,_=y;v=(E=i.distcode[_+((u&(1<<b+x)-1)>>b)])>>>16&255,y=65535&E,!(b+(g=E>>>24)<=h);){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}u>>>=b,h-=b,i.back+=b}if(u>>>=g,h-=g,i.back+=g,64&v){t.msg="invalid distance code",i.mode=rT;break}i.offset=y,i.extra=15&v,i.mode=KP;case KP:if(i.extra){for(M=i.extra;h<M;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}i.offset+=u&(1<<i.extra)-1,u>>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=rT;break}i.mode=JP;case JP:if(0===c)break t;if(d=p-c,i.offset>d){if((d=i.offset-d)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=rT;break}d>i.wnext?(d-=i.wnext,f=i.wsize-d):f=i.wnext-d,d>i.length&&(d=i.length),m=i.window}else m=n,f=a-i.offset,d=i.length;for(c<d&&(d=c),c-=d,i.length-=d;n[a++]=m[f++],--d;);0===i.length&&(i.mode=qP);break;case QP:if(0===c)break t;n[a++]=i.length,c--,i.mode=qP;break;case tT:if(i.wrap){for(;h<32;){if(0===s)break t;s--,u|=r[o++]<<h,h+=8}if(p-=c,t.total_out+=p,i.total+=p,p&&(t.adler=i.check=i.flags?QE(i.check,n,p,a-p):KE(i.check,n,p,a-p)),p=c,(i.flags?u:cT(u))!==i.check){t.msg="incorrect data check",i.mode=rT;break}h=u=0}i.mode=eT;case eT:if(i.wrap&&i.flags){for(;h<32;){if(0===s)break t;s--,u+=r[o++]<<h,h+=8}if(u!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=rT;break}h=u=0}i.mode=iT;case iT:S=_P;break t;case rT:S=AP;break t;case nT:return MP;case oT:default:return SP}return t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=u,i.bits=h,(i.wsize||p!==t.avail_out&&i.mode<rT&&(i.mode<tT||e!==vP))&&gT(t,t.output,t.next_out,p-t.avail_out),l-=t.avail_in,p-=t.avail_out,t.total_in+=l,t.total_out+=p,i.total+=p,i.wrap&&p&&(t.adler=i.check=i.flags?QE(i.check,n,p,t.next_out-p):KE(i.check,n,p,t.next_out-p)),t.data_type=i.bits+(i.last?64:0)+(i.mode===zP?128:0)+(i.mode===XP||i.mode===GP?256:0),(0===l&&0===p||e===vP)&&S===xP&&(S=EP),S}var yT=!0,bT=!0;try{String.fromCharCode.apply(null,[0])}catch(t){yT=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){bT=!1}for(var xT=new Uint8Array(256),_T=0;_T<256;_T++)xT[_T]=252<=_T?6:248<=_T?5:240<=_T?4:224<=_T?3:192<=_T?2:1;function wT(t){var e,i,r,n,o,a=t.length,s=0;for(n=0;n<a;n++)55296==(64512&(i=t.charCodeAt(n)))&&n+1<a&&56320==(64512&(r=t.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),s+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(s),n=o=0;o<s;n++)55296==(64512&(i=t.charCodeAt(n)))&&n+1<a&&56320==(64512&(r=t.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),i<128?e[o++]=i:(i<2048?e[o++]=192|i>>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e}function ST(t,e){var i,r,n,o,a=e||t.length,s=new Array(2*a);for(i=r=0;i<a;)if((n=t[i++])<128)s[r++]=n;else if(4<(o=xT[n]))s[r++]=65533,i+=o-1;else{for(n&=2===o?31:3===o?15:7;1<o&&i<a;)n=n<<6|63&t[i++],o--;1<o?s[r++]=65533:n<65536?s[r++]=n:(n-=65536,s[r++]=55296|n>>10&1023,s[r++]=56320|1023&n)}return function(t,e){if(e<65537&&(t.subarray&&bT||!t.subarray&&yT))return String.fromCharCode.apply(null,YE(t,e));for(var i="",r=0;r<e;r++)i+=String.fromCharCode(t[r]);return i}(s,r)}function AT(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0?e:0===i?e:i+xT[t[i]]>e?i:e}xT[254]=xT[254]=1;var MT=0,ET={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 PT(){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 TT(){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 CT=Object.prototype.toString;function IT(t){if(!(this instanceof IT))return new IT(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&&0<=e.windowBits&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(0<=e.windowBits&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),15<e.windowBits&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new PT,this.strm.avail_out=0;var i,r,n,o=lT(this.strm,e.windowBits);if(o!==MT)throw new Error(ET[o]);this.header=new TT,i=this.strm,r=this.header,i&&i.state&&(0==(2&(n=i.state).wrap)||((n.head=r).done=!1))}IT.prototype.push=function(t,e){var i,r,n,o,a,s,c,u,h,l,p=this.strm,d=this.options.chunkSize,f=this.options.dictionary,m=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?p.input=function(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i<r;i++)e[i]=t.charCodeAt(i);return e}(t):"[object ArrayBuffer]"===CT.call(t)?p.input=new Uint8Array(t):p.input=t,p.next_in=0,p.avail_in=p.input.length;do{if(0===p.avail_out&&(p.output=new Uint8Array(d),p.next_out=0,p.avail_out=d),2===(i=vT(p,0))&&f&&(s="string"==typeof f?wT(f):"[object ArrayBuffer]"===CT.call(f)?new Uint8Array(f):f,c=this.strm,h=void 0,l=(u=s).length,i=c&&c.state?0!==(h=c.state).wrap&&h.mode!==FP?SP:h.mode===FP&&KE(1,u,l,0)!==h.check?AP:gT(c,u,l,l)?(h.mode=nT,MP):(h.havedict=1,xP):SP),-5===i&&!0===m&&(i=MT,m=!1),1!==i&&i!==MT)return this.onEnd(i),!(this.ended=!0);p.next_out&&(0!==p.avail_out&&1!==i&&(0!==p.avail_in||4!==r&&2!==r)||("string"===this.options.to?(n=AT(p.output,p.next_out),o=p.next_out-n,a=ST(p.output,n),p.next_out=o,p.avail_out=d-o,o&&ZE(p.output,p.output,n,o,0),this.onData(a)):this.onData(YE(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(m=!0)}while((0<p.avail_in||0===p.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(t){if(!t||!t.state)return SP;var e=t.state;return e.window&&(e.window=null),t.state=null,xP}(this.strm),this.onEnd(i),this.ended=!0,i===MT):2!==r||(this.onEnd(MT),!(p.avail_out=0))},IT.prototype.onData=function(t){this.chunks.push(t)},IT.prototype.onEnd=function(t){t===MT&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,r,n,o,a;for(e=r=0,i=t.length;e<i;e++)r+=t[e].length;for(a=new Uint8Array(r),e=n=0,i=t.length;e<i;e++)o=t[e],a.set(o,n),n+=o.length;return a}(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},nd.add("gz",function(e){var i;e instanceof ArrayBuffer&&(e=new Uint8Array(e));try{i=function(t,e){var i=new IT(e);if(i.push(t,!0),i.err)throw i.msg;return i.result}(e)}catch(t){i=e}return i});var OT=function(){},LT="//mmtf.rcsb.org/v1.0/",RT=LT+"full/",DT=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.getUrl=function(t){var e,i=md(t),r=i.name.substr(0,4);return!["pdb","cif"].includes(i.ext)||!1!==i.compressed&&"gz"!==i.compressed?"mmtf"===i.ext?e=i.base.endsWith(".bb")?"//mmtf.rcsb.org/v1.0/reduced/"+r:RT+r:(i.ext&&Yp.warn("unsupported ext",i.ext),e=RT+r):e="//files.rcsb.org/download/"+i.path,wl()+e},e.prototype.getExt=function(t){var e=md(t).ext;return e||"mmtf"},e}(OT);td.add("rcsb",new DT);var kT="//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/",BT="/SDF?record_type=3d",NT=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.getUrl=function(t){var e,i=md(t),r=i.name;return i.ext&&"sdf"!==i.ext&&Yp.warn("unsupported ext",i.ext),e=kT+r+BT,wl()+e},e.prototype.getExt=function(t){var e=md(t).ext;return e||"sdf"},e}(OT);td.add("pubchem",new NT);var FT=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.getUrl=function(t){return t},e.prototype.getExt=function(t){return md(t).ext},e}(OT);td.add("ftp",new FT),td.add("http",new FT),td.add("https",new FT);var zT=/^((http|https|ftp):)*\/\//,UT=function(e){function t(t){void 0===t&&(t=""),e.call(this),this.baseUrl=t}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.getUrl=function(t){var e,i,r,n,o=md(t),a=this.baseUrl+o.path;return zT.test(this.baseUrl)||(e=a,i=window.location,r=i.pathname,n=r.substring(0,r.lastIndexOf("/")+1),a=i.origin+n+e),a},t.prototype.getExt=function(t){return md(t).ext},t}(OT),jT=function(e){function t(t){void 0===t&&(t=""),e.call(this),this.baseUrl=t}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.getListing=function(e){void 0===e&&(e="");var t=this.baseUrl+"dir/"+e;return"/"!==t[t.length-1]&&(t+="/"),vd(t,{ext:"json"}).then(function(t){return{path:e,data:t.data}})},t.prototype.getUrl=function(t){var e=md(t);return this.baseUrl+"file/"+e.path+e.query},t.prototype.getCountUrl=function(t){var e=md(t);return this.baseUrl+"traj/numframes/"+e.path+e.query},t.prototype.getFrameUrl=function(t,e){var i=md(t);return this.baseUrl+"traj/frame/"+e+"/"+i.path+i.query},t.prototype.getFrameParams=function(t,e){return"atomIndices="+e.join(";")},t.prototype.getPathUrl=function(t,e){var i=md(t);return this.baseUrl+"traj/path/"+e+"/"+i.path+i.query},t.prototype.getExt=function(t){return md(t).ext},t}(OT);function GT(t,e){return{type:"integer",max:t,min:e}}function VT(t,e,i){return{type:"number",precision:t,max:e,min:i}}function HT(t,e,i){return{type:"range",step:t,max:e,min:i}}function $T(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return{type:"select",options:t.reduce(function(t,e){var i;return Object.assign({},t,((i={})[e]=e,i))},{})}}var WT={backgroundColor:{type:"color"},quality:$T("auto","low","medium","high"),sampleLevel:HT(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:VT(1,10,0),zoomSpeed:VT(1,10,0),panSpeed:VT(1,10,0),clipNear:HT(1,100,0),clipFar:HT(1,100,0),clipDist:GT(200,0),clipMode:$T("scene","camera"),clipScale:$T("relative","absolute"),fogNear:HT(1,100,0),fogFar:HT(1,100,0),fogMode:$T("scene","camera"),fogScale:$T("relative","absolute"),cameraType:$T("perspective","orthographic","stereo"),cameraEyeSep:VT(3,1,.01),cameraFov:HT(1,120,15),lightColor:{type:"color"},lightIntensity:VT(2,10,0),ambientColor:{type:"color"},ambientIntensity:VT(2,10,0),hoverTimeout:GT(1e4,-1),tooltip:{type:"boolean"},mousePreset:$T.apply(void 0,Object.keys(Ay))};window.Promise||(window.Promise=s),de.Version="2.0.0-dev.37",de.StaticDatasource=UT,de.MdsrvDatasource=jT,de.Colormaker=ip,de.Selection=Lp,de.PdbWriter=xd,de.SdfWriter=_d,de.StlWriter=Ad,de.Stage=E_,de.Collection=Zx,de.ComponentCollection=w_,de.RepresentationCollection=Jx,de.Component=qx,de.ShapeComponent=P_,de.StructureComponent=b_,de.SurfaceComponent=x_,de.VolumeComponent=__,de.Assembly=fb,de.TrajectoryPlayer=o_,de.Superposition=r_,de.Frames=e_,de.Queue=am,de.Counter=Md,de.BufferRepresentation=mx,de.ArrowBuffer=XS,de.BoxBuffer=QS,de.ConeBuffer=HS,de.CylinderBuffer=Gw,de.EllipsoidBuffer=oA,de.MeshBuffer=my,de.OctahedronBuffer=hA,de.PointBuffer=Ix,de.SphereBuffer=Px,de.TetrahedronBuffer=mA,de.TextBuffer=Aw,de.TorusBuffer=_A,de.WidelineBuffer=Pw,de.Shape=dx,de.Structure=cx,de.Kdtree=ub,de.SpatialHash=Zm,de.MolecularSurface=SS,de.Volume=ay,de.MouseActions=Sy,de.KeyActions=Py,de.setDebug=function(t){de.Debug=t},de.MeasurementDefaultParams=Zp,de.setMeasurementDefaultParams=function(t){void 0===t&&(t={}),Object.assign(Zp,t)},de.ScriptExtensions=Kp,de.ColormakerRegistry=Qp,de.DatasourceRegistry=td,de.DecompressorRegistry=nd,de.ParserRegistry=id,de.RepresentationRegistry=ed,de.setListingDatasource=function(t){de.ListingDatasource=t},de.setTrajectoryDatasource=function(t){de.TrajectoryDatasource=t},de.autoLoad=vd,de.getDataInfo=gd,de.getFileInfo=md,de.superpose=v_,de.guessElement=Rb,de.concatStructures=function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];de.Debug&&Yp.time("concatStructures");var r=new cx(t,""),n=new yb(r),o=r.atomStore,a=r.atomMap;o.addField("formalCharge",1,"int8"),o.addField("partialCharge",1,"float32");var s={},c=0,u=0,h=0;e.forEach(function(t){t.eachAtom(function(t){o.growIfFull(),o.atomTypeId[c]=a.add(t.atomname,t.element),o.x[c]=t.x,o.y[c]=t.y,o.z[c]=t.z,o.serial[c]=t.serial,o.formalCharge[c]=t.formalCharge,o.partialCharge[c]=t.partialCharge,o.altloc[c]=t.altloc,o.occupancy[c]=t.occupancy,o.bfactor[c]=t.bfactor,n.addAtom(t.modelIndex+h,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),s[t.index+u]=c,c+=1}),u+=t.atomStore.count,h+=t.modelStore.count});var l=r.bondStore,p=r.getAtomProxy(),d=r.getAtomProxy();return u=0,e.forEach(function(t){t.eachBond(function(t){p.index=s[t.atomIndex1+u],d.index=s[t.atomIndex2+u],l.addBond(p,d,t.bondOrder)}),u+=t.atomStore.count}),n.finalize(),Cb(r,!0),Tb(r,!0),r.finalizeAtoms(),r.finalizeBonds(),Db(r),de.Debug&&Yp.timeEnd("concatStructures"),r},de.flatten=function t(e,i){i=bl(i,[]);for(var r=0;r<e.length;r++)Array.isArray(e[r])?t(e[r],i):i.push(e[r]);return i},de.throttle=function(i,r,n){var o,a,s,c=null,u=0;function h(){u=!1===n.leading?0:Date.now(),c=null,s=i.apply(o,a),c||(o=a=null)}return n||(n={}),function(){var t=Date.now();u||!1!==n.leading||(u=t);var e=r-(t-u);return o=this,a=arguments,e<=0||r<e?(c&&(clearTimeout(c),c=null),u=t,s=i.apply(o,a),c||(o=a=null)):c||!1===n.trailing||(c=setTimeout(h,e)),s}},de.download=Ml,de.getQuery=yl,de.uniqueArray=Cl,de.LeftMouseButton=1,de.MiddleMouseButton=2,de.RightMouseButton=3,de.Signal=op,de.Matrix3=ni,de.Matrix4=ei,de.Vector2=ti,de.Vector3=ri,de.Box3=Pi,de.Quaternion=ii,de.Euler=Gi,de.Plane=Ci,de.Color=ki,de.UIStageParameters=WT,Object.defineProperty(de,"__esModule",{value:!0})});
\ No newline at end of file
diff --git a/ippisite/ippidb/static/js/targetcentric.js b/ippisite/ippidb/static/js/targetcentric.js
index a496000b2d4063dec970ca98616bb4d6db3b8834..42f6b50ae04e046b82264a0ddf108cf62d056506 100644
--- a/ippisite/ippidb/static/js/targetcentric.js
+++ b/ippisite/ippidb/static/js/targetcentric.js
@@ -366,20 +366,29 @@ function loadNGL(url, callback){
             // Handle window resizing
             var divflex = createElement("div",{},{},"d-flex justify-content-between flex-row-reverse bd-highlight");
             var divmultiButtonright = createElement("div",{role: "group"},{},"d-flex align-items-end flex-column");
-            var divcavitiesButton  = createElement("div",{role: "group"},{},"btn-group-vertical btn-group-sm btn-group-toggle p-2");
+            var divcavitiesButton  = createElement("div",{role: "group"},{},"infobulle btn-group-vertical btn-group-sm btn-group-toggle p-2");
+            var spaninfocav = createElement("span", {}, {}, '');
+            spaninfocav.innerHTML = "Load a pocket detected with Volsite (Desaphy et al., 2012).";
+            divcavitiesButton.appendChild(spaninfocav);
             divmultiButtonright.appendChild(divcavitiesButton);
             var divmultiButtoncenter = createElement("div",{},{}, "btn-group-vertical align-self-start");
             var divmultiButtonleft = createElement("div", {}, {}, "btn-group align-self-start");
             divflex.appendChild(divmultiButtonright);
             divflex.appendChild(divmultiButtoncenter);
             divflex.appendChild(divmultiButtonleft);
-            var divslider = createElement("div", {}, {}, 'form-group border border-info rounded p-2');
+            var divslider = createElement("div", {}, {}, 'infobulle form-group border border-info rounded p-2');
+            var spaninfodrug = createElement("span", {}, {}, '');
+            spaninfodrug.innerHTML = "Druggability has been determined by our Deep Learning tool InDeep trained on protein/ligand interactions. They are represented as isolevel probabilities, which you can adjust with the slider (0,1)."
+            divslider.appendChild(spaninfodrug);
             titledruggable = createElement("strong", {}, {}, '');
-            titledruggable.innerHTML = "Predictive Druggability";
+            titledruggable.innerHTML = "Predicted druggability";
             divslider.appendChild(titledruggable);
-            var divsliderinteractibility = createElement("div", {}, {}, 'form-group border border-info rounded p-2 mr-2');
+            var divsliderinteractibility = createElement("div", {}, {}, 'infobulle form-group border border-info rounded p-2 mr-2');
+            var spaninfoint = createElement("span", {}, {"right":"50%"}, '');
+            spaninfoint.innerHTML = "Interactability has been determined by our Deep Learning tool InDeep trained on protein-protein interactions. They are represented as isolevel probabilities, which you can adjust with the slider (0,1)."
+            divsliderinteractibility.appendChild(spaninfoint);
             titleinteractible = createElement("strong", {}, {}, '');
-            titleinteractible.innerHTML = "Predictive Interactibility";
+            titleinteractible.innerHTML = "Predicted Interactability";
             divsliderinteractibility.appendChild(titleinteractible);
             divmultiButtonleft.appendChild(divsliderinteractibility);
             divmultiButtonleft.appendChild(divslider);
@@ -388,7 +397,7 @@ function loadNGL(url, callback){
                 }, false );
             var hasmrc = 0
             var hasinteract = 0
-            pdb.chain_set.reverse().forEach(function(chain, indexchain){
+            pdb.chain_set.forEach(function(chain, indexchain){
                 var blobchain = new Blob( [ chain.file_content ], {type: 'text/plain'} );
                 var componentname = pdb.code +  '_' + chain.pdb_chain_id;
                 stage.loadFile( blobchain, {ext:"pdb", name: componentname}).then( function( o ){
@@ -410,7 +419,7 @@ function loadNGL(url, callback){
 
                     hasinteract = 1;
                     var labelsliderinterac = createElement("label", {}, {}, "", {'for':'isolevel' + chain.pdb_chain_id});
-                    labelsliderinterac.innerHTML = 'Adjust predictive interactibility surface on chain ' + chain.pdb_chain_id;
+                    labelsliderinterac.innerHTML = 'Adjust predicted interactability surface on chain ' + chain.pdb_chain_id;
                     divchain.appendChild(labelsliderinterac);
                     divchain.appendChild(createElement('br'));
                     var divdropdowninterac = createElement("div",{},{},"dropdown");
@@ -419,7 +428,7 @@ function loadNGL(url, callback){
                                                                   "data-toggle":"dropdown", 
                                                                   "aria-haspopup":"true", 
                                                                   "aria-expanded":"false"});
-                    buttondorpdowninterac.append("Select interactibility model, chain ".concat(chain.pdb_chain_id ));
+                    buttondorpdowninterac.append("Select interactability model, chain ".concat(chain.pdb_chain_id ));
                     divdropdowninterac.appendChild(buttondorpdowninterac);
                     var dropdowninteracmenu = createElement("div",{},{},"dropdown-menu",{'aria-labelledby': componentname + "_interact"});
                     divdropdowninterac.appendChild(dropdowninteracmenu);
@@ -448,13 +457,13 @@ function loadNGL(url, callback){
                                                                                         opaqueBack: false,
                                                                                         smooth: 2,
                                                                                         color: filecolor(indexchain, indexfile),
-                                                                                        isolevel: 0.7,
+                                                                                        isolevel: interactfile.default_isolevel,
                                                                                         isolevelType: 'value',});
                                     });
                                     var divvalueslider = createElement("div", {}, {}, "",  {'id': baseName(interactfile.interact_file) + "_interact_isolevel"});
-                                    divvalueslider.innerHTML = 'current value for ' + interactfile.label + ': 0.7';
+                                    divvalueslider.innerHTML = 'current value for ' + interactfile.label + ': ' + interactfile.default_isolevel;
                                     divchain.appendChild(divvalueslider);
-                                    var isolevel = createElement("input", {type: "range", value: 70, min: 0, max: 100, step: 1},
+                                    var isolevel = createElement("input", {type: "range", value: interactfile.default_isolevel*100, min: 0, max: 100, step: 1},
                                                                  {},"form-control-range",{'id': baseName(interactfile.interact_file) + "_interact_isolevelslide"});
                                     isolevel.oninput = function(e) {
                                         $('#' + baseName(interactfile.interact_file) + "_interact_isolevel").html('current value for ' + interactfile.label + ': ' + parseFloat(e.target.value)/100);
@@ -485,19 +494,19 @@ function loadNGL(url, callback){
                                                                             opaqueBack: false,
                                                                             smooth: 2,
                                                                             color: filecolor(indexchain, -1),
-                                                                            isolevel: 0.7,
+                                                                            isolevel: chain.default_isolevel,
                                                                             isolevelType: 'value',});
                         });
                     
                     
                     var labelslider = createElement("label", {}, {}, "", {'for':'isolevel' + chain.pdb_chain_id});
-                    labelslider.innerHTML = 'Adjust predictive surface druggable on chain ' + chain.pdb_chain_id;
+                    labelslider.innerHTML = 'Adjust predicted druggability surface on chain ' + chain.pdb_chain_id;
                     var divvalueslider = createElement("div", {}, {}, "",  {'id': 'valueisolevel' + chain.pdb_chain_id});
-                    divvalueslider.innerHTML = 'current value: 0.7'
+                    divvalueslider.innerHTML = 'current value: '+ chain.default_isolevel
                     divchainmrc.appendChild(labelslider);
                     divchainmrc.appendChild(divvalueslider);
                     var isolevel = createElement("input", {
-                        type: "range", value: 70, min: 0, max: 100, step: 1
+                        type: "range", value: chain.default_isolevel*100, min: 0, max: 100, step: 1
                     }, {},"form-control-range",{'id':'isolevel' + chain.pdb_chain_id});
                     isolevel.oninput = function(e) {
                         $('#valueisolevel' + chain.pdb_chain_id).html('current value: ' + parseFloat(e.target.value)/100);
@@ -572,7 +581,7 @@ function loadNGL(url, callback){
                     var blobcavity = new Blob( [ cavity.mol2 ], {type: 'text/plain' } );
                     var multiButton = createElement("input", {
                         type: "button",
-                        value: "load cavity " + cavity.cavity_number + " from " + chain.pdb_chain_id,
+                        value: "load pocket " + cavity.cavity_number + " from " + chain.pdb_chain_id,
                         onclick: function (e) {
                             stage.compList.forEach(function(component){
                                 if (component.name.includes("CAVITY")) {
@@ -615,7 +624,7 @@ function loadNGL(url, callback){
             };
             if (hasinteract == 0) {
                     var labelsliderinteractibility = createElement("label", {}, {}, "", {});
-                    labelsliderinteractibility.innerHTML = 'No interactible surface predict';
+                    labelsliderinteractibility.innerHTML = 'No interactable surface predict';
                     divsliderinteractibility.appendChild(labelsliderinteractibility);
             };
             pdb.ligand_set.forEach(function(ligand){
@@ -681,7 +690,8 @@ function loadNGL(url, callback){
             var backgroundcolorButton = createElement("button", {
                 
                 onclick: function () {
-                    if (stage.parameters.backgroundColor.value == 'white'){
+                    /* old ngl version use stage.parameters.backgroundColor.value */
+                    if (stage.parameters.backgroundColor == 'white'){
                         stage.setParameters({backgroundColor: 'black'});
                     } else {
                         stage.setParameters({backgroundColor: 'white'});
@@ -701,5 +711,4 @@ function loadNGL(url, callback){
             addElement(stage, divflex)
         }
     });
-};
-
+};
\ No newline at end of file
diff --git a/ippisite/ippidb/static/js/targetcentrict_networks.js b/ippisite/ippidb/static/js/targetcentrict_networks.js
index 14505706c4a7c9b503ed7362dff386932661be25..e5283ec992f093ffccbf9261695be2980ca3b2c4 100644
--- a/ippisite/ippidb/static/js/targetcentrict_networks.js
+++ b/ippisite/ippidb/static/js/targetcentrict_networks.js
@@ -17,13 +17,13 @@ var node_trace = function(nodes, edges) {
         if (nodes[i].type == "PL"){
             x_PL.push(nodes[i].coord[0]);
             y_PL.push(nodes[i].coord[1]);
-            text_PL.push(nodes[i].name + " # of connections: " + nodes[i].num_connect);
+            text_PL.push(nodes[i].name + "</br>" + nodes[i].num_connect + " connections");
 	    size_PL.push((Math.log10(nodes[i].num_connect)+1)*8);
 	    colors_PL.push('#4e79a7')
 	} else {
 	    x_HD.push(nodes[i].coord[0]);
             y_HD.push(nodes[i].coord[1]);
-            text_HD.push(nodes[i].name + " # of connections: " + nodes[i].num_connect);
+            text_HD.push(nodes[i].name + "</br>" + nodes[i].num_connect + " connections");
 	    size_HD.push((Math.log10(nodes[i].num_connect)+1)*8);
 	    colors_HD.push('#de425b')
 	};
@@ -68,9 +68,12 @@ var node_trace = function(nodes, edges) {
 	name: 'Link',
 	visible: 'legendonly'
     };
-    return [trace_edges, trace_PL, trace_HD, dict_nodes, [size_PL, size_HD]]
+    return [trace_PL, trace_HD, trace_edges, dict_nodes, [size_PL, size_HD]]
 };
 
+var pathurl = window.location.pathname.split( '/' );
+pathurl.pop();
+var base_url = window.location.origin + pathurl.join('/')
 
 var build_trace = function(nodes, edges) {
     traces = node_trace(nodes, edges);
@@ -99,36 +102,60 @@ $.ajax({
     Plotly.newPlot('myDiv', [data[0], data[1], data[2]], layout, {scrollZoom: true});
     $(".loader").remove();
     ippidb_plot.on('plotly_click', function(datapoints){
-      var curvenumber = datapoints.points[0].curveNumber - 1;
-      var pointnumber = datapoints.points[0].pointNumber;
-      var colors = [repeatElement("#4e79a7", connect_ippidb[0].length), 
-              repeatElement("#de425b", connect_ippidb[1].length)];
-      var opacity = [repeatElement(0.2, connect_ippidb[0].length), 
-              repeatElement(0.2, connect_ippidb[1].length)];
-      colors[curvenumber][pointnumber] = '#488f31';
-      opacity[curvenumber][pointnumber] = 1;
-      for (var i=0; i < connect_ippidb[curvenumber][pointnumber].length; i++){
-          var curvenumber2 = connect_ippidb[curvenumber][pointnumber][i][0];
-          var pointnumber2 = connect_ippidb[curvenumber][pointnumber][i][1];
-          colors[curvenumber2][pointnumber2] = '#488f31';
-          opacity[curvenumber2][pointnumber2] = 1;
-      }
-      var update_PL = {'marker':{color: colors[0], size: data[4][0], line: {width: 1,
-                                                                     color: 'DarkSlateGrey'}, opacity: opacity[0], symbol: 1}};
-      var update_HD = {'marker':{color: colors[1], size: data[4][1], line: {width: 1,
-                                                                     color: 'DarkSlateGrey'}, opacity: opacity[1]}};
-      Plotly.restyle('myDiv', update_PL, 1);
-      Plotly.restyle('myDiv', update_HD, 2);
+      if (datapoints.event.button == 0) {
+        window.open(base_url + "/?pdbsearch=" + datapoints.points[0].text.split("-")[0], '_blank');
+      };
+    });
+    ippidb_plot.on('plotly_hover', function(datapoints){
+          var curvenumber = datapoints.points[0].curveNumber;
+          var pointnumber = datapoints.points[0].pointNumber;
+          var colors = [repeatElement("#4e79a7", connect_ippidb[0].length), 
+                  repeatElement("#de425b", connect_ippidb[1].length)];
+          var opacity = [repeatElement(0.2, connect_ippidb[0].length), 
+                  repeatElement(0.2, connect_ippidb[1].length)];
+          colors[curvenumber][pointnumber] = '#488f31';
+          opacity[curvenumber][pointnumber] = 1;
+          for (var i=0; i < connect_ippidb[curvenumber][pointnumber].length; i++){
+              var curvenumber2 = connect_ippidb[curvenumber][pointnumber][i][0];
+              var pointnumber2 = connect_ippidb[curvenumber][pointnumber][i][1];
+              colors[curvenumber2][pointnumber2] = '#488f31';
+              opacity[curvenumber2][pointnumber2] = 1;
+          }
+          var update_PL = {'marker':{color: colors[0], size: data[4][0], line: {width: 1,
+                                                                         color: 'DarkSlateGrey'}, opacity: opacity[0], symbol: 1}};
+          var update_HD = {'marker':{color: colors[1], size: data[4][1], line: {width: 1,
+                                                                         color: 'DarkSlateGrey'}, opacity: opacity[1]}};
+          Plotly.restyle('myDiv', update_PL, 0);
+          Plotly.restyle('myDiv', update_HD, 1);
     });
+    
+    var queryString = window.location.search;
+    var urlParams = new URLSearchParams(queryString);
+    var cavity = urlParams.get('search');
+    if (cavity) {
+      if (cavity in nodes_coords) {
+        console.log(cavity);
+        currentlayout = ippidb_plot.layout;
+        currentlayout.xaxis['autorange'] = false;
+        currentlayout.yaxis['autorange'] = false;
+        currentlayout.xaxis['range'] = [nodes_coords[cavity][0]-0.01, nodes_coords[cavity][0]+0.01];
+        currentlayout.yaxis['range'] = [nodes_coords[cavity][1]-0.01, nodes_coords[cavity][1]+0.01];
+        Plotly.relayout('myDiv', currentlayout);
+      } else {
+        $("#message_warning").removeClass("hide").addClass("show");
+        $("#message_warning").append("No pocket found: the pocket does not exist, PSI is too low or pocket is alone without any pocket nearby.");
+      };
+    }
 
     $('.search-button').click(function() {
       var cavity = $("#id_search").val();
-      currentlayout = ippidb_plot.layout;
+      window.open(window.location.pathname+"?search="+cavity, '_self');
+      /*currentlayout = ippidb_plot.layout;
       currentlayout.xaxis['autorange'] = false;
       currentlayout.yaxis['autorange'] = false;
       currentlayout.xaxis['range'] = [nodes_coords[cavity][0]-0.01, nodes_coords[cavity][0]+0.01];
       currentlayout.yaxis['range'] = [nodes_coords[cavity][1]-0.01, nodes_coords[cavity][1]+0.01];
-      Plotly.relayout('myDiv', currentlayout);
+      Plotly.relayout('myDiv', currentlayout);*/
     });
 
     autocomplete(document.getElementById("id_search"), Object.keys(nodes_coords));
diff --git a/ippisite/ippidb/templates/base.html b/ippisite/ippidb/templates/base.html
index 9aedefb5d98cf9665e662912d027f657b95616ce..623af9ee1cb1caf3f13a5965de423a752b023bbe 100644
--- a/ippisite/ippidb/templates/base.html
+++ b/ippisite/ippidb/templates/base.html
@@ -99,7 +99,7 @@
                         <a href="{% url 'compound_list' %}">Query compounds</a>
                     </li>
                     <li>
-                        <a href="{% url 'cavities' %}">Query cavities</a>
+                        <a href="{% url 'cavities' %}">Query pockets</a>
                     </li>
                     <li>
                         <a href="{% url 'tutorials' %}">Tutorials</a>
diff --git a/ippisite/ippidb/templates/index.html b/ippisite/ippidb/templates/index.html
index bcd153454e28b25fc0dce6b9fa9179c0d4685879..281599bb45584a707fc9ffd5287c6cbad7c85ba4 100644
--- a/ippisite/ippidb/templates/index.html
+++ b/ippisite/ippidb/templates/index.html
@@ -14,16 +14,16 @@
 			<div id="content" class="main-content">
 				<div class="section">
 					<main role="main">
-						<h1 class="page-title"> IPPI - DB </h1>
+						<h1 class="page-title"> iPPI - DB </h1>
 						<div class="tabs"></div>
 						<div class="main__inner">
 							<div class="region region-content">
 								<div class="page-intro">
 									{% block pageintro %}
-									IPPI-DB is a database of modulators of protein-protein interactions. It contains
+									iPPI-DB is a database of modulators of protein-protein interactions. It contains
 									exclusively small molecules and therefore no peptides. The data are retrieved from
 									the literature either peer reviewed scientific articles or world patents.
-									A large variety of data is stored within IPPI-DB: structural, pharmacological,
+									A large variety of data is stored within iPPI-DB: structural, pharmacological,
 									binding and activity profile, pharmacokinetic and cytotoxicity when available, as
 									well as some data about the PPI targets themselves.
 									{% endblock %}
@@ -65,143 +65,265 @@
 										<a class="next" onclick='plusSlides(1)'>&#10095;</a>
 									</div>
 								</div>
-								<div class="row background_choices" style="height:300px;">
-									<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
 
-										<div class="choices_background flip-card">
-											<div class="flip-card-inner">
+								<div class="row mt-4">
+									<div class="col-12 col-sm-12 col-md-12 col-lg-6 col-xl-6">
+									<div class="compound_choices" data-toggle="modal" data-target="#compoundModal">
+									    <div class="icons">
+											<i style="font-size: 5em;" class="icon icon-conceptual icon-chemical"></i>
+											<div class="choices_title">Compounds</div>
+									    </div>
+									</div>
+									</div>
+									<div class="col-12 col-sm-12 col-md-12 col-lg-6 col-xl-6">
+									<div class="pocket_choices"  data-toggle="modal" data-target="#pocketModal">
+										<div class="icons">
+											<i style="font-size: 5em;" class="icon icon-conceptual icon-structures-3d"></i>
+											<div class="choices_title">Pockets</div>
+										</div>
+									</div>
+									</div>
+								</div>
+								<div class="modal fade fade_index" id="compoundModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
+									<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
+									  <div class="modal-content">
+										<div class="modal-header align_modal">
+											<div class="modal_choices_title">Compounds</div>
+										    <button type="button" class="close_choices_modal" data-dismiss="modal" aria-label="Close">&times;</button>
+										</div>
+										<div class="modal-body">
+											<div class="row mt-4">
+											<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
+											<div class="compound_background">
+												<div class="row ml-2 mr-2" >
+													<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
 
-												<div class="flip-card-front">
-													<a href="/compounds">
-														<div style="top:30%; left:35%; position:absolute;">
-															<i class="fas fa-search fa-4x"></i>
-															<p
-																style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
-																Query</p>
-														</div>
-													</a>
-												</div>
-												<div class="flip-card-back">
-													<a href="/compounds">
-														<div style="padding-top: 3.5em;">
-															<div class="choices_title">
-																Query
-															</div>
-															<div class="choices_description">Build sophisticated
-																queries
-																and
-																interrogate iPPI-DB using a large catalog of
-																criteria.
+														<div class="choices_background flip-card modalhref" style="height: 300px">
+															<div class="flip-card-inner">
+
+																<div class="flip-card-front">
+																	<a href="/compounds">
+																	    <div class="front-vertical-align">
+																			<i class="fas fa-search fa-4x"></i>
+																			<p
+																				style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
+																				Query</p>
+																	    </div>
+																	</a>
+																</div>
+																<div class="flip-card-back">
+																	<a href="/compounds">
+																		<div class="back-vertical-align">
+																			<div class="choices_title">
+																				Query
+																			</div>
+																			<div class="choices_description">Build sophisticated
+																				queries
+																				and
+																				interrogate iPPI-DB using a large catalog of
+																				criteria.
+																			</div>
+																		</div>
+																	</a>
+																</div>
+																
 															</div>
 														</div>
-													</a>
-												</div>
-											</div>
-										</div>
-									</div>
-									<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
-										<div class="choices_background flip-card">
-											<div class="flip-card-inner">
-												<div class="flip-card-front">
-													<a href="/about-pca">
-														<div style="top:30%; left:10%; position:absolute;">
-															<i class="far fa-compass fa-4x"></i>
-															<p
-																style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
-																Navigate the PPI chemical space</p>
+													</div>
+													<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
+														<div class="choices_background flip-card modalhref" style="height: 300px">
+															<div class="flip-card-inner">
+																<div class="flip-card-front">
+																	<a href="/about-pca">
+																		<div class="front-vertical-align">
+																			<i class="far fa-compass fa-4x"></i>
+																			<p
+																				style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
+																				Navigate the PPI chemical space</p>
+																		</div>
+																	</a>
+																</div>
+																<div class="flip-card-back">
+																	<a href="/about-pca">
+																		<div class="back-vertical-align">
+																			<div class="choices_title">
+																				Navigate the PPI chemical space
+																			</div>
+																			<div class="choices_description">Explore iPPI-DB
+																				compounds
+																				by
+																				navigating within an interactive Principal
+																				Component
+																				Analysis
+																				individual map.
+																			</div>
+																		</div>
+																	</a>
+																</div>
+															</div>
 														</div>
-													</a>
-												</div>
-												<div class="flip-card-back">
-													<a href="/about-pca">
-														<div style="padding-top: 3.5em;">
-															<div class="choices_title">
-																Navigate the PPI chemical space
+													</div>
+													<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
+														<div class="choices_background flip-card modalhref" style="height: 300px">
+															<div class="flip-card-inner">
+																<div class="flip-card-front">
+																	<a href="/about-le-lle">
+																		<div class="front-vertical-align">
+																			<i class="fas fa-snowboarding fa-4x"></i>
+																			<p
+																				style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
+																				Surf the efficiency plot</p>
+																		</div>
+																	</a>
+																</div>
+																<div class="flip-card-back">
+																	<a href="/about-le-lle">
+																		<div class="back-vertical-align">
+																			<div class="choices_title">
+																				Surf the efficiency plot
+																			</div>
+																			<div class="choices_description">Select iPPI-DB
+																				compounds using
+																				an
+																				interactive efficiency plot that highlights their
+																				ligand
+																				(LE)
+																				and lipophilic efficiencies (LLE).
+																			</div>
+																		</div>
+																	</a>
+																</div>
 															</div>
-															<div class="choices_description">Explore iPPI-DB
-																compounds
-																by
-																navigating within an interactive Principal
-																Component
-																Analysis
-																individual map.
+														</div>
+													</div>
+													<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
+														<div class="choices_background flip-card modalhref" style="height: 300px">
+															<div class="flip-card-inner">
+
+																<div class="flip-card-front">
+																	<a href="/contribute">
+																		<div class="front-vertical-align">
+																			<i class="fas fa-plus fa-4x"></i>
+																			<p
+																				style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
+																				Contribute</p>
+																		</div>
+																	</a>
+																</div>
+																<div class="flip-card-back">
+																	<a href="/contribute">
+																		<div class="back-vertical-align">
+																			<div class="choices_title">
+																				Contribute
+																			</div>
+																			<div class="choices_description">You have read or written a
+																				publication describing new iPPI compounds. Let it be a
+																				benefit
+																				for the whole PPI community by using our intuitive
+																				Contribute
+																				process. You are just few clicks away from adding new
+																				precious
+																				data to iPPI-DB.
+																			</div>
+																		</div>
+																	</a>
+																</div>
 															</div>
 														</div>
-													</a>
+													</div>
 												</div>
 											</div>
+											</div>
+											</div>
 										</div>
-									</div>
-									<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
-										<div class="choices_background flip-card">
-											<div class="flip-card-inner">
-												<div class="flip-card-front">
-													<a href="/about-le-lle">
-														<div style="top:30%; left:20%; position:absolute;">
-															<i class="fas fa-snowboarding fa-4x"></i>
-															<p
-																style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
-																Surf the efficiency plot</p>
-														</div>
-													</a>
-												</div>
-												<div class="flip-card-back">
-													<a href="/about-le-lle">
-														<div style="padding-top: 3.5em;">
-															<div class="choices_title">
-																Surf the efficiency plot
+								      </div>
+								   </div>
+							    </div>
+								<div class="modal fade fade_index" id="pocketModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
+									<div class="modal-dialog  modal-dialog-centered modal-xl" role="document">
+									  <div class="modal-content">
+										<div class="modal-header align_modal">
+										  <div class="modal_choices_title">Pockets</div>
+										  <button type="button" class="close_choices_modal" data-dismiss="modal" aria-label="Close">&times;</button>
+										</div>
+										<div class="modal-body">
+											<div class="row mt-4">
+											<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
+											<div class="pocket_background">
+												<div class="row ml-2 mr-2">
+													<div class="col-12 col-sm-12 col-md-12 col-lg-6 col-xl-6" style="padding: 10px;">
+				
+														<div class="choices_background flip-card modalhref" style="height: 300px">
+															<div class="flip-card-inner">
+				
+																<div class="flip-card-front">
+																	<a href="{% url 'cavities' %}">
+																		<div class="front-vertical-align">
+																			<i class="fas fa-search fa-4x"></i>
+																			<p
+																				style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
+																				Query the pocket database</p>
+																		</div>
+																	</a>
+																</div>
+																<div class="flip-card-back">
+																	<a href="{% url 'cavities' %}">
+																		<div class="back-vertical-align">
+																			<div class="choices_title">
+																				Query the pocket database
+																			</div>
+																			<div class="choices_description">
+																				Query the pocket database and explore pocket 
+																				descriptors, predictive interactibility and 
+																				druggability, tridimensional structures...
+																			</div>
+																		</div>
+																	</a>
+																</div>
 															</div>
-															<div class="choices_description">Select iPPI-DB
-																compounds using
-																an
-																interactive efficiency plot that highlights their
-																ligand
-																(LE)
-																and lipophilic efficiencies (LLE).
+														</div>
+													</div>
+													<div class="col-12 col-sm-12 col-md-12 col-lg-6 col-xl-6" style="padding: 10px;">
+														<div class="choices_background flip-card modalhref" style="height: 300px">
+															<div class="flip-card-inner">
+																<div class="flip-card-front">
+																	<a href="{% url 'networks' %}">
+																		<div class="front-vertical-align">
+																			<i class="far fa-compass fa-4x"></i>
+																			<p
+																				style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
+																				Navigate the PPI pocketome</p>
+																		</div>
+																	</a>
+																</div>
+																<div class="flip-card-back">
+																	<a href="{% url 'networks' %}">
+																		<div class="back-vertical-align">
+																			<div class="choices_title">
+																				Navigate the PPI pocketome
+																			</div>
+																			<div class="choices_description">Explore the iPPI-DB 
+																				pocketome by navigating 
+																				within an interactive network.
+																			</div>
+																		</div>
+																	</a>
+																</div>
 															</div>
 														</div>
-													</a>
+													</div>
 												</div>
 											</div>
+											</div>
+											</div>
 										</div>
 									</div>
+								 </div>
+							  </div>
 
-									<div class="col-12 col-sm-12 col-md-12 col-lg-3 col-xl-3" style="padding: 10px;">
-										<div class="choices_background flip-card">
-											<div class="flip-card-inner">
+							</div>
+						</div>
 
-												<div class="flip-card-front">
-													<a href="/contribute">
-														<div style="top:30%; left:35%; position:absolute;">
-															<i class="fas fa-plus fa-4x"></i>
-															<p
-																style="font-family: BrandonGrotesqueReg; margin-top: 20px;">
-																Contribute</p>
-														</div>
-													</a>
-												</div>
-												<div class="flip-card-back">
-													<a href="/contribute">
-														<div style="padding-top: 2.5em; ">
-															<div class="choices_title">
-																Contribute
-															</div>
-															<div class="choices_description">You have read or written a
-																publication describing new iPPI compounds. Let it be a
-																benefit
-																for the whole PPI community by using our intuitive
-																Contribute
-																process. You are just few clicks away from adding new
-																precious
-																data to iPPI-DB.
-															</div>
-														</div>
-													</a>
-												</div>
-											</div>
-										</div>
-									</div>
-								</div>
 								<div>
 									<div class="aklgmt_title">
 										Aknowledgments
diff --git a/ippisite/ippidb/templates/targetcentric.html b/ippisite/ippidb/templates/targetcentric.html
index cfec2abc787ec4b551d2e56dcb72dccd2e39792f..046c3535e2218317ba5eee9b25f96d003973df8a 100644
--- a/ippisite/ippidb/templates/targetcentric.html
+++ b/ippisite/ippidb/templates/targetcentric.html
@@ -36,13 +36,22 @@
     <nav class="breadcrumb breadNav" role="navigation">
         <div class="breadNav-label">You are here</div>
         <div aria-labelledby="breadNav-label">
-          {% block breadcrumb %} <a href="{% url 'cavities' %}" class="breadNav-link">Query cavities</a> > Cavity {% endblock %}
+          {% block breadcrumb %} <a href="{% url 'cavities' %}" class="breadNav-link">Query pockets</a> > Pocket {% endblock %}
         </div>
     </nav>
-    <div>
-        <a href="{% url 'networks' %}"><strong>Explore the PPI pocketome</strong></a>
-    </div>
-    <div class="card">
+        <div class="card mb-3">
+          <div class="card-header">   												
+            <strong>Navigate the PPI pocketome</strong>
+            </a>
+          </div>
+          <div class="card-body">
+              <p>Explore iPPI-DB pocketome by navigating within an interactive network.</p>
+              <a href="{% url 'networks' %}" class="btn btn-info">Go to pocketome</a>
+          </div>
+        </div>
+        <div class="card mb-3">
+        <div class="card-header"><strong>Query the pocket database</strong></div>
+        <div class="card-body">
         <div id="accordion">
         <div class="card">
         <div class="card-title" id="headingOne">
@@ -60,7 +69,7 @@
                 </div>
             </div>
             </form>
-        {{ cavitiescount }} Cavities in {{ proteincount }} proteins of {{ organismcount }} organisms
+        {{ cavitiescount }} Pockets in {{ proteincount }} proteins of {{ organismcount }} organisms
         </div>
         </div>
         </div>
@@ -86,7 +95,7 @@
                 </div>
                 <div class="row form-group">
                 <div class="col">
-                <input id="id_ligandcode" name="ligandcode" class="form-control" type="text" placeholder="Ligand code 3 letters">
+                <input id="id_ligandcode" name="ligandcode" class="form-control" type="text" placeholder="3 characters code ligands">
                 </div>
                 <div class="col">
                 <input id="id_organism" name="organism" class="form-control" type="text" placeholder="Organism name">
@@ -98,14 +107,19 @@
                 </div>
                 </div>
             </form>
-        {{ cavitiescount }} Cavities in {{ proteincount }} proteins of {{ organismcount }} organisms
+        {{ cavitiescount }} Pockets in {{ proteincount }} proteins of {{ organismcount }} organisms
+        </div>
         </div>
         </div>
         </div>
         </div>
         {% if pdb_list %}
-        Search Pattern : {{ searchfield }}, {{ pdb_list.count }} result(s)
-        <div class="card-body">
+        <div class="card">
+            <div class="card-header"><strong>Search results</strong></div>
+            <div class="card-body">
+            <div class="card-title">
+            <p>Search Pattern : {{ searchfield }}, {{ pdb_list.count }} result(s)</p>
+            </div>
             <div class="row flex-row flex-nowrap" style="overflow-y: auto">
                 {% for pdb in pdb_list %}
                 <div class="col-md-auto">
@@ -114,8 +128,8 @@
                             <a class="submithref" href="{% url 'cavities' %}?pdbsearch={{ pdb.code }}"><strong>{{ pdb.code }}</strong></a>
                         </div>
                         <div class="card-body text-nowrap">
-                            {% for chain in pdb.chain_set.all reversed %}
-                                {% if forloop.counter > 1 %}With {% else %}On {% endif %}Chain {{ chain.pdb_chain_id }} <a class="submithref" href="{% url 'cavities' %}?uniprotid={{ chain.protein.uniprot_id }}">{{ chain.protein.uniprot_id }}</a> 
+                            {% for chain in pdb.chain_set.all %}
+                                Chain {{ chain.pdb_chain_id }} <a class="submithref" href="{% url 'cavities' %}?uniprotid={{ chain.protein.uniprot_id }}">{{ chain.protein.uniprot_id }}</a> 
                                 <a class="submithref" href="{% url 'cavities' %}?organism={{ chain.protein.organism.name }}">{{ chain.protein.organism.name }}</a>
                                 </br>
                             {% endfor %}
@@ -124,6 +138,7 @@
                 </div>
                 {% endfor %}
             </div>
+            <p>First pdb is loaded below</p>
             <div class="mt-3 h5">
                 <strong>{{ pdb_list.0.code }}</strong>
                 </br>
@@ -146,20 +161,27 @@
                     <div class="card-title">
                         <div class="row text-center mt-3">
                             <div class="col-12">
-                                <a class="infobulle" href='#'>
+                                <div class="infobulle" style="display: inline-block">
                                     <i class="fas fa-question-circle fa-2x"></i>
                                     <span>The color gradient in the table illustrates the pocket similarity index (PSI) of a selected pocket with respect to its most similar neighbors in the PPI pocketome. 
                                         This pocket similarity index is calculated using a Gaussian kernel of all the pair-wise Euclidean distances between PPI pockets. It is bounded between 0 and 1. 
-                                        The pocket similarity index value is given when you mouseover a cavity name.
-                                        <br><img width="50%" height="50%" src="{% static 'images/Other/PSIequation.png' %}" alt="psi equation" />                     
-                                    </a>
-                                <strong> Cavities </strong>
+                                        The pocket similarity index value is given when you mouseover a pocket name.
+                                        <br><img width="50%" height="50%" src="{% static 'images/Other/PSIequation.png' %}" alt="psi equation" />
+                                    </span>                     
+                                </div>
+                                <strong> Pockets </strong>
                             </div>
                     </div>
                         <div class="row text-justify ml-3 mr-3">
                             <div class="col-8 text-wrap">
-                                The color gradient for the table is based on maximum and minimum PSI (Pocket Similarity Index) in the matrix. 
-                                PSI is given when you mouseover a cavity name. 
+                                <p>The color gradient for the table is based on maximum and minimum PSI (Pocket Similarity Index) in the matrix. 
+                                PSI is given when you mouseover a pocket name. </p>
+                                <p>Table of descriptors for each pocket, detected by Volsite (<a title="Desaphy J, Azdimousa K, Kellenberger E, Rognan D. 
+Comparison and druggability prediction of protein-ligand binding sites from pharmacophore-annotated cavity shapes. J Chem Inf Model. 2012 Aug 27;52(8):2287-99." href="https://doi.org/10.1021/ci300184x"  target="_blank">Desaphy et al., 2012</a>). 
+                                Click on <i class="far fa-plus-square"></i> icon to see closest pockets, based on the Pocket Similarity Index. 
+                                Pocket name is built with: pdb id / pocket's chain id | name / pocket number ::
+                                    partner ligand id or chain id | name
+                                </p>
                             </div>
                             <div class="col-4">
                             <table class="gradiant"><tbody><tr>
@@ -180,7 +202,8 @@
                      <table id="cavitiestable" class="table table-hover shadow table-responsive table-sm zui-table table-header-rotated">
                          <thead class="thead-light">
                           <tr>
-                            <th class="zui-sticky-col" title="PDB / Chain / Partner / Cavity" scope="col"><div><span>Cavities</span></div></th>
+                            <th class="zui-sticky-col" title="PDB ID / Chain ID | name / Pocket :: Partner ID | name" scope="col"><div><span>Pockets</span></div></th>
+                            <th class="rotate-45" title="HD: Heterodimer, PL: Protein ligand" scope="col"><div><span>Type</span></div></th>
                             <th class="rotate-45" title="Volume in Aˆ3" scope="col"><div><span>Volume</span></div></th>
                             <th class="rotate-45" title="Normalized Moment of Inertia PMX/PMZ" scope="col"><div><span>NPR1</span></div></th>
                             <th class="rotate-45" title="Normalized Moment of Inertia PMY/PMZ" scope="col"><div><span>NPR2</span></div></th>
@@ -189,23 +212,23 @@
                             <th class="rotate-45" title="Radius of gyration" scope="col"><div><span>Rgyr</span></div></th>
                             <th class="rotate-45" title="Spherocity Index" scope="col"><div><span>Spherocity Index</span></div></th>
                             <th class="rotate-45" title="% of hydrophobic points" scope="col"><div><span>CA</span></div></th>
-                            <th class="rotate-45" title="% of aromatic cavity points" scope="col"><div><span>CZ</span></div></th>
+                            <th class="rotate-45" title="% of aromatic pocket points" scope="col"><div><span>CZ</span></div></th>
                             <th class="rotate-45" title="% of h‐bond donor points" scope="col"><div><span>N</span></div></th>
                             <th class="rotate-45" title="% of h‐bond acceptor points" scope="col"><div><span>O</span></div></th>
                             <th class="rotate-45" title="% of h‐bond acceptor & donor points" scope="col"><div><span>OG</span></div></th>
                             <th class="rotate-45" title="% of positively ionizable points" scope="col"><div><span>NZ</span></div></th>
                             <th class="rotate-45" title="% of negatively ionizable points" scope="col"><div><span>OD1</span></div></th>
-                            <th class="rotate-45" title="% of non specific cavity points" scope="col"><div><span>DU</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness below 33.3%" scope="col"><div><span>T40</div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 33.3% and 41.6%" scope="col"><div><span>T40-50</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 41.6% and 50.0%" scope="col"><div><span>T50-60</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 50.0% and 58.3%" scope="col"><div><span>T60-70</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 58.3% and 66.6%" scope="col"><div><span>T70-80</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 66.6% and 75.0%" scope="col"><div><span>T80-90</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 75.0% and 83.3%" scope="col"><div><span>T90-100</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 83.3% and 91.6%" scope="col"><div><span>T100-110</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness between 91.6% and 99.9%" scope="col"><div><span>T110-120</span></div></th>
-                            <th class="rotate-45" title="% cavity points with buridness of 100%" scope="col"><div><span>T120</span></div></th>
+                            <th class="rotate-45" title="% of non specific pocket points" scope="col"><div><span>DU</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness below 33.3%" scope="col"><div><span>T40</div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 33.3% and 41.6%" scope="col"><div><span>T40-50</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 41.6% and 50.0%" scope="col"><div><span>T50-60</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 50.0% and 58.3%" scope="col"><div><span>T60-70</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 58.3% and 66.6%" scope="col"><div><span>T70-80</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 66.6% and 75.0%" scope="col"><div><span>T80-90</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 75.0% and 83.3%" scope="col"><div><span>T90-100</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 83.3% and 91.6%" scope="col"><div><span>T100-110</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness between 91.6% and 99.9%" scope="col"><div><span>T110-120</span></div></th>
+                            <th class="rotate-45" title="% pocket points with buridness of 100%" scope="col"><div><span>T120</span></div></th>
                           </tr>
                          </thead>
                          <tbody>
@@ -216,43 +239,51 @@
                                 <tr id="cavity_{{ cavity.id }}" class="table-light" >
                                     <th class="zui-sticky-col text-nowrap">
                                         
-                                        <i class="far fa-plus-square" data-toggle="collapse" data-target=".collapseme{{ chaincount }}_{{ cavcount }}"></i>
+                                        <i class="far fa-plus-square" style="cursor: pointer;" data-toggle="collapse" data-target=".collapseme{{ chaincount }}_{{ cavcount }}"></i>
                                         <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ cavity.chain.pdb.code }}">{{ cavity.chain.pdb.code }}</a>
                                         / 
                                         <span class="dropdown">
-                                        <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="uniprot: {{ cavity.chain.protein.uniprot_id }}">
-                                            {{ cavity.chain.pdb_chain_id }} / {{ cavity.chain.protein.short_name }}
-                                        </button>
+                                        <div class="dropbtn" data-toggle="dropdown" title="uniprot: {{ cavity.chain.protein.uniprot_id }}">
+                                            {{ cavity.chain.pdb_chain_id }} | {{ cavity.chain.protein.short_name }}
+                                        </div>
                                         <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ cavity.chain.protein.uniprot_id }}">Query UniprotID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ cavity.chain.protein.uniprot_id }}">Query UniprotID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?uniprot_id={{ cavity.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
                                         </div>
                                         </span>
-                                        {% if cavity.partner.ligand %}
                                         / 
                                         <span class="dropdown">
-                                        <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="smiles: {{ cavity.partner.ligand.canonical_smile }}">
+                                            <div class="dropbtn" data-toggle="dropdown">
+                                                {{ cavity.cavity_number }}
+                                            </div>
+                                        <div class="dropdown-content">
+                                        <a target="_blank" rel="noopener noreferrer" href="{% url 'networks' %}?search={{ cavity|build_name }}"> Query pocket in pocketome</a>
+                                        </div>
+                                        </span>
+                                        ::
+                                        {% if cavity.partner.ligand %}
+                                        <span class="dropdown">
+                                        <div class="dropbtn" data-toggle="dropdown" title="smiles: {{ cavity.partner.ligand.canonical_smile }}">
                                             {{ cavity.partner.ligand.pdb_ligand_id }}_{{ cavity.partner.ligand.supplementary_id }}
-                                        </button>
+                                        </div>
                                         <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?ligandcode={{ cavity.partner.ligand.pdb_ligand_id }}">Query ligand ID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?ligandcode={{ cavity.partner.ligand.pdb_ligand_id }}">Query ligand ID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?similar_to=ECFP4:{{ cavity.partner.ligand.canonical_smile|urlencode }}">Query SMILES in iPPI-DB compounds</a>
                                         </div>
                                         </span>
                                         {% else %}
-                                        / 
                                         <span class="dropdown">
-                                        <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="uniprot: {{ cavity.partner.chain.protein.uniprot_id }}">
-                                            {{ cavity.partner.chain.pdb_chain_id }}
-                                        </button>
+                                        <div class="dropbtn" data-toggle="dropdown" title="uniprot: {{ cavity.partner.chain.protein.uniprot_id }}">
+                                            {{ cavity.partner.chain.pdb_chain_id }} | {{ cavity.partner.chain.protein.short_name }}
+                                        </div>
                                         <div class="dropdown-content">
-                                        <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ cavity.partner.chain.protein.uniprot_id }}">Query UniprotID in cavities</a>
+                                        <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ cavity.partner.chain.protein.uniprot_id }}">Query UniprotID in pockets</a>
                                         <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?uniprot_id={{ cavity.partner.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
                                         </div>
                                         </span>
                                         {% endif %}
-                                        / {{ cavity.cavity_number }}
                                     </th>
+                                    <td>{% if cavity.partner.ligand %}PL{% else %}HD{% endif %}</td>
                                     <td>{{ cavity.volume|floatformat:0 }}</td>
                                     <td>{{ cavity.npr1|floatformat:2 }}</td>
                                     <td>{{ cavity.npr2|floatformat:2 }}</td>
@@ -287,39 +318,47 @@
                                             <a title="{{ distance.distance|get_zscore:avg_std|floatformat:3|intcomma }}" target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ distance.cavity2.chain.pdb.code }}">{{ distance.cavity2.chain.pdb.code }}</a>
                                             / 
                                             <span class="dropdown">
-                                            <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="uniprot: {{ distance.cavity2.chain.protein.uniprot_id }}">
-                                                {{ distance.cavity2.chain.pdb_chain_id }} / {{ distance.cavity2.chain.protein.short_name }}
-                                            </button>
+                                            <div class="dropbtn" data-toggle="dropdown" title="uniprot: {{ distance.cavity2.chain.protein.uniprot_id }}">
+                                                {{ distance.cavity2.chain.pdb_chain_id }} | {{ distance.cavity2.chain.protein.short_name }}
+                                            </div>
                                             <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity2.chain.protein.uniprot_id }}">Query UniprotID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity2.chain.protein.uniprot_id }}">Query UniprotID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?uniprot_id={{ distance.cavity2.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
                                             </div>
                                             </span>
+                                            /  
+                                            <span class="dropdown">
+                                                <div class="dropbtn" data-toggle="dropdown">
+                                                    {{ distance.cavity2.cavity_number }}
+                                                </div>
+                                            <div class="dropdown-content">
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'networks' %}?search={{ distance.cavity2|build_name }}"> Query pocket in pocketome</a>
+                                            </div>
+                                            </span>
+                                            ::
                                         {% if distance.cavity2.partner.ligand %}
-                                            / 
                                             <span class="dropdown">
-                                            <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="smiles: {{ distance.cavity2.partner.ligand.canonical_smile }}">
-                                            {{ distance.cavity2.partner.ligand.pdb_ligand_id }}_{{ distance.cavity2.partner.ligand.supplementary_id }}
-                                            </button>
+                                            <div class="dropbtn" data-toggle="dropdown" title="smiles: {{ distance.cavity2.partner.ligand.canonical_smile }}">
+                                                {{ distance.cavity2.partner.ligand.pdb_ligand_id }}_{{ distance.cavity2.partner.ligand.supplementary_id }}
+                                            </div>
                                             <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?ligandcode={{ distance.cavity2.partner.ligand.pdb_ligand_id }}">Query ligand ID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?ligandcode={{ distance.cavity2.partner.ligand.pdb_ligand_id }}">Query ligand ID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?similar_to=ECFP4:{{ distance.cavity2.partner.ligand.canonical_smile|urlencode }}">Query SMILES in iPPI-DB compounds</a>
                                             </div>
                                             </span>
                                         {% else %}
-                                            / 
                                             <span class="dropdown">
-                                            <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="uniprot: {{ distance.cavity2.partner.chain.protein.uniprot_id }}">
-                                                {{ distance.cavity2.partner.chain.pdb_chain_id }}
-                                            </button>
+                                            <div class="dropbtn" data-toggle="dropdown" title="uniprot: {{ distance.cavity2.partner.chain.protein.uniprot_id }}">
+                                                {{ distance.cavity2.partner.chain.pdb_chain_id }} | {{ distance.cavity2.partner.chain.protein.short_name }}
+                                            </div>
                                             <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity2.partner.chain.protein.uniprot_id }}">Query UniprotID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity2.partner.chain.protein.uniprot_id }}">Query UniprotID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?uniprot_id={{ distance.cavity2.partner.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
                                             </div>
                                             </span>
                                         {% endif %}
-                                            / {{ distance.cavity2.cavity_number }}
                                         </th>
+                                        <td>{% if distance.cavity2.partner.ligand %}PL{% else %}HD{% endif %}</td>
                                         <td>{{ distance.cavity2.volume|floatformat:0 }}</td>
                                         <td>{{ distance.cavity2.npr1|floatformat:2 }}</td>
                                         <td>{{ distance.cavity2.npr2|floatformat:2 }}</td>
@@ -352,39 +391,47 @@
                                             <a title="{{ distance.distance|get_zscore:avg_std|floatformat:3|intcomma }}" target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?pdbsearch={{ distance.cavity1.chain.pdb.code }}">{{ distance.cavity1.chain.pdb.code }}</a>
                                             / 
                                             <span class="dropdown">
-                                            <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="uniprot:  {{ distance.cavity1.chain.protein.uniprot_id }}">
-                                                {{ distance.cavity1.chain.pdb_chain_id }} / {{ distance.cavity1.chain.protein.short_name }}  
-                                            </button>
+                                            <div class="dropbtn" data-toggle="dropdown" title="uniprot:  {{ distance.cavity1.chain.protein.uniprot_id }}">
+                                                {{ distance.cavity1.chain.pdb_chain_id }} | {{ distance.cavity1.chain.protein.short_name }}
+                                            </div>
+                                            <div class="dropdown-content">
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity1.chain.protein.uniprot_id }}">Query UniprotID in pockets</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?uniprot_id={{ distance.cavity1.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
+                                            </div>
+                                            </span>
+                                            / 
+                                            <span class="dropdown">
+                                                <div class="dropbtn" data-toggle="dropdown">
+                                                    {{ distance.cavity1.cavity_number }}
+                                                </div>
                                             <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity1.chain.protein.uniprot_id }}">Query UniprotID in cavities</a>
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprot_id={{ distance.cavity1.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'networks' %}?search={{ distance.cavity1|build_name }}"> Query pocket in pocketome</a>
                                             </div>
                                             </span>
+                                            ::
                                         {% if distance.cavity1.partner.ligand %}
-                                            / 
                                             <span class="dropdown">
-                                            <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="smiles: {{ distance.cavity1.partner.ligand.canonical_smile }}">
-                                            {{ distance.cavity1.partner.ligand.pdb_ligand_id }}_{{ distance.cavity1.partner.ligand.supplementary_id }}
-                                            </button>
+                                            <div class="dropbtn" data-toggle="dropdown" title="smiles: {{ distance.cavity1.partner.ligand.canonical_smile }}">
+                                                {{ distance.cavity1.partner.ligand.pdb_ligand_id }}_{{ distance.cavity1.partner.ligand.supplementary_id }}
+                                            </div>
                                             <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?ligandcode={{ distance.cavity1.partner.ligand.pdb_ligand_id }}">Query ligand ID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?ligandcode={{ distance.cavity1.partner.ligand.pdb_ligand_id }}">Query ligand ID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?similar_to=ECFP4:{{ distance.cavity1.partner.ligand.canonical_smile|urlencode }}">Query SMILES in iPPI-DB compounds</a>
                                             </div>
                                             </span>
                                         {% else %}
-                                            / 
                                             <span class="dropdown">
-                                            <button class="dropbtn btn-outline-secondary" data-toggle="dropdown" title="uniprot: {{ distance.cavity1.partner.chain.protein.uniprot_id }}">
-                                                {{ distance.cavity1.partner.chain.pdb_chain_id }}
-                                            </button>
+                                            <div class="dropbtn" data-toggle="dropdown" title="uniprot: {{ distance.cavity1.partner.chain.protein.uniprot_id }}">
+                                                {{ distance.cavity1.partner.chain.pdb_chain_id }} | {{ distance.cavity1.partner.chain.protein.short_name }}
+                                            </div>
                                             <div class="dropdown-content">
-                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity1.partner.chain.protein.uniprot_id }}">Query UniprotID in cavities</a>
+                                            <a target="_blank" rel="noopener noreferrer" href="{% url 'cavities' %}?uniprotid={{ distance.cavity1.partner.chain.protein.uniprot_id }}">Query UniprotID in pockets</a>
                                             <a target="_blank" rel="noopener noreferrer" href="{% url 'compound_list' %}?uniprot_id={{ distance.cavity1.partner.chain.protein.uniprot_id }}">Query UniprotID as iPPI-DB target</a>
                                             </div>
                                             </span>
                                         {% endif %}
-                                            / {{ distance.cavity1.cavity_number }}
                                         </th>
+                                        <td>{% if distance.cavity1.partner.ligand %}PL{% else %}HD{% endif %}</td>
                                         <td>{{ distance.cavity1.volume|floatformat:0 }}</td>
                                         <td>{{ distance.cavity1.npr1|floatformat:2 }}</td>
                                         <td>{{ distance.cavity1.npr2|floatformat:2 }}</td>
diff --git a/ippisite/ippidb/templates/targetcentric_networks.html b/ippisite/ippidb/templates/targetcentric_networks.html
index 5e11b50615c00f2945771525d5dc30f7ceb815c9..1e240fd67833c1bd32760ce43cd0cf88c79b03d7 100644
--- a/ippisite/ippidb/templates/targetcentric_networks.html
+++ b/ippisite/ippidb/templates/targetcentric_networks.html
@@ -13,11 +13,10 @@
     <nav class="breadcrumb breadNav" role="navigation">
         <div class="breadNav-label">You are here</div>
         <div aria-labelledby="breadNav-label">
-          {% block breadcrumb %} <a href="{% url 'networks' %}" class="breadNav-link">Query cavities</a> > Cavity {% endblock %}
+          {% block breadcrumb %} <a href="{% url 'networks' %}" class="breadNav-link">Query pockets</a> > Pocket {% endblock %}
         </div>
     </nav>
     <div class="card">
-      
       <div class="input-group">
         <div class="btn-group">
           <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@@ -28,13 +27,18 @@
             <a class="dropdown-item {% if net.id == network.id %}active{% endif %}" href="{% url 'networks' %}?currentjson={{ net.id }}">{{ net.label }}</a>
             {% endfor %}
           </div>
-          </div>
+        </div>
           <p>
             <a class="infobulle" href='#'>
               <i class="fas fa-question-circle fa-2x m-1 mt-3"></i>
-              <span>Vicinity network of the PPI pocketome: Displays pockets having a pocket similarity index (PSI) with at least one other pocket above 0.65 
+              <span>Vicinity network of the PPI pocketome: Displays pockets having a pocket similarity index (PSI) with at least one other pocket above 0.65.
                     <br><br>Vicinity network of PPI pockets (non-redundant): Same as above but by only considering similar pockets within proteins having a different Uniprot ID. 
                      The purpose is this network is to highlight unforeseen vicinities within the PPI pocketome.
+                     <br> <br>
+                     <i>mouse hover pocket to show closest pockets
+                     <br>
+                     mouse left-click on pocket to load details on protein (pockets, 3d structure, pockets descriptors...)
+                     </i>
               </span>
             </a>
           </p>
@@ -43,6 +47,12 @@
               <button type="button" class="btn btn-outline-secondary search-button"><i class="fas fa-search"></i></button>
           </div>
       </div>
+      <div id="message_warning" class="alert alert-warning alert-dismissible fade hide" role="alert">
+        
+        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
+          <span aria-hidden="true">&times;</span>
+        </button>
+      </div>
       {% block messages %}
     
     {% if messages %}
diff --git a/ippisite/ippidb/templatetags/customtags.py b/ippisite/ippidb/templatetags/customtags.py
index 91be01cfac97ad42094a16761772c0b269a17764..b5ee094e67a1824e771a2cd10cd90dad4ac4fabd 100644
--- a/ippisite/ippidb/templatetags/customtags.py
+++ b/ippisite/ippidb/templatetags/customtags.py
@@ -281,4 +281,32 @@ def get_color(ratio):
 @register.filter
 def make_list(avg_std):
     step = 1 / 25
-    return np.flip(np.arange(0, 1 + step, step))
+    return np.arange(0, 1 + step, step)
+
+
+@register.filter
+def to_minus(value):
+    return value.replace("_", "-")
+
+
+@register.filter
+def build_name(cavity):
+    if cavity.partner.is_ligand:
+        return "{}-{}-{}-{}-{}_CAVITY_N{}".format(
+            cavity.chain.pdb.code,
+            cavity.chain.pdb_chain_id,
+            cavity.chain.protein.uniprot_id,
+            cavity.partner.ligand.pdb_ligand_id,
+            cavity.partner.ligand.supplementary_id,
+            cavity.cavity_number,
+        )
+    else:
+        return "{}-{}{}-{}-{}-within{}_CAVITY_N{}".format(
+            cavity.chain.pdb.code,
+            cavity.chain.pdb_chain_id,
+            cavity.partner.chain.pdb_chain_id,
+            cavity.chain.protein.uniprot_id,
+            cavity.partner.chain.protein.uniprot_id,
+            cavity.chain.pdb_chain_id,
+            cavity.cavity_number,
+        )