diff --git a/client/gulpfile.js b/client/gulpfile.js index 45ba4957fab..c0d010cb852 100644 --- a/client/gulpfile.js +++ b/client/gulpfile.js @@ -1,7 +1,7 @@ const path = require("path"); const fs = require("fs"); const del = require("del"); -const { src, dest, series, parallel } = require("gulp"); +const { src, dest, series, parallel, watch } = require("gulp"); const child_process = require("child_process"); const glob = require("glob"); @@ -10,14 +10,17 @@ const glob = require("glob"); * un-built visualizations in the repository; for performance and * simplicity just add them one at a time until we upgrade older viz's. */ -const PLUGIN_BUILD_DIRS = [ +const PLUGIN_BUILD_IDS = [ "annotate_image", "chiraviz", "editor", + "heatmap/heatmap_default", "hyphyvision", "media_player", "mvpapp", + "ngl", "openlayers", + "pv", ]; const paths = { @@ -26,7 +29,7 @@ const paths = { "../config/plugins/{visualizations,interactive_environments}/*/static/**/*", "../config/plugins/{visualizations,interactive_environments}/*/*/static/**/*", ], - plugin_build_dirs: [`../config/plugins/visualizations/{${PLUGIN_BUILD_DIRS.join(",")}}/package.json`], + plugin_build_modules: [`../config/plugins/visualizations/{${PLUGIN_BUILD_IDS.join(",")}}/package.json`], lib_locs: { // This is a stepping stone towards having all this staged // automatically. Eventually, this dictionary and staging step will @@ -73,10 +76,10 @@ function stagePlugins() { function buildPlugins(callback) { /* - * Walk plugin_build_dirs glob and attempt to build modules. + * Walk plugin_build_modules glob and attempt to build modules. * */ - paths.plugin_build_dirs.map((build_dir) => { - glob(build_dir, {}, (er, files) => { + paths.plugin_build_modules.map((build_module) => { + glob(build_module, {}, (er, files) => { files.map((file) => { let skip_build = false; const f = path.join(process.cwd(), file).slice(0, -12); @@ -120,10 +123,15 @@ function cleanPlugins() { return del(["../static/plugins/{visualizations,interactive_environments}/*"], { force: true }); } -client = parallel(fonts, stageLibs); -plugins = series(buildPlugins, cleanPlugins, stagePlugins); +const client = parallel(fonts, stageLibs); +const plugins = series(buildPlugins, cleanPlugins, stagePlugins); + +function watchPlugins() { + const BUILD_PLUGIN_WATCH_GLOB = [`../config/plugins/visualizations/{${PLUGIN_BUILD_IDS.join(",")}}/**/*`]; + watch(BUILD_PLUGIN_WATCH_GLOB, { queue: false }, plugins); +} module.exports.client = client; module.exports.plugins = plugins; - +module.exports.watchPlugins = watchPlugins; module.exports.default = parallel(client, plugins); diff --git a/client/package.json b/client/package.json index d4c1a92aa96..eae0defc282 100644 --- a/client/package.json +++ b/client/package.json @@ -110,7 +110,7 @@ "duplicate-package-checker-webpack-plugin": "^3.0.0", "eslint": "^7.7.0", "eslint-plugin-vue": "^6.2.2", - "expose-loader": "^0.7.5", + "expose-loader": "^1.0.0", "file-loader": "^6.0.0", "gulp": "^4.0.2", "ignore-loader": "^0.1.2", diff --git a/client/src/bundleEntries.js b/client/src/bundleEntries.js index 73fc7b57d2d..a9c6b0fff13 100644 --- a/client/src/bundleEntries.js +++ b/client/src/bundleEntries.js @@ -7,8 +7,10 @@ * will handle initializations for components individually. */ +/* jquery and _ are exposed via expose-loader while several external plugins rely on these */ import $ from "jquery"; -import "bootstrap"; +import _ from "expose-loader?exposes[]=_&exposes[]=underscore!underscore"; // eslint-disable-line no-unused-vars + export { getGalaxyInstance, setGalaxyInstance } from "app"; import { TracksterUIView } from "viz/trackster"; export { TracksterUI } from "viz/trackster"; diff --git a/client/src/components/Panels/ToolBox.vue b/client/src/components/Panels/ToolBox.vue index 41e11007be8..4c6f31bb66d 100644 --- a/client/src/components/Panels/ToolBox.vue +++ b/client/src/components/Panels/ToolBox.vue @@ -17,9 +17,11 @@ {{ buttonText }} -
- Search string too short! - No results found! +
+ Search string too short! +
+
+ No results found!
@@ -70,6 +72,7 @@ export default { query: null, results: null, queryFilter: null, + queryPending: false, showSections: false, buttonText: "", buttonIcon: "", @@ -90,6 +93,12 @@ export default { }, }, computed: { + queryTooShort() { + return this.query && this.query.length < 3; + }, + queryFinished() { + return this.query && this.queryPending != true; + }, sections() { if (this.showSections) { return filterToolSections(this.toolbox, this.results); @@ -124,11 +133,13 @@ export default { methods: { onQuery(query) { this.query = query; + this.queryPending = true; }, onResults(results) { this.results = results; this.queryFilter = this.hasResults ? this.query : null; this.setButtonText(); + this.queryPending = false; }, onFavorites(term) { this.query = term; diff --git a/client/webpack.config.js b/client/webpack.config.js index 8cf36fe071e..7f73f48b442 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -88,11 +88,9 @@ module.exports = (env = {}, argv = {}) => { use: [ { loader: "expose-loader", - options: "jQuery", - }, - { - loader: "expose-loader", - options: "$", + options: { + exposes: ["jQuery", "$"], + }, }, ], }, @@ -101,11 +99,9 @@ module.exports = (env = {}, argv = {}) => { use: [ { loader: "expose-loader", - options: "_", - }, - { - loader: "expose-loader", - options: "underscore", + options: { + exposes: ["underscore", "_"], + }, }, ], }, @@ -128,7 +124,9 @@ module.exports = (env = {}, argv = {}) => { use: [ { loader: "expose-loader", - options: "bundleEntries", + options: { + exposes: "bundleEntries", + }, }, ], }, @@ -137,7 +135,7 @@ module.exports = (env = {}, argv = {}) => { use: [ { loader: "expose-loader", - options: "config", + options: { exposes: "config" }, }, ], }, diff --git a/client/yarn.lock b/client/yarn.lock index cb96d2661bd..ebcd9daec68 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -5655,10 +5655,13 @@ expect@^26.4.2: jest-message-util "^26.3.0" jest-regex-util "^26.0.0" -expose-loader@^0.7.5: - version "0.7.5" - resolved "https://registry.yarnpkg.com/expose-loader/-/expose-loader-0.7.5.tgz#e29ea2d9aeeed3254a3faa1b35f502db9f9c3f6f" - integrity sha512-iPowgKUZkTPX5PznYsmifVj9Bob0w2wTHVkt/eYNPSzyebkUgIedmskf/kcfEIWpiWjg3JRjnW+a17XypySMuw== +expose-loader@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/expose-loader/-/expose-loader-1.0.0.tgz#1676dde8fce6662584e17f8531e24d2afe8dae11" + integrity sha512-xgt47+pEQrlCyCoO09cMKWf5qiurK6qMtvjUPm8+Uso5WwkNHeD47P0Zb3R9Kvk5zUcJWLax95xaaXDJCmoNjw== + dependencies: + loader-utils "^2.0.0" + schema-utils "^2.6.6" express@^4.17.1: version "4.17.1" diff --git a/config/plugins/visualizations/heatmap/heatmap_cluster/config/heatmap_cluster.xml b/config/plugins/visualizations/heatmap/heatmap_cluster/config/heatmap_cluster.xml index 035f9691513..3ca7d59172b 100644 --- a/config/plugins/visualizations/heatmap/heatmap_cluster/config/heatmap_cluster.xml +++ b/config/plugins/visualizations/heatmap/heatmap_cluster/config/heatmap_cluster.xml @@ -5,7 +5,7 @@ ../../heatmap_default/config/heatmap_shared.xml Applies hierarchical clustering to a matrix using R. The data has to be provided in 3-column format. The result is displayed as clustered heatmap. - + svg diff --git a/config/plugins/visualizations/heatmap/heatmap_default/config/heatmap_default.xml b/config/plugins/visualizations/heatmap/heatmap_default/config/heatmap_default.xml index dc1ba9ac3c2..589a7deecb2 100644 --- a/config/plugins/visualizations/heatmap/heatmap_default/config/heatmap_default.xml +++ b/config/plugins/visualizations/heatmap/heatmap_default/config/heatmap_default.xml @@ -5,7 +5,7 @@ heatmap_shared.xml Renders a heatmap from matrix data provided in 3-column format (x, y, observation). - + svg diff --git a/config/plugins/visualizations/heatmap/heatmap_default/package.json b/config/plugins/visualizations/heatmap/heatmap_default/package.json index e6bdca108dc..6889e031305 100644 --- a/config/plugins/visualizations/heatmap/heatmap_default/package.json +++ b/config/plugins/visualizations/heatmap/heatmap_default/package.json @@ -8,13 +8,14 @@ "license": "AFL-3.0", "dependencies": { "babel-preset-env": "^1.6.1", - "backbone": "^1.3.3", + "backbone": "^1.4.0", "bootstrap": "^3.3.7", "d3": "3", - "jquery": "^3.1.1", - "parcel-bundler": "^1.4.1" + "jquery": "^3.5.1", + "parcel-bundler": "^1.4.1", + "underscore": "^1.11.0" }, "scripts": { - "build": "parcel build src/script.js -d static" + "build": "parcel build src/script.js -d static/dist" } } diff --git a/config/plugins/visualizations/heatmap/heatmap_default/src/script.js b/config/plugins/visualizations/heatmap/heatmap_default/src/script.js index ccec12d7726..d886f46eeab 100644 --- a/config/plugins/visualizations/heatmap/heatmap_default/src/script.js +++ b/config/plugins/visualizations/heatmap/heatmap_default/src/script.js @@ -1,10 +1,9 @@ +import _ from "underscore"; +import $ from "jquery"; import * as d3 from "d3"; +import Backbone from "backbone"; import Colors from "./colorsets"; -/* global Backbone */ -/* global _ */ -/* global $ */ - var Series = window.bundleEntries.chartUtilities.Series; var Datasets = window.bundleEntries.chartUtilities.Datasets; var Jobs = window.bundleEntries.chartUtilities.Jobs; @@ -15,12 +14,12 @@ var CommonWrapper = Backbone.View.extend({ top: 40, right: 70, bottom: 70, - left: 70 + left: 70, }, style: { "font-weight": "normal", "font-family": "Verdana", - "font-size": 12 + "font-size": 12, }, legend: { width: 15, @@ -28,15 +27,15 @@ var CommonWrapper = Backbone.View.extend({ style: { "font-weight": "normal", "font-family": "Verdana", - "font-size": 11 + "font-size": 11, }, - limit: 7 + limit: 7, }, background_color: "#FFFFFF", - debug_color: "#FFFFFF" + debug_color: "#FFFFFF", }, - initialize: function(options) { + initialize: function (options) { var self = this; this.chart = options.chart; this.canvas_id = options.canvas_id; @@ -55,26 +54,17 @@ var CommonWrapper = Backbone.View.extend({ this.yScale = d3.scale.linear().domain([0, this.categories.array.y.length]); // color scale - this.zMin = d3.min(this.data, function(d) { + this.zMin = d3.min(this.data, function (d) { return d.z; }); - this.zMax = d3.max(this.data, function(d) { + this.zMax = d3.max(this.data, function (d) { return d.z; }); - this.zScale = d3.scale - .quantize() - .domain([this.zMin, this.zMax]) - .range(this.color_set); + this.zScale = d3.scale.quantize().domain([this.zMin, this.zMax]).range(this.color_set); // create axis - this.xAxis = d3.svg - .axis() - .scale(this.xScale) - .orient("bottom"); - this.yAxis = d3.svg - .axis() - .scale(this.yScale) - .orient("left"); + this.xAxis = d3.svg.axis().scale(this.xScale).orient("bottom"); + this.yAxis = d3.svg.axis().scale(this.yScale).orient("left"); // make categories this._makeTickFormat("x"); @@ -89,22 +79,22 @@ var CommonWrapper = Backbone.View.extend({ .style("opacity", 0); // refresh on window resize - $(window).on("resize", function() { + $(window).on("resize", function () { self.redraw(); }); this.redraw(); Series.addZoom({ xAxis: this.xAxis, yAxis: this.yAxis, - redraw: function() { + redraw: function () { self.redraw(); }, - svg: d3.select("#" + this.canvas_id) + svg: d3.select("#" + this.canvas_id), }); }, /** Redraw */ - redraw: function() { + redraw: function () { // get/reset container var container = $("#" + this.canvas_id); container.empty(); @@ -157,7 +147,7 @@ var CommonWrapper = Backbone.View.extend({ }, /** Build boxes */ - _buildBoxes: function() { + _buildBoxes: function () { var self = this; var height = this.height; var width = this.width; @@ -172,15 +162,10 @@ var CommonWrapper = Backbone.View.extend({ } // set background color - svg - .append("rect") - .attr("width", width) - .attr("height", height) - .attr("fill", this.options.background_color); + svg.append("rect").attr("width", width).attr("height", height).attr("fill", this.options.background_color); // clip path - svg - .append("clipPath") + svg.append("clipPath") .attr("id", "clip") .append("rect") .attr("x", 0) @@ -192,13 +177,10 @@ var CommonWrapper = Backbone.View.extend({ var chartBody = svg.append("g").attr("clip-path", "url(#clip)"); // add boxes to chart area - var boxes = chartBody.selectAll("box-group").data(this.data, function(d, i) { + var boxes = chartBody.selectAll("box-group").data(this.data, function (d, i) { return d.x + "\0" + d.y; }); - var gEnter = boxes - .enter() - .append("g") - .attr("class", "box-group"); + var gEnter = boxes.enter().append("g").attr("class", "box-group"); gEnter.append("rect").attr("class", "heat-box"); boxes .selectAll("rect") @@ -212,7 +194,7 @@ var CommonWrapper = Backbone.View.extend({ // add tooltip events boxes .selectAll("rect") - .on("dblclick", function(d) { + .on("dblclick", function (d) { var url = self.chart.settings.get("url_template").trim(); if (url) { d3.event.stopPropagation(); @@ -222,7 +204,7 @@ var CommonWrapper = Backbone.View.extend({ window.open(url.replace("__LABEL__", yLabel)); } }) - .on("mouseover", function(d) { + .on("mouseover", function (d) { var matrix = this.getScreenCTM().translate(+this.getAttribute("cx"), +this.getAttribute("cy")); self.tooltip.style("opacity", 0.9); self.tooltip @@ -230,7 +212,7 @@ var CommonWrapper = Backbone.View.extend({ .style("left", window.pageXOffset + matrix.e + 15 + "px") .style("top", window.pageYOffset + matrix.f - 30 + "px"); }) - .on("mouseout", function(d) { + .on("mouseout", function (d) { self.tooltip.style("opacity", 0); }); @@ -242,7 +224,7 @@ var CommonWrapper = Backbone.View.extend({ }, /** Build x axis */ - _buildX: function() { + _buildX: function () { var height = this.height; var width = this.width; var margin = this.options.margin; @@ -264,15 +246,14 @@ var CommonWrapper = Backbone.View.extend({ .selectAll("text") .style(this.options.style) .style({ "font-size": xFontSize + "px" }) - .attr("transform", function(d) { + .attr("transform", function (d) { var y = -this.getBBox().height - 15; var x = -xFontSize + boxWidth / 2; return "rotate(-90)translate(" + y + "," + x + ")"; }); // set background color - svg - .append("rect") + svg.append("rect") .attr("width", width) .attr("height", font_size + 3) .attr("y", height + margin.bottom - font_size - 3) @@ -285,7 +266,7 @@ var CommonWrapper = Backbone.View.extend({ .attr("class", "x label") .style(this.options.style) .text(this.chart.settings.get("x_axis_label")) - .attr("transform", function(d) { + .attr("transform", function (d) { var y = height + margin.bottom - font_size / 3; var x = (width - this.getBBox().width) / 2; return "translate(" + x + "," + y + ")"; @@ -298,7 +279,7 @@ var CommonWrapper = Backbone.View.extend({ .style(this.options.style) .style({ "font-size": 1.1 * font_size }) .text(this.group.key) - .attr("transform", function(d) { + .attr("transform", function (d) { var y = -margin.top / 2; var x = (width - this.getBBox().width) / 2; return "translate(" + x + "," + y + ")"; @@ -306,7 +287,7 @@ var CommonWrapper = Backbone.View.extend({ }, /** Build y axis */ - _buildY: function() { + _buildY: function () { var height = this.height; var margin = this.options.margin; var svg = this.svg; @@ -314,11 +295,7 @@ var CommonWrapper = Backbone.View.extend({ var boxHeight = this.boxHeight; // draw y axis - this.gyAxis = svg - .append("g") - .attr("class", "y axis") - .style("stroke-width", 1) - .call(this.yAxis); + this.gyAxis = svg.append("g").attr("class", "y axis").style("stroke-width", 1).call(this.yAxis); // fix text var yFontSize = Math.min(boxHeight, font_size); @@ -329,8 +306,7 @@ var CommonWrapper = Backbone.View.extend({ .attr("y", -boxHeight / 2); // set background color - svg - .append("rect") + svg.append("rect") .attr("width", font_size) .attr("height", height) .attr("x", -margin.left) @@ -343,7 +319,7 @@ var CommonWrapper = Backbone.View.extend({ .attr("class", "y label") .style(this.options.style) .text(this.chart.settings.get("y_axis_label")) - .attr("transform", function(d) { + .attr("transform", function (d) { var x = -margin.left + font_size - 2; var y = -(height + this.getBBox().width) / 2; return "rotate(-90)translate(" + y + "," + x + ")"; @@ -351,7 +327,7 @@ var CommonWrapper = Backbone.View.extend({ }, /** Build legend */ - _buildLegend: function() { + _buildLegend: function () { var self = this; var height = this.height; var width = this.width; @@ -361,9 +337,9 @@ var CommonWrapper = Backbone.View.extend({ var legendSize = this.options.legend.size; var legendWidth = this.options.legend.width; var legendElements = this.zScale.range().length; - var legendElementHeight = Math.max(legendSize * height / legendElements, font_size); - var legendHeight = legendElements * legendElementHeight / 2; - var data = d3.range(this.zMin, this.zMax, 2 * (this.zMax - this.zMin) / legendElements).reverse(); + var legendElementHeight = Math.max((legendSize * height) / legendElements, font_size); + var legendHeight = (legendElements * legendElementHeight) / 2; + var data = d3.range(this.zMin, this.zMax, (2 * (this.zMax - this.zMin)) / legendElements).reverse(); if (data.length < 2) { return; } @@ -373,7 +349,7 @@ var CommonWrapper = Backbone.View.extend({ .enter() .append("g") .attr("class", "legend") - .attr("transform", function(d, i) { + .attr("transform", function (d, i) { var x = width + 10; var y = (height - legendHeight) / 2 + i * legendElementHeight; return "translate(" + x + "," + y + ")"; @@ -382,17 +358,17 @@ var CommonWrapper = Backbone.View.extend({ .append("rect") .attr("width", legendWidth) .attr("height", legendElementHeight) - .style("fill", function(z) { + .style("fill", function (z) { return self.zScale(z); }); legend .append("text") .attr("x", legendWidth + 4) - .attr("y", function() { + .attr("y", function () { return (legendElementHeight + this.getBBox().height) / 2; }) .style(this.options.legend.style) - .text(function(d) { + .text(function (d) { return String(d).length > limit ? String(d).substr(0, limit - 2) + ".." : String(d); }); this.svg @@ -400,7 +376,7 @@ var CommonWrapper = Backbone.View.extend({ .style(this.options.legend.style) .style({ "font-size": 9, "font-weight": "bold" }) .text("Legend") - .attr("transform", function(d, i) { + .attr("transform", function (d, i) { var x = width + (margin.right - this.getBBox().width) / 2; var y = (height - legendHeight) / 2 - 10; return "translate(" + x + "," + y + ")"; @@ -408,30 +384,30 @@ var CommonWrapper = Backbone.View.extend({ }, /** Create axes formatting */ - _makeTickFormat: function(id) { + _makeTickFormat: function (id) { var settings = this.chart.settings; var self = this; Series.makeTickFormat({ categories: self.categories.array[id], type: settings.get(id + "_axis_type|type"), precision: settings.get(id + "_axis_type|precision"), - formatter: function(formatter) { + formatter: function (formatter) { if (formatter) { - self[id + "Axis"].tickFormat(function(value) { + self[id + "Axis"].tickFormat(function (value) { return formatter(value); }); } - } + }, }); }, /** Handle error */ - _handleError: function(err) { + _handleError: function (err) { this.chart.state("failed", err); }, /** Main template */ - _templateTooltip: function(d) { + _templateTooltip: function (d) { var x = this.categories.array.x[d.x]; var y = this.categories.array.y[d.y]; var z = d.z; @@ -457,55 +433,55 @@ var CommonWrapper = Backbone.View.extend({ "" + "" ); - } + }, }); _.extend(window.bundleEntries || {}, { - heatmap_default: function(options) { - options.render = function(canvas_id, groups) { + heatmap_default: function (options) { + options.render = function (canvas_id, groups) { new CommonWrapper({ chart: options.chart, canvas_id: canvas_id, - groups: groups + groups: groups, }); return true; }; Datasets.requestPanels(options); }, - heatmap_cluster: function(options) { + heatmap_cluster: function (options) { Jobs.request( options.chart, Jobs.requestCharts(options.chart, "heatmap"), - function(dataset) { + function (dataset) { var dataset_groups = new Backbone.Collection(); - options.chart.groups.each(function(group, index) { + options.chart.groups.each(function (group, index) { dataset_groups.add({ __data_columns: { x: { is_label: true }, y: { is_label: true }, - z: { is_numeric: true } + z: { is_numeric: true }, }, x: index++, y: index++, z: index++, - key: group.get("key") + key: group.get("key"), }); }); options.dataset_id = dataset.id; options.dataset_groups = dataset_groups; - options.render = function(canvas_id, groups) { + options.render = function (canvas_id, groups) { new CommonWrapper({ chart: options.chart, canvas_id: canvas_id, - groups: groups + groups: groups, }); return true; }; Datasets.requestPanels(options); }, - function() { + function () { options.process.reject(); } ); - } + }, }); diff --git a/config/plugins/visualizations/heatmap/heatmap_default/static/script.js b/config/plugins/visualizations/heatmap/heatmap_default/static/script.js deleted file mode 100644 index 93ab71383ee..00000000000 --- a/config/plugins/visualizations/heatmap/heatmap_default/static/script.js +++ /dev/null @@ -1,8 +0,0 @@ -parcelRequire=function(e,r,n){var t="function"==typeof parcelRequire&&parcelRequire,i="function"==typeof require&&require;function u(n,o){if(!r[n]){if(!e[n]){var f="function"==typeof parcelRequire&&parcelRequire;if(!o&&f)return f(n,!0);if(t)return t(n,!0);if(i&&"string"==typeof n)return i(n);var c=new Error("Cannot find module '"+n+"'");throw c.code="MODULE_NOT_FOUND",c}a.resolve=function(r){return e[n][1][r]||r};var l=r[n]=new u.Module(n);e[n][0].call(l.exports,a,l,l.exports)}return r[n].exports;function a(e){return u(a.resolve(e))}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=r,u.parent=t;for(var o=0;ot?1:n>=t?0:NaN}function h(n){return null===n?NaN:+n}function p(n){return!isNaN(n)}function g(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);r>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);r>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}n.ascending=s,n.descending=function(n,t){return tn?1:t>=n?0:NaN},n.min=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ir&&(e=r)}else{for(;++i=r){e=r;break}for(;++ir&&(e=r)}return e},n.max=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ie&&(e=r)}else{for(;++i=r){e=r;break}for(;++ie&&(e=r)}return e},n.extent=function(n,t){var e,r,i,u=-1,o=n.length;if(1===arguments.length){for(;++u=r){e=i=r;break}for(;++ur&&(e=r),i=r){e=i=r;break}for(;++ur&&(e=r),i1)return o/(l-1)},n.deviation=function(){var t=n.variance.apply(this,arguments);return t?Math.sqrt(t):t};var v=g(s);function d(n){return n.length}n.bisectLeft=v.left,n.bisect=n.bisectRight=v.right,n.bisector=function(n){return g(1===n.length?function(t,e){return s(n(t),e)}:n)},n.shuffle=function(n,t,e){(u=arguments.length)<3&&(e=n.length,u<2&&(t=0));for(var r,i,u=e-t;u;)i=Math.random()*u--|0,r=n[u+t],n[u+t]=n[i+t],n[i+t]=r;return n},n.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},n.pairs=function(n){for(var t=0,e=n.length-1,r=n[0],i=new Array(e<0?0:e);t=0;)for(t=(r=n[i]).length;--t>=0;)e[--o]=r[t];return e};var y=Math.abs;function m(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function M(){this._=Object.create(null)}n.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e==1/0)throw new Error("infinite range");var r,i=[],u=function(n){var t=1;for(;n*t%1;)t*=10;return t}(y(e)),o=-1;if(n*=u,t*=u,(e*=u)<0)for(;(r=n+e*++o)>t;)i.push(r/u);else for(;(r=n+e*++o)=i.length)return e?e.call(r,u):t?u.sort(t):u;for(var l,c,f,s,h=-1,p=u.length,g=i[a++],v=new M;++h=i.length)return t;var r=[],o=u[e++];return t.forEach(function(t,i){r.push({key:t,values:n(i,e)})}),o?r.sort(function(n,t){return o(n.key,t.key)}):r}(o(n.map,t,0),0)},r.key=function(n){return i.push(n),r},r.sortKeys=function(n){return u[i.length-1]=n,r},r.sortValues=function(n){return t=n,r},r.rollup=function(n){return e=n,r},r},n.set=function(n){var t=new C;if(n)for(var e=0,r=n.length;e=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},n.event=null,n.requote=function(n){return n.replace(H,"\\$&")};var H=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,O={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]};function I(n){return O(n,X),n}var Y=function(n,t){return t.querySelector(n)},Z=function(n,t){return t.querySelectorAll(n)},V=function(n,t){var e=n.matches||n[q(n,"matchesSelector")];return(V=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(Y=function(n,t){return Sizzle(n,t)[0]||null},Z=Sizzle,V=Sizzle.matchesSelector),n.selection=function(){return n.select(r.documentElement)};var X=n.selection.prototype=[];function $(n){return"function"==typeof n?n:function(){return Y(n,this)}}function B(n){return"function"==typeof n?n:function(){return Z(n,this)}}X.select=function(n){var t,e,r,i,u=[];n=$(n);for(var o=-1,a=this.length;++o=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),J.hasOwnProperty(e)?{space:J[e],local:n}:n}},X.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return(t=n.ns.qualify(t)).local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(G(e,t[e]));return this}return this.each(G(t,e))},X.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=nn(n)).length,i=-1;if(t=e.classList){for(;++i=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},X.sort=function(n){n=function(n){arguments.length||(n=s);return function(t,e){return t&&e?n(t.__data__,e.__data__):!t-!e}}.apply(this,arguments);for(var t=-1,e=this.length;++t0&&(t=t.slice(0,o));var l=gn.get(t);function c(){var n=this[u];n&&(this.removeEventListener(t,n,n.$),delete this[u])}return l&&(t=l,a=dn),o?r?function(){var n=a(r,e(arguments));c.call(this),this.addEventListener(t,this[u]=n,n.$=i),n._=r}:c:r?R:function(){var e,r=new RegExp("^__on([^.]+)"+n.requote(t)+"$");for(var i in this)if(e=i.match(r)){var u=this[i];this.removeEventListener(e[1],u,u.$),delete this[i]}}}n.selection.enter=sn,n.selection.enter.prototype=hn,hn.append=X.append,hn.empty=X.empty,hn.node=X.node,hn.call=X.call,hn.size=X.size,hn.select=function(n){for(var t,e,r,i,u,o=[],a=-1,l=this.length;++a=r&&(r=t+1);!(o=a[r])&&++r0?1:n<0?-1:0}function qn(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Tn(n){return n>1?0:n<-1?kn:Math.acos(n)}function Rn(n){return n>1?An:n<-1?-An:Math.asin(n)}function Dn(n){return((n=Math.exp(n))+1/n)/2}function Pn(n){return(n=Math.sin(n/2))*n}var Un=Math.SQRT2;n.interpolateZoom=function(n,t){var e,r,i=n[0],u=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-i,s=l-u,h=f*f+s*s;if(h0&&(t=t.transition().duration(v)),t.call(_.event)}function E(){c&&c.domain(l.range().map(function(n){return(n-h.x)/h.k}).map(l.invert)),s&&s.domain(f.range().map(function(n){return(n-h.y)/h.k}).map(f.invert))}function A(n){d++||n({type:"zoomstart"})}function C(n){E(),n({type:"zoom",scale:h.k,translate:[h.x,h.y]})}function z(n){--d||(n({type:"zoomend"}),e=null)}function L(){var t=this,e=b.of(t,arguments),r=0,i=n.select(u(t)).on(m,function(){r=1,k(n.mouse(t),o),C(e)}).on(M,function(){i.on(m,null).on(M,null),a(r),z(e)}),o=w(n.mouse(t)),a=Mn(t);oa.call(t),A(e)}function q(){var t,e=this,r=b.of(e,arguments),i={},u=0,o=".zoom-"+n.event.changedTouches[0].identifier,l="touchmove"+o,c="touchend"+o,f=[],s=n.select(e),p=Mn(e);function g(){var r=n.touches(e);return t=h.k,r.forEach(function(n){n.identifier in i&&(i[n.identifier]=w(n))}),r}function v(){var t=n.event.target;n.select(t).on(l,d).on(c,m),f.push(t);for(var r=n.event.changedTouches,o=0,s=r.length;o1){y=p[0];var M=p[1],x=y[0]-M[0],b=y[1]-M[1];u=x*x+b*b}}function d(){var o,l,c,f,s=n.touches(e);oa.call(e);for(var h=0,p=s.length;h360?n-=360:n<0&&(n+=360),n<60?r+(i-r)*n/60:n<180?i:n<240?r+(i-r)*(240-n)/60:r}(n))}return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:t<0?0:t>1?1:t,r=2*(e=e<0?0:e>1?1:e)-(i=e<=.5?e*(1+t):e+t-e*t),new ut(u(n+120),u(n),u(n-120))}function Vn(t,e,r){return this instanceof Vn?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof Vn?new Vn(t.h,t.c,t.l):tt(t instanceof Bn?t.l:(t=ht((t=n.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new Vn(t,e,r)}Yn.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new In(this.h,this.s,this.l/n)},Yn.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new In(this.h,this.s,n*this.l)},Yn.rgb=function(){return Zn(this.h,this.s,this.l)},n.hcl=Vn;var Xn=Vn.prototype=new On;function $n(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new Bn(e,Math.cos(n*=Cn)*t,Math.sin(n)*t)}function Bn(n,t,e){return this instanceof Bn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof Bn?new Bn(n.l,n.a,n.b):n instanceof Vn?$n(n.h,n.c,n.l):ht((n=ut(n)).r,n.g,n.b):new Bn(n,t,e)}Xn.brighter=function(n){return new Vn(this.h,this.c,Math.min(100,this.l+Wn*(arguments.length?n:1)))},Xn.darker=function(n){return new Vn(this.h,this.c,Math.max(0,this.l-Wn*(arguments.length?n:1)))},Xn.rgb=function(){return $n(this.h,this.c,this.l).rgb()},n.lab=Bn;var Wn=18,Jn=.95047,Gn=1,Kn=1.08883,Qn=Bn.prototype=new On;function nt(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return new ut(it(3.2404542*(i=et(i)*Jn)-1.5371385*(r=et(r)*Gn)-.4985314*(u=et(u)*Kn)),it(-.969266*i+1.8760108*r+.041556*u),it(.0556434*i-.2040259*r+1.0572252*u))}function tt(n,t,e){return n>0?new Vn(Math.atan2(e,t)*zn,Math.sqrt(t*t+e*e),n):new Vn(NaN,NaN,n)}function et(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function rt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function it(n){return Math.round(255*(n<=.00304?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function ut(n,t,e){return this instanceof ut?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof ut?new ut(n.r,n.g,n.b):ft(""+n,ut,Zn):new ut(n,t,e)}function ot(n){return new ut(n>>16,n>>8&255,255&n)}function at(n){return ot(n)+""}Qn.brighter=function(n){return new Bn(Math.min(100,this.l+Wn*(arguments.length?n:1)),this.a,this.b)},Qn.darker=function(n){return new Bn(Math.max(0,this.l-Wn*(arguments.length?n:1)),this.a,this.b)},Qn.rgb=function(){return nt(this.l,this.a,this.b)},n.rgb=ut;var lt=ut.prototype=new On;function ct(n){return n<16?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function ft(n,t,e){var r,i,u,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(gt(i[0]),gt(i[1]),gt(i[2]))}return(u=vt.get(n))?t(u.r,u.g,u.b):(null==n||"#"!==n.charAt(0)||isNaN(u=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&u)>>4,o|=o>>4,a=240&u,a|=a>>4,l=15&u,l|=l<<4):7===n.length&&(o=(16711680&u)>>16,a=(65280&u)>>8,l=255&u)),t(o,a,l))}function st(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-u,l=(o+u)/2;return a?(i=l<.5?a/(o+u):a/(2-o-u),r=n==o?(t-e)/a+(t0&&l<1?0:r),new In(r,i,l)}function ht(n,t,e){var r=rt((.4124564*(n=pt(n))+.3575761*(t=pt(t))+.1804375*(e=pt(e)))/Jn),i=rt((.2126729*n+.7151522*t+.072175*e)/Gn);return Bn(116*i-16,500*(r-i),200*(i-rt((.0193339*n+.119192*t+.9503041*e)/Kn)))}function pt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function gt(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}lt.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&t=200&&t<300||304===t){try{n=i.call(o,c)}catch(n){return void a.error.call(o,n)}a.load.call(o,n)}else a.error.call(o,c)}return!this.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(t)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=s:c.onreadystatechange=function(){c.readyState>3&&s()},c.onprogress=function(t){var e=n.event;n.event=t;try{a.progress.call(o,c)}finally{n.event=e}},o.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?l[n]:(null==t?delete l[n]:l[n]=t+"",o)},o.mimeType=function(n){return arguments.length?(r=null==n?null:n+"",o):r},o.responseType=function(n){return arguments.length?(f=n,o):f},o.response=function(n){return i=n,o},["get","post"].forEach(function(n){o[n]=function(){return o.send.apply(o,[n].concat(e(arguments)))}}),o.send=function(n,e,i){if(2===arguments.length&&"function"==typeof e&&(i=e,e=null),c.open(n,t,!0),null==r||"accept"in l||(l.accept=r+",*/*"),c.setRequestHeader)for(var u in l)c.setRequestHeader(u,l[u]);return null!=r&&c.overrideMimeType&&c.overrideMimeType(r),null!=f&&(c.responseType=f),null!=i&&o.on("error",i).on("load",function(n){i(null,n)}),a.beforesend.call(o,c),c.send(null==e?null:e),o},o.abort=function(){return c.abort(),o},n.rebind(o,a,"on"),null==u?o:o.get(function(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}(u))}vt.forEach(function(n,t){vt.set(n,ot(t))}),n.functor=dt,n.xhr=yt(z),n.dsv=function(n,t){var e=new RegExp('["'+n+"\n]"),r=n.charCodeAt(0);function i(n,e,r){arguments.length<3&&(r=e,e=null);var i=mt(n,t,null==e?u:o(e),r);return i.row=function(n){return arguments.length?i.response(null==(e=n)?u:o(n)):e},i}function u(n){return i.parse(n.responseText)}function o(n){return function(t){return i.parse(t.responseText,n)}}function a(t){return t.map(l).join(n)}function l(n){return e.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}return i.parse=function(n,t){var e;return i.parseRows(n,function(n,r){if(e)return e(n,r-1);var i=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");e=t?function(n,e){return t(i(n),e)}:i})},i.parseRows=function(n,t){var e,i,u={},o={},a=[],l=n.length,c=0,f=0;function s(){if(c>=l)return o;if(i)return i=!1,u;var t=c;if(34===n.charCodeAt(t)){for(var e=t;e++24?(isFinite(t)&&(clearTimeout(_t),_t=setTimeout(kt,t)),bt=0):(bt=1,wt(kt))}function Nt(){for(var n=Date.now(),t=Mt;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Et(){for(var n,t=Mt,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}});n.formatPrefix=function(t,e){var r=0;return(t=+t)&&(t<0&&(t*=-1),e&&(t=n.round(t,At(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),Ct[8+r/3]};var zt=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Lt=n.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(t,e){return(t=n.round(t,At(t,e))).toFixed(Math.max(0,Math.min(20,At(t*(1+1e-15),e))))}});function qt(n){return n+""}var Tt=n.time={},Rt=Date;function Dt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Dt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Pt.setUTCDate.apply(this._,arguments)},setDay:function(){Pt.setUTCDay.apply(this._,arguments)},setFullYear:function(){Pt.setUTCFullYear.apply(this._,arguments)},setHours:function(){Pt.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Pt.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Pt.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Pt.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Pt.setUTCSeconds.apply(this._,arguments)},setTime:function(){Pt.setTime.apply(this._,arguments)}};var Pt=Date.prototype;function Ut(n,t,e){function r(t){var e=n(t),r=u(e,1);return t-e1)for(;o68?1900:2e3),e+i[0].length):-1}function Jt(n,t,e){return/^[+-]\d{4}$/.test(t=t.slice(e,e+5))?(n.Z=-t,e+5):-1}function Gt(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Kt(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Qt(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function ne(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function te(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function ee(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function re(n,t,e){Ht.lastIndex=0;var r=Ht.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ie(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=y(t)/60|0,i=y(t)%60;return e+It(r,"0",2)+It(i,"0",2)}function ue(n,t,e){Ot.lastIndex=0;var r=Ot.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function oe(n){for(var t=n.length,e=-1;++e0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),u.push(n.substring(e-=a,e+a)),!((l+=a+1)>t));)a=i[o=(o+1)%i.length];return u.reverse().join(r)}:z;return function(t){var r=zt.exec(t),i=r[1]||" ",a=r[2]||">",l=r[3]||"-",c=r[4]||"",f=r[5],s=+r[6],h=r[7],p=r[8],g=r[9],v=1,d="",y="",m=!1,M=!0;switch(p&&(p=+p.substring(1)),(f||"0"===i&&"="===a)&&(f=i="0",a="="),g){case"n":h=!0,g="g";break;case"%":v=100,y="%",g="f";break;case"p":v=100,y="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(d="0"+g.toLowerCase());case"c":M=!1;case"d":m=!0,p=0;break;case"s":v=-1,g="r"}"$"===c&&(d=u[0],y=u[1]),"r"!=g||p||(g="g"),null!=p&&("g"==g?p=Math.max(1,Math.min(21,p)):"e"!=g&&"f"!=g||(p=Math.max(0,Math.min(20,p)))),g=Lt.get(g)||qt;var x=f&&h;return function(t){var r=y;if(m&&t%1)return"";var u=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===l?"":l;if(v<0){var c=n.formatPrefix(t,p);t=c.scale(t),r=c.symbol+y}else t*=v;var b,_,w=(t=g(t,p)).lastIndexOf(".");if(w<0){var S=M?t.lastIndexOf("e"):-1;S<0?(b=t,_=""):(b=t.substring(0,S),_=t.substring(S))}else b=t.substring(0,w),_=e+t.substring(w+1);!f&&h&&(b=o(b,1/0));var k=d.length+b.length+_.length+(x?0:u.length),N=k"===a?N+u+t:"^"===a?N.substring(0,k>>=1)+u+t+N.substring(k):u+(x?t:N+t))+r}}}(t),timeFormat:function(t){var e=t.dateTime,r=t.date,i=t.time,u=t.periods,o=t.days,a=t.shortDays,l=t.months,c=t.shortMonths;function f(n){var t=n.length;function e(e){for(var r,i,u,o=[],a=-1,l=0;++a=c)return-1;if(37===(i=t.charCodeAt(a++))){if(o=t.charAt(a++),!(u=_[o in Ft?t.charAt(a++):o])||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}f.utc=function(n){var t=f(n);function e(n){try{var e=new(Rt=Dt);return e._=n,t(e)}finally{Rt=Date}}return e.parse=function(n){try{Rt=Dt;var e=t.parse(n);return e&&e._}finally{Rt=Date}},e.toString=t.toString,e},f.multi=f.utc.multi=oe;var h=n.map(),p=Yt(o),g=Zt(o),v=Yt(a),d=Zt(a),y=Yt(l),m=Zt(l),M=Yt(c),x=Zt(c);u.forEach(function(n,t){h.set(n.toLowerCase(),t)});var b={a:function(n){return a[n.getDay()]},A:function(n){return o[n.getDay()]},b:function(n){return c[n.getMonth()]},B:function(n){return l[n.getMonth()]},c:f(e),d:function(n,t){return It(n.getDate(),t,2)},e:function(n,t){return It(n.getDate(),t,2)},H:function(n,t){return It(n.getHours(),t,2)},I:function(n,t){return It(n.getHours()%12||12,t,2)},j:function(n,t){return It(1+Tt.dayOfYear(n),t,3)},L:function(n,t){return It(n.getMilliseconds(),t,3)},m:function(n,t){return It(n.getMonth()+1,t,2)},M:function(n,t){return It(n.getMinutes(),t,2)},p:function(n){return u[+(n.getHours()>=12)]},S:function(n,t){return It(n.getSeconds(),t,2)},U:function(n,t){return It(Tt.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return It(Tt.mondayOfYear(n),t,2)},x:f(r),X:f(i),y:function(n,t){return It(n.getFullYear()%100,t,2)},Y:function(n,t){return It(n.getFullYear()%1e4,t,4)},Z:ie,"%":function(){return"%"}},_={a:function(n,t,e){v.lastIndex=0;var r=v.exec(t.slice(e));return r?(n.w=d.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(n,t,e){p.lastIndex=0;var r=p.exec(t.slice(e));return r?(n.w=g.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(n,t,e){M.lastIndex=0;var r=M.exec(t.slice(e));return r?(n.m=x.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(n,t,e){y.lastIndex=0;var r=y.exec(t.slice(e));return r?(n.m=m.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(n,t,e){return s(n,b.c.toString(),t,e)},d:Kt,e:Kt,H:ne,I:ne,j:Qt,L:re,m:Gt,M:te,p:function(n,t,e){var r=h.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)},S:ee,U:Xt,w:Vt,W:$t,x:function(n,t,e){return s(n,b.x.toString(),t,e)},X:function(n,t,e){return s(n,b.X.toString(),t,e)},y:Wt,Y:Bt,Z:Jt,"%":ue};return f}(t)}};var ae=n.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function le(){}n.format=ae.numberFormat,n.geo={},le.prototype={s:0,t:0,add:function(n){fe(n,this.t,ce),fe(ce.s,this.s,this),this.s?this.t+=ce.t:this.s=ce.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ce=new le;function fe(n,t,e){var r=e.s=n+t,i=r-n,u=r-i;e.t=n-u+(t-i)}function se(n,t){n&&pe.hasOwnProperty(n.type)&&pe[n.type](n,t)}n.geo.stream=function(n,t){n&&he.hasOwnProperty(n.type)?he[n.type](n,t):se(n,t)};var he={Feature:function(n,t){se(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++r=0?1:-1,a=o*u,l=Math.cos(t),c=Math.sin(t),f=i*c,s=r*l+f*Math.cos(a),h=f*o*Math.sin(a);Ae.add(Math.atan2(h,s)),e=n,r=l,i=c}Ce.point=function(o,a){Ce.point=u,e=(n=o)*Cn,r=Math.cos(a=(t=a)*Cn/2+kn/4),i=Math.sin(a)},Ce.lineEnd=function(){u(n,t)}}function Le(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function qe(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function Te(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Re(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function De(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function Pe(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function Ue(n){return[Math.atan2(n[1],n[0]),Rn(n[2])]}function je(n,t){return y(n[0]-t[0])wn?i=90:c<-wn&&(e=-90),s[0]=t,s[1]=r}};function p(n,u){f.push(s=[t=n,r=n]),ui&&(i=u)}function g(n,o){var a=Le([n*Cn,o*Cn]);if(l){var c=Te(l,a),f=Te([c[1],-c[0],0],c);Pe(f),f=Ue(f);var s=n-u,h=s>0?1:-1,g=f[0]*zn*h,v=y(s)>180;if(v^(h*ui&&(i=d);else if(v^(h*u<(g=(g+360)%360-180)&&gi&&(i=o);v?nb(t,r)&&(r=n):b(n,r)>b(t,r)&&(t=n):r>=t?(nr&&(r=n)):n>u?b(t,n)>b(t,r)&&(r=n):b(n,r)>b(t,r)&&(t=n)}else p(n,o);l=a,u=n}function v(){h.point=g}function d(){s[0]=t,s[1]=r,h.point=p,l=null}function m(n,t){if(l){var e=n-u;c+=y(e)>180?e+(e>0?360:-360):e}else o=n,a=t;Ce.point(n,t),g(n,t)}function M(){Ce.lineStart()}function x(){m(o,a),Ce.lineEnd(),y(c)>wn&&(t=-(r=180)),s[0]=t,s[1]=r,l=null}function b(n,t){return(t-=n)<0?t+360:t}function _(n,t){return n[0]-t[0]}function w(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nb(v[0],v[1])&&(v[1]=p[1]),b(p[0],v[1])>b(v[0],v[1])&&(v[0]=p[0])):a.push(v=p);for(var l,c,p,g=-1/0,v=(o=0,a[c=a.length-1]);o<=c;v=p,++o)p=a[o],(l=b(v[1],p[0]))>g&&(g=l,t=p[0],r=v[1])}return f=s=null,t===1/0||e===1/0?[[NaN,NaN],[NaN,NaN]]:[[t,e],[r,i]]}}(),n.geo.centroid=function(t){ye=me=Me=xe=be=_e=we=Se=ke=Ne=Ee=0,n.geo.stream(t,Fe);var e=ke,r=Ne,i=Ee,u=e*e+r*r+i*i;return u=0;--a)i.point((s=f[a])[0],s[1]);else r(p.x,p.p.x,-1,i);p=p.p}f=(p=p.o).z,g=!g}while(!p.v);i.lineEnd()}}}function Be(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r=0?1:-1,w=_*b,S=w>kn,k=g*M;if(Ae.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),u+=S?b+_*Nn:b,S^h>=e^y>=e){var N=Te(Le(s),Le(n));Pe(N);var E=Te(i,N);Pe(E);var A=(S^b>=0?-1:1)*Rn(E[2]);(r>A||r===A&&(N[0]||N[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=y,g=M,v=x,s=n}}return(u<-wn||u0){for(M||(o.polygonStart(),M=!0),o.lineStart();++u1&&2&t&&e.push(e.pop().concat(e.shift())),a.push(e.filter(Ge))}return f}}function Ge(n){return n.length>1}function Ke(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:R,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Qe(n,t){return((n=n.x)[0]<0?n[1]-An-wn:An-n[1])-((t=t.x)[0]<0?t[1]-An-wn:An-t[1])}var nr=Je(Xe,function(n){var t,e=NaN,r=NaN,i=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(u,o){var a=u>0?kn:-kn,l=y(u-e);y(l-kn)0?An:-An),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(u,r),t=0):i!==a&&l>=kn&&(y(e-i)wn?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*o)):(t+r)/2}(e,r,u,o),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),t=0),n.point(e=u,r=o),i=a},lineEnd:function(){n.lineEnd(),e=r=NaN},clean:function(){return 2-t}}},function(n,t,e,r){var i;if(null==n)i=e*An,r.point(-kn,i),r.point(0,i),r.point(kn,i),r.point(kn,0),r.point(kn,-i),r.point(0,-i),r.point(-kn,-i),r.point(-kn,0),r.point(-kn,i);else if(y(n[0]-t[0])>wn){var u=n[0]0)){if(u/=h,h<0){if(u0){if(u>s)return;u>f&&(f=u)}if(u=e-l,h||!(u<0)){if(u/=h,h<0){if(u>s)return;u>f&&(f=u)}else if(h>0){if(u0)){if(u/=p,p<0){if(u0){if(u>s)return;u>f&&(f=u)}if(u=r-c,p||!(u<0)){if(u/=p,p<0){if(u>s)return;u>f&&(f=u)}else if(p>0){if(u0&&(i.a={x:l+f*h,y:c+f*p}),s<1&&(i.b={x:l+s*h,y:c+s*p}),i}}}}}}var er=1e9;function rr(t,e,r,i){return function(l){var c,f,s,h,p,g,v,d,y,m,M,x=l,b=Ke(),_=tr(t,e,r,i),w={point:N,lineStart:function(){w.point=E,f&&f.push(s=[]);m=!0,y=!1,v=d=NaN},lineEnd:function(){c&&(E(h,p),g&&y&&b.rejoin(),c.push(b.buffer()));w.point=N,y&&l.lineEnd()},polygonStart:function(){l=b,c=[],f=[],M=!0},polygonEnd:function(){l=x,c=n.merge(c);var e=function(n){for(var t=0,e=f.length,r=n[1],i=0;ir&&qn(c,u,n)>0&&++t:u[1]<=r&&qn(c,u,n)<0&&--t,c=u;return 0!==t}([t,i]),r=M&&e,u=c.length;(r||u)&&(l.polygonStart(),r&&(l.lineStart(),S(null,null,1,l),l.lineEnd()),u&&$e(c,o,e,S,l),l.polygonEnd()),c=f=s=null}};function S(n,o,l,c){var f=0,s=0;if(null==n||(f=u(n,l))!==(s=u(o,l))||a(n,o)<0^l>0)do{c.point(0===f||3===f?t:r,f>1?i:e)}while((f=(f+l+4)%4)!==s);else c.point(o[0],o[1])}function k(n,u){return t<=n&&n<=r&&e<=u&&u<=i}function N(n,t){k(n,t)&&l.point(n,t)}function E(n,t){var e=k(n=Math.max(-er,Math.min(er,n)),t=Math.max(-er,Math.min(er,t)));if(f&&s.push([n,t]),m)h=n,p=t,g=e,m=!1,e&&(l.lineStart(),l.point(n,t));else if(e&&y)l.point(n,t);else{var r={a:{x:v,y:d},b:{x:n,y:t}};_(r)?(y||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),e||l.lineEnd(),M=!1):e&&(l.lineStart(),l.point(n,t),M=!1)}v=n,d=t,y=e}return w};function u(n,i){return y(n[0]-t)0?0:3:y(n[0]-r)0?2:1:y(n[1]-e)0?1:0:i>0?3:2}function o(n,t){return a(n.x,t.x)}function a(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}}function ir(n){var t=0,e=kn/3,r=Nr(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*kn/180,e=n[1]*kn/180):[t/kn*180,e/kn*180]},i}function ur(n,t){var e=Math.sin(n),r=(e+Math.sin(t))/2,i=1+e*(2*r-e),u=Math.sqrt(i)/r;function o(n,t){var e=Math.sqrt(i-2*r*Math.sin(t))/r;return[e*Math.sin(n*=r),u-e*Math.cos(n)]}return o.invert=function(n,t){var e=u-t;return[Math.atan2(n,e)/r,Rn((i-(n*n+e*e)*r*r)/(2*r))]},o}n.geo.clipExtent=function(){var n,t,e,r,i,u,o={stream:function(n){return i&&(i.valid=!1),(i=u(n)).valid=!0,i},extent:function(a){return arguments.length?(u=rr(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),i&&(i.valid=!1,i=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(n.geo.conicEqualArea=function(){return ir(ur)}).raw=ur,n.geo.albers=function(){return n.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},n.geo.albersUsa=function(){var t,e,r,i,u=n.geo.albers(),o=n.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=n.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(n,e){t=[n,e]}};function c(n){var u=n[0],o=n[1];return t=null,e(u,o),t||(r(u,o),t)||i(u,o),t}return c.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&i<.234&&r>=-.425&&r<-.214?o:i>=.166&&i<.234&&r>=-.214&&r<-.115?a:u).invert(n)},c.stream=function(n){var t=u.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},c.precision=function(n){return arguments.length?(u.precision(n),o.precision(n),a.precision(n),c):u.precision()},c.scale=function(n){return arguments.length?(u.scale(n),o.scale(.35*n),a.scale(n),c.translate(u.translate())):u.scale()},c.translate=function(n){if(!arguments.length)return u.translate();var t=u.scale(),f=+n[0],s=+n[1];return e=u.translate(n).clipExtent([[f-.455*t,s-.238*t],[f+.455*t,s+.238*t]]).stream(l).point,r=o.translate([f-.307*t,s+.201*t]).clipExtent([[f-.425*t+wn,s+.12*t+wn],[f-.214*t-wn,s+.234*t-wn]]).stream(l).point,i=a.translate([f-.205*t,s+.212*t]).clipExtent([[f-.214*t+wn,s+.166*t+wn],[f-.115*t-wn,s+.234*t-wn]]).stream(l).point,c},c.scale(1070)};var or,ar,lr,cr,fr,sr,hr={point:R,lineStart:R,lineEnd:R,polygonStart:function(){ar=0,hr.lineStart=pr},polygonEnd:function(){hr.lineStart=hr.lineEnd=hr.point=R,or+=y(ar/2)}};function pr(){var n,t,e,r;function i(n,t){ar+=r*n-e*t,e=n,r=t}hr.point=function(u,o){hr.point=i,n=e=u,t=r=o},hr.lineEnd=function(){i(n,t)}}var gr={point:function(n,t){nfr&&(fr=n);tsr&&(sr=t)},lineStart:R,lineEnd:R,polygonStart:R,polygonEnd:R};function vr(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}var dr,yr={point:mr,lineStart:Mr,lineEnd:xr,polygonStart:function(){yr.lineStart=br},polygonEnd:function(){yr.point=mr,yr.lineStart=Mr,yr.lineEnd=xr}};function mr(n,t){Me+=n,xe+=t,++be}function Mr(){var n,t;function e(e,r){var i=e-n,u=r-t,o=Math.sqrt(i*i+u*u);_e+=o*(n+e)/2,we+=o*(t+r)/2,Se+=o,mr(n=e,t=r)}yr.point=function(r,i){yr.point=e,mr(n=r,t=i)}}function xr(){yr.point=mr}function br(){var n,t,e,r;function i(n,t){var i=n-e,u=t-r,o=Math.sqrt(i*i+u*u);_e+=o*(e+n)/2,we+=o*(r+t)/2,Se+=o,ke+=(o=r*n-e*t)*(e+n),Ne+=o*(r+t),Ee+=3*o,mr(e=n,r=t)}yr.point=function(u,o){yr.point=i,mr(n=e=u,t=r=o)},yr.lineEnd=function(){i(n,t)}}function _r(n){var t=.5,e=Math.cos(30*Cn),r=16;function i(t){return(r?function(t){var e,i,o,a,l,c,f,s,h,p,g,v,d={point:y,lineStart:m,lineEnd:x,polygonStart:function(){t.polygonStart(),d.lineStart=b},polygonEnd:function(){t.polygonEnd(),d.lineStart=m}};function y(e,r){e=n(e,r),t.point(e[0],e[1])}function m(){s=NaN,d.point=M,t.lineStart()}function M(e,i){var o=Le([e,i]),a=n(e,i);u(s,h,f,p,g,v,s=a[0],h=a[1],f=e,p=o[0],g=o[1],v=o[2],r,t),t.point(s,h)}function x(){d.point=y,t.lineEnd()}function b(){m(),d.point=_,d.lineEnd=w}function _(n,t){M(e=n,t),i=s,o=h,a=p,l=g,c=v,d.point=M}function w(){u(s,h,f,p,g,v,i,o,e,a,l,c,r,t),d.lineEnd=x,x()}return d}:function(t){return Sr(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})})(t)}function u(r,i,o,a,l,c,f,s,h,p,g,v,d,m){var M=f-r,x=s-i,b=M*M+x*x;if(b>4*t&&d--){var _=a+p,w=l+g,S=c+v,k=Math.sqrt(_*_+w*w+S*S),N=Math.asin(S/=k),E=y(y(S)-1)t||y((M*L+x*q)/b-.5)>.3||a*p+l*g+c*v0&&16,i):Math.sqrt(t)},i}function wr(n){this.stream=n}function Sr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function kr(n){return Nr(function(){return n})()}function Nr(t){var e,r,i,u,o,a,l=_r(function(n,t){return[(n=e(n,t))[0]*c+u,o-n[1]*c]}),c=150,f=480,s=250,h=0,p=0,g=0,v=0,d=0,m=nr,M=z,x=null,b=null;function _(n){return[(n=i(n[0]*Cn,n[1]*Cn))[0]*c+u,o-n[1]*c]}function w(n){return(n=i.invert((n[0]-u)/c,(o-n[1])/c))&&[n[0]*zn,n[1]*zn]}function S(){i=Ve(r=zr(g,v,d),e);var n=e(h,p);return u=f-n[0]*c,o=s+n[1]*c,k()}function k(){return a&&(a.valid=!1,a=null),_}return _.stream=function(n){return a&&(a.valid=!1),(a=Er(m(r,l(M(n))))).valid=!0,a},_.clipAngle=function(n){return arguments.length?(m=null==n?(x=n,nr):function(n){var t=Math.cos(n),e=t>0,r=y(t)>wn;return Je(i,function(n){var t,a,l,c,f;return{lineStart:function(){c=l=!1,f=1},point:function(s,h){var p,g=[s,h],v=i(s,h),d=e?v?0:o(s,h):v?o(s+(s<0?kn:-kn),h):0;if(!t&&(c=l=v)&&n.lineStart(),v!==l&&(p=u(t,g),(je(t,p)||je(g,p))&&(g[0]+=wn,g[1]+=wn,v=i(g[0],g[1]))),v!==l)f=0,v?(n.lineStart(),p=u(g,t),n.point(p[0],p[1])):(p=u(t,g),n.point(p[0],p[1]),n.lineEnd()),t=p;else if(r&&t&&e^v){var y;d&a||!(y=u(g,t,!0))||(f=0,e?(n.lineStart(),n.point(y[0][0],y[0][1]),n.point(y[1][0],y[1][1]),n.lineEnd()):(n.point(y[1][0],y[1][1]),n.lineEnd(),n.lineStart(),n.point(y[0][0],y[0][1])))}!v||t&&je(t,g)||n.point(g[0],g[1]),t=g,l=v,a=d},lineEnd:function(){l&&n.lineEnd(),t=null},clean:function(){return f|(c&&l)<<1}}},Rr(n,6*Cn),e?[0,-n]:[-kn,n-kn]);function i(n,e){return Math.cos(n)*Math.cos(e)>t}function u(n,e,r){var i=[1,0,0],u=Te(Le(n),Le(e)),o=qe(u,u),a=u[0],l=o-a*a;if(!l)return!r&&n;var c=t*o/l,f=-t*a/l,s=Te(i,u),h=De(i,c);Re(h,De(u,f));var p=s,g=qe(h,p),v=qe(p,p),d=g*g-v*(qe(h,h)-1);if(!(d<0)){var m=Math.sqrt(d),M=De(p,(-g-m)/v);if(Re(M,h),M=Ue(M),!r)return M;var x,b=n[0],_=e[0],w=n[1],S=e[1];_0^M[1]<(y(M[0]-b)kn^(b<=M[0]&&M[0]<=_)){var E=De(p,(-g+m)/v);return Re(E,h),[M,Ue(E)]}}}function o(t,r){var i=e?n:kn-n,u=0;return t<-i?u|=1:t>i&&(u|=2),r<-i?u|=4:r>i&&(u|=8),u}}((x=+n)*Cn),k()):x},_.clipExtent=function(n){return arguments.length?(b=n,M=n?rr(n[0][0],n[0][1],n[1][0],n[1][1]):z,k()):b},_.scale=function(n){return arguments.length?(c=+n,S()):c},_.translate=function(n){return arguments.length?(f=+n[0],s=+n[1],S()):[f,s]},_.center=function(n){return arguments.length?(h=n[0]%360*Cn,p=n[1]%360*Cn,S()):[h*zn,p*zn]},_.rotate=function(n){return arguments.length?(g=n[0]%360*Cn,v=n[1]%360*Cn,d=n.length>2?n[2]%360*Cn:0,S()):[g*zn,v*zn,d*zn]},n.rebind(_,l,"precision"),function(){return e=t.apply(this,arguments),_.invert=e.invert&&w,S()}}function Er(n){return Sr(n,function(t,e){n.point(t*Cn,e*Cn)})}function Ar(n,t){return[n,t]}function Cr(n,t){return[n>kn?n-Nn:n<-kn?n+Nn:n,t]}function zr(n,t,e){return n?t||e?Ve(qr(n),Tr(t,e)):qr(n):t||e?Tr(t,e):Cr}function Lr(n){return function(t,e){return[(t+=n)>kn?t-Nn:t<-kn?t+Nn:t,e]}}function qr(n){var t=Lr(n);return t.invert=Lr(-n),t}function Tr(n,t){var e=Math.cos(n),r=Math.sin(n),i=Math.cos(t),u=Math.sin(t);function o(n,t){var o=Math.cos(t),a=Math.cos(n)*o,l=Math.sin(n)*o,c=Math.sin(t),f=c*e+a*r;return[Math.atan2(l*i-f*u,a*e-c*r),Rn(f*i+l*u)]}return o.invert=function(n,t){var o=Math.cos(t),a=Math.cos(n)*o,l=Math.sin(n)*o,c=Math.sin(t),f=c*i-l*u;return[Math.atan2(l*i+c*u,a*e+f*r),Rn(f*e-a*r)]},o}function Rr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,o,a){var l=o*t;null!=i?(i=Dr(e,i),u=Dr(e,u),(o>0?iu)&&(i+=o*Nn)):(i=n+o*Nn,u=n-.5*l);for(var c,f=i;o>0?f>u:f2?n[2]*Cn:0),t.invert=function(t){return(t=n.invert(t[0]*Cn,t[1]*Cn))[0]*=zn,t[1]*=zn,t},t},Cr.invert=Ar,n.geo.circle=function(){var n,t,e=[0,0],r=6;function i(){var n="function"==typeof e?e.apply(this,arguments):e,r=zr(-n[0]*Cn,-n[1]*Cn,0).invert,i=[];return t(null,null,1,{point:function(n,t){i.push(n=r(n,t)),n[0]*=zn,n[1]*=zn}}),{type:"Polygon",coordinates:[i]}}return i.origin=function(n){return arguments.length?(e=n,i):e},i.angle=function(e){return arguments.length?(t=Rr((n=+e)*Cn,r*Cn),i):n},i.precision=function(e){return arguments.length?(t=Rr(n*Cn,(r=+e)*Cn),i):r},i.angle(90)},n.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Cn,i=n[1]*Cn,u=t[1]*Cn,o=Math.sin(r),a=Math.cos(r),l=Math.sin(i),c=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*o)*e+(e=c*f-l*s*a)*e),l*f+c*s*a)},n.geo.graticule=function(){var t,e,r,i,u,o,a,l,c,f,s,h,p=10,g=p,v=90,d=360,m=2.5;function M(){return{type:"MultiLineString",coordinates:x()}}function x(){return n.range(Math.ceil(i/v)*v,r,v).map(s).concat(n.range(Math.ceil(l/d)*d,a,d).map(h)).concat(n.range(Math.ceil(e/p)*p,t,p).filter(function(n){return y(n%v)>wn}).map(c)).concat(n.range(Math.ceil(o/g)*g,u,g).filter(function(n){return y(n%d)>wn}).map(f))}return M.lines=function(){return x().map(function(n){return{type:"LineString",coordinates:n}})},M.outline=function(){return{type:"Polygon",coordinates:[s(i).concat(h(a).slice(1),s(r).reverse().slice(1),h(l).reverse().slice(1))]}},M.extent=function(n){return arguments.length?M.majorExtent(n).minorExtent(n):M.minorExtent()},M.majorExtent=function(n){return arguments.length?(i=+n[0][0],r=+n[1][0],l=+n[0][1],a=+n[1][1],i>r&&(n=i,i=r,r=n),l>a&&(n=l,l=a,a=n),M.precision(m)):[[i,l],[r,a]]},M.minorExtent=function(n){return arguments.length?(e=+n[0][0],t=+n[1][0],o=+n[0][1],u=+n[1][1],e>t&&(n=e,e=t,t=n),o>u&&(n=o,o=u,u=n),M.precision(m)):[[e,o],[t,u]]},M.step=function(n){return arguments.length?M.majorStep(n).minorStep(n):M.minorStep()},M.majorStep=function(n){return arguments.length?(v=+n[0],d=+n[1],M):[v,d]},M.minorStep=function(n){return arguments.length?(p=+n[0],g=+n[1],M):[p,g]},M.precision=function(n){return arguments.length?(m=+n,c=Pr(o,u,90),f=Ur(e,t,m),s=Pr(l,a,90),h=Ur(i,r,m),M):m},M.majorExtent([[-180,-90+wn],[180,90-wn]]).minorExtent([[-180,-80-wn],[180,80+wn]])},n.geo.greatArc=function(){var t,e,r=jr,i=Fr;function u(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}return u.distance=function(){return n.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},u.source=function(n){return arguments.length?(r=n,t="function"==typeof n?null:n,u):r},u.target=function(n){return arguments.length?(i=n,e="function"==typeof n?null:n,u):i},u.precision=function(){return arguments.length?u:0},u},n.geo.interpolate=function(n,t){return e=n[0]*Cn,r=n[1]*Cn,i=t[0]*Cn,u=t[1]*Cn,o=Math.cos(r),a=Math.sin(r),l=Math.cos(u),c=Math.sin(u),f=o*Math.cos(e),s=o*Math.sin(e),h=l*Math.cos(i),p=l*Math.sin(i),g=2*Math.asin(Math.sqrt(Pn(u-r)+o*l*Pn(i-e))),v=1/Math.sin(g),(d=g?function(n){var t=Math.sin(n*=g)*v,e=Math.sin(g-n)*v,r=e*f+t*h,i=e*s+t*p,u=e*a+t*c;return[Math.atan2(i,r)*zn,Math.atan2(u,Math.sqrt(r*r+i*i))*zn]}:function(){return[e*zn,r*zn]}).distance=g,d;var e,r,i,u,o,a,l,c,f,s,h,p,g,v,d},n.geo.length=function(t){return dr=0,n.geo.stream(t,Hr),dr};var Hr={sphere:R,point:R,lineStart:function(){var n,t,e;function r(r,i){var u=Math.sin(i*=Cn),o=Math.cos(i),a=y((r*=Cn)-n),l=Math.cos(a);dr+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=e*u-t*o*l)*a),t*u+e*o*l),n=r,t=u,e=o}Hr.point=function(i,u){n=i*Cn,t=Math.sin(u*=Cn),e=Math.cos(u),Hr.point=r},Hr.lineEnd=function(){Hr.point=Hr.lineEnd=R}},lineEnd:R,polygonStart:R,polygonEnd:R};function Or(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),o=Math.cos(i);return[Math.atan2(n*u,r*o),Math.asin(r&&e*u/r)]},e}var Ir=Or(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(n.geo.azimuthalEqualArea=function(){return kr(Ir)}).raw=Ir;var Yr=Or(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},z);function Zr(n,t){var e=Math.cos(n),r=function(n){return Math.tan(kn/4+n/2)},i=n===t?Math.sin(n):Math.log(e/Math.cos(t))/Math.log(r(t)/r(n)),u=e*Math.pow(r(n),i)/i;if(!i)return $r;function o(n,t){u>0?t<-An+wn&&(t=-An+wn):t>An-wn&&(t=An-wn);var e=u/Math.pow(r(t),i);return[e*Math.sin(i*n),u-e*Math.cos(i*n)]}return o.invert=function(n,t){var e=u-t,r=Ln(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(u/r,1/i))-An]},o}function Vr(n,t){var e=Math.cos(n),r=n===t?Math.sin(n):(e-Math.cos(t))/(t-n),i=e/r+n;if(y(r)1&&qn(n[e[r-2]],n[e[r-1]],n[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function ti(n,t){return n[0]-t[0]||n[1]-t[1]}(n.geo.stereographic=function(){return kr(Jr)}).raw=Jr,Gr.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-An]},(n.geo.transverseMercator=function(){var n=Br(Gr),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):[(n=t())[1],-n[0]]},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):[(n=e())[0],n[1],n[2]-90]},e([0,0,90])}).raw=Gr,n.geom={},n.geom.hull=function(n){var t=Kr,e=Qr;if(arguments.length)return r(n);function r(n){if(n.length<3)return[];var r,i=dt(t),u=dt(e),o=n.length,a=[],l=[];for(r=0;r=0;--r)p.push(n[a[c[r]][2]]);for(r=+s;rwn)a=a.L;else{if(!((i=u-mi(a,o))>wn)){r>-wn?(t=a.P,e=a):i>-wn?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=pi(n);if(li.insert(t,l),t||e){if(t===e)return _i(t),e=pi(t.site),li.insert(l,e),l.edge=e.edge=ki(t.site,l.site),bi(t),void bi(e);if(e){_i(t),_i(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,p=n.y-s,g=e.site,v=g.x-f,d=g.y-s,y=2*(h*d-p*v),m=h*h+p*p,M=v*v+d*d,x={x:(d*m-p*M)/y+f,y:(h*M-v*m)/y+s};Ni(e.edge,c,g,x),l.edge=ki(c,n,null,x),e.edge=ki(n,g,null,x),bi(t),bi(e)}else l.edge=ki(t.site,l.site)}}function yi(n,t){var e=n.site,r=e.x,i=e.y,u=i-t;if(!u)return r;var o=n.P;if(!o)return-1/0;var a=(e=o.site).x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/u-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+i-u/2)))/s+r:(r+a)/2}function mi(n,t){var e=n.N;if(e)return yi(e,t);var r=n.site;return r.y===t?r.x:1/0}function Mi(n){this.site=n,this.edges=[]}function xi(n,t){return t.angle-n.angle}function bi(n){var t=n.P,e=n.N;if(t&&e){var r=t.site,i=n.site,u=e.site;if(r!==u){var o=i.x,a=i.y,l=r.x-o,c=r.y-a,f=u.x-o,s=2*(l*(d=u.y-a)-c*f);if(!(s>=-Sn)){var h=l*l+c*c,p=f*f+d*d,g=(d*h-c*p)/s,v=(l*p-f*h)/s,d=v+a,y=hi.pop()||new function(){Ci(this),this.x=this.y=this.arc=this.site=this.cy=null};y.arc=n,y.site=i,y.x=g+o,y.y=d+Math.sqrt(g*g+v*v),y.cy=d,n.circle=y;for(var m=null,M=fi._;M;)if(y.y=a)return;if(h>g){if(u){if(u.y>=c)return}else u={x:d,y:l};e={x:d,y:c}}else{if(u){if(u.y1)if(h>g){if(u){if(u.y>=c)return}else u={x:(l-i)/r,y:l};e={x:(c-i)/r,y:c}}else{if(u){if(u.y=a)return}else u={x:o,y:r*o+i};e={x:a,y:r*a+i}}else{if(u){if(u.xwn||y(i-e)>wn)&&(a.splice(o,0,new Ei((m=u.site,M=f,x=y(r-s)wn?{x:s,y:y(t-s)wn?{x:y(e-g)wn?{x:h,y:y(t-h)wn?{x:y(e-p)=e&&c.x<=i&&c.y>=r&&c.y<=o?[[e,o],[i,o],[i,r],[e,r]]:[]).point=n[a]}),t}function a(n){return n.map(function(n,t){return{x:Math.round(r(n,t)/wn)*wn,y:Math.round(i(n,t)/wn)*wn,i:t}})}return o.links=function(n){return Ti(a(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},o.triangles=function(n){var t=[];return Ti(a(n)).cells.forEach(function(e,r){for(var i,u,o,a,l=e.site,c=e.edges.sort(xi),f=-1,s=c.length,h=c[s-1].edge,p=h.l===l?h.r:h.l;++fu&&(i=t.slice(u,i),a[o]?a[o]+=i:a[++o]=i),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:Hi(e,r)})),u=Yi.lastIndex;return uv&&(v=l.x),l.y>d&&(d=l.y),c.push(l.x),f.push(l.y);else for(s=0;sv&&(v=x),b>d&&(d=b),c.push(x),f.push(b)}var _=v-p,w=d-g;function S(n,t,e,r,i,u,o,a){if(!isNaN(e)&&!isNaN(r))if(n.leaf){var l=n.x,c=n.y;if(null!=l)if(y(l-e)+y(c-r)<.01)k(n,t,e,r,i,u,o,a);else{var f=n.point;n.x=n.y=n.point=null,k(n,f,l,c,i,u,o,a),k(n,t,e,r,i,u,o,a)}else n.x=e,n.y=r,n.point=t}else k(n,t,e,r,i,u,o,a)}function k(n,t,e,r,i,u,o,a){var l=.5*(i+o),c=.5*(u+a),f=e>=l,s=r>=c,h=s<<1|f;n.leaf=!1,n=n.nodes[h]||(n.nodes[h]={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(n){S(N,n,+m(n,++s),+M(n,s),p,g,v,d)}}),f?i=l:o=l,s?u=c:a=c,S(n,t,e,r,i,u,o,a)}_>w?d=g+_:v=p+w;var N={leaf:!0,nodes:[],point:null,x:null,y:null,add:function(n){S(N,n,+m(n,++s),+M(n,s),p,g,v,d)}};if(N.visit=function(n){!function n(t,e,r,i,u,o){if(!t(e,r,i,u,o)){var a=.5*(r+u),l=.5*(i+o),c=e.nodes;c[0]&&n(t,c[0],r,i,a,l),c[1]&&n(t,c[1],a,i,u,l),c[2]&&n(t,c[2],r,l,a,o),c[3]&&n(t,c[3],a,l,u,o)}}(n,N,p,g,v,d)},N.find=function(n){return function(n,t,e,r,i,u,o){var a,l=1/0;return function n(c,f,s,h,p){if(!(f>u||s>o||h=b)<<1|t>=x,w=_+4;_=0&&!(r=n.interpolators[i](t,e)););return r}function Vi(n,t){var e,r=[],i=[],u=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;e=1)return 1;var t=n*n,e=t*n;return 4*(n<.5?e:3*(n-t)+e-.75)}function nu(n){return 1-Math.cos(n*An)}function tu(n){return Math.pow(2,10*(n-1))}function eu(n){return 1-Math.sqrt(1-n*n)}function ru(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function iu(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function uu(n){var t,e,r,i=[n.a,n.b],u=[n.c,n.d],o=au(i),a=ou(i,u),l=au(((t=u)[0]+=(r=-a)*(e=i)[0],t[1]+=r*e[1],t))||0;i[0]*u[1]=0?n.slice(0,r):n,u=r>=0?n.slice(r+1):"in";return i=$i.get(i)||Xi,u=Bi.get(u)||z,e=u(i.apply(null,t.call(arguments,1))),function(n){return n<=0?0:n>=1?1:e(n)}},n.interpolateHcl=function(t,e){t=n.hcl(t),e=n.hcl(e);var r=t.h,i=t.c,u=t.l,o=e.h-r,a=e.c-i,l=e.l-u;isNaN(a)&&(a=0,i=isNaN(i)?e.c:i);isNaN(o)?(o=0,r=isNaN(r)?e.h:r):o>180?o-=360:o<-180&&(o+=360);return function(n){return $n(r+o*n,i+a*n,u+l*n)+""}},n.interpolateHsl=function(t,e){t=n.hsl(t),e=n.hsl(e);var r=t.h,i=t.s,u=t.l,o=e.h-r,a=e.s-i,l=e.l-u;isNaN(a)&&(a=0,i=isNaN(i)?e.s:i);isNaN(o)?(o=0,r=isNaN(r)?e.h:r):o>180?o-=360:o<-180&&(o+=360);return function(n){return Zn(r+o*n,i+a*n,u+l*n)+""}},n.interpolateLab=function(t,e){t=n.lab(t),e=n.lab(e);var r=t.l,i=t.a,u=t.b,o=e.l-r,a=e.a-i,l=e.b-u;return function(n){return nt(r+o*n,i+a*n,u+l*n)+""}},n.interpolateRound=iu,n.transform=function(t){var e=r.createElementNS(n.ns.prefix.svg,"g");return(n.transform=function(n){if(null!=n){e.setAttribute("transform",n);var t=e.transform.baseVal.consolidate()}return new uu(t?t.matrix:lu)})(t)},uu.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var lu={a:1,b:0,c:0,d:1,e:0,f:0};function cu(n){return n.length?n.pop()+",":""}function fu(t,e){var r=[],i=[];return t=n.transform(t),e=n.transform(e),function(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push("translate(",null,",",null,")");r.push({i:i-4,x:Hi(n[0],t[0])},{i:i-2,x:Hi(n[1],t[1])})}else(t[0]||t[1])&&e.push("translate("+t+")")}(t.translate,e.translate,r,i),function(n,t,e,r){n!==t?(n-t>180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(cu(e)+"rotate(",null,")")-2,x:Hi(n,t)})):t&&e.push(cu(e)+"rotate("+t+")")}(t.rotate,e.rotate,r,i),function(n,t,e,r){n!==t?r.push({i:e.push(cu(e)+"skewX(",null,")")-2,x:Hi(n,t)}):t&&e.push(cu(e)+"skewX("+t+")")}(t.skew,e.skew,r,i),function(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push(cu(e)+"scale(",null,",",null,")");r.push({i:i-4,x:Hi(n[0],t[0])},{i:i-2,x:Hi(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(cu(e)+"scale("+t+")")}(t.scale,e.scale,r,i),t=e=null,function(n){for(var t,e=-1,u=i.length;++e0?r=n:(t.c=null,t.t=NaN,t=null,l.end({type:"end",alpha:r=0})):n>0&&(l.start({type:"start",alpha:r=n}),t=St(a.tick)),a):r},a.start=function(){var n,t,e,r=y.length,l=m.length,f=c[0],g=c[1];for(n=0;n=0;)e.push(i[r])}function Su(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(u=n.children)&&(i=u.length))for(var i,u,o=-1;++o=0;)o.push(f=c[l]),f.parent=u,f.depth=u.depth+1;e&&(u.value=0),u.children=c}else e&&(u.value=+e.call(r,u,u.depth)||0),delete u.children;return Su(i,function(t){var r,i;n&&(r=t.children)&&r.sort(n),e&&(i=t.parent)&&(i.value+=t.value)}),a}return r.sort=function(t){return arguments.length?(n=t,r):n},r.children=function(n){return arguments.length?(t=n,r):t},r.value=function(n){return arguments.length?(e=n,r):e},r.revalue=function(n){return e&&(wu(n,function(n){n.children&&(n.value=0)}),Su(n,function(n){var t;n.children||(n.value=+e.call(r,n,n.depth)||0),(t=n.parent)&&(t.value+=n.value)})),n},r},n.layout.partition=function(){var t=n.layout.hierarchy(),e=[1,1];function r(n,r){var i=t.call(this,n,r);return function n(t,e,r,i){var u=t.children;if(t.x=e,t.y=t.depth*i,t.dx=r,t.dy=i,u&&(o=u.length)){var o,a,l,c=-1;for(r=t.value?r/t.value:0;++ca&&(a=r),o.push(r)}for(e=0;ei&&(r=e,i=t);return r}function ju(n){return n.reduce(Fu,0)}function Fu(n,t){return n+t[1]}function Hu(n,t){return Ou(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function Ou(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function Iu(t){return[n.min(t),n.max(t)]}function Yu(n,t){return n.value-t.value}function Zu(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Vu(n,t){n._pack_next=t,t._pack_prev=n}function Xu(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return.999*i*i>e*e+r*r}function $u(n){if((t=n.children)&&(l=t.length)){var t,e,r,i,u,o,a,l,c=1/0,f=-1/0,s=1/0,h=-1/0;if(t.forEach(Bu),(e=t[0]).x=-e.r,e.y=0,M(e),l>1&&((r=t[1]).x=r.r,r.y=0,M(r),l>2))for(Ju(e,r,i=t[2]),M(i),Zu(e,i),e._pack_prev=i,Zu(i,r),r=e._pack_next,u=3;u0)for(o=-1;++o=s[0]&&l<=s[1]&&((a=c[n.bisect(h,l,1,g)-1]).y+=v,a.push(u[o]));return c}return u.value=function(n){return arguments.length?(e=n,u):e},u.range=function(n){return arguments.length?(r=dt(n),u):r},u.bins=function(n){return arguments.length?(i="number"==typeof n?function(t){return Ou(t,n)}:dt(n),u):i},u.frequency=function(n){return arguments.length?(t=!!n,u):t},u},n.layout.pack=function(){var t,e=n.layout.hierarchy().sort(Yu),r=0,i=[1,1];function u(n,u){var o=e.call(this,n,u),a=o[0],l=i[0],c=i[1],f=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Su(a,function(n){n.r=+f(n.value)}),Su(a,$u),r){var s=r*(t?1:Math.max(2*a.r/l,2*a.r/c))/2;Su(a,function(n){n.r+=s}),Su(a,$u),Su(a,function(n){n.r-=s})}return function n(t,e,r,i){var u=t.children;t.x=e+=i*t.x;t.y=r+=i*t.y;t.r*=i;if(u)for(var o=-1,a=u.length;++op.x&&(p=n),n.depth>g.depth&&(g=n)});var v=e(h,p)/2-h.x,d=r[0]/(p.x+e(p,h)/2+v),y=r[1]/(g.depth||1);wu(f,function(n){n.x=(n.x+v)*d,n.y=n.depth*y})}return c}function o(n){var t=n.children,r=n.parent.children,i=n.i?r[n.i-1]:null;if(t.length){!function(n){var t,e=0,r=0,i=n.children,u=i.length;for(;--u>=0;)(t=i[u]).z+=e,t.m+=e,e+=t.s+(r+=t.c)}(n);var u=(t[0].z+t[t.length-1].z)/2;i?(n.z=i.z+e(n._,i._),n.m=n.z-u):n.z=u}else i&&(n.z=i.z+e(n._,i._));n.parent.A=function(n,t,r){if(t){for(var i,u=n,o=n,a=t,l=u.parent.children[0],c=u.m,f=o.m,s=a.m,h=l.m;a=Qu(a),u=Ku(u),a&&u;)l=Ku(l),(o=Qu(o)).a=n,(i=a.z+s-u.z-c+e(a._,u._))>0&&(no(to(a,n,r),n,i),c+=i,f+=i),s+=a.m,c+=u.m,h+=l.m,f+=o.m;a&&!Qu(o)&&(o.t=a,o.m+=s-f),u&&!Ku(l)&&(l.t=u,l.m+=c-h,r=n)}return r}(n,i,n.parent.A||r[0])}function a(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function l(n){n.x*=r[0],n.y=n.depth*r[1]}return u.separation=function(n){return arguments.length?(e=n,u):e},u.size=function(n){return arguments.length?(i=null==(r=n)?l:null,u):i?null:r},u.nodeSize=function(n){return arguments.length?(i=null==(r=n)?null:l,u):i?r:null},_u(u,t)},n.layout.cluster=function(){var t=n.layout.hierarchy().sort(null).value(null),e=Gu,r=[1,1],i=!1;function u(u,o){var a,l=t.call(this,u,o),c=l[0],f=0;Su(c,function(t){var r=t.children;r&&r.length?(t.x=function(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}(r),t.y=function(t){return 1+n.max(t,function(n){return n.y})}(r)):(t.x=a?f+=e(t,a):0,t.y=0,a=t)});var s=function n(t){var e=t.children;return e&&e.length?n(e[0]):t}(c),h=function n(t){var e,r=t.children;return r&&(e=r.length)?n(r[e-1]):t}(c),p=s.x-e(s,h)/2,g=h.x+e(h,s)/2;return Su(c,i?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-p)/(g-p)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),l}return u.separation=function(n){return arguments.length?(e=n,u):e},u.size=function(n){return arguments.length?(i=null==(r=n),u):i?null:r},u.nodeSize=function(n){return arguments.length?(i=null!=(r=n),u):i?r:null},_u(u,t)},n.layout.treemap=function(){var t,e=n.layout.hierarchy(),r=Math.round,i=[1,1],u=null,o=eo,a=!1,l="squarify",c=.5*(1+Math.sqrt(5));function f(n,t){for(var e,r,i=-1,u=n.length;++i0;)a.push(e=c[i-1]),a.area+=e.area,"squarify"!==l||(r=p(a,v))<=h?(c.pop(),h=r):(a.area-=a.pop().area,g(a,v,u,!1),v=Math.min(u.dx,u.dy),a.length=a.area=0,h=1/0);a.length&&(g(a,v,u,!0),a.length=a.area=0),t.forEach(s)}}function h(n){var t=n.children;if(t&&t.length){var e,r=o(n),i=t.slice(),u=[];for(f(i,r.dx*r.dy/n.value),u.area=0;e=i.pop();)u.push(e),u.area+=e.area,null!=e.z&&(g(u,e.z?r.dx:r.dy,r,!i.length),u.length=u.area=0);t.forEach(h)}}function p(n,t){for(var e,r=n.area,i=0,u=1/0,o=-1,a=n.length;++oi&&(i=e));return t*=t,(r*=r)?Math.max(t*i*c/r,r/(t*u*c)):1/0}function g(n,t,e,i){var u,o=-1,a=n.length,l=e.x,c=e.y,f=t?r(n.area/t):0;if(t==e.dx){for((i||f>e.dy)&&(f=e.dy);++oe.dx)&&(f=e.dx);++o1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=n.random.normal.apply(n,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=n.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(n){return function(){for(var t=0,e=0;e2?fo:oo,a=i?hu:su;return u=n(t,e,a,r),o=n(e,t,a,Zi),l}function l(n){return u(n)}l.invert=function(n){return o(n)};l.domain=function(n){return arguments.length?(t=n.map(Number),a()):t};l.range=function(n){return arguments.length?(e=n,a()):e};l.rangeRound=function(n){return l.range(n).interpolate(iu)};l.clamp=function(n){return arguments.length?(i=n,a()):i};l.interpolate=function(n){return arguments.length?(r=n,a()):r};l.ticks=function(n){return go(t,n)};l.tickFormat=function(n,e){return vo(t,n,e)};l.nice=function(n){return ho(t,n),a()};l.copy=function(){return n(t,e,r,i)};return a()}([0,1],[0,1],Zi,!1)};var yo={s:1,g:1,p:1,r:1,e:1};function mo(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}n.scale.log=function(){return function t(e,r,i,u){function o(n){return(i?Math.log(n<0?0:n):-Math.log(n>0?0:-n))/Math.log(r)}function a(n){return i?Math.pow(r,n):-Math.pow(r,-n)}function l(n){return e(o(n))}l.invert=function(n){return a(e.invert(n))};l.domain=function(n){return arguments.length?(i=n[0]>=0,e.domain((u=n.map(Number)).map(o)),l):u};l.base=function(n){return arguments.length?(r=+n,e.domain(u.map(o)),l):r};l.nice=function(){var n=ao(u.map(o),i?Math:xo);return e.domain(n),u=n.map(a),l};l.ticks=function(){var n=io(u),t=[],e=n[0],l=n[1],c=Math.floor(o(e)),f=Math.ceil(o(l)),s=r%1?2:r;if(isFinite(f-c)){if(i){for(;c0;h--)t.push(a(c)*h);for(c=0;t[c]l;f--);t=t.slice(c,f)}return t};l.tickFormat=function(t,e){if(!arguments.length)return Mo;arguments.length<2?e=Mo:"function"!=typeof e&&(e=n.format(e));var i=Math.max(1,r*t/l.ticks().length);return function(n){var t=n/a(Math.round(o(n)));return t*r0?i[n-1]:e[0],ns?0:1;if(c=En)return l(c,p)+(a?l(a,1-p):"")+"Z";var g,v,d,y,m,M,x,b,_,w,S,k,N=0,E=0,A=[];if((y=(+o.apply(this,arguments)||0)/2)&&(d=r===Eo?Math.sqrt(a*a+c*c):+r.apply(this,arguments),p||(E*=-1),c&&(E=Rn(d/c*Math.sin(y))),a&&(N=Rn(d/a*Math.sin(y)))),c){m=c*Math.cos(f+E),M=c*Math.sin(f+E),x=c*Math.cos(s-E),b=c*Math.sin(s-E);var C=Math.abs(s-f-2*E)<=kn?0:1;if(E&&To(m,M,x,b)===p^C){var z=(f+s)/2;m=c*Math.cos(z),M=c*Math.sin(z),x=b=null}}else m=M=0;if(a){_=a*Math.cos(s-N),w=a*Math.sin(s-N),S=a*Math.cos(f+N),k=a*Math.sin(f+N);var L=Math.abs(f-s+2*N)<=kn?0:1;if(N&&To(_,w,S,k)===1-p^L){var q=(f+s)/2;_=a*Math.cos(q),w=a*Math.sin(q),S=k=null}}else _=w=0;if(h>wn&&(g=Math.min(Math.abs(c-a)/2,+e.apply(this,arguments)))>.001){v=a0?0:1}function Ro(n,t,e,r,i){var u=n[0]-t[0],o=n[1]-t[1],a=(i?r:-r)/Math.sqrt(u*u+o*o),l=a*o,c=-a*u,f=n[0]+l,s=n[1]+c,h=t[0]+l,p=t[1]+c,g=(f+h)/2,v=(s+p)/2,d=h-f,y=p-s,m=d*d+y*y,M=e-r,x=f*p-h*s,b=(y<0?-1:1)*Math.sqrt(Math.max(0,M*M*m-x*x)),_=(x*y-d*b)/m,w=(-x*d-y*b)/m,S=(x*y+d*b)/m,k=(-x*d+y*b)/m,N=_-g,E=w-v,A=S-g,C=k-v;return N*N+E*E>A*A+C*C&&(_=S,w=k),[[_-l,w-c],[_*e/M,w*e/M]]}function Do(n){var t=Kr,e=Qr,r=Xe,i=Uo,u=i.key,o=.7;function a(u){var a,l=[],c=[],f=-1,s=u.length,h=dt(t),p=dt(e);function g(){l.push("M",i(n(c),o))}for(;++f1&&i.push("H",r[0]);return i.join("")},"step-before":Fo,"step-after":Ho,basis:Yo,"basis-open":function(n){if(n.length<4)return Uo(n);var t,e=[],r=-1,i=n.length,u=[0],o=[0];for(;++r<3;)t=n[r],u.push(t[0]),o.push(t[1]);e.push(Zo($o,u)+","+Zo($o,o)),--r;for(;++r9&&(i=3*t/Math.sqrt(i),o[a]=i*e,o[a+1]=i*r));a=-1;for(;++a<=l;)i=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),u.push([i||0,o[a]*i||0]);return u}(n))}});function Uo(n){return n.length>1?n.join("L"):n+"Z"}function jo(n){return n.join("L")+"Z"}function Fo(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1){a=t[1],u=n[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(u[0]-a[0])+","+(u[1]-a[1])+","+u[0]+","+u[1];for(var c=2;ckn)+",1 "+t}function l(n,t,e,r){return"Q 0,0 "+r}return u.radius=function(n){return arguments.length?(e=dt(n),u):e},u.source=function(t){return arguments.length?(n=dt(t),u):n},u.target=function(n){return arguments.length?(t=dt(n),u):t},u.startAngle=function(n){return arguments.length?(r=dt(n),u):r},u.endAngle=function(n){return arguments.length?(i=dt(n),u):i},u},n.svg.diagonal=function(){var n=jr,t=Fr,e=Qo;function r(r,i){var u=n.call(this,r,i),o=t.call(this,r,i),a=(u.y+o.y)/2,l=[u,{x:u.x,y:a},{x:o.x,y:a},o];return"M"+(l=l.map(e))[0]+"C"+l[1]+" "+l[2]+" "+l[3]}return r.source=function(t){return arguments.length?(n=dt(t),r):n},r.target=function(n){return arguments.length?(t=dt(n),r):t},r.projection=function(n){return arguments.length?(e=n,r):e},r},n.svg.diagonal.radial=function(){var t=n.svg.diagonal(),e=Qo,r=t.projection;return t.projection=function(n){return arguments.length?r(function(n){return function(){var t=n.apply(this,arguments),e=t[0],r=t[1]-An;return[e*Math.cos(r),e*Math.sin(r)]}}(e=n)):e},t},n.svg.symbol=function(){var n=ta,t=na;function e(e,r){return(ra.get(n.call(this,e,r))||ea)(t.call(this,e,r))}return e.type=function(t){return arguments.length?(n=dt(t),e):n},e.size=function(n){return arguments.length?(t=dt(n),e):t},e};var ra=n.map({circle:ea,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*ua)),e=t*ua;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/ia),e=t*ia/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/ia),e=t*ia/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});n.svg.symbolTypes=ra.keys();var ia=Math.sqrt(3),ua=Math.tan(30*Cn);X.transition=function(n){for(var t,e,r=ca||++ha,i=va(n),u=[],o=fa||{time:Date.now(),ease:Qi,delay:0,duration:250},a=-1,l=this.length;++a0;)c[--h].call(n,o);if(u>=1)return s.event&&s.event.end.call(n,n.__data__,t),--f.count?delete f[r]:delete n[e],1}s||(u=i.time,o=St(function(n){var t=s.delay;if(o.t=t+u,t<=n)return h(n-t);o.c=h},0,u),s=f[r]={tween:new M,time:u,timer:o,delay:i.delay,duration:i.duration,ease:i.ease,index:t},i=null,++f.count)}sa.call=X.call,sa.empty=X.empty,sa.node=X.node,sa.size=X.size,n.transition=function(t,e){return t&&t.transition?ca?t.transition(e):t:n.selection().transition(t)},n.transition.prototype=sa,sa.select=function(n){var t,e,r,i=this.id,u=this.namespace,o=[];n=$(n);for(var a=-1,l=this.length;++arect,.s>rect").attr("width",a[1]-a[0])}function v(n){n.select(".extent").attr("y",l[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",l[1]-l[0])}function d(){var s,d,y=this,m=n.select(n.event.target),M=r.of(y,arguments),x=n.select(y),b=m.datum(),_=!/^(n|s)$/.test(b)&&i,w=!/^(e|w)$/.test(b)&&o,S=m.classed("extent"),k=Mn(y),N=n.mouse(y),E=n.select(u(y)).on("keydown.brush",function(){32==n.event.keyCode&&(S||(s=null,N[0]-=a[1],N[1]-=l[1],S=2),U())}).on("keyup.brush",function(){32==n.event.keyCode&&2==S&&(N[0]+=a[1],N[1]+=l[1],S=0,U())});if(n.event.changedTouches?E.on("touchmove.brush",z).on("touchend.brush",q):E.on("mousemove.brush",z).on("mouseup.brush",q),x.interrupt().selectAll("*").interrupt(),S)N[0]=a[0]-N[0],N[1]=l[0]-N[1];else if(b){var A=+/w$/.test(b),C=+/^n/.test(b);d=[a[1-A]-N[0],l[1-C]-N[1]],N[0]=a[A],N[1]=l[C]}else n.event.altKey&&(s=N.slice());function z(){var t=n.mouse(y),e=!1;d&&(t[0]+=d[0],t[1]+=d[1]),S||(n.event.altKey?(s||(s=[(a[0]+a[1])/2,(l[0]+l[1])/2]),N[0]=a[+(t[0]1?{floor:function(t){for(;a(t=n.floor(t));)t=Aa(t-1);return t},ceil:function(t){for(;a(t=n.ceil(t));)t=Aa(+t+1);return t}}:n))},i.ticks=function(n,t){var e=io(i.domain()),r=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return r&&(n=r[0],t=r[1]),n.range(e[0],Aa(+e[1]+1),t<1?1:t)},i.tickFormat=function(){return r},i.copy=function(){return Ea(t.copy(),e,r)},so(i,t)}function Aa(n){return new Date(n)}wa.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Na:ka,Na.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Na.toString=ka.toString,Tt.second=Ut(function(n){return new Rt(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),Tt.seconds=Tt.second.range,Tt.seconds.utc=Tt.second.utc.range,Tt.minute=Ut(function(n){return new Rt(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),Tt.minutes=Tt.minute.range,Tt.minutes.utc=Tt.minute.utc.range,Tt.hour=Ut(function(n){var t=n.getTimezoneOffset()/60;return new Rt(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),Tt.hours=Tt.hour.range,Tt.hours.utc=Tt.hour.utc.range,Tt.month=Ut(function(n){return(n=Tt.day(n)).setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),Tt.months=Tt.month.range,Tt.months.utc=Tt.month.utc.range;var Ca=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],za=[[Tt.second,1],[Tt.second,5],[Tt.second,15],[Tt.second,30],[Tt.minute,1],[Tt.minute,5],[Tt.minute,15],[Tt.minute,30],[Tt.hour,1],[Tt.hour,3],[Tt.hour,6],[Tt.hour,12],[Tt.day,1],[Tt.day,2],[Tt.week,1],[Tt.month,1],[Tt.month,3],[Tt.year,1]],La=wa.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Xe]]),qa={range:function(t,e,r){return n.range(Math.ceil(t/r)*r,+e,r).map(Aa)},floor:z,ceil:z};za.year=Tt.year,Tt.scale=function(){return Ea(n.scale.linear(),za,La)};var Ta=za.map(function(n){return[n[0].utc,n[1]]}),Ra=Sa.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Xe]]);function Da(n){return JSON.parse(n.responseText)}function Pa(n){var t=r.createRange();return t.selectNode(r.body),t.createContextualFragment(n.responseText)}Ta.year=Tt.year.utc,Tt.scale.utc=function(){return Ea(n.scale.linear(),Ta,Ra)},n.text=yt(function(n){return n.responseText}),n.json=function(n,t){return mt(n,"application/json",Da,t)},n.html=function(n,t){return mt(n,"text/html",Pa,t)},n.xml=yt(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=n,define(n)):"object"==typeof module&&module.exports?module.exports=n:this.d3=n}(); -},{}],3:[function(require,module,exports) { -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default={seis:["#AA0000","#D00000","#F70000","#FF1D00","#FF4400","#FF6A00","#FF9000","#FFB700","#FFDD00","#FFFF00","#FFFF00","#FFFF00","#BDFF0C","#73FF1A","#3FFA36","#16F45A","#00D08B","#0087CD","#0048FA","#0024E3"].reverse(),sealand:["#8C66FF","#6A66FF","#6684FF","#66A7FF","#66CAFF","#66ECFF","#66FFF0","#66FFCE","#66FFAB","#66FF88","#66FF66","#88FF66","#ABFF66","#CEFF66","#FFEEA6","#FFD3A6","#FFB8A6","#FFAAB0","#FFB5CB","#FFC0E1"].reverse(),redgreen:["#005824","#1A693B","#347B53","#4F8D6B","#699F83","#83B09B","#9EC2B3","#B8D4CB","#D2E6E3","#EDF8FB","#FFFFFF","#F1EEF6","#E6D3E1","#DBB9CD","#D19EB9","#C684A4","#BB6990","#B14F7C","#A63467","#9B1A53","#91003F"],ocean:["#000000","#000209","#000413","#00061E","#000728","#000932","#002650","#00426E","#005E8C","#007AAA","#0096C8","#22A9C2","#45BCBB","#67CFB5","#8AE2AE","#ACF6A8","#BCF8B9","#CBF9CA","#DBFBDC","#EBFDED"].reverse(),cool:["#00FFFF","#0DF2FF","#19E6FF","#26D9FF","#33CCFF","#3FBFFF","#4CB3FF","#59A6FF","#6699FF","#738CFF","#7F7FFF","#8C73FF","#9966FF","#A659FF","#B24DFF","#BF3FFF","#CC33FF","#D926FF","#E619FF","#F20DFF"],copper:["#000000","#100906","#1F130D","#301E13","#40281A","#50321F","#603C26","#70462D","#805033","#905A3A","#A06440","#B06E46","#C0784D","#D08253","#E08C5A","#F09660","#FFA066","#FFAA6D","#FFB473","#FFBE7A"].reverse(),gray:["#000000","#0D0D0D","#191919","#262626","#333333","#3F3F3F","#4C4C4C","#595959","#666666","#737373","#7F7F7F","#8C8C8C","#999999","#A6A6A6","#B2B2B2","#BFBFBF","#CCCCCC","#D9D9D9","#E6E6E6","#F2F2F2"].reverse(),hot:["#000000","#220000","#440000","#660000","#880000","#AA0000","#CC0000","#EE0000","#FF1100","#FF3300","#FF5500","#FF7700","#FF9900","#FFBB00","#FFDD00","#FFFF00","#FFFF33","#FFFF66","#FFFF99","#FFFFCC"].reverse(),jet:["#00007F","#0000B2","#0000E5","#0019FF","#004DFF","#007FFF","#00B2FF","#00E5FF","#FFFFF2","#FFFFD9","#FFFFBF","#FFFFA5","#FFFF8C","#FFE500","#FFB300","#FF7F00","#FF4C00","#FF1900","#E50000","#B20000"],no_green:["#1F60FF","#1F60FF","#1F9FFF","#1FBFFF","#00CFFF","#2AFFFF","#2AFFFF","#55FFFF","#7FFFFF","#AAFFFF","#FFFF54","#FFFF54","#FFF000","#FFBF00","#FFA800","#FF8A00","#FF8A00","#FF7000","#FF4D00","#FF0000"],polar:["#0000FF","#1919FF","#3333FF","#4C4CFF","#6666FF","#7F7FFF","#9999FF","#B2B2FF","#CCCCFF","#E6E6FF","#FFFFFF","#FFE5E5","#FFCCCC","#FFB2B2","#FF9999","#FF7F7F","#FF6666","#FF4C4C","#FF3333","#FF1A1A"],red2green:["#FF0000","#FF1919","#FF3333","#FF4C4C","#FF6666","#FF7F7F","#FF9999","#FFB2B2","#FFCCCC","#FFE6E6","#FFFFFF","#E5FFE5","#CCFFCC","#B2FFB2","#99FF99","#7FFF7F","#66FF66","#4CFF4C","#33FF33","#1AFF1A"].reverse(),relief:["#000000","#000413","#000728","#002650","#005E8C","#0096C8","#45BCBB","#8AE2AE","#BCF8B9","#DBFBDC","#467832","#887438","#B19D48","#DBC758","#FAE769","#FAEB7E","#FCED93","#FCF1A7","#FCF6C1","#FDFAE0"].reverse(),split:["#7F7FFF","#6666E6","#4D4DCC","#3333B3","#1A1A99","#00007F","#000066","#00004D","#000033","#00001A","#000000","#1A0000","#330000","#4D0000","#660000","#7F0000","#991A1A","#B33333","#CC4D4D","#E66666"],wysiwyg:["#3F003F","#3F003F","#3F00BF","#003FFF","#00A0FF","#3FBFFF","#3FBFFF","#40E0FF","#3FFFBF","#3FFF3F","#7FFF3F","#BFFF3F","#BFFF3F","#FFE040","#FFE040","#FF6040","#FF1F40","#FF60C0","#FFA0FF","#FFA0FF"].reverse()}; -},{}],1:[function(require,module,exports) { -"use strict";var t=require("d3"),i=r(t),e=require("./colorsets"),s=a(e);function a(t){return t&&t.__esModule?t:{default:t}}function r(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e]);return i.default=t,i}var n=window.bundleEntries.chartUtilities.Series,o=window.bundleEntries.chartUtilities.Datasets,h=window.bundleEntries.chartUtilities.Jobs,l=Backbone.View.extend({optionsDefault:{margin:{top:40,right:70,bottom:70,left:70},style:{"font-weight":"normal","font-family":"Verdana","font-size":12},legend:{width:15,size:.9,style:{"font-weight":"normal","font-family":"Verdana","font-size":11},limit:7},background_color:"#FFFFFF",debug_color:"#FFFFFF"},initialize:function(t){var e=this;this.chart=t.chart,this.canvas_id=t.canvas_id,this.group=t.groups[0],this.data=t.groups[0].values,this.options=_.defaults(this.optionsDefault,t),this.color_set=s.default[this.chart.settings.get("color_set","seism")],this.categories=n.makeUniqueCategories([this.group]),this.xScale=i.scale.linear().domain([0,this.categories.array.x.length]),this.yScale=i.scale.linear().domain([0,this.categories.array.y.length]),this.zMin=i.min(this.data,function(t){return t.z}),this.zMax=i.max(this.data,function(t){return t.z}),this.zScale=i.scale.quantize().domain([this.zMin,this.zMax]).range(this.color_set),this.xAxis=i.svg.axis().scale(this.xScale).orient("bottom"),this.yAxis=i.svg.axis().scale(this.yScale).orient("left"),this._makeTickFormat("x"),this._makeTickFormat("y"),this.tooltip=i.select(".charts-viewport-container").append("div").attr("class","charts-tooltip").style(this.options.style).style("opacity",0),$(window).on("resize",function(){e.redraw()}),this.redraw(),n.addZoom({xAxis:this.xAxis,yAxis:this.yAxis,redraw:function(){e.redraw()},svg:i.select("#"+this.canvas_id)})},redraw:function(){var t=$("#"+this.canvas_id);t.empty();var e=this.xScale.domain(),s=this.yScale.domain(),a=Math.ceil(e[0]),r=Math.floor(e[1]),n=Math.ceil(s[0]),o=Math.floor(s[1]);this.xAxis.tickValues(i.range(a,r,1)),this.yAxis.tickValues(i.range(n,o,1));var h=this.options.margin;this.height=parseInt(t.height())-h.top-h.bottom,this.width=parseInt(t.width())-h.left-h.right,this.xScale.range([0,this.width]),this.yScale.range([this.height,0]),this.rowCount=s[1]-s[0],this.colCount=e[1]-e[0],this.boxWidth=Math.max(1,Math.floor(this.width/this.colCount)),this.boxHeight=Math.max(1,Math.floor(this.height/this.rowCount)),this.svg=i.select("#"+this.canvas_id).append("g").attr("class","heatmap").attr("transform","translate("+h.left+","+h.top+")"),this._buildBoxes(),this._buildX(),this._buildY(),"true"==this.chart.settings.get("show_legend")&&this._buildLegend()},_buildBoxes:function(){var t=this,e=this.height,s=this.width,a=this.svg,r=this.boxWidth,n=this.boxHeight;a.append("rect").attr("width",s).attr("height",e).attr("fill",this.options.background_color),a.append("clipPath").attr("id","clip").append("rect").attr("x",0).attr("y",0).attr("width",s).attr("height",e);var o=a.append("g").attr("clip-path","url(#clip)").selectAll("box-group").data(this.data,function(t,i){return t.x+"\0"+t.y});o.enter().append("g").attr("class","box-group").append("rect").attr("class","heat-box"),o.selectAll("rect").attr("rx",1).attr("ry",1).attr("fill",function(i){return t.zScale(i.z)}).attr("width",r).attr("height",n).attr("transform",function(i){return"translate("+t.xScale(i.x)+","+t.yScale(i.y+1)+")"}),o.selectAll("rect").on("dblclick",function(e){var s=t.chart.settings.get("url_template").trim();if(s){i.event.stopPropagation();var a=t.categories.array.x[e.x],r=t.categories.array.y[e.y];window.open(s.replace("__LABEL__",a)),window.open(s.replace("__LABEL__",r))}}).on("mouseover",function(i){var e=this.getScreenCTM().translate(+this.getAttribute("cx"),+this.getAttribute("cy"));t.tooltip.style("opacity",.9),t.tooltip.html(t._templateTooltip(i)).style("left",window.pageXOffset+e.e+15+"px").style("top",window.pageYOffset+e.f-30+"px")}).on("mouseout",function(i){t.tooltip.style("opacity",0)}),this.tooltip.style("opacity",0),o.exit().remove()},_buildX:function(){var t=this.height,i=this.width,e=this.options.margin,s=this.svg,a=this.options.style["font-size"],r=this.boxWidth;this.gxAxis=s.append("g").attr("class","x axis").style("stroke-width",1).attr("transform","translate(0,"+t+")").call(this.xAxis);var n=Math.min(r,a);this.gxAxis.selectAll("text").style(this.options.style).style({"font-size":n+"px"}).attr("transform",function(t){return"rotate(-90)translate("+(-this.getBBox().height-15)+","+(r/2-n)+")"}),s.append("rect").attr("width",i).attr("height",a+3).attr("y",t+e.bottom-a-3).attr("fill",this.options.debug_color).attr("opacity",.7),this.gxAxisLabel=s.append("text").attr("class","x label").style(this.options.style).text(this.chart.settings.get("x_axis_label")).attr("transform",function(s){var r=t+e.bottom-a/3;return"translate("+(i-this.getBBox().width)/2+","+r+")"}),this.gxTickLabel=s.append("text").attr("class","title").style(this.options.style).style({"font-size":1.1*a}).text(this.group.key).attr("transform",function(t){var s=-e.top/2;return"translate("+(i-this.getBBox().width)/2+","+s+")"})},_buildY:function(){var t=this.height,i=this.options.margin,e=this.svg,s=this.options.style["font-size"],a=this.boxHeight;this.gyAxis=e.append("g").attr("class","y axis").style("stroke-width",1).call(this.yAxis);var r=Math.min(a,s);this.gyAxis.selectAll("text").style(this.options.style).style({"font-size":r+"px"}).attr("y",-a/2),e.append("rect").attr("width",s).attr("height",t).attr("x",-i.left).attr("fill",this.options.debug_color).attr("opacity",.7),this.gyAxisLabel=e.append("text").attr("class","y label").style(this.options.style).text(this.chart.settings.get("y_axis_label")).attr("transform",function(e){var a=-i.left+s-2;return"rotate(-90)translate("+-(t+this.getBBox().width)/2+","+a+")"})},_buildLegend:function(){var t=this,e=this.height,s=this.width,a=this.options.margin,r=this.options.legend.style["font-size"],n=this.options.legend.limit,o=this.options.legend.size,h=this.options.legend.width,l=this.zScale.range().length,c=Math.max(o*e/l,r),d=l*c/2,p=i.range(this.zMin,this.zMax,2*(this.zMax-this.zMin)/l).reverse();if(!(p.length<2)){var g=this.svg.selectAll(".legend").data(p).enter().append("g").attr("class","legend").attr("transform",function(t,i){return"translate("+(s+10)+","+((e-d)/2+i*c)+")"});g.append("rect").attr("width",h).attr("height",c).style("fill",function(i){return t.zScale(i)}),g.append("text").attr("x",h+4).attr("y",function(){return(c+this.getBBox().height)/2}).style(this.options.legend.style).text(function(t){return String(t).length>n?String(t).substr(0,n-2)+"..":String(t)}),this.svg.append("text").style(this.options.legend.style).style({"font-size":9,"font-weight":"bold"}).text("Legend").attr("transform",function(t,i){return"translate("+(s+(a.right-this.getBBox().width)/2)+","+((e-d)/2-10)+")"})}},_makeTickFormat:function(t){var i=this.chart.settings,e=this;n.makeTickFormat({categories:e.categories.array[t],type:i.get(t+"_axis_type|type"),precision:i.get(t+"_axis_type|precision"),formatter:function(i){i&&e[t+"Axis"].tickFormat(function(t){return i(t)})}})},_handleError:function(t){this.chart.state("failed",t)},_templateTooltip:function(t){var i=this.categories.array.x[t.x];return'
Row:'+this.categories.array.y[t.y]+'
Column:'+i+'
Value:'+t.z+"
"}});_.extend(window.bundleEntries||{},{heatmap_default:function(t){t.render=function(i,e){return new l({chart:t.chart,canvas_id:i,groups:e}),!0},o.requestPanels(t)},heatmap_cluster:function(t){h.request(t.chart,h.requestCharts(t.chart,"heatmap"),function(i){var e=new Backbone.Collection;t.chart.groups.each(function(t,i){e.add({__data_columns:{x:{is_label:!0},y:{is_label:!0},z:{is_numeric:!0}},x:i++,y:i++,z:i++,key:t.get("key")})}),t.dataset_id=i.id,t.dataset_groups=e,t.render=function(i,e){return new l({chart:t.chart,canvas_id:i,groups:e}),!0},o.requestPanels(t)},function(){t.process.reject()})}}); -},{"d3":4,"./colorsets":3}]},{},[1]) -//# sourceMappingURL=/script.map \ No newline at end of file diff --git a/config/plugins/visualizations/ngl/config/ngl.xml b/config/plugins/visualizations/ngl/config/ngl.xml index ef581714140..269a198c3a5 100644 --- a/config/plugins/visualizations/ngl/config/ngl.xml +++ b/config/plugins/visualizations/ngl/config/ngl.xml @@ -12,7 +12,7 @@ dataset_id - + diff --git a/config/plugins/visualizations/ngl/package.json b/config/plugins/visualizations/ngl/package.json index ca015d8c048..306200ac740 100644 --- a/config/plugins/visualizations/ngl/package.json +++ b/config/plugins/visualizations/ngl/package.json @@ -16,6 +16,6 @@ "ngl": "^0.10.4" }, "scripts": { - "build": "parcel build src/ngl.js -d static" + "build": "parcel build src/ngl.js -d static/dist" } } diff --git a/config/plugins/visualizations/ngl/src/ngl.js b/config/plugins/visualizations/ngl/src/ngl.js index 42c431080a4..b453c33b8e7 100644 --- a/config/plugins/visualizations/ngl/src/ngl.js +++ b/config/plugins/visualizations/ngl/src/ngl.js @@ -1,35 +1,37 @@ import * as ngl from "./viewer"; -_.extend(window.bundleEntries || {}, { - load: function(options) { - var dataset = options.dataset, - settings = options.chart.settings, - stage = new ngl.Stage(options.targets[0], {backgroundColor: settings.get('backcolor')}), - viewer_options = {}, - representation_parameters = {}, - stage_parameters = {}; - representation_parameters = { - radius: settings.get('radius'), - scale: settings.get('scale'), - assembly: settings.get('assembly'), - color: settings.get('colorscheme'), - opacity: settings.get('opacity') - }; - stage_parameters = {ext: dataset.extension, defaultRepresentation: true}; - try { - stage.loadFile(dataset.download_url, stage_parameters).then(function(component) { - component.addRepresentation(settings.get('mode'), representation_parameters); - options.chart.state('ok', 'Chart drawn.'); - options.process.resolve(); - } ); - } catch(e) { - options.chart.state('failed', 'Could not load PDB file.'); + +window.bundleEntries = window.bundleEntries || {}; +window.bundleEntries.load = function (options) { + var dataset = options.dataset, + settings = options.chart.settings, + stage = new ngl.Stage(options.targets[0], { backgroundColor: settings.get("backcolor") }), + viewer_options = {}, + representation_parameters = {}, + stage_parameters = {}; + representation_parameters = { + radius: settings.get("radius"), + scale: settings.get("scale"), + assembly: settings.get("assembly"), + color: settings.get("colorscheme"), + opacity: settings.get("opacity"), + }; + stage_parameters = { ext: dataset.extension, defaultRepresentation: true }; + try { + stage.loadFile(dataset.download_url, stage_parameters).then(function (component) { + component.addRepresentation(settings.get("mode"), representation_parameters); + options.chart.state("ok", "Chart drawn."); options.process.resolve(); - } - stage.setQuality(settings.get('quality' ) ); - if (settings.get('spin') === true || settings.get('spin') === 'true') { - stage.setSpin([0, 1, 0], 0.01); - } - // Re-renders the molecule view when window is resized - $(window).resize(function() {stage.viewer.handleResize()}); + }); + } catch (e) { + options.chart.state("failed", "Could not load PDB file."); + options.process.resolve(); } -}); + stage.setQuality(settings.get("quality")); + if (settings.get("spin") === true || settings.get("spin") === "true") { + stage.setSpin([0, 1, 0], 0.01); + } + // Re-renders the molecule view when window is resized + window.onresize = function () { + viewer.fitParent(); + }; +}; diff --git a/config/plugins/visualizations/ngl/static/ngl.js b/config/plugins/visualizations/ngl/static/ngl.js deleted file mode 100644 index 94787fd8cea..00000000000 --- a/config/plugins/visualizations/ngl/static/ngl.js +++ /dev/null @@ -1,5 +0,0 @@ -require=function(r,e,n){function t(n,o){function i(r){return t(i.resolve(r))}function f(e){return r[n][1][e]||e}if(!e[n]){if(!r[n]){var c="function"==typeof require&&require;if(!o&&c)return c(n,!0);if(u)return u(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}i.resolve=f;var a=e[n]=new t.Module;r[n][0].call(a.exports,i,a,a.exports)}return e[n].exports}function o(){this.bundle=t,this.exports={}}var u="function"==typeof require&&require;t.Module=o,t.modules=r,t.cache=e,t.parent=u;for(var i=0;i1?s.pop().toLowerCase():"",h=e.match(/^(.+):\/\/(.+)$/);h&&(n=h[1].toLowerCase(),e=h[2]);var u=e.substring(0,e.lastIndexOf("/")+1);if(["gz"].includes(c)){i=c;var l=e.length-c.length-1;c=e.substr(0,l).split(".").pop().toLowerCase();var d=a.length-c.length-1;a=a.substr(0,d)}else i=!1;return{path:e,name:o,ext:c,base:a,dir:u,compressed:i,protocol:n,src:t}}function p(t){return t.sort().filter(function(t,e,i){return 0===e||t!==i[e-1]})}function m(t){var e=28672;if(t.length>e){for(var i=[],n=0;n 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(n),l.attachShader(e,i),l.attachShader(e,n),l.linkProgram(e),e}function r(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,h,u,l=t.context,d=t.state,f=new A,p=new S,m=new A;this.render=function(n,g){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(h.projectionMatrix,!1,g.projectionMatrix.elements),d.activeTexture(l.TEXTURE0),l.uniform1i(h.map,0);var v=0,y=0,b=n.fog;b?(l.uniform3f(h.fogColor,b.color.r,b.color.g,b.color.b),b&&b.isFog?(l.uniform1f(h.fogNear,b.near),l.uniform1f(h.fogFar,b.far),l.uniform1i(h.fogType,1),v=1,y=1):b&&b.isFogExp2&&(l.uniform1f(h.fogDensity,b.density),l.uniform1i(h.fogType,2),v=2,y=2)):(l.uniform1i(h.fogType,0),v=0,y=0);for(var x=0,_=e.length;x<_;x++){(S=e[x]).modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,S.matrixWorld),S.z=-S.modelViewMatrix.elements[14]}e.sort(r);var w=[];for(x=0,_=e.length;x<_;x++){var S,A=(S=e[x]).material;if(!1!==A.visible){l.uniform1f(h.alphaTest,A.alphaTest),l.uniformMatrix4fv(h.modelViewMatrix,!1,S.modelViewMatrix.elements),S.matrixWorld.decompose(f,p,m),w[0]=m.x,w[1]=m.y;var M=0;n.fog&&A.fog&&(M=y),v!==M&&(l.uniform1i(h.fogType,M),v=M),null!==A.map?(l.uniform2f(h.uvOffset,A.map.offset.x,A.map.offset.y),l.uniform2f(h.uvScale,A.map.repeat.x,A.map.repeat.y)):(l.uniform2f(h.uvOffset,0,0),l.uniform2f(h.uvScale,1,1)),l.uniform1f(h.opacity,A.opacity),l.uniform3f(h.color,A.color.r,A.color.g,A.color.b),l.uniform1f(h.rotation,A.rotation),l.uniform2fv(h.scale,w),d.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst),d.setDepthTest(A.depthTest),d.setDepthWrite(A.depthWrite),A.map?t.setTexture2D(A.map,0):t.setTexture2D(u,0),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0)}}d.enable(l.CULL_FACE),t.resetGLState()}}}function P(t,e){this.min=void 0!==t?t:new x(1/0,1/0),this.max=void 0!==e?e:new x(-1/0,-1/0)}function C(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]);r=d.createBuffer(),o=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,r),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),u=d.createTexture(),l=d.createTexture(),f.bindTexture(d.TEXTURE_2D,u),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,l),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=n(a),c={vertex:d.getAttribLocation(s,"position"),uv:d.getAttribLocation(s,"uv")},h={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 n(e){var i=d.createProgram(),n=d.createShader(d.FRAGMENT_SHADER),r=d.createShader(d.VERTEX_SHADER),o="precision "+t.getPrecision()+" float;\n";return d.shaderSource(n,o+e.fragmentShader),d.shaderSource(r,o+e.vertexShader),d.compileShader(n),d.compileShader(r),d.attachShader(i,n),d.attachShader(i,r),d.linkProgram(i),i}var r,o,a,s,c,h,u,l,d=t.context,f=t.state;this.render=function(n,a,p){if(0!==e.length){var m=new A,g=p.w/p.z,v=.5*p.z,y=.5*p.w,b=16/p.w,_=new x(b*g,b),w=new A(1,1,0),S=new x(1,1),M=new P;M.min.set(0,0),M.max.set(p.z-16,p.w-16),void 0===s&&i(),d.useProgram(s),f.initAttributes(),f.enableAttribute(c.vertex),f.enableAttribute(c.uv),f.disableUnusedAttributes(),d.uniform1i(h.occlusionMap,0),d.uniform1i(h.map,1),d.bindBuffer(d.ARRAY_BUFFER,r),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.setDepthWrite(!1);for(var C=0,T=e.length;C.001&&O.scale>.001&&(w.x=O.x,w.y=O.y,w.z=O.z,b=O.size*O.scale/p.w,_.x=b*g,_.y=b,d.uniform3f(h.screenPosition,w.x,w.y,w.z),d.uniform2f(h.scale,_.x,_.y),d.uniform1f(h.rotation,O.rotation),d.uniform1f(h.opacity,O.opacity),d.uniform3f(h.color,O.color.r,O.color.g,O.color.b),f.setBlending(O.blending,O.blendEquation,O.blendSrc,O.blendDst),t.setTexture2D(O.texture,1),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0))}}}f.enable(d.CULL_FACE),f.enable(d.DEPTH_TEST),f.setDepthWrite(!0),t.resetGLState()}}}function T(t,e,i,n,r,o,a,s,c,h){t=void 0!==t?t:[],e=void 0!==e?e:Eh,_.call(this,t,e,i,n,r,o,a,s,c,h),this.flipY=!1}function E(){this.seq=[],this.map={}}function I(t,e,i){var n=t[0];if(n<=0||n>0)return t;var r=e*i,o=zu[r];if(void 0===o&&(o=new Float32Array(r),zu[r]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=i,t[a].toArray(o,s)}return o}function L(t,e){var i=Bu[e];void 0===i&&(i=new Int32Array(e),Bu[e]=i);for(var n=0;n!==e;++n)i[n]=t.allocTextureUnit();return i}function O(t,e){t.uniform1f(this.addr,e)}function R(t,e){t.uniform1i(this.addr,e)}function D(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function N(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 k(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function F(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function z(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function B(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function U(t,e,i){var n=i.allocTextureUnit();t.uniform1i(this.addr,n),i.setTexture2D(e||ku,n)}function $(t,e,i){var n=i.allocTextureUnit();t.uniform1i(this.addr,n),i.setTextureCube(e||Fu,n)}function V(t,e){t.uniform2iv(this.addr,e)}function j(t,e){t.uniform3iv(this.addr,e)}function G(t,e){t.uniform4iv(this.addr,e)}function H(t,e){t.uniform1fv(this.addr,e)}function W(t,e){t.uniform1iv(this.addr,e)}function X(t,e){t.uniform2fv(this.addr,I(e,this.size,2))}function q(t,e){t.uniform3fv(this.addr,I(e,this.size,3))}function Y(t,e){t.uniform4fv(this.addr,I(e,this.size,4))}function Z(t,e){t.uniformMatrix2fv(this.addr,!1,I(e,this.size,4))}function K(t,e){t.uniformMatrix3fv(this.addr,!1,I(e,this.size,9))}function Q(t,e){t.uniformMatrix4fv(this.addr,!1,I(e,this.size,16))}function J(t,e,i){var n=e.length,r=L(i,n);t.uniform1iv(this.addr,r);for(var o=0;o!==n;++o)i.setTexture2D(e[o]||ku,r[o])}function tt(t,e,i){var n=e.length,r=L(i,n);t.uniform1iv(this.addr,r);for(var o=0;o!==n;++o)i.setTextureCube(e[o]||Fu,r[o])}function et(t,e,i){this.id=t,this.addr=i,this.setValue=function(t){switch(t){case 5126:return O;case 35664:return D;case 35665:return N;case 35666:return k;case 35674:return F;case 35675:return z;case 35676:return B;case 35678:return U;case 35680:return $;case 5124:case 35670:return R;case 35667:case 35671:return V;case 35668:case 35672:return j;case 35669:case 35673:return G}}(e.type)}function it(t,e,i){this.id=t,this.addr=i,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return H;case 35664:return X;case 35665:return q;case 35666:return Y;case 35674:return Z;case 35675:return K;case 35676:return Q;case 35678:return J;case 35680:return tt;case 5124:case 35670:return W;case 35667:case 35671:return V;case 35668:case 35672:return j;case 35669:case 35673:return G}}(e.type)}function nt(t){this.id=t,E.call(this)}function rt(t,e){t.seq.push(e),t.map[e.id]=e}function ot(t,e,i){var n=t.name,r=n.length;for(Uu.lastIndex=0;;){var o=Uu.exec(n),a=Uu.lastIndex,s=o[1],c="]"===o[2],h=o[3];if(c&&(s|=0),void 0===h||"["===h&&a+2===r){rt(i,void 0===h?new et(s,t,e):new it(s,t,e));break}var u=i.map[s];void 0===u&&rt(i,u=new nt(s)),i=u}}function at(t,e,i){E.call(this),this.renderer=i;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r!==n;++r){var o=t.getActiveUniform(e,r),a=o.name;ot(o,t.getUniformLocation(e,a),this)}}function st(t,e,i,n,r,o,a){function s(t,e){if(t.width>e||t.height>e){var i=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*i),n.height=Math.floor(t.height*i),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return Du.isPowerOfTwo(t.width)&&Du.isPowerOfTwo(t.height)}function h(e){return e===Bh||e===Uh||e===$h?t.NEAREST:t.LINEAR}function u(t){var e=t.target;e.removeEventListener("dispose",u),d(e),x.textures--}function l(t){var e=t.target;e.removeEventListener("dispose",l),f(e),x.textures--}function d(e){var i=n.get(e);if(e.image&&i.__image__webglTextureCube)t.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture)}n.delete(e)}function f(e){var i=n.get(e),r=n.get(e.texture);if(e){if(void 0!==r.__webglTexture&&t.deleteTexture(r.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e&&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);n.delete(e.texture),n.delete(e)}}function p(e,r){var o=n.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a);else if(!1!==a.complete)return void g(o,e,r)}i.activeTexture(t.TEXTURE0+r),i.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function m(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===Fh&&a.wrapT,t.texParameteri(i,t.TEXTURE_MAG_FILTER,h(a.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,h(a.minFilter)),a.minFilter!==Bh&&a.minFilter),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===Kh&&null===e.get("OES_texture_float_linear"))return;if(a.type===Qh&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(t.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function g(e,n,a){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",u),e.__webglTexture=t.createTexture(),x.textures++),i.activeTexture(t.TEXTURE0+a),i.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var h=s(n.image,r.maxTextureSize);(function(t){return t.wrapS!==Fh||t.wrapT!==Fh||t.minFilter!==Bh&&t.minFilter!==Vh})(n)&&!1===c(h)&&(h=function(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Du.nearestPowerOfTwo(t.width),e.height=Du.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}(h));var l=c(h),d=o(n.format),f=o(n.type);m(t.TEXTURE_2D,n,l);var p,g=n.mipmaps;if(n&&n.isDepthTexture){var v=t.DEPTH_COMPONENT;if(n.type===Kh){if(!_)throw new Error("Float Depth Texture only supported in WebGL2.0");v=t.DEPTH_COMPONENT32F}else _&&(v=t.DEPTH_COMPONENT16);n.format===hu&&(v=t.DEPTH_STENCIL),i.texImage2D(t.TEXTURE_2D,0,v,h.width,h.height,0,d,f,null)}else if(n&&n.isDataTexture)if(g.length>0&&l){for(var y=0,b=g.length;y-1&&i.compressedTexImage2D(t.TEXTURE_2D,y,d,p.width,p.height,0,p.data):i.texImage2D(t.TEXTURE_2D,y,d,p.width,p.height,0,d,f,p.data);else if(g.length>0&&l){for(y=0,b=g.length;y0&&h.__version!==e.version){h.__image__webglTextureCube||(e.addEventListener("dispose",u),h.__image__webglTextureCube=t.createTexture(),x.textures++),i.activeTexture(t.TEXTURE0+a),i.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var l=e&&e.isCompressedTexture,d=e.image[0]&&e.image[0].isDataTexture,f=[],p=0;p<6;p++)f[p]=l||d?d?e.image[p].image:e.image[p]:s(e.image[p],r.maxCubemapSize);var g=c(f[0]),v=o(e.format),y=o(e.type);for(m(t.TEXTURE_CUBE_MAP,e,g),p=0;p<6;p++)if(l)for(var b,_=f[p].mipmaps,w=0,S=_.length;w-1&&i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,w,v,b.width,b.height,0,b.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,w,v,b.width,b.height,0,v,y,b.data);else d?i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,v,f[p].width,f[p].height,0,v,y,f[p].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,v,v,y,f[p]);e.generateMipmaps&&g&&t.generateMipmap(t.TEXTURE_CUBE_MAP),h.__version=e.version,e.onUpdate&&e.onUpdate(e)}else i.activeTexture(t.TEXTURE0+a),i.bindTexture(t.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,r){i.activeTexture(t.TEXTURE0+r),i.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var r=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",l),o.__webglTexture=t.createTexture(),x.textures++;var a=e&&e.isWebGLRenderTargetCube,s=c(e);if(a){r.__webglFramebuffer=[];for(var h=0;h<6;h++)r.__webglFramebuffer[h]=t.createFramebuffer()}else r.__webglFramebuffer=t.createFramebuffer();if(a){for(i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),m(t.TEXTURE_CUBE_MAP,e.texture,s),h=0;h<6;h++)v(r.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_CUBE_MAP),i.bindTexture(t.TEXTURE_CUBE_MAP,null)}else i.bindTexture(t.TEXTURE_2D,o.__webglTexture),m(t.TEXTURE_2D,e.texture,s),v(r.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_2D),i.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&b(e)},this.updateRenderTargetMipmap=function(e){var r=e.texture;if(r.generateMipmaps&&c(e)&&r.minFilter!==Bh&&r.minFilter!==Vh){var o=e&&e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(r).__webglTexture;i.bindTexture(o,a),t.generateMipmap(o),i.bindTexture(o,null)}}}function ct(t,e,i,n){this.x=t||0,this.y=e||0,this.z=i||0,this.w=void 0!==n?n:1}function ht(t,e,i){this.uuid=Du.generateUUID(),this.width=t,this.height=e,this.scissor=new ct(0,0,t,e),this.scissorTest=!1,this.viewport=new ct(0,0,t,e),void 0===(i=i||{}).minFilter&&(i.minFilter=Vh),this.texture=new _(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 ut(){Object.defineProperty(this,"id",{value:$u++}),this.uuid=Du.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Wc,this.side=zc,this.shading=Vc,this.vertexColors=jc,this.opacity=1,this.transparent=!1,this.blendSrc=ah,this.blendDst=sh,this.blendEquation=Kc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=gh,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this._needsUpdate=!0}function lt(t){ut.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(t.attributes,this.setValues(t))}function dt(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}function ft(t){ut.call(this),this.type="MeshDepthMaterial",this.depthPacking=Ou,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 pt(t,e){this.min=void 0!==t?t:new A(1/0,1/0,1/0),this.max=void 0!==e?e:new A(-1/0,-1/0,-1/0)}function mt(t,e){this.center=void 0!==t?t:new A,this.radius=void 0!==e?e:0}function gt(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length}function vt(t,e){this.normal=void 0!==t?t:new A(1,0,0),this.constant=void 0!==e?e:0}function yt(t,e,i,n,r,o){this.planes=[void 0!==t?t:new vt,void 0!==e?e:new vt,void 0!==i?i:new vt,void 0!==n?n:new vt,void 0!==r?r:new vt,void 0!==o?o:new vt]}function bt(t,e,i,n){function r(e,i,n,r){var o=e.geometry,a=null,s=b,c=e.customDepthMaterial;if(n&&(s=_,c=e.customDistanceMaterial),c)a=c;else{var h=!1;i.morphTargets&&(o&&o.isBufferGeometry?h=o.morphAttributes&&o.morphAttributes.position&&o.morphAttributes.position.length>0:o&&o.isGeometry&&(h=o.morphTargets&&o.morphTargets.length>0));var u=e.isSkinnedMesh&&i.skinning,l=0;h&&(l|=g),u&&(l|=v),a=s[l]}if(t.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var d=a.uuid,f=i.uuid,p=S[d];void 0===p&&(p={},S[d]=p);var m=p[f];void 0===m&&(m=a.clone(),p[f]=m),a=m}a.visible=i.visible,a.wireframe=i.wireframe;var y=i.side;return k.renderSingleSided&&y==Uc&&(y=zc),k.renderReverseSided&&(y===zc?y=Bc:y===Bc&&(y=zc)),a.side=y,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,n&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(r),a}function o(t,e,i){if(!1!==t.visible){if(0!=(t.layers.mask&e.layers.mask)&&(t.isMesh||t.isLine||t.isPoints)&&t.castShadow&&(!1===t.frustumCulled||!0===c.intersectsObject(t)))!0===t.material.visible&&(t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),m.push(t));for(var n=t.children,r=0,a=n.length;r/g,function(t,e){var i=ju[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return Mt(i)})}function Pt(t){return t.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,i,n){for(var r="",o=parseInt(e);o0?t.gammaFactor:1,g=function(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(St).join("\n")}(o,n,t.extensions),v=function(t){var e=[];for(var i in t){var n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(a),y=r.createProgram();i.isRawShaderMaterial?(f=[v,"\n"].filter(St).join("\n"),p=[g,v,"\n"].filter(St).join("\n")):(f=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+i.__webglShader.name,v,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",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"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(St).join("\n"),p=[g,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+i.__webglShader.name,v,n.alphaTest?"#define ALPHATEST "+n.alphaTest:"","#define GAMMA_FACTOR "+m,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 "+u:"",n.envMap?"#define "+l:"",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.flatShading?"#define FLAT_SHADED":"",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.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!==Ah?"#define TONE_MAPPING":"",n.toneMapping!==Ah?ju.tonemapping_pars_fragment:"",n.toneMapping!==Ah?function(t,e){var i;switch(e){case Mh:i="Linear";break;case Ph:i="Reinhard";break;case Ch:i="Uncharted2";break;case Th:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",n.toneMapping):"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?ju.encodings_pars_fragment:"",n.mapEncoding?wt("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?wt("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?wt("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?function(t,e){var i=_t(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}("linearToOutputTexel",n.outputEncoding):"",n.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(St).join("\n")),s=At(s=Mt(s),n),c=At(c=Mt(c),n),i.isShaderMaterial||(s=Pt(s),c=Pt(c));var b=f+s,x=p+c,_=xt(r,r.VERTEX_SHADER,b),w=xt(r,r.FRAGMENT_SHADER,x);r.attachShader(y,_),r.attachShader(y,w),void 0!==i.index0AttributeName?r.bindAttribLocation(y,0,i.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);var S,A,M=r.getProgramInfoLog(y),P=r.getShaderInfoLog(_),C=r.getShaderInfoLog(w),T=!0,E=!0;return!1===r.getProgramParameter(y,r.LINK_STATUS)?T=!1:""!==M||""!==P&&""!==C||(E=!1),E&&(this.diagnostics={runnable:T,material:i,programLog:M,vertexShader:{log:P,prefix:f},fragmentShader:{log:C,prefix:p}}),r.deleteShader(_),r.deleteShader(w),this.getUniforms=function(){return void 0===S&&(S=new at(r,y,t)),S},this.getAttributes=function(){return void 0===A&&(A=function(t,e,i){for(var n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),o=0;o0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:n.premultipliedAlpha,alphaTest:n.alphaTest,doubleSided:n.side===Uc,flipSided:n.side===Bc,depthPacking:void 0!==n.depthPacking&&n.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 n in t.defines)i.push(n),i.push(t.defines[n]);for(var r=0;ri){var n=e;e=i,i=n}var r=t[e];return void 0===r?(t[e]=[i],!0):-1===r.indexOf(i)&&(r.push(i),!0)}var s=new Bt(t,e,i);return{getAttributeBuffer:function(t){return t.isInterleavedBufferAttribute?e.get(t.data).__webglBuffer:e.get(t).__webglBuffer},getWireframeAttribute:function(i){var r=e.get(i);if(void 0!==r.wireframe)return r.wireframe;var o,s=[],c=i.index,h=i.attributes,u=h.position;if(null!==c)for(var l={},d=0,f=(o=c.array).length;d65535?Uint32Array:Uint16Array)(s),1);return n(v,t.ELEMENT_ARRAY_BUFFER),r.wireframe=v,v},update:function(e){var i=s.get(e);e.geometry.isGeometry&&i.updateFromObject(e);var r=i.index,o=i.attributes;for(var a in null!==r&&n(r,t.ELEMENT_ARRAY_BUFFER),o)n(o[a],t.ARRAY_BUFFER);var c=i.morphAttributes;for(var a in c)for(var h=c[a],u=0,l=h.length;u0),i.numPlanes=r}function e(t,e,n,r){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=h.value,!0!==r||null===a){var u=n+4*o,l=e.matrixWorldInverse;c.getNormalMatrix(l),(null===a||a.length0?1:-1,d[p]=L.x,d[p+1]=L.y,d[p+2]=L.z,f[m]=D/h,f[m+1]=1-O/b,p+=3,m+=2,E+=1}for(O=0;O65535?Uint32Array:Uint16Array)(h),l=new Float32Array(3*c),d=new Float32Array(3*c),f=new Float32Array(2*c),p=0,m=0,g=0,v=0,y=0;a("z","y","x",-1,-1,i,e,t,o,r,0),a("z","y","x",1,-1,i,e,-t,o,r,1),a("x","z","y",1,1,t,i,e,n,o,2),a("x","z","y",1,-1,t,i,-e,n,o,3),a("x","y","z",1,-1,t,e,i,n,r,4),a("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(new Et(u,1)),this.addAttribute("position",new Et(l,3)),this.addAttribute("normal",new Et(d,3)),this.addAttribute("uv",new Et(f,2))}function Ht(t,e){this.origin=void 0!==t?t:new A,this.direction=void 0!==e?e:new A}function Wt(t,e){this.start=void 0!==t?t:new A,this.end=void 0!==e?e:new A}function Xt(t,e,i){this.a=void 0!==t?t:new A,this.b=void 0!==e?e:new A,this.c=void 0!==i?i:new A}function qt(t){ut.call(this),this.type="MeshBasicMaterial",this.color=new dt(16777215),this.map=null,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=_h,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 Yt(t,e){Dt.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new zt,this.material=void 0!==e?e:new qt({color:16777215*Math.random()}),this.drawMode=wu,this.updateMorphTargets()}function Zt(t,e,i,n){zt.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};for(var r=t/2,o=e/2,a=Math.floor(i)||1,s=Math.floor(n)||1,c=a+1,h=s+1,u=t/a,l=e/s,d=new Float32Array(c*h*3),f=new Float32Array(c*h*3),p=new Float32Array(c*h*2),m=0,g=0,v=0;v65535?Uint32Array:Uint16Array)(a*s*6);for(v=0;v=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(d=0;d=0&&t.numSupportedMorphNormals++}var f=n.__webglShader.uniforms;!t.isShaderMaterial&&!t.isRawShaderMaterial|!0===t.clipping&&(n.numClippingPlanes=ft.numPlanes,f.clippingPlanes=ft.uniform),n.fog=e,n.lightsHash=wt.hash,t.lights&&(f.ambientLightColor.value=wt.ambient,f.directionalLights.value=wt.directional,f.spotLights.value=wt.spot,f.pointLights.value=wt.point,f.hemisphereLights.value=wt.hemi,f.directionalShadowMap.value=wt.directionalShadowMap,f.directionalShadowMatrix.value=wt.directionalShadowMatrix,f.spotShadowMap.value=wt.spotShadowMap,f.spotShadowMatrix.value=wt.spotShadowMatrix,f.pointShadowMap.value=wt.pointShadowMap,f.pointShadowMatrix.value=wt.pointShadowMatrix);var p=n.program.getUniforms(),m=at.seqWithValue(p.seq,f);n.uniformsList=m,n.dynamicUniforms=at.splitDynamic(m,f)}function g(t){t.side===Uc?Ct.disable($.CULL_FACE):Ct.enable($.CULL_FACE),Ct.setFlipSided(t.side===Bc),!0===t.transparent?Ct.setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha):Ct.setBlending(Hc),Ct.setDepthFunc(t.depthFunc),Ct.setDepthTest(t.depthTest),Ct.setDepthWrite(t.depthWrite),Ct.setColorWrite(t.colorWrite),Ct.setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)}function v(t,e,i,n){Q=0;var r=Et.get(i);if(pt&&(gt||t!==q)){var o=t===q&&i.id===W;ft.setState(i.clippingPlanes,i.clipShadows,t,r,o)}!1===i.needsUpdate&&(void 0===r.program?i.needsUpdate=!0:i.fog&&r.fog!==e?i.needsUpdate=!0:i.lights&&r.lightsHash!==wt.hash?i.needsUpdate=!0:void 0!==r.numClippingPlanes&&r.numClippingPlanes!==ft.numPlanes&&(i.needsUpdate=!0)),i.needsUpdate&&(m(i,e,n),i.needsUpdate=!1);var a=!1,s=!1,c=!1,h=r.program,u=h.getUniforms(),l=r.__webglShader.uniforms;if(h.id!==j&&($.useProgram(h.program),j=h.id,a=!0,s=!0,c=!0),i.id!==W&&(W=i.id,s=!0),a||t!==q){if(u.set($,t,"projectionMatrix"),Pt.logarithmicDepthBuffer&&u.setValue($,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),t!==q&&(q=t,s=!0,c=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var d=u.map.cameraPosition;void 0!==d&&d.setValue($,_t.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&u.setValue($,"viewMatrix",t.matrixWorldInverse),u.set($,V,"toneMappingExposure"),u.set($,V,"toneMappingWhitePoint")}if(i.skinning){u.setOptional($,n,"bindMatrix"),u.setOptional($,n,"bindMatrixInverse");var f=n.skeleton;f&&(Pt.floatVertexTextures&&f.useVertexTexture?(u.set($,f,"boneTexture"),u.set($,f,"boneTextureWidth"),u.set($,f,"boneTextureHeight")):u.setOptional($,f,"boneMatrices"))}s&&(i.lights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(l,c),e&&i.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(l,e),(i.isMeshBasicMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshDepthMaterial)&&function(t,e){var i;if(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.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);var n=i.offset,r=i.repeat;t.offsetRepeat.value.set(n.x,n.y,r.x,r.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}(l,i),i.isLineBasicMaterial?y(l,i):i.isLineDashedMaterial?(y(l,i),function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(l,i)):i.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*nt,t.scale.value=.5*_.clientHeight,t.map.value=e.map,null!==e.map){var i=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}}(l,i):i.isMeshLambertMaterial?function(t,e){e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(l,i):i.isMeshPhongMaterial?function(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),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)}(l,i):i.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,b(t,e)}(l,i):i.isMeshStandardMaterial?b(l,i):i.isMeshDepthMaterial?i.displacementMap&&(l.displacementMap.value=i.displacementMap,l.displacementScale.value=i.displacementScale,l.displacementBias.value=i.displacementBias):i.isMeshNormalMaterial&&(l.opacity.value=i.opacity),at.upload($,r.uniformsList,l,V)),u.set($,n,"modelViewMatrix"),u.set($,n,"normalMatrix"),u.setValue($,"modelMatrix",n.matrixWorld);var p=r.dynamicUniforms;return null!==p&&(at.evalDynamic(p,l,n,t),at.upload($,p,l,V)),h}function y(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function b(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.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),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 x(t){var e;if(t===kh)return $.REPEAT;if(t===Fh)return $.CLAMP_TO_EDGE;if(t===zh)return $.MIRRORED_REPEAT;if(t===Bh)return $.NEAREST;if(t===Uh)return $.NEAREST_MIPMAP_NEAREST;if(t===$h)return $.NEAREST_MIPMAP_LINEAR;if(t===Vh)return $.LINEAR;if(t===jh)return $.LINEAR_MIPMAP_NEAREST;if(t===Gh)return $.LINEAR_MIPMAP_LINEAR;if(t===Hh)return $.UNSIGNED_BYTE;if(t===Jh)return $.UNSIGNED_SHORT_4_4_4_4;if(t===tu)return $.UNSIGNED_SHORT_5_5_5_1;if(t===eu)return $.UNSIGNED_SHORT_5_6_5;if(t===Wh)return $.BYTE;if(t===Xh)return $.SHORT;if(t===qh)return $.UNSIGNED_SHORT;if(t===Yh)return $.INT;if(t===Zh)return $.UNSIGNED_INT;if(t===Kh)return $.FLOAT;if(null!==(e=Mt.get("OES_texture_half_float"))&&t===Qh)return e.HALF_FLOAT_OES;if(t===nu)return $.ALPHA;if(t===ru)return $.RGB;if(t===ou)return $.RGBA;if(t===au)return $.LUMINANCE;if(t===su)return $.LUMINANCE_ALPHA;if(t===cu)return $.DEPTH_COMPONENT;if(t===hu)return $.DEPTH_STENCIL;if(t===Kc)return $.FUNC_ADD;if(t===Qc)return $.FUNC_SUBTRACT;if(t===Jc)return $.FUNC_REVERSE_SUBTRACT;if(t===ih)return $.ZERO;if(t===nh)return $.ONE;if(t===rh)return $.SRC_COLOR;if(t===oh)return $.ONE_MINUS_SRC_COLOR;if(t===ah)return $.SRC_ALPHA;if(t===sh)return $.ONE_MINUS_SRC_ALPHA;if(t===ch)return $.DST_ALPHA;if(t===hh)return $.ONE_MINUS_DST_ALPHA;if(t===uh)return $.DST_COLOR;if(t===lh)return $.ONE_MINUS_DST_COLOR;if(t===dh)return $.SRC_ALPHA_SATURATE;if(null!==(e=Mt.get("WEBGL_compressed_texture_s3tc"))){if(t===uu)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===lu)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===du)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===fu)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(null!==(e=Mt.get("WEBGL_compressed_texture_pvrtc"))){if(t===pu)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===mu)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===gu)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===vu)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(null!==(e=Mt.get("WEBGL_compressed_texture_etc1"))&&t===yu)return e.COMPRESSED_RGB_ETC1_WEBGL;if(null!==(e=Mt.get("EXT_blend_minmax"))){if(t===th)return e.MIN_EXT;if(t===eh)return e.MAX_EXT}return null!==(e=Mt.get("WEBGL_depth_texture"))&&t===iu?e.UNSIGNED_INT_24_8_WEBGL:0}var _=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),S=void 0!==t.context?t.context:null,P=void 0!==t.alpha&&t.alpha,T=void 0===t.depth||t.depth,E=void 0===t.stencil||t.stencil,I=void 0!==t.antialias&&t.antialias,L=void 0===t.premultipliedAlpha||t.premultipliedAlpha,O=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,R=[],D=[],N=-1,k=[],F=-1,z=new Float32Array(8),B=[],U=[];this.domElement=_,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=Mh,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var $,V=this,j=null,G=null,H=null,W=-1,X="",q=null,Y=new ct,Z=null,K=new ct,Q=0,J=new dt(0),tt=0,et=_.width,it=_.height,nt=1,rt=new ct(0,0,et,it),ot=!1,ht=new ct(0,0,et,it),ut=new yt,ft=new Vt,pt=!1,gt=!1,vt=new mt,xt=new w,_t=new A,wt={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},St={calls:0,vertices:0,faces:0,points:0};this.info={render:St,memory:{geometries:0,textures:0},programs:null};try{var At={alpha:P,depth:T,stencil:E,antialias:I,premultipliedAlpha:L,preserveDrawingBuffer:O};if(null===($=S||_.getContext("webgl",At)||_.getContext("experimental-webgl",At)))throw null!==_.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===$.getShaderPrecisionFormat&&($.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),_.addEventListener("webglcontextlost",o,!1)}catch(t){}var Mt=new function(t){var e={};return{get:function(i){if(void 0!==e[i])return e[i];var n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(i)}return e[i]=n,n}}}($);Mt.get("WEBGL_depth_texture"),Mt.get("OES_texture_float"),Mt.get("OES_texture_float_linear"),Mt.get("OES_texture_half_float"),Mt.get("OES_texture_half_float_linear"),Mt.get("OES_standard_derivatives"),Mt.get("ANGLE_instanced_arrays"),Mt.get("OES_element_index_uint")&&(zt.MaxIndex=4294967296);var Pt=new function(t,e,i){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 r,o=void 0!==i.precision?i.precision:"highp",a=n(o);a!==o&&(o=a);var s=!0===i.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),l=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),d=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),p=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=h>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==r)return r;var i=e.get("EXT_texture_filter_anisotropic");return r=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:l,maxAttributes:d,maxVertexUniforms:f,maxVaryings:p,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}($,Mt,t),Ct=new function(t,e,i){function n(e,i,n){var r=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;a8&&(d.length=8);var y=n.morphAttributes;for(f=0,p=d.length;f=0){var u=o[c];if(void 0!==u){var l=$.FLOAT,d=u.array,f=u.normalized;d instanceof Float32Array?l=$.FLOAT:d instanceof Float64Array||(d instanceof Uint16Array?l=$.UNSIGNED_SHORT:d instanceof Int16Array?l=$.SHORT:d instanceof Uint32Array?l=$.UNSIGNED_INT:d instanceof Int32Array?l=$.INT:d instanceof Int8Array?l=$.BYTE:d instanceof Uint8Array&&(l=$.UNSIGNED_BYTE));var p=u.itemSize,m=Lt.getAttributeBuffer(u);if(u&&u.isInterleavedBufferAttribute){var g=u.data,v=g.stride,y=u.offset;g&&g.isInstancedInterleavedBuffer?(Ct.enableAttributeAndDivisor(h,g.meshPerAttribute,r),void 0===i.maxInstancedCount&&(i.maxInstancedCount=g.meshPerAttribute*g.count)):Ct.enableAttribute(h),$.bindBuffer($.ARRAY_BUFFER,m),$.vertexAttribPointer(h,p,l,f,v*g.array.BYTES_PER_ELEMENT,(n*v+y)*g.array.BYTES_PER_ELEMENT)}else u&&u.isInstancedBufferAttribute?(Ct.enableAttributeAndDivisor(h,u.meshPerAttribute,r),void 0===i.maxInstancedCount&&(i.maxInstancedCount=u.meshPerAttribute*u.count)):Ct.enableAttribute(h),$.bindBuffer($.ARRAY_BUFFER,m),$.vertexAttribPointer(h,p,l,f,0,n*p*u.array.BYTES_PER_ELEMENT)}else if(void 0!==s){var b=s[c];if(void 0!==b)switch(b.length){case 2:$.vertexAttrib2fv(h,b);break;case 3:$.vertexAttrib3fv(h,b);break;case 4:$.vertexAttrib4fv(h,b);break;default:$.vertexAttrib1fv(h,b)}}}}Ct.disableUnusedAttributes()}}(r,s,n),null!==b&&$.bindBuffer($.ELEMENT_ARRAY_BUFFER,Lt.getAttributeBuffer(b)));var w=1/0;null!==b?w=b.count:void 0!==_&&(w=_.count);var S=n.drawRange.start,A=n.drawRange.count,M=null!==a?a.start:0,P=null!==a?a.count:1/0,C=Math.max(0,S,M),T=Math.min(0+w,S+A,M+P)-1,E=Math.max(0,T-C+1);if(o.isMesh)if(!0===r.wireframe)Ct.setLineWidth(r.wireframeLinewidth*e()),x.setMode($.LINES);else switch(o.drawMode){case wu:x.setMode($.TRIANGLES);break;case Su:x.setMode($.TRIANGLE_STRIP);break;case Au:x.setMode($.TRIANGLE_FAN)}else if(o.isLine){var I=r.linewidth;void 0===I&&(I=1),Ct.setLineWidth(I*e()),o.isLineSegments?x.setMode($.LINES):x.setMode($.LINE_STRIP)}else o.isPoints&&x.setMode($.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&x.renderInstances(n,C,E):x.render(C,E)},this.render=function(t,e,n,r){if(!1!==(e&&e.isCamera)){var o=t.fog;X="",W=-1,q=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld),xt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),ut.setFromMatrix(xt),R.length=0,N=-1,F=-1,B.length=0,U.length=0,gt=this.localClippingEnabled,pt=ft.init(this.clippingPlanes,gt,e),f(t,e),D.length=N+1,k.length=F+1,!0===V.sortObjects&&(D.sort(h),k.sort(u)),pt&&ft.beginShadows(),function(t){for(var e=0,i=0,n=t.length;i=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&$.readPixels(e,i,n,r,x(h),x(u),o)}finally{s&&$.bindFramebuffer($.FRAMEBUFFER,H)}}}}}function ee(t,e){this.name="",this.color=new dt(t),this.density=void 0!==e?e:25e-5}function ie(t,e,i){this.name="",this.color=new dt(t),this.near=void 0!==e?e:1,this.far=void 0!==i?i:1e3}function ne(){Dt.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function re(t,e,i,n,r){Dt.call(this),this.lensFlares=[],this.positionScreen=new A,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,i,n,r)}function oe(t){ut.call(this),this.type="SpriteMaterial",this.color=new dt(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function ae(t){Dt.call(this),this.type="Sprite",this.material=void 0!==t?t:new oe}function se(){Dt.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ce(t,e,i,n,r,o,a,s,c,h,u,l){_.call(this,null,o,a,s,c,h,n,r,u,l),this.image={data:t,width:e,height:i},this.magFilter=void 0!==c?c:Bh,this.minFilter=void 0!==h?h:Bh,this.flipY=!1,this.generateMipmaps=!1}function he(t,e,i){if(this.useVertexTexture=void 0===i||i,this.identityMatrix=new w,t=t||[],this.bones=t.slice(0),this.useVertexTexture){var n=Math.sqrt(4*this.bones.length);n=Du.nextPowerOfTwo(Math.ceil(n)),n=Math.max(n,4),this.boneTextureWidth=n,this.boneTextureHeight=n,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new ce(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,ou,Kh)}else this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{this.boneInverses=[];for(var r=0,o=this.bones.length;r0)&&S.push(M,P,T),(m!==i-1||s65535?function(t,e){return new Et(new Uint32Array(t),e)}:function(t,e){return new Et(new Uint16Array(t),e)})(S,1)),this.addAttribute("position",h),this.addAttribute("normal",u),this.addAttribute("uv",l),this.boundingSphere=new mt(new A,t)}function Pi(t,e,i,n,r,o,a){Nt.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new Mi(t,e,i,n,r,o,a))}function Ci(t,e){Dt.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.colors=[new dt,new dt];var i=new Pi(e,4,2);i.rotateX(-Math.PI/2);for(var n=0;n<8;n++)i.faces[n].color=this.colors[n<4?0:1];var r=new qt({vertexColors:Gc,wireframe:!0});this.lightSphere=new Yt(i,r),this.add(this.lightSphere),this.update()}function Ti(t,e,i,n){this.object=t,this.size=void 0!==e?e:1;var r=void 0!==i?i:16776960,o=void 0!==n?n:1,a=0,s=this.object.geometry;s&&s.isGeometry&&(a=s.faces.length);var c=new zt,h=new It(2*a*3,3);c.addAttribute("position",h),pe.call(this,c,new de({color:r,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function Ei(t,e){function i(t,e){return t-e}zt.call(this),e=void 0!==e?e:1;var n,r=Math.cos(Du.DEG2RAD*e),o=[0,0],a={},s=["a","b","c"];t&&t.isBufferGeometry?(n=new Nt).fromBufferGeometry(t):n=t.clone(),n.mergeVertices(),n.computeFaceNormals();for(var c=n.vertices,h=n.faces,u=0,l=h.length;u0&&u++,e>0&&u++);var l=function(){var t=(n+1)*(r+1);return!1===o&&(t+=(n+1)*u+n*u),t}(),d=function(){var t=n*r*2*3;return!1===o&&(t+=n*u*3),t}(),f=new Et(new(d>65535?Uint32Array:Uint16Array)(d),1),p=new Et(new Float32Array(3*l),3),m=new Et(new Float32Array(3*l),3),g=new Et(new Float32Array(2*l),2),v=0,y=0,b=[],_=i/2,w=0;(function(){var o,c,u=new A,l=new A,d=0,x=(e-t)/i;for(c=0;c<=r;c++){var S=[],M=c/r,P=M*(e-t)+t;for(o=0;o<=n;o++){var C=o/n;l.x=P*Math.sin(C*s+a),l.y=-M*i+_,l.z=P*Math.cos(C*s+a),p.setXYZ(v,l.x,l.y,l.z),u.copy(l),(0===t&&0===c||0===e&&c===r)&&(u.x=Math.sin(C*s+a),u.z=Math.cos(C*s+a)),u.setY(Math.sqrt(u.x*u.x+u.z*u.z)*x).normalize(),m.setXYZ(v,u.x,u.y,u.z),g.setXY(v,C,1-M),S.push(v),v++}b.push(S)}for(o=0;o0&&c(!0),e>0&&c(!1)),this.setIndex(f),this.addAttribute("position",p),this.addAttribute("normal",m),this.addAttribute("uv",g)}function Ni(t,e,i,n,r,o){Dt.call(this),void 0===n&&(n=16776960),void 0===i&&(i=1),void 0===r&&(r=.2*i),void 0===o&&(o=.2*r),this.position.copy(e),this.line=new fe(al,new de({color:n})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Yt(sl,new qt({color:n})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,r,o)}function ki(t,e,i,n){function r(t){var e=t.normalize().clone();e.index=h.vertices.push(e)-1;var i=s(t)/2/Math.PI+.5,n=function(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}(t)/Math.PI+.5;return e.uv=new x(i,1-n),e}function o(t,e,i){var n=new Lt(t.index,e.index,i.index,[t.clone(),e.clone(),i.clone()]);h.faces.push(n),y.copy(t).add(e).add(i).divideScalar(3);var r=s(y);h.faceVertexUvs[0].push([c(t.uv,t,r),c(e.uv,e,r),c(i.uv,i,r)])}function a(t,e){for(var i=Math.pow(2,e),n=r(h.vertices[t.a]),a=r(h.vertices[t.b]),s=r(h.vertices[t.c]),c=[],u=0;u<=i;u++){c[u]=[];for(var l=r(n.clone().lerp(s,u/i)),d=r(a.clone().lerp(s,u/i)),f=i-u,p=0;p<=f;p++)c[u][p]=0===p&&u===i?l:r(l.clone().lerp(d,p/f))}for(u=0;u.9&&P<.1&&(_<.2&&(b[0].x+=1),w<.2&&(b[1].x+=1),S<.2&&(b[2].x+=1))}for(u=0,l=this.vertices.length;u65535?Uint32Array:Uint16Array)(u),1),d=new Et(new Float32Array(3*h),3),f=new Et(new Float32Array(3*h),3),p=new Et(new Float32Array(2*h),2),m=0,g=0,v=new A,y=new A,b=new x,_=new A,w=new A,S=new A,M=new A,P=new A;for(s=0;s<=i;++s){var C=s/i*r*Math.PI*2;for(a(C,r,o,t,_),a(C+.01,r,o,t,w),M.subVectors(w,_),P.addVectors(w,_),S.crossVectors(M,P),P.crossVectors(S,M),S.normalize(),P.normalize(),c=0;c<=n;++c){var T=c/n*Math.PI*2,E=-e*Math.cos(T),I=e*Math.sin(T);v.x=_.x+(E*P.x+I*S.x),v.y=_.y+(E*P.y+I*S.y),v.z=_.z+(E*P.z+I*S.z),d.setXYZ(m,v.x,v.y,v.z),y.subVectors(v,_).normalize(),f.setXYZ(m,y.x,y.y,y.z),b.x=s/i,b.y=c/n,p.setXY(m,b.x,b.y),m++}}for(c=1;c<=i;c++)for(s=1;s<=n;s++){var L=(n+1)*(c-1)+(s-1),O=(n+1)*c+(s-1),R=(n+1)*c+s,D=(n+1)*(c-1)+s;l.setX(g,L),g++,l.setX(g,O),g++,l.setX(g,D),g++,l.setX(g,O),g++,l.setX(g,R),g++,l.setX(g,D),g++}this.setIndex(l),this.addAttribute("position",d),this.addAttribute("normal",f),this.addAttribute("uv",p)}function Bi(t,e,i,n,r){zt.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r},t=t||100,e=e||40,i=Math.floor(i)||8,n=Math.floor(n)||6,r=r||2*Math.PI;var o,a,s=(i+1)*(n+1),c=i*n*2*3,h=new(c>65535?Uint32Array:Uint16Array)(c),u=new Float32Array(3*s),l=new Float32Array(3*s),d=new Float32Array(2*s),f=0,p=0,m=0,g=new A,v=new A,y=new A;for(o=0;o<=i;o++)for(a=0;a<=n;a++){var b=a/n*r,x=o/i*Math.PI*2;v.x=(t+e*Math.cos(x))*Math.cos(b),v.y=(t+e*Math.cos(x))*Math.sin(b),v.z=e*Math.sin(x),u[f]=v.x,u[f+1]=v.y,u[f+2]=v.z,g.x=t*Math.cos(b),g.y=t*Math.sin(b),y.subVectors(v,g).normalize(),l[f]=y.x,l[f+1]=y.y,l[f+2]=y.z,d[p]=a/n,d[p+1]=o/i,f+=3,p+=2}for(o=1;o<=i;o++)for(a=1;a<=n;a++){var _=(n+1)*o+a-1,w=(n+1)*(o-1)+a-1,S=(n+1)*(o-1)+a,M=(n+1)*o+a;h[m]=_,h[m+1]=w,h[m+2]=M,h[m+3]=w,h[m+4]=S,h[m+5]=M,m+=6}this.setIndex(new Et(h,1)),this.addAttribute("position",new Et(u,3)),this.addAttribute("normal",new Et(l,3)),this.addAttribute("uv",new Et(d,2))}function Ui(t,e,i,n,r,o){zt.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:o},t=t||20,e=e||50,r=void 0!==r?r:0,o=void 0!==o?o:2*Math.PI;var a,s,c,h=((i=void 0!==i?Math.max(3,i):8)+1)*((n=void 0!==n?Math.max(1,n):1)+1),u=i*n*2*3,l=new Et(new(u>65535?Uint32Array:Uint16Array)(u),1),d=new Et(new Float32Array(3*h),3),f=new Et(new Float32Array(3*h),3),p=new Et(new Float32Array(2*h),2),m=0,g=0,v=t,y=(e-t)/n,b=new A,_=new x;for(s=0;s<=n;s++){for(c=0;c<=i;c++)a=r+c/i*o,b.x=v*Math.cos(a),b.y=v*Math.sin(a),d.setXYZ(m,b.x,b.y,b.z),f.setXYZ(m,0,0,1),_.x=(b.x/e+1)/2,_.y=(b.y/e+1)/2,p.setXY(m,_.x,_.y),m++;v+=y}for(s=0;s65535?Uint32Array:Uint16Array)(c),1),u=new Et(new Float32Array(3*s),3),l=new Et(new Float32Array(2*s),2),d=0,f=0,p=1/e,m=new A,g=new x;for(o=0;o<=e;o++){var v=i+o*p*n,y=Math.sin(v),b=Math.cos(v);for(a=0;a<=t.length-1;a++)m.x=t[a].x*y,m.y=t[a].y,m.z=t[a].x*b,u.setXYZ(d,m.x,m.y,m.z),g.x=o/e,g.y=a/(t.length-1),l.setXY(d,g.x,g.y),d++}for(o=0;o=0&&e<=7&&Wf[t]?Wf[t][e]:Array(e+1).join(t)}function Dn(){this.count=0,this.signals={countChanged:new qi}}function Nn(t){this.name=t||"",this.nextGid=1,this.objectList=[],this.rangeList=[]}function kn(){this.signals={updated:new qi},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 Fn(t,e){function i(t){!1!==d.enabled&&(g=m,m===f.NONE&&(t.keyCode!==d.keys[f.ROTATE]||d.noRotate?t.keyCode!==d.keys[f.ZOOM]||d.noZoom?t.keyCode!==d.keys[f.PAN]||d.noPan||(m=f.PAN):m=f.ZOOM:m=f.ROTATE))}function n(){!1!==d.enabled&&(m=g)}function r(t){!1!==d.enabled&&(m===f.NONE&&(m=t.button),m!==f.ROTATE||d.noRotate?m!==f.ZOOM||d.noZoom?m!==f.PAN||d.noPan||(E.copy(D(t.pageX,t.pageY)),I.copy(E)):(M.copy(D(t.pageX,t.pageY)),P.copy(M)):(b.copy(N(t.pageX,t.pageY)),y.copy(b)),document.addEventListener("mousemove",o,!1),document.addEventListener("mouseup",a,!1),d.dispatchEvent(O))}function o(t){!1!==d.enabled&&(m!==f.ROTATE||d.noRotate?m!==f.ZOOM||d.noZoom?m!==f.PAN||d.noPan||I.copy(D(t.pageX,t.pageY)):P.copy(D(t.pageX,t.pageY)):(y.copy(b),b.copy(N(t.pageX,t.pageY))))}function a(){!1!==d.enabled&&(m=f.NONE,document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a),d.dispatchEvent(R))}function s(t){if(!1!==d.enabled){var e;e=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail/3:-t.deltaY/(t.deltaMode?.33:30),M.y+=.01*e,d.dispatchEvent(O),d.dispatchEvent(R)}}function c(t){if(!1!==d.enabled){switch(t.touches.length){case 1:m=f.TOUCH_ROTATE,b.copy(N(t.touches[0].pageX,t.touches[0].pageY)),y.copy(b);break;default:m=f.TOUCH_ZOOM_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,i=t.touches[0].pageY-t.touches[1].pageY;T=C=Math.sqrt(e*e+i*i);var n=(t.touches[0].pageX+t.touches[1].pageX)/2,r=(t.touches[0].pageY+t.touches[1].pageY)/2;E.copy(D(n,r)),I.copy(E)}d.dispatchEvent(O)}}function h(t){if(!1!==d.enabled)switch(t.touches.length){case 1:y.copy(b),b.copy(N(t.touches[0].pageX,t.touches[0].pageY));break;default:var e=t.touches[0].pageX-t.touches[1].pageX,i=t.touches[0].pageY-t.touches[1].pageY;T=Math.sqrt(e*e+i*i);var n=(t.touches[0].pageX+t.touches[1].pageX)/2,r=(t.touches[0].pageY+t.touches[1].pageY)/2;I.copy(D(n,r))}}function u(t){if(!1!==d.enabled){switch(t.touches.length){case 0:m=f.NONE;break;case 1:m=f.TOUCH_ROTATE,b.copy(N(t.touches[0].pageX,t.touches[0].pageY)),y.copy(b)}d.dispatchEvent(R)}}function l(t){t.preventDefault()}var d=this,f={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=t,this.domElement=void 0!==e?e:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.keys=[65,83,68],this.target=new A;var p=new A,m=f.NONE,g=f.NONE,v=new A,y=new x,b=new x,_=new A,w=0,M=new x,P=new x,C=0,T=0,E=new x,I=new x;this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.up0=this.object.up.clone();var L={type:"change"},O={type:"start"},R={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var t=this.domElement.getBoundingClientRect(),e=this.domElement.ownerDocument.documentElement;this.screen.left=t.left+window.pageXOffset-e.clientLeft,this.screen.top=t.top+window.pageYOffset-e.clientTop,this.screen.width=t.width,this.screen.height=t.height}},this.handleEvent=function(t){"function"==typeof this[t.type]&&this[t.type](t)};var D=function(){var t=new x;return function(e,i){return t.set((e-d.screen.left)/d.screen.width,(i-d.screen.top)/d.screen.height),t}}(),N=function(){var t=new x;return function(e,i){return t.set((e-.5*d.screen.width-d.screen.left)/(.5*d.screen.width),(d.screen.height+2*(d.screen.top-i))/d.screen.width),t}}();this.rotateCamera=function(){var t,e=new A,i=new S,n=new A,r=new A,o=new A,a=new A;return function(){a.set(b.x-y.x,b.y-y.y,0),(t=a.length())?(v.copy(d.object.position).sub(d.target),n.copy(v).normalize(),r.copy(d.object.up).normalize(),o.crossVectors(r,n).normalize(),r.setLength(b.y-y.y),o.setLength(b.x-y.x),a.copy(r.add(o)),e.crossVectors(a,v).normalize(),t*=d.rotateSpeed,i.setFromAxisAngle(e,t),v.applyQuaternion(i),d.object.up.applyQuaternion(i),_.copy(e),w=t):!d.staticMoving&&w&&(w*=Math.sqrt(1-d.dynamicDampingFactor),v.copy(d.object.position).sub(d.target),i.setFromAxisAngle(_,w),v.applyQuaternion(i),d.object.up.applyQuaternion(i)),y.copy(b)}}(),this.zoomCamera=function(){var t;m===f.TOUCH_ZOOM_PAN?(t=C/T,C=T,v.multiplyScalar(t),void 0===d.object.fov&&(d.object.zoom*=t)):1!==(t=1+(P.y-M.y)*d.zoomSpeed)&&t>0&&(v.multiplyScalar(t),void 0===d.object.fov&&(d.object.zoom/=t),d.staticMoving?M.copy(P):M.y+=(P.y-M.y)*this.dynamicDampingFactor)},this.panCamera=function(){var t=new x,e=new A,i=new A;return function(){if(t.copy(I).sub(E),t.lengthSq()){if(void 0===d.object.fov){var n=(d.object.right-d.object.left)/d.object.zoom,r=(d.object.top-d.object.bottom)/d.object.zoom;t.x*=n,t.y*=r}else t.multiplyScalar(v.length()*d.panSpeed);i.copy(v).cross(d.object.up).setLength(t.x),i.add(e.copy(d.object.up).setLength(t.y)),d.object.position.add(i),d.target.add(i),d.staticMoving?E.copy(I):E.add(t.subVectors(I,E).multiplyScalar(d.dynamicDampingFactor))}}}(),this.checkDistances=function(){d.noZoom&&d.noPan||(v.lengthSq()>d.maxDistance*d.maxDistance&&(d.object.position.addVectors(d.target,v.setLength(d.maxDistance)),M.copy(P)),v.lengthSq()1e-6&&(d.dispatchEvent(L),p.copy(d.object.position))},this.reset=function(){m=f.NONE,g=f.NONE,d.target.copy(d.target0),d.object.position.copy(d.position0),d.object.up.copy(d.up0),v.subVectors(d.object.position,d.target),d.object.lookAt(d.target),d.dispatchEvent(L),p.copy(d.object.position)},this.dispose=function(){this.domElement.removeEventListener("contextmenu",l,!1),this.domElement.removeEventListener("mousedown",r,!1),this.domElement.removeEventListener("mousewheel",s,!1),this.domElement.removeEventListener("wheel",s,!1),this.domElement.removeEventListener("MozMousePixelScroll",s,!1),this.domElement.removeEventListener("touchstart",c,!1),this.domElement.removeEventListener("touchend",u,!1),this.domElement.removeEventListener("touchmove",h,!1),document.removeEventListener("mousemove",o,!1),document.removeEventListener("mouseup",a,!1),window.removeEventListener("keydown",i,!1),window.removeEventListener("keyup",n,!1)},this.domElement.addEventListener("contextmenu",l,!1),this.domElement.addEventListener("mousedown",r,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("wheel",s,!1),this.domElement.addEventListener("MozMousePixelScroll",s,!1),this.domElement.addEventListener("touchstart",c,!1),this.domElement.addEventListener("touchend",u,!1),this.domElement.addEventListener("touchmove",h,!1),window.addEventListener("keydown",i,!1),window.addEventListener("keyup",n,!1),this.handleResize(),this.update()}function zn(t,e){e=e||{};var i=t+"|";for(var n in e)i+=n+":"+e[n];if(!qf[i]){var r=function(t){if(void 0===t)return"";var e=[];for(var i in t){var n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")+"\n"}(e),o=Vf.get("shader/"+t);if(!o)throw"empty shader, '"+t+"'";o=o.replace(Xf,function(t,e){var i="shader/chunk/"+e+".glsl",n=Vf.get(i)||ju[e];return n||""}),qf[i]=r+o}return qf[i]}function Bn(t,e,i,n){function r(e){var n=e%s,r=Math.floor(e/s),o=n*f,a=r*p;i.camera.setViewOffset(f*s,p*s,o,a,f,p),i.render(),c?m.drawImage(t.domElement,Math.floor(o/2),Math.floor(a/2),Math.ceil(f/2),Math.ceil(p/2)):m.drawImage(t.domElement,Math.floor(o),Math.floor(a),Math.ceil(f),Math.ceil(p)),"function"==typeof h&&h(e+1,l,!1)}function o(){i.setSampling(g),i.camera.view=null,"function"==typeof u&&u(l+1,l,!1)}var a=n||{},s=void 0!==a.factor?a.factor:2,c=void 0!==a.antialias&&a.antialias,h=a.onProgress,u=a.onFinish;c&&(s*=2);var l=s*s,d=document.createElement("canvas"),f=i.width,p=i.height;c?(d.width=f*s/2,d.height=p*s/2):(d.width=f*s,d.height=p*s);var m=d.getContext("2d"),g=i.sampleLevel;i.setSampling(-1),this.render=function(){for(var t=0;t<=l;++t)t===l?o():r(t)},this.renderAsync=function(){function t(){e===l?o():r(e),e+=1}for(var e=0,i=0;i<=l;++i)setTimeout(t,0,i)},this.canvas=d}function Un(t,e,i,n,r){i=i||1,n=n||0;var o,a,s=r?r.length:t.length/i,c=0,h=0;if(r)for(a=0;a=0;a--){for(o=u-1;o>=0;o--)if(l[c=4*(a*u+o)]!==e||l[c+1]!==i||l[c+2]!==n||l[c+3]!==r){s=!0;break}if(s)break}var p=a;for(s=!1,o=u-1;o>=0;o--){for(a=h-1;a>=0;a--)if(l[c=4*(a*u+o)]!==e||l[c+1]!==i||l[c+2]!==n||l[c+3]!==r){s=!0;break}if(s)break}var m=o,g=document.createElement("canvas");return g.width=m-f,g.height=p-d,g.getContext("2d").drawImage(t,f,d,g.width,g.height,0,0,g.width,g.height),g}(t,0|(h?0:255*e.r),0|(h?0:255*e.g),0|(h?0:255*e.b),0|(h?0:255))}return t}function r(t,e,i){"function"==typeof o.onProgress&&o.onProgress(t,e,i)}var o=e||{},a=void 0!==o.trim&&o.trim,s=void 0!==o.factor?o.factor:1,c=void 0!==o.antialias&&o.antialias,h=void 0!==o.transparent&&o.transparent,u=t.renderer,l=t.camera,d=u.getClearAlpha(),f=u.getClearColor();return new Promise(function(e){var o=new Bn(u,l,t,{factor:s,antialias:c,onProgress:r,onFinish:function(a,s){n(o.canvas).toBlob(function(n){u.setClearAlpha(d),i(!0),t.requestRender(),r(s,s,!0),e(n)},"image/png")}});u.setClearAlpha(h?0:1),i(),o.renderAsync()})}function Xn(e){function i(){D||(D=new ne),(F=new ve).name="rotationGroup",D.add(F),(z=new ve).name="modelGroup",F.add(z),(B=new ve).name="pickingGroup",F.add(B),(U=new ve).name="backgroundGroup",F.add(U),($=new ve).name="helperGroup",F.add($),D.fog=new ie,N=new Ee(E.lightColor,E.lightIntensity),D.add(N),k=new Re(E.ambientLight,E.ambientIntensity),D.add(k)}function n(){var t=tt.geometry.attributes.position,e=t.array,i=et.min,n=et.max;e[0]=n.x,e[1]=n.y,e[2]=n.z,e[3]=i.x,e[4]=n.y,e[5]=n.z,e[6]=i.x,e[7]=i.y,e[8]=n.z,e[9]=n.x,e[10]=i.y,e[11]=n.z,e[12]=n.x,e[13]=n.y,e[14]=i.z,e[15]=i.x,e[16]=n.y,e[17]=i.z,e[18]=i.x,e[19]=i.y,e[20]=i.z,e[21]=n.x,e[22]=i.y,e[23]=i.z,t.needsUpdate=!0,et.isEmpty()||tt.geometry.computeBoundingSphere()}function r(t,e){function i(t){"Group"===t.type?t.children.forEach(function(t){t.userData.instance=e}):t.userData.instance=e}var n=t.getMesh();n.userData.buffer=t,e&&(n.applyMatrix(e.matrix),i(n)),t.group.add(n);var r=t.getWireframeMesh();if(r.userData.buffer=t,e&&(r.matrix.copy(n.matrix),r.position.copy(n.position),r.quaternion.copy(n.quaternion),r.scale.copy(n.scale),i(r)),t.wireframeGroup.add(r),t.pickable){var a=t.getPickingMesh();a.userData.buffer=t,e&&(a.matrix.copy(n.matrix),a.position.copy(n.position),a.quaternion.copy(n.quaternion),a.scale.copy(n.scale),i(a)),t.pickingGroup.add(a)}e?o(t.geometry,e.matrix):o(t.geometry)}function o(t,e){function i(t,e){var i;0!==t.attributes.position.count&&(t.boundingBox||t.computeBoundingBox(),e?(i=t.boundingBox.clone()).applyMatrix4(e):i=t.boundingBox,i.min.equals(i.max)&&i.expandByScalar(5),et.expandByPoint(i.min),et.expandByPoint(i.max))}function n(t){var e;void 0!==t.geometry&&(t.userData.instance&&(e=t.userData.instance.matrix),i(t.geometry,e))}t?Array.isArray(t)?t.forEach(function(t){i(t,e)}):i(t,e):(et.makeEmpty(),z.traverse(n),U.traverse(n)),et.size(it),nt=it.length(),K.maxDistance=10*nt}function a(t,e,i){var n=E;void 0!==t&&n.fogColor.set(t),void 0!==e&&(n.fogNear=e),void 0!==i&&(n.fogFar=i),u()}function s(t){var e=E;t&&e.backgroundColor.set(t),a(e.backgroundColor),V.setClearColor(e.backgroundColor,0),V.domElement.style.backgroundColor=e.backgroundColor.getStyle(),u()}function c(t,e){b=t||1,x=e||1,L.aspect=b/x,O.left=-b/2,O.right=b/2,O.top=x/2,O.bottom=-x/2,R.updateProjectionMatrix();var i=window.devicePixelRatio;V.setPixelRatio(i),V.setSize(b,x);var n=b*i,r=x*i;G.setSize(n,r),H.setSize(n,r),W.setSize(n,r),K.handleResize(),u()}function h(t){var e=ot.memory,i=ot.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 n=V.info,r=n.memory,o=n.render;e.programs=r.programs,e.geometries=r.geometries,e.textures=r.textures,i.calls+=o.calls,i.vertices+=o.vertices,i.faces+=o.faces,i.points+=o.points}}function u(){w||(performance.now()-I.startTime>22&&(I.begin(),P=!1),w=!0,requestAnimationFrame(function(){g(),I.update()}))}function l(){var t=E;(C=rt.copy(R.position).sub(K.target).length())||(R.position.set(0,0,t.cameraZ),C=Math.abs(t.cameraZ)),T=Math.max(10,.5*nt),((T+=et.center(rt).length())===1/0||T===-1/0||isNaN(T))&&(T=50);var e=(50-t.clipNear)/50,i=-(50-t.clipFar)/50;R.near=C-T*e,R.far=C+T*i;var n=(50-t.fogNear)/50,r=-(50-t.fogFar)/50,o=D.fog;o.color.set(t.fogColor),o.near=C-T*n,o.far=C+T*r,"PerspectiveCamera"===R.type?(R.near=Math.max(.1,t.clipDist,R.near),R.far=Math.max(1,R.far),o.near=Math.max(.1,o.near),o.far=Math.max(1,o.far)):"OrthographicCamera"===R.type&&0===t.clipNear&&t.clipDist>0&&C+R.zoom>2*-t.clipDist&&(R.near+=R.zoom+t.clipDist)}function d(){l();var t=Zi(L.fov),e=(R.near+R.far)/2,i=2*Math.tan(t/2)*e;O.zoom=x/i}function f(){var t,e,i,n,r,o,a,s;R.updateMatrix(),R.updateMatrixWorld(!0),R.matrixWorldInverse.getInverse(R.matrixWorld),R.updateProjectionMatrix(),t=D,e=R,n=C,r=T,o=(i=V).getSize().height,a=i.getPixelRatio(),s="OrthographicCamera"===e.type,Jf.getInverse(e.projectionMatrix),tp.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,h=n-r*c;i.nearClip.value=h}i.canvasHeight&&(i.canvasHeight.value=o),i.pixelRatio&&(i.pixelRatio.value=a),i.projectionMatrixInverse&&i.projectionMatrixInverse.value.copy(Jf),i.projectionMatrixTranspose&&i.projectionMatrixTranspose.value.copy(tp),i.ortho&&(i.ortho.value=s)}}}),function(t,e){var i;t.traverseVisible(function(t){if(t instanceof ge&&t.sortParticles){var n=t.geometry.attributes,r=n.position.count;if(0!==r){var o,a,s,c,h,u,l;for(Kf.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),Qf.multiplyMatrices(e.projectionMatrix,Kf),t.userData.sortData?(o=t.userData.sortData,s=o.__zArray,a=o.__sortArray,c=o.__cmpFn):(s=new Float32Array(r),a=new Uint32Array(r),o={__zArray:s,__sortArray:a,__cmpFn:c=function(t,e){var i=s[t],n=s[e];return i>n?1:ie?1:t=h&&e(t[o],l)>0;)t[o+1]=t[o],--o;t[o+1]=l}if(-1===c)break;u=s[c--],h=s[c--]}else{for(a=u,r(h+u>>1,o=h+1),e(t[h],t[u])>0&&r(h,u),e(t[o],t[u])>0&&r(o,u),e(t[h],t[o])>0&&r(h,o),l=t[o];;){do{o++}while(e(t[o],l)<0);do{a--}while(e(t[a],l)>0);if(a=a-h?(s[++c]=o,s[++c]=u,u=a-1):(s[++c]=h,s[++c]=a-1,h=o)}}(a,c),n){var f=n[d],p=f.array,m=f.itemSize;for(o[d]||(o[d]=new Float32Array(m*r)),l=o[d],o[d]=p,i=0;i0?function(){var t=ep[Math.max(0,Math.min(M,5))],e=1/t.length;X.tForeground.value=H.texture;for(var i=H.width,n=H.height,r=0;r500&&!P&&M<3&&-1!==M){var i=M;M=3,w=!0,g(),P=!0,M=i,t.Debug&&Nf.log("rendered still frame")}var n=E;n.spinAxis&&n.spinAngle&&(at(n.spinAxis,n.spinAngle*I.lastDuration/16),u()),requestAnimationFrame(e)},this.updateHelper=n,this.controls=K,this.renderer=V,this.scene=D,Object.defineProperties(this,{camera:{get:function(){return R}},width:{get:function(){return b}},height:{get:function(){return x}},sampleLevel:{get:function(){return M}}})}function qn(t,e){this.count=0,this.words=new Uint32Array(8),this.resize(t),e&&this.flip_all()}function Yn(t,e){this.type=t,this.scale=e||1,this.max=10}function Zn(t){var e,i=t.length,n=t.length/3,r=0,o=0,a=0;for(e=0;er&&(r=h),u>o&&(o=u),l>a&&(a=l)}return[ir([e,i,n]),ir([r,o,a])]}function Jn(t,e){for(var i=0,n=e.length;i(e=Math.abs(e))?(e/=t,t*Math.sqrt(1+e*e)):e>0?(t/=e,e*Math.sqrt(1+t*t)):0}function Sr(t,e,i,n){var r=0,o=0,a=t.rows,s=t.cols,c=a,h=s;c>16)?D:-D,t[u*e+d]=R;for(f=0;f<2;f++)for(l=0;l>r),u=1+(o.max.y-s>>r),l=1+(o.max.z-c>>r),d=h*u*l,f=t.count,p=t.x,m=t.y,g=t.z,v=0,y=new Uint32Array(d),b=new Int32Array(f);for(i=0;i>r,_=m[i]-s>>r,w=g[i]-c>>r,S=(x*u+_)*l+w;1===(y[S]+=1)&&(v+=1),b[i]=S}var A=new Uint16Array(v);for(i=0,n=0;i0&&(y[i]=n+1,A[n]=M,n+=1)}var P=new Uint32Array(v);for(i=1;i0){var I=E-1;T[P[I]+C[I]]=i,C[I]+=1}}this.within=function(t,e,i,n){for(var o=n*n,d=Math.max(0,t-n-a>>r),f=Math.max(0,e-n-s>>r),v=Math.max(0,i-n-c>>r),b=Math.min(h,t+n-a>>r),x=Math.min(u,e+n-s>>r),_=Math.min(l,i+n-c>>r),w=[],S=d;S<=b;++S)for(var M=f;M<=x;++M)for(var C=v;C<=_;++C){var E=y[(S*u+M)*l+C];if(E>0)for(var I=E-1,L=P[I],O=L+A[I],R=L;Rn&&(n=i);var l=u-h;if(0===l)return-1;var d=4*s;if(s+=1,1===l)return a[d]=h,a[d+1]=-1,a[d+2]=-1,a[d+3]=o,d;var f=h+Math.floor(l/2);c=i%3;for(var p,m,g,v,y,b=h,x=u-1;x>b;){for(v=t[3*r[g=b+x>>1]+c],m=r[g],r[g]=r[x],r[x]=m,y=b,p=b;pn&&s.pop()}var l,d,f=function t(e){var i=a[e+3];return-1===i?0:t(i)+1}(h)%3,p=3*r[a[h]],m=[t[p+0],t[p+1],t[p+2]],g=e(i,m),v=a[h+1],y=a[h+2];if(-1!==y||-1!==v){c(l=-1===y?v:-1===v?y:i[f]<=t[p+f]?v:y),(s.size()t[3*r[a[i]]+s])throw"left child is > parent!";o+=e(c,n+1)}if(-1!==u){if(t[3*r[a[u]]+s]0&&(e=":"+p(t).join(" OR :")),new Yi(e)}function Wr(t){this.name=t||"",this.partList=[]}function Xr(t,e){this.matrixList=t||[],this.chainList=e||[]}function qr(e,i){if(i){t.Debug&&Nf.time("assignSecondaryStructure");var n=[];e.eachModel(function(t){t.eachChain(function(t){n.push(t.chainname)})});var r=n.slice().sort(),o=[];r.forEach(function(t){o.push(n.indexOf(t))});var a=i.helices;(a=a.filter(function(t){return Lc(r,t[0])>=0})).sort(function(t,e){var i=t[0],n=e[0],a=t[1],s=e[1];if(i===n)return a===s?0:a=0})).sort(function(t,e){var i=t[0],n=e[0];if(i===n)return 0;var a=Lc(r,i),s=Lc(r,n);return o[a]=r;)e=Math.floor(e/r),o+=n[e%r],i+=1;return i>=5&&Nf.warn("chainname overflow"),o},h=e.getAtomProxy(),u=e.getAtomProxy(),l=0,d=0,f=0,p=0,m=[];1===s.count?m.push({mIndex:0,chainname:"A",rStart:0,rCount:1}):e.eachResidueN(2,function(t,e){var i=!1,n=t.backboneType,r=e.backboneType,o=Dl;p=t.index,t.modelIndex!==e.modelIndex?i=!0:t.moleculeType!==e.moleculeType?i=!0:n!==o&&n===r&&(h.index=t.backboneEndAtomIndex,u.index=e.backboneStartAtomIndex,h.connectedTo(u)||(i=!0)),i||e.index!==s.count-1||(i=!0,p=e.index),i&&(m.push({mIndex:d,chainname:c(l),rStart:f,rCount:p-f+1}),l+=1,t.modelIndex!==e.modelIndex&&(l=0,d+=1),e.index===s.count-1&&p!==e.index&&m.push({mIndex:d,chainname:c(l),rStart:s.count-1,rCount:1}),f=e.index,p=e.index)}),a.count=0,m.forEach(function(t){!function(t,e,i,n){for(var r=a.count,c=0;c500)){var c,h,u=[],l=[],d=[];if(o>50){var f=new Gr(e,!0),p=e.isCg()?1.2:2.3;for(c=a;c500)return void Nf.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());for(var l=t.getBonds(),d=l.atomIndices1,f=l.atomIndices2,p=l.bondOrders,m=d.length,g=0;g1&&(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),h.setPosition(c),h.multiplyMatrices(n.fracToCart,h),h.multiply(n.cartToFrac),e.push(h)}),e}if(e.unitcell){t.Debug&&Nf.time("buildUnitcellAssembly");var n=e.unitcell,r=e.center.clone().applyMatrix4(n.cartToFrac),o=function(t){var e=cp[t],i={};if(void 0===e)return i;for(var n=[],r=0,o=e.length;r1&&(a.x-=1),r.x<0&&(a.x+=1),r.y>1&&(a.y-=1),r.y<0&&(a.y+=1),r.z>1&&(a.z-=1),r.z<0&&(a.z+=1);var h,u=new Wr("UNITCELL"),l=i();if(e.biomolDict.NCS){h=[new w].concat(e.biomolDict.NCS.partList[0].matrixList);var d=[];l.forEach(function(t){h.forEach(function(e){d.push(t.clone().multiply(e))})}),u.addPart(d)}else u.addPart(l);var f=new A,p=new Wr("SUPERCELL"),m=Array.prototype.concat.call(i(),i(f.set(1,1,1)),i(f.set(-1,-1,-1)),i(f.set(1,0,0)),i(f.set(1,1,0)),i(f.set(1,0,1)),i(f.set(0,1,0)),i(f.set(0,1,1)),i(f.set(0,0,1)),i(f.set(-1,0,0)),i(f.set(-1,-1,0)),i(f.set(-1,0,-1)),i(f.set(0,-1,0)),i(f.set(0,-1,-1)),i(f.set(0,0,-1)),i(f.set(1,-1,-1)),i(f.set(1,1,-1)),i(f.set(1,-1,1)),i(f.set(-1,1,1)),i(f.set(-1,-1,1)),i(f.set(-1,1,-1)),i(f.set(0,1,-1)),i(f.set(0,-1,1)),i(f.set(1,0,-1)),i(f.set(-1,0,1)),i(f.set(1,-1,0)),i(f.set(-1,1,0)));if(e.biomolDict.NCS){var g=[];m.forEach(function(t){h.forEach(function(e){g.push(t.clone().multiply(e))})}),p.addPart(g)}else p.addPart(m);e.biomolDict.UNITCELL=u,e.biomolDict.SUPERCELL=p,t.Debug&&Nf.timeEnd("buildUnitcellAssembly")}}function eo(t){var e=t.bondHash,i=e.countArray,n=e.offsetArray,r=e.indexArray,o=t.getBondProxy();t.eachResidue(function(t){var e=t.residueType;if(void 0===e.bonds){var a=t.atomOffset,s=[],c=[],h=[],u={};t.eachAtom(function(t){for(var e=t.index,l=n[e],d=0,f=i[e];dm){var g=m;m=p,p=g}var v=p+"|"+m;void 0===u[v]&&(u[v]=!0,s.push(p-a),c.push(m-a),h.push(o.bondOrder))}}),e.bonds={atomIndices1:s,atomIndices2:c,bondOrders:h}}})}function io(t,e,i){this.structure=t,i=i||up(e),this.atomname=e,this.element=i,this.vdw=Ul[i],this.covalent=$l[i]}function no(t,e,i,n,r,o){this.structure=t,this.resname=e,this.atomTypeIdList=i,this.hetero=n?1:0,this.chemCompType=r,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=td[this.backboneType],s=td[this.backboneStartType],c=td[this.backboneEndType],h=this.getAtomIndexByName(a.trace);this.traceAtomIndex=void 0!==h?h:-1;var u=this.getAtomIndexByName(a.direction1);this.direction1AtomIndex=void 0!==u?u:-1;var l=this.getAtomIndexByName(a.direction2);this.direction2AtomIndex=void 0!==l?l:-1;var d=this.getAtomIndexByName(s.backboneStart);this.backboneStartAtomIndex=void 0!==d?d:-1;var f,p=this.getAtomIndexByName(c.backboneEnd);this.backboneEndAtomIndex=void 0!==p?p:-1,f=ql.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=void 0!==f?f:-1,this.bondReferenceAtomIndices=[]}function ro(t,e){this.structure=t,this.bondStore=t.bondStore,this.index=e,this._v12=new A,this._v13=new A,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}function oo(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.bondHash=t.bondHash,this.index=e}function ao(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}function so(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 n=this.structure.getResidueProxy(this.residueIndexStart),r=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==n.getPreviousConnectedResidue();var o=r.getNextConnectedResidue();this.isNextConnected=void 0!==o,this.isNextNextConnected=this.isNextConnected&&void 0!==o.getNextConnectedResidue(),this.isCyclic=r.connectedTo(n),this.__residueProxy=this.structure.getResidueProxy()}function co(t,e){this.structure=t,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e,this.__residueProxy=this.structure.getResidueProxy()}function ho(t,e){this.structure=t,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.index=e}function uo(t,e){this.signals={refreshed:new qi},this.name=t,this.path=e,this.title="",this.id="",this.header={},this.atomSetCache=void 0,this.atomSetDict={},this.biomolDict={},this.entityList=[],this.unitcell=void 0,this.frames=[],this.boxes=[],this.bondStore=new Nr(0),this.backboneBondStore=new Nr(0),this.rungBondStore=new Nr(0),this.atomStore=new kr(0),this.residueStore=new Fr(0),this.chainStore=new zr(0),this.modelStore=new Br(0),this.atomMap=new function(t){var e={},i=[];this.add=function(n,r){var o=function(t,e){return t+"|"+e}(n,r=r||up(n)),a=e[o];if(void 0===a){var s=new io(t,n,r);a=i.length,e[o]=a,i.push(s)}return a},this.get=function(t){return i[t]},this.list=i,this.dict=e,this.toJSON=function(){return{metadata:{version:.1,type:"AtomMap",generator:"AtomMapExporter"},idDict:e,typeList:i.map(function(t){return t.toJSON()})}},this.fromJSON=function(n){e=n.idDict,i=n.typeList.map(function(e){return new io(t,e.atomname,e.element)}),this.list=i,this.dict=e}}(this),this.residueMap=new function(t){var e={},i=[];this.add=function(n,r,o,a,s){var c=function(t,e,i,n){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+(n||"")}(n=n.toUpperCase(),r,o,a),h=e[c];if(void 0===h){var u=new no(t,n,r,o,a,s);h=i.length,e[c]=h,i.push(u)}return h},this.get=function(t){return i[t]},this.list=i,this.dict=e}(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()}function lo(t,e,i){this.name=t,this.path=e,this.info={},this.center=new A,this.boundingBox=new pt,i instanceof Nt||i instanceof zt||i instanceof ve?this.fromGeometry(i):i&&this.set(i.position,i.index,i.normal,i.color,i.atomindex,i.contour)}function fo(e){var i=0,n=0,r={},o={},a=URL.createObjectURL(Ff.get(e)),s=new window.Worker(a);Ff.activeWorkerCount+=1,s.onmessage=function(n){i-=1;var a=n.data.__postId;t.Debug&&Nf.timeEnd("Worker.postMessage "+e+" #"+a),r[a]&&r[a].call(s,n),delete r[a],delete o[a]},s.onerror=function(t){if(i-=1,t.data){var n=t.data.__postId;o[n]?o[n].call(s,t):Nf.error("Worker.onerror",n,e,t),delete r[n],delete o[n]}else Nf.error("Worker.onerror",e,t)},this.name=e,this.post=function(a,c,h,u){r[n]=h,o[n]=u,(a=a||{}).__name=e,a.__postId=n,a.__debug=t.Debug,t.Debug&&Nf.time("Worker.postMessage "+e+" #"+n);try{s.postMessage(a,c)}catch(t){Nf.error("worker.post:",t),s.postMessage(a)}return i+=1,n+=1,this},this.terminate=function(){s?(s.terminate(),URL.revokeObjectURL(a),Ff.activeWorkerCount-=1):Nf.log("no worker to terminate")},Object.defineProperties(this,{postCount:{get:function(){return n}},pending:{get:function(){return i}}})}function po(t,e){e=Math.min(8,e||2);var i=[],n=0;this.name=t,this.maxCount=e,this.post=function(t,e,i,n){return this.getNextWorker().post(t,e,i,n),this},this.terminate=function(){i.forEach(function(t){t.terminate()})},this.getNextWorker=function(){for(var r,o=1/0,a=0;a=n){r=new fo(t),i.push(r),n+=1;break}var s=i[a];if(0===s.pending){o=s.pending,r=s;break}s.pending=g){O=m,E=!0;break}if(E)break}if(E)break}for(E=!1,p=o;p=g){L=p,E=!0;break}if(E)break}if(E)break}for(E=!1,d=r;d=g){I=d,E=!0;break}if(E)break}if(E)break}for(E=!1,m=h;m>=a;--m){for(p=c;p>=o;--p){for(d=s;d>=r;--d)if(t[l=e*i*m+e*p+d]>=g){N=m,E=!0;break}if(E)break}if(E)break}for(E=!1,p=c;p>=o;--p){for(m=N;m>=a;--m){for(d=s;d>=r;--d)if(t[l=e*i*m+e*p+d]>=g){D=p,E=!0;break}if(E)break}if(E)break}for(E=!1,d=s;d>=r;--d){for(p=D;p>=o;--p){for(m=N;m>=a;--m)if(t[l=e*i*m+e*p+d]>=g){R=d,E=!0;break}if(E)break}if(E)break}v?(r=Math.max(0,I-1),o=Math.max(0,L-1),a=Math.max(0,O-1),s=Math.min(e-1,R+1),c=Math.min(i-1,D+1),h=Math.min(n-1,N+1)):(r=Math.max(1,I-1),o=Math.max(1,L-1),a=Math.max(1,O-1),s=Math.min(e-2,R+1),c=Math.min(i-2,D+1),h=Math.min(n-2,N+1));var k=15;for(m=a;m65535?Uint32Array:Uint16Array;return{position:new Float32Array(S),normal:v?void 0:new Float32Array(A),index:new s(M),atomindex:r?new Int32Array(P):void 0,contour:y}}}function bo(t,e,i,n){i=i||1,n=n||!0;var r,o=t.length/3,a=e.length/3;n&&(r=new Float32Array(3*o));var s,c,h,u,l=new Float32Array(3*o),d=new Array(20);for(s=0;s<20;++s)d[s]=new Uint32Array(o);for(s=0;s65535?Uint32Array:Uint16Array)(3*r),a=0;a65535?Uint32Array:Uint16Array;this.meshIndex=new h(c*o*3),this.makeIndex(),Io.call(this,this.meshPosition,this.meshColor,this.meshIndex,this.meshNormal,this.meshPickingColor,a),this.initNormals=!0,this.setAttributes({position:t,color:e,pickingColor:i}),this.initNormals=!1}function Oo(t,e,i,n,r){var o=r||{},a=h(o.sphereDetail,1);this.geo=new Fi(1,a),this._radius=i,Lo.call(this,t,e,n,o)}function Ro(t){this.size=this.count,this.attributeSize=this.count*this.mappingSize;var e=this.count*this.mappingIndicesSize,i=this.attributeSize>65535?Uint32Array:Uint16Array;this.index=new i(e),this.makeIndex(),Eo.call(this,null,null,this.index,null,t),this.addAttributes({mapping:{type:this.mappingType,value:null}})}function Do(t){this.mapping=new Float32Array([-1,1,-1,-1,1,1,1,-1]),this.mappingIndices=new Uint16Array([0,1,2,1,3,2]),this.mappingIndicesSize=6,this.mappingType="v2",this.mappingSize=4,this.mappingItemSize=2,Ro.call(this,t)}function No(t,e,i,n,r){this.impostor=!0,this.count=t.length/3,this.vertexShader="SphereImpostor.vert",this.fragmentShader="SphereImpostor.frag",Do.call(this,r),this.addUniforms({projectionMatrixInverse:{value:new w},ortho:{value:0}}),this.addAttributes({radius:{type:"f",value:null}}),this.setAttributes({position:t,color:e,radius:i}),n&&(this.addAttributes({pickingColor:{type:"c",value:null}}),this.setAttributes({pickingColor:n}),this.pickable=!0),this.makeMapping()}function ko(t,e,i,n,r){return!Df||(r||{}).disableImpostor?new Oo(t,e,i,n,r):new No(t,e,i,n,r)}function Fo(t,e,i,n,r,o,a){var s=a||{},c=h(s.sphereDetail,2);this.updateNormals=!0,this.geo=new Fi(1,c),this._radius=i,this._majorAxis=n,this._minorAxis=r,Lo.call(this,t,e,o,s)}function zo(t,e,i,n,r,o,a){return new Fo(t,e,i,n,r,o,a)}function Bo(t,e,i,n,r,o,a,s){var c=s||{},u=h(c.radialSegments,10),l=h(c.openEnded,!0);this.updateNormals=!0;var d=(new w).makeRotationX(Math.PI/2);this.geo=new Di(1,1,1,u,1,l),this.geo.applyMatrix(d);var f=t.length,p=r.length;this._position=new Float32Array(2*f),this._color=new Float32Array(2*f),this._pickingColor=new Float32Array(2*f),this._from=new Float32Array(2*f),this._to=new Float32Array(2*f),this._radius=new Float32Array(2*p),this.__center=new Float32Array(f),Lo.call(this,this._position,this._color,this._pickingColor,c),this.setAttributes({position1:t,position2:e,color:i,color2:n,radius:r,pickingColor:o,pickingColor2:a})}function Uo(t){this.mapping=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),this.mappingIndices=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]),this.mappingIndicesSize=12,this.mappingType="v3",this.mappingSize=6,this.mappingItemSize=3,Ro.call(this,t)}function $o(t,e,i,n,r,o,a,s){var c=s||{};this.openEnded=h(c.openEnded,!1),this.impostor=!0,this.count=t.length/3,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",Uo.call(this,c);var u=new xi(new w).onUpdate(function(t){this.value.getInverse(t.modelViewMatrix)});this.addUniforms({modelViewMatrixInverse:u,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({position1:t,position2:e,color:i,color2:n,radius:r}),o&&(this.addAttributes({pickingColor:{type:"c",value:null},pickingColor2:{type:"c",value:null}}),this.setAttributes({pickingColor:o,pickingColor2:a}),this.pickable=!0),this.makeMapping()}function Vo(t,e,i,n,r,o,a,s){return!Df||(s||{}).disableImpostor?new Bo(t,e,i,n,r,o,a,s):new $o(t,e,i,n,r,o,a,s)}function jo(t,e,i,n,r,o){var a=o||{},s=h(a.radialSegments,60),c=h(a.openEnded,!1);this.updateNormals=!0;var u=(new w).makeRotationX(-Math.PI/2);this.geo=new Gi(1,1,s,1,c),this.geo.applyMatrix(u);var l=t.length,d=n.length;this._position=new Float32Array(l),this._from=new Float32Array(l),this._to=new Float32Array(l),this._radius=new Float32Array(d),Lo.call(this,this._position,i,r,a),this.setAttributes({position1:t,position2:e,color:i,radius:n,pickingColor:r})}function Go(t,e,i,n,r,o){return new jo(t,e,i,n,r,o)}function Ho(t,e,i,n,r,o){function a(t){var e,i,n={};if(t.radius){for(e=0,i=p.length;e65535?Uint32Array:Uint16Array)(i)),Array.isArray(n)&&(n=new Float32Array(n));var r=new Io(t,e,i,n);p.push(r),f.setFromArray(t),l.union(f)},this.addSphere=function(t,e,n){i(t,m),i(e,g),v.push(n),l.expandByPoint(d.fromArray(t))},this.addEllipsoid=function(t,e,n,r,o){i(t,y),i(e,b),x.push(n),i(r,_),i(o,w),l.expandByPoint(d.fromArray(t))},this.addCylinder=function(t,e,n,r){i(t,S),i(e,M),i(n,P),C.push(r),l.expandByPoint(d.fromArray(t)),l.expandByPoint(d.fromArray(e))},this.addCone=function(t,e,n,r){i(t,T),i(e,E),i(n,I),L.push(r),l.expandByPoint(d.fromArray(t)),l.expandByPoint(d.fromArray(e))},this.addArrow=function(t,e,n,r){i(t,O),i(e,R),i(n,D),N.push(r),l.expandByPoint(d.fromArray(t)),l.expandByPoint(d.fromArray(e))},this.getBufferList=function(){var t=[];if(m.length){var e=new ko(new Float32Array(m),new Float32Array(g),new Float32Array(v),void 0,{sphereDetail:o,disableImpostor:s});t.push(e)}if(y.length){var i=new zo(new Float32Array(y),new Float32Array(b),new Float32Array(x),new Float32Array(_),new Float32Array(w),void 0,{sphereDetail:o,disableImpostor:s});t.push(i)}if(S.length){var n=new Vo(new Float32Array(S),new Float32Array(M),new Float32Array(P),new Float32Array(P),new Float32Array(C),void 0,void 0,{radialSegments:a,disableImpostor:s,openEnded:c});t.push(n)}if(T.length){var h=new Go(new Float32Array(T),new Float32Array(E),new Float32Array(I),new Float32Array(L),void 0,{radialSegments:a,disableImpostor:s,openEnded:c});t.push(h)}if(O.length){var u=new Ho(new Float32Array(O),new Float32Array(R),new Float32Array(D),new Float32Array(N),void 0,{aspectRatio:r,radialSegments:a,disableImpostor:s,openEnded:c});t.push(u)}return p.concat(t)},this.dispose=function(){p.forEach(function(t){t.dispose()}),p.length=0,m.length=0,g.length=0,v.length=0,y.length=0,b.length=0,x.length=0,_.length=0,w.length=0,S.length=0,M.length=0,P.length=0,C.length=0,T.length=0,E.length=0,I.length=0,L.length=0,O.length=0,R.length=0,D.length=0,N.length=0}}function Xo(t,e,i){this.viewer=e,this.gidPool=i?i.gidPool:void 0,this.tasks=new Dn,this.queue=new Mo(this.make.bind(this)),this.bufferList=[],this.init(i)}function qo(t,e,i){Array.isArray(t)||(t=[t]),Xo.call(this,t,e,i),this.buffer=t,this.build()}function Yo(){Io.apply(this,arguments)}function Zo(t){this.size=t.size,this.side=t.side,this.wireframe=t.wireframe,this.visible=t.visible,this.geometry=t.geometry,this.pickable=t.pickable,this.background=t.background,this.group=new ve,this.wireframeGroup=new ve,this.pickingGroup=new ve;var e=[],i=[],n=t,r=new t.constructor;n.makeMaterial(),r.makeMaterial(),r.geometry=t.geometry,r.wireframeGeometry=t.wireframeGeometry,r.size=t.size,r.attributeSize=t.attributeSize,r.pickable=t.pickable,r.setParameters(t.getParameters()),r.updateShader(),n.setParameters({side:"front"}),r.setParameters({side:"back",opacity:r.opacity}),this.getMesh=function(t){var o,a;return t?(a=r.getPickingMesh(),o=n.getPickingMesh()):(a=r.getMesh(),o=n.getMesh()),e.push(o),i.push(a),this.setParameters({side:this.side}),(new ve).add(a,o)},this.getWireframeMesh=function(){return t.getWireframeMesh()},this.getPickingMesh=function(){return this.getMesh(!0)},this.setAttributes=function(e){t.setAttributes(e)},this.setParameters=function(t){"front"===(t=Object.assign({},t)).side?(e.forEach(function(t){t.visible=!0}),i.forEach(function(t){t.visible=!1})):"back"===t.side?(e.forEach(function(t){t.visible=!1}),i.forEach(function(t){t.visible=!0})):"double"===t.side&&(e.forEach(function(t){t.visible=!0}),i.forEach(function(t){t.visible=!0})),void 0!==t.side&&(this.side=t.side),delete t.side,n.setParameters(t),void 0!==t.wireframe&&(this.wireframe=t.wireframe,this.setVisibility(this.visible)),delete t.wireframe,r.setParameters(t)},this.setVisibility=Eo.prototype.setVisibility,this.dispose=function(){n.dispose(),r.dispose()}}function Ko(t,e,i){Xo.call(this,t,e,i),t instanceof Ao?(this.surface=void 0,this.volume=t):(this.surface=t,this.volume=void 0),this.boxCenter=new A,this.__boxCenter=new A,this.box=new pt,this.__box=new pt,this.setBox=function(){var t=new A;return function(){var i=e.controls.target,n=e.rotationGroup.position;t.copy(n).negate().add(i),t.equals(this.boxCenter)||this.setParameters({boxCenter:t})}.bind(this)}.bind(this)(),this.viewer.signals.orientationChanged.add(this.setBox),this.build()}function Qo(t){function e(t,e,i,n){var r=i-t,o=n-e;return Math.sqrt(r*r+o*o)}function i(t,e,i){return(i=function(t,e,i){return Math.min(Math.max(t,e),i)}((i-t)/(e-t),0,1))*i*(3-2*i)}for(var n=Object.assign({},t),r=h(n.width,256),o=h(n.height,256),a=[r/2,o/2],s=Math.min(r/2,o/2),c=h(n.delta,1/(s+1))*s,u=0,l=0,d=new Uint8Array(r*o*4),f=0,p=d.length;f1&&(l=1),r(e,i,n,o,u,p),r(e,i,n,o,l,m),m.sub(p).normalize(),m.toArray(a,g)}}function s(e,i,n,r,o){for(var a=i.next(),s=i.next(),c=i.next(),h=i.size,u=h-1,l=r||0,d=0;d65535?Uint32Array:Uint16Array;this.meshIndex=new p(f),this.makeIndex(),Io.call(this,this.meshPosition,this.meshColor,this.meshIndex,this.meshNormal,this.meshPickingColor,c),this.setAttributes({position:t,normal:e,binormal:i,tangent:n,color:r,size:o,pickingColor:a})}function Da(t,e,i){na.call(this,t,e,i)}function Na(t,e){this.sview1=t,this.sview2=e,this.kdtree2=new Gr(e)}function ka(t,e,i){e=e||3.5,i=i||40;for(var n=new Yi("( 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 )"),r=new Yi("( 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=new Na(t.getView(n),t.getView(r)).within(e),a=o.bondStore,s=t.getAtomProxy(),c=t.getAtomProxy(),h=t.getAtomProxy(),u=t.getAtomProxy(),l=t.getResidueProxy(),d=t.getResidueProxy(),f=new A,p=new A,m=function(t,e,n,r){var o,a;t.atomname===n?(o=t,a=e):(o=e,a=t),l.index=o.residueIndex;var s=l.getAtomIndexByName(r);return f.subVectors(s,o),p.subVectors(s,a),Ki(f.angleTo(p))i&&o.bondSet.flip_unsafe(g)}else("OH"===s.atomname&&"TYR"===s.resname||"OH"===c.atomname&&"TYR"===c.resname)&&(m(s,c,"OH","CZ")||o.bondSet.flip_unsafe(g));return{atomSet:o.atomSet,bondSet:o.bondSet,bondStore:o.bondStore}}function Fa(t,e,i){e=e||3.5,i=i||40;for(var n=new Yi("( PROTEIN and .N )"),r=new Yi("( PROTEIN and .O )"),o=new Na(t.getView(n),t.getView(r)).within(e),a=o.bondStore,s=t.getAtomProxy(),c=t.getAtomProxy(),h=t.getAtomProxy(),u=t.getAtomProxy(),l=t.getResidueProxy(),d=t.getResidueProxy(),f=new A,p=new A,m=0,g=a.count;mi&&o.bondSet.flip_unsafe(m)))}}return{atomSet:o.atomSet,bondSet:o.bondSet,bondStore:o.bondStore}}function za(t,e,i){na.call(this,t,e,i)}function Ba(t){var e=Object.assign({},t);if(this.font=h(e.font,["sans-serif"]),this.size=h(e.size,36),this.style=h(e.style,"normal"),this.variant=h(e.variant,"normal"),this.weight=h(e.weight,"normal"),this.outline=h(e.outline,0),this.width=h(e.width,1024),this.height=h(e.height,1024),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 be(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}function Ua(t,e,i,n,r){var o=r||{};o.forceTransparent=!0,this.fontFamily=h(o.fontFamily,"sans-serif"),this.fontStyle=h(o.fontStyle,"normal"),this.fontWeight=h(o.fontWeight,"bold"),this.fontSize=h(o.fontSize,48),this.sdf=h(o.sdf,"Chrome"===Lf),this.xOffset=h(o.xOffset,0),this.yOffset=h(o.yOffset,0),this.zOffset=h(o.zOffset,.5),this.attachment=h(o.attachment,"bottom-left"),this.showBorder=h(o.showBorder,!1),this.borderColor=h(o.borderColor,"lightgrey"),this.borderWidth=h(o.borderWidth,.15),this.showBackground=h(o.showBackground,!1),this.backgroundColor=h(o.backgroundColor,"lightgrey"),this.backgroundMargin=h(o.backgroundMargin,.5),this.backgroundOpacity=h(o.backgroundOpacity,1);for(var a=t.length/3,s=0,c=0;ca?h[u]=-1:(o=Math.sqrt(a-r),h[u]=Math.floor(o)),++u;w[d]=c,_[d]=h}}function o(i){var n,r,o,a,s,c,h,u,l,d,f,m,b,S,P,T,E,L,O=3*i,R=i;n=Math.floor(.5+p*(t[O]+x[0])),r=Math.floor(.5+p*(t[O+1]+x[1])),o=Math.floor(.5+p*(t[O+2]+x[2]));var D,N=e[R],k=_[N],F=0,z=v*y,B=w[N];for(d=0;d=g||S>=v||P>=y)){var U=b*z+S*y+P;if(A)if(M[U]&I){if(M[U]&I){var $=C[U];$!==O&&(h*h+u*u+l*l<(a=n+h-Math.floor(.5+p*(t[$]+x[0])))*a+(s=r+u-Math.floor(.5+p*(t[$+1]+x[1])))*s+(c=o+l-Math.floor(.5+p*(t[$+2]+x[2])))*c&&(C[U]=i))}}else M[U]|=I,C[U]=i;else M[U]|=I}F++}}function a(e){var i,n;for(i=0,n=M.length;i=g||f>=v||m>=y)){var z=d*F+f*y+m;if(M[z]&L){if(A){var B=C[z];h*h+u*u+l*l<(a=Math.floor(.5+p*(t[B]+x[0])))*a+(s=Math.floor(.5+p*(t[B+1]+x[1])))*s+(c=Math.floor(.5+p*(t[B+2]+x[2])))*c&&(C[z]=i)}}else M[z]|=L,A&&(C[z]=i)}N++}}function c(){var e,i;for(e=0,i=M.length;e0);var p,b=m*m,x=new Uint16Array(3);for(t=0;t=b)||(M[r]|=O,A&&M[r]&L&&(o.toArray(t,e,i,x),p=x[0]*a+x[1]*y+x[2],C[r]=C[p])))}function u(t,e,i,n){var r,o,a,s,c,h,u,l,d,f,p,m,b=new Uint16Array(3),x=0;if(0===i)return x;var _=-1,w=-1,S=-1,A=v*y;for(u=0,d=i;u-1&&w-1&&S-1&&(M[p=_*A+y*w+S]&I&&!(M[p]&L)?(e.fromArray(_,w,S,b),f=(s=_-b[0])*s+(c=w-b[1])*c+(h=S-b[2])*h,P[p]=f,M[p]|=L,M[p]|=O,n[x]=_,n[x+1]=w,n[x+2]=S,x+=3):M[p]&I&&M[p]&L&&((f=(s=_-b[0])*s+(c=w-b[1])*c+(h=S-b[2])*h)-1&&w-1&&S-1&&(M[p=_*A+y*w+S]&I&&!(M[p]&L)?(e.fromArray(_,w,S,b),f=(s=_-b[0])*s+(c=w-b[1])*c+(h=S-b[2])*h,P[p]=f,M[p]|=L,M[p]|=O,n[x]=_,n[x+1]=w,n[x+2]=S,x+=3):M[p]&I&&M[p]&L&&((f=(s=_-b[0])*s+(c=w-b[1])*c+(h=S-b[2])*h)-1&&w-1&&S-1&&(M[p=_*A+y*w+S]&I&&!(M[p]&L)?(e.fromArray(_,w,S,b),f=(s=_-b[0])*s+(c=w-b[1])*c+(h=S-b[2])*h,P[p]=f,M[p]|=L,M[p]|=O,n[x]=_,n[x+1]=w,n[x+2]=S,x+=3):M[p]&I&&M[p]&L&&((f=(s=_-b[0])*s+(c=w-b[1])*c+(h=S-b[2])*h)-1&&a-1&&c-1&&sT&&(T=O)}this.neighbourListLength=27*T+1,this.withinRadii=function(r,o,a,c,d){for(var f=0,p=s(r,h),y=s(o,u),x=s(a,l),_=Math.max(0,p-1),w=Math.max(0,y-1),S=Math.max(0,x-1),C=Math.min(m,p+1),T=Math.min(g,y+1),E=Math.min(v,x+1),I=_;I<=C;++I)for(var L=I*b,O=w;O<=T;++O)for(var R=O*v,D=S;D<=E;++D)for(var N=L+R+D,k=A[N],F=k+M[N],z=k;z_&&(_=b[c]);o(),function(){var t=0,e=2*Math.PI/M;D=new Float32Array(M),R=new Float32Array(M);for(var i=0;i=0;){if(o!==n&&o!==r&&s(o,t,e,i))return U=o,o;o=k[++a]}return U=-1,-1}function s(e,i,n,r){var o=3*e,a=x[e],s=t[o]-i,c=t[o+1]-n,h=t[o+2]-r;return s*s+c*c+h*h0&&c=0;)t65535?Uint32Array:Uint16Array;this.meshIndex=new u(h),this.makeIndex(),Io.call(this,this.meshPosition,this.meshColor,this.meshIndex,this.meshNormal,this.meshPickingColor,s),this.vertexShader="Ribbon.vert",this.fragmentShader="Mesh.frag",this.geometry.addAttribute("dir",new Et(new Float32Array(h),3)),this.geometry.addAttribute("size",new Et(new Float32Array(c),1)),this.setAttributes({position:t,normal:e,dir:i,color:n,size:r,pickingColor:o})}function cs(t,e,i){na.call(this,t,e,i),this.defaultScale.sstruc*=3}function hs(t,e,i){this.helixbundleList=[],na.call(this,t,e,i)}function us(t,e,i){Da.call(this,t,e,i)}function ls(t,e,i){na.call(this,t,e,i)}function ds(t,e,i){var n=i||{};this.size=t.length/3,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.line=!0;var r=this.size-1;this.attributeSize=2*r,this.linePosition=new Float32Array(3*r*2),this.lineColor=new Float32Array(3*r*2),Eo.call(this,this.linePosition,this.lineColor,void 0,void 0,n),this.setAttributes({position:t,color:e})}function fs(t,e,i){na.call(this,t,e,i)}function ps(t,e,i){Da.call(this,t,e,i)}function ms(t,e,i){na.call(this,t,e,i)}function gs(t,e){var i=e||{};this.streamer=t,this.name=h(i.name,""),this.path=h(i.path,"")}function vs(t,e){var i=e||{};this.firstModelOnly=h(i.firstModelOnly,!1),this.asTrajectory=h(i.asTrajectory,!1),this.cAlphaOnly=h(i.cAlphaOnly,!1),gs.call(this,t,i),this.structure=new uo(this.name,this.path),this.structureBuilder=new function(t){function e(t){for(var e=l.atomCount[t],r=l.atomOffset[t],o=new Array(e),a=0;a0&&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,d.residueCount[v]+=1),u.count+=1,u.residueIndex[m]=g,l.atomCount[g]+=1,r=t,o=b,a=x,s=_,c=A,h=w},this.finalize=function(){i=a,n=h,g>-1&&e(g)}}(this.structure)}function ys(t,e,i,n,r,o,a,s){this.a=t||1,this.b=e||1,this.c=i||1,this.alpha=n||90,this.beta=r||90,this.gamma=o||90,this.spacegroup=a||"P 1";var c=Zi(this.alpha),h=Zi(this.beta),u=Zi(this.gamma),l=Math.cos(c),d=Math.cos(h),f=Math.cos(u),p=Math.sin(h),m=Math.sin(u);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-l*l-d*d-f*f+2*l*d*f),void 0===s){var g=this.a*this.b*m/this.volume,v=(d*f-l)/(p*m);this.fracToCart=(new w).set(this.a,0,0,0,this.b*f,this.b*m,0,0,this.c*d,-this.c*p*v,1/g,0,0,0,0,1).transpose(),this.cartToFrac=(new w).getInverse(this.fracToCart)}else this.cartToFrac=s,this.fracToCart=(new w).getInverse(this.cartToFrac)}function bs(t,e){vs.call(this,t,e)}function xs(t,e,i,n,r){this.structure=t,this.index=e,this.description=i||"",this.entityType=function(t){switch(t=t.toLowerCase()){case"polymer":return Al;case"non-polymer":return Ml;case"macrolide":return Pl;case"water":return Cl;default:return Sl}}(n||""),this.chainIndexList=r||[],r.forEach(function(i){t.chainStore.entityIndex[i]=e})}function _s(t,e){vs.call(this,t,e)}function ws(t,e){vs.call(this,t,e)}function Ss(t,e){Array.isArray(t[e])||Object.keys(t).forEach(function(e){t[e]=[t[e]]})}function As(t){return"?"!==t}function Ms(t,e){return As(t)?t:e}function Ps(t){switch(t.toLowerCase()){case"?":case"sing":return 1;case"doub":return 2;case"trip":return 3;case"quad":return 4}return 0}function Cs(t,e,i){var n={},r=e.biomolDict;if(t.pdbx_struct_oper_list){var o=t.pdbx_struct_oper_list;Ss(o,"id"),o.id.forEach(function(t,e){var i=new w,r=i.elements;r[0]=parseFloat(o["matrix[1][1]"][e]),r[1]=parseFloat(o["matrix[1][2]"][e]),r[2]=parseFloat(o["matrix[1][3]"][e]),r[4]=parseFloat(o["matrix[2][1]"][e]),r[5]=parseFloat(o["matrix[2][2]"][e]),r[6]=parseFloat(o["matrix[2][3]"][e]),r[8]=parseFloat(o["matrix[3][1]"][e]),r[9]=parseFloat(o["matrix[3][2]"][e]),r[10]=parseFloat(o["matrix[3][3]"][e]),r[3]=parseFloat(o["vector[1]"][e]),r[7]=parseFloat(o["vector[2]"][e]),r[11]=parseFloat(o["vector[3]"][e]),i.transpose(),n[t]=i})}if(t.pdbx_struct_assembly_gen){var a=t.pdbx_struct_assembly_gen;Ss(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("-"),r=parseInt(i[0]),o=parseInt(i[1]);r<=o;++r)e[r]=n[r];else e[t]=n[t]}),e};a.assembly_id.forEach(function(t,e){var n={},o=a.oper_expression[e].replace(/'\(|'/g,"");if(o.includes(")(")||o.indexOf("(")>0){o=o.split("(");var c=s(o[0]),h=s(o[1]);Object.keys(c).forEach(function(t){Object.keys(h).forEach(function(e){var i=new w;i.multiplyMatrices(c[t],h[e]),n[t+"x"+e]=i})})}else n=s(o);var u=[];for(var l in n)u.push(n[l]);var d=t;/^(0|[1-9][0-9]*)$/.test(d)&&(d="BU"+d);for(var f=a.asym_id_list[e].split(","),p=0,m=f.length;po&&++s;e=new Int32Array(s)}for(i=0,n=0;i>>16&65535|0,a=0;0!==i;){i-=a=i>2e3?2e3:i;do{o=o+(r=r+e[n++]|0)|0}while(--a);r%=65521,o%=65521}return r|o<<16|0}function fc(t,e,i,n){var r=Pp,o=n+i;t^=-1;for(var a=n;a>>8^r[255&(t^e[a])];return-1^t}function pc(t,e){var i,n,r,o,a,s,c,h,u,l,d,f,p,m,g,v,y,b,x,_,w,S,A,M,P;i=t.state,n=t.next_in,M=t.input,r=n+(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,h=i.wsize,u=i.whave,l=i.wnext,d=i.window,f=i.hold,p=i.bits,m=i.lencode,g=i.distcode,v=(1<>>=x=b>>>24,p-=x,0===(x=b>>>16&255))P[o++]=65535&b;else{if(!(16&x)){if(0==(64&x)){b=m[(65535&b)+(f&(1<>>=x,p-=x),p<15&&(f+=M[n++]<>>=x=b>>>24,p-=x,!(16&(x=b>>>16&255))){if(0==(64&x)){b=g[(65535&b)+(f&(1<c){t.msg="invalid distance too far back",i.mode=Cp;break t}if(f>>>=x,p-=x,w>(x=o-a)){if((x=w-x)>u&&i.sane){t.msg="invalid distance too far back",i.mode=Cp;break t}if(S=0,A=d,0===l){if(S+=h-x,x<_){_-=x;do{P[o++]=d[S++]}while(--x);S=o-w,A=P}}else if(l2;)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(n>3,f&=(1<<(p-=_<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n=1&&0===I[_];_--);if(w>_&&(w=_),0===_)return r[o++]=20971520,r[o++]=20971520,s.bits=1,0;for(x=1;x<_&&0===I[x];x++);for(w0&&(t===Op||1!==_))return-1;for(L[1]=0,y=1;yIp||t===Dp&&P>Lp)return 1;for(;;){0,p=y-A,a[b]f?(m=O[R+a[b]],g=T[E+a[b]]):(m=96,g=0),c=1<>A)+(h-=c)]=p<<24|m<<16|g|0}while(0!==h);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,b++,0==--I[y]){if(y===_)break;y=e[i+a[b]]}if(y>w&&(C&l)!==u){for(0===A&&(A=w),d+=x,M=1<<(S=y-A);S+A<_&&!((M-=I[S+A])<=0);)S++,M<<=1;if(P+=1<Ip||t===Dp&&P>Lp)return 1;r[u=C&l]=w<<24|S<<16|d-o|0}}return 0!==C&&(r[d+C]=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(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Jp,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Lm),e.distcode=e.distdyn=new Int32Array(Om),e.sane=1,e.back=-1,Hp):qp}(t)):qp}function yc(t,e){var i,n;return t?(n=new function(){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},t.state=n,n.window=null,(i=function(t,e){var i,n;return t&&t.state?(n=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?qp:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,vc(t))):qp}(t,e))!==Hp&&(t.state=null),i):qp}function bc(t){if(Rm){var e;for(Ap=new Int32Array(512),Mp=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(mc(Up,t.lens,0,288,Ap,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;mc($p,t.lens,0,32,Mp,0,t.work,{bits:5}),Rm=!1}t.lencode=Ap,t.lenbits=9,t.distcode=Mp,t.distbits=5}function xc(t,e,i,n){var r,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(lc(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((r=o.wsize-o.wnext)>n&&(r=n),lc(o.window,e,i-n,r,o.wnext),(n-=r)?(lc(o.window,e,i-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=fc(i.check,C,2,0),h=0,u=0,i.mode=tm;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=Tm;break}if((15&h)!==Qp){t.msg="unknown compression method",i.mode=Tm;break}if(u-=4,w=8+(15&(h>>>=4)),0===i.wbits)i.wbits=w;else if(w>i.wbits){t.msg="invalid window size",i.mode=Tm;break}i.dmax=1<>8&1),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=fc(i.check,C,2,0)),h=0,u=0,i.mode=em;case em:for(;u<32;){if(0===s)break t;s--,h+=n[o++]<>>8&255,C[2]=h>>>16&255,C[3]=h>>>24&255,i.check=fc(i.check,C,4,0)),h=0,u=0,i.mode=im;case im:for(;u<16;){if(0===s)break t;s--,h+=n[o++]<>8),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=fc(i.check,C,2,0)),h=0,u=0,i.mode=nm;case nm:if(1024&i.flags){for(;u<16;){if(0===s)break t;s--,h+=n[o++]<>>8&255,i.check=fc(i.check,C,2,0)),h=0,u=0}else i.head&&(i.head.extra=null);i.mode=rm;case rm:if(1024&i.flags&&((f=i.length)>s&&(f=s),f&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),lc(i.head.extra,n,o,f,w)),512&i.flags&&(i.check=fc(i.check,n,f,o)),s-=f,o+=f,i.length-=f),i.length))break t;i.length=0,i.mode=om;case om:if(2048&i.flags){if(0===s)break t;f=0;do{w=n[o+f++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&f>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=um;break;case cm:for(;u<32;){if(0===s)break t;s--,h+=n[o++]<>>=7&u,u-=7&u,i.mode=Mm;break}for(;u<3;){if(0===s)break t;s--,h+=n[o++]<>>=1)){case 0:i.mode=dm;break;case 1:if(bc(i),i.mode=ym,e===Gp){h>>>=2,u-=2;break t}break;case 2:i.mode=mm;break;case 3:t.msg="invalid block type",i.mode=Tm}h>>>=2,u-=2;break;case dm:for(h>>>=7&u,u-=7&u;u<32;){if(0===s)break t;s--,h+=n[o++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=Tm;break}if(i.length=65535&h,h=0,u=0,i.mode=fm,e===Gp)break t;case fm:i.mode=pm;case pm:if(f=i.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break t;lc(r,n,o,f,a),s-=f,o+=f,c-=f,a+=f,i.length-=f;break}i.mode=um;break;case mm:for(;u<14;){if(0===s)break t;s--,h+=n[o++]<>>=5,u-=5,i.ndist=1+(31&h),h>>>=5,u-=5,i.ncode=4+(15&h),h>>>=4,u-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Tm;break}i.have=0,i.mode=gm;case gm:for(;i.have>>=3,u-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=mc(Bp,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid code lengths set",i.mode=Tm;break}i.have=0,i.mode=vm;case vm:for(;i.have>>16&255,y=65535&P,!((g=P>>>24)<=u);){if(0===s)break t;s--,h+=n[o++]<>>=g,u-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;u>>=g,u-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=Tm;break}w=i.lens[i.have-1],f=3+(3&h),h>>>=2,u-=2}else if(17===y){for(M=g+3;u>>=g)),h>>>=3,u-=3}else{for(M=g+7;u>>=g)),h>>>=7,u-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Tm;break}for(;f--;)i.lens[i.have++]=w}}if(i.mode===Tm)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Tm;break}if(i.lenbits=9,A={bits:i.lenbits},S=mc(Up,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){t.msg="invalid literal/lengths set",i.mode=Tm;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=mc($p,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){t.msg="invalid distances set",i.mode=Tm;break}if(i.mode=ym,e===Gp)break t;case ym:i.mode=bm;case bm:if(s>=6&&c>=258){t.next_out=a,t.avail_out=c,t.next_in=o,t.avail_in=s,i.hold=h,i.bits=u,pc(t,d),a=t.next_out,r=t.output,c=t.avail_out,o=t.next_in,n=t.input,s=t.avail_in,h=i.hold,u=i.bits,i.mode===um&&(i.back=-1);break}for(i.back=0;v=(P=i.lencode[h&(1<>>16&255,y=65535&P,!((g=P>>>24)<=u);){if(0===s)break t;s--,h+=n[o++]<>b)])>>>16&255,y=65535&P,!(b+(g=P>>>24)<=u);){if(0===s)break t;s--,h+=n[o++]<>>=b,u-=b,i.back+=b}if(h>>>=g,u-=g,i.back+=g,i.length=y,0===v){i.mode=Am;break}if(32&v){i.back=-1,i.mode=um;break}if(64&v){t.msg="invalid literal/length code",i.mode=Tm;break}i.extra=15&v,i.mode=xm;case xm:if(i.extra){for(M=i.extra;u>>=i.extra,u-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=_m;case _m:for(;v=(P=i.distcode[h&(1<>>16&255,y=65535&P,!((g=P>>>24)<=u);){if(0===s)break t;s--,h+=n[o++]<>b)])>>>16&255,y=65535&P,!(b+(g=P>>>24)<=u);){if(0===s)break t;s--,h+=n[o++]<>>=b,u-=b,i.back+=b}if(h>>>=g,u-=g,i.back+=g,64&v){t.msg="invalid distance code",i.mode=Tm;break}i.offset=y,i.extra=15&v,i.mode=wm;case wm:if(i.extra){for(M=i.extra;u>>=i.extra,u-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Tm;break}i.mode=Sm;case Sm:if(0===c)break t;if(f=d-c,i.offset>f){if((f=i.offset-f)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Tm;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),m=i.window}else m=r,p=a-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[a++]=m[p++]}while(--f);0===i.length&&(i.mode=bm);break;case Am:if(0===c)break t;r[a++]=i.length,c--,i.mode=bm;break;case Mm:if(i.wrap){for(;u<32;){if(0===s)break t;s--,h|=n[o++]<>>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 Ac(t,e){var i,n,r,o,a=e||t.length,s=new Array(2*a);for(n=0,i=0;i4)s[n++]=65533,i+=o-1;else{for(r&=2===o?31:3===o?15:7;o>1&&i1?s[n++]=65533:r<65536?s[n++]=r:(r-=65536,s[n++]=55296|r>>10&1023,s[n++]=56320|1023&r)}return function(t,e){if(e<65537&&(t.subarray&&Nm||!t.subarray&&Dm))return String.fromCharCode.apply(null,uc(t,e));for(var i="",n=0;nt.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0?e:0===i?e:i+km[t[i]]>e?i:e}function Pc(t){if(!(this instanceof Pc))return new Pc(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 n in i)i.hasOwnProperty(n)&&(t[n]=i[n])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new function(){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},this.strm.avail_out=0;var i=yc(this.strm,e.windowBits);if(i!==zm)throw new Error(Bm[i]);this.header=new function(){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(t,e){var i;t&&t.state&&(0==(2&(i=t.state).wrap)||(i.head=e,e.done=!1))}(this.strm,this.header)}function Cc(){this.getUrl=function(t){return t}}"undefined"!=typeof window&&function(){window.console=window.console||{};for(var t,e,i=window.console,n={},r=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]=n);for(;e=a.pop();)i[e]||(i[e]=r)}(),"undefined"==typeof HTMLCanvasElement||HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,i){for(var n=window.atob(this.toDataURL(e,i).split(",")[1]),r=n.length,o=r>>2,a=new Uint8Array(r),s=new Uint32Array(a.buffer,0,o),c=0,h=0;c-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){if(void 0===t||null===t)throw new TypeError("Cannot convert first argument to object");for(var e,i=Object(t),n=!1,r=1;r1?arguments[1]:void 0,s=a?Number(a):0;s!=s&&(s=0);var c=Math.min(Math.max(s,0),n);if(o+c>n)return!1;for(var h=-1;++hi.length)&&(e=i.length),e-=t.length;var n=i.indexOf(t,e);return-1!==n&&n===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 n,r,o=parseInt(arguments[1],10)||0;for(o>=0?n=o:(n=i+o)<0&&(n=0);n0?1:-1)*Math.floor(Math.abs(e)):e}(t);return Math.min(Math.max(e,0),i)};return function(t){var i=Object(t);if(null==t)throw new TypeError("Array.from requires an array-like object - not null or undefined");var r,o=arguments.length>1?arguments[1]:void 0;if(void 0!==o){if(!e(o))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(r=arguments[2])}for(var a,s=n(i.length),c=e(this)?Object(new this(s)):new Array(s),h=0;he?1:0}return function(e,i,n){var r=0,o=e.length-1;for(n||(n=t);r<=o;){var a=r+o>>1,s=n(i,e[a]);if(s>0)r=a+1;else{if(!(s<0))return a;o=a-1}}return-r-1}}();void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),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*)\s*\(/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),i=1;i>=4,i[r]=e[19===r?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,n,r){return n+(t-e)*(r-n)/(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)},random16:function(){return Math.random()},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*Du.DEG2RAD},radToDeg:function(t){return t*Du.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}};x.prototype={constructor:x,isVector2:!0,get width(){return this.x},set width(t){this.x=t},get height(){return this.y},set height(t){this.y=t},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)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),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,e;return function(i,n){return void 0===t&&(t=new x,e=new x),t.set(i,i),e.set(n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,i))/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())},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.multiplyScalar(t/this.length())},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},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this},rotateAround:function(t,e){var i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*i-o*n+t.x,this.y=r*n+o*i+t.y,this}},_.DEFAULT_IMAGE=void 0,_.DEFAULT_MAPPING=300,_.prototype={constructor:_,isTexture:!0,set needsUpdate(t){!0===t&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return 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.4,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=Du.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 kh:t.x=t.x-Math.floor(t.x);break;case Fh:t.x=t.x<0?0:1;break;case zh: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 kh:t.y=t.y-Math.floor(t.y);break;case Fh:t.y=t.y<0?0:1;break;case zh: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(_.prototype,b.prototype);var Nu=0;w.prototype={constructor:w,isMatrix4:!0,set:function(t,e,i,n,r,o,a,s,c,h,u,l,d,f,p,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=h,g[10]=u,g[14]=l,g[3]=d,g[7]=f,g[11]=p,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 w).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),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;return function(e){void 0===t&&(t=new A);var i=this.elements,n=e.elements,r=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return i[0]=n[0]*r,i[1]=n[1]*r,i[2]=n[2]*r,i[4]=n[4]*o,i[5]=n[5]*o,i[6]=n[6]*o,i[8]=n[8]*a,i[9]=n[9]*a,i[10]=n[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler;var e=this.elements,i=t.x,n=t.y,r=t.z,o=Math.cos(i),a=Math.sin(i),s=Math.cos(n),c=Math.sin(n),h=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){var l=o*h,d=o*u,f=a*h,p=a*u;e[0]=s*h,e[4]=-s*u,e[8]=c,e[1]=d+f*c,e[5]=l-p*c,e[9]=-a*s,e[2]=p-l*c,e[6]=f+d*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*h,g=s*u,v=c*h,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*h,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*h,g=s*u,v=c*h,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*h,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){l=o*h,d=o*u,f=a*h,p=a*u;e[0]=s*h,e[4]=f*c-d,e[8]=l*c+p,e[1]=s*u,e[5]=p*c+l,e[9]=d*c-f,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*h,e[4]=w-b*u,e[8]=_*u+x,e[1]=u,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=x*u+_,e[10]=b-w*u}else if("XZY"===t.order){b=o*s,x=o*c,_=a*s,w=a*c;e[0]=s*h,e[4]=-u,e[8]=c*h,e[1]=b*u+w,e[5]=o*h,e[9]=x*u-_,e[2]=_*u-x,e[6]=a*h,e[10]=w*u+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,n=t.y,r=t.z,o=t.w,a=i+i,s=n+n,c=r+r,h=i*a,u=i*s,l=i*c,d=n*s,f=n*c,p=r*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(d+p),e[4]=u-v,e[8]=l+g,e[1]=u+v,e[5]=1-(h+p),e[9]=f-m,e[2]=l-g,e[6]=f+m,e[10]=1-(h+d),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,e,i;return function(n,r,o){void 0===t&&(t=new A,e=new A,i=new A);var a=this.elements;return i.subVectors(n,r).normalize(),0===i.lengthSq()&&(i.z=1),t.crossVectors(o,i).normalize(),0===t.lengthSq()&&(i.z+=1e-4,t.crossVectors(o,i).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?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var i=t.elements,n=e.elements,r=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],h=i[1],u=i[5],l=i[9],d=i[13],f=i[2],p=i[6],m=i[10],g=i[14],v=i[3],y=i[7],b=i[11],x=i[15],_=n[0],w=n[4],S=n[8],A=n[12],M=n[1],P=n[5],C=n[9],T=n[13],E=n[2],I=n[6],L=n[10],O=n[14],R=n[3],D=n[7],N=n[11],k=n[15];return r[0]=o*_+a*M+s*E+c*R,r[4]=o*w+a*P+s*I+c*D,r[8]=o*S+a*C+s*L+c*N,r[12]=o*A+a*T+s*O+c*k,r[1]=h*_+u*M+l*E+d*R,r[5]=h*w+u*P+l*I+d*D,r[9]=h*S+u*C+l*L+d*N,r[13]=h*A+u*T+l*O+d*k,r[2]=f*_+p*M+m*E+g*R,r[6]=f*w+p*P+m*I+g*D,r[10]=f*S+p*C+m*L+g*N,r[14]=f*A+p*T+m*O+g*k,r[3]=v*_+y*M+b*E+x*R,r[7]=v*w+y*P+b*I+x*D,r[11]=v*S+y*C+b*L+x*N,r[15]=v*A+y*T+b*O+x*k,this},multiplyToArray:function(t,e,i){var n=this.elements;return this.multiplyMatrices(t,e),i[0]=n[0],i[1]=n[1],i[2]=n[2],i[3]=n[3],i[4]=n[4],i[5]=n[5],i[6]=n[6],i[7]=n[7],i[8]=n[8],i[9]=n[9],i[10]=n[10],i[11]=n[11],i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15],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},applyToVector3Array:function(){var t;return function(e,i,n){void 0===t&&(t=new A),void 0===i&&(i=0),void 0===n&&(n=e.length);for(var r=0,o=i;r0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(u-c)*e,this._y=(o-h)*e,this._z=(a-r)*e):n>s&&n>l?(e=2*Math.sqrt(1+n-s-l),this._w=(u-c)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(o+h)/e):s>l?(e=2*Math.sqrt(1+s-n-l),this._w=(o-h)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+l-n-s),this._w=(a-r)/e,this._x=(o+h)/e,this._y=(c+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e;return function(i,n){return void 0===t&&(t=new A),(e=i.dot(n)+1)<1e-6?(e=0,Math.abs(i.x)>Math.abs(i.z)?t.set(-i.y,i.x,0):t.set(0,-i.z,i.y)):t.crossVectors(i,n),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?this.multiplyQuaternions(t,e):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var i=t._x,n=t._y,r=t._z,o=t._w,a=e._x,s=e._y,c=e._z,h=e._w;return this._x=i*h+o*a+n*c-r*s,this._y=n*h+o*s+r*a-i*c,this._z=r*h+o*c+i*s-n*a,this._w=o*h-i*a-n*s-r*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var i=this._x,n=this._y,r=this._z,o=this._w,a=o*t._w+i*t._x+n*t._y+r*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=n,this._z=r,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*(n+this._y),this._z=.5*(r+this._z),this;var c=Math.atan2(s,a),h=Math.sin((1-e)*c)/s,u=Math.sin(e*c)/s;return this._w=o*h+this._w*u,this._x=i*h+this._x*u,this._y=n*h+this._y*u,this._z=r*h+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(S,{slerp:function(t,e,i,n){return i.copy(t).slerp(e,n)},slerpFlat:function(t,e,i,n,r,o,a){var s=i[n+0],c=i[n+1],h=i[n+2],u=i[n+3],l=r[o+0],d=r[o+1],f=r[o+2],p=r[o+3];if(u!==p||s!==l||c!==d||h!==f){var m=1-a,g=s*l+c*d+h*f+u*p,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+d*_,h=h*m+f*_,u=u*m+p*_,m===1-a){var w=1/Math.sqrt(s*s+c*c+h*h+u*u);s*=w,c*=w,h*=w,u*=w}}t[e]=s,t[e+1]=c,t[e+2]=h,t[e+3]=u}}),A.prototype={constructor:A,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)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),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;return function(e){return e&&e.isEuler,void 0===t&&(t=new S),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t;return function(e,i){return void 0===t&&(t=new S),this.applyQuaternion(t.setFromAxisAngle(e,i))}}(),applyMatrix3:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this},applyMatrix4:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12],this.y=r[1]*e+r[5]*i+r[9]*n+r[13],this.z=r[2]*e+r[6]*i+r[10]*n+r[14],this},applyProjection:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements,o=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*o,this},applyQuaternion:function(t){var e=this.x,i=this.y,n=this.z,r=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*n-a*i,h=s*i+a*e-r*n,u=s*n+r*i-o*e,l=-r*e-o*i-a*n;return this.x=c*s+l*-r+h*-a-u*-o,this.y=h*s+l*-o+u*-r-c*-a,this.z=u*s+l*-a+c*-o-h*-r,this},project:function(){var t;return function(e){return void 0===t&&(t=new w),t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyProjection(t)}}(),unproject:function(){var t;return function(e){return void 0===t&&(t=new w),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyProjection(t)}}(),transformDirection:function(t){var e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(i,n){return void 0===t&&(t=new A,e=new A),t.set(i,i,i),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var i=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,i))/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())},setLength:function(t){return this.multiplyScalar(t/this.length())},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 this.crossVectors(t,e);var i=this.x,n=this.y,r=this.z;return this.x=n*t.z-r*t.y,this.y=r*t.x-i*t.z,this.z=i*t.y-n*t.x,this},crossVectors:function(t,e){var i=t.x,n=t.y,r=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-r*a,this.y=r*o-i*s,this.z=i*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t;return function(e){return void 0===t&&(t=new A),t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t;return function(e){return void 0===t&&(t=new A),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(Du.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,n=this.z-t.z;return e*e+i*i+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this},setFromMatrixColumn:function(t,e){if("number"==typeof t){var i=t;t=e,e=i}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},fromAttribute:function(t,e,i){return void 0===i&&(i=0),e=e*t.itemSize+i,this.x=t.array[e],this.y=t.array[e+1],this.z=t.array[e+2],this}},P.prototype={constructor:P,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;ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new x).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new x).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new x;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)}},T.prototype=Object.create(_.prototype),T.prototype.constructor=T,T.prototype.isCubeTexture=!0,Object.defineProperty(T.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});var ku=new _,Fu=new T,zu=[],Bu=[];nt.prototype.setValue=function(t,e){for(var i=this.seq,n=0,r=i.length;n!==r;++n){var o=i[n];o.setValue(t,e[o.id])}};var Uu=/([\w\d_]+)(\])?(\[|\.)?/g;at.prototype.setValue=function(t,e,i){var n=this.map[e];void 0!==n&&n.setValue(t,i,this.renderer)},at.prototype.set=function(t,e,i){var n=this.map[i];void 0!==n&&n.setValue(t,e[i],this.renderer)},at.prototype.setOptional=function(t,e,i){var n=e[i];void 0!==n&&this.setValue(t,i,n)},at.upload=function(t,e,i,n){for(var r=0,o=e.length;r!==o;++r){var a=e[r],s=i[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,n)}},at.seqWithValue=function(t,e){for(var i=[],n=0,r=t.length;n!==r;++n){var o=t[n];o.id in e&&i.push(o)}return i},at.splitDynamic=function(t,e){for(var i=null,n=t.length,r=0,o=0;o!==n;++o){var a=t[o],s=e[a.id];s&&!0===s.dynamic?(null===i&&(i=[]),i.push(a)):(rv&&g>y?gy?v0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),n.skinning=this.skinning,n.morphTargets=this.morphTargets,i){var r=e(t.textures),o=e(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.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.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.clipShadows=t.clipShadows;var e=t.clippingPlanes,i=null;if(null!==e){var n=e.length;i=new Array(n);for(var r=0;r!==n;++r)i[r]=e[r].clone()}return this.clippingPlanes=i,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(ut.prototype,b.prototype);var $u=0,Vu={merge:function(t){for(var e={},i=0;i 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\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}\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 = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\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 < NUM_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\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 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}\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:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\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 += normal * ( 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 return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return 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 return 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 return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return 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 vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return 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 float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return 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 = saturate( flipNormal * reflectVec.y * 0.5 + 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 envMapIntenstiy;\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_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\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\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",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\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.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_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 ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\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_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\t#include \n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * 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 = flipNormal * 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\t#include \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 = flipNormal * 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 = flipNormal * 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( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * 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 = flipNormal * 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\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\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}\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_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 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\t\t\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.r;\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 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\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 return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 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 return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( 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:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\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\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\treturn (\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\treturn (\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\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\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 boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\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\tskinned = bindMatrixInverse * skinned;\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 return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return 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 color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return 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\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \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 \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include \n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",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\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n}\n",normal_frag:"uniform float opacity;\nvarying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include \n}\n",normal_vert:"varying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};dt.prototype={constructor:dt,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){this.r=t,this.g=t,this.b=t},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,n){if(e=Du.euclideanModulo(e,1),i=Du.clamp(i,0,1),n=Du.clamp(n,0,1),0===i)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+i):n+i-n*i,o=2*n-r;this.r=t(o,r,e+1/3),this.g=t(o,r,e),this.b=t(o,r,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(t)){var h,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}t&&t.length>0&&(void 0!==(h=Gu[t])&&this.setHex(h));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,n=t||{h:0,s:0,l:0},r=this.r,o=this.g,a=this.b,s=Math.max(r,o,a),c=Math.min(r,o,a),h=(c+s)/2;if(c===s)e=0,i=0;else{var u=s-c;switch(i=h<=.5?u/(s+c):u/(2-s-c),s){case r:e=(o-a)/u+(or&&(r=h),u>o&&(o=u),l>a&&(a=l)}this.min.set(e,i,n),this.max.set(r,o,a)},setFromPoints:function(t){this.makeEmpty();for(var e=0,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new A).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t;return function(e){return void 0===t&&(t=new A),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 A).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new A;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new A;return function(e){var i=e||new mt;return i.center=this.center(),i.radius=.5*this.size(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 A,new A,new A,new A,new A,new A,new A,new A];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)}},mt.prototype={constructor:mt,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new pt;return function(e,i){var n=this.center;void 0!==i?n.copy(i):t.setFromPoints(e).center(n);for(var r=0,o=0,a=e.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new pt;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}},gt.prototype={constructor:gt,isMatrix3:!0,set:function(t,e,i,n,r,o,a,s,c){var h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=r,h[5]=s,h[6]=i,h[7]=o,h[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=t.elements;return this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[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},applyToVector3Array:function(){var t;return function(e,i,n){void 0===t&&(t=new A),void 0===i&&(i=0),void 0===n&&(n=e.length);for(var r=0,o=i;r1))return n.copy(r).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return n.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),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 A).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new A,e=new gt;return function(i,n){var r=this.coplanarPoint(t).applyMatrix4(i),o=n||e.getNormalMatrix(i),a=this.normal.applyMatrix3(o).normalize();return this.constant=-r.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}},yt.prototype={constructor:yt,set:function(t,e,i,n,r,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(r),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,n=i[0],r=i[1],o=i[2],a=i[3],s=i[4],c=i[5],h=i[6],u=i[7],l=i[8],d=i[9],f=i[10],p=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return e[0].setComponents(a-n,u-s,p-l,y-m).normalize(),e[1].setComponents(a+n,u+s,p+l,y+m).normalize(),e[2].setComponents(a+r,u+c,p+d,y+g).normalize(),e[3].setComponents(a-r,u-c,p-d,y-g).normalize(),e[4].setComponents(a-o,u-h,p-f,y-v).normalize(),e[5].setComponents(a+o,u+h,p+f,y+v).normalize(),this},intersectsObject:function(){var t=new mt;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 mt;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,n=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(i)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}};var Xu=0;Et.prototype={constructor:Et,isBufferAttribute:!0,get count(){return this.array.length/this.itemSize},set needsUpdate(t){!0===t&&this.version++},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.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(var n=0,r=this.itemSize;n1){for(var e=0;e1)for(var e=0;e0){r.children=[];for(var o=0;o0&&(n.geometries=a),s.length>0&&(n.materials=s),c.length>0&&(n.textures=c),h.length>0&&(n.images=h)}return n.object=r,n},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.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;i0)for(f=0;f0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,i,n,r;for(i=0,n=this.faces.length;i0&&(t+=e[i].distanceTo(e[i-1])),this.lineDistances[i]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new pt),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new mt),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,i){if(!1!==(t&&t.isGeometry)){var n,r=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,h=this.faceVertexUvs[0],u=t.faceVertexUvs[0];void 0===i&&(i=0),void 0!==e&&(n=(new gt).getNormalMatrix(e));for(var l=0,d=a.length;l=0;i--){var p=d[i];for(this.faces.splice(p,1),a=0,s=this.faceVertexUvs.length;a0,x=v.vertexNormals.length>0,_=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,S=0;if(S=t(S=t(S=t(S=t(S=t(S=t(S=t(S=t(S,0,0),1,!0),2,!1),3,y),4,b),5,x),6,_),7,w),u.push(S),u.push(v.a,v.b,v.c),u.push(v.materialIndex),y){var A=this.faceVertexUvs[0][c];u.push(n(A[0]),n(A[1]),n(A[2]))}if(b&&u.push(e(v.normal)),x){var M=v.vertexNormals;u.push(e(M[0]),e(M[1]),e(M[2]))}if(_&&u.push(i(v.color)),w){var P=v.vertexColors;u.push(i(P[0]),i(P[1]),i(P[2]))}}return r.data={},r.data.vertices=s,r.data.normals=l,f.length>0&&(r.data.colors=f),m.length>0&&(r.data.uvs=[m]),r.data.faces=u,r},clone:function(){return(new Nt).copy(this)},copy:function(t){this.vertices=[],this.faces=[],this.faceVertexUvs=[[]];for(var e=t.vertices,i=0,n=e.length;i0,a=r[1]&&r[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var h=0;h0){u=[];for(h=0;h0){var i=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Et(i,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new Et(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var r=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Et(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Et(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(t.vertices.length>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new Et(a,1).copyIndicesArray(t.indices))}for(var s in this.groups=t.groups,t.morphTargets){for(var c=[],h=t.morphTargets[s],u=0,l=h.length;u0){var p=new It(4*t.skinIndices.length,4);this.addAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new It(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new pt);var t=this.attributes.position.array;void 0!==t?this.boundingBox.setFromArray(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:function(){var t=new pt,e=new A;return function(){null===this.boundingSphere&&(this.boundingSphere=new mt);var i=this.attributes.position;if(i){var n=i.array,r=this.boundingSphere.center;t.setFromArray(n),t.center(r);for(var o=0,a=0,s=n.length;a0&&(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 zt).copy(this)},copy:function(t){var e=t.index;null!==e&&this.setIndex(e.clone());var i=t.attributes;for(var n in i){var r=i[n];this.addAttribute(n,r.clone())}for(var o=t.groups,a=0,s=o.length;a0)if(c=d*f-p,u=l*g,(s=d*p-f)>=0)if(c>=-u)if(c<=u){var v=1/g;h=(s*=v)*(s+d*(c*=v)+2*f)+c*(d*s+c+2*p)+m}else c=l,h=-(s=Math.max(0,-(d*c+f)))*s+c*(c+2*p)+m;else c=-l,h=-(s=Math.max(0,-(d*c+f)))*s+c*(c+2*p)+m;else c<=-u?h=-(s=Math.max(0,-(-d*l+f)))*s+(c=s>0?-l:Math.min(Math.max(-l,-p),l))*(c+2*p)+m:c<=u?(s=0,h=(c=Math.min(Math.max(-l,-p),l))*(c+2*p)+m):h=-(s=Math.max(0,-(d*l+f)))*s+(c=s>0?l:Math.min(Math.max(-l,-p),l))*(c+2*p)+m;else c=d>0?-l:l,h=-(s=Math.max(0,-(d*c+f)))*s+c*(c+2*p)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),h}}(),intersectSphere:function(){var t=new A;return function(e,i){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),r=t.dot(t)-n*n,o=e.radius*e.radius;if(r>o)return null;var a=Math.sqrt(o-r),s=n-a,c=n+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,n,r,o,a,s,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,l=this.origin;return c>=0?(i=(t.min.x-l.x)*c,n=(t.max.x-l.x)*c):(i=(t.max.x-l.x)*c,n=(t.min.x-l.x)*c),h>=0?(r=(t.min.y-l.y)*h,o=(t.max.y-l.y)*h):(r=(t.max.y-l.y)*h,o=(t.min.y-l.y)*h),i>o||r>n?null:((r>i||i!=i)&&(i=r),(o=0?(a=(t.min.z-l.z)*u,s=(t.max.z-l.z)*u):(a=(t.max.z-l.z)*u,s=(t.min.z-l.z)*u),i>s||a>n?null:((a>i||i!=i)&&(i=a),(s=0?i:n,e)))},intersectsBox:function(){var t=new A;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new A,e=new A,i=new A,n=new A;return function(r,o,a,s,c){e.subVectors(o,r),i.subVectors(a,r),n.crossVectors(e,i);var h,u=this.direction.dot(n);if(u>0){if(s)return null;h=1}else{if(!(u<0))return null;h=-1,u=-u}t.subVectors(this.origin,r);var l=h*this.direction.dot(i.crossVectors(t,i));if(l<0)return null;var d=h*this.direction.dot(e.cross(t));if(d<0)return null;if(l+d>u)return null;var f=-h*t.dot(n);return f<0?null:this.at(f/u,c)}}(),applyMatrix4:function(t){return this.direction.add(this.origin).applyMatrix4(t),this.origin.applyMatrix4(t),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}},Wt.prototype={constructor:Wt,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},center:function(t){return(t||new A).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new A).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 A;return this.delta(i).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new A,e=new A;return function(i,n){t.subVectors(i,this.start),e.subVectors(this.end,this.start);var r=e.dot(e),o=e.dot(t)/r;return n&&(o=Du.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,i){var n=this.closestPointToPointParameter(t,e),r=i||new A;return this.delta(r).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}},Xt.normal=function(){var t=new A;return function(e,i,n,r){var o=r||new A;o.subVectors(n,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)}}(),Xt.barycoordFromPoint=function(){var t=new A,e=new A,i=new A;return function(n,r,o,a,s){t.subVectors(a,r),e.subVectors(o,r),i.subVectors(n,r);var c=t.dot(t),h=t.dot(e),u=t.dot(i),l=e.dot(e),d=e.dot(i),f=c*l-h*h,p=s||new A;if(0===f)return p.set(-2,-1,-1);var m=1/f,g=(l*u-h*d)*m,v=(c*d-h*u)*m;return p.set(1-g-v,v,g)}}(),Xt.containsPoint=function(){var t=new A;return function(e,i,n,r){var o=Xt.barycoordFromPoint(e,i,n,r,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),Xt.prototype={constructor:Xt,set:function(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this},setFromPointsAndIndices:function(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new A,e=new A;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 A).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return Xt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new vt).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return Xt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Xt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t,e,i,n;return function(r,o){void 0===t&&(t=new vt,e=[new Wt,new Wt,new Wt],i=new A,n=new A);var a=o||new A,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(r,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;c0){this.morphTargetBase=-1,this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var t=0,e=this.geometry.morphTargets.length;te.far?null:{distance:c,point:v.clone(),object:t}}function i(i,n,r,o,h,u,l,m){a.fromArray(o,3*u),s.fromArray(o,3*l),c.fromArray(o,3*m);var v=e(i,n,r,a,s,c,g);return v&&(h&&(d.fromArray(h,2*u),f.fromArray(h,2*l),p.fromArray(h,2*m),v.uv=t(g,a,s,c,d,f,p)),v.face=new Lt(u,l,m,Xt.normal(a,s,c)),v.faceIndex=u),v}var n=new w,r=new Ht,o=new mt,a=new A,s=new A,c=new A,h=new A,u=new A,l=new A,d=new x,f=new x,p=new x,m=new A,g=new A,v=new A;return function(m,v){var y,b,x=this.geometry,_=this.material,w=this.matrixWorld;if(void 0!==_&&(null===x.boundingSphere&&x.computeBoundingSphere(),o.copy(x.boundingSphere),o.applyMatrix4(w),!1!==m.ray.intersectsSphere(o)&&(n.getInverse(w),r.copy(m.ray).applyMatrix4(n),null===x.boundingBox||!1!==r.intersectsBox(x.boundingBox))))if(x&&x.isBufferGeometry){var S,A,M,P=x.index,C=x.attributes,T=C.position.array;if(void 0!==C.uv&&(y=C.uv.array),null!==P)for(var E=P.array,I=0,L=E.length;I0&&(y=B);for(var U=0,$=z.length;U<$;U++){var V=z[U],j=!0===N?k[V.materialIndex]:_;if(void 0!==j){if(O=F[V.a],R=F[V.b],D=F[V.c],!0===j.morphTargets){var G=x.morphTargets,H=this.morphTargetInfluences;a.set(0,0,0),s.set(0,0,0),c.set(0,0,0);for(var W=0,X=G.length;Wthis.scale.x*this.scale.y/4||i.push({distance:Math.sqrt(n),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),se.prototype=Object.assign(Object.create(Dt.prototype),{constructor:se,copy:function(t){Dt.prototype.copy.call(this,t,!1);for(var e=t.levels,i=0,n=e.length;i1){t.setFromMatrixPosition(i.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var r=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa))d.applyMatrix4(this.matrixWorld),(S=n.ray.origin.distanceTo(d))n.far||r.push({distance:S,point:l.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}else for(v=0,y=m.length/3-1;va))d.applyMatrix4(this.matrixWorld),(S=n.ray.origin.distanceTo(d))n.far||r.push({distance:S,point:l.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else if(s&&s.isGeometry){var _=s.vertices,w=_.length;for(v=0;va))d.applyMatrix4(this.matrixWorld),(S=n.ray.origin.distanceTo(d))n.far||r.push({distance:S,point:l.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),pe.prototype=Object.assign(Object.create(fe.prototype),{constructor:pe,isLineSegments:!0}),me.prototype=Object.create(ut.prototype),me.prototype.constructor=me,me.prototype.isPointsMaterial=!0,me.prototype.copy=function(t){return ut.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},ge.prototype=Object.assign(Object.create(Dt.prototype),{constructor:ge,isPoints:!0,raycast:function(){var t=new w,e=new Ht,i=new mt;return function(n,r){function o(t,i){var o=e.distanceSqToPoint(t);if(on.far)return;r.push({distance:h,distanceToRay:Math.sqrt(o),point:s.clone(),index:i,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,h=n.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),i.copy(s.boundingSphere),i.applyMatrix4(c),!1!==n.ray.intersectsSphere(i)){t.getInverse(c),e.copy(n.ray).applyMatrix4(t);var u=h/((this.scale.x+this.scale.y+this.scale.z)/3),l=u*u,d=new A;if(s&&s.isBufferGeometry){var f=s.index,p=s.attributes.position.array;if(null!==f)for(var m=f.array,g=0,v=m.length;g0||0===t.search(/^data\:image\/jpeg/);r.format=n?ru:ou,r.image=i,r.needsUpdate=!0,void 0!==e&&e(r)},i,n),r},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this}}),Me.prototype=Object.assign(Object.create(Dt.prototype),{constructor:Me,isLight:!0,copy:function(t){return Dt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=Dt.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}}),Pe.prototype=Object.assign(Object.create(Me.prototype),{constructor:Pe,isHemisphereLight:!0,copy:function(t){return Me.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Ce.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}}),Te.prototype=Object.assign(Object.create(Ce.prototype),{constructor:Te,isSpotLightShadow:!0,update:function(t){var e=2*Du.RAD2DEG*t.angle,i=this.mapSize.width/this.mapSize.height,n=t.distance||500,r=this.camera;e===r.fov&&i===r.aspect&&n===r.far||(r.fov=e,r.aspect=i,r.far=n,r.updateProjectionMatrix())}}),Ee.prototype=Object.assign(Object.create(Me.prototype),{constructor:Ee,isSpotLight:!0,copy:function(t){return Me.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}}),Ie.prototype=Object.assign(Object.create(Me.prototype),{constructor:Ie,isPointLight:!0,copy:function(t){return Me.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Le.prototype=Object.assign(Object.create(Ce.prototype),{constructor:Le}),Oe.prototype=Object.assign(Object.create(Me.prototype),{constructor:Oe,isDirectionalLight:!0,copy:function(t){return Me.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Re.prototype=Object.assign(Object.create(Me.prototype),{constructor:Re,isAmbientLight:!0});var Qu,Ju={arraySlice:function(t,e,i){return Ju.isTypedArray(t)?new t.constructor(t.subarray(e,i)):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){for(var e=t.length,i=new Array(e),n=0;n!==e;++n)i[n]=n;return i.sort(function(e,i){return t[e]-t[i]}),i},sortedArray:function(t,e,i){for(var n=t.length,r=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=i[o]*e,c=0;c!==e;++c)r[a++]=t[s+c];return r},flattenJSON:function(t,e,i,n){for(var r=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[r++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),i.push.apply(i,a)),o=t[r++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(i,i.length)),o=t[r++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),i.push(a)),o=t[r++]}while(void 0!==o)}}};De.prototype={constructor:De,evaluate:function(t){var e=this.parameterPositions,i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{var o;i:{n:if(!(t=r)break t;var s=e[1];t=(r=e[--i-1]))break e}o=i,i=0}for(;i>>1;te;)--o;if(++o,0!==r||o!==n){r>=o&&(r=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=Ju.arraySlice(i,r,o),this.values=Ju.arraySlice(this.values,r*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);var i=this.times,n=this.values,r=i.length;0===r&&(t=!1);for(var o=null,a=0;a!==r;a++){var s=i[a];if("number"==typeof s&&isNaN(s)){t=!1;break}if(null!==o&&o>s){t=!1;break}o=s}if(void 0!==n&&Ju.isTypedArray(n)){a=0;for(var c=n.length;a!==c;++a){var h=n[a];if(isNaN(h)){t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,i=this.getValueSize(),n=1,r=1,o=t.length-1;r<=o;++r){var a=!1,s=t[r];if(s!==t[r+1]&&(1!==r||s!==s[0]))for(var c=r*i,h=c-i,u=c+i,l=0;l!==i;++l){var d=e[c+l];if(d!==e[h+l]||d!==e[u+l]){a=!0;break}}if(a){if(r!==n){t[n]=t[r];var f=r*i,p=n*i;for(l=0;l!==i;++l)e[p+l]=e[f+l]}++n}}return n!==t.length&&(this.times=Ju.arraySlice(t,0,n),this.values=Ju.arraySlice(e,0,n*i)),this}},Be.prototype=Object.assign(Object.create(Qu),{constructor:Be,ValueTypeName:"vector"}),Ue.prototype=Object.assign(Object.create(De.prototype),{constructor:Ue,interpolate_:function(t,e,i,n){for(var r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(i-e)/(n-e),h=s+a;s!==h;s+=4)S.slerpFlat(r,0,o,s-a,o,s,c);return r}}),$e.prototype=Object.assign(Object.create(Qu),{constructor:$e,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new Ue(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Ve.prototype=Object.assign(Object.create(Qu),{constructor:Ve,ValueTypeName:"number"}),je.prototype=Object.assign(Object.create(Qu),{constructor:je,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ge.prototype=Object.assign(Object.create(Qu),{constructor:Ge,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),He.prototype=Object.assign(Object.create(Qu),{constructor:He,ValueTypeName:"color"}),We.prototype=Qu,Qu.constructor=We,Object.assign(We,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=We._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var i=[],n=[];Ju.flattenJSON(t.keys,i,n,"value"),t.times=i,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,i=t.constructor;if(void 0!==i.toJSON)e=i.toJSON(t);else{e={name:t.name,times:Ju.convertArray(t.times,Array),values:Ju.convertArray(t.values,Array)};var n=t.getInterpolation();n!==t.DefaultInterpolation&&(e.interpolation=n)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ve;case"vector":case"vector2":case"vector3":case"vector4":return Be;case"color":return He;case"quaternion":return $e;case"bool":case"boolean":return Ge;case"string":return je}throw new Error("Unsupported typeName: "+t)}}),Xe.prototype={constructor:Xe,resetDuration:function(){for(var t=0,e=0,i=this.tracks.length;e!==i;++e){var n=this.tracks[e];t=Math.max(t,n.times[n.times.length-1])}this.duration=t},trim:function(){for(var t=0;t1){var h=n[l=c[1]];h||(n[l]=h=[]),h.push(s)}}var u=[];for(var l in n)u.push(Xe.CreateFromMorphTargetSequence(l,n[l],e,i));return u},parseAnimation:function(t,e,i){if(!t)return null;for(var n=function(t,e,i,n,r){if(0!==i.length){var o=[],a=[];Ju.flattenJSON(i,o,a,n),0!==o.length&&r.push(new t(e,o,a))}},r=[],o=t.name||"default",a=t.length||-1,s=t.fps||30,c=t.hierarchy||[],h=0;h1?t.skinWeights[n+1]:0,s=e>2?t.skinWeights[n+2]:0,c=e>3?t.skinWeights[n+3]:0;i.skinWeights.push(new ct(o,a,s,c))}if(t.skinIndices)for(n=0,r=t.skinIndices.length;n1?t.skinIndices[n+1]:0,l=e>2?t.skinIndices[n+2]:0,d=e>3?t.skinIndices[n+3]:0;i.skinIndices.push(new ct(h,u,l,d))}i.bones=t.bones,i.bones&&i.bones.length>0&&(i.skinWeights.length!==i.skinIndices.length||(i.skinIndices.length,i.vertices.length))}(),function(e){if(void 0!==t.morphTargets)for(var n=0,r=t.morphTargets.length;n0){var u=i.faces,l=t.morphColors[0].colors;for(n=0,r=u.length;n0&&(i.animations=e)}(),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:i};var r=Ze.prototype.initMaterials(t.materials,e,this.crossOrigin);return{geometry:i,materials:r}}}),Object.assign(function(t){this.manager=void 0!==t?t:Ku,this.texturePath=""}.prototype,{load:function(t,e,i,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var r=this;new we(r.manager).load(t,function(t){r.parse(JSON.parse(t),e)},i,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var i=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),r=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,r),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={};if(void 0!==t)for(var i=new Ke,n=new Ye,r=0,o=t.length;r0){var o=new Se(new _e(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new le(s,c):new Yt(s,c);break;case"LOD":a=new se;break;case"Line":a=new fe(r(e.geometry),o(e.material),e.mode);break;case"LineSegments":a=new pe(r(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new ge(r(e.geometry),o(e.material));break;case"Sprite":a=new ae(o(e.material));break;case"Group":a=new ve;break;default:a=new Dt}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(this.parseObject(e.children[h],i,n));if("LOD"===e.type)for(var u=e.levels,l=0;l(h-s)*(d-c)-(u-c)*(l-s))return!1;for(m=l-h,g=d-u,v=s-l,y=c-d,b=h-s,x=u-c,a=0;a=-Number.EPSILON&&w>=-Number.EPSILON&&_>=-Number.EPSILON))return!1;return!0}return function(e,i){var n=e.length;if(n<3)return null;var r,o,a,s=[],c=[],h=[];if(tl.area(e)>0)for(o=0;o2;){if(l--<=0)return i?h:s;if(u<=(r=o)&&(r=0),u<=(o=r+1)&&(o=0),u<=(a=o+1)&&(a=0),t(e,r,o,a,u,c)){var d,f,p,m,g;for(d=c[r],f=c[o],p=c[a],s.push([e[d],e[f],e[p]]),h.push([c[r],c[o],c[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,i){return t.x!==e.x?t.xNumber.EPSILON){var p;if(d>0){if(f<0||f>d)return[];if((p=h*u-c*l)<0||p>d)return[]}else{if(f>0||f0||pS?[]:y===S?o?[]:[g]:b<=S?[g,v]:[g,_])}function o(t,e,i,n){var r=e.x-t.x,o=e.y-t.y,a=i.x-t.x,s=i.y-t.y,c=n.x-t.x,h=n.y-t.y,u=r*s-o*a,l=r*h-o*c;if(Math.abs(u)>Number.EPSILON){var d=c*s-h*a;return u>0?l>=0&&d>=0:l>=0||d>=0}return l>0}i(t),e.forEach(i);for(var a,s,c,h,u,l,d={},f=t.concat(),p=0,m=e.length;pi&&(r=0);var a=o(y[t],y[n],y[r],s[e]);if(!a)return!1;var c=s.length-1,h=e-1;h<0&&(h=c);var u=e+1;return u>c&&(u=0),!!(a=o(s[e],s[h],s[u],y[t]))}function n(t,e){var i,n;for(i=0;i0)return!0;return!1}function a(t,i){var n,o,a,s;for(n=0;n0)return!0;return!1}for(var s,c,h,u,l,d,f,p,m,g,v,y=t.concat(),b=[],x=[],_=0,w=e.length;_0&&!(--A<0);)for(h=S;h=0)break;x[f]=!0}if(c>=0)break}return y}(t,e),v=tl.triangulate(g,!1);for(a=0,s=v.length;a0)){c=r;break}c=r-1}if(n[r=c]===i)return r/(o-1);var h=n[r];return(r+(i-h)/(n[r+1]-h))/(o-1)},getTangent:function(t){var e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);var n=this.getPoint(e);return this.getPoint(i).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)}},Qe.create=function(t,e){return t.prototype=Object.create(Qe.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Je.prototype=Object.create(Qe.prototype),Je.prototype.constructor=Je,Je.prototype.isLineCurve=!0,Je.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},Je.prototype.getPointAt=function(t){return this.getPoint(t)},Je.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},ti.prototype=Object.assign(Object.create(Qe.prototype),{constructor:ti,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 Je(e,t))},getPoint:function(t){for(var e=t*this.getLength(),i=this.getCurveLengths(),n=0;n=e){var r=i[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-r/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,i=0,n=this.curves.length;i1&&!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 Nt,i=0,n=t.length;ie;)i-=e;ie.length-2?e.length-1:n+1],c=e[n>e.length-3?e.length-1:n+2],h=nl;return new x(h(o.x,a.x,s.x,c.x,r),h(o.y,a.y,s.y,c.y,r))},ni.prototype=Object.create(Qe.prototype),ni.prototype.constructor=ni,ni.prototype.getPoint=function(t){var e=tl.b3;return new x(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y))},ni.prototype.getTangent=function(t){var e=il;return new x(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y)).normalize()},ri.prototype=Object.create(Qe.prototype),ri.prototype.constructor=ri,ri.prototype.getPoint=function(t){var e=tl.b2;return new x(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y))},ri.prototype.getTangent=function(t){var e=el;return new x(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y)).normalize()};var rl,ol=Object.assign(Object.create(ti.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,i=t.length;e0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var u=c.getPoint(1);this.currentPoint.copy(u)}});oi.prototype=Object.create(Nt.prototype),oi.prototype.constructor=oi,oi.NoTaper=function(t){return 1},oi.SinusoidalTaper=function(t){return Math.sin(Math.PI*t)},oi.FrenetFrames=function(t,e,i){var n,r,o,a,s,c,h,u=new A,l=[],d=[],f=[],p=new A,m=new w,g=e+1;for(this.tangents=l,this.normals=d,this.binormals=f,c=0;cNumber.EPSILON&&(p.normalize(),n=Math.acos(Du.clamp(l[c-1].dot(l[c]),-1,1)),d[c].applyMatrix4(m.makeRotationAxis(p,n))),f[c].crossVectors(l[c],d[c]);if(i)for(n=Math.acos(Du.clamp(d[0].dot(d[g-1]),-1,1)),n/=g-1,l[0].dot(p.crossVectors(d[0],d[g-1]))>0&&(n=-n),c=1;cNumber.EPSILON){var d=Math.sqrt(u),f=Math.sqrt(c*c+h*h),p=e.x-s/d,m=e.y+a/d,g=((i.x-h/f-p)*h-(i.y+c/f-m)*c)/(a*h-s*c),v=(n=p+a*g-t.x)*n+(r=m+s*g-t.y)*r;if(v<=2)return new x(n,r);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(h)&&(y=!0),y?(n=-s,r=a,o=Math.sqrt(u)):(n=a,r=s,o=Math.sqrt(u/2))}return new x(n/o,r/o)}function r(t,e){var i,n;for(H=t.length;--H>=0;){i=H,(n=H-1)<0&&(n=t.length-1);var r=0,o=b+2*g;for(r=0;r=0;k--){for(z=k/g,B=p*Math.cos(z*Math.PI/2),F=m*Math.sin(z*Math.PI/2),H=0,W=N.length;HNumber.EPSILON){if(h<0&&(a=e[o],c=-c,s=e[r],h=-h),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=h*(t.x-a.x)-c*(t.y-a.y);if(0===u)return!0;if(u<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n}var r=tl.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return i(o);var a,s,c,h=[];if(1===o.length)return s=o[0],(c=new ci).curves=s.curves,h.push(c),h;var u=!r(o[0].getPoints());u=t?!u:u;var l,d=[],f=[],p=[],m=0;f[m]=void 0,p[m]=[];for(var g=0,v=o.length;g1){for(var y=!1,b=[],x=0,_=f.length;x<_;x++)d[x]=[];for(x=0,_=f.length;x<_;x++)for(var w=p[x],S=0;S0&&(y||(p=d))}g=0;for(var C,T=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==r;++o)t[e+o]=t[i+o]},_slerp:function(t,e,i,n,r){S.slerpFlat(t,e,t,e,t,i,n)},_lerp:function(t,e,i,n,r){for(var o=1-n,a=0;a!==r;++a){var s=e+a;t[s]=t[s]*o+t[i+a]*n}}},vi.prototype={constructor:vi,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,n=e.propertyName,r=e.propertyIndex;if(t||(t=vi.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;if(!t.material.materials)return;t=t.material.materials;break;case"bones":if(!t.skeleton)return;t=t.skeleton.bones;for(var a=0;a0)for(var c=this._interpolants,h=this._propertyBindings,u=0,l=c.length;u!==l;++u)c[u].evaluate(a),h[u].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var i=this._weightInterpolant;if(null!==i){var n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var 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,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var i=this._clip.duration,n=this.loop,r=this._loopCount;if(2200===n){-1===r&&(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===n;if(-1===r&&(t>=0?(r=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,r+=Math.abs(a);var s=this.repetitions-r;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=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&r))return this.time=e,i-e}return this.time=e,e},_setEndings:function(t,e,i){var n=this._interpolantSettings;i?(n.endingStart=_u,n.endingEnd=_u):(n.endingStart=t?this.zeroSlopeAtStart?_u:xu:2402,n.endingEnd=e?this.zeroSlopeAtEnd?_u:xu:2402)},_scheduleFading:function(t,e,i){var n=this._mixer,r=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=e,a[1]=r+t,s[1]=i,this}},Object.assign(bi.prototype,b.prototype,{clipAction:function(t,e){var i=e||this._root,n=i.uuid,r="string"==typeof t?Xe.findByName(i,t):t,o=null!==r?r.uuid:t,a=this._actionsByClip[o],s=null;if(void 0!==a){var c=a.actionByRoot[n];if(void 0!==c)return c;s=a.knownActions[0],null===r&&(r=s._clip)}if(null===r)return null;var h=new yi(this,r,e);return this._bindAction(h,s),this._addInactiveAction(h,o,n),h},existingAction:function(t,e){var i=e||this._root,n=i.uuid,r="string"==typeof t?Xe.findByName(i,t):t,o=r?r.uuid:t,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[n]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,i=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==e;++r)t[r].reset();for(r=0;r!==n;++r)i[r].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1,a=0;a!==i;++a){var s=e[a];s.enabled&&s._update(n,t,r,o)}var c=this._bindings,h=this._nActiveBindings;for(a=0;a!==h;++a)c[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){for(var o=r.knownActions,a=0,s=o.length;a!==s;++a){var c=o[a];this._deactivateAction(c);var h=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[i]}},uncacheRoot:function(t){var e=t.uuid,i=this._actionsByClip;for(var n in i){var r=i[n].actionByRoot[e];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}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))}}),Object.assign(bi.prototype,{_bindAction:function(t,e){var i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,o=t._propertyBindings,a=t._interpolants,s=i.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var u=0;u!==r;++u){var l=n[u],d=l.name,f=h[d];if(void 0!==f)o[u]=f;else{if(void 0!==(f=o[u])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,d));continue}var p=e&&e._propertyBindings[u].binding.parsedPath;++(f=new gi(vi.create(i,d,p),l.ValueTypeName,l.getValueSize())).referenceCount,this._addInactiveBinding(f,s,d),o[u]=f}a[u].resultBuffer=f.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}for(var r=t._propertyBindings,o=0,a=r.length;o!==a;++o){var s=r[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,n=e.length;i!==n;++i){var r=e[i];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e.99999?this.quaternion.set(0,0,0,1):i.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(i.z,0,-i.x).normalize(),t=Math.acos(i.y),this.quaternion.setFromAxisAngle(e,t))}}(),Ni.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()},Ni.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},ki.prototype=Object.create(Nt.prototype),ki.prototype.constructor=ki,Fi.prototype=Object.create(ki.prototype),Fi.prototype.constructor=Fi,zi.prototype=Object.create(zt.prototype),zi.prototype.constructor=zi,Bi.prototype=Object.create(zt.prototype),Bi.prototype.constructor=Bi,Ui.prototype=Object.create(zt.prototype),Ui.prototype.constructor=Ui,$i.prototype=Object.create(Nt.prototype),$i.prototype.constructor=$i,Vi.prototype=Object.create(zt.prototype),Vi.prototype.constructor=Vi,ji.prototype=Object.create(Nt.prototype),ji.prototype.constructor=ji,Gi.prototype=Object.create(zt.prototype),Gi.prototype.constructor=Gi,Hi.prototype=Object.create(zt.prototype),Hi.prototype.constructor=Hi,function(){function t(){}var e=new A,i=new t,n=new t,r=new t;t.prototype.init=function(t,e,i,n){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-n,this.c3=2*t-2*e+i+n},t.prototype.initNonuniformCatmullRom=function(t,e,i,n,r,o,a){var s=(e-t)/r-(i-t)/(r+o)+(i-e)/o,c=(i-e)/o-(n-e)/(o+a)+(n-i)/a;s*=o,c*=o,this.init(e,i,s,c)},t.prototype.initCatmullRom=function(t,e,i,n,r){this.init(e,i,r*(i-t),r*(n-e))},t.prototype.calc=function(t){var e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i},Qe.create(function(t){this.points=t||[],this.closed=!1},function(t){var o,a,s,c,h,u,l,d,f=this.points;if(s=(o=((c=f.length)-(this.closed?0:1))*t)-(a=Math.floor(o)),this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/f.length)+1)*f.length:0===s&&a===c-1&&(a=c-2,s=1),this.closed||a>0?h=f[(a-1)%c]:(e.subVectors(f[0],f[1]).add(f[0]),h=e),u=f[a%c],l=f[(a+1)%c],this.closed||a+2e.length-2?e.length-1:n+1],c=e[n>e.length-3?e.length-1:n+2],h=nl;return new A(h(o.x,a.x,s.x,c.x,r),h(o.y,a.y,s.y,c.y,r),h(o.z,a.z,s.z,c.z,r))}),Qe.create(function(t,e,i,n){this.v0=t,this.v1=e,this.v2=i,this.v3=n},function(t){var e=tl.b3;return new A(e(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y),e(t,this.v0.z,this.v1.z,this.v2.z,this.v3.z))}),Qe.create(function(t,e,i){this.v0=t,this.v1=e,this.v2=i},function(t){var e=tl.b2;return new A(e(t,this.v0.x,this.v1.x,this.v2.x),e(t,this.v0.y,this.v1.y,this.v2.y),e(t,this.v0.z,this.v1.z,this.v2.z))}),Qe.create(function(t,e){this.v1=t,this.v2=e},function(t){if(1===t)return this.v2.clone();var e=new A;return e.subVectors(this.v2,this.v1),e.multiplyScalar(t),e.add(this.v1),e}),Object.defineProperty(t,"AudioContext",{get:function(){return t.getAudioContext()}}),Wi.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+"]"}},qi.prototype={VERSION:"1.0.0",memorize:!1,_shouldPropagate:!0,active:!0,_registerListener:function(t,e,i,n){var r,o=this._indexOfListener(t,i);if(-1!==o){if((r=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 r=new Wi(this,t,e,i,n),this._addBinding(r);return this.memorize&&this._prevParams&&r.execute(this._prevParams),r},_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,n=this._bindings.length;n--;)if((i=this._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 Xi(t,"add"),this._registerListener(t,!1,e,i)},addOnce:function(t,e,i){return Xi(t,"addOnce"),this._registerListener(t,!0,e,i)},remove:function(t,e){Xi(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),n=this._bindings.length;if(this.memorize&&(this._prevParams=i),n){e=this._bindings.slice(),this._shouldPropagate=!0;do{n--}while(e[n]&&this._shouldPropagate&&!1!==e[n].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 cl=1,hl=2,ul=3,ll=4,dl=5,fl=6,pl=7,ml=8,gl=9,vl=10,yl=11,bl=12,xl=13,_l=14;Yi.prototype={constructor:Yi,type:"selection",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)}},parse:function(t){if(this.selection={operator:void 0,rules:[]},t){var e,i,n=this,r=this.selection,o=[];"("===(t=t.replace(/\(/g," ( ").replace(/\)/g," ) ").trim()).charAt(0)&&")"===t.substr(-1)&&(t=t.slice(1,-1).trim());var a,s,c,h,u,l,d,f,p,m,g=t.split(/\s+/),v=["*","","ALL"],y=function(t){e={operator:t,rules:[]},void 0===r?(r=e,n.selection=e):(r.rules.push(e),o.push(r),r=e)},b=function(t){i=r,void 0===(r=o.pop())&&(y(t),x(i))},x=function(t){r.rules.push(t)};for(c=0;c0)if("NOT"===a.toUpperCase())h=1;else if(1===h)h=2;else{if(2!==h)throw new Error("something went wrong with 'not'");h=!1,b()}if("AND"!==a.toUpperCase())if("OR"!==a.toUpperCase())if("NOT"!==a.toUpperCase())if(s={},"HETERO"!==a.toUpperCase())if("WATER"!==a.toUpperCase())if("PROTEIN"!==a.toUpperCase())if("NUCLEIC"!==a.toUpperCase())if("RNA"!==a.toUpperCase())if("DNA"!==a.toUpperCase())if("POLYMER"!==a.toUpperCase())if("ION"!==a.toUpperCase())if("SACCHARIDE"!==a.toUpperCase()&&"SUGAR"!==a.toUpperCase())if("HYDROGEN"!==a.toUpperCase())if("SMALL"!==a.toUpperCase())if("NUCLEOPHILIC"!==a.toUpperCase())if("HYDROPHOBIC"!==a.toUpperCase())if("AROMATIC"!==a.toUpperCase())if("AMIDE"!==a.toUpperCase())if("ACIDIC"!==a.toUpperCase())if("BASIC"!==a.toUpperCase())if("CHARGED"!==a.toUpperCase())if("POLAR"!==a.toUpperCase())if("NONPOLAR"!==a.toUpperCase())if("HELIX"!==a.toUpperCase())if("SHEET"!==a.toUpperCase())if("TURN"!==a.toUpperCase())if("BACKBONE"!==a.toUpperCase())if("SIDECHAIN"!==a.toUpperCase())if("SIDECHAINATTACHED"!==a.toUpperCase())if(-1===v.indexOf(a.toUpperCase()))if("@"!==a.charAt(0))if("#"!==a.charAt(0))if("["!==a[0]||"]"!==a[a.length-1])if(a.length>=1&&a.length<=4&&"^"!==a[0]&&":"!==a[0]&&"."!==a[0]&&"%"!==a[0]&&"/"!==a[0]&&isNaN(parseInt(a)))s.resname=a.toUpperCase(),x(s);else{if(s={operator:"AND",rules:[]},(d=a.split("/")).length>1&&d[1]){if(isNaN(parseInt(d[1])))throw new Error("model must be an integer");s.rules.push({model:parseInt(d[1])})}if((p=d[0].split("%")).length>1&&s.rules.push({altloc:p[1]}),(u=p[0].split(".")).length>1&&u[1]){if(u[1].length>4)throw new Error("atomname must be one to four characters");s.rules.push({atomname:u[1].substring(0,4).toUpperCase()})}var _,w;if((l=u[0].split(":")).length>1&&l[1]&&s.rules.push({chainname:l[1]}),(m=l[0].split("^")).length>1&&s.rules.push({inscode:m[1]}),m[0])if("-"===m[0][0]&&(m[0]=m[0].substr(1),_=!0),m[0].includes("--")&&(m[0]=m[0].replace("--","-"),w=!0),1===(f=m[0].split("-")).length){if(f=parseInt(f[0]),isNaN(f))throw new Error("resi must be an integer");_&&(f*=-1),s.rules.push({resno:f})}else{if(2!==f.length)throw new Error("resi range must contain one '-'");_&&(f[0]*=-1),w&&(f[1]*=-1),s.rules.push({resno:[parseInt(f[0]),parseInt(f[1])]})}if(1===s.rules.length)x(s.rules[0]);else{if(!(s.rules.length>1))throw new Error("empty selection chunk");x(s)}}else s.resname=a.substr(1,a.length-2).toUpperCase(),x(s);else s.element=a.substr(1).toUpperCase(),x(s);else{for(var S=a.substr(1).split(","),A=0,M=S.length;A0?e:null},makeAtomTest:function(t){var e,i=["h","g","i"],n=["e","b"];e=t?this._filter(function(t){return void 0!==t.keyword&&t.keyword!==gl&&t.keyword!==vl||void 0!==t.model||void 0!==t.chainname||void 0!==t.resname||void 0!==t.resno||void 0!==t.sstruc}):this.selection;return this._makeTest(function(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===gl&&!t.isBackbone())return!1;if(e.keyword===vl&&!t.isSidechain())return!1;if(e.keyword===bl&&!t.isHetero())return!1;if(e.keyword===cl&&!t.isProtein())return!1;if(e.keyword===hl&&!t.isNucleic())return!1;if(e.keyword===ul&&!t.isRna())return!1;if(e.keyword===ll&&!t.isDna())return!1;if(e.keyword===dl&&!t.isPolymer())return!1;if(e.keyword===fl&&!t.isWater())return!1;if(e.keyword===pl&&-1===i.indexOf(t.sstruc))return!1;if(e.keyword===ml&&-1===n.indexOf(t.sstruc))return!1;if(e.keyword===xl&&!t.isIon())return!1;if(e.keyword===_l&&!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&&Lc(e.atomindex,t.index)<0)return!1;if(void 0!==e.resname&&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]e.atomindexLast||t.atomEndt.resno||e.resno[1]e.atomindexLast||t.atomEnde.atomindexLast||t.atomEnd>=4,i[r]=e[19===r?3&t|8:t]);return i.join("")}}(),Sl=0,Al=1,Ml=2,Pl=3,Cl=4,Tl=1,El=2,Il=3,Ll=4,Ol=5,Rl=6,Dl=0,Nl=["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"],kl=["RNA OH 3 PRIME TERMINUS","RNA OH 5 PRIME TERMINUS","RNA LINKING"],Fl=["DNA OH 3 PRIME TERMINUS","DNA OH 5 PRIME TERMINUS","DNA LINKING","L-DNA LINKING","L-RNA LINKING"],zl=["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"],Bl=["NON-POLYMER"].concat(["OTHER"],zl),Ul={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},$l={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},Vl={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]},jl=[0,0,0],Gl={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:""},Hl=Object.keys(Gl),Wl=["A","C","T","G","U"],Xl=["DA","DC","DT","DG","DU","TCY","MCY","5CM"],ql=["A","G","DA","DG"],Yl=["SOL","WAT","HOH","H2O","W","DOD","D3O","TIP3","TIP4"],Zl=["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"],Kl=["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"],Ql=["CA","C","N","O","O1","O2","OC1","OC2","OX1","OXT","H","H1","H2","H3","HA","BB"],Jl=["P","O3'","O5'","C5'","C4'","C3'","OP1","OP2","O3*","O5*","C5*","C4*","C3*"],td={1:{trace:"CA",direction1:"C",direction2:["O","OC1","O1","OX1","OXT"],backboneStart:"N",backboneEnd:"C"},2:{trace:["C4'","C4*"],direction1:["C1'","C1*"],direction2:["C3'","C3*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},3:{trace:["C3'","C3*"],direction1:["C2'","C2*"],direction2:["O4'","O4*"],backboneStart:"P",backboneEnd:["O3'","O3*"]},4:{trace:["CA","BB"],backboneStart:["CA","BB"],backboneEnd:["CA","BB"]},5:{trace:["C4'","C4*","P"],backboneStart:["C4'","C4*","P"],backboneEnd:["C4'","C4*","P"]},6:{trace:["C3'","C3*","C2'","P"],backboneStart:["C3'","C3*","C2'","P"],backboneEnd:["C3'","C3*","C2'","P"]}};td[Dl]={};var ed,id,nd,rd,od,ad,sd,cd,hd,ud,ld,dd,fd,pd,md,gd,vd,yd,bd,xd,_d,wd,Sd,Ad,Md,Pd,Cd,Td,Ed,Id,Ld,Od,Rd,Dd,Nd,kd,Fd,zd,Bd,Ud,$d,Vd,jd,Gd,Hd,Wd,Xd,qd,Yd,Zd,Kd,Qd,Jd,tf,ef,nf,rf,of,af,sf,cf,hf,uf,lf,df,ff,pf,mf,gf,vf,yf,bf,xf,_f,wf,Sf=[].slice;yf=function(){var t,e,i,n,r;for(t={},n=0,e=(r="Boolean Number String Function Array Date RegExp Undefined Null".split(" ")).length;ni&&(t=i),t},bf=function(t){return t.length>=3?[].slice.call(t):t[0]},bd=function(t){var e;for(e in t)e<3?(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},rd=Math.PI,ff=Math.round,_d=Math.cos,Pd=Math.floor,Kd=Math.pow,Gd=Math.log,mf=Math.sin,gf=Math.sqrt,fd=Math.atan2,Xd=Math.max,dd=Math.abs,sd=2*rd,od=rd/3,id=rd/180,ad=180/rd,ld=[],(yd=function(){return arguments[0]instanceof ed?arguments[0]:function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,arguments,function(){})}).version="1.1.1",ud={},cd=[],hd=!1,ed=function(){function t(){var t,e,i,n,r,o,a,s,c;for(o=this,e=[],s=0,n=arguments.length;s3?e[3]:1]},wf=function(t){return ff(255*(t<=.00304?12.92*t:1.055*Kd(t,1/2.4)-.055))},Bd=function(t){return t>nd.t1?t*t*t:nd.t2*(t-nd.t0)},nd={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},of=function(){var t,e,i,n,r,o,a;return i=(n=bf(arguments))[0],e=n[1],t=n[2],o=(r=uf(i,e,t))[0],[116*(a=r[1])-16,500*(o-a),200*(a-r[2])]},lf=function(t){return(t/=255)<=.04045?t/12.92:Kd((t+.055)/1.055,2.4)},_f=function(t){return t>nd.t3?Kd(t,1/3):t/nd.t2+nd.t0},uf=function(){var t,e,i,n;return i=(n=bf(arguments))[0],e=n[1],t=n[2],i=lf(i),e=lf(e),t=lf(t),[_f((.4124564*i+.3575761*e+.1804375*t)/nd.Xn),_f((.2126729*i+.7151522*e+.072175*t)/nd.Yn),_f((.0193339*i+.119192*e+.9503041*t)/nd.Zn)]},yd.lab=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["lab"]),function(){})},ud.lab=zd,ed.prototype.lab=function(){return of(this._rgb)},pd=function(t){var e,i,n,r,o,a,s,c,h,u,l;return 2===(t=function(){var e,i,n;for(n=[],i=0,e=t.length;i=0&&e[3]<=1?"rgb":void 0}}),Cd=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,ff((255&i)/255*100)/100];if(null!=ud.css&&(e=ud.css(t)))return e;throw"unknown color: "+t},tf=function(t,e){var i,n,r,o,a,s;return null==e&&(e="rgb"),a=t[0],r=t[1],n=t[2],i=t[3],s=(s="000000"+(a<<16|r<<8|n).toString(16)).substr(s.length-6),o=(o="0"+ff(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}}()},ud.hex=function(t){return Cd(t)},yd.hex=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["hex"]),function(){})},ed.prototype.hex=function(t){return null==t&&(t="rgb"),tf(this._rgb,t)},cd.push({p:10,test:function(t){if(1===arguments.length&&"string"===yf(t))return"hex"}}),Id=function(){var t,e,i,n,r,o,a,s,c,h,u,l,d,f;if(r=(t=bf(arguments))[0],u=t[1],a=t[2],0===u)c=n=e=255*a;else{for(f=[0,0,0],i=[0,0,0],l=2*a-(d=a<.5?a*(1+u):a+u-a*u),r/=360,f[0]=r+1/3,f[1]=r,f[2]=r-1/3,o=s=0;s<=2;o=++s)f[o]<0&&(f[o]+=1),f[o]>1&&(f[o]-=1),6*f[o]<1?i[o]=l+6*(d-l)*f[o]:2*f[o]<1?i[o]=d:3*f[o]<2?i[o]=l+(d-l)*(2/3-f[o])*6:i[o]=l;c=(h=[ff(255*i[0]),ff(255*i[1]),ff(255*i[2])])[0],n=h[1],e=h[2]}return t.length>3?[c,n,e,t[3]]:[c,n,e]},nf=function(t,e,i){var n,r,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),r=((Xd=Math.max(t,e,i))+o)/2,Xd===o?(s=0,n=Number.NaN):s=r<.5?(Xd-o)/(Xd+o):(Xd-o)/(2-Xd-o),t===Xd?n=(e-i)/(Xd-o):e===Xd?n=2+(i-t)/(Xd-o):i===Xd&&(n=4+(t-e)/(Xd-o)),(n*=60)<0&&(n+=360),[n,s,r]},yd.hsl=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["hsl"]),function(){})},ud.hsl=Id,ed.prototype.hsl=function(){return nf(this._rgb)},Ld=function(){var t,e,i,n,r,o,a,s,c,h,u,l,d,f,p,m,g,v;if(r=(t=bf(arguments))[0],m=t[1],v=t[2],v*=255,0===m)c=n=e=v;else switch(360===r&&(r=0),r>360&&(r-=360),r<0&&(r+=360),r/=60,o=Pd(r),i=r-o,a=v*(1-m),s=v*(1-m*i),g=v*(1-m*(1-i)),o){case 0:c=(h=[v,g,a])[0],n=h[1],e=h[2];break;case 1:c=(u=[s,v,a])[0],n=u[1],e=u[2];break;case 2:c=(l=[a,v,g])[0],n=l[1],e=l[2];break;case 3:c=(d=[a,s,v])[0],n=d[1],e=d[2];break;case 4:c=(f=[g,a,v])[0],n=f[1],e=f[2];break;case 5:c=(p=[v,a,s])[0],n=p[1],e=p[2]}return[c=ff(c),n=ff(n),e=ff(e),t.length>3?t[3]:1]},rf=function(){var t,e,i,n,r,o,a,s,c;return o=(a=bf(arguments))[0],i=a[1],t=a[2],r=Math.min(o,i,t),e=(Xd=Math.max(o,i,t))-r,c=Xd/255,0===Xd?(n=Number.NaN,s=0):(s=e/Xd,o===Xd&&(n=(i-t)/e),i===Xd&&(n=2+(t-o)/e),t===Xd&&(n=4+(o-i)/e),(n*=60)<0&&(n+=360)),[n,s,c]},yd.hsv=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["hsv"]),function(){})},ud.hsv=Ld,ed.prototype.hsv=function(){return rf(this._rgb)},Yd=function(t){return"number"===yf(t)&&t>=0&&t<=16777215?[t>>16,t>>8&255,255&t,1]:[0,0,0,1]},cf=function(){var t;return((t=bf(arguments))[0]<<16)+(t[1]<<8)+t[2]},yd.num=function(t){return new ed(t,"num")},ed.prototype.num=function(t){return null==t&&(t="rgb"),cf(this._rgb,t)},ud.num=Yd,cd.push({p:10,test:function(t){if(1===arguments.length&&"number"===yf(t)&&t>=0&&t<=16777215)return"num"}}),wd=function(t){var e,i,n,r,o,a,s,c;if(t=t.toLowerCase(),null!=yd.colors&&yd.colors[t])return Cd(yd.colors[t]);if(o=t.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(s=o.slice(1,4),r=a=0;a<=2;r=++a)s[r]=+s[r];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),r=c=0;c<=3;r=++c)s[r]=+s[r];else if(o=t.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(s=o.slice(1,4),r=e=0;e<=2;r=++e)s[r]=ff(2.55*s[r]);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),r=i=0;i<=2;r=++i)s[r]=ff(2.55*s[r]);s[3]=+s[3]}else(o=t.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?((n=o.slice(1,4))[1]*=.01,n[2]*=.01,(s=Id(n))[3]=1):(o=t.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&((n=o.slice(1,4))[1]*=.01,n[2]*=.01,(s=Id(n))[3]=+o[4]);return s},Jd=function(t){var e;return"rgb"===(e=t[3]<1?"rgba":"rgb")?e+"("+t.slice(0,3).map(ff).join(",")+")":"rgba"===e?e+"("+t.slice(0,3).map(ff).join(",")+","+t[3]+")":void 0},df=function(t){return ff(100*t)/100},Ed=function(t,e){var i;return i=e<1?"hsla":"hsl",t[0]=df(t[0]||0),t[1]=df(100*t[1])+"%",t[2]=df(100*t[2])+"%","hsla"===i&&(t[3]=e),i+"("+t.join(",")+")"},ud.css=function(t){return wd(t)},yd.css=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["css"]),function(){})},ed.prototype.css=function(t){return null==t&&(t="rgb"),"rgb"===t.slice(0,3)?Jd(this._rgb):"hsl"===t.slice(0,3)?Ed(this.hsl(),this.alpha()):void 0},ud.named=function(t){return Cd(xf[t])},cd.push({p:20,test:function(t){if(1===arguments.length&&null!=xf[t])return"named"}}),ed.prototype.name=function(t){var e,i;for(i in arguments.length&&(xf[t]&&(this._rgb=Cd(xf[t])),this._rgb[3]=1),e=this.hex(),xf)if(e===xf[i])return i;return e},Ud=function(){var t,e,i,n;return i=(n=bf(arguments))[0],t=n[1],e=n[2],[i,_d(e*=id)*t,mf(e)*t]},$d=function(){var t,e,i,n,r,o,a,s,c,h,u;return s=(i=bf(arguments))[0],r=i[1],a=i[2],t=(h=Ud(s,r,a))[0],e=h[1],n=h[2],c=(u=zd(t,e,n))[0],o=u[1],n=u[2],[jd(c,0,255),jd(o,0,255),jd(n,0,255),i.length>3?i[3]:1]},Fd=function(){var t,e,i,n,r,o;return r=(o=bf(arguments))[0],t=o[1],e=o[2],i=gf(t*t+e*e),n=(fd(e,t)*ad+360)%360,0===ff(1e4*i)&&(n=Number.NaN),[r,i,n]},af=function(){var t,e,i,n,r,o,a;return r=(o=bf(arguments))[0],i=o[1],e=o[2],n=(a=of(r,i,e))[0],t=a[1],e=a[2],Fd(n,t,e)},yd.lch=function(){var t;return t=bf(arguments),new ed(t,"lch")},yd.hcl=function(){var t;return t=bf(arguments),new ed(t,"hcl")},ud.lch=$d,ud.hcl=function(){var t,e,i,n;return e=(n=bf(arguments))[0],t=n[1],i=n[2],$d([i,t,e])},ed.prototype.lch=function(){return af(this._rgb)},ed.prototype.hcl=function(){return af(this._rgb).reverse()},Qd=function(t){var e,i,n,r,o,a;return null==t&&(t="rgb"),o=(a=bf(arguments))[0],n=a[1],e=a[2],n/=255,e/=255,[(1-(o/=255)-(r=1-Math.max(o,Math.max(n,e))))*(i=r<1?1/(1-r):0),(1-n-r)*i,(1-e-r)*i,r]},xd=function(){var t,e,i,n,r,o;return i=(e=bf(arguments))[0],r=e[1],o=e[2],n=e[3],t=e.length>4?e[4]:1,1===n?[0,0,0,t]:[i>=1?0:ff(255*(1-i)*(1-n)),r>=1?0:ff(255*(1-r)*(1-n)),o>=1?0:ff(255*(1-o)*(1-n)),t]},ud.cmyk=function(){return xd(bf(arguments))},yd.cmyk=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["cmyk"]),function(){})},ed.prototype.cmyk=function(){return Qd(this._rgb)},ud.gl=function(){var t,e,i,n,r;for(n=function(){var t,i;for(e in i=[],t=bf(arguments))r=t[e],i.push(r);return i}.apply(this,arguments),t=i=0;i<=2;t=++i)n[t]*=255;return n},yd.gl=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["gl"]),function(){})},ed.prototype.gl=function(){var t;return[(t=this._rgb)[0]/255,t[1]/255,t[2]/255,t[3]]},sf=function(t,e,i){var n;return t=(n=bf(arguments))[0],e=n[1],i=n[2],.2126*(t=Hd(t))+.7152*(e=Hd(e))+.0722*(i=Hd(i))},Hd=function(t){return(t/=255)<=.03928?t/12.92:Kd((t+.055)/1.055,2.4)},ld=[],yd.interpolate=Od=function(t,e,i,n){var r,o,a,s;for(null==i&&(i=.5),null==n&&(n="rgb"),"object"!==yf(t)&&(t=yd(t)),"object"!==yf(e)&&(e=yd(e)),a=0,o=ld.length;at?o(i,c):o(c,a)},i=sf(this._rgb),this._rgb=(i>t?o(yd("black"),this):o(this,yd("white"))).rgba()),this):sf(this._rgb)},vf=function(t){var e,i,n,r;return(r=t/100)<66?(n=255,i=-155.25485562709179-.44596950469579133*(i=r-2)+104.49216199393888*Gd(i),e=r<20?0:.8274096064007395*(e=r-10)-254.76935184120902+115.67994401066147*Gd(e)):(n=351.97690566805693+.114206453784165*(n=r-55)-40.25366309332127*Gd(n),i=325.4494125711974+.07943456536662342*(i=r-50)-28.0852963507957*Gd(i),e=255),bd([n,i,e])},hf=function(){var t,e,i,n,r,o,a;for(n=(r=bf(arguments))[0],r[1],t=r[2],i=1e3,e=4e4,.4;e-i>.4;)(o=vf(a=.5*(e+i)))[2]/o[0]>=t/n?e=a:i=a;return ff(a)},yd.temperature=yd.kelvin=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["temperature"]),function(){})},ud.temperature=ud.kelvin=ud.K=vf,ed.prototype.temperature=function(){return hf(this._rgb)},ed.prototype.kelvin=ed.prototype.temperature,yd.contrast=function(t,e){var i,n,r,o;return"string"!==(r=yf(t))&&"number"!==r||(t=new ed(t)),"string"!==(o=yf(e))&&"number"!==o||(e=new ed(e)),(i=t.luminance())>(n=e.luminance())?(i+.05)/(n+.05):(n+.05)/(i+.05)},ed.prototype.get=function(t){var e,i,n,r,o;return this,n=(r=t.split("."))[0],e=r[1],o=this[n](),e?(i=n.indexOf(e))>-1?o[i]:void 0:o},ed.prototype.set=function(t,e){var i,n,r,o,a,s;if(r=this,o=(a=t.split("."))[0],i=a[1]){if(s=r[o](),(n=o.indexOf(i))>-1)if("string"===yf(e))switch(e.charAt(0)){case"+":case"-":s[n]+=+e;break;case"*":s[n]*=+e.substr(1);break;case"/":s[n]/=+e.substr(1);break;default:s[n]=+e}else s[n]=e}else s=e;return r._rgb=yd(s,o).alpha(r.alpha())._rgb,r},ed.prototype.darken=function(t){var e,i;return null==t&&(t=1),(e=(i=this).lab())[0]-=nd.Kn*t,yd.lab(e).alpha(i.alpha())},ed.prototype.brighten=function(t){return null==t&&(t=1),this.darken(-t)},ed.prototype.darker=ed.prototype.darken,ed.prototype.brighter=ed.prototype.brighten,ed.prototype.saturate=function(t){var e,i;return null==t&&(t=1),(e=(i=this).lch())[1]+=t*nd.Kn,e[1]<0&&(e[1]=0),yd.lch(e).alpha(i.alpha())},ed.prototype.desaturate=function(t){return null==t&&(t=1),this.saturate(-t)},ed.prototype.premultiply=function(){var t,e;return e=this.rgb(),t=this.alpha(),yd(e[0]*t,e[1]*t,e[2]*t,t)},qd=function(t,e){return t*e/255},Sd=function(t,e){return t>e?e:t},Vd=function(t,e){return t>e?t:e},pf=function(t,e){return 255*(1-(1-t/255)*(1-e/255))},Zd=function(t,e){return e<128?2*t*e/255:255*(1-2*(1-t/255)*(1-e/255))},vd=function(t,e){return 255*(1-(1-e/255)/(t/255))},Ad=function(t,e){return 255===t?255:(t=e/255*255/(1-t/255))>255?255:t},(md=function(t,e,i){if(!md[i])throw"unknown blend mode "+i;return md[i](t,e)}).normal=(gd=function(t){return function(e,i){var n,r;return n=yd(i).rgb(),r=yd(e).rgb(),yd(t(n,r),"rgb")}})((Md=function(t){return function(e,i){var n,r,o;for(o=[],n=r=0;r<=3;n=++r)o[n]=t(e[n],i[n]);return o}})(function(t,e){return t})),md.multiply=gd(Md(qd)),md.screen=gd(Md(pf)),md.overlay=gd(Md(Zd)),md.darken=gd(Md(Sd)),md.lighten=gd(Md(Vd)),md.dodge=gd(Md(Ad)),md.burn=gd(Md(vd)),yd.blend=md,yd.analyze=function(t){var e,i,n,r;for(n={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},i=0,e=t.length;in.max&&(n.max=r),n.count+=1);return n.domain=[n.min,n.max],n.limits=function(t,e){return yd.limits(n,t,e)},n},yd.scale=function(t,e){var i,n,r,o,a,s,c,h,u,l,d,f,p,m,g,v,y,b,x;return h="rgb",u=yd("#ccc"),p=0,!1,a=[0,1],f=[],d=[0,0],i=!1,r=[],l=!1,c=0,s=1,o=!1,n={},b=function(t){var e,i,n,o,a,s,c;if(null==t&&(t=["#fff","#000"]),null!=t&&"string"===yf(t)&&null!=(null!=(o=yd.brewer)?o[t]:void 0)&&(t=yd.brewer[t]),"array"===yf(t)){for(e=n=0,a=(t=t.slice(0)).length-1;0<=a?n<=a:n>=a;e=0<=a?++n:--n)i=t[e],"string"===yf(i)&&(t[e]=yd(i));for(f.length=0,e=c=0,s=t.length-1;0<=s?c<=s:c>=s;e=0<=s?++c:--c)f.push(e/(t.length-1))}return y(),r=t},g=function(t){var e,n;if(null!=i){for(n=i.length-1,e=0;e=i[e];)e++;return e-1}return 0},x=function(t){return t},function(t){var e,n,r,o,a;return a=t,i.length>2&&(o=i.length-1,e=g(t),r=i[0]+(i[1]-i[0])*(0+.5*p),n=i[o-1]+(i[o]-i[o-1])*(1-.5*p),a=c+(i[e]+.5*(i[e+1]-i[e])-r)/(n-r)*(s-c)),a},v=function(t,e){var o,a,l,p,m,v,y;if(null==e&&(e=!1),isNaN(t))return u;if(e?y=t:i&&i.length>2?(y=g(t)/(i.length-2),y=d[0]+y*(1-d[0]-d[1])):s!==c?(y=(t-c)/(s-c),y=d[0]+y*(1-d[0]-d[1]),y=Math.min(1,Math.max(0,y))):y=1,e||(y=x(y)),l=Math.floor(1e4*y),n[l])o=n[l];else{if("array"===yf(r))for(a=p=0,v=f.length-1;0<=v?p<=v:p>=v;a=0<=v?++p:--p){if(y<=(m=f[a])){o=r[a];break}if(y>=m&&a===f.length-1){o=r[a];break}if(y>m&&y=u;e=0<=u?++l:--l)f.push(e/(n-1));return a=[c,s],m},m.mode=function(t){return arguments.length?(h=t,y(),m):h},m.range=function(t,e){return b(t),m},m.out=function(t){return l=t,m},m.spread=function(t){return arguments.length?(p=t,m):p},m.correctLightness=function(t){return null==t&&(t=!0),o=t,y(),x=o?function(t){var e,i,n,r,o,a,s,c,h;for(e=v(0,!0).lab()[0],i=v(1,!0).lab()[0],s=e>i,n=v(t,!0).lab()[0],r=n-(o=e+(i-e)*t),c=0,h=1,a=20;Math.abs(r)>.01&&a-- >0;)s&&(r*=-1),r<0?(c=t,t+=.5*(h-t)):(h=t,t+=.5*(c-t)),n=v(t,!0).lab()[0],r=n-o;return t}:function(t){return t},m},m.padding=function(t){return null!=t?("number"===yf(t)&&(t=[t,t]),d=t,m):d},m.colors=function(){var e,n,r,o,s,c,h,u,l;if(o=0,s="hex",1===arguments.length&&("string"===yf(arguments[0])?s=arguments[0]:o=arguments[0]),2===arguments.length&&(o=arguments[0],s=arguments[1]),o)return n=a[0],e=a[1]-n,function(){h=[];for(var t=0;0<=o?to;0<=o?t++:t--)h.push(t);return h}.apply(this).map(function(t){return m(n+t/(o-1)*e)[s]()});if(t=[],u=[],i&&i.length>2)for(r=l=1,c=i.length;1<=c?lc;r=1<=c?++l:--l)u.push(.5*(i[r-1]+i[r]));else u=a;return u.map(function(t){return m(t)[s]()})},m},null==yd.scales&&(yd.scales={}),yd.scales.cool=function(){return yd.scale([yd.hsl(180,1,.9),yd.hsl(250,.7,.4)])},yd.scales.hot=function(){return yd.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},yd.analyze=function(t,e,i){var n,r,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}),n=function(t){null==t||isNaN(t)||(s.values.push(t),s.sum+=t,ts.max&&(s.max=t),s.count+=1)},c=function(t,r){if(i(t,r))return n(null!=e&&"function"===yf(e)?e(t):null!=e&&"string"===yf(e)||"number"===yf(e)?t[e]:t)},"array"===yf(t))for(a=0,o=t.length;a=F;w=1<=F?++R:--R)M.push(C+w/i*(Xd-C));M.push(Xd)}else if("l"===e.substr(0,1)){if(C<=0)throw"Logarithmic scales are only possible for values > 0";for(T=Math.LOG10E*Gd(C),P=Math.LOG10E*Gd(Xd),M.push(C),w=it=1,z=i-1;1<=z?it<=z:it>=z;w=1<=z?++it:--it)M.push(Kd(10,T+w/i*(P-T)));M.push(Xd)}else if("q"===e.substr(0,1)){for(M.push(C),w=n=1,G=i-1;1<=G?n<=G:n>=G;w=1<=G?++n:--n)D=et.length*w/i,(N=Pd(D))===D?M.push(et[N]):(k=D-N,M.push(et[N]*k+et[N+1]*(1-k)));M.push(Xd)}else if("k"===e.substr(0,1)){for(I=et.length,g=new Array(I),x=new Array(i),Q=!0,L=0,y=null,(y=[]).push(C),w=r=1,H=i-1;1<=H?r<=H:r>=H;w=1<=H?++r:--r)y.push(C+w/i*(Xd-C));for(y.push(Xd);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(tt=et[w],E=Number.MAX_VALUE,S=s=0,q=i-1;0<=q?s<=q:s>=q;S=0<=q?++s:--s)(_=dd(y[S]-tt))=Y;S=0<=Y?++c:--c)O[S]=null;for(w=h=0,Z=I-1;0<=Z?h<=Z:h>=Z;w=0<=Z?++h:--h)null===O[b=g[w]]?O[b]=et[w]:O[b]+=et[w];for(S=u=0,K=i-1;0<=K?u<=K:u>=K;S=0<=K?++u:--u)O[S]*=1/x[S];for(Q=!1,S=l=0,B=i-1;0<=B?l<=B:l>=B;S=0<=B?++l:--l)if(O[S]!==y[w]){Q=!0;break}y=O,++L>200&&(Q=!1)}for(A={},S=d=0,U=i-1;0<=U?d<=U:d>=U;S=0<=U?++d:--d)A[S]=[];for(w=f=0,$=I-1;0<=$?f<=$:f>=$;w=0<=$?++f:--f)A[b=g[w]].push(et[w]);for(J=[],S=p=0,V=i-1;0<=V?p<=V:p>=V;S=0<=V?++p:--p)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,j=J.length-1;m<=j;w=m+=2)isNaN(J[w])||M.push(J[w])}return M},Td=function(t,e,i){var n,r,o,a;return t=(n=bf(arguments))[0],e=n[1],i=n[2],(t/=360)<1/3?o=1-((r=(1-e)/3)+(a=(1+e*_d(sd*t)/_d(od-sd*t))/3)):t<2/3?r=1-((a=(1-e)/3)+(o=(1+e*_d(sd*(t-=1/3))/_d(od-sd*t))/3)):a=1-((o=(1-e)/3)+(r=(1+e*_d(sd*(t-=2/3))/_d(od-sd*t))/3)),[255*(a=jd(i*a*3)),255*(o=jd(i*o*3)),255*(r=jd(i*r*3)),n.length>3?n[3]:1]},ef=function(){var t,e,i,n,r,o,a;return r=(o=bf(arguments))[0],e=o[1],t=o[2],sd=2*Math.PI,r/=255,e/=255,t/=255,0===(a=1-Math.min(r,e,t)/(n=(r+e+t)/3))?i=0:(i=(r-e+(r-t))/2,i/=Math.sqrt((r-e)*(r-e)+(r-t)*(e-t)),i=Math.acos(i),t>e&&(i=sd-i),i/=sd),[360*i,a,n]},yd.hsi=function(){return function(t,e,i){i.prototype=t.prototype;var n=new i,r=t.apply(n,e);return Object(r)===r?r:n}(ed,Sf.call(arguments).concat(["hsi"]),function(){})},ud.hsi=Td,ed.prototype.hsi=function(){return ef(this._rgb)},Rd=function(t,e,i,n){var r,o,a,s,c,h,u,l,d,f;return"hsl"===n?(d=t.hsl(),f=e.hsl()):"hsv"===n?(d=t.hsv(),f=e.hsv()):"hsi"===n?(d=t.hsi(),f=e.hsi()):"lch"!==n&&"hcl"!==n||(n="hcl",d=t.hcl(),f=e.hcl()),"h"===n.substr(0,1)&&(o=d[0],u=d[1],s=d[2],a=f[0],l=f[1],c=f[2]),isNaN(o)||isNaN(a)?isNaN(o)?isNaN(a)?r=Number.NaN:(r=a,1!==s&&0!==s||"hsv"===n||(h=l)):(r=o,1!==c&&0!==c||"hsv"===n||(h=u)):r=o+i*(a>o&&a-o>180?a-(o+360):a180?a+360-o:a-o),null==h&&(h=u+i*(l-u)),yd[n](r,h,s+i*(c-s))},Nd=function(t,e,i,n){var r,o;return r=t.num(),o=e.num(),yd.num(r+(o-r)*i,"num")},(ld=ld.concat(function(){var t,e,i,n;for(n=[],e=0,t=(i=["hsv","hsl","hsi","hcl","lch"]).length;e>16&255)/255,e[i+1]=(t>>8&255)/255,e[i+2]=(255&t)/255,e},atomColor:function(){return 16777215},atomColorToArray:function(t,e,i){return this.colorToArray(this.atomColor(t),e,i)},bondColor:function(t,e){return this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)},bondColorToArray:function(t,e,i,n){return this.colorToArray(this.bondColor(t,e),i,n)},volumeColor:function(){return 16777215},volumeColorToArray:function(t,e,i){return this.colorToArray(this.volumeColor(t),e,i)},positionColor:function(){return 16777215},positionColorToArray:function(t,e,i){return this.colorToArray(this.positionColor(t),e,i)}},tn.prototype=Ji.prototype,tn.prototype.constructor=tn,en.prototype=Ji.prototype,en.prototype.constructor=en,nn.prototype=Ji.prototype,nn.prototype.constructor=nn,rn.prototype=Ji.prototype,rn.prototype.constructor=rn,on.prototype=Ji.prototype,on.prototype.constructor=on,an.prototype=Ji.prototype,an.prototype.constructor=an,sn.prototype=Ji.prototype,sn.prototype.constructor=sn,cn.prototype=Ji.prototype,cn.prototype.constructor=cn,hn.prototype=Ji.prototype,hn.prototype.constructor=hn,un.prototype=Ji.prototype,un.prototype.constructor=un,ln.prototype=Ji.prototype,ln.prototype.constructor=ln,dn.prototype=Ji.prototype,dn.prototype.constructor=dn,fn.prototype=Ji.prototype,fn.prototype.constructor=fn,pn.prototype=Ji.prototype,pn.prototype.constructor=pn,mn.prototype=Ji.prototype,mn.prototype.constructor=mn,gn.prototype=Ji.prototype,gn.prototype.constructor=gn,vn.prototype=Ji.prototype,vn.prototype.constructor=vn,yn.prototype=Ji.prototype,yn.prototype.constructor=yn,bn.prototype=Ji.prototype,bn.prototype.constructor=bn,xn.prototype=Ji.prototype,xn.prototype.constructor=xn,Qi.types={"":Ji,picking:nn,random:rn,uniform:on,atomindex:an,residueindex:sn,chainindex:cn,chainname:hn,chainid:un,entityindex:ln,modelindex:dn,entitytype:fn,moleculetype:pn,sstruc:mn,element:gn,resname:vn,bfactor:yn,hydrophobicity:xn,value:en,volume:tn,occupancy:bn};var Lf=l(),Of="undefined"!=typeof window&&void 0!==window.orientation,Rf=!1,Df=!1,Nf={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))}(c("debug"));var kf='

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

Find out how to get it here.

',Ff=new function(){this.activeWorkerCount=0;var t={},e={},i={};this.add=function(i,n,r){t[i]=n,e[i]=r},this.get=function(n){return i[n]||(i[n]=y(t[n],e[n])),i[n]}},zf=new Qi,Bf=new g("datasource"),Uf=new g("representatation"),$f=new g("parser"),Vf=new g("shader"),jf=new g("decompressor"),Gf=new g("component");_n.prototype={constructor:_n,type:"",__srcName:void 0,isBinary:function(){return this.binary||this.compressed},onload:function(){},onprogress:function(){},onerror:function(){},read:function(t){this._read(function(e){var i=jf.get(this.compressed);this.compressed&&i?this.data=i(e):((this.binary||this.compressed)&&e instanceof ArrayBuffer&&(e=new Uint8Array(e)),this.data=e),"function"==typeof this.onload&&this.onload(this.data),t()}.bind(this))},_read:function(t){t(this.src)},_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)},chunk:function(t){var e=t+this.chunkSize;return this._chunk(t,e)},peekLines:function(t){var e,i=this.data,n=i.length,r=this.isBinary()?this.newline.charCodeAt(0):this.newline,o=0;for(e=0;en).lines},lineCount:function(){for(var t=this.data,e=t.length,i=this.isBinary()?this.newline.charCodeAt(0):this.newline,n=0,r=0;rthis.data.length))return this.__pointer+=this.chunkSize,this.chunk(t)},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}},eachChunk:function(t){for(var e=this.chunkSize,i=this.data.length,n=this.chunkCount(),r=0;r=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=On(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()}Hf.json.test(o[8])?d[d.length]=i:(!Hf.number.test(o[8])||f&&!o[3]?p="":(p=f?"+":"-",i=i.toString().replace(Hf.sign,"")),s=o[4]?"0"===o[4]?"0":o[4].charAt(1):" ",c=o[6]-(p+i).length,a=o[6]&&c>0?Rn(s,c):"",d[d.length]=o[5]?p+i+a:"0"===s?p+a+i:a+p+i)}return d.join("")},Ln.cache={},Ln.parse=function(t){for(var e=t,i=[],n=[],r=0;e;){if(null!==(i=Hf.text.exec(e)))n[n.length]=i[0];else if(null!==(i=Hf.modulo.exec(e)))n[n.length]="%";else{if(null===(i=Hf.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(i[2]){r|=1;var o=[],a=i[2],s=[];if(null===(s=Hf.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=Hf.key_access.exec(a)))o[o.length]=s[1];else{if(null===(s=Hf.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o[o.length]=s[1]}i[2]=o}else r|=2;if(3===r)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=i}e=e.substring(i[0].length)}return n};var Wf={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," "," "," "," "," "," "," "],_:["","_","__","___","____","_____","______","_______"]};Dn.prototype={clear:function(){this.change(-this.count)},change:function(t){this.count+=t,this.signals.countChanged.dispatch(t,this.count),this.count<0&&Nf.warn("Counter.count below zero",this.count)},increment:function(){this.change(1)},decrement:function(){this.change(-1)},listen:function(t){this.change(t.count),t.signals.countChanged.add(this.change,this)},unlisten:function(t){var e=t.signals.countChanged;e.has(this.change,this)&&e.remove(this.change,this)},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)}},dispose:function(){this.clear(),this.signals.countChanged.dispose()}},Nn.prototype={constructor:Nn,getBaseObject:function(t){return"StructureView"===t.type&&(t=t.getStructure()),t},addObject:function(t){t=this.getBaseObject(t);var e=this.allocateGidRange(t);return e&&(this.objectList.push(t),this.rangeList.push(e)),this},removeObject:function(t){t=this.getBaseObject(t);var e=this.objectList.indexOf(t);return-1!==e&&(this.objectList.splice(e,1),this.rangeList.splice(e,1),0===this.objectList.length&&(this.nextGid=1)),this},updateObject:function(t,e){t=this.getBaseObject(t);var i=this.objectList.indexOf(t);if(-1!==i){var n=this.rangeList[i];if(n[1]===this.nextGid){var r=this.getGidCount(t);this.nextGid+=r-(n[1]-n[0]),n[1]=this.nextGid}else this.rangeList[i]=this.allocateGidRange(t)}else e||Nf.warn("GidPool.updateObject: object not found.");return this},getGidCount:function(t){var e=0;return"Structure"===(t=this.getBaseObject(t)).type?e=t.atomStore.count+t.bondStore.count+t.backboneBondStore.count+t.rungBondStore.count:"Volume"===t.type?e=t.__data.length:Nf.warn("GidPool.getGidCount: unknown object type"),e},allocateGidRange:function(t){t=this.getBaseObject(t);var e=this.getGidCount(t);if(e>Math.pow(10,7))return Nf.warn("GidPool.allocateGidRange: gidCount too large"),null;var i=this.nextGid;return this.nextGid+=e,this.nextGid>Math.pow(2,24)&&Nf.error("GidPool.allocateGidRange: GidPool overflown"),[i,this.nextGid]},getNextGid:function(){return this.nextGid++},getGid:function(t,e){t=this.getBaseObject(t),e=e||0;var i=0,n=this.objectList.indexOf(t);-1!==n?i=this.rangeList[n][0]+e:Nf.warn("GidPool.getGid: object not found.");return i},getByGid:function(t){var e;return this.objectList.forEach(function(i,n){var r=this.rangeList[n];if(!(t=r[1])){var o=t-r[0];"Structure"===i.type?othis.prevFpsTime+1e3&&(this.lastFps=this.frames,this.prevFpsTime=t,this.frames=0),t}},Fn.prototype=Object.create(b.prototype),Fn.prototype.constructor=Fn,Vf.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"),Vf.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"),Vf.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"),Vf.add("shader/chunk/nearclip_fragment.glsl","#ifdef NEAR_CLIP\nif( vViewPosition.z < nearClip )\ndiscard;\n#endif"),Vf.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"),Vf.add("shader/chunk/radiusclip_fragment.glsl","#ifdef RADIUS_CLIP\nif( distance( vViewPosition, vClipCenter ) > clipRadius )\ndiscard;\n#endif"),Vf.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");var Xf=/^(?!\/\/)\s*#include\s+(\S+)/gim,qf={};Bn.prototype.constructor=Bn;var Yf=2*Math.PI,Zf=(new Float32Array(4),new Float32Array(4),new A),Kf=new w,Qf=new w,Jf=new w,tp=new w;"undefined"!=typeof WebGLRenderingContext&&WebGLRenderingContext&&(WebGLRenderingContext.prototype.getShaderParameter=function(){var e=WebGLRenderingContext.prototype.getShaderParameter;return function(){return!t.Debug||e.apply(this,arguments)}}(),WebGLRenderingContext.prototype.getShaderInfoLog=function(){var e=WebGLRenderingContext.prototype.getShaderInfoLog;return function(){return t.Debug?e.apply(this,arguments):""}}(),WebGLRenderingContext.prototype.getProgramParameter=function(){var e=WebGLRenderingContext.prototype.getProgramParameter;return function(i,n){return!t.Debug&&n===WebGLRenderingContext.prototype.LINK_STATUS||e.apply(this,arguments)}}(),WebGLRenderingContext.prototype.getProgramInfoLog=function(){var e=WebGLRenderingContext.prototype.getProgramInfoLog;return function(){return t.Debug?e.apply(this,arguments):""}}());var ep=[[[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]]];ep.forEach(function(t){t.forEach(function(t){t[0]*=.0625,t[1]*=.0625})}),Xn.prototype.constructor=Xn;var ip=2,np=function(e,i){function n(t){var e=Object.assign({},t);c=h(e.hoverTimeout,c)}function r(t,e){var i,n,r,o=a.pick(t.canvasPosition.x,t.canvasPosition.y),c=o.instance,h=s.getByGid(o.gid);return h&&"AtomProxy"===h.type?i=h:h&&"BondProxy"===h.type?n=h:h&&"Volume"===h.volume.type&&(r=h),(i||n||r)&&t.which===ip&&e&&(i?l.copy(i):n?l.copy(n.atom1).add(n.atom2).multiplyScalar(.5):r&&l.copy(r),c&&l.applyProjection(c.matrix),a.centerView(!1,l)),{atom:i,bond:n,volume:r,instance:c,canvasPosition:t.canvasPosition.clone()}}function o(){setTimeout(function(){d.scrolled=!0},c)}var a=e.viewer,s=e.gidPool,c=50;n(i);var u={clicked:new qi,hovered:new qi},l=new A,d={position:new x,down:new x,canvasPosition:new x,moving:!1,hovering:!0,scrolled:!1,lastMoved:1/0,which:void 0,distance:function(){return d.position.distanceTo(d.down)},setCanvasPosition:function(t){var e=a.renderer.domElement.getBoundingClientRect(),i=t.clientX-e.left,n=t.clientY-e.top;d.canvasPosition.set(i,e.height-n)}};(function t(){if(performance.now()-d.lastMoved>c&&(d.moving=!1),d.scrolled||!d.moving&&!d.hovering){d.hovering=!0,d.scrolled=!1;var e=r(d);u.hovered.dispatch(e)}requestAnimationFrame(t)})(),a.renderer.domElement.addEventListener("mousemove",function(t){t.preventDefault(),d.moving=!0,d.hovering=!1,d.lastMoved=performance.now(),d.position.set(t.layerX,t.layerY),d.setCanvasPosition(t)}),a.renderer.domElement.addEventListener("mousedown",function(t){t.preventDefault(),d.moving=!1,d.hovering=!1,d.down.set(t.layerX,t.layerY),d.which=t.which,d.setCanvasPosition(t)}),a.renderer.domElement.addEventListener("mouseup",function(e){if(e.preventDefault(),!(d.distance()>3||3===e.which)){var i=r(d,!0);d.which=void 0,u.clicked.dispatch(i),t.Debug&&Nf.log("clicked",i)}}),a.renderer.domElement.addEventListener("mousewheel",o),a.renderer.domElement.addEventListener("wheel",o),a.renderer.domElement.addEventListener("MozMousePixelScroll",o),this.signals=u,this.setParameters=n};qn.prototype.add=function(t){this.count<<5<=t&&this.resize(t),this.words[t>>>5]|=1<>>5]|=1<>>5]^=1<>>5]^=1<>>5),r=(e>>>5)-1,o=0|n;o+7>>5]|=1<>>5]|=1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]&=~(1<>>5]&1<0;)0===this.words[this.count-1]&&this.count--;this.words=this.words.slice(0,this.count)},qn.prototype.resize=function(t){if(this.length=t,!(this.count<<5>t)&&(this.count=t+32>>>5,this.words.length<<5<=t)){var e=new Uint32Array(this.count<<1);e.set(this.words),this.words=e}},qn.prototype.hammingWeight=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},qn.prototype.size=function(){for(var t=0,e=this.count,i=0;i=t&&eo?a.set(this[n].subarray(0,o)):a.set(this[n]),this[n]=a}},growIfFull:function(){if(this.count>=this.length){var t=Math.round(1.5*this.length);this.resize(Math.max(256,t))}},copyFrom:function(t,e,i,n){for(var r=0,o=this.__fields.length;r0;)s-=1;a<=s&&(a===o?o=s:s===o&&(o=a),e(a,s),a+=1,s-=1)}while(a<=s);i(n,s),i(a,r)}})(0,this.count-1),Nf.timeEnd("Store.sort")},clear:function(){this.count=0},dispose:function(){delete this.length,delete this.count;for(var t=0,e=this.__fields.length;t0&&(l[i]=M.angleTo(P)),t=Math.cos(b.angleTo(x)),p[i]=180/Math.PI*Math.acos(t),n=b.length(),r=x.length(),d[i]=Math.sqrt(r*n)/Math.max(2,2*(1-t)),f[i]=Math.abs(v.dot(M)),_.copy(b).multiplyScalar(d[i]/n),w.copy(x).multiplyScalar(d[i]/r),_.subVectors(L,_),w.subVectors(O,w),_.toArray(h,e+3),w.toArray(h,e+6),C.subVectors(I,T),C.toArray(m,e),P.copy(M),T.copy(_);for(_.fromArray(h,3),w.fromArray(h,6),M.subVectors(_,w).normalize(),I.index=o.getAtomIndexByType(0,E),T.copy(I),S.copy(I),Kn(S,M,_),S.toArray(h,0),C.subVectors(T,_),C.toArray(m,0),_.fromArray(h,3*s-6),w.fromArray(h,3*s-9),M.subVectors(_,w).normalize(),I.index=o.getAtomIndexByType(s-1,E),T.copy(I),S.copy(I),Kn(S,M,_),S.toArray(h,3*s-3),i=s-3;ie?z=!0:u.bending[B]>t&&(z=!0)),z){if(B-v<4){v=B,z=!1;continue}N.index=R.traceAtomIndex,E=u.axis.subarray(3*v+3,3*B),I=u.center.subarray(3*v,3*B+3),d=Zn(E).normalize(),f=Zn(I),L.fromArray(I),Kn(L,d,f),O.fromArray(I,I.length-3),Kn(O,d,f),d.subVectors(O,L),d.toArray(b,y),f.toArray(x,y),L.toArray(_,y),O.toArray(w,y),p.atomColorToArray(N,S,y),m.atomColorToArray(N,M,y),P.push(g.atomRadius(N)),C.push(h+v),T.push(h+B+1-v),y+=3,v=B,z=!1}return{axis:new Float32Array(b),center:new Float32Array(x),begin:new Float32Array(_),end:new Float32Array(w),color:new Float32Array(S),pickingColor:new Float32Array(M),size:new Float32Array(P),residueOffset:C,residueCount:T}}},Vr.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.content.length,i=0;i0;){var i=Math.floor((t+1)/2)-1,n=this.content[i];if(!(this.scoreFunction(e)":"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"},cp={"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":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"};Wr.prototype={constructor:Wr,type:"Assembly",addPart:function(t,e){var i=new Xr(t,e);return this.partList.push(i),i},getAtomCount:function(t){var e=0;return this.partList.forEach(function(i){e+=i.getAtomCount(t)}),e},getInstanceCount:function(){var t=0;return this.partList.forEach(function(e){t+=e.matrixList.length}),t},isIdentity:function(t){if(1!==this.partList.length)return!1;var e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new w).equals(e.matrixList[0]))return!1;var i=[];return t.eachChain(function(t){i.push(t.chainname)}),i=p(i),e.chainList.length===i.length},getBoundingBox:function(t){var e=new pt;return this.partList.forEach(function(i){var n=i.getBoundingBox(t);e.expandByPoint(n.min),e.expandByPoint(n.max)}),e},getSelection:function(){var t=[];return this.partList.forEach(function(e){t=t.concat(e.chainList)}),Hr(t)}},Xr.prototype={constructor:Xr,type:"AssemblyPart",getAtomCount:function(t){var e=0,i=this.chainList;return t.eachChain(function(t){(0===i.length||i.includes(t.chainname))&&(e+=t.atomCount)}),this.matrixList.length*e},getBoundingBox:function(t){var e=new pt,i=new pt,n=this.getSelection(),r=t.getBoundingBox(n);return this.matrixList.forEach(function(t){i.copy(r).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)}),e},getSelection:function(){return Hr(this.chainList)},getView:function(t){var e=this.getSelection();return e?t.getView(e):t},getInstanceList:function(){for(var t=[],e=0,i=this.matrixList.length;e=t.residueCount)){a.index=o+u,s.index=o+u+l,c.index=a.traceAtomIndex,h.index=s.traceAtomIndex;var d=c.distanceTo(h);if(Math.abs(d-i[l-2])>n)return!1}return!0},i=function(t,i){return e(t,i,[5.45,5.18,6.37],2.1)},n=function(t,i){return e(t,i,[6.1,10.4,13],1.42)},r=function(t){for(var e=t.residueStore,r=t.residueIndexStart,o=0,a=t.residueCount;o1&&n.bending[a]<20&&(e.sstruc[i+a]="h".charCodeAt(0),e.sstruc[i+a+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;r(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&&Nf.timeEnd("calculateSecondaryStructure")}}(),up=function(){var t=["H","C","O","N","S","P"],e=["NA","CL"];return function(i){var n=i.trim().toUpperCase();parseInt(n.charAt(0))&&(n=n.substr(1)),parseInt(n.charAt(0))&&(n=n.substr(1));var r=n.length;if(0===r)return"";if(1===r)return n;if(2===r){if(-1!==e.indexOf(n))return n;if(-1!==t.indexOf(n[0]))return n[0]}return r>=3&&-1!==t.indexOf(n[0])?n[0]:""}}();io.prototype={constructor:io,type:"AtomType",atomname:void 0,element:void 0,vdw:void 0,covalent:void 0},no.prototype={constructor:no,type:"ResidueType",resname:void 0,atomTypeIdList:void 0,atomCount:void 0,getBackboneIndexList:function(){var t,e=[];switch(this.moleculeType){case Il:t=Ql;break;case Ll:case Ol:t=Jl;break;default:return e}for(var i=this.structure.atomMap,n=this.atomTypeIdList,r=0,o=this.atomCount;r=2?t(l,e[l],a):i[l]=2;else if(1===i[l]&&c&&c!=l){var d=[l];n[l]=1,r.push(d);for(var f=o.length-1;f>=0;--f){var p=o[f];if(p===l)break;d.push(p),n[p]=1}}}i[a]=2,o.pop()}for(var e=this.getBondGraph(),i=new Int8Array(this.atomCount),n=new Int8Array(this.atomCount),r=[],o=[],a=0;a1){for(e=0;e1)for(e=0;e0){var e=this.residueStore.atomOffset[this.residueIndex];return t.includes(this.index-e)}return!1},isPolymer:function(){if(this.structure.entityList.length>0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return t===Il||t===Ll||t===Ol},isSidechain:function(){return this.isPolymer()&&!this.isBackbone()},isCg:function(){var t=this.residueType.backboneType;return 4===t||5===t||6===t},isHetero:function(){return 1===this.residueType.hetero},isProtein:function(){return this.residueType.moleculeType===Il},isNucleic:function(){var t=this.residueType.moleculeType;return t===Ll||t===Ol},isRna:function(){return this.residueType.moleculeType===Ll},isDna:function(){return this.residueType.moleculeType===Ol},isWater:function(){return this.residueType.moleculeType===Tl},isIon:function(){return this.residueType.moleculeType===El},isSaccharide:function(){return this.residueType.moleculeType===Rl},isRing:function(){return 1===this.residueType.getRings().flags[this.index-this.residueAtomOffset]},distanceTo:function(t){var e=this.atomStore,i=t.atomStore,n=this.index,r=t.index,o=e.x[n]-i.x[r],a=e.y[n]-i.y[r],s=e.z[n]-i.z[r],c=o*o+a*a+s*s;return Math.sqrt(c)},connectedTo:function(t){var e=this.atomStore,i=t.atomStore,n=this.index,r=t.index;if(e.altloc&&i.altloc){var o=e.altloc[n],a=i.altloc[r];if(0!==o&&0!==a&&32!==o&&32!==a&&o!==a)return!1}var s=e.x[n]-i.x[r],c=e.y[n]-i.y[r],h=e.z[n]-i.z[r],u=s*s+c*c+h*h;if(u<64&&this.isCg())return!0;if(isNaN(u))return!1;var l=this.covalent+t.covalent,d=l+.3,f=l-.5;return uf*f},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},positionToArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var i=this.index,n=this.atomStore;return t[e+0]=n.x[i],t[e+1]=n.y[i],t[e+2]=n.z[i],t},positionToVector3:function(t){return void 0===t&&(t=new A),t.x=this.x,t.y=this.y,t.z=this.z,t},positionFromVector3:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},getResidueBonds:function(t){var e,i,n,r,o=this.residueAtomOffset,a=this.index-this.residueAtomOffset,s=this.residueType.getBonds(),c=s.atomIndices1,h=s.atomIndices2;for(t||(r=[]),e=c.indexOf(a);-1!==e;){if(n=h[e]+o,t)return n;r.push(n),e=c.indexOf(a,e+1)}for(i=h.indexOf(a);-1!==i;){if(n=c[i]+o,t)return n;r.push(n),i=h.indexOf(a,i+1)}return r},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},clone:function(){return new this.constructor(this.structure,this.index)},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}}},ao.prototype={constructor:ao,type:"ResidueProxy",structure:void 0,chainStore:void 0,residueStore:void 0,atomStore:void 0,index:void 0,get entity(){return this.structure.entityList[this.entityIndex]},get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]},get chain(){return this.structure.getChainProxy(this.chainIndex)},get chainIndex(){return this.residueStore.chainIndex[this.index]},set chainIndex(t){this.residueStore.chainIndex[this.index]=t},get atomOffset(){return this.residueStore.atomOffset[this.index]},set atomOffset(t){this.residueStore.atomOffset[this.index]=t},get atomCount(){return this.residueStore.atomCount[this.index]},set atomCount(t){this.residueStore.atomCount[this.index]=t},get atomEnd(){return this.atomOffset+this.atomCount-1},get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]},get chainname(){return this.chainStore.getChainname(this.chainIndex)},get chainid(){return this.chainStore.getChainid(this.chainIndex)},get resno(){return this.residueStore.resno[this.index]},set resno(t){this.residueStore.resno[this.index]=t},get sstruc(){return this.residueStore.getSstruc(this.index)},set sstruc(t){this.residueStore.setSstruc(this.index,t)},get inscode(){return this.residueStore.getInscode(this.index)},set inscode(t){this.residueStore.getInscode(this.index,t)},get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])},get resname(){return this.residueType.resname},get hetero(){return this.residueType.hetero},get moleculeType(){return this.residueType.moleculeType},get backboneType(){return this.residueType.backboneType},get backboneStartType(){return this.residueType.backboneStartType},get backboneEndType(){return this.residueType.backboneEndType},get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset},get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset},get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset},get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset},get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset},get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset},eachAtom:function(t,e){var i,n=this.atomCount,r=this.atomOffset,o=this.structure._ap,a=r+n;if(e&&e.atomOnlyTest){var s=e.atomOnlyTest;for(i=r;i0)return this.entity.isPolymer();var t=this.residueType.moleculeType;return t===Il||t===Ll||t===Ol},isHetero:function(){return 1===this.residueType.hetero},isWater:function(){return this.residueType.moleculeType===Tl},isIon:function(){return this.residueType.moleculeType===El},isSaccharide:function(){return this.residueType.moleculeType===Rl},getAtomType:function(t){return this.atomMap.get(this.atomStore.atomTypeId[t])},getResname1:function(){return Gl[this.resname.toUpperCase()]||"X"},getBackboneType:function(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}},getAtomIndexByName:function(t){var e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e},getAtomByName:function(t){return this.residueType.getAtomByName(t)},hasAtomWithName:function(t){return this.residueType.hasAtomWithName(t)},getAtomnameList:function(){for(var t=this.atomCount,e=this.atomOffset,i=new Array(t),n=0;n=e){if(void 0===t&&(t=this.structure.getResidueProxy()),t.index=i,t.connectedTo(this))return t}else if(i===e-1){void 0===t&&(t=this.structure.getResidueProxy());var n=this.chainStore.residueCount[this.chainIndex];if(t.index=e+n-1,t.connectedTo(this))return t}},getBonds:function(){return this.residueType.getBonds(this)},getRings:function(){return this.residueType.getRings()},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},clone:function(){return new this.constructor(this.structure,this.index)},toObject:function(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}},so.prototype={constructor:so,type:"Polymer",structure:void 0,residueStore:void 0,atomStore:void 0,residueIndexStart:void 0,residueIndexEnd:void 0,residueCount:void 0,get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]},get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]},get chainname(){return this.chainStore.getChainname(this.chainIndex)},isProtein:function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()},isCg:function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()},isNucleic:function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()},getMoleculeType:function(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType},getBackboneType:function(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)},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,n=this.__residueProxy;switch(n.index=this.residueIndexStart+t,e){case"trace":i=n.traceAtomIndex;break;case"direction1":i=n.direction1AtomIndex;break;case"direction2":i=n.direction2AtomIndex;break;default:var r=n.getAtomByName(e);i=r?r.index:void 0}return i},eachAtom:function(t,e){this.eachResidue(function(i){i.eachAtom(t,e)},e)},eachAtomN:function(t,e,i){var n,r=this.residueCount,o=new Array(t);for(n=0;n=n&&i=t&&e.apply(this,a)}})}},eachDirectionAtomsN:function(t,e){var i=2*t,n=this.atomOffset,r=this.atomCount,o=n+r;if(!(r=n&&i=n&&r=t&&e.apply(this,a)}},c,h)}},eachResidue:function(t){for(var e=this.structure.getResidueProxy(),i=this.residueCount,n=this.residueIndexStart,r=0;r1&&t(new so(o,i,h.index)),i=n)):(m!==Dl&&h.index-i>1&&t(new so(o,i,h.index)),i=n)}n-i>1&&this.structure.getResidueProxy(i).backboneStartType&&t(new so(o,i,n))},qualifiedName:function(){return":"+this.chainname+"/"+this.modelIndex},clone:function(){return new this.constructor(this.structure,this.index)},toObject:function(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}},ho.prototype={constructor:ho,type:"ModelProxy",structure:void 0,modelStore:void 0,index:void 0,get chainOffset(){return this.modelStore.chainOffset[this.index]},set chainOffset(t){this.modelStore.chainOffset[this.index]=t},get chainCount(){return this.modelStore.chainCount[this.index]},set chainCount(t){this.modelStore.chainCount[this.index]=t},get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]},get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]},get chainEnd(){return this.chainOffset+this.chainCount-1},get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1},get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1},get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1},get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1},eachAtom:function(t,e){this.eachChain(function(i){i.eachAtom(t,e)},e)},eachResidue:function(t,e){this.eachChain(function(i){i.eachResidue(t,e)},e)},eachPolymer:function(t,e){if(e&&e.chainOnlyTest){var i=e.chainOnlyTest;this.eachChain(function(n){i(n)&&n.eachPolymer(t,e)})}else this.eachChain(function(i){i.eachPolymer(t,e)})},eachChain:function(t,e){var i,n=this.chainCount,r=this.chainOffset,o=this.structure._cp,a=r+n;if(e&&e.test){var s=e.chainOnlyTest;if(s)for(i=r;i1?(R=i.atomRadius(M),D=R*b/(.5*O),w.calculateShiftDir(B),y?(N=2*x*R,B.multiplyScalar(N),B.negate(),z.subVectors(P,M).multiplyScalar(Math.max(.1,N/1.88)),M.positionToArray(o,I),P.positionToArray(a,I),O>=2&&(F.addVectors(M,B).add(z).toArray(o,I+3),F.addVectors(P,B).sub(z).toArray(a,I+3),O>=3&&(F.subVectors(M,B).add(z).toArray(o,I+6),F.subVectors(P,B).sub(z).toArray(a,I+6)))):(N=(x-b)*R,B.multiplyScalar(N),2===O?(F.addVectors(M,B).toArray(o,I),F.subVectors(M,B).toArray(o,I+3),F.addVectors(P,B).toArray(a,I),F.subVectors(P,B).toArray(a,I+3)):3===O?(M.positionToArray(o,I),F.addVectors(M,B).toArray(o,I+3),F.subVectors(M,B).toArray(o,I+6),P.positionToArray(a,I),F.addVectors(P,B).toArray(a,I+3),F.subVectors(P,B).toArray(a,I+6)):(M.positionToArray(o,I),P.positionToArray(a,I)))):(M.positionToArray(o,I),P.positionToArray(a,I))),s&&(n.bondColorToArray(w,1,s,I),n.bondColorToArray(w,0,c,I),v&&O>1))for(E=1;E1))for(E=1;E1))for(D=d[k]*b/(y?1:.5*O),E=y?1:0;E1))for(D=f[k]*b/(y?1:.5*O),E=y?1:0;Ea&&(a=e),i>s&&(s=i),h>c&&(c=h)},e),i.min.set(n,r,o),i.max.set(a,s,c),t.Debug&&Nf.timeEnd("getBoundingBox"),i},getPrincipalAxes:function(e){t.Debug&&Nf.time("getPrincipalAxes");var i=0,n=new mr(3,this.atomCount),r=n.data;return this.eachAtom(function(t){r[i+0]=t.x,r[i+1]=t.y,r[i+2]=t.z,i+=3},e),t.Debug&&Nf.timeEnd("getPrincipalAxes"),function(t){var e=t.rows,i=new mr(e,3),n=new mr(3,3),r=new mr(1,3),o=new mr(3,3),a=new mr(3,3),s=br(t);xr(t,s),gr(i,t),vr(n,i,i),Sr(n,r,o,a);var c=new A(s[0],s[1],s[2]),h=new A(o.data[0],o.data[3],o.data[6]),u=new A(o.data[1],o.data[4],o.data[7]),l=new A(o.data[2],o.data[5],o.data[8]);return h.multiplyScalar(Math.sqrt(r.data[0]/(e/3))),u.multiplyScalar(Math.sqrt(r.data[1]/(e/3))),l.multiplyScalar(Math.sqrt(r.data[2]/(e/3))),[[(new A).copy(c).sub(h),(new A).copy(c).add(h)],[(new A).copy(c).sub(u),(new A).copy(c).add(u)],[(new A).copy(c).sub(l),(new A).copy(c).add(l)],c]}(n)},atomCenter:function(t){return t?this.getBoundingBox(t).center():this.center.clone()},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},getAtomIndices:function(t){var e;if(t&&t.string)e=[],this.eachAtom(function(t){e.push(t.index)},t);else{e=this.getAtomData({what:{index:!0}}).index}return e},getChainnameCount:function(t){var e=new Set;return this.eachChain(function(t){t.residueCount&&e.add(t.chainname)},t),e.size},updatePosition:function(t){var e=0;this.eachAtom(function(i){i.positionFromArray(t,e),e+=3})},refreshPosition:function(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.center(this.center),this.spatialHash=new Or(this.atomStore,this.boundingBox)},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}},lo.prototype={constructor:lo,type:"Surface",set:function(t,e,i,n,r,o){this.position=t,this.index=e,this.normal=i,this.color=n,this.atomindex=r,this.size=t.length/3,this.contour=o},fromGeometry:function(e){var i,n,r,o;if(t.Debug&&Nf.time("GeometrySurface.fromGeometry"),e instanceof Nt?(e.computeVertexNormals(!0),i=(new zt).fromGeometry(e)):i=e instanceof zt?e:e[0],i.boundingBox||i.computeBoundingBox(),this.center.copy(i.boundingBox.center()),this.boundingBox.copy(i.boundingBox),i instanceof zt){var a=i.attributes,s=!!a.normal&&a.normal.array;(!s||0===s[0]&&0===s[1]&&0===s[2])&&i.computeVertexNormals(),n=a.position.array,r=a.index?a.index.array:null,o=a.normal.array}this.set(n,r,o,void 0,void 0),t.Debug&&Nf.timeEnd("GeometrySurface.setGeometry")},getPosition:function(){return this.position},getColor:function(t){var e,i,n,r=t||{},o=this.size;if("volume"===r.scheme){var a=new A,s=this.position;for(n=zf.getScheme(r),i=new Float32Array(3*o),e=0;e65535?Uint32Array:Uint16Array)(o)}return this.index},getAtomindex:function(){return this.atomindex},dispose:function(){}},fo.prototype.constructor=fo,po.prototype.constructor=po,yo.__deps=[mo,go,vo],bo.__deps=[xo],xo.__deps=[rr,nr,or,er],wo.__deps=[Zi,ur,lr,sr,cr,dr,fr,rr,pr,Ar,Pr,Tr,Cr,Er],So.__deps=[bo,xo,yo,Jn,tr,Ir,Lr],Ff.add("surf",function(t,e){var i=t.data.args,n=t.data.params;if(i&&(self.volsurf=new So(i[0],i[1],i[2],i[3],i[4])),n){var r=self.volsurf.getSurface(n.isolevel,n.smooth,n.box,n.matrix,n.contour),o=[r.position.buffer,r.index.buffer];r.normal&&o.push(r.normal.buffer),r.atomindex&&o.push(r.atomindex.buffer),e({sd:r,p:n},o)}},[So]),Ao.prototype={constructor:Ao,type:"Volume",setData:function(t,e,i,n,r){this.nx=e||1,this.ny=i||1,this.nz=n||1,this.data=t||new Float32Array(1),this.__data=this.data,this.setDataAtomindex(r),delete this.mc,delete this.__isolevel,delete this.__smooth,delete this.__minValue,delete this.__maxValue,delete this.__dataPositionBuffer,delete this.__dataPosition,delete this.__dataBuffer,delete this.__dataMin,delete this.__dataMax,delete this.__dataMean,delete this.__dataRms,this.worker&&this.worker.terminate()},setMatrix:function(t){this.matrix.copy(t);var e=this.boundingBox,i=this.center,n=this.nx-1,r=this.ny-1,o=this.nz-1;e.makeEmpty(),e.expandByPoint(i.set(n,r,o)),e.expandByPoint(i.set(n,r,0)),e.expandByPoint(i.set(n,0,o)),e.expandByPoint(i.set(n,0,0)),e.expandByPoint(i.set(0,r,o)),e.expandByPoint(i.set(0,0,o)),e.expandByPoint(i.set(0,r,0)),e.expandByPoint(i.set(0,0,0)),e.applyMatrix4(this.matrix),e.center(this.center);var a=this.matrix.elements,s=new A(a[0],a[1],a[2]),c=new A(a[4],a[5],a[6]),h=new A(a[8],a[9],a[10]),u=new A,l=this.normalMatrix.elements;u.crossVectors(c,h),l[0]=u.x,l[1]=u.y,l[2]=u.z,u.crossVectors(h,s),l[3]=u.x,l[4]=u.y,l[5]=u.z,u.crossVectors(s,c),l[6]=u.x,l[7]=u.y,l[8]=u.z,this.inverseMatrix.getInverse(this.matrix)},setDataAtomindex:function(t){this.dataAtomindex=t,this.__dataAtomindex=this.dataAtomindex,delete this.__dataAtomindexBuffer},getBox:function(t,e,i){return i||(i=new pt),i.set(t,t),i.expandByScalar(e),i.applyMatrix4(this.inverseMatrix),i.min.round(),i.max.round(),i},__getBox:function(t,e){if(t&&e){this.__box||(this.__box=new pt);var i=this.getBox(t,e,this.__box);return[i.min.toArray(),i.max.toArray()]}},makeSurface:function(t,e,i){var n=new lo("","",t);return n.info.isolevel=e,n.info.smooth=i,n},getSurface:function(t,e,i,n){t=isNaN(t)?this.getValueForSigma(2):t,e=e||0,void 0===this.volsurf&&(this.volsurf=new So(this.__data,this.nx,this.ny,this.nz,this.__dataAtomindex));var r=this.__getBox(i,n),o=this.volsurf.getSurface(t,e,r,this.matrix.elements);return this.makeSurface(o,t,e)},getSurfaceWorker:function(t,e,i,n,r){if(t=isNaN(t)?this.getValueForSigma(2):t,e=e||0,window.Worker){void 0===this.workerPool&&(this.workerPool=new po("surf",2));var o={},a=this.workerPool.getNextWorker();0===a.postCount&&(o.args=[this.__data,this.nx,this.ny,this.nz,this.__dataAtomindex]),o.params={isolevel:t,smooth:e,box:this.__getBox(i,n),matrix:this.matrix.elements},a.post(o,void 0,function(t){var e=t.data.sd,i=t.data.p;r(this.makeSurface(e,i.isolevel,i.smooth))}.bind(this),function(o){var a=this.getSurface(t,e,i,n);r(a)}.bind(this))}else{var s=this.getSurface(t,e,i,n);r(s)}},getValueForSigma:function(t){return t=void 0!==t?t:2,this.getDataMean()+t*this.getDataRms()},getSigmaForValue:function(t){return((t=void 0!==t?t:0)-this.getDataMean())/this.getDataRms()},filterData: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=void 0!==e?e:1/0,i=i||!1,this.dataPosition||this.makeDataPosition();var n=this.__dataPosition,r=this.__data;if(t!==this.__minValue||e!=this.__maxValue||i!==this.__outside){if(t===-1/0&&e===1/0)this.dataPosition=n,this.data=r;else{var o=r.length;this.__dataBuffer||(this.__dataPositionBuffer=new ArrayBuffer(3*o*4),this.__dataBuffer=new ArrayBuffer(4*o));for(var a=new Float32Array(this.__dataPositionBuffer),s=new Float32Array(this.__dataBuffer),c=0,h=0;h=t&&l<=e||i&&(le)){var d=3*c;a[d+0]=n[u+0],a[d+1]=n[u+1],a[d+2]=n[u+2],s[c]=l,c+=1}}this.dataPosition=new Float32Array(this.__dataPositionBuffer,0,3*c),this.data=new Float32Array(this.__dataBuffer,0,c)}this.__minValue=t,this.__maxValue=e,this.__outside=i}},makeDataPosition:function(){for(var t=this.nz,e=this.ny,i=this.nx,n=new Float32Array(i*e*t*3),r=0,o=0;o0&&this.centerPbc){var r=[e[0],e[4],e[8]];!function(t,e,i){if(0!==i[0]&&0!==i[8]&&0!==i[4]){var n,r=t.length,o=i[0],a=i[1],s=i[2],c=-e[0]+o+o/2,h=-e[1]+a+a/2,u=-e[2]+s+s/2;for(n=0;n.9*e[3*n+n])if(o>0)for(r=0;r<3;++r)t[i+r]-=e[3*n+r];else for(r=0;r<3;++r)t[i+r]+=e[3*n+r]}}(i,e)}this.indices.length>0&&this.superpose&&this.doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1},setNumframes:function(t){t!==this.numframes&&(this.numframes=t,this.signals.gotNumframes.dispatch(t))},dispose:function(){this.frameCache=[],this._disposed=!0,this.player&&this.player.stop()},setPlayer:function(t){this.player=t,this.signals.playerChanged.dispatch(t)},getPath:function(t,e){Nf.error("Trajectory.getPath not implemented",t,e)}},Vf.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 )\nattribute vec3 pickingColor;\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 = pickingColor;\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}"),Vf.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 )\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}"),Eo.prototype={constructor:Eo,parameters:{opaqueBack:{updateShader:!0},dullInterior:{updateShader:!0},side:{updateShader:!0,property:!0},opacity:{uniform:!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}},get transparent(){return this.opacity<1||this.forceTransparent},makeMaterial:function(){var t=To(this.side);this.material=new lt({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:!0,lights:!0,fog:!0,side:t,linewidth:this.linewidth}),this.material.vertexColors=2,this.material.extensions.derivatives=this.flatShaded,this.material.extensions.fragDepth=this.impostor,this.material.clipNear=this.clipNear,this.wireframeMaterial=new lt({uniforms:this.uniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:this.transparent,depthWrite:!0,lights:!1,fog:!0,side:t,linewidth:this.linewidth}),this.wireframeMaterial.vertexColors=2,this.wireframeMaterial.clipNear=this.clipNear,this.pickingMaterial=new lt({uniforms:this.pickingUniforms,vertexShader:"",fragmentShader:"",depthTest:!0,transparent:!1,depthWrite:!0,lights:!1,fog:!1,side:t,linewidth:this.linewidth}),this.pickingMaterial.vertexColors=2,this.pickingMaterial.extensions.fragDepth=this.impostor,this.pickingMaterial.clipNear=this.clipNear,this.updateShader()},makeWireframeGeometry:function(){this.makeWireframeIndex();var t=this.geometry,e=this.wireframeIndex,i=new zt;i.attributes=t.attributes,e&&(i.setIndex(new Et(e,1).setDynamic(this.dynamic)),i.setDrawRange(0,this.wireframeIndexCount)),this.wireframeGeometry=i},makeWireframeIndex:function(){function t(t,i){if(t>i){var n=t;t=i,i=n}var r=e[t];return void 0===r?(e[t]=[i],!0):!r.includes(i)&&(r.push(i),!0)}var e=[];return function(){var i=this.geometry.index;if(this.wireframe){if(i){var n,r=i.array,o=r.length;if(this.geometry.drawRange.count!==1/0&&(o=this.geometry.drawRange.count),this.wireframeIndex&&this.wireframeIndex.length>2*o)n=this.wireframeIndex;else n=new(this.geometry.attributes.position.count>65535?Uint32Array:Uint16Array)(2*o);var a=0;e.length=0;for(var s=0;sthis.wireframeGeometry.index.array.length)this.wireframeGeometry.setIndex(new Et(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)},getRenderOrder:function(){var t=0;return"text"===this.type?t=1:this.transparent&&(t="surface"===this.type?3:2),t},getMesh:function(){var t;return this.material||this.makeMaterial(),this.line?t=new pe(this.geometry,this.material):this.point?(t=new ge(this.geometry,this.material),this.sortParticles&&(t.sortParticles=!0)):t=new Yt(this.geometry,this.material),t.frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},getWireframeMesh:function(){var t;return this.material||this.makeMaterial(),this.wireframeGeometry||this.makeWireframeGeometry(),(t=new pe(this.wireframeGeometry,this.wireframeMaterial)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},getPickingMesh:function(){var t;return this.material||this.makeMaterial(),(t=new Yt(this.geometry,this.pickingMaterial)).frustumCulled=!1,t.renderOrder=this.getRenderOrder(),t},getShader:function(t,e){return zn(t,this.getDefines(e))},getVertexShader:function(t){return this.getShader(this.vertexShader,t)},getFragmentShader:function(t){return this.getShader(this.fragmentShader,t)},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},getParameters:function(){var t={};for(var e in this.parameters)t[e]=this[e];return t},addUniforms:function(t){this.uniforms=Vu.merge([this.uniforms,t]),this.pickingUniforms=Vu.merge([this.pickingUniforms,t])},addAttributes:function(t){var e={f:1,v2:2,v3:3,c:3};for(var i in t){var n,r=t[i];r.value?(this.attributeSize*e[r.type]!==r.value.length&&Nf.error("attribute value has wrong length",i),n=r.value):n=new Float32Array(this.attributeSize*e[r.type]),this.geometry.addAttribute(i,new Et(n,e[r.type]).setDynamic(this.dynamic))}},updateRenderOrder:function(){function t(t){t.renderOrder=e}var e=this.getRenderOrder();this.group.children.forEach(t),this.pickingGroup&&this.pickingGroup.children.forEach(t)},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},setParameters:function(t){if(t){var e=t,i=this.parameters,n={},r={},o=!1,a=!1;for(var s in e)void 0!==e[s]&&void 0!==i[s]&&(this[s]=e[s],i[s].property&&(!0!==i[s].property?n[i[s].property]=e[s]:n[s]=e[s]),i[s].uniform&&(!0!==i[s].uniform?r[i[s].uniform]=e[s]:r[s]=e[s]),i[s].updateShader&&(o=!0),i[s].updateVisibility&&(a=!0),this.dynamic&&"wireframe"===s&&!0===e[s]&&this.updateWireframeIndex(),"flatShaded"===s&&(this.material.extensions.derivatives=this.flatShaded),"forceTransparent"===s&&(n.transparent=this.transparent));this.setProperties(n),this.setUniforms(r),o&&this.updateShader(),a&&this.setVisibility(this.visible)}},setAttributes:function(t){var e=this.geometry,i=e.attributes;for(var n in t){var r=t[n],o=r.length;if("index"===n){var a=e.getIndex();e.setDrawRange(0,1/0),o>a.array.length?e.setIndex(new Et(r,1).setDynamic(this.dynamic)):(a.set(r),a.needsUpdate=o>0,a.updateRange.count=o,e.setDrawRange(0,o)),this.indexVersion++,this.wireframe&&this.updateWireframeIndex()}else{var s=i[n];o>s.array.length?e.addAttribute(n,new Et(r,s.itemSize).setDynamic(this.dynamic)):(i[n].set(r),i[n].needsUpdate=o>0,i[n].updateRange.count=o)}}},setUniforms:function(t){if(t){var e=this.material.uniforms,i=this.wireframeMaterial.uniforms,n=this.pickingMaterial.uniforms;for(var r in t)"opacity"===r&&this.setProperties({transparent:this.transparent}),void 0!==e[r]&&(e[r].value.isVector3?e[r].value.copy(t[r]):e[r].value.set?e[r].value.set(t[r]):e[r].value=t[r]),void 0!==i[r]&&(i[r].value.isVector3?i[r].value.copy(t[r]):i[r].value.set?i[r].value.set(t[r]):i[r].value=t[r]),void 0!==n[r]&&(n[r].value.isVector3?n[r].value.copy(t[r]):n[r].value.set?n[r].value.set(t[r]):n[r].value=t[r])}},setProperties:function(t){if(t){var e=this.material,i=this.wireframeMaterial,n=this.pickingMaterial;for(var r in t){var o=t[r];"transparent"===r?this.updateRenderOrder():"side"===r&&(o=To(o)),void 0!==e[r]&&(e[r]=o),void 0!==i[r]&&(i[r]=o),void 0!==n[r]&&(n[r]=o)}e.needsUpdate=!0,i.needsUpdate=!0,n.needsUpdate=!0}},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))},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()}},Io.prototype=Object.assign(Object.create(Eo.prototype),{constructor:Io}),Lo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Lo,applyPositionTransform:function(){},setAttributes:function(){var t=new w,e=new gt;return function(i){var n,r,o,a,s,c,h,u,l,d,f,p=this.geometry.attributes;i.position&&(n=i.position,a=this.geoPosition,u=this.meshPosition,c=this.transformedGeoPosition,p.position.needsUpdate=!0),i.color&&(r=i.color,l=this.meshColor,p.color.needsUpdate=!0),i.pickingColor&&(o=i.pickingColor,d=this.meshPickingColor,p.pickingColor.needsUpdate=!0);var m=!(!this.updateNormals||!n),g=!(!this.initNormals||!n);(m||g)&&(s=this.geoNormal,f=this.meshNormal,h=this.transformedGeoNormal,p.normal.needsUpdate=!0);for(var v=this.positionCount,y=this.geoPositionCount,b=0;b 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}"),Ro.prototype=Object.assign(Object.create(Eo.prototype),{constructor:Ro,setAttributes:function(t){var e,i,n,r,o,a,s,c=this.count,h=this.mappingSize,u=this.geometry.attributes;for(var l in t){i=t[l],n=(e=u[l]).itemSize,r=e.array;for(var d=0;d 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\nif( distSq3( new_point, end_cyl ) < distSq3( new_point, base ) ){\nif( b < 0.0 ){\ngl_FragColor = vec4( vPickingColor, objectId );\n}else{\ngl_FragColor = vec4( vPickingColor2, objectId );\n}\n}else{\nif( b > 0.0 ){\ngl_FragColor = vec4( vPickingColor, objectId );\n}else{\ngl_FragColor = vec4( vPickingColor2, objectId );\n}\n}\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}"),Uo.prototype=Object.assign(Object.create(Ro.prototype),{constructor:Uo}),$o.prototype=Object.assign(Object.create(Uo.prototype),{constructor:$o,parameters:Object.assign({openEnded:{updateShader:!0}},Uo.prototype.parameters),getDefines:function(t){var e=Uo.prototype.getDefines.call(this,t);return this.openEnded||(e.CAP=1),e},setAttributes:function(t){t&&t.position1&&t.position2&&(t.position=$n(t.position1,t.position2)),Uo.prototype.setAttributes.call(this,t)}}),jo.prototype=Object.assign(Object.create(Lo.prototype),{constructor:jo,applyPositionTransform:function(){var t,e=new A,i=new A,n=new A,r=new A(0,1,0);return function(o,a,s){i.fromArray(this._from,s),n.fromArray(this._to,s),o.lookAt(i,n,r),t=this._radius[a],e.set(t,t,i.distanceTo(n)),o.scale(e)}}(),setAttributes:function(t){var e={};t.position1&&t.position2&&($n(t.position1,t.position2,this._position),this._from.set(t.position1),this._to.set(t.position2),e.position=this._position),t.color&&(e.color=t.color),t.pickingColor&&(e.pickingColor=t.pickingColor),t.radius&&this._radius.set(t.radius),Lo.prototype.setAttributes.call(this,e)}}),Wo.prototype.constructor=Wo,Wo.prototype.type="Shape",Xo.prototype={constructor:Xo,type:"",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},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:zf.getTypes()},colorScale:{type:"select",update:"color",options:zf.getScales()},colorValue:{type:"color",update:"color"},colorDomain:{type:"hidden",update:"color"},colorMode:{type:"select",update:"color",options:zf.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}},init:function(t){var e=t||{};this.clipNear=h(e.clipNear,0),this.clipRadius=h(e.clipRadius,0),this.clipCenter=h(e.clipCenter,new A),this.flatShaded=h(e.flatShaded,!1),this.side=h(e.side,"double"),this.opacity=h(e.opacity,1),this.wireframe=h(e.wireframe,!1),this.linewidth=h(e.linewidth,2),this.setColor(e.color,e),this.colorScheme=h(e.colorScheme,"uniform"),this.colorScale=h(e.colorScale,""),this.colorValue=h(e.colorValue,9474192),this.colorDomain=h(e.colorDomain,""),this.colorMode=h(e.colorMode,"hcl"),this.visible=h(e.visible,!0),this.quality=h(e.quality,void 0),this.roughness=h(e.roughness,.4),this.metalness=h(e.metalness,0),this.diffuse=h(e.diffuse,16777215),this.lazy=h(e.lazy,!1),this.lazyProps={build:!1,bufferParams:{},what:{}};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=h(e.sphereDetail,1)),i.radialSegments&&(this.radialSegments=h(e.radialSegments,10))),i.openEnded&&(this.openEnded=h(e.openEnded,!0)),i.disableImpostor&&(this.disableImpostor=h(e.disableImpostor,!1))},getColorParams:function(t){return Object.assign({gidPool:this.gidPool,scheme:this.colorScheme,scale:this.colorScale,value:this.colorValue,domain:this.colorDomain,mode:this.colorMode},t)},getBufferParams:function(t){return Object.assign({clipNear:this.clipNear,clipRadius:this.clipRadius,clipCenter:this.clipCenter,flatShaded:this.flatShaded,opacity:this.opacity,side:this.side,wireframe:this.wireframe,linewidth:this.linewidth,roughness:this.roughness,metalness:this.metalness,diffuse:this.diffuse},t)},setColor:function(t,e){return Object.keys(zf.getTypes()).includes(t)?e?e.colorScheme=t:this.setParameters({colorScheme:t}):void 0!==t&&(t=new dt(t).getHex(),e?(e.colorScheme="uniform",e.colorValue=t):this.setParameters({colorScheme:"uniform",colorValue:t})),this},prepare:!1,create:function(){},update:function(){this.build()},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())},make:function(e,i){t.Debug&&Nf.time("Representation.make "+this.type);var n=function(){e?(this.update(e),this.viewer.requestRender(),this.tasks.decrement(),i&&i()):(this.clear(),this.create(),this.manualAttach||this.disposed||(t.Debug&&Nf.time("Representation.attach "+this.type),this.attach(function(){t.Debug&&Nf.timeEnd("Representation.attach "+this.type),this.tasks.decrement(),i&&i()}.bind(this)))),t.Debug&&Nf.timeEnd("Representation.make "+this.type)}.bind(this);this.prepare?this.prepare(n):n()},attach:function(t){this.setVisibility(this.visible),t()},setVisibility:function(t,e){if(this.visible=t,this.visible){var i=this.lazyProps,n=i.bufferParams,r=i.what;if(i.build)return i.build=!1,void this.build();(Object.keys(n).length||Object.keys(r).length)&&(i.bufferParams={},i.what={},this.updateParameters(n,r))}return this.bufferList.forEach(function(e){e.setVisibility(t)}),e||this.viewer.requestRender(),this},setParameters:function(t,e,i){var n=t||{},r=this.parameters;e=e||{},i=i||!1;var o={};for(var a in n)void 0!==n[a]&&void 0!==r[a]&&(r[a].int&&(n[a]=parseInt(n[a])),r[a].float&&(n[a]=parseFloat(n[a])),n[a]!==this[a]&&(this[a]=n[a],r[a].buffer&&(!0===r[a].buffer?o[a]=n[a]:o[r[a].buffer]=n[a]),r[a].update&&(e[r[a].update]=!0),!r[a].rebuild||"impostor"===r[a].rebuild&&Df&&!this.disableImpostor||(i=!0)));return i?this.build():this.updateParameters(o,e),this},updateParameters:function(t,e){return this.lazy&&!this.visible?(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),void this.viewer.requestRender())},getParameters:function(){var t={lazy:this.lazy,visible:this.visible,quality:this.quality};return Object.keys(this.parameters).forEach(function(e){"button"===this.parameters.type?t[e]=this[e].bind(this):t[e]=this[e]},this),t},clear:function(){this.bufferList.forEach(function(t){this.viewer.remove(t),t.dispose()},this),this.bufferList.length=0,this.viewer.requestRender()},dispose:function(){this.disposed=!0,this.queue.kill(),this.tasks.dispose(),this.clear()}},qo.prototype=Object.assign(Object.create(Xo.prototype),{constructor:qo,type:"buffer",parameters:Object.assign({},Xo.prototype.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),create:function(){this.bufferList.push.apply(this.bufferList,this.buffer)},attach:function(t){this.bufferList.forEach(function(t){this.viewer.add(t),t.setParameters(this.getBufferParams())},this),this.setVisibility(this.visible),t()}}),Yo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Yo,type:"surface"}),Zo.prototype.constructor=Zo,Ko.prototype=Object.assign(Object.create(Xo.prototype),{constructor:Ko,type:"surface",parameters:Object.assign({isolevelType:{type:"select",options:{value:"value",sigma:"sigma"}},isolevel:{type:"number",precision:2,max:1e3,min:-1e3},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},useWorker:{type:"boolean",rebuild:!0}},Xo.prototype.parameters),init:function(t){var e=t||{};e.colorScheme=h(e.colorScheme,"uniform"),e.colorValue=h(e.colorValue,14540253),this.isolevelType=h(e.isolevelType,"sigma"),this.isolevel=h(e.isolevel,2),this.smooth=h(e.smooth,0),this.background=h(e.background,!1),this.opaqueBack=h(e.opaqueBack,!0),this.boxSize=h(e.boxSize,0),this.useWorker=h(e.useWorker,!0),Xo.prototype.init.call(this,e)},attach:function(t){this.bufferList.forEach(function(t){this.viewer.add(t)},this),this.setVisibility(this.visible),t()},prepare:function(t){var e;if(this.volume)if(e="sigma"===this.isolevelType?this.volume.getValueForSigma(this.isolevel):this.isolevel,!this.surface||this.__isolevel!==e||this.__smooth!==this.smooth||this.__boxSize!==this.boxSize||this.boxSize>0&&!this.__boxCenter.equals(this.boxCenter)){this.__isolevel=e,this.__smooth=this.smooth,this.__boxSize=this.boxSize,this.__boxCenter.copy(this.boxCenter),this.__box.copy(this.box);var i=function(e){this.surface=e,t()}.bind(this);this.useWorker?this.volume.getSurfaceWorker(e,this.smooth,this.boxCenter,this.boxSize,i):i(this.volume.getSurface(e,this.smooth,this.boxCenter,this.boxSize))}else t();else t()},create:function(){var t=new Zo(new Yo(this.surface.getPosition(),this.surface.getColor(this.getColorParams()),this.surface.getIndex(),this.surface.getNormal(),void 0,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1})));this.bufferList.push(t)},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)})}},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),Xo.prototype.setParameters.call(this,t,e,i),this.volume&&this.volume.getBox(this.boxCenter,this.boxSize,this.box),this.surface&&(void 0!==t.isolevel||void 0!==t.smooth||void 0!==t.boxSize||this.boxSize>0&&!this.__box.equals(this.box))&&this.build({position:!0,color:!0,index:!0,normal:!0}),this},dispose:function(){this.viewer.signals.orientationChanged.remove(this.setBox),Xo.prototype.dispose.call(this)}}),Vf.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#include color_pars_vertex\n#include common\nvoid main(){\n#include color_vertex\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}"),Vf.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#include common\n#include color_pars_fragment\n#include fog_pars_fragment\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\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}"),Jo.prototype=Object.assign(Object.create(Eo.prototype),{constructor:Jo,parameters:Object.assign({pointSize:{uniform:"size"},sizeAttenuation:{updateShader:!0},sortParticles:{},alphaTest:{updateShader:!0},useTexture:{updateShader:!0},forceTransparent:{},edgeBleach:{uniform:!0}},Eo.prototype.parameters),makeMaterial:function(){Eo.prototype.makeMaterial.call(this),this.makeTexture(),this.material.uniforms.map.value=this.tex,this.material.blending=Wc,this.material.needsUpdate=!0,this.wireframeMaterial.uniforms.map.value=this.tex,this.wireframeMaterial.blending=Wc,this.wireframeMaterial.needsUpdate=!0,this.pickingMaterial.uniforms.map.value=this.tex,this.pickingMaterial.blending=Wc,this.pickingMaterial.needsUpdate=!0},makeTexture:function(){this.tex&&this.tex.dispose(),this.tex=Qo({delta:this.edgeBleach})},getDefines:function(t){var e=Eo.prototype.getDefines.call(this,t);return this.sizeAttenuation&&(e.USE_SIZEATTENUATION=1),this.useTexture&&(e.USE_MAP=1),this.alphaTest>0&&this.alphaTest<=1&&(e.ALPHATEST=this.alphaTest.toPrecision(2)),e},setUniforms:function(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),Eo.prototype.setUniforms.call(this,t)},dispose:function(){Eo.prototype.dispose.call(this),this.tex&&this.tex.dispose()}}),ta.prototype=Object.assign(Object.create(Xo.prototype),{constructor:ta,type:"dot",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}},Xo.prototype.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform"}}}),defaultSize:.1,init:function(t){var e=t||{};e.colorScheme=h(e.colorScheme,"uniform"),e.colorValue=h(e.colorValue,14540253),this.thresholdType=h(e.thresholdType,"sigma"),this.thresholdMin=h(e.thresholdMin,2),this.thresholdMax=h(e.thresholdMax,1/0),this.thresholdOut=h(e.thresholdOut,!1),this.dotType=h(e.dotType,"point"),this.radius=h(e.radius,.1),this.scale=h(e.scale,1),this.pointSize=h(e.pointSize,1),this.sizeAttenuation=h(e.sizeAttenuation,!0),this.sortParticles=h(e.sortParticles,!1),this.useTexture=h(e.useTexture,!1),this.alphaTest=h(e.alphaTest,.5),this.forceTransparent=h(e.forceTransparent,!1),this.edgeBleach=h(e.edgeBleach,0),Xo.prototype.init.call(this,e)},attach:function(t){this.bufferList.forEach(function(t){this.viewer.add(t)},this),this.setVisibility(this.visible),t()},create:function(){var t,e,i,n;if(this.volume){var r,o,a=this.volume;"sigma"===this.thresholdType?(r=a.getValueForSigma(this.thresholdMin),o=a.getValueForSigma(this.thresholdMax)):(r=this.thresholdMin,o=this.thresholdMax),a.filterData(r,o,this.thresholdOut),t=a.getDataPosition(),e=a.getDataColor(this.getColorParams()),i=a.getDataSize(this.radius,this.scale),n=a.getPickingDataColor(this.getColorParams())}else{var s=this.surface;t=s.getPosition(),e=s.getColor(this.getColorParams()),i=s.getSize(this.radius,this.scale),n=s.getPickingColor(this.getColorParams())}"sphere"===this.dotType?this.dotBuffer=new ko(t,e,i,n,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Jo(t,e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)},update: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)}},setParameters:function(t,e,i){return e=e||{},t&&void 0!==t.thresholdType&&this.volume instanceof Ao&&("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=this.defaultSize:this.radius=t.radiusType,e.radius=!0,"sphere"!==this.dotType||Df&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,"sphere"!==this.dotType||Df&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.scale=!0,"sphere"!==this.dotType||Df&&!this.disableImpostor||(i=!0)),Xo.prototype.setParameters.call(this,t,e,i),this}}),Vf.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\nvViewPosition = -mvPosition.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Vf.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float nearClip;\nuniform float clipRadius;\nvarying vec2 vUv;\nvarying vec3 vViewPosition;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#include fog_pars_fragment\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 )\n{\nf = -f;\n}\nif( f < 1.0 )\n{\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}\nelse if( f >= 1.0 && f < 2.0 )\n{\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}\nelse\n{\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\ngl_FragColor.a *= opacity;\nif( gl_FragColor.a < 0.01 )\ndiscard;\n#include fog_fragment\n}");var lp=new Uint16Array([0,1,2,1,3,2]),dp=new Float32Array([0,1,0,0,1,1,1,0]);ea.prototype=Object.assign(Object.create(Eo.prototype),{constructor:ea,parameters:Object.assign({filter:{updateShader:!0,uniform:!0}},Eo.prototype.parameters),getDefines:function(t){var e=Eo.prototype.getDefines.call(this,t);return this.filter.startsWith("cubic")&&(e.CUBIC_INTERPOLATION=1,this.filter.endsWith("bspline")?e.BSPLINE_FILTER=1:this.filter.endsWith("catmulrom")?e.CATMULROM_FILTER=1:this.filter.endsWith("mitchell")&&(e.MITCHELL_FILTER=1)),e},updateTexture:function(){var t=this.tex;this.filter.startsWith("cubic")?(t.minFilter=Bh,t.magFilter=Bh):"linear"===this.filter?(t.minFilter=Vh,t.magFilter=Vh):(t.minFilter=Bh,t.magFilter=Bh),t.needsUpdate=!0},makeMaterial:function(){Eo.prototype.makeMaterial.call(this),this.updateTexture();var t=this.material;t.uniforms.map.value=this.tex,t.blending=Wc,t.needsUpdate=!0;var e=this.wireframeMaterial;e.uniforms.map.value=this.tex,e.blending=Wc,e.needsUpdate=!0;var i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.blending=Wc,i.needsUpdate=!0},setUniforms:function(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),Eo.prototype.setUniforms.call(this,t)}}),ia.prototype=Object.assign(Object.create(Xo.prototype),{constructor:ia,type:"slice",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"}},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}},Xo.prototype.parameters,{flatShaded:null,side:null,wireframe:null,linewidth:null,colorScheme:null,roughness:null,metalness:null,diffuse:null}),init:function(t){var e=t||{};e.colorScheme=h(e.colorScheme,"value"),e.colorScale=h(e.colorScale,"Spectral"),Xo.prototype.init.call(this,e),this.colorScheme="value",this.dimension=h(e.dimension,"x"),this.filter=h(e.filter,"cubic-bspline"),this.position=h(e.position,30),this.thresholdType=h(e.thresholdType,"sigma"),this.thresholdMin=h(e.thresholdMin,-1/0),this.thresholdMax=h(e.thresholdMax,1/0)},attach:function(t){this.bufferList.forEach(function(t){this.viewer.add(t)},this),this.setVisibility(this.visible),t()},create:function(){function t(t){return Math.round(t/100*(i-1))}function e(t,e,i,r){return 3*(i*n.ny*n.nx+e*n.nx+t)+r}var i=this.position,n=this.volume;n.filterData(-1/0,1/0,!1);var r,o,a,s,c,h=n.data,u=n.matrix,l=new Float32Array(12),d=0,f=0,p=0,m=n.nx,g=n.ny,v=n.nz,y=new A;"x"===this.dimension?(a=t(n.nx),s=n.ny-1,c=n.nz-1,r=n.nz,o=n.ny,m=(d=a)+1,y.set(a,0,0).applyMatrix4(u).toArray(l,0),y.set(a,s,0).applyMatrix4(u).toArray(l,3),y.set(a,0,c).applyMatrix4(u).toArray(l,6),y.set(a,s,c).applyMatrix4(u).toArray(l,9)):"y"===this.dimension?(a=n.nx-1,s=t(n.ny),c=n.nz-1,r=n.nz,o=n.nx,g=(f=s)+1,y.set(0,s,0).applyMatrix4(u).toArray(l,0),y.set(a,s,0).applyMatrix4(u).toArray(l,3),y.set(0,s,c).applyMatrix4(u).toArray(l,6),y.set(a,s,c).applyMatrix4(u).toArray(l,9)):"z"===this.dimension&&(a=n.nx-1,s=n.ny-1,c=t(n.nz),r=n.nx,o=n.ny,v=(p=c)+1,y.set(0,0,c).applyMatrix4(u).toArray(l,0),y.set(0,s,c).applyMatrix4(u).toArray(l,3),y.set(a,0,c).applyMatrix4(u).toArray(l,6),y.set(a,s,c).applyMatrix4(u).toArray(l,9));var b,x,_=0,w=new Uint8Array(r*o*4);"sigma"===this.thresholdType?(b=n.getValueForSigma(this.thresholdMin),x=n.getValueForSigma(this.thresholdMax)):(b=this.thresholdMin,x=this.thresholdMax);var S=this.getColorParams({volume:n});S.domain=[n.getDataMin(),n.getDataMax()];for(var M=zf.getScheme(S),P=new Float32Array(3),C=f;Cb&&L0&&this.updateData(t,e)},this)},updateData:function(){},getColorParams:function(){var t=Xo.prototype.getColorParams.call(this);return t.structure=this.structure,t},getAtomParams:function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},getBondParams:function(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:{radius:this.radius,scale:this.scale}},e)},setSelection:function(t,e){return this.selection.setString(t,e),this},setParameters:function(t,e,i){return e=e||{},t&&void 0!==t.radiusType&&("size"===t.radiusType?this.radius=this.defaultSize:this.radius=t.radiusType,e.radius=!0,Df&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,Df&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.radius=!0,Df&&!this.disableImpostor||(i=!0)),t&&void 0!==t.defaultAssembly&&(i=!0),Xo.prototype.setParameters.call(this,t,e,i),this},getParameters:function(){return Object.assign(Xo.prototype.getParameters.call(this),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})},attach:function(t){var e=this.viewer,i=this.bufferList;this.dataList.forEach(function(t){t.bufferList.forEach(function(n){i.push(n),e.add(n,t.instanceList)})}),this.setVisibility(this.visible),t()},clear:function(){this.dataList.length=0,Xo.prototype.clear.call(this)},dispose:function(){this.structureView.dispose(),delete this.structure,delete this.structureView,Xo.prototype.dispose.call(this)}}),Vf.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}"),Vf.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}"),ra.prototype=Object.assign(Object.create(Eo.prototype),{constructor:ra,setAttributes:function(t){var e,i,n,r,o,a,s=this.geometry.attributes;t.from&&t.to&&(e=t.from,i=t.to,o=s.position.array,s.position.needsUpdate=!0),t.color&&t.color2&&(n=t.color,r=t.color2,a=s.color.array,s.color.needsUpdate=!0);for(var c,h,u,l,d,f,p,m,g,v,y,b,x=this.size,_=6*x,w=0;w5&&i>15e3||i>7e5){var c=Math.min(1.5,Math.max(.1,2e3/(i/n)));a&&(c=Math.min(c,.15)),e.addRepresentation("surface",{sele:"polymer",surfaceType:"sas",probeRadius:1.4,scaleFactor:c,colorScheme:s,colorScale:"RdYlBu",useWorker:!1})}else i>25e4?e.addRepresentation("backbone",{lineOnly:!0,colorScheme:s,colorScale:"RdYlBu"}):i>1e5?e.addRepresentation("backbone",{quality:"low",disableImpostor:!0,colorScheme:s,colorScale:"RdYlBu",scale:2}):i>8e4?e.addRepresentation("backbone",{colorScheme:s,colorScale:"RdYlBu",scale:2}):(e.addRepresentation("cartoon",{color:s,colorScale:"RdYlBu",scale:.7,aspectRatio:5,quality:"auto"}),i<5e4&&e.addRepresentation("base",{color:s,colorScale:"RdYlBu",quality:"auto"}),e.addRepresentation("ball+stick",{sele:"hetero and not ( water or ion )",colorScheme:"element",scale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));this.centerView(),e.structure.frames.length&&e.addTrajectory()}else"surface"!==e.type&&"volume"!==e.type||(e.addRepresentation("surface"),this.centerView())},loadFile:function(t,e){var i=Object.assign({},this.defaultFileParams,e),n=new ca(this,i);n.name=f(t).name,this.addComponent(n);var r=this.tasks;r.increment();var o=function(t){return this.removeComponent(n),"script"===(n=this.addComponentFromObject(t,i)).type&&n.run(),i.defaultRepresentation&&this.defaultFileRepresentation(n),r.decrement(),n}.bind(this);return("dcd"===h(i.ext,f(t).ext)?Promise.reject("loadFile: ext 'dcd' must be loaded into a structure component"):In(t,i)).then(o,function(t){throw n.setStatus(t),r.decrement(),t})},addComponent:function(t){return t?(this.compList.push(t),void this.signals.componentAdded.dispatch(t)):void Nf.warn("Stage.addComponent: no component given")},addComponentFromObject:function(t,e){var i=Gf.get(t.type);if(i){var n=new i(this,t,e);return this.addComponent(n),n}Nf.warn("no component for object type",t.type)},removeComponent:function(t){var e=this.compList.indexOf(t);-1!==e&&this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t)},removeAllComponents:function(t){this.compList.slice().forEach(function(e){t&&e.type!==t||this.removeComponent(e)},this)},handleResize:function(){this.viewer.handleResize()},toggleFullscreen:function(t){function e(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function i(){if(!e()&&n.lastFullscreenElement){var t=n.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),n.handleResize(),n.signals.fullscreenChanged.dispatch(!1)}}if(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled){var n=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=screen.width+"px",t.style.height=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(){n.handleResize()},100))}else Nf.log("fullscreen mode (currently) not possible")},centerView:function(){if(this.tasks.count>0){var t=function(e,i){0===i&&this.tasks.signals.countChanged.remove(t,this),this.viewer.centerView(!0)};this.tasks.signals.countChanged.add(t,this)}this.viewer.centerView(!0)},setSpin:function(t,e){Array.isArray(t)&&(t=(new A).fromArray(t)),this.viewer.setSpin(t,e)},setOrientation:function(t){this.tasks.onZeroOnce(function(){this.viewer.setOrientation(t)},this)},getOrientation:function(){return this.viewer.getOrientation()},makeImage:function(t){var e=this.viewer,i=this.tasks;return new Promise(function(n,r){i.onZeroOnce(function(){i.increment(),e.makeImage(t).then(function(t){i.decrement(),n(t)}).catch(function(t){i.decrement(),r(t)})})})},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 n=i.getParameters();n.disableImpostor=!t,i.build(n)}})},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(n){if("script"!==n.type){var r=n.getParameters();if(!e.includes(n.getType())){if(!i.includes(n.getType()))return;if(!r.disableImpostor)return void(n.repr.quality=t)}r.quality=t,n.build(r)}})},eachComponent:function(t,e){this.compList.forEach(function(i,n){e&&i.type!==e||t(i,n)})},eachRepresentation:function(t,e){this.eachComponent(function(e){e.reprList.forEach(function(i){t(i,e)})},e)},getComponentsByName:function(t,e){var i=[];return this.eachComponent(function(e){(void 0===t||fa(t,e))&&i.push(e)},e),new la(i)},getRepresentationsByName:function(t,e){var i,n;"object"!=typeof t?(i=void 0,n=t):(i=t.comp,n=t.repr);var r=[];return this.eachRepresentation(function(t,e){(void 0===i||fa(i,e))&&(void 0===n||fa(n,t))&&r.push(t)},e),new da(r)},getAnythingByName:function(t){var e=this.getComponentsByName(t).list,i=this.getRepresentationsByName(t).list;return new ua(e.concat(i))},dispose:function(){this.tasks.dispose()}},ma.prototype={constructor:ma,_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.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()}},pause:function(){this._running&&(this._stopFlag=!0,this.signals.haltedRunning.dispatch())},stop:function(){this.traj.setFrame(this.start),this.pause()}};var pp=function(){function t(t,e){var i,n=0,r={};return e.forEach(function(e){i=0;var o={};e.forEach(function(e){o[t[i++]]=e}),r[t[n++]]=o}),r}return{blosum62:t("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:t("ACDEFGHIKLMNPQRSTVWY",[[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]])}}();ga.prototype={constructor:ga,initMatrices:function(){var t,e;for(this.n=this.seq1.length,this.m=this.seq2.length,this.score=void 0,this.ali="",this.S=[],this.V=[],this.H=[],t=0;t<=this.n;++t)for(this.S[t]=[],this.V[t]=[],this.H[t]=[],e=0;e<=this.m;++e)this.S[t][e]=0,this.V[t][e]=0,this.H[t][e]=0;for(t=0;t<=this.n;++t)this.S[t][0]=this.gap(0),this.H[t][0]=-1/0;for(e=0;e<=this.m;++e)this.S[0][e]=this.gap(0),this.V[0][e]=-1/0;this.S[0][0]=0},gap:function(t){return this.gapPenalty+t*this.gapExtensionPenalty},makeScoreFn:function(){var t,e,i=this.seq1,n=this.seq2,r=this.substMatrix;return r?function(o,a){t=i[o],e=n[a];try{return r[t][e]}catch(t){return-4}}:(Nf.warn("Alignment: no subst matrix"),function(r,o){return t=i[r],e=n[o],t===e?5:-3})},calc:function(){t.Debug&&Nf.time("Alignment.calc"),this.initMatrices();var e,i,n,r,o,a,s,c=this.gap(0),h=this.makeScoreFn(),u=this.gapExtensionPenalty,l=this.V,d=this.H,f=this.S,p=this.n,m=this.m;for(a=1;a<=p;++a)for(i=f[a-1],e=l[a-1],n=l[a],r=d[a],o=f[a],s=1;s<=m;++s)n[s]=Math.max(i[s]+c,e[s]+u),r[s]=Math.max(o[s-1]+c,r[s-1]+u),o[s]=Math.max(i[s-1]+h(a-1,s-1),n[s],r[s]);t.Debug&&Nf.timeEnd("Alignment.calc"),t.Debug&&Nf.log(this.S,this.V,this.H)},trace:function(){t.Debug&&Nf.time("Alignment.trace"),this.ali1="",this.ali2="";var e=this.makeScoreFn(),i=this.n,n=this.m,r="S";for(this.S[i][n]>=this.V[i][n]&&this.S[i][n]>=this.V[i][n]?(r="S",this.score=this.S[i][n]):this.V[i][n]>=this.H[i][n]?(r="V",this.score=this.V[i][n]):(r="H",this.score=this.H[i][n]),t.Debug&&Nf.log("Alignment: SCORE",this.score),t.Debug&&Nf.log("Alignment: S, V, H",this.S[i][n],this.V[i][n],this.H[i][n]);i>0&&n>0;)"S"===r?this.S[i][n]===this.S[i-1][n-1]+e(i-1,n-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--i,--n,r="S"):this.S[i][n]===this.V[i][n]?r="V":this.S[i][n]===this.H[i][n]?r="H":(--i,--n):"V"===r?this.V[i][n]===this.V[i-1][n]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,r="V"):this.V[i][n]===this.S[i-1][n]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,r="S"):--i:"H"===r?this.H[i][n]===this.H[i][n-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--n,r="H"):this.H[i][n]===this.S[i][n-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--n,r="S"):--n:Nf.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;n>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[n-1]+this.ali2,--n;t.Debug&&Nf.timeEnd("Alignment.trace"),t.Debug&&Nf.log([this.ali1,this.ali2])}},ya.prototype=Object.assign(Object.create(ca.prototype),{constructor:ya,type:"script",addRepresentation:function(){},removeRepresentation:function(){},run:function(){var t=this;this.setStatus("running"),this.script.call(this.stage,function(){t.setStatus("finished")}),this.setStatus("called")},dispose:function(){this.signals.disposed.dispatch()},setVisibility:function(){},getCenter:function(){}}),Gf.add("script",ya),ba.prototype=Object.assign(Object.create(ca.prototype),{constructor:ba,type:"shape",addRepresentation:function(t,e){return ca.prototype.addRepresentation.call(this,t,this.shape,e)},centerView:function(t){t=h(t,!0);var e=this.getCenter();if(t){var i=this.shape.boundingBox.size(),n=Math.max(i.x,i.y,i.z),r=Math.min(i.x,i.y,i.z);t=Math.max(1,n+r/2)}return this.viewer.centerView(t,e),this},getCenter:function(){return this.shape.center},dispose:function(){this.shape.dispose(),ca.prototype.dispose.call(this)}}),Gf.add("shape",ba),xa.prototype=Object.assign(Object.create(ca.prototype),{constructor:xa,type:"trajectory",signals:Object.assign({frameChanged:null,playerChanged:null,gotNumframes:null,parametersChanged:null},ca.prototype.signals),addRepresentation:function(t,e){return ca.prototype.addRepresentation.call(this,t,this.trajectory,e)},setFrame:function(t){this.trajectory.setFrame(t)},setParameters:function(t){return this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t),this},dispose:function(){this.trajectory.dispose(),ca.prototype.dispose.call(this)},getCenter:function(){}}),_a.prototype=Object.assign(Object.create(Co.prototype),{constructor:_a,type:"frames",makeAtomIndices:function(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=null},_loadFrame:function(t,e){var i,n=this.frames[t];if(this.atomIndices){var r=this.atomIndices,o=r.length;i=new Float32Array(3*o);for(var a=0;a0&&(n="( "+e.join(" ) AND ( ")+" )"),new Yi(n)},getStructure:function(){return this.structure.getStructure()},eachBond:function(t,e){this.structure.eachBond(t,this.getSelection(e))},eachAtom:function(t,e){var i=this.getAtomProxy(),n=this.getAtomSet(e),r=this.atomStore.count;if(n&&n.size()0?n>w&&(w=n):n>S&&(S=n),Kn(y.copy(t),m,e[3]);var r=x.subVectors(y,e[3]).normalize().dot(m),o=y.distanceTo(e[3]);r>0?o>M&&(M=o):o>P&&(P=o),Kn(b.copy(t),g,e[3]);var a=x.subVectors(b,e[3]).normalize().dot(g),s=b.distanceTo(e[3]);a>0?s>C&&(C=s):s>T&&(T=s)});var E=2*d,I=function(t,i,n){_.copy(e[3]).addScaledVector(p,t).addScaledVector(m,i).addScaledVector(g,n),_.toArray(o,E),E+=3};I(w,M,C),I(w,M,-T),I(w,-P,-T),I(w,-P,C),I(-S,-P,-T),I(-S,-P,C),I(-S,M,C),I(-S,M,-T);var L=d,O=function(t,e){_.fromArray(o,2*d+3*t).toArray(c,L),_.fromArray(o,2*d+3*e).toArray(h,L),L+=3};O(0,1),O(0,3),O(0,6),O(1,2),O(1,7),O(2,3),O(2,4),O(3,5),O(4,5),O(4,7),O(5,6),O(6,7)}return{vertexPosition:o,vertexColor:a,vertexRadius:s,edgePosition1:c,edgePosition2:h,edgeColor:u,edgeRadius:l}},create:function(){var t=this.getAxesData(this.structureView);this.sphereBuffer=new ko(t.vertexPosition,t.vertexColor,t.vertexRadius,void 0,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Vo(t.edgePosition1,t.edgePosition2,t.edgeColor,t.edgeColor,t.edgeRadius,void 0,void 0,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})},updateData:function(t,e){var i=this.getAxesData(e.sview),n={},r={};t&&!t.position||(n.position=i.vertexPosition,r.position1=i.edgePosition1,r.position2=i.edgePosition2),t&&!t.color||(n.color=i.vertexColor,r.color=i.edgeColor,r.color2=i.edgeColor),t&&!t.radius||(n.radius=i.vertexRadius,r.radius=i.edgeRadius),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(r)}}),Uf.add("axes",Ta),Ea.prototype=Object.assign(Object.create(na.prototype),{constructor:Ea,type:"ball+stick",defaultSize:.15,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}},na.prototype.parameters),init:function(t){var e=t||{};e.radius=h(e.radius,this.defaultSize),this.aspectRatio=h(e.aspectRatio,2),this.lineOnly=h(e.lineOnly,!1),this.cylinderOnly=h(e.cylinderOnly,!1),this.multipleBond=h(e.multipleBond,"off"),this.bondSpacing=h(e.bondSpacing,1),this.bondScale=h(e.bondScale,.4),na.prototype.init.call(this,e)},getAtomParams:function(t,e){return e=Object.assign({radiusParams:{radius:this.radius,scale:this.scale*this.aspectRatio}},e),na.prototype.getAtomParams.call(this,t,e)},getAtomData:function(t,e,i){return t.getAtomData(this.getAtomParams(e,i))},getBondParams:function(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},e),na.prototype.getBondParams.call(this,t,e)},getBondData:function(t,e,i){return t.getBondData(this.getBondParams(e,i))},createData:function(t){var e=this.getBondData(t),i=[];if(this.lineOnly)this.lineBuffer=new ra(e.position1,e.position2,e.color1,e.color2,this.getBufferParams()),i.push(this.lineBuffer);else{var n=new Vo(e.position1,e.position2,e.color1,e.color2,e.radius,e.pickingColor1,e.pickingColor2,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(i.push(n),!this.cylinderOnly){var r=this.getAtomData(t),o=new ko(r.position,r.color,r.radius,r.pickingColor,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));i.push(o)}}return{bufferList:i}},updateData:function(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);var i=this.getBondData(e.sview,t);if(this.lineOnly){var n={};t&&!t.position||(n.from=i.position1,n.to=i.position2),t&&!t.color||(n.color=i.color1,n.color2=i.color2),e.bufferList[0].setAttributes(n)}else{var r={};if(t&&!t.position||(r.position1=i.position1,r.position2=i.position2),t&&!t.color||(r.color=i.color1,r.color2=i.color2),t&&!t.radius||(r.radius=i.radius),e.bufferList[0].setAttributes(r),!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)}}},setParameters:function(t){var e=!1,i={};return t&&(t.aspectRatio||t.bondSpacing||t.bondScale)&&(i.radius=!0,Df&&!this.disableImpostor||(e=!0)),na.prototype.setParameters.call(this,t,i,e),this}}),Uf.add("ball+stick",Ea),Ia.prototype=Object.assign(Object.create(Ea.prototype),{constructor:Ia,type:"backbone",defaultSize:.25,parameters:Object.assign({},Ea.prototype.parameters,{multipleBond:null,bondSpacing:null}),init:function(t){var e=t||{};e.aspectRatio=h(e.aspectRatio,1),Ea.prototype.init.call(this,e)},getAtomData:function(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))},getBondData:function(t,e,i){var n=this.getBondParams(e,i);return n.colorParams.backbone=!0,t.getBackboneBondData(n)}}),Uf.add("backbone",Ia),La.prototype=Object.assign(Object.create(Ea.prototype),{constructor:La,type:"base",defaultSize:.3,parameters:Object.assign({},Ea.prototype.parameters,{multipleBond:null,bondSpacing:null}),init:function(t){var e=t||{};e.aspectRatio=h(e.aspectRatio,1),Ea.prototype.init.call(this,e)},getAtomData:function(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))},getBondData:function(t,e,i){var n=this.getBondParams(e,i);return n.colorParams.rung=!0,t.getRungBondData(n)}}),Uf.add("base",La),Oa.prototype={constructor:Oa,getAtomIterator:function(t,e){var i=this.polymer,n=i.structure,r=i.residueCount,o=0,a=-1,s=[n.getAtomProxy(),n.getAtomProxy(),n.getAtomProxy(),n.getAtomProxy()],c=[new A,new A,new A,new A],h=n.getAtomProxy(),u=n.getAtomProxy();return{size:r,next:function(){var t=this.get(a);return a+=1,t},get:function(n){var a=s[o%4];if(a.index=i.getAtomIndexByType(n,t),e&&n>0&&ne)&&(s=!0,r.add_unsafe(n.index),o.addBond(a,n,1))}s&&r.add_unsafe(a.index)});var a=new rp(o.count);return a.set_all(!0),Nf.timeEnd("Contact within"),{atomSet:r,bondSet:a,bondStore:o}}},za.prototype=Object.assign(Object.create(na.prototype),{constructor:za,type:"contact",defaultSize:.25,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},na.prototype.parameters),init:function(t){var e=t||{};e.radius=h(e.radius,this.defaultSize),this.contactType=h(e.contactType,"polarBackbone"),this.maxDistance=h(e.maxDistance,3.5),this.maxAngle=h(e.maxAngle,40),na.prototype.init.call(this,e)},getContactData:function(t){return{polar:ka,polarBackbone:Fa}[this.contactType](t,this.maxDistance,this.maxAngle)},getBondData:function(t,e,i){return t.getBondData(this.getBondParams(e,i))},createData:function(t){var e=this.getContactData(t),i={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(t,void 0,i);return{bufferList:[new Vo(n.position1,n.position2,n.color1,n.color2,n.radius,n.pickingColor1,n.pickingColor2,this.getBufferParams({openEnded:!1,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],bondSet:e.bondSet,bondStore:e.bondStore}},updateData:function(t,e){if(!t||t.position){var i=this.getContactData(e.sview);e.bondSet=i.bondSet,e.bondStore=i.bondStore}var n={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,n),o={};t&&!t.position||(o.position=$n(r.position1,r.position2),o.position1=r.position1,o.position2=r.position2),t&&!t.color||(o.color=r.color1,o.color2=r.color2),t&&!t.radius||(o.radius=r.radius),e.bufferList[0].setAttributes(o)}}),Uf.add("contact",za),Vf.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;\nvarying vec3 vViewPosition;\nvarying vec2 texCoord;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec2 mapping;\nattribute vec2 inputTexCoord;\nattribute float inputSize;\n#include color_pars_vertex\n#include common\nvoid main(void){\n#include color_vertex\ntexCoord = inputTexCoord;\nfloat _zOffset = zOffset;\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;\ncameraCornerPos.x += xOffset;\ncameraCornerPos.y += yOffset;\nif( !ortho ){\ncameraCornerPos.xyz += normalize( -cameraCornerPos.xyz ) * _zOffset;\n}\ngl_Position = projectionMatrix * cameraCornerPos;\nvViewPosition = -cameraCornerPos.xyz;\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n#include radiusclip_vertex\n}"),Vf.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#include common\n#include color_pars_fragment\n#include fog_pars_fragment\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#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n}");var mp=function(){var t={};return function(e){var i=JSON.stringify(e);return void 0===t[i]&&(t[i]=new Ba(e)),t[i]}}();Ba.prototype={constructor:Ba,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 n=i.getContext("2d");n.font=this.style+" "+this.variant+" "+this.weight+" "+this.size+"px "+this.font,n.fillStyle="#FF0000",n.textAlign="left",n.textBaseline="bottom",n.lineJoin="round";for(var r=[],o=3*this.outline,a=0;athis.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY,this.scratchH,this.height,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]},draw:function(t){var e,i,n,r,o,a=this.lineHeight,s=this.outline,c=this.context,h=this.scratch,u=this.maxWidth,l=this.colors,d=s,f=a-this.outline,p=c.measureText(t),m=Math.min(u,Math.ceil(p.width+2*d+1));if(c.clearRect(0,0,m,a),0===this.outline)for(c.fillText(t,d,f),n=3,e=0,i=(o=(r=c.getImageData(0,0,m,a)).data).length/4;e0;--e)n=e>1?2*e-2:e,c.strokeStyle=l[n-1],c.lineWidth=n,c.strokeText(t,d,f);c.globalCompositeOperation="multiply",c.fillStyle="#FF00FF",c.fillText(t,d,f),o=(r=c.getImageData(0,0,m,a)).data,n=0;var g=this.gamma;for(e=0,i=o.length/4;e0&&(i-=u,r=r.subarray(0,3*i));var l=new rp(s.count);return l.set_all(!0),{text:n,position:r,bondSet:l,bondStore:s}},getBondData:function(t,e,i){return t.getBondData(this.getBondParams(e,i))},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 dt(this.labelColor);this.textBuffer=new Ua(e.position,Vn(t,this.labelSize),jn(t,i.r,i.g,i.b),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 n={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(this.structureView,void 0,n);this.cylinderBuffer=new Vo(r.position1,r.position2,r.color1,r.color2,r.radius,void 0,void 0,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]})}}},update:function(t){t.position?this.build():na.prototype.update.call(this,t)},updateData:function(t,e){var i={bondSet:e.bondSet,bondStore:e.bondStore},n=this.getBondData(e.sview,t,i),r={},o={},a=this.atomPair.length;if(t.labelSize&&(o.size=Vn(a,this.labelSize)),t.labelColor){var s=new dt(this.labelColor);o.color=jn(a,s.r,s.g,s.b)}t.color&&(r.color=n.color1,r.color2=n.color2),(t.radius||t.scale)&&(r.radius=n.radius),this.textBuffer.setAttributes(o),this.cylinderBuffer.setAttributes(r)},setVisibility:function(t,e){return na.prototype.setVisibility.call(this,t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),e||this.viewer.requestRender(),this},setParameters:function(t){var e={};return t&&t.labelSize&&(e.labelSize=!0),t&&t.labelColor&&(e.labelColor=!0),na.prototype.setParameters.call(this,t,e,!1),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this}}),Uf.add("distance",$a),Va.prototype=Object.assign(Object.create(Eo.prototype),{constructor:Va,setAttributes:function(t){var e,i,n,r=this.geometry.attributes;t.position&&t.vector&&(e=t.position,i=t.vector,n=r.position.array,r.position.needsUpdate=!0);var o,a,s=this.size,c=this.scale;if(t.position&&t.vector)for(var h=0;h 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}"),Vf.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;\nvarying vec3 vPickingColor2;\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\nif( distance_ratio > 0.5 ){\ngl_FragColor = vec4( vPickingColor, objectId );\n}else{\ngl_FragColor = vec4( vPickingColor2, objectId );\n}\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}"),Ha.prototype=Object.assign(Object.create(Ro.prototype),{constructo:Ha});var gp=new w;Xa.prototype=Object.assign(Object.create(Ha.prototype),{constructor:Xa,parameters:Object.assign({shrink:{uniform:!0}},Ha.prototype.parameters)}),Ya.prototype=Object.assign(Object.create(Ga.prototype),{constructor:Ya,type:"hyperball",defaultSize:1,parameters:Object.assign({shrink:{type:"number",precision:3,max:1,min:.001,buffer:!0}},Ga.prototype.parameters,{multipleBond:null,bondSpacing:null}),init:function(t){var e=t||{};e.scale=h(e.scale,.2),e.radius=h(e.radius,"vdw"),this.shrink=h(e.shrink,.12),Ga.prototype.init.call(this,e)},getBondParams:function(t,e){return t&&!t.radius||(e=Object.assign({radius2:!0},e)),Ga.prototype.getBondParams.call(this,t,e)},createData:function(t){var e=t.getAtomData(this.getAtomParams()),i=t.getBondData(this.getBondParams()),n=new ko(e.position,e.color,e.radius,e.pickingColor,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));return this.__center=new Float32Array(3*t.bondCount),{bufferList:[n,new qa(i.position1,i.position2,i.color1,i.color2,i.radius1,i.radius2,i.pickingColor1,i.pickingColor2,this.getBufferParams({shrink:this.shrink,radialSegments:this.radialSegments,dullInterior:!0}),this.disableImpostor)]}},updateData:function(t,e){var i=e.sview.getAtomData(this.getAtomParams()),n=e.sview.getBondData(this.getBondParams()),r={},o={};if(!t||t.position){r.position=i.position;var a=n.position1,s=n.position2;o.position=$n(a,s,this.__center),o.position1=a,o.position2=s}t&&!t.color||(r.color=i.color,o.color=n.color1,o.color2=n.color2),t&&!t.radius||(r.radius=i.radius,o.radius=n.radius1,o.radius2=n.radius2),e.bufferList[0].setAttributes(r),e.bufferList[1].setAttributes(o)}}),Uf.add("hyperball",Ya),Za.prototype={constructor:Za,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=(Gl[i]||i)+t.resno;break;case"text":e=this.text[t.index];break;default:e=t.qualifiedName()}return void 0===e?"":e}},Za.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"},Ka.prototype=Object.assign(Object.create(na.prototype),{constructor:Ka,type:"label",parameters:Object.assign({labelType:{type:"select",options:Za.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}},na.prototype.parameters,{side:null,flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null,diffuse:null}),init:function(t){var e=t||{};this.labelType=h(e.labelType,"res"),this.labelText=h(e.labelText,{}),this.fontFamily=h(e.fontFamily,"sans-serif"),this.fontStyle=h(e.fontStyle,"normal"),this.fontWeight=h(e.fontWeight,"bold"),this.sdf=h(e.sdf,"Chrome"===Lf),this.xOffset=h(e.xOffset,0),this.yOffset=h(e.yOffset,0),this.zOffset=h(e.zOffset,.5),this.attachment=h(e.attachment,"bottom-left"),this.showBorder=h(e.showBorder,!1),this.borderColor=h(e.borderColor,"lightgrey"),this.borderWidth=h(e.borderWidth,.15),this.showBackground=h(e.showBackground,!1),this.backgroundColor=h(e.backgroundColor,"lightgrey"),this.backgroundMargin=h(e.backgroundMargin,.5),this.backgroundOpacity=h(e.backgroundOpacity,1),na.prototype.init.call(this,e)},createData:function(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,radius:!0})),i=[],n=new Za(this.labelType,this.labelText);return t.eachAtom(function(t){i.push(n.atomLabel(t))}),{bufferList:[new Ua(e.position,e.radius,e.color,i,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}))]}},updateData:function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),n={};t&&!t.position||(n.position=i.position),t&&!t.radius||(n.size=i.radius),t&&!t.color||(n.color=i.color),e.bufferList[0].setAttributes(n)}}),Uf.add("label",Ka),Qa.prototype=Object.assign(Object.create(na.prototype),{constructor:Qa,type:"line",parameters:Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5}},Xo.prototype.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null,diffuse:null}),init:function(t){var e=t||{};this.multipleBond=h(e.multipleBond,"off"),this.bondSpacing=h(e.bondSpacing,1),na.prototype.init.call(this,e)},getBondParams:function(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{radius:.1,scale:1}},e),na.prototype.getBondParams.call(this,t,e)},createData:function(t){var e=t.getBondData(this.getBondParams({position:!0,color:!0}));return{bufferList:[new ra(e.position1,e.position2,e.color1,e.color2,this.getBufferParams())]}},updateData:function(t,e){var i=e.sview.getBondData(this.getBondParams(t)),n={};t&&!t.position||(n.from=i.position1,n.to=i.position2),t&&!t.color||(n.color=i.color1,n.color2=i.color2),e.bufferList[0].setAttributes(n)},setParameters:function(t){var e={};return t&&t.bondSpacing&&(e.position=!0),na.prototype.setParameters.call(this,t,e,!1),this}}),Uf.add("line",Qa),ts.__deps=[wo,_o,So,Qn,Ja],is.__deps=[wo,So,Vn,Qn,cr,nr,hr,es,h],Ff.add("molsurf",function(t,e){var i=t.data.args,n=t.data.params;if(i&&n){var r=new("av"===n.type?is:ts)(i.coordList,i.radiusList,i.indexList).getSurface(n.type,n.probeRadius,n.scaleFactor,n.cutoff,!0,n.smooth,n.contour),o=[r.position.buffer,r.index.buffer];r.normal&&o.push(r.normal.buffer),r.atomindex&&o.push(r.atomindex.buffer),e({sd:r,p:n},o)}},[ts,is]),ns.prototype={getAtomData:function(){return this.structure.getAtomData({what:{position:!0,radius:!0,index:!0},radiusParams:{radius:"vdw",scale:1}})},makeSurface:function(t,e){var i=new lo("","",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},getSurface:function(t){var e=t||{},i=this.getAtomData(),n=i.position,r=i.radius,o=i.index,a=new("av"===e.type?is:ts)(n,r,o).getSurface(e.type,e.probeRadius,e.scaleFactor,e.cutoff,!0,e.smooth,e.contour);return this.makeSurface(a,e)},getSurfaceWorker:function(t,e){var i=Object.assign({},t);if(window.Worker){void 0===this.worker&&(this.worker=new fo("molsurf"));var n=this.getAtomData(),r=n.position,o=n.radius,a=n.index,s={args:{coordList:r,radiusList:o,indexList:a},params:i},c=[r.buffer,o.buffer,a.buffer];this.worker.post(s,c,function(t){var n=t.data.sd;e(this.makeSurface(n,i))}.bind(this),function(t){this.worker.terminate(),this.worker=void 0;var n=this.getSurface(i);e(n)}.bind(this))}else{var h=this.getSurface(i);e(h)}},dispose:function(){this.worker&&this.worker.terminate()}},rs.prototype=Object.assign(Object.create(Eo.prototype),{constructor:rs,setAttributes:function(t){var e=this.geometry.attributes;t.color&&(e.color.array.set(t.color),e.color.needsUpdate=!0),t.index&&(e.index.array.set(t.index),e.index.needsUpdate=!0)}}),os.prototype=Object.assign(Object.create(na.prototype),{constructor:os,type:"surface",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},volume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},na.prototype.parameters,{radiusType:null,radius:null,scale:null}),init:function(t){var e=t||{};e.colorScheme=h(e.colorScheme,"uniform"),e.colorValue=h(e.colorValue,14540253),this.surfaceType=h(e.surfaceType,"ms"),this.probeRadius=h(e.probeRadius,1.4),this.smooth=h(e.smooth,2),this.scaleFactor=h(e.scaleFactor,2),this.cutoff=h(e.cutoff,0),this.contour=h(e.contour,!1),this.background=h(e.background,!1),this.opaqueBack=h(e.opaqueBack,!0),this.filterSele=h(e.filterSele,""),this.volume=h(e.volume,void 0),this.useWorker=h(e.useWorker,!0),na.prototype.init.call(this,t)},prepareData:function(t,e,i){var n=this.__infoList[e];if(n||(n={},this.__infoList[e]=n),n.molsurf&&n.sele===t.selection.string)i(e);else{if(this.filterSele){var r=t.structure.getView(new Yi(this.filterSele)),o=r.boundingBox.size(),a=Math.max(o.x,o.y,o.z),s=t.getAtomSetWithinPoint(r.center,a/2);t=t.getView(new Yi(t.getAtomSetWithinSelection(s,3).toSeleString()))}n.sele=t.selection.string,n.molsurf=new ns(t);var c=this.getSurfaceParams(),h=function(t){n.surface=t,i(e)};this.useWorker?n.molsurf.getSurfaceWorker(c,h):h(n.molsurf.getSurface(c))}},prepare:function(t){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach(function(t){t.molsurf.dispose()}.bind(this)),this.__infoList.length=0),0!==this.structureView.atomCount){var e=function(){this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()}.bind(this),i="default"===this.assembly?this.defaultAssembly:this.assembly,n=this.structure.biomolDict[i];n?n.partList.forEach(function(t,i){var r=t.getView(this.structureView);this.prepareData(r,i,function(t){t===n.partList.length-1&&e()}.bind(this))},this):this.prepareData(this.structureView,0,e)}else t()},createData:function(t,e){var i=this.__infoList[e],n=i.surface.getPosition(),r=i.surface.getColor(this.getColorParams()),o=i.surface.getFilteredIndex(this.filterSele,t);return i.surface.contour?{bufferList:[new rs(n,r,o,this.getBufferParams({wireframe:!1}))],info:i}:{bufferList:[new Zo(new Yo(n,r,o,i.surface.getNormal(),i.surface.getPickingColor(this.getColorParams()),this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1})))],info:i}},updateData:function(t,e){var i={};return t.position?(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)),void e.bufferList[0].setAttributes(i))},setParameters:function(t,e,i){return e=e||{},t&&t.filterSele&&(e.index=!0),t&&void 0!==t.volume&&(e.color=!0),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),na.prototype.setParameters.call(this,t,e,i),this},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)},getColorParams:function(){var t=na.prototype.getColorParams.call(this);return t.volume=this.volume,t},clear:function(){na.prototype.clear.call(this)},dispose:function(){this.__infoList.forEach(function(t){t.molsurf.dispose()}.bind(this)),this.__infoList.length=0,na.prototype.dispose.call(this)}}),Uf.add("surface",os),as.prototype=Object.assign(Object.create(na.prototype),{constructor:as,type:"point",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}},Xo.prototype.parameters,{flatShaded:null,wireframe:null,linewidth:null,roughness:null,metalness:null}),init:function(t){var e=t||{};this.pointSize=h(e.pointSize,1),this.sizeAttenuation=h(e.sizeAttenuation,!0),this.sortParticles=h(e.sortParticles,!1),this.useTexture=h(e.useTexture,!1),this.alphaTest=h(e.alphaTest,.5),this.forceTransparent=h(e.forceTransparent,!1),this.edgeBleach=h(e.edgeBleach,0),na.prototype.init.call(this,e)},createData:function(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0}));return{bufferList:[new Jo(e.position,e.color,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}},updateData:function(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),n={};t&&!t.position||(n.position=i.position),t&&!t.color||(n.color=i.color),e.bufferList[0].setAttributes(n)}}),Uf.add("point",as),Vf.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\nattribute vec3 pickingColor;\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 = pickingColor;\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}"),ss.prototype=Object.assign(Object.create(Eo.prototype),{constructor:ss,setAttributes:function(t){var e,i,n,r,o,a,s,c,h,u,l,d,f=this.size/4,p=this.geometry.attributes;t.position&&(e=t.position,s=p.position.array,p.position.needsUpdate=!0),t.normal&&(i=t.normal,c=p.normal.array,p.normal.needsUpdate=!0),t.size&&(n=t.size,h=p.size.array,p.size.needsUpdate=!0),t.dir&&(r=t.dir,u=p.dir.array,p.dir.needsUpdate=!0),t.color&&(o=t.color,l=p.color.array,p.color.needsUpdate=!0),t.pickingColor&&(a=t.pickingColor,d=p.pickingColor.array,p.pickingColor.needsUpdate=!0);var m,g,v,y,b,x,_,w=n?n[0]:null;for(m=0;mx)continue}d=T.substr(5,5).trim(),f=parseInt(T.substr(0,5)),p=parseInt(T.substr(15,5)),w.growIfFull(),w.atomTypeId[S]=_.add(l),w.x[S]=L,w.y[S]=O,w.z[S]=R,w.serial[S]=p,r.addAtom(A,"","",d,f,0,"l"),S+=1}}}(0,t.length,t)}),n.unitcell=new ys(h[0][0],h[0][4],h[0][8],90,90,90,"P 1"),r.finalize(),n.finalizeAtoms(),Yr(n),Zr(n),n.finalizeBonds(),hp(n),to(n),t.Debug&&Nf.timeEnd("GroParser._parse "+this.name)}}),$f.add("gro",bs),xs.prototype={constructor:xs,type:"Entity",getEntityType:function(){return this.entityType},isPolymer:function(){return this.entityType===Al},isNonPolymer:function(){return this.entityType===Ml},isMacrolide:function(){return this.entityType===Pl},isWater:function(){return this.entityType===Cl},eachChain:function(t){var e=this.structure.getChainProxy();this.chainIndexList.forEach(function(i){e.index=i,t(e)})}};var vp={1:"h",2:"h",3:"i",4:"h",5:"g",6:"h",7:"h",8:"h",9:"h",10:"h","":"h"};_s.prototype=Object.assign(Object.create(vs.prototype),{constructor:_s,type:"pdb",_parse:function(){t.Debug&&Nf.time("PdbParser._parse "+this.name);var e,i,n,r,o,a,s,c,h,u,l,d,f,p,m,g,v,y,b,x,_,S,A,M,P,C,T,E,I,L,O,R,D="pqr"===this.type,N=/\s+/,k=this.structure,F=this.structureBuilder,z=this.firstModelOnly,B=this.asTrajectory,U=this.cAlphaOnly,$=k.frames,V=k.boxes,j=!1,G=k.biomolDict,H={},W={},X={},q=[],Y=["MOL_ID","MOLECULE","CHAIN","FRAGMENT","SYNONYM","EC","ENGINEERED","MUTATION","OTHER_DETAILS"],Z={},K={},Q={helices:[],sheets:[]},J=Q.helices,tt=Q.sheets,et=k.atomMap,it=k.atomStore;it.resize(Math.round(this.streamer.data.length/80));var nt=k.getAtomProxy(),rt=k.getAtomProxy(),ot=0,at=0,st=!0;this.streamer.eachChunkOfLines(function(t){!function(t,Q,ct){for(var ht,ut,lt=t;lt0)continue;var dt,ft,pt,mt,gt,vt;if(D){if(gt=10===(mt=a.split(N)).length?1:0,p=mt[2],U&&"CA"!==p)continue;dt=parseFloat(mt[6-gt]),ft=parseFloat(mt[7-gt]),pt=parseFloat(mt[8-gt])}else{if(p=a.substr(12,4).trim(),U&&"CA"!==p)continue;dt=parseFloat(a.substr(30,8)),ft=parseFloat(a.substr(38,8)),pt=parseFloat(a.substr(46,8))}if(B&&(e[0+(ht=3*i)]=dt,e[ht+1]=ft,e[ht+2]=pt,i+=1,j))continue;D?(c=parseInt(mt[1]),vt="",m="H"===a[0]?1:0,h=gt?"":mt[4],u=parseInt(mt[5-gt]),f="",l=mt[3],g=parseFloat(mt[9-gt]),v="",d=0):(c=parseInt(a.substr(6,5)),vt=a.substr(76,2).trim(),m="H"===a[0]?1:0,h=a[21].trim()||a.substr(72,4).trim(),u=parseInt(a.substr(22,4)),f=a[26].trim(),l=a.substr(17,4).trim(),g=parseFloat(a.substr(60,6)),v=a[16].trim(),d=parseFloat(a.substr(54,6))),it.growIfFull(),it.atomTypeId[ot]=et.add(p,vt),it.x[ot]=dt,it.y[ot]=ft,it.z[ot]=pt,it.serial[ot]=c,it.bfactor[ot]=isNaN(g)?0:g,it.altloc[ot]=v.charCodeAt(0),it.occupancy[ot]=isNaN(d)?0:d,m?I===h&&O===l&&(Yl.includes(l)||L===u&&R===f)||(T=(C+=1).toString(),L=u,O=l,R=f):E||I===h||(T=(C+=1).toString()),F.addAtom(at,h,T,l,u,m,void 0,f),H[c]=ot,ot+=1,E=!1,I=h}else if("CONECT"===s){var yt=H[parseInt(a.substr(6,5))],bt=[11,16,21,26],xt={};if(void 0===yt)continue;for(ht=0;ht<4;++ht){var _t=parseInt(a.substr(bt[ht],5));if(!Number.isNaN(_t)&&void 0!==(_t=H[_t]))if(yt<_t?(nt.index=yt,rt.index=_t):(nt.index=_t,rt.index=yt),void 0!==xt[_t])k.bondStore.bondOrder[xt[_t]]+=1;else{var wt=nt.index+"|"+rt.index;void 0===X[wt]&&(X[wt]=!0,xt[_t]=k.bondStore.count,k.bondStore.addBond(nt,rt,1))}}}else if("HELIX "===s){y=a[19].trim(),b=parseInt(a.substr(21,4)),x=a[25].trim(),_=a[31].trim(),S=parseInt(a.substr(33,4)),A=a[37].trim();var St=parseInt(a.substr(39,1));St=(vp[St]||vp[""]).charCodeAt(0),J.push([y,b,x,_,S,A,St])}else if("SHEET "===s)y=a[21].trim(),b=parseInt(a.substr(22,4)),x=a[26].trim(),_=a[32].trim(),S=parseInt(a.substr(33,4)),A=a[37].trim(),tt.push([y,b,x,_,S,A]);else if("HETNAM"===s)K[a.substr(11,3)]=a.substr(15).trim();else if("COMPND"===s){var At,Mt=a.substr(10,70).trim(),Pt=Mt.indexOf(":"),Ct=Mt.substring(0,Pt);Y.includes(Ct)?(P=Ct,At=Mt.substring(Pt+2)):At=Mt,At=At.replace(/;$/,""),"MOL_ID"===P?(M={chainList:[],name:""},q.push(M)):"MOLECULE"===P?(M.name&&(M.name+=" "),M.name+=At):"CHAIN"===P&&Array.prototype.push.apply(M.chainList,At.split(/\s*,\s*/))}else if(a.startsWith("TER")){var Tt=k.getChainProxy(k.chainStore.count-1);Z[Tt.chainname]=Tt.index,T=(C+=1).toString(),E=!0}else if("REMARK"===s&&"350"===a.substr(7,3)){if("BIOMOLECULE:"===a.substr(11,12)){var Et=a.substr(23).trim();/^(0|[1-9][0-9]*)$/.test(Et)&&(Et="BU"+Et),n=new Wr(Et),G[Et]=n}else if("BIOMT"===a.substr(13,5)){var It=a.split(/\s+/),Lt=parseInt(a[18])-1;0===Lt&&(o=new w,r.matrixList.push(o));var Ot=o.elements;Ot[0+Lt]=parseFloat(It[4]),Ot[4+Lt]=parseFloat(It[5]),Ot[8+Lt]=parseFloat(It[6]),Ot[12+Lt]=parseFloat(It[7])}else if("APPLY THE FOLLOWING TO CHAINS:"===a.substr(11,30)||" AND CHAINS:"===a.substr(11,30)){"APPLY"===a.substr(11,5)&&(r=n.addPart());var Rt=a.substr(41,30).split(",");for(ut=Rt.length;ht0)continue;var at=rt[c].replace(xp,"");if(C&&"CA"!==at)continue;var st=parseFloat(rt[y]),ct=parseFloat(rt[b]),ht=parseFloat(rt[x]);if(P){var ut=3*n;if(i[ut+0]=st,i[ut+1]=ct,i[ut+2]=ht,n+=1,X>0)continue}var lt=rt[h],dt=parseInt(rt[s]),ft=rt[v];ft="?"===ft?"":ft;var pt=rt[a],mt=rt[u],gt="H"===rt[f][0]?1:0,vt=rt[m],yt=parseFloat(rt[_]),bt=parseFloat(rt[w]),xt=rt[d];if(xt="."===xt?"":xt,G.growIfFull(),G.atomTypeId[W]=j.add(at,vt),G.x[W]=st,G.y[W]=ct,G.z[W]=ht,G.serial[W]=parseInt(rt[p]),G.bfactor[W]=isNaN(yt)?0:yt,G.occupancy[W]=isNaN(bt)?0:bt,G.altloc[W]=xt.charCodeAt(0),A.addAtom(X,pt,mt,lt,dt,gt,void 0,ft),t.Debug){var _t=I[mt];void 0!==_t&&_t!==pt&&Nf.warn(_t,pt)}I[mt]=pt;var wt=rt[l];L[wt]||(L[wt]=new Set),L[wt].add(S.chainStore.count-1),W+=1}else{nt=(rt=o.match(bp)).length,z===F.length&&(z=0);for(var St=0;Stw){var S=_;_=w,w=S;var A=p;p=b,b=A}if(0!==_&&0!==w)for(var M=0;M0&&(h=!0))),_>=p&&_0)continue;var C=parseFloat(P.substr(0,10)),T=parseFloat(P.substr(10,10)),E=parseFloat(P.substr(20,10));if(r){var I=3*s;if(a[I+0]=C,a[I+1]=T,a[I+2]=E,s+=1,h)continue}var L=P.substr(31,3).trim(),O=L+(x+1);l.growIfFull(),l.atomTypeId[x]=u.add(O,L),l.x[x]=C,l.y[x]=T,l.z[x]=E,l.serial[x]=x,i.addAtom(w,"","","HET",1,1),x+=1}if(_>=g&&_0)continue;if(r&&w>0)continue;y.index=parseInt(P.substr(0,3))-1+S,b.index=parseInt(P.substr(3,3))-1+S;var R=parseInt(P.substr(6,3));e.bondStore.addBond(y,b,R)}++_}}(0,t.length,t)}),i.finalize(),e.finalizeAtoms(),e.finalizeBonds(),eo(e),t.Debug&&Nf.timeEnd("SdfParser._parse "+this.name)},_postProcess:function(){eo(this.structure)}}),$f.add("sdf",Es),Is.prototype=Object.assign(Object.create(vs.prototype),{constructor:Is,type:"mol2",_parse:function(){t.Debug&&Nf.time("Mol2Parser._parse "+this.name);var e,i,n=/\s+/,r=this.structure,o=this.structureBuilder,a=this.firstModelOnly,s=this.asTrajectory,c=r.frames,h=!1,u=r.atomMap,l=r.atomStore;l.resize(Math.round(this.streamer.data.length/60));var d=0,f=0,p=0,m=-1,g=0,v=0,y=1,b=2,x=3,_=r.getAtomProxy(),w=r.getAtomProxy(),S={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};this.streamer.eachChunkOfLines(function(t){!function(t,A,M){for(var P,C=t;CMOLECULE"===T?(v=y,f=0,++m):"@ATOM"===T?(v=b,p=l.count,s&&(i=0,e=new Float32Array(3*g),c.push(e),m>0&&(h=!0))):v="@BOND"===T?x:0;else if(v===y)0===f?(r.title=T,r.id=T):1===f&&(P=T.split(n),g=parseInt(P[0])),++f;else if(v===b){if(P=T.split(n),a&&m>0)continue;var E=parseFloat(P[2]),I=parseFloat(P[3]),L=parseFloat(P[4]);if(s){var O=3*i;if(e[O+0]=E,e[O+1]=I,e[O+2]=L,i+=1,h)continue}var R=P[0],D=P[1],N=P[5].split(".")[0],k=P[6]?parseInt(P[6]):1,F=P[7]?P[7]:"",z=P[8]?parseFloat(P[8]):0;l.growIfFull(),l.atomTypeId[d]=u.add(D,N),l.x[d]=E,l.y[d]=I,l.z[d]=L,l.serial[d]=R,l.bfactor[d]=z,o.addAtom(m,"","",F,k,1),d+=1}else if(v===x){if(a&&m>0)continue;if(s&&m>0)continue;P=T.split(n),_.index=parseInt(P[1])-1+p,w.index=parseInt(P[2])-1+p;var B=S[P[3]];r.bondStore.addBond(_,w,B)}}}(0,t.length,t)}),o.finalize(),r.finalizeAtoms(),Yr(r),Qr(r,!0),Jr(r,!0),r.finalizeBonds(),eo(r),hp(r),t.Debug&&Nf.timeEnd("Mol2Parser._parse "+this.name)}}),$f.add("mol2",Is);var wp=["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"]),Sp={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)};Hs.prototype=Object.assign(Object.create(vs.prototype),{constructor:Hs,type:"mmtf",_parse:function(){t.Debug&&Nf.time("MmtfParser._parse "+this.name);var e,i,n,r,o,a,s,c,h,u,l,d=this.structure,f=Gs(function(t){function e(t){for(var e={},i=0;in){for(var r=[],o=0;o0&&(d.biomolDict.NCS=at)}f.unitCell&&Array.isArray(f.unitCell)&&f.unitCell[0]?d.unitcell=new ys(f.unitCell[0],f.unitCell[1],f.unitCell[2],f.unitCell[3],f.unitCell[4],f.unitCell[5],f.spaceGroup):d.unitcell=void 0,t.Debug&&Nf.timeEnd("MmtfParser._parse "+this.name),Jr(d,!0),Qr(d,!0),d.finalizeAtoms(),d.finalizeBonds(),to(d)}}),$f.add("mmtf",Hs),Ws.prototype={constructor:Ws,type:"Frames"},Xs.prototype=Object.assign(Object.create(gs.prototype),{constructor:Xs,type:"trajectory",__objName:"frames"}),qs.prototype=Object.assign(Object.create(Xs.prototype),{constructor:qs,type:"dcd",_parse:function(){t.Debug&&Nf.time("DcdParser._parse "+this.name);var e=this.streamer.data;e instanceof Uint8Array&&(e=e.buffer);var i,n,r=new DataView(e),o=this.frames,a=o.coordinates,s=o.boxes,c={},h=0,u=new Int32Array(e,0,23),l=u[0]!==r.getInt32(0);if(84!==u[0])for(n=e.byteLength,i=0;i0)Nf.error("dcd format with fixed atoms unsupported, aborting");else{var y=c.NATOM,b=4*y;for(i=0,n=c.NSET;i0?0:1;this.streamer.eachChunkOfLines(function(t){!function(t,e,i){for(var n=t;n=r.atomCount+6+u)for(var l=0,d=(a=a.split(o)).length;lo){var r=i[n].trim();if(""!==r)for(var l=r.split(a),d=0,f=l.length;d=s&&(g-s)%v!=0&&m=n.elements[a].count&&(a++,s=0);var u=this.parseASCIIElement(n.elements[a].properties,h);this.handleElement(i,n.elements[a].name,u),s++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e=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 n=this.vertices,r=this.object.geometry.vertices;r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[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 n=this.normals,r=this.object.geometry.normals;r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addFace:function(t,e,i,n,r,o,a,s){var c,h=this.vertices.length,u=this.parseVertexIndex(t,h),l=this.parseVertexIndex(e,h),d=this.parseVertexIndex(i,h);if(void 0===n?this.addVertex(u,l,d):(c=this.parseVertexIndex(n,h),this.addVertex(u,l,c),this.addVertex(l,d,c)),void 0!==r){var f=this.normals.length;u=this.parseNormalIndex(r,f),l=r===o?u:this.parseNormalIndex(o,f),d=r===a?u:this.parseNormalIndex(a,f),void 0===n?this.addNormal(u,l,d):(c=this.parseNormalIndex(s,f),this.addNormal(u,l,c),this.addNormal(l,d,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,n=t.length;i0?b.addAttribute("normal",new Et(new Float32Array(y.normals),3)):b.computeVertexNormals(),v.push(b)}}return v}},oc.prototype=Object.assign(Object.create(ec.prototype),{constructor:oc,type:"obj"}),$f.add("obj",oc),ac.prototype=Object.assign(Object.create(gs.prototype),{constructor:ac,type:"text",__objName:"text",_parse:function(){this.text.data=this.streamer.asText()}}),$f.add("txt",ac),$f.add("text",ac),sc.prototype=Object.assign(Object.create(gs.prototype),{constructor:sc,type:"csv",__objName:"table",_parse:function(){var t=this.table.data,e=/\s*,\s*/;this.streamer.eachChunkOfLines(function(i,n){for(var r=i.length,o=0;o/g,""),{declaration:function(){if(i(/^<\?xml\s*/)){for(var t={attributes:{}};!n()&&!r("?>");){var o=e();if(!o)return t;t.attributes[o.name]=o.value}return i(/\?>\s*/),t}}(),root:function t(){var o=i(/^<([\w-:.]+)\s*/);if(o){for(var a={name:o[1],attributes:{},children:[]};!(n()||r(">")||r("?>")||r("/>"));){var s=e();if(!s)return a;a.attributes[s.name]=s.value}if(i(/^\s*\/>\s*/))return a;i(/\??>\s*/),a.content=function(){var t=i(/^([^<]*)/);return t?t[1]:""}();for(var c;c=t();)a.children.push(c);return i(/^<\/[\w-:.]+>\s*/),a}}()}},__domParser:function(t){return(new window.DOMParser).parseFromString(t,"text/xml")},_parse:function(){t.Debug&&Nf.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.isBinary()||this.string?this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.streamer.data:this.xml.data=this.__xmlParser(this.streamer.asText()),t.Debug&&Nf.timeEnd("XmlParser._parse "+this.name)}}),$f.add("xml",hc);var Ap,Mp,Pp=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}(),Cp=30,Tp=12,Ep=15,Ip=852,Lp=592,Op=0,Rp=1,Dp=2,Np=[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],kp=[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],Fp=[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],zp=[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],Bp=0,Up=1,$p=2,Vp=4,jp=5,Gp=6,Hp=0,Wp=1,Xp=2,qp=-2,Yp=-3,Zp=-4,Kp=-5,Qp=8,Jp=1,tm=2,em=3,im=4,nm=5,rm=6,om=7,am=8,sm=9,cm=10,hm=11,um=12,lm=13,dm=14,fm=15,pm=16,mm=17,gm=18,vm=19,ym=20,bm=21,xm=22,_m=23,wm=24,Sm=25,Am=26,Mm=27,Pm=28,Cm=29,Tm=30,Em=31,Im=32,Lm=852,Om=592,Rm=!0,Dm=!0,Nm=!0;try{String.fromCharCode.apply(null,[0])}catch(t){Dm=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Nm=!1}for(var km=new Uint8Array(256),Fm=0;Fm<256;Fm++)km[Fm]=Fm>=252?6:Fm>=248?5:Fm>=240?4:Fm>=224?3:Fm>=192?2:1;km[254]=km[254]=1;var zm=0,Bm={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"},Um=Object.prototype.toString;Pc.prototype.push=function(t,e){var i,n,r,o,a,s,c=this.strm,h=this.options.chunkSize,u=this.options.dictionary,l=!1;if(this.ended)return!1;n=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),i=0,n=e.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(n=4),4===n?(i=function(t){if(!t||!t.state)return qp;var e=t.state;return e.window&&(e.window=null),t.state=null,Hp}(this.strm),this.onEnd(i),this.ended=!0,i===zm):2!==n||(this.onEnd(zm),c.avail_out=0,!0)},Pc.prototype.onData=function(t){this.chunks.push(t)},Pc.prototype.onEnd=function(t){t===zm&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,n,r,o,a;for(n=0,e=0,i=t.length;ee?(a&&(clearTimeout(a),a=null),s=h,o=t.apply(n,r),a||(n=r=null)):a||!1===i.trailing||(a=setTimeout(c,u)),o}},t.download=d,t.getQuery=c,t.getDataInfo=En,t.getFileInfo=f,t.uniqueArray=p,t.BufferRepresentation=qo,t.SphereBuffer=ko,t.EllipsoidBuffer=zo,t.CylinderBuffer=Vo,t.ConeBuffer=Go,t.ArrowBuffer=Ho,t.Shape=Wo,t.Kdtree=Gr,t.SpatialHash=Or,t.Signal=qi,t.Matrix3=gt,t.Matrix4=w,t.Vector2=x,t.Vector3=A,t.Box3=pt,t.Quaternion=S,t.Plane=vt,t.Color=dt,Object.defineProperty(t,"__esModule",{value:!0})}); -},{}],1:[function(require,module,exports) { -"use strict";var e=require("./viewer"),t=a(e);function a(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t.default=e,t}_.extend(window.bundleEntries||{},{load:function(e){var a,r,o=e.dataset,n=e.chart.settings,s=new t.Stage(e.targets[0],{backgroundColor:n.get("backcolor")});a={radius:n.get("radius"),scale:n.get("scale"),assembly:n.get("assembly"),color:n.get("colorscheme"),opacity:n.get("opacity")},r={ext:o.extension,defaultRepresentation:!0};try{s.loadFile(o.download_url,r).then(function(t){t.addRepresentation(n.get("mode"),a),e.chart.state("ok","Chart drawn."),e.process.resolve()})}catch(t){e.chart.state("failed","Could not load PDB file."),e.process.resolve()}s.setQuality(n.get("quality")),!0!==n.get("spin")&&"true"!==n.get("spin")||s.setSpin([0,1,0],.01),$(window).resize(function(){s.viewer.handleResize()})}}); -},{"./viewer":2}]},{},[1]) \ No newline at end of file diff --git a/config/plugins/visualizations/pv/config/pv.xml b/config/plugins/visualizations/pv/config/pv.xml index dfebafb9ce1..fabdcb18e02 100644 --- a/config/plugins/visualizations/pv/config/pv.xml +++ b/config/plugins/visualizations/pv/config/pv.xml @@ -12,7 +12,7 @@ dataset_id - + diff --git a/config/plugins/visualizations/pv/package.json b/config/plugins/visualizations/pv/package.json index 57f402c98da..1b180a11eae 100644 --- a/config/plugins/visualizations/pv/package.json +++ b/config/plugins/visualizations/pv/package.json @@ -8,14 +8,10 @@ ], "license": "AFL-3.0", "dependencies": { - "babel-preset-env": "^1.6.1", - "backbone": "^1.3.3", - "bootstrap": "^3.3.7", - "jquery": "^3.1.1", - "parcel-bundler": "^1.4.1", - "bio-pv": "^1.8.1" + "bio-pv": "^1.8.1", + "parcel-bundler": "^1.12.4" }, "scripts": { - "build": "parcel build src/pv.js -d static" + "build": "parcel build src/pv.js -d static/dist" } } diff --git a/config/plugins/visualizations/pv/src/pv.js b/config/plugins/visualizations/pv/src/pv.js index 5aa7a62a72f..ed16b77c4ce 100644 --- a/config/plugins/visualizations/pv/src/pv.js +++ b/config/plugins/visualizations/pv/src/pv.js @@ -1,35 +1,37 @@ import * as pv from "bio-pv"; -_.extend(window.bundleEntries || {}, { - load: function(options) { - var settings = options.chart.settings; - var viewer = pv.Viewer(document.getElementById(options.targets[0]), { - quality: settings.get('quality'), - width: 'auto', - height: 'auto', - antialias: true, - outline: true - }); - $.ajax( { - url: options.dataset.download_url, - cache: true, - success: function(response) { - var structure = pv.io.pdb(response); - var viewer_options = {}; - _.each(settings.attributes, function(value, key) { - viewer_options[key.replace('viewer|', '')] = value; - }); - viewer.clear(); - viewer.renderAs('protein', structure, viewer_options.mode, viewer_options); - viewer.centerOn(structure); - viewer.autoZoom(); - options.chart.state('ok', 'Chart drawn.'); - options.process.resolve(); - }, - error: function() { - options.chart.state('ok', 'Failed to load pdb file.'); - options.process.resolve(); + +window.bundleEntries = window.bundleEntries || {}; +window.bundleEntries.load = function (options) { + var settings = options.chart.settings; + var viewer = pv.Viewer(document.getElementById(options.targets[0]), { + quality: settings.get("quality"), + width: "auto", + height: "auto", + antialias: true, + outline: true, + }); + var xhr = new XMLHttpRequest(); + xhr.open("GET", options.dataset.download_url); + xhr.onload = function () { + if (xhr.status === 200) { + var structure = pv.io.pdb(xhr.response); + var viewer_options = {}; + for (const [key, value] of Object.entries(settings.attributes)) { + viewer_options[key.replace("viewer|", "")] = value; } - }); - $(window).resize(function() { viewer.fitParent() }); - } -}); + viewer.clear(); + viewer.renderAs("protein", structure, viewer_options.mode, viewer_options); + viewer.centerOn(structure); + viewer.autoZoom(); + options.chart.state("ok", "Chart drawn."); + options.process.resolve(); + } else { + options.chart.state("ok", "Failed to load pdb file."); + options.process.resolve(); + } + }; + xhr.send(); + window.onresize = function () { + viewer.fitParent(); + }; +}; diff --git a/config/plugins/visualizations/pv/static/pv.js b/config/plugins/visualizations/pv/static/pv.js deleted file mode 100644 index f65940bb99f..00000000000 --- a/config/plugins/visualizations/pv/static/pv.js +++ /dev/null @@ -1,5 +0,0 @@ -require=function(r,e,n){function t(n,o){function i(r){return t(i.resolve(r))}function f(e){return r[n][1][e]||e}if(!e[n]){if(!r[n]){var c="function"==typeof require&&require;if(!o&&c)return c(n,!0);if(u)return u(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}i.resolve=f;var a=e[n]=new t.Module;r[n][0].call(a.exports,i,a,a.exports)}return e[n].exports}function o(){this.bundle=t,this.exports={}}var u="function"==typeof require&&require;t.Module=o,t.modules=r,t.cache=e,t.parent=u;for(var i=0;i0&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},s.cross=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],h=r[2];return t[0]=i*h-a*o,t[1]=a*s-n*h,t[2]=n*o-i*s,t},s.lerp=function(t,e,r,n){var i=e[0],a=e[1],s=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=s+n*(r[2]-s),t},s.random=function(t,e){e=e||1;var r=2*n()*Math.PI,i=2*n()-1,a=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*a,t[1]=Math.sin(r)*a,t[2]=i*e,t},s.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12],t[1]=r[1]*n+r[5]*i+r[9]*a+r[13],t[2]=r[2]*n+r[6]*i+r[10]*a+r[14],t},s.transformMat3=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t},s.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],h=r[2],u=r[3],l=u*n+o*a-h*i,c=u*i+h*n-s*a,d=u*a+s*i-o*n,f=-s*n-o*i-h*a;return t[0]=l*u+f*-s+c*-h-d*-o,t[1]=c*u+f*-o+d*-s-l*-h,t[2]=d*u+f*-h+l*-o-c*-s,t},s.forEach=(a=s.create(),function(t,e,r,n,i,s){var o,h;for(e||(e=3),r||(r=0),h=n?Math.min(n*e+r,t.length):t.length,o=r;o0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s),t},o.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},o.lerp=function(t,e,r,n){var i=e[0],a=e[1],s=e[2],o=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=s+n*(r[2]-s),t[3]=o+n*(r[3]-o),t},o.random=function(t,e){return e=e||1,t[0]=n(),t[1]=n(),t[2]=n(),t[3]=n(),o.normalize(t,t),o.scale(t,t,e),t},o.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*s,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*s,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*s,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*s,t},o.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],h=r[2],u=r[3],l=u*n+o*a-h*i,c=u*i+h*n-s*a,d=u*a+s*i-o*n,f=-s*n-o*i-h*a;return t[0]=l*u+f*-s+c*-h-d*-o,t[1]=c*u+f*-o+d*-s-l*-h,t[2]=d*u+f*-h+l*-o-c*-s,t},o.forEach=function(){var t=o.create();return function(e,r,n,i,a,s){var o,h;for(r||(r=4),n||(n=0),h=i?Math.min(i*r+n,e.length):e.length,o=n;o.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(s.cross(l,e,r),t[0]=l[0],t[1]=l[1],t[2]=l[2],t[3]=1+n,m.normalize(t,t))}),m.setAxes=(f=h.create(),function(t,e,r,n){return f[0]=r[0],f[3]=r[1],f[6]=r[2],f[1]=n[0],f[4]=n[1],f[7]=n[2],f[2]=e[0],f[5]=e[1],f[8]=e[2],m.normalize(t,m.fromMat3(t,f))}),m.clone=o.clone,m.fromValues=o.fromValues,m.copy=o.copy,m.set=o.set,m.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},m.setAxisAngle=function(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t},m.add=o.add,m.multiply=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[0],h=r[1],u=r[2],l=r[3];return t[0]=n*l+s*o+i*u-a*h,t[1]=i*l+s*h+a*o-n*u,t[2]=a*l+s*u+n*h-i*o,t[3]=s*l-n*o-i*h-a*u,t},m.mul=m.multiply,m.scale=o.scale,m.rotateX=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),h=Math.cos(r);return t[0]=n*h+s*o,t[1]=i*h+a*o,t[2]=a*h-i*o,t[3]=s*h-n*o,t},m.rotateY=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),h=Math.cos(r);return t[0]=n*h-a*o,t[1]=i*h+s*o,t[2]=a*h+n*o,t[3]=s*h-i*o,t},m.rotateZ=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),h=Math.cos(r);return t[0]=n*h+i*o,t[1]=i*h-n*o,t[2]=a*h+s*o,t[3]=s*h-a*o,t},m.calculateW=function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=-Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},m.dot=o.dot,m.lerp=o.lerp,m.slerp=function(t,e,r,n){var i,a,s,o,h,u=e[0],l=e[1],c=e[2],d=e[3],f=r[0],_=r[1],m=r[2],v=r[3];return(a=u*f+l*_+c*m+d*v)<0&&(a=-a,f=-f,_=-_,m=-m,v=-v),1-a>1e-6?(i=Math.acos(a),s=Math.sin(i),o=Math.sin((1-n)*i)/s,h=Math.sin(n*i)/s):(o=1-n,h=n),t[0]=o*u+h*f,t[1]=o*l+h*_,t[2]=o*c+h*m,t[3]=o*d+h*v,t},m.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r*r+n*n+i*i+a*a,o=s?1/s:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-i*o,t[3]=a*o,t},m.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},m.length=o.length,m.len=m.length,m.squaredLength=o.squaredLength,m.sqrLen=m.squaredLength,m.normalize=o.normalize,m.fromMat3=(_="undefined"!=typeof Int8Array?new Int8Array([1,2,0]):[1,2,0],function(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[7]-e[5])*r,t[1]=(e[2]-e[6])*r,t[2]=(e[3]-e[1])*r;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=_[i],s=_[a];r=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*s+s]+1),t[i]=.5*r,r=.5/r,t[3]=(e[3*s+a]-e[3*a+s])*r,t[a]=(e[3*a+i]+e[3*i+a])*r,t[s]=(e[3*s+i]+e[3*i+s])*r}return t}),m.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},t.quat=m,t}(),e=function(){var e=t.vec4,r={rgb:{}},n=r.rgb;r.rgb.create=e.create,r.rgb.scale=e.scale,r.rgb.copy=e.copy,r.rgb.fromValues=e.fromValues,r.rgb.mix=function(t,e,r,n){var i=1-n;return t[0]=e[0]*n+r[0]*i,t[1]=e[1]*n+r[1]*i,t[2]=e[2]*n+r[2]*i,t[3]=e[3]*n+r[3]*i,t};var i={white:n.fromValues(1,1,1,1),black:n.fromValues(0,0,0,1),grey:n.fromValues(.5,.5,.5,1),lightgrey:n.fromValues(.8,.8,.8,1),darkgrey:n.fromValues(.3,.3,.3,1),red:n.fromValues(1,0,0,1),darkred:n.fromValues(.5,0,0,1),lightred:n.fromValues(1,.5,.5,1),green:n.fromValues(0,1,0,1),darkgreen:n.fromValues(0,.5,0,1),lightgreen:n.fromValues(.5,1,.5,1),blue:n.fromValues(0,0,1,1),darkblue:n.fromValues(0,0,.5,1),lightblue:n.fromValues(.5,.5,1,1),yellow:n.fromValues(1,1,0,1),darkyellow:n.fromValues(.5,.5,0,1),lightyellow:n.fromValues(1,1,.5,1),cyan:n.fromValues(0,1,1,1),darkcyan:n.fromValues(0,.5,.5,1),lightcyan:n.fromValues(.5,1,1,1),magenta:n.fromValues(1,0,1,1),darkmagenta:n.fromValues(.5,0,.5,1),lightmagenta:n.fromValues(1,.5,1,1),orange:n.fromValues(1,.5,0,1),darkorange:n.fromValues(.5,.25,0,1),lightorange:n.fromValues(1,.75,.5,1)};function a(t,e){this._colors=t;for(var n=0;n0&&"#"===t[0])return r.hex2rgb(t)}return 3===t.length?[t[0],t[1],t[2],1]:t},a.prototype={colorAt:function(t,r){if(r<=this._stops[0])return e.copy(t,this._colors[0]);if(r>=this._stops[this._stops.length-1])return e.copy(t,this._colors[this._stops.length-1]);for(var i=0,a=1;ar);++a)i=a;var s=i+1,o=this._stops[i],h=(r-o)/(this._stops[s]-o);return n.mix(t,this._colors[s],this._colors[i],h)}};var s={};r.gradient=function(t,e){if("string"==typeof t)return s[t];if("equal"===(e=e||"equal")){e=[];for(var r=0;r0?s.max:1));var u=[0,0,0,0];t.colorAt(u,h),n[i]=u[0],n[i+1]=u[1],n[i+2]=u[2],n[i+3]=u[3]},function(t){var e=t.chains();this.chainLimits={};for(var r=0;r1?1/(e.length-1):1},function(){this.chainIndices=null})};var l,c=(l=e.create(),function(t,e,r,n){r.colorAt(l,n),t[e+0]=l[0],t[e+1]=l[1],t[e+2]=l[2],t[e+3]=l[3]});function d(t,e,r,n,i){return e||(e=o("rainbow")),new h(function(r,n,a){var s=0;this._min!==this._max&&(s=(i(r).prop(t)-this._min)/(this._max-this._min)),c(n,a,e,s)},function(e){if(void 0!==r)return this._min=r[0],void(this._max=r[1]);r=function(t,e,r){var n=null,i=null;return t[e](function(t){var e=t.prop(r);null!==n||null!==i?(n=Math.min(n,e),i=Math.max(i,e)):n=i=e}),{min:n,max:i}}(e,n,t),this._min=r.min,this._max=r.max},function(){})}return r.byAtomProp=function(t,e,r){return d(t,e,r,"eachAtom",function(t){return t})},r.byResidueProp=function(t,e,r){return d(t,e,r,"eachResidue",function(t){return t.residue()})},r.interpolateColor=function(t,r){for(var n=new Float32Array(4*(r*(t.length/4-1)+1)),i=0,a=e.create(),s=e.create(),o=1/r,h=0;h=e&&(null===n||athis.MAX_ID)return null;this._unusedRangeStart=h;var u=new t(this,o,h);return this._usedCount++,u},clear:function(){this._objects={},this._unusedRangeStart=1,this._free=[],this._usedCount=0},recycle:function(t){for(var e=t._start;e0&&0===this._usedCount&&this.clear()},objectForId:function(t){return this._objects[t]}},e}(),n=function(){var t={};function e(t,e){return t>1;;){var o=t[s];if(n(r,o))a=s;else{if(!n(o,r))return s;i=s}var h=i+a>>1;if(h===s)return-1;s=h}return-1},t.indexFirstLargerEqualThan=function(t,r,n){if(n=n||e,0===t.length||n(t[t.length-1],r))return-1;for(var i=0,a=t.length,s=i+a>>1;;){var o=t[s];n(r,o)?a=s:n(o,r)?i=s+1:a=s;var h=i+a>>1;if(h===s)return s;s=h}},t.indexLastSmallerThan=function(t,r,n){if(n=n||e,0===t.length||n(t[t.length-1],r))return t.length-1;if(n(r,t[0])||!n(t[0],r))return-1;for(var i=0,a=t.length,s=i+a>>1;;){var o=t[s];n(r,o)||!n(o,r)?a=s:i=s;var h=i+a>>1;if(h===s)return s;s=h}},t.indexLastSmallerEqualThan=function(t,r,n){if(n=n||e,0===t.length||n(t[t.length-1],r))return t.length-1;if(n(r,t[0]))return-1;for(var i=0,a=t.length,s=i+a>>1;;){n(r,t[s])?a=s:i=s;var o=i+a>>1;if(o===s)return s;s=o}},r.prototype={min:function(){return this._min},max:function(){return this._max},length:function(){return this._max-this._min},empty:function(){return this._empty},center:function(){return.5*(this._max+this._min)},extend:function(t){this._min-=t,this._max+=t},update:function(t){this._empty?(this._min=this._max=t,this._empty=!1):tthis._max&&(this._max=t)}},t.Range=r,t}(),i=function(){function t(t){if("complete"!==document.readyState&&"loaded"!==document.readyState&&"interactive"!==document.readyState)return!1;if(void 0===t)try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("experimental-webgl"))}catch(t){return!1}return!!t}function e(t,e){this._width=e.width,this._antialias=e.antialias,this._height=e.height,this._resize=!1,this._lastTimestamp=null,this._domElement=t,this._initCanvas(),this._backgroundColor=e.backgroundColor,this._forceManualAntialiasing=e.forceManualAntialiasing}return e.prototype={_ensureSize:function(){if(this._resize){this._resize=!1;var t=this._width*this._samples,e=this._height*this._samples;this._realWidth=t,this._realHeight=e,this._gl.viewport(0,0,t,e),this._canvas.width=t,this._canvas.height=e,this._samples>1&&this._initManualAntialiasing(this._samples)}},resize:function(t,e){t===this._width&&e===this._height||(this._resize=!0,this._width=t,this._height=e)},fitParent:function(){var t=this._domElement.getBoundingClientRect();this.resize(t.width,t.height)},gl:function(){return this._gl},imageData:function(){return this._canvas.toDataURL()},_initContext:function(){try{var t={antialias:this._antialias&&!this._forceManualAntialiasing,preserveDrawingBuffer:!0};this._gl=this._canvas.getContext("experimental-webgl",t)}catch(t){return!1}return!!this._gl},_initManualAntialiasing:function(t){var e=1/t,r="translate("+.5*-(1-e)*this._realWidth+"px, "+.5*-(1-e)*this._realHeight+"px)"+" "+("scale("+e+", "+e+")");this._canvas.style.webkitTransform=r,this._canvas.style.transform=r,this._canvas.style.ieTransform=r,this._canvas.width=this._realWidth,this._canvas.height=this._realHeight},initGL:function(){var t=1;if(!this._initContext())return!1;var e=this._gl;return e.getContextAttributes().antialias&&!this._forceManualAntialiasing||!this._antialias||(t=2),this._realWidth=this._width*t,this._realHeight=this._height*t,this._samples=t,t>1&&this._initManualAntialiasing(t),e.viewportWidth=this._realWidth,e.viewportHeight=this._realHeight,e.clearColor(this._backgroundColor[0],this._backgroundColor[1],this._backgroundColor[2],1),e.lineWidth(2),e.cullFace(e.FRONT),e.enable(e.CULL_FACE),e.enable(e.DEPTH_TEST),!0},_shaderFromString:function(t,e,r){var n,i=this._gl;if("fragment"===e)n=i.createShader(i.FRAGMENT_SHADER);else{if("vertex"!==e)return null;n=i.createShader(i.VERTEX_SHADER)}var a=t.replace("${PRECISION}",r);return i.shaderSource(n,a),i.compileShader(n),i.getShaderParameter(n,i.COMPILE_STATUS)?n:null},initShader:function(t,e,r){var i=this._gl,a=this._shaderFromString(e,"fragment",r),s=this._shaderFromString(t,"vertex",r),o=i.createProgram();if(i.attachShader(o,s),i.attachShader(o,a),i.linkProgram(o),!i.getProgramParameter(o,i.LINK_STATUS))return null;var h=n.bind(i,i.getAttribLocation),u=n.bind(i,i.getUniformLocation);return o.posAttrib=h(o,"attrPos"),o.colorAttrib=h(o,"attrColor"),o.normalAttrib=h(o,"attrNormal"),o.objIdAttrib=h(o,"attrObjId"),o.selectAttrib=h(o,"attrSelect"),o.symId=u(o,"symId"),o.projection=u(o,"projectionMat"),o.modelview=u(o,"modelviewMat"),o.rotation=u(o,"rotationMat"),o.fog=u(o,"fog"),o.fogFar=u(o,"fogFar"),o.fogNear=u(o,"fogNear"),o.fogColor=u(o,"fogColor"),o.outlineColor=u(o,"outlineColor"),o.outlineWidth=u(o,"outlineWidth"),o.relativePixelSize=u(o,"relativePixelSize"),o.screenDoorTransparency=u(o,"screenDoorTransparency"),o.selectionColor=u(o,"selectionColor"),o.pointSize=u(o,"pointSize"),o.zoom=u(o,"zoom"),o},on:function(t,e){this._canvas.addEventListener(t,e,!1)},removeEventListener:function(t,e){this._canvas.removeEventListener(t,e,!1)},onWheel:function(t,e){"onwheel"in this._canvas?this.on("wheel",t):this.on("mousewheel",e)},domElement:function(){return this._canvas},bind:function(){this._ensureSize(),this._gl.viewport(0,0,this._realWidth,this._realHeight)},superSamplingFactor:function(){return this._samples},viewportWidth:function(){return this._realWidth},viewportHeight:function(){return this._realHeight},width:function(){return this._width},height:function(){return this._height},_initCanvas:function(){this._canvas=document.createElement("canvas"),this._canvas.width=this._width,this._canvas.height=this._height,this._domElement.appendChild(this._canvas)},isWebGLSupported:function(){return t(this._gl)},destroy:function(){this._canvas.width=1,this._canvas.height=1,this._canvas.parentElement.removeChild(this._canvas),this._canvas=null}},{Canvas:e,isWebGLSupported:t}}(),a=function(){function t(t,e){this._width=e.width,this._height=e.height,this._colorBufferWidth=this._width,this._colorBufferHeight=this._height,this._gl=t,this._colorHandle=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,this._colorHandle),this._depthHandle=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this._depthHandle),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,this._width,this._height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this._depthHandle),this._colorTexture=t.createTexture(),this._initColorBuffer()}return t.prototype={width:function(){return this._width},height:function(){return this._height},bind:function(){var t=this._gl;t.bindFramebuffer(t.FRAMEBUFFER,this._colorHandle),t.bindRenderbuffer(t.RENDERBUFFER,this._depthHandle),this._colorBufferWidth===this._width&&this._colorBufferHeight===this._height||this._resizeBuffers(),t.viewport(0,0,this._width,this._height)},colorTexture:function(){return this._colorTexture},_initColorBuffer:function(){this.bind();var t=this._gl;t.bindTexture(t.TEXTURE_2D,this._colorTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this._width,this._height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this._colorTexture,0),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null),this.release()},_resizeBuffers:function(){var t=this._gl;t.bindRenderbuffer(t.RENDERBUFFER,this._depthHandle),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,this._width,this._height),t.bindTexture(t.TEXTURE_2D,this._colorTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this._width,this._height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this._colorTexture,0),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this._depthHandle),t.bindTexture(t.TEXTURE_2D,null),this._colorBufferWidth=this._width,this._colorBufferHeight=this._height},resize:function(t,e){this._width=t,this._height=e},release:function(){var t=this._gl;t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindRenderbuffer(t.RENDERBUFFER,null)}},t}(),s=function(){function t(t){this._freeArrays=[],this._bufferType=t}return t.prototype.request=function(t){for(var e=-1,r=null,n=0;n=t&&(null===r||i68719476735&&(this._stateId=0)},setScreenDoorTransparency:function(t){this._screenDoorTransparency=t,this._incrementStateId()},setOutlineWidth:function(t){this._outlineWidth!==t&&(this._outlineWidth=t,this._incrementStateId())},setRotation:function(t){16===t.length?a.copy(this._rotation,t):a.fromMat3(this._rotation,t),this._updateModelViewMat=!0},upsamplingFactor:function(){return this._upsamplingFactor},setUpsamplingFactor:function(t){if(this._upsamplingFactor!==t){this._incrementStateId(),this._upsamplingFactor=t;var e=this._upsamplingFactor/this._width,r=this._upsamplingFactor/this._height;this._relativePixelSize=new Float32Array([e,r])}},mainAxes:function(){return[i.fromValues(this._rotation[0],this._rotation[4],this._rotation[8]),i.fromValues(this._rotation[1],this._rotation[5],this._rotation[9]),i.fromValues(this._rotation[2],this._rotation[6],this._rotation[10])]},fieldOfViewY:function(){return this._fovY},setFieldOfViewY:function(t){this._fovY=t,this._updateProjectionMat=!0},aspectRatio:function(){return this._width/this._height},rotation:function(){return this._rotation},_updateIfRequired:function(){var t=!1;return this._updateModelViewMat&&(a.identity(this._camModelView),a.translate(this._camModelView,this._camModelView,[-this._center[0],-this._center[1],-this._center[2]]),a.mul(this._camModelView,this._rotation,this._camModelView),a.identity(this._translation),a.translate(this._translation,this._translation,[0,0,-this._zoom]),a.mul(this._camModelView,this._translation,this._camModelView),t=!0),this._updateProjectionMat&&(a.identity(this._projection),a.perspective(this._projection,this._fovY,this._width/this._height,this._near,this._far),t=!0),this._updateProjectionMat=!1,this._updateModelViewMat=!1,t&&this._incrementStateId(),t},setViewportSize:function(t,e){this._updateProjectionMat=!0,this._width=t,this._height=e,this._relativePixelSize=new Float32Array([this._upsamplingFactor/t,this._upsamplingFactor/e])},viewportWidth:function(){return this._width},viewportHeight:function(){return this._height},setCenter:function(t){this._updateModelViewMat=!0,i.copy(this._center,t)},fog:function(t){return void 0!==t&&t!==this._fog&&(this._fog=t,this._incrementStateId()),this._fog},rotateZ:(n=a.create(),function(t){a.identity(n),this._updateModelViewMat=!0,a.rotate(n,n,t,[0,0,1]),a.mul(this._rotation,n,this._rotation)}),rotateX:function(){var t=a.create();return function(e){a.identity(t),this._updateModelViewMat=!0,a.rotate(t,t,e,[1,0,0]),a.mul(this._rotation,t,this._rotation)}}(),rotateY:function(){var t=a.create();return function(e){a.identity(t),this._updateModelViewMat=!0,a.rotate(t,t,e,[0,1,0]),a.mul(this._rotation,t,this._rotation)}}(),panX:function(t){return this.panXY(t,0)},panY:function(t){return this.panXY(0,t)},panXY:(e=a.create(),r=i.create(),function(t,n){a.transpose(e,this._rotation),this._updateModelViewMat=!0,i.set(r,-t,n,0),i.transformMat4(r,r,e),i.add(r,r,this._center),this.setCenter(r)}),nearOffset:function(){return this._near},farOffset:function(){return this._far},setNearFar:function(t,e){t===this._near&&e===this._far||(this._near=t,this._far=e,this._updateProjectionMat=!0)},setFogNearFar:function(t,e){this._fogNear=t,this._fogFar=e,this._updateProjectionMat=!0},setZoom:function(t){return this._updateModelViewMat=!0,this._zoom=t,this._zoom},zoom:function(t){if(void 0===t)return this._zoom;this._updateModelViewMat=!0;var e=1+.1*t;return this._zoom=Math.min(1e3,Math.max(2,e*this._zoom)),this._zoom},center:function(){return this._center},setFogColor:function(t){this._fogColor=i.clone(t)},currentShader:function(){return this._currentShader},invalidateCurrentShader:function(){this._currentShader=null},setOutlineColor:function(t){this._outlineColor=i.clone(t)},setSelectionColor:function(t){this._selectionColor=i.clone(t)},bind:function(t,e){var r=!1,n=this._gl;if(this._currentShader!==t&&(this._currentShader=t,n.useProgram(t),r=!0),r=this._updateIfRequired()||r,e?(a.mul(this._modelView,this._camModelView,e),n.uniformMatrix4fv(t.modelview,!1,this._modelView)):n.uniformMatrix4fv(t.modelview,!1,this._camModelView),this._stateId!==t.stateId){t.stateId=this._stateId,n.uniformMatrix4fv(t.projection,!1,this._projection),t.rotation&&n.uniformMatrix4fv(t.rotation,!1,this._rotation),n.uniform1i(t.fog,this._fog);var i=this._zoom;n.uniform1f(t.fogFar,this._fogFar+i),n.uniform1f(t.zoom,this._zoom),n.uniform1f(t.fogNear,this._fogNear+i),n.uniform3fv(t.fogColor,this._fogColor),n.uniform3fv(t.outlineColor,this._outlineColor),n.uniform3fv(t.selectionColor,this._selectionColor),n.uniform2fv(t.relativePixelSize,this._relativePixelSize),n.uniform1f(t.outlineWidth,this._outlineWidth),n.uniform1i(t.screenDoorTransparency,this._screenDoorTransparency)}}},s}(),h={PRELUDE_FS:"\nprecision ${PRECISION} float;\nuniform bool screenDoorTransparency;\nvec4 handleAlpha(vec4 inColor) {\n if (screenDoorTransparency) {\n ivec2 pxCoord = ivec2(gl_FragCoord.xy);\n ivec2 mod = pxCoord - (pxCoord/2) * 2;\n if (inColor.a < 0.99 &&\n (inColor.a < 0.01 || mod.x != 0 || mod.y != 0)) { discard; }\n return vec4(inColor.rgb, 1.0);\n } else {\n if (inColor.a == 0.0) { discard; }\n return inColor;\n } \n} \nuniform vec3 selectionColor;\n\nvec3 handleSelect(vec3 inColor, float vertSelect) { \n return mix(inColor, selectionColor, step(0.5, vertSelect) * 0.7); \n} \n\nuniform bool fog;\nuniform float fogNear;\nuniform float fogFar;\nuniform vec3 fogColor;\nvec3 handleFog(vec3 inColor) {\n if (fog) {\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n float fogFactor = smoothstep(fogNear, fogFar, depth);\n return mix(inColor, fogColor, fogFactor);\n } else {\n return inColor;\n }\n}",LINES_FS:"\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\n\nvoid main(void) {\n gl_FragColor = handleAlpha(vertColor);\n gl_FragColor.rgb = handleFog(gl_FragColor.rgb);\n}",SELECT_LINES_FS:"\nprecision ${PRECISION} float;\n\nvarying float vertSelect;\nvarying vec3 vertNormal;\nuniform float fogNear;\nuniform float fogFar;\nuniform vec3 fogColor;\nuniform bool fog;\nuniform vec3 selectionColor;\n\nvoid main(void) {\n gl_FragColor = mix(vec4(0.0, 0.0, 0.0, 0.0), vec4(selectionColor, 1.0), \n vertSelect);\n gl_FragColor.a = step(0.5, vertSelect);\n if (gl_FragColor.a == 0.0) { discard; }\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n if (fog) {\n float fog_factor = smoothstep(fogNear, fogFar, depth);\n gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w),\n fog_factor);\n }\n}",SELECT_LINES_VS:"\nattribute vec3 attrPos;\nattribute float attrSelect;\n\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nuniform float pointSize;\nvarying float vertSelect;\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n gl_Position.z += gl_Position.w * 0.000001; \n float distToCamera = vec4(modelviewMat * vec4(attrPos, 1.0)).z;\n gl_PointSize = pointSize * 200.0 / abs(distToCamera); \n vertSelect = attrSelect;\n}",SELECT_VS:"\nprecision ${PRECISION} float;\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nuniform float pointSize;\nattribute vec3 attrPos;\nattribute float attrObjId;\n\nvarying float objId;\n\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n float distToCamera = vec4(modelviewMat * vec4(attrPos, 1.0)).z;\n gl_PointSize = pointSize * 200.0 / abs(distToCamera); \n objId = attrObjId;\n}",SELECT_FS:"\nprecision ${PRECISION} float;\n\nvarying float objId;\nuniform int symId;\n\nint intMod(int x, int y) { \n int z = x/y;\n return x-y*z;\n}\nvoid main(void) {\n // ints are only required to be 7bit...\n int integralObjId = int(objId+0.5);\n int red = intMod(integralObjId, 256);\n integralObjId/=256;\n int green = intMod(integralObjId, 256);\n integralObjId/=256;\n int blue = intMod(integralObjId, 256);\n int alpha = symId;\n gl_FragColor = vec4(float(red), float(green), \n float(blue), float(alpha))/255.0;\n}",LINES_VS:"\nattribute vec3 attrPos;\nattribute vec4 attrColor;\n\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nvarying vec4 vertColor;\nuniform float pointSize;\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n float distToCamera = vec4(modelviewMat * vec4(attrPos, 1.0)).z;\n gl_PointSize = pointSize * 200.0 / abs(distToCamera); \n vertColor = attrColor;\n}",HEMILIGHT_FS:"\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\nvarying float vertSelect;\n\nvoid main(void) {\n float dp = dot(vertNormal, vec3(0.0, 0.0, 1.0));\n float hemi = min(1.0, max(0.0, dp)*0.6+0.5);\n gl_FragColor = vec4(vertColor.rgb*hemi, vertColor.a);\n gl_FragColor.rgb = handleFog(handleSelect(gl_FragColor.rgb, vertSelect));\n gl_FragColor = handleAlpha(gl_FragColor);\n}",PHONG_FS:"\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\nvarying vec3 vertPos;\nuniform float zoom;\nvarying float vertSelect;\n\nvoid main(void) {\n vec3 eyePos = vec3(0.0, 0.0, zoom);\n float dp = dot(vertNormal, normalize(eyePos - vertPos));\n float hemi = min(1.0, max(0.3, dp)+0.2);\n //hemi *= vertColor.a;\n vec3 rgbColor = vertColor.rgb * hemi; \n rgbColor += min(vertColor.rgb, 0.8) * pow(max(0.0, dp), 18.0);\n rgbColor = handleSelect(rgbColor, vertSelect);\n gl_FragColor = vec4(clamp(rgbColor, 0.0, 1.0), vertColor.a);\n gl_FragColor.rgb = handleFog(gl_FragColor.rgb);\n gl_FragColor = handleAlpha(gl_FragColor);\n}",HEMILIGHT_VS:"\nattribute vec3 attrPos;\nattribute vec4 attrColor;\nattribute vec3 attrNormal;\nattribute float attrSelect;\n\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nvarying vec4 vertColor;\nvarying vec3 vertNormal;\nvarying vec3 vertPos;\nvarying float vertSelect;\nvoid main(void) {\n vertPos = (modelviewMat * vec4(attrPos, 1.0)).xyz;\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n vec4 n = (modelviewMat * vec4(attrNormal, 0.0));\n vertNormal = n.xyz;\n vertColor = attrColor;\n vertSelect = attrSelect;\n}",OUTLINE_FS:"\nvarying float vertAlpha;\nvarying float vertSelect;\n\nuniform vec3 outlineColor;\n\nvoid main() {\n gl_FragColor = vec4(mix(outlineColor, selectionColor, \n step(0.5, vertSelect)), \n vertAlpha);\n gl_FragColor.rgb = handleFog(gl_FragColor.rgb);\n gl_FragColor = handleAlpha(gl_FragColor);\n}",OUTLINE_VS:"\nprecision ${PRECISION} float;\n\nattribute vec3 attrPos;\nattribute vec3 attrNormal;\nattribute vec4 attrColor;\nattribute float attrSelect;\n\nuniform vec3 outlineColor;\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nvarying float vertAlpha;\nvarying float vertSelect;\nuniform vec2 relativePixelSize;\nuniform float outlineWidth;\n\nvoid main(void) {\n gl_Position = projectionMat * modelviewMat * vec4(attrPos, 1.0);\n vec4 normal = modelviewMat * vec4(attrNormal, 0.0);\n vertAlpha = attrColor.a;\n vertSelect = attrSelect;\n vec2 expansion = relativePixelSize * \n (outlineWidth + 2.0 * step(0.5, attrSelect));\n vec2 offset = normal.xy * expansion;\n gl_Position.xy += gl_Position.w * offset;\n}",TEXT_VS:"\nprecision ${PRECISION} float;\n\nattribute vec3 attrCenter;\nattribute vec2 attrCorner;\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nuniform mat4 rotationMat;\nvarying vec2 vertTex;\nuniform float width;\nuniform float height;\nvoid main() { \n vec4 pos = modelviewMat* vec4(attrCenter, 1.0);\n pos.z += 4.0;\n gl_Position = projectionMat * pos;\n gl_Position.xy += vec2(width,height)*attrCorner*gl_Position.w; \n vertTex = (attrCorner+abs(attrCorner))/(2.0*abs(attrCorner)); \n}",TEXT_FS:"\nprecision ${PRECISION} float;\n\nuniform mat4 projectionMat;\nuniform mat4 modelviewMat;\nuniform sampler2D sampler;\nuniform float xScale;\nuniform float yScale;\nvarying vec2 vertTex;\nvoid main() { \n vec2 texCoord = vec2(vertTex.x*xScale, vertTex.y*yScale);\n gl_FragColor = texture2D(sampler, texCoord);\n if (gl_FragColor.a == 0.0) { discard; }\n}"},u=function(){function t(t,e,r){this._element=t,this._element.addEventListener("touchmove",n.bind(this,this._touchMove)),this._element.addEventListener("touchstart",n.bind(this,this._touchStart)),this._element.addEventListener("touchend",n.bind(this,this._touchEnd)),this._element.addEventListener("touchcancel",n.bind(this,this._touchEnd)),this._touchState={scale:1,rotation:0,center:null},this._lastSingleTap=null,this._viewer=e,this._cam=r}function e(t,e){var r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function r(t,e){var r=e.x-t.x,n=e.y-t.y;return Math.atan2(n,r)}return t.prototype={_extractEventAttributes:function(t,n){var i,a,s,o={};o.center=function(t){for(var e=0,r=0,n=0;n300)&r-this._lastMouseDownTime<300){var n=this._canvas.domElement().getBoundingClientRect(),i=this._viewer.pick({x:t.clientX-n.left,y:t.clientY-n.top});this._viewer._dispatchEvent(t,"click",i)}this._lastMouseUpTime=r,e.removeEventListener("mousemove",this._mouseRotateListener),e.removeEventListener("mousemove",this._mousePanListener),e.removeEventListener("mouseup",this._mouseUpListener),document.removeEventListener("mouseup",this._mouseUpListener),document.removeEventListener("mousemove",this._mouseRotateListener),document.removeEventListener("mousemove",this._mousePanListener)},setCam:function(t){this._cam=t},_init:function(){return this._mousePanListener=n.bind(this,this._mousePan),this._mouseRotateListener=n.bind(this,this._mouseRotate),this._mouseUpListener=n.bind(this,this._mouseUp),this._canvas.onWheel(n.bind(this,this._mouseWheelFF),n.bind(this,this._mouseWheel)),this._canvas.on("dblclick",n.bind(this,this._mouseDoubleClick)),this._canvas.on("mousedown",n.bind(this,this._mouseDown)),!0},_mouseWheel:function(t){this._cam.zoom(t.wheelDelta<0?-1:1),t.preventDefault(),this._viewer.requestRedraw()},_mouseWheelFF:function(t){this._cam.zoom(t.deltaY<0?1:-1),t.preventDefault(),this._viewer.requestRedraw()},_mouseDoubleClick:function(t){var e=this._canvas.domElement().getBoundingClientRect(),r=this._viewer.pick({x:t.clientX-e.left,y:t.clientY-e.top});this._viewer._dispatchEvent(t,"doubleClick",r),this._viewer.requestRedraw()},_mouseDown:function(t){0===t.button&&(this._lastMouseDownTime=(new Date).getTime(),t.preventDefault(),!0===t.shiftKey?(this._canvas.on("mousemove",this._mousePanListener),document.addEventListener("mousemove",this._mousePanListener,!1)):(this._canvas.on("mousemove",this._mouseRotateListener),document.addEventListener("mousemove",this._mouseRotateListener,!1)),this._canvas.on("mouseup",this._mouseUpListener),document.addEventListener("mouseup",this._mouseUpListener,!1),this._lastMousePos={x:t.pageX,y:t.pageY})},_mouseRotate:function(t){var e={x:t.pageX,y:t.pageY},r=e.x-this._lastMousePos.x,n=e.y-this._lastMousePos.y;this._cam.rotateX(.005*n),this._cam.rotateY(.005*r),this._lastMousePos=e,this._viewer.requestRedraw()},_mousePan:function(t){var e={x:t.pageX,y:t.pageY},r=e.x-this._lastMousePos.x,n=e.y-this._lastMousePos.y,i=.002*Math.tan(.5*this._cam.fieldOfViewY())*this._cam.zoom();this._cam.panXY(i*r,i*n),this._lastMousePos=e,this._viewer.requestRedraw()}},t}(),c=function(){var e,r,n=t.vec3,i=t.vec4,a=t.mat3,s=t.quat,o=(e=n.create(),function(t,r,i){return n.cross(e,t,r),Math.atan2(n.dot(e,i),n.dot(t,r))}),h=function(){var t=n.create();return function(e,r){return n.copy(t,r),Math.abs(r[0])g[1]&&g[0]>g[2]?0:g[1]>g[2]?1:2,u=(h+1)%3,l=(h+2)%3;if(0===p[h])break;var c=(f[3*l+l]-f[3*u+u])/(2*p[h]),A=c>0?1:-1,b=A/((c*=A)+(c<1e6?Math.sqrt(c*c+1):c)),y=1/Math.sqrt(b*b+1);if(1===y)break;if(i.set(v,0,0,0,0),v[h]=A*Math.sqrt((1-y)/2),v[h]*=-1,v[3]=Math.sqrt(1-v[h]*v[h]),1===v[3])break;e=s.mul(e,e,v),s.normalize(e,e)}return e});return c.prototype.center=function(){return this._center},c.prototype.radius=function(){return this._radius},{signedAngle:o,axisRotation:function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],s=e[1],o=e[2],h=a*a,u=a*s,l=a*o,c=s*s,d=s*o,f=o*o;return t[0]=h+i-h*i,t[1]=u-i*u-n*o,t[2]=l-i*l+n*s,t[3]=u-i*u+n*o,t[4]=c+i-i*c,t[5]=d-i*d-n*a,t[6]=l-i*l-n*s,t[7]=d-i*d+n*a,t[8]=f+i-i*f,t},ortho:h,diagonalizer:A,catmullRomSpline:function(t,e,r,i,a,s){a=a||!1,i=i||.5;var o=null,h=3*l(e,r,a);o=s?s.request(h):new Float32Array(h);var c,d,f,_=0,m=1/r,v=n.create(),p=n.create(),g=n.create(),A=n.create(),b=n.create(),y=n.create();for(n.set(A,t[0],t[1],t[2]),n.set(b,t[3],t[4],t[5]),a?(n.set(g,t[t.length-3],t[t.length-2],t[t.length-1]),n.sub(v,b,g),n.scale(v,v,i)):(n.set(g,t[0],t[1],t[2]),n.set(v,0,0,0)),c=1,f=e-1;ct)return r[n].matrix(t);t-=r[n].matrices().length}return null},showRelated:function(){return this._showRelated},select:function(t){return this.structure().select(t)},structure:function(){return this._vertAssocs[0]._structure},getColorForAtom:function(t,e){return this._vertAssocs[0].getColorForAtom(t,e)},addIdRange:function(t){this._idRanges.push(t)},destroy:function(){F.prototype.destroy.call(this);for(var t=0;t=this._indexData.length||(this._indexData[n++]=t,this._indexData[n++]=e,this._indexData[n++]=r,this._numTriangles+=1,this._ready=!1)},bindBuffers:function(){var t=this._ready,e=this._gl;D.prototype.bindBuffers.call(this),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),t||e.bufferData(e.ELEMENT_ARRAY_BUFFER,this._indexData,e.STATIC_DRAW)},bindAttribs:function(t){var e=this._gl,r=this._BYTES_PER_VERT;e.enableVertexAttribArray(t.posAttrib),e.vertexAttribPointer(t.posAttrib,3,e.FLOAT,!1,r,this._POS_BYTE_OFFSET),-1!==t.normalAttrib&&(e.enableVertexAttribArray(t.normalAttrib),e.vertexAttribPointer(t.normalAttrib,3,e.FLOAT,!1,r,this._NORMAL_BYTE_OFFSET)),-1!==t.colorAttrib&&(e.vertexAttribPointer(t.colorAttrib,4,e.FLOAT,!1,r,this._COLOR_BYTE_OFFSET),e.enableVertexAttribArray(t.colorAttrib)),-1!==t.objIdAttrib&&(e.vertexAttribPointer(t.objIdAttrib,1,e.FLOAT,!1,r,this._OBJID_BYTE_OFFSET),e.enableVertexAttribArray(t.objIdAttrib)),-1!==t.selectAttrib&&(e.vertexAttribPointer(t.selectAttrib,1,e.FLOAT,!1,r,this._SELECT_BYTE_OFFSET),e.enableVertexAttribArray(t.selectAttrib))},releaseAttribs:function(t){var e=this._gl;e.disableVertexAttribArray(t.posAttrib),-1!==t.colorAttrib&&e.disableVertexAttribArray(t.colorAttrib),-1!==t.normalAttrib&&e.disableVertexAttribArray(t.normalAttrib),-1!==t.objIdAttrib&&e.disableVertexAttribArray(t.objIdAttrib),-1!==t.selectAttrib&&e.disableVertexAttribArray(t.selectAttrib)},bind:function(t){this.bindBuffers(),this.bindAttribs(t)},draw:function(){var t=this._gl;t.drawElements(t.TRIANGLES,3*this._numTriangles,t.UNSIGNED_SHORT,0)}}),t}(),m=function(t){function e(e,r,n,i){t.call(this,r,n,i),this._chain=e}function r(t,e,r,n,i,a){V.call(this,e,r,n,i,a),this._chain=t}return n.derive(e,t,{chain:function(){return this._chain},drawSymmetryRelated:function(t,e,r){this.bind(e);for(var n=0;nb.maxVerts()&&(T=b.numVerts(),s.addAssoc(h,b,E,w,T),b=a.vertArrayWithSpaceFor(Z),w=0,W(b,e,n,j,t,r,C,!0,d,0,$)),z&&(s.addAssoc(h,b,E,w,T),W(b,e,n,"A",t,r,C,!1,d,0,$),D+=d.arrowSkip),T=b.numVerts(),D===V-1&&(T+=1),s.addAssoc(h,b,E,w,T),E+=1,z&&(E+=d.arrowSkip)}return b.addVertex(e,t,r,p[p.length-1]),function(t,e,r){for(var n=e+r,i=0;ib-A.numVerts()&&(A=l.vertArrayWithSpaceFor(g)),g-=T;var M=A.numVerts();m.protoCyl.addTransformed(A,i,x,m.radius,t,o,h,R,C),S=A.numVerts(),S-=(S-M)/2,m.protoSphere.addTransformed(A,s,m.radius,h,C),R=C,d.addAssoc(_,A,E,y,S),y=S,u.copy(o,h)}d.setPerResidueColors(_,w),d.addAssoc(_,A,f.length()-1,y,A.numVerts())}}}();return A}(d,function(t,e){var r=m.MeshChainData;function i(t,e,r){I.call(this,t),this._indexedVAs=[],this._float32Allocator=e,this._uint16Allocator=r,this._remainingVerts=null,this._remainingIndices=null}return n.derive(i,I,{_boundedVertArraySize:function(t){return Math.min(65536,t)},addChainVertArray:function(t,e,n){this._remainingVerts=e,this._remainingIndices=n;var i=new r(t.name(),this._gl,this._boundedVertArraySize(e),n,this._float32Allocator,this._uint16Allocator);return this._indexedVAs.push(i),i},addVertArray:function(t,r){this._remainingVerts=t,this._remainingIndices=r;var n=new e(this._gl,this._boundedVertArraySize(t),r,this._float32Allocator,this._uint16Allocator);return this._indexedVAs.push(n),n},vertArrayWithSpaceFor:function(t){var n=this._indexedVAs[this._indexedVAs.length-1];if(n.maxVerts()-n.numVerts()>=t)return n;this._remainingVerts-=n.numVerts(),this._remainingIndices-=n.numIndices(),t=this._boundedVertArraySize(this._remainingVerts);var i=null;return i=n instanceof r?new r(n.chain(),this._gl,t,this._remainingIndices,this._float32Allocator,this._uint16Allocator):new e(this._gl,t,this._remainingIndices,this._float32Allocator,this._uint16Allocator),this._indexedVAs.push(i),i},vertArray:function(t){return this._indexedVAs[t]},destroy:function(){I.prototype.destroy.call(this);for(var t=0;t1?a.push(e.interpolateColor(o,this._interpolation)):a.push(o)}for(n=0;n1?n.push(c.interpolateScalars(a,this._interpolation)):n.push(a)}for(e=0;e1?a.push(e.interpolateColor(o,this._interpolation)):a.push(o)}for(n=0;n0},add:function(t){this._animations.push(t)},remove:function(t){this._animations=this._animations.filter(function(e){return e!==t})}},{AnimationControl:_,move:function(t,e,r){return new u(t,e,r)},rotate:function(t,e,r){return new l(t,e,r)},zoom:function(t,e,r){return new h(t,e,r)},rockAndRoll:function(){return new d([0,1,0],2e3)},spin:function(t,e){return new f(t,e)}}}(),b=function(){function t(t,e){this.near=t,this.far=e}function e(t){t=t||{},this._near=t.near||.1,this._far=t.far||400}function r(){this._far=100}return e.prototype.update=function(){return new t(this._near,this._far)},r.prototype.update=function(e,r){for(var n=r.center(),i=null,a=0;a1}function f(t,e){e.length()<2||t.push(e)}function _(t,e,r){if(0===t.length)return!0;if(!e)return!1;var n=o(r.num(),r.insCode()),i=t[t.length-1];return o(i.num(),i.insCode())=t&&c.num()<=e&&a.push(c)}return a},prop:function(t){return this[t]()}},n.derive(c,l,{name:function(){return this._name},full:function(){return this},addResidue:function(t,e,r){var n=new a(this,t,e,r=r||"\0");return this._rnumsOrdered=_(this._residues,this._rnumsOrdered,n),this._residues.push(n),n},assignSS:function(t,e,r){for(var n=o(t[0],t[1]),i=o(e[0],e[1]),a=1;a=i||s.setSS(r)}},eachBackboneTrace:function(t){this._cacheBackboneTraces();for(var e=0;e0)){for(var t=new r.BackboneTrace,e=null,n=0;n=this._atoms.length&&t<0?null:this._atoms[t]},centralAtom:function(){return this.isAminoacid()?this.atom("CA"):this.isNucleotide()?this.atom("C3'"):null},center:function(){var t=0,e=r.create();return this.eachAtom(function(n){r.add(e,e,n.pos()),t+=1}),t>0&&r.scale(e,e,1/t),e},isAminoacid:function(){return this._isAminoacid},isNucleotide:function(){return this._isNucleotide}},n.derive(o,s,{_deduceType:function(){this._isNucleotide=null!==this.atom("P")&&null!==this.atom("C3'"),this._isAminoacid=null!==this.atom("N")&&null!==this.atom("CA")&&null!==this.atom("C")&&null!==this.atom("O")},name:function(){return this._name},insCode:function(){return this._insCode},num:function(){return this._num},full:function(){return this},addAtom:function(t,e,r,n,a,s){var o=new i(this,t,e,r,this.structure().nextAtomIndex(),n,a,s);return this._atoms.push(o),o},ss:function(){return this._ss},setSS:function(t){this._ss=t},index:function(){return this._index},atoms:function(){return this._atoms},chain:function(){return this._chain},structure:function(){return this._chain.structure()}}),n.derive(h,s,{addAtom:function(t,e){if(e)for(var r=0;r0?this.posAt(e,n-1):this.posAt(e,n),ne&&this._trace[e].index()=this._trace.length)break;for(var a=this._trace[e].index();t.length>r&&t[r].full().index()=t.length)break;for(var s=e;t.length>r&&this._trace.length>e&&t[r].full().index()===this._trace[e].index();)++r,++e;var h=e;n.push(new o(this,s,h))}return n}},s.prototype.smoothPosAt=s.prototype.posAt,s.prototype.smoothNormalAt=s.prototype.normalAt,o.prototype={length:function(){return this._length},residueAt:function(t){return this._fullTrace.residueAt(this._fullTraceBegin+t)},_interpolate:(n=a.create(),i=a.create(),function(t,e,r,s){return this.tangentAt(n,e),this.tangentAt(i,r),a.scale(n,n,s),a.scale(i,i,s),c.cubicHermiteInterpolate(t,this.centralAtomAt(e).pos(),n,this.centralAtomAt(r).pos(),i,.5,0),t}),smoothPosAt:function(t,e,r){if(0===e&&!this._isNTerminal)return this._interpolate(t,e,e+1,r);if(e===this._length-1&&!this._isCTerminal)return this._interpolate(t,e-1,e,r);var n=this.centralAtomAt(e);return a.copy(t,n.pos()),t},smoothNormalAt:function(t,e){return this._fullTrace.normalAt(t,e+this._fullTraceBegin),t},posAt:function(t,e){var r=this.centralAtomAt(e),n=null;return a.copy(t,r.pos()),0!==e||this._isNTerminal||(n=this.centralAtomAt(e+1),a.add(t,t,n.pos()),a.scale(t,t,.5)),e!==this._length-1||this._isCTerminal||(n=this.centralAtomAt(e-1),a.add(t,t,n.pos()),a.scale(t,t,.5)),t},centralAtomAt:function(t){return this.residueAt(t).centralAtom()},fullTraceIndex:function(t){return this._fullTraceBegin+t},tangentAt:function(t,e){return this._fullTrace.tangentAt(t,e+this._fullTraceBegin)}},{TraceSubset:o,BackboneTrace:s}}()),L=t.vec3,S={Bond:function(t,e){var r={atom_one:t,atom_two:e};return{atom_one:function(){return r.atom_one},atom_two:function(){return r.atom_two},mid_point:function(t){return t||(t=L.create()),L.add(t,r.atom_one.pos(),r.atom_two.pos()),L.scale(t,t,.5),t}}}},w=function(){function t(t,e){for(var r=0;rn)){if(l||(l=h.addChain(c[f].full(),!1)),u||(u=l.addResidue(_[v].full(),i)),i){d=!0;break}u.addAtom(p[g].full());break}}}return h}),createEmptyView:function(){return new m(this.full())}},n.derive(_,f,{addAssembly:function(t){this._assemblies.push(t)},setAssemblies:function(t){this._assemblies=t},assemblies:function(){return this._assemblies},chains:function(){return this._chains},full:function(){return this},containsResidue:function(t){return t.full().structure()===this},chainByName:function(t){for(var e=0;eA*A&&t.connect(f,p)}r._deduceType(),null!==e&&(r.isAminoacid()&&e.isAminoacid()&&(i=t,a=r,o=e.atom("C"),h=a.atom("N"),o&&h&&s.sqrDist(o.pos(),h.pos())<1.6*1.6&&i.connect(h,o)),r.isNucleotide()&&e.isNucleotide()&&function(t,e,r){var n=e.atom("O3'"),i=r.atom("P");n&&i&&s.sqrDist(n.pos(),i.pos())<1.7*1.7&&t.connect(n,i)}(t,e,r)),e=r})}}),n.derive(m,f,{full:function(){return this._mol},assemblies:function(){return this._mol.assemblies()},addChain:function(t,e){var r=new h(this,t.full());if(this._chains.push(r),e)for(var n=t.residues(),i=0;i(e=Math.abs(e))?t*Math.sqrt(1+e*e/t/t):0==e?t:e*Math.sqrt(1+t*t/e/e)}var p=0,g=0,A=0,b=0,y=0,R=0,C=0;for(a=0;a=0&&(g=-g),A=p*g-C,u[a][a]=p-g,s=h;s=0&&(g=-g),A=p*g-C,u[a][a+1]=p-g,s=h;sb&&(b=y)}for(a=c-1;-1!=a;a+=-1){if(0!=g){for(A=g*u[a][a+1],s=h;s=49)throw"Error: no convergence.";for(b=f[h],g=v(p=(((y=f[o-1])-R)*(y+R)+((g=d[o-1])-(A=d[o]))*(g+A))/(2*A*y),1),p=p<0?((b-R)*(b+R)+A*(y/(p-g)-A))/b:((b-R)*(b+R)+A*(y/(p+g)-A))/b,i=1,C=1,a=h+1;a=0;s--)if(f[s]=t.length())){var u=i.dist(t.posAt(r,o),t.posAt(n,o+h));if(Math.abs(u-a[h-2])>s)return!1}return!0}),s=function(t,e){return a(t,e,[5.45,5.18,6.37],2.1)},o=function(t,e){return a(t,e,[6.1,10.4,13],1.42)};function h(t){for(var e=0;e122||n>90&&n<97);)++r,n=e.charCodeAt(r);return e[r]}var i=e.charCodeAt(0);return i>=48&&i<=57?e[1]:e.substr(0,2)}return t[1]}function s(t){this._helices=[],this._sheets=[],this._conect=[],this._serialToAtomMap={},this._structure=new P.Mol,this._remark350Reader=new i,this._currChain=null,this._currRes=null,this._currAtom=null,this._options={},this._options.conectRecords=!!t.conectRecords}function o(t){return t.split(/\r\n|\r|\n/g)}function h(t,e){for(var r=e||{},n=o(t),i=new s(r),a=[],h=0;he||r.push(i))}return this._conect.push({from:e,to:r}),!0},processLine:function(t){var e=t.substr(0,6);return"ATOM "===e||"HETATM"===e?this.parseAndAddAtom(t)?this.CONTINUE:this.ERROR:"REMARK"===e?("350"===t.substr(7,3)&&this._remark350Reader.nextLine(t),this.CONTINUE):"HELIX "===e?this.parseHelixRecord(t)?this.CONTINUE:this.ERROR:"SHEET "===e?this.parseSheetRecord(t)?this.CONTINUE:this.ERROR:this._options.conectRecords&&"CONECT"===e?this.parseConectRecord(t)?this.CONTINUE:this.ERROR:"END "===e?this.FILE_END:"ENDMDL"===e?this.MODEL_COMPLETE:this.CONTINUE},finish:function(){if(null===this._currChain)return null;var t,e=null;for(t=0;t>> from galaxy.datatypes.sniff import sniff_with_cls >>> sniff_with_cls(Wav, 'hello.wav') diff --git a/templates/webapps/galaxy/galaxy.masthead.mako b/templates/webapps/galaxy/galaxy.masthead.mako index fcc6e01f001..33dd0d9ee7a 100644 --- a/templates/webapps/galaxy/galaxy.masthead.mako +++ b/templates/webapps/galaxy/galaxy.masthead.mako @@ -35,11 +35,17 @@ ## load the frame manager