From ef1ee01d1e4ed6d4b2358f1cd13d15381ef2fa9e Mon Sep 17 00:00:00 2001 From: Pavel Smirnov Date: Mon, 16 Oct 2017 15:44:01 +0300 Subject: [PATCH] 0.7.4 --- CHANGELOG.md | 22 +++++- dist/Miew.js | 160 ++++++++++++++++++++++++++++----------- dist/Miew.min.js | 12 +-- dist/Miew.module.js | 160 ++++++++++++++++++++++++++++----------- package.json | 2 +- sonar-project.properties | 2 +- 6 files changed, 261 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb1521b6..259ae206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.7.4] - 2017-10-16 +### Added +- Add e2e tests with golden images using Selenium WebDriver. Run `npm run e2e` or `gulp test:e2e`, + then examine the results with `gulp show:e2e`. +- Recognize pi-helices in PDB files (class 3) and color them dark violet. + +### Fixed +- Fix unlit geometry (Lines Mode, Lines Objects) rendering for IE and Edge. +- Fix clipping of electron density volumes. +- Fix `build all` script command when autobuild is disabled. +- Fix the current material highlight in UI when changing it from the terminal. +- Fix the `list` script command when a missing rep is specified. +- Prevent 's' key from appearing in the terminal when it is closed. +- Fix screenshots in case when the height is greater than the width. +- Fix curved surfaces on iPad and similar hardware, choose appropriate shader precision automatically. + +### Changed +- Use webpack dev server for `npm start` command. + ## [0.7.3] - 2017-10-02 ### Added - Add functional tests for parsing PDB, CIF, MMTF, PubChem, CCP4. @@ -46,6 +65,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Update dependencies to the latest supported versions. - Move the project to GitHub. -[Unreleased]: https://github.com/epam/miew/compare/v0.7.3...HEAD +[Unreleased]: https://github.com/epam/miew/compare/v0.7.4...HEAD +[0.7.4]: https://github.com/epam/miew/compare/v0.7.3...v0.7.4 [0.7.3]: https://github.com/epam/miew/compare/v0.7.2...v0.7.3 [0.7.2]: https://github.com/epam/miew/compare/v0.7.1...v0.7.2 diff --git a/dist/Miew.js b/dist/Miew.js index 3e4b7207..ea070fcc 100644 --- a/dist/Miew.js +++ b/dist/Miew.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.3 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.4 Copyright (c) 2015-2017 EPAM Systems, Inc. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : @@ -69120,9 +69120,22 @@ RCGroup.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -var vertexShader = "precision mediump float;\r\nprecision mediump int;\r\n\r\nfloat INSTANCED_SPRITE_OVERSCALE = 1.3;\r\n\r\nattribute vec3 normal;\r\nvarying vec3 vNormal;\r\n#ifdef THICK_LINE\r\n attribute vec4 position; // W contains vert pos or neg offset\r\n#else\r\n attribute vec3 position;\r\n#endif\r\nvarying vec3 vPosition;\r\n\r\nvarying vec3 vWorldPosition;\r\nvarying vec3 vViewPosition;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n attribute float alphaColor;\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n varying vec2 vUv;\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n varying vec4 instOffset;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\nuniform mat4 projMatrixInv; // TODO move to thick line\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n vec3 objectNormal = vec3( normal );\r\n#ifdef INSTANCED_MATRIX\r\n vec3 transformedNormal = vec3(\r\n dot(objectNormal, matVector1.xyz),\r\n dot(objectNormal, matVector2.xyz),\r\n dot(objectNormal, matVector3.xyz));\r\n transformedNormal = normalMatrix * transformedNormal;\r\n#else\r\n vec3 transformedNormal = normalMatrix * objectNormal;\r\n#endif\r\n vNormal = normalize(transformedNormal);\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n instOffset = offset;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n spritePosEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = spritePosEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n spritePosEye.w = offset.w * scale;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n spritePosEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n spritePosEye.w = 1.0;\r\n\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n vec2 spriteSize = INSTANCED_SPRITE_OVERSCALE * abs(spritePosEye.z) *\r\n (spriteSizeScreen + 2.0 * rad / minZ);\r\n\r\n mvPosition = spritePosEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n vUv = uv;\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n"; +var vertexShader = "float INSTANCED_SPRITE_OVERSCALE = 1.3;\r\n\r\nattribute vec3 normal;\r\nvarying vec3 vNormal;\r\n#ifdef THICK_LINE\r\n attribute vec4 position; // W contains vert pos or neg offset\r\n#else\r\n attribute vec3 position;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition;\r\nvarying vec3 vViewPosition;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n attribute float alphaColor;\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n varying vec2 vUv;\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n varying vec4 instOffset;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\nuniform mat4 projMatrixInv; // TODO move to thick line\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n vec3 objectNormal = vec3( normal );\r\n#ifdef INSTANCED_MATRIX\r\n vec3 transformedNormal = vec3(\r\n dot(objectNormal, matVector1.xyz),\r\n dot(objectNormal, matVector2.xyz),\r\n dot(objectNormal, matVector3.xyz));\r\n transformedNormal = normalMatrix * transformedNormal;\r\n#else\r\n vec3 transformedNormal = normalMatrix * objectNormal;\r\n#endif\r\n vNormal = normalize(transformedNormal);\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n instOffset = offset;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n spritePosEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = spritePosEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n spritePosEye.w = offset.w * scale;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n spritePosEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n spritePosEye.w = 1.0;\r\n\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n vec2 spriteSize = INSTANCED_SPRITE_OVERSCALE * abs(spritePosEye.z) *\r\n (spriteSizeScreen + 2.0 * rad / minZ);\r\n\r\n mvPosition = spritePosEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n vUv = uv;\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n"; -var fragmentShader = "precision mediump float;\r\nprecision mediump int;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n varying vec2 vUv;\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\nvarying vec3 vNormal;\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n uniform mat4 projectionMatrix;\r\n varying vec4 spritePosEye;\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 instOffset;\r\n\r\n float intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_sphere_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into sphere local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = normalize(v.xyz);\r\n\r\n return intersect_ray_sphere(origin, ray, point);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n float intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n float halfHeight = 0.5;\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_cylinder_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into cylinder local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Lighting ////////////////////////////////////////////////\r\n\r\n#if NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n uniform vec3 ambientLightColor;\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n // use loop for number\r\n #if NUM_DIR_LIGHTS > 1\r\n for (int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n RE_Direct_BlinnPhong(directionalLights[i], geometry, material, reflectedLight);\r\n #else\r\n RE_Direct_BlinnPhong(directionalLights[0], geometry, material, reflectedLight);\r\n #endif\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n #if NUM_DIR_LIGHTS > 1\r\n }\r\n #endif\r\n\r\n return reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (get_sphere_point(-vViewPosition, p) < 0.0) discard;\r\n pixelPosWorld = modelMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n // pixelPosEye = modelViewMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += instOffset.w *\r\n (modelViewMatrix[0][2] * p.x +\r\n modelViewMatrix[1][2] * p.y +\r\n modelViewMatrix[2][2] * p.z);\r\n normal = normalize(normalMatrix * p);\r\n }\r\n\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (get_cylinder_point(-vViewPosition, p) < 0.0) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n#else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n#endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n#ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n#endif\r\n\r\n// transparency prepass writes only z, so we don't need to calc the color\r\n#ifdef PREPASS_TRANSP\r\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n#endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n#endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n#ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n#else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n#endif\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n #ifdef DOUBLE_SIDED\r\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #else\r\n float flipNormal = 1.0;\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n#endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n GeometricContext geometry = GeometricContext(normal, normalize( vViewPosition ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material);\r\n#else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n gl_FragColor = world2colorMatrix * pixelPosWorld;\r\n#else\r\n #ifdef OVERRIDE_COLOR\r\n gl_FragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float fogFactor = smoothstep( fogNear, fogFar, vViewPosition.z );\r\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n#endif\r\n}\r\n"; +var fragmentShader = "#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n varying vec2 vUv;\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\nvarying vec3 vNormal;\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n uniform mat4 projectionMatrix;\r\n varying vec4 spritePosEye;\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 instOffset;\r\n\r\n float intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_sphere_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into sphere local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = normalize(v.xyz);\r\n\r\n return intersect_ray_sphere(origin, ray, point);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n float intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n float halfHeight = 0.5;\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_cylinder_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into cylinder local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Lighting ////////////////////////////////////////////////\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n uniform vec3 ambientLightColor;\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n // use loop for number\r\n #if NUM_DIR_LIGHTS > 1\r\n for (int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n RE_Direct_BlinnPhong(directionalLights[i], geometry, material, reflectedLight);\r\n #else\r\n RE_Direct_BlinnPhong(directionalLights[0], geometry, material, reflectedLight);\r\n #endif\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n #if NUM_DIR_LIGHTS > 1\r\n }\r\n #endif\r\n\r\n return reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (get_sphere_point(-vViewPosition, p) < 0.0) discard;\r\n pixelPosWorld = modelMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n // pixelPosEye = modelViewMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += instOffset.w *\r\n (modelViewMatrix[0][2] * p.x +\r\n modelViewMatrix[1][2] * p.y +\r\n modelViewMatrix[2][2] * p.z);\r\n normal = normalize(normalMatrix * p);\r\n }\r\n\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (get_cylinder_point(-vViewPosition, p) < 0.0) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n#else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n#endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n#ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n#endif\r\n\r\n// transparency prepass writes only z, so we don't need to calc the color\r\n#ifdef PREPASS_TRANSP\r\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n#endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n#endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n#ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n#else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n#endif\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n #ifdef DOUBLE_SIDED\r\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #else\r\n float flipNormal = 1.0;\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n#endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n GeometricContext geometry = GeometricContext(normal, normalize( vViewPosition ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material);\r\n#else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n gl_FragColor = world2colorMatrix * pixelPosWorld;\r\n#else\r\n #ifdef OVERRIDE_COLOR\r\n gl_FragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float fogFactor = smoothstep( fogNear, fogFar, vViewPosition.z );\r\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n#endif\r\n}\r\n"; + +var capabilities = { + + precision: 'mediump', + + /** + * + * @param {THREE.WebGLRenderer} renderer + */ + init: function init(renderer) { + this.precision = renderer.capabilities.getMaxPrecision('highp'); + } +}; /* eslint-disable no-magic-numbers */ /* eslint-disable guard-for-in */ @@ -69191,8 +69204,8 @@ function UberMaterial(params) { // set default values RawShaderMaterial.prototype.setValues.call(this, { uniforms: UniformsUtils.clone(defaultUniforms), - vertexShader: vertexShader, - fragmentShader: fragmentShader, + vertexShader: this.precisionString() + vertexShader, + fragmentShader: this.precisionString() + fragmentShader, lights: true, fog: true, side: DoubleSide @@ -69204,6 +69217,12 @@ function UberMaterial(params) { UberMaterial.prototype = Object.create(RawShaderMaterial.prototype); UberMaterial.prototype.constructor = UberMaterial; +UberMaterial.prototype.precisionString = function () { + var precision = capabilities.precision; + var str = 'precision ' + precision + ' float;\n' + 'precision ' + precision + ' int;\n\n'; + return str; +}; + // properties that convert to uniforms UberMaterial.prototype.uberOptions = { diffuse: new Color(0xffffff), // used in phong lighting @@ -77580,6 +77599,14 @@ var exports$1 = /** @alias module:gfx/modes */{ */ list: modeList, + /** + * The list of mode descriptions. + * @type {Array<{id:string, name:string}>} + */ + descriptions: lodash.map(modeList, function (m) { + return lodash.pick(m.prototype, ['id', 'name']); + }), + /** * The mode constructor one can use if he doesn't care (the default one). * @type {function(new:Mode)} @@ -77975,8 +78002,13 @@ palette$1.chainColors = [ 0xFFB22222]; palette$1.secondaryColors = { - 'helix': { 1: 0xFF0080, 5: 0xA00080 }, + 'helix': { + 1: 0xFF0080, // RH alpha + 3: 0x600080, // RH pi + 5: 0xA00080 // RH 3-10 + }, 'strand': 0xFFC800, + 'turn': 0x6080FF, 'dna': 0xAE00FE, 'rna': 0xFD0162 }; @@ -78525,6 +78557,14 @@ var exports$2 = /** @alias module:gfx/colorers */{ */ list: colorerList, + /** + * The list of colorer descriptions. + * @type {Array<{id:string, name:string}>} + */ + descriptions: lodash.map(colorerList, function (m) { + return lodash.pick(m.prototype, ['id', 'name']); + }), + /** * The colorer constructor one can use if he doesn't care (the default one). * @type {Function} @@ -78644,6 +78684,10 @@ for (var i$2 = 0, n$1 = materialList.length; i$2 < n$1; ++i$2) { var materials = { list: materialList, + descriptions: lodash.map(materialList, function (m) { + return lodash.pick(m, ['id', 'name']); + }), + any: materialDict[settings.now.presets.default.material] || materialList[0], get: function get(id) { @@ -80187,7 +80231,7 @@ VolumeMesh.prototype._updateVertices = function () { var i; var norm = this.clipPlane.normal; - var D = -norm.dot(this.clipPlane.constant); + var D = this.clipPlane.constant; var vert = this.vertices; var size = this.size; @@ -80288,11 +80332,13 @@ VolumeMesh.prototype._updateVertices = function () { this.faces[6] = face; var diff = new Vector3(); + var coplanarPoint = new Vector3(); + this.clipPlane.coplanarPoint(coplanarPoint); for (i = 0; i < vert.length; ++i) { this.cullFlag[i] = false; if (i < 8) { // corners should be culled by clipping plane - diff.subVectors(vert[i], this.clipPlane.constant); + diff.subVectors(vert[i], coplanarPoint); this.cullFlag[i] = norm.dot(diff) >= 0.0; } else if (i < 8 + face.indices.length) { // cross section vertices don't get culled @@ -80460,26 +80506,41 @@ VolumeMesh.prototype.setDataSource = function (dataSource) { bbox.getCenter(this.position); }; -VolumeMesh.prototype.rebuild = function (camera) { +VolumeMesh.prototype.rebuild = function () { + var nearClipPlaneOffset = 0.2; + var pos = new Vector3(); + var norm = new Vector3(); + var norm4D = new Vector4(); + var matrixWorldToLocal = new Matrix4(); + var clipPlane = new Plane(); - // get clip plane in local space - var norm = camera.getWorldDirection(); - var pos = camera.getWorldPosition(); - pos.addScaledVector(norm, camera.near + nearClipPlaneOffset); - this.worldToLocal(pos); - this.worldToLocal(norm); - norm.normalize(); + return function (camera) { - var clipPlane = new Plane(norm, pos); + // get clip plane in local space + camera.getWorldDirection(norm); + camera.getWorldPosition(pos); + pos.addScaledVector(norm, camera.near + nearClipPlaneOffset); - if (!this.clipPlane.equals(clipPlane)) { - this.clipPlane = clipPlane; + // transform pos to local CS + matrixWorldToLocal.getInverse(this.matrixWorld); + pos.applyMatrix4(matrixWorldToLocal); - this._updateVertices(); - this._updateIndices(); - } -}; + // transform norm to local CS + norm4D.set(norm.x, norm.y, norm.z, 0.0); // NOTE: use homogeneous norm for proper transformation + norm4D.applyMatrix4(matrixWorldToLocal); + norm.copy(norm4D); + norm.normalize(); + + clipPlane.setFromNormalAndCoplanarPoint(norm, pos); + + if (!this.clipPlane.equals(clipPlane)) { + this.clipPlane = clipPlane.clone(); + this._updateVertices(); + this._updateIndices(); + } + }; +}(); function VolumeVisual(name, dataSource) { Visual.call(this, name, dataSource); @@ -86210,7 +86271,7 @@ Cookies.prototype._exists = function (key) { return document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)')); }; -/* global "0.7.3":false */ +/* global "0.7.4":false */ ////////////////////////////////////////////////////////////////////////////// @@ -86537,6 +86598,7 @@ Miew$1.prototype._initGfx = function () { gfx.renderer2d = new CSS2DRenderer(); gfx.renderer = new WebGLRenderer(webGLOptions); + capabilities.init(gfx.renderer); // z-sprites and ambient occlusion possibility if (!gfx.renderer.getContext().getExtension('EXT_frag_depth')) { @@ -88457,6 +88519,8 @@ Miew$1.prototype._onKeyDown = function (event) { } break; case 'S'.charCodeAt(0): + event.preventDefault(); + event.stopPropagation(); settings.now.ao = !settings.now.ao; this._needRender = true; break; @@ -88696,6 +88760,14 @@ Miew$1.prototype.benchmarkGfx = function (force) { Miew$1.prototype.screenshot = function (width, height) { var gfx = this._gfx; + function Fov2Tan(fov) { + return Math.tan(_Math.degToRad(0.5 * fov)); + } + + function Tan2Fov(tan) { + return _Math.radToDeg(Math.atan(tan)) * 2.0; + } + height = height || width || gfx.height; width = width || gfx.width; @@ -88706,17 +88778,19 @@ Miew$1.prototype.screenshot = function (width, height) { screenshotURI = gfx.renderer.domElement.toDataURL('image/png'); } else { - var originalAspect = gfx.width / gfx.height; + var originalAspect = gfx.camera.aspect; var originalFov = gfx.camera.fov; + var originalTanFov2 = Fov2Tan(gfx.camera.fov); // screenshot should contain the principal area of interest (a centered square touching screen sides) var areaOfInterestSize = Math.min(gfx.width, gfx.height); - var areaOfInterestFov = originalFov * areaOfInterestSize / gfx.height; + //var areaOfInterestFov = originalFov * areaOfInterestSize / gfx.height; + var areaOfInterestTanFov2 = originalTanFov2 * areaOfInterestSize / gfx.height; // set appropriate camera aspect & FOV var shotAspect = width / height; gfx.camera.aspect = shotAspect; - gfx.camera.fov = areaOfInterestFov / Math.min(shotAspect, 1.0); + gfx.camera.fov = Tan2Fov(areaOfInterestTanFov2 / Math.min(shotAspect, 1.0)); gfx.camera.updateProjectionMatrix(); // resize canvas to the required size of screenshot @@ -89746,7 +89820,7 @@ function load(file, loadOptions, master, context) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.3" !== 'undefined' && "0.7.3" || '0.0.0-dev'; +Miew$1.prototype.VERSION = typeof "0.7.4" !== 'undefined' && "0.7.4" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew$1, /** @lends Miew */{ @@ -89884,7 +89958,7 @@ case 4: this.$ = yy.miew.rebuild(); break; case 5: -this.$ = yy.miew.rebuildAll(); +this.$ = yy.miew.rebuildAll(); yy.miew.rebuild(); break; case 6: this.$ = yy.echo(yy.utils.help().toString()); @@ -91256,28 +91330,26 @@ CLIUtils.prototype.list = function (miew, repMap, key) { CLIUtils.prototype.listRep = function (miew, repMap, repIndex, key) { var ret = ''; - var opts = miew.rep(repIndex); + var rep = miew.repGet(repIndex); + if (!rep) { + logger.warn('Rep ' + repIndex + ' does not exist!'); + return ret; + } var index = repIndex; var repName = repMap.get(index); - var modeId = opts.mode instanceof Array ? opts.mode[0] : opts.mode; + var mode = rep.mode; + var selectionStr = rep.selectorString; + var colorer = rep.colorer; + var material = rep.materialPreset; - ret += '#' + index + ' : ' + modes$1.get(modeId).name + (repName === '' ? '' : repName) + '\n'; + ret += '#' + index + ' : ' + mode.name + (repName === '' ? '' : repName) + '\n'; if (key !== undefined) { - var selectionStr = opts.selector; - if (selectionStr instanceof Array) { - var converter = new JSONtoSelectorConverter(); - selectionStr = converter.createSelectorFromNode(selectionStr); - } - - var colorerId = opts.colorer instanceof Array ? opts.colorer[0] : opts.colorer; - var materialId = opts.material; - ret += ' selection : "' + selectionStr + '"\n'; - ret += ' mode : (' + modeId + '), ' + modes$1.get(modeId).name + '\n'; - ret += ' colorer : (' + colorerId + '), ' + colorers$1.get(colorerId).name + '\n'; - ret += ' material : (' + materialId + '), ' + materials$1.get(materialId).name + '\n'; + ret += ' mode : (' + mode.id + '), ' + mode.name + '\n'; + ret += ' colorer : (' + colorer.id + '), ' + colorer.name + '\n'; + ret += ' material : (' + material.id + '), ' + material.name + '\n'; } return ret; diff --git a/dist/Miew.min.js b/dist/Miew.min.js index 4701a7e8..6024bb96 100644 --- a/dist/Miew.min.js +++ b/dist/Miew.min.js @@ -1,9 +1,9 @@ -/** Miew - 3D Molecular Viewer v0.7.3 Copyright (c) 2015-2017 EPAM Systems, Inc. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Miew=e()}(this,function(){"use strict";function t(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(){}function n(t,e){this.x=t||0,this.y=e||0}function i(t,e,r,o,a,s,c,l,u,h){Object.defineProperty(this,"id",{value:Pp++}),this.uuid=Tp.generateUUID(),this.name="",this.image=void 0!==t?t:i.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:i.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:Rh,this.wrapT=void 0!==o?o:Rh,this.magFilter=void 0!==a?a:zh,this.minFilter=void 0!==s?s:kh,this.anisotropy=void 0!==u?u:1,this.format=void 0!==c?c:Jh,this.type=void 0!==l?l:Uh,this.offset=new n(0,0),this.repeat=new n(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:_p,this.version=0,this.onUpdate=null}function o(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function a(t,e,r){this.uuid=Tp.generateUUID(),this.width=t,this.height=e,this.scissor=new o(0,0,t,e),this.scissorTest=!1,this.viewport=new o(0,0,t,e),void 0===(r=r||{}).minFilter&&(r.minFilter=zh),this.texture=new i(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}function s(t,e,r){a.call(this,t,e,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function c(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function l(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function u(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length}function h(t,e,r,n,o,a,s,c,l,u){t=void 0!==t?t:[],e=void 0!==e?e:Sh,i.call(this,t,e,r,n,o,a,s,c,l,u),this.flipY=!1}function p(){this.seq=[],this.map={}}function f(t,e,r){var n=t[0];if(n<=0||n>0)return t;var i=e*r,o=Np[i];if(void 0===o&&(o=new Float32Array(i),Np[i]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function d(t,e){var r=Ip[e];void 0===r&&(r=new Int32Array(e),Ip[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function m(t,e){t.uniform1f(this.addr,e)}function g(t,e){t.uniform1i(this.addr,e)}function v(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function y(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 x(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function b(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function w(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function S(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function M(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Lp,n)}function A(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Rp,n)}function E(t,e){t.uniform2iv(this.addr,e)}function C(t,e){t.uniform3iv(this.addr,e)}function T(t,e){t.uniform4iv(this.addr,e)}function P(t){switch(t){case 5126:return m;case 35664:return v;case 35665:return y;case 35666:return x;case 35674:return b;case 35675:return w;case 35676:return S;case 35678:return M;case 35680:return A;case 5124:case 35670:return g;case 35667:case 35671:return E;case 35668:case 35672:return C;case 35669:case 35673:return T}}function L(t,e){t.uniform1fv(this.addr,e)}function R(t,e){t.uniform1iv(this.addr,e)}function N(t,e){t.uniform2fv(this.addr,f(e,this.size,2))}function I(t,e){t.uniform3fv(this.addr,f(e,this.size,3))}function O(t,e){t.uniform4fv(this.addr,f(e,this.size,4))}function D(t,e){t.uniformMatrix2fv(this.addr,!1,f(e,this.size,4))}function z(t,e){t.uniformMatrix3fv(this.addr,!1,f(e,this.size,9))}function F(t,e){t.uniformMatrix4fv(this.addr,!1,f(e,this.size,16))}function k(t,e,r){var n=e.length,i=d(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||Lp,i[o])}function U(t,e,r){var n=e.length,i=d(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||Rp,i[o])}function B(t){switch(t){case 5126:return L;case 35664:return N;case 35665:return I;case 35666:return O;case 35674:return D;case 35675:return z;case 35676:return F;case 35678:return k;case 35680:return U;case 5124:case 35670:return R;case 35667:case 35671:return E;case 35668:case 35672:return C;case 35669:case 35673:return T}}function V(t,e,r){this.id=t,this.addr=r,this.setValue=P(e.type)}function j(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=B(e.type)}function G(t){this.id=t,p.call(this)}function W(t,e){t.seq.push(e),t.map[e.id]=e}function H(t,e,r){var n=t.name,i=n.length;for(Op.lastIndex=0;;){var o=Op.exec(n),a=Op.lastIndex,s=o[1],c="]"===o[2],l=o[3];if(c&&(s|=0),void 0===l||"["===l&&a+2===i){W(r,void 0===l?new V(s,t,e):new j(s,t,e));break}var u=r.map[s];void 0===u&&W(r,u=new G(s)),r=u}}function X(t,e,r){p.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,b=R.size*R.scale/g.w,w.x=b*y,w.y=b,d.uniform3f(h.screenPosition,S.x,S.y,S.z),d.uniform2f(h.scale,w.x,w.y),d.uniform1f(h.rotation,R.rotation),d.uniform1f(h.opacity,R.opacity),d.uniform3f(h.color,R.color.r,R.color.g,R.color.b),m.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),t.setTexture2D(R.texture,1),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0))}}}m.enable(d.CULL_FACE),m.enable(d.DEPTH_TEST),m.setDepthWrite(!0),t.resetGLState()}}}function K(t,e){function r(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),e=new Uint16Array([0,1,2,0,2,3]);a=d.createBuffer(),s=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,a),d.bufferData(d.ARRAY_BUFFER,t,d.STATIC_DRAW),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.bufferData(d.ELEMENT_ARRAY_BUFFER,e,d.STATIC_DRAW),u=n(),h={position:d.getAttribLocation(u,"position"),uv:d.getAttribLocation(u,"uv")},p={uvOffset:d.getUniformLocation(u,"uvOffset"),uvScale:d.getUniformLocation(u,"uvScale"),rotation:d.getUniformLocation(u,"rotation"),scale:d.getUniformLocation(u,"scale"),color:d.getUniformLocation(u,"color"),map:d.getUniformLocation(u,"map"),opacity:d.getUniformLocation(u,"opacity"),modelViewMatrix:d.getUniformLocation(u,"modelViewMatrix"),projectionMatrix:d.getUniformLocation(u,"projectionMatrix"),fogType:d.getUniformLocation(u,"fogType"),fogDensity:d.getUniformLocation(u,"fogDensity"),fogNear:d.getUniformLocation(u,"fogNear"),fogFar:d.getUniformLocation(u,"fogFar"),fogColor:d.getUniformLocation(u,"fogColor"),alphaTest:d.getUniformLocation(u,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var o=r.getContext("2d");o.fillStyle="white",o.fillRect(0,0,8,8),(f=new i(r)).needsUpdate=!0}function n(){var e=d.createProgram(),r=d.createShader(d.VERTEX_SHADER),n=d.createShader(d.FRAGMENT_SHADER);return d.shaderSource(r,["precision "+t.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),d.shaderSource(n,["precision "+t.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),d.compileShader(r),d.compileShader(n),d.attachShader(e,r),d.attachShader(e,n),d.linkProgram(e),e}function o(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var a,s,u,h,p,f,d=t.context,m=t.state,g=new l,v=new c,y=new l;this.render=function(n,i){if(0!==e.length){void 0===u&&r(),d.useProgram(u),m.initAttributes(),m.enableAttribute(h.position),m.enableAttribute(h.uv),m.disableUnusedAttributes(),m.disable(d.CULL_FACE),m.enable(d.BLEND),d.bindBuffer(d.ARRAY_BUFFER,a),d.vertexAttribPointer(h.position,2,d.FLOAT,!1,16,0),d.vertexAttribPointer(h.uv,2,d.FLOAT,!1,16,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.uniformMatrix4fv(p.projectionMatrix,!1,i.projectionMatrix.elements),m.activeTexture(d.TEXTURE0),d.uniform1i(p.map,0);var c=0,l=0,_=n.fog;_?(d.uniform3f(p.fogColor,_.color.r,_.color.g,_.color.b),_.isFog?(d.uniform1f(p.fogNear,_.near),d.uniform1f(p.fogFar,_.far),d.uniform1i(p.fogType,1),c=1,l=1):_.isFogExp2&&(d.uniform1f(p.fogDensity,_.density),d.uniform1i(p.fogType,2),c=2,l=2)):(d.uniform1i(p.fogType,0),c=0,l=0);for(var x=0,b=e.length;x0:o&&o.isGeometry&&(l=o.morphTargets&&o.morphTargets.length>0));var u=e.isSkinnedMesh&&r.skinning,h=0;l&&(h|=b),u&&(h|=w),a=s[h]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var p=a.uuid,f=r.uuid,d=E[p];void 0===d&&(d={},E[p]=d);var m=d[f];void 0===m&&(m=a.clone(),d[f]=m),a=m}a.visible=r.visible,a.wireframe=r.wireframe;var g=r.side;return k.renderSingleSided&&g==Iu&&(g=Ru),k.renderReverseSided&&(g===Ru?g=Nu:g===Nu&&(g=Ru)),a.side=g,a.clipShadows=r.clipShadows,a.clippingPlanes=r.clippingPlanes,a.wireframeLinewidth=r.wireframeLinewidth,a.linewidth=r.linewidth,n&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(i),a}function c(t,e,r){if(!1!==t.visible){0!=(t.layers.mask&e.layers.mask)&&(t.isMesh||t.isLine||t.isPoints)&&(!t.castShadow||!1!==t.frustumCulled&&!0!==f.intersectsObject(t)||!0===t.material.visible&&(t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),x.push(t)));for(var n=t.children,i=0,o=n.length;ir&&(r=t[e]);return r}function Ct(){return jp++}function Tt(){Object.defineProperty(this,"id",{value:Ct()}),this.uuid=Tp.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Pt(){Object.defineProperty(this,"id",{value:Ct()}),this.uuid=Tp.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Lt(t,e){ut.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Pt,this.material=void 0!==e?e:new dt({color:16777215*Math.random()}),this.drawMode=gp,this.updateMorphTargets()}function Rt(t,e,r,n,i,o){Tt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Nt(t,e,r,n,i,o)),this.mergeVertices()}function Nt(t,e,r,n,i,o){function a(t,e,r,n,i,o,a,m,g,v,y){var _,x,b=o/g,w=a/v,S=o/2,M=a/2,A=m/2,E=g+1,C=v+1,T=0,P=0,L=new l;for(x=0;x0?1:-1,h.push(L.x,L.y,L.z),p.push(_/g),p.push(1-x/v),T+=1}}for(x=0;x/g;return t.replace(e,function(t,e){var r=zp[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return Kt(r)})}function Qt(t){var e=/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return t.replace(e,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,g=Xt(o,n,t.extensions),v=Yt(a),y=i.createProgram();r.isRawShaderMaterial?(f=[v,"\n"].filter($t).join("\n"),d=[g,v,"\n"].filter($t).join("\n")):(f=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.__webglShader.name,v,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",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 "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter($t).join("\n"),d=[g,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.__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 "+h:"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(n.numClippingPlanes-n.numClipIntersection),n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",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!==yh?"#define TONE_MAPPING":"",n.toneMapping!==yh?zp.tonemapping_pars_fragment:"",n.toneMapping!==yh?Ht("toneMapping",n.toneMapping):"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?zp.encodings_pars_fragment:"",n.mapEncoding?Gt("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?Gt("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?Gt("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?Wt("linearToOutputTexel",n.outputEncoding):"",n.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter($t).join("\n")),s=Zt(s=Kt(s,n),n),c=Zt(c=Kt(c,n),n),r.isShaderMaterial||(s=Qt(s),c=Qt(c));var _=f+s,x=d+c,b=Vt(i,i.VERTEX_SHADER,_),w=Vt(i,i.FRAGMENT_SHADER,x);i.attachShader(y,b),i.attachShader(y,w),void 0!==r.index0AttributeName?i.bindAttribLocation(y,0,r.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);var S=i.getProgramInfoLog(y),M=i.getShaderInfoLog(b),A=i.getShaderInfoLog(w),E=!0,C=!0;!1===i.getProgramParameter(y,i.LINK_STATUS)?E=!1:""!==S||""!==M&&""!==A||(C=!1),C&&(this.diagnostics={runnable:E,material:r,programLog:S,vertexShader:{log:M,prefix:f},fragmentShader:{log:A,prefix:d}}),i.deleteShader(b),i.deleteShader(w);var T;this.getUniforms=function(){return void 0===T&&(T=new X(i,y,t)),T};var P;return this.getAttributes=function(){return void 0===P&&(P=qt(i,y)),P},this.destroy=function(){i.deleteProgram(y),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return this.getUniforms()}},attributes:{get:function(){return this.getAttributes()}}}),this.id=Gp++,this.code=e,this.usedTimes=1,this.program=y,this.vertexShader=b,this.fragmentShader=w,this}function te(t,e){function r(t){if(e.floatVertexTextures&&t&&t.skeleton&&t.skeleton.useVertexTexture)return 1024;var r=e.maxVertexUniforms,n=Math.floor((r-20)/4);return void 0!==t&&t&&t.isSkinnedMesh&&(n=Math.min(t.skeleton.bones.length,n),t.skeleton.bones.length),n}function n(t,e){var r;return t?t.isTexture?r=t.encoding:t.isWebGLRenderTarget&&(r=t.texture.encoding):r=_p,r===_p&&e&&(r=bp),r}var i=[],o={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},a=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking"];this.getParameters=function(i,a,s,c,l,u){var h=o[i.type],p=r(u),f=t.getPrecision();null!==i.precision&&(f=e.getMaxPrecision(i.precision),i.precision);var d=t.getCurrentRenderTarget();return{shaderID:h,precision:f,supportsVertexTextures:e.vertexTextures,outputEncoding:n(d?d.texture:null,t.gammaOutput),map:!!i.map,mapEncoding:n(i.map,t.gammaInput),envMap:!!i.envMap,envMapMode:i.envMap&&i.envMap.mapping,envMapEncoding:n(i.envMap,t.gammaInput),envMapCubeUV:!!i.envMap&&(i.envMap.mapping===Th||i.envMap.mapping===Ph),lightMap:!!i.lightMap,aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,emissiveMapEncoding:n(i.emissiveMap,t.gammaInput),bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,alphaMap:!!i.alphaMap,gradientMap:!!i.gradientMap,combine:i.combine,vertexColors:i.vertexColors,fog:!!s,useFog:i.fog,fogExp:s&&s.isFogExp2,flatShading:i.shading===Ou,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:e.logarithmicDepthBuffer,skinning:i.skinning,maxBones:p,useVertexTexture:e.floatVertexTextures&&u&&u.skeleton&&u.skeleton.useVertexTexture,morphTargets:i.morphTargets,morphNormals:i.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:c,numClipIntersection:l,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&a.shadows.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===Iu,flipSided:i.side===Nu,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(t,e){var r=[];if(e.shaderID?r.push(e.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(var i=0;i65535?wt:xt)(o,1);return n(d,t.ELEMENT_ARRAY_BUFFER),i.wireframe=d,d},update:function(e){var r=a.get(e);e.geometry.isGeometry&&r.updateFromObject(e);var i=r.index,o=r.attributes;null!==i&&n(i,t.ELEMENT_ARRAY_BUFFER);for(var s in o)n(o[s],t.ARRAY_BUFFER);var c=r.morphAttributes;for(var s in c)for(var l=c[s],u=0,h=l.length;ue||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return Tp.isPowerOfTwo(t.width)&&Tp.isPowerOfTwo(t.height)}function l(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Tp.nearestPowerOfTwo(t.width),e.height=Tp.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}function u(t){return t.wrapS!==Rh||t.wrapT!==Rh||t.minFilter!==Ih&&t.minFilter!==zh}function h(e){return e===Ih||e===Oh||e===Dh?t.NEAREST:t.LINEAR}function p(t){var e=t.target;e.removeEventListener("dispose",p),d(e),S.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),m(e),S.textures--}function d(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.delete(e)}function m(e){var r=n.get(e),i=n.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.delete(e.texture),n.delete(e)}}function g(e,i){var o=n.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a);else if(!1!==a.complete)return void y(o,e,i)}r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function v(r,a,s){var c;if(s?(t.texParameteri(r,t.TEXTURE_WRAP_S,o(a.wrapS)),t.texParameteri(r,t.TEXTURE_WRAP_T,o(a.wrapT)),t.texParameteri(r,t.TEXTURE_MAG_FILTER,o(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,o(a.minFilter))):(t.texParameteri(r,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(r,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS!==Rh||a.wrapT,t.texParameteri(r,t.TEXTURE_MAG_FILTER,h(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,h(a.minFilter)),a.minFilter!==Ih&&a.minFilter),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===Hh&&null===e.get("OES_texture_float_linear"))return;if(a.type===Xh&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function y(e,n,a){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),S.textures++),r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var h=s(n.image,i.maxTextureSize);u(n)&&!1===c(h)&&(h=l(h));var f=c(h),d=o(n.format),m=o(n.type);v(t.TEXTURE_2D,n,f);var g,y=n.mipmaps;if(n.isDepthTexture){var _=t.DEPTH_COMPONENT;if(n.type===Hh){if(!M)throw new Error("Float Depth Texture only supported in WebGL2.0");_=t.DEPTH_COMPONENT32F}else M&&(_=t.DEPTH_COMPONENT16);n.format===np&&_===t.DEPTH_COMPONENT&&n.type!==jh&&n.type!==Wh&&(n.type=jh,m=o(n.type)),n.format===ip&&(_=t.DEPTH_STENCIL,n.type!==Zh&&(n.type=Zh,m=o(n.type))),r.texImage2D(t.TEXTURE_2D,0,_,h.width,h.height,0,d,m,null)}else if(n.isDataTexture)if(y.length>0&&f){for(var x=0,b=y.length;x-1&&r.compressedTexImage2D(t.TEXTURE_2D,x,d,g.width,g.height,0,g.data):r.texImage2D(t.TEXTURE_2D,x,d,g.width,g.height,0,d,m,g.data);else if(y.length>0&&f){for(var x=0,b=y.length;x0&&l.__version!==e.version){l.__image__webglTextureCube||(e.addEventListener("dispose",p),l.__image__webglTextureCube=t.createTexture(),S.textures++),r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var u=e&&e.isCompressedTexture,h=e.image[0]&&e.image[0].isDataTexture,f=[],d=0;d<6;d++)f[d]=u||h?h?e.image[d].image:e.image[d]:s(e.image[d],i.maxCubemapSize);var m=c(f[0]),g=o(e.format),y=o(e.type);for(v(t.TEXTURE_CUBE_MAP,e,m),d=0;d<6;d++)if(u)for(var _,x=f[d].mipmaps,b=0,w=x.length;b-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,b,g,_.width,_.height,0,_.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,b,g,_.width,_.height,0,g,y,_.data);else h?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,g,f[d].width,f[d].height,0,g,y,f[d].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,g,g,y,f[d]);e.generateMipmaps&&m&&t.generateMipmap(t.TEXTURE_CUBE_MAP),l.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",f),o.__webglTexture=t.createTexture(),S.textures++;var a=!0===e.isWebGLRenderTargetCube,s=c(e);if(a)for(i.__webglFramebuffer=[],l=0;l<6;l++)i.__webglFramebuffer[l]=t.createFramebuffer();else i.__webglFramebuffer=t.createFramebuffer();if(a){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),v(t.TEXTURE_CUBE_MAP,e.texture,s);for(var l=0;l<6;l++)_(i.__webglFramebuffer[l],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+l);e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),v(t.TEXTURE_2D,e.texture,s),_(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&w(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(i.generateMipmaps&&c(e)&&i.minFilter!==Ih&&i.minFilter!==zh){var o=e&&e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function ie(){var t={};return{get:function(e){var r=e.uuid,n=t[r];return void 0===n&&(n={},t[r]=n),n},delete:function(e){delete t[e.uuid]},clear:function(){t={}}}}function oe(t,e,r){function n(e,r,n){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a=1,k=null,U={},B=new o,V=new o,j={};return j[t.TEXTURE_2D]=n(t.TEXTURE_2D,t.TEXTURE_2D,1),j[t.TEXTURE_CUBE_MAP]=n(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:p,depth:f,stencil:d},init:function(){p.setClear(0,0,0,1),f.setClear(1),d.setClear(0),i(t.DEPTH_TEST),c(uh),l(!1),u(Eu),i(t.CULL_FACE),i(t.BLEND),s(Bu)},initAttributes:function(){for(var t=0,e=g.length;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var i,o=void 0!==r.precision?r.precision:"highp",a=n(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),d=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=l>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var r=e.get("EXT_texture_filter_anisotropic");return i=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}function se(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var n;switch(r){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(r)}return e[r]=n,n}}}function ce(){function t(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=l.value,!0!==i||null===a){var u=n+4*o,h=e.matrixWorldInverse;c.getNormalMatrix(h),(null===a||a.length=0){var u=o[c];if(void 0!==u){var h=u.normalized,p=u.itemSize,f=ue.getAttributeProperties(u),d=f.__webglBuffer,m=f.type,g=f.bytesPerElement;if(u.isInterleavedBufferAttribute){var v=u.data,y=v.stride,_=u.offset;v&&v.isInstancedInterleavedBuffer?(Jt.enableAttributeAndDivisor(l,v.meshPerAttribute,i),void 0===r.maxInstancedCount&&(r.maxInstancedCount=v.meshPerAttribute*v.count)):Jt.enableAttribute(l),$t.bindBuffer($t.ARRAY_BUFFER,d),$t.vertexAttribPointer(l,p,m,h,y*g,(n*y+_)*g)}else u.isInstancedBufferAttribute?(Jt.enableAttributeAndDivisor(l,u.meshPerAttribute,i),void 0===r.maxInstancedCount&&(r.maxInstancedCount=u.meshPerAttribute*u.count)):Jt.enableAttribute(l),$t.bindBuffer($t.ARRAY_BUFFER,d),$t.vertexAttribPointer(l,p,m,h,0,n*p*g)}else if(void 0!==s){var x=s[c];if(void 0!==x)switch(x.length){case 2:$t.vertexAttrib2fv(l,x);break;case 3:$t.vertexAttrib3fv(l,x);break;case 4:$t.vertexAttrib4fv(l,x);break;default:$t.vertexAttrib1fv(l,x)}}}}Jt.disableUnusedAttributes()}}function p(t,e){return Math.abs(e[0])-Math.abs(t[0])}function f(t,e){return t.object.renderOrder!==e.object.renderOrder?t.object.renderOrder-e.object.renderOrder:t.material.program&&e.material.program&&t.material.program!==e.material.program?t.material.program.id-e.material.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function d(t,e){return t.object.renderOrder!==e.object.renderOrder?t.object.renderOrder-e.object.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function m(t,e,r,n,i){var o,a;r.transparent?(o=et,a=++nt):(o=Q,a=++tt);var s=o[a];void 0!==s?(s.id=t.id,s.object=t,s.geometry=e,s.material=r,s.z=Wt.z,s.group=i):(s={id:t.id,object:t,geometry:e,material:r,z:Wt.z,group:i},o.push(s))}function g(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),jt.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),y(jt)}function v(t){return jt.center.set(0,0,0),jt.radius=.7071067811865476,jt.applyMatrix4(t.matrixWorld),y(jt)}function y(t){if(!Rt.intersectsSphere(t))return!1;var e=It.numPlanes;if(0===e)return!0;var r=lt.clippingPlanes,n=t.center,i=-t.radius,o=0;do{if(r[o].distanceToPoint(n)=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p=0&&t.numSupportedMorphNormals++}var f=n.__webglShader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=It.numPlanes,n.numIntersection=It.numIntersection,f.clippingPlanes=It.uniform),n.fog=e,n.lightsHash=Yt.hash,t.lights&&(f.ambientLightColor.value=Yt.ambient,f.directionalLights.value=Yt.directional,f.spotLights.value=Yt.spot,f.rectAreaLights.value=Yt.rectArea,f.pointLights.value=Yt.point,f.hemisphereLights.value=Yt.hemi,f.directionalShadowMap.value=Yt.directionalShadowMap,f.directionalShadowMatrix.value=Yt.directionalShadowMatrix,f.spotShadowMap.value=Yt.spotShadowMap,f.spotShadowMatrix.value=Yt.spotShadowMatrix,f.pointShadowMap.value=Yt.pointShadowMap,f.pointShadowMatrix.value=Yt.pointShadowMatrix);var d=n.program.getUniforms(),m=X.seqWithValue(d.seq,f);n.uniformsList=m}function w(t){t.side===Iu?Jt.disable($t.CULL_FACE):Jt.enable($t.CULL_FACE),Jt.setFlipSided(t.side===Nu),!0===t.transparent?Jt.setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha):Jt.setBlending(Uu),Jt.setDepthFunc(t.depthFunc),Jt.setDepthTest(t.depthTest),Jt.setDepthWrite(t.depthWrite),Jt.setColorWrite(t.colorWrite),Jt.setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)}function S(t,e,r,n){xt=0;var i=ee.get(r);if(Dt&&(Vt||t!==gt)){var o=t===gt&&r.id===ft;It.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,o)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsHash!==Yt.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===It.numPlanes&&i.numIntersection===It.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(b(r,e,n),r.needsUpdate=!1);var a=!1,s=!1,c=!1,l=i.program,u=l.getUniforms(),h=i.__webglShader.uniforms;if(l.id!==ut&&($t.useProgram(l.program),ut=l.id,a=!0,s=!0,c=!0),r.id!==ft&&(ft=r.id,s=!0),a||t!==gt){if(u.set($t,t,"projectionMatrix"),Qt.logarithmicDepthBuffer&&u.setValue($t,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),t!==gt&&(gt=t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var p=u.map.cameraPosition;void 0!==p&&p.setValue($t,Wt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&u.setValue($t,"viewMatrix",t.matrixWorldInverse),u.set($t,lt,"toneMappingExposure"),u.set($t,lt,"toneMappingWhitePoint")}if(r.skinning){u.setOptional($t,n,"bindMatrix"),u.setOptional($t,n,"bindMatrixInverse");var f=n.skeleton;f&&(Qt.floatVertexTextures&&f.useVertexTexture?(u.set($t,f,"boneTexture"),u.set($t,f,"boneTextureWidth"),u.set($t,f,"boneTextureHeight")):u.setOptional($t,f,"boneMatrices"))}return(s||r.forceUniformsUpdate)&&(r.lights&&D(h,c),e&&r.fog&&T(h,e),(r.isMeshBasicMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshNormalMaterial||r.isMeshDepthMaterial)&&M(h,r),r.isLineBasicMaterial?A(h,r):r.isLineDashedMaterial?(A(h,r),E(h,r)):r.isPointsMaterial?C(h,r):r.isMeshLambertMaterial?P(h,r):r.isMeshToonMaterial?R(h,r):r.isMeshPhongMaterial?L(h,r):r.isMeshPhysicalMaterial?I(h,r):r.isMeshStandardMaterial?N(h,r):r.isMeshDepthMaterial?r.displacementMap&&(h.displacementMap.value=r.displacementMap,h.displacementScale.value=r.displacementScale,h.displacementBias.value=r.displacementBias):r.isMeshNormalMaterial&&O(h,r),void 0!==h.ltcMat&&(h.ltcMat.value=THREE.UniformsLib.LTC_MAT_TEXTURE),void 0!==h.ltcMag&&(h.ltcMag.value=THREE.UniformsLib.LTC_MAG_TEXTURE),X.upload($t,i.uniformsList,h,lt)),u.set($t,n,"modelViewMatrix"),u.set($t,n,"normalMatrix"),u.setValue($t,"modelMatrix",n.matrixWorld),l}function M(t,e){t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var r;if(e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}function A(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function E(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function C(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*At,t.scale.value=.5*Mt,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}function T(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function P(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function L(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function R(t,e){L(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function N(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function I(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,N(t,e)}function O(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function D(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}function z(t){for(var e=0,r=0,n=t.length;r8&&(f.length=8);for(var g=n.morphAttributes,d=0,m=f.length;d0&&M.renderInstances(n,L,N):M.render(L,N)}},this.render=function(t,e,r,n){if(void 0===e||!0===e.isCamera){mt="",ft=-1,gt=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld),Gt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),Rt.setFromMatrix(Gt),$.length=0,tt=-1,nt=-1,st.length=0,ct.length=0,Vt=this.localClippingEnabled,Dt=It.init(this.clippingPlanes,Vt,e),_(t,e),Q.length=tt+1,et.length=nt+1,!0===lt.sortObjects&&(Q.sort(f),et.sort(d)),Dt&&It.beginShadows(),z($),_e.render(t,e),F($,e),Dt&&It.endShadows(),qt.calls=0,qt.vertices=0,qt.faces=0,qt.points=0,void 0===r&&(r=null),this.setRenderTarget(r);var i=t.background;if(null===i?Jt.buffers.color.setClear(bt.r,bt.g,bt.b,wt,H):i&&i.isColor&&(Jt.buffers.color.setClear(i.r,i.g,i.b,1,H),n=!0),(this.autoClear||n)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),i&&i.isCubeTexture?(void 0===me&&(me=new zt,ge=new Lt(new Nt(5,5,5),new J({uniforms:Up.cube.uniforms,vertexShader:Up.cube.vertexShader,fragmentShader:Up.cube.fragmentShader,side:Nu,depthTest:!1,depthWrite:!1,fog:!1}))),me.projectionMatrix.copy(e.projectionMatrix),me.matrixWorld.extractRotation(e.matrixWorld),me.matrixWorldInverse.getInverse(me.matrixWorld),ge.material.uniforms.tCube.value=i,ge.modelViewMatrix.multiplyMatrices(me.matrixWorldInverse,ge.matrixWorld),ue.update(ge),lt.renderBufferDirect(me,null,ge.geometry,ge.material,ge,null)):i&&i.isTexture&&(void 0===fe&&(fe=new Ft(-1,1,1,-1,0,1),de=new Lt(new Ot(2,2),new dt({depthTest:!1,depthWrite:!1,fog:!1}))),de.material.map=i,ue.update(de),lt.renderBufferDirect(fe,null,de.geometry,de.material,de,null)),t.overrideMaterial){var o=t.overrideMaterial;x(Q,t,e,o),x(et,t,e,o)}else Jt.setBlending(Uu),x(Q,t,e),x(et,t,e);xe.render(t,e),be.render(t,e,_t),r&&le.updateRenderTargetMipmap(r),Jt.setDepthTest(!0),Jt.setDepthWrite(!0),Jt.setColorWrite(!0)}},this.setFaceCulling=function(t,e){Jt.setCullFace(t),Jt.setFlipSided(e===Tu)},this.allocTextureUnit=function(){var t=xt;return Qt.maxTextures,xt+=1,t},this.setTexture2D=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTarget&&(t||(t=!0),e=e.texture),le.setTexture2D(e,r)}}(),this.setTexture=function(){var t=!1;return function(e,r){t||(t=!0),le.setTexture2D(e,r)}}(),this.setTextureCube=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTargetCube&&(t||(t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?le.setTextureCube(e,r):le.setTextureCubeDynamic(e,r)}}(),this.getCurrentRenderTarget=function(){return ht},this.setRenderTarget=function(t){ht=t,t&&void 0===ee.get(t).__webglFramebuffer&&le.setupRenderTarget(t);var e,r=t&&t.isWebGLRenderTargetCube;if(t){var n=ee.get(t);e=r?n.__webglFramebuffer[t.activeCubeFace]:n.__webglFramebuffer,vt.copy(t.scissor),yt=t.scissorTest,_t.copy(t.viewport)}else e=null,vt.copy(Et).multiplyScalar(At),yt=Ct,_t.copy(Tt).multiplyScalar(At);if(pt!==e&&($t.bindFramebuffer($t.FRAMEBUFFER,e),pt=e),Jt.scissor(vt),Jt.setScissorTest(yt),Jt.viewport(_t),r){var i=ee.get(t.texture);$t.framebufferTexture2D($t.FRAMEBUFFER,$t.COLOR_ATTACHMENT0,$t.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,i.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,r,n,i,o){if(!1!==(t&&t.isWebGLRenderTarget)){var a=ee.get(t).__webglFramebuffer;if(a){var s=!1;a!==pt&&($t.bindFramebuffer($t.FRAMEBUFFER,a),s=!0);try{var c=t.texture,l=c.format,u=c.type;if(l!==Jh&&k(l)!==$t.getParameter($t.IMPLEMENTATION_COLOR_READ_FORMAT))return;if(!(u===Uh||k(u)===$t.getParameter($t.IMPLEMENTATION_COLOR_READ_TYPE)||u===Hh&&(Kt.get("OES_texture_float")||Kt.get("WEBGL_color_buffer_float"))||u===Xh&&Kt.get("EXT_color_buffer_half_float")))return;$t.checkFramebufferStatus($t.FRAMEBUFFER)===$t.FRAMEBUFFER_COMPLETE&&e>=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&$t.readPixels(e,r,n,i,k(l),k(u),o)}finally{s&&$t.bindFramebuffer($t.FRAMEBUFFER,pt)}}}}}function ue(t,e){this.name="",this.color=new Y(t),this.density=void 0!==e?e:25e-5}function he(t,e,r){this.name="",this.color=new Y(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function pe(){ut.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function fe(t,e,r,n,i){ut.call(this),this.lensFlares=[],this.positionScreen=new l,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function de(t){Q.call(this),this.type="SpriteMaterial",this.color=new Y(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function me(t){ut.call(this),this.type="Sprite",this.material=void 0!==t?t:new de}function ge(){ut.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ve(t,e,r){if(this.useVertexTexture=void 0===r||r,this.identityMatrix=new u,t=t||[],this.bones=t.slice(0),this.useVertexTexture){var n=Math.sqrt(4*this.bones.length);n=Tp.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 q(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,Jh,Hh)}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 i=0,o=this.bones.length;i=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0)}i.call(this,t,e,r,n,o,a,s,c,l),this.generateMipmaps=!1;var h=this;u()}function Ce(t,e,r,n,o,a,s,c,l,u,h,p){i.call(this,null,a,s,c,l,u,n,o,h,p),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Te(t,e,r,n,o,a,s,c,l){i.call(this,t,e,r,n,o,a,s,c,l),this.needsUpdate=!0}function Pe(t,e,r,n,o,a,s,c,l,u){if((u=void 0!==u?u:np)!==np&&u!==ip)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===np&&(r=jh),void 0===r&&u===ip&&(r=Zh),i.call(this,null,n,o,a,s,c,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:Ih,this.minFilter=void 0!==c?c:Ih,this.flipY=!1,this.generateMipmaps=!1}function Le(t){function e(t,e){return t-e}Pt.call(this),this.type="WireframeGeometry";var r,n,i,o,a,s,c,u,h=[],p=[0,0],f={},d=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(r=0,i=m.length;r.9&&o<.1&&(e<.2&&(m[t+0]+=1),r<.2&&(m[t+2]+=1),n<.2&&(m[t+4]+=1))}}function s(t){d.push(t.x,t.y,t.z)}function c(e,r){var n=3*e;r.x=t[n+0],r.y=t[n+1],r.z=t[n+2]}function u(){for(var t=new l,e=new l,r=new l,i=new l,o=new n,a=new n,s=new n,c=0,u=0;c0)&&m.push(w,S,A),(c!==r-1||u0&&u(!0),e>0&&u(!1)),this.setIndex(p),this.addAttribute("position",new St(f,3)),this.addAttribute("normal",new St(d,3)),this.addAttribute("uv",new St(m,2))}function cr(t,e,r,n,i,o,a){ar.call(this,0,t,e,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function lr(t,e,r,n,i,o,a){sr.call(this,0,t,e,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function ur(t,e,r,n){Tt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new hr(t,e,r,n))}function hr(t,e,r,i){Pt.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var o,a,s=[],c=[],u=[],h=[],p=new l,f=new n;for(c.push(0,0,0),u.push(0,0,1),h.push(.5,.5),a=0,o=3;a<=e;a++,o+=3){var d=r+a/e*i;p.x=t*Math.cos(d),p.y=t*Math.sin(d),c.push(p.x,p.y,p.z),u.push(0,0,1),f.x=(c[o]/t+1)/2,f.y=(c[o+1]/t+1)/2,h.push(f.x,f.y)}for(o=1;o<=e;o++)s.push(o,o+1,0);this.setIndex(s),this.addAttribute("position",new St(c,3)),this.addAttribute("normal",new St(u,3)),this.addAttribute("uv",new St(h,2))}function pr(){J.call(this,{uniforms:Dp.merge([kp.lights,{opacity:{value:1}}]),vertexShader:zp.shadow_vert,fragmentShader:zp.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}}})}function fr(t){J.call(this,t),this.type="RawShaderMaterial"}function dr(t){this.uuid=Tp.generateUUID(),this.type="MultiMaterial",this.materials=Array.isArray(t)?t:[],this.visible=!0}function mr(t){Q.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Y(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function gr(t){mr.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function vr(t){Q.call(this),this.type="MeshPhongMaterial",this.color=new Y(16777215),this.specular=new Y(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=mh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function yr(t){vr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function _r(t){Q.call(this,t),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function xr(t){Q.call(this),this.type="MeshLambertMaterial",this.color=new Y(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=mh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function br(t){Q.call(this),this.type="LineDashedMaterial",this.color=new Y(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(t)}function wr(t,e,r){var n=this,i=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){a++,!1===i&&void 0!==n.onStart&&n.onStart(t,o,a),i=!0},this.itemEnd=function(t){o++,void 0!==n.onProgress&&n.onProgress(t,o,a),o===a&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)}}function Sr(t){this.manager=void 0!==t?t:qp}function Mr(t){this.manager=void 0!==t?t:qp,this._parser=null}function Ar(t){this.manager=void 0!==t?t:qp,this._parser=null}function Er(t){this.manager=void 0!==t?t:qp}function Cr(t){this.manager=void 0!==t?t:qp}function Tr(t){this.manager=void 0!==t?t:qp}function Pr(t,e){ut.call(this),this.type="Light",this.color=new Y(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Lr(t,e,r){Pr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ut.DefaultUp),this.updateMatrix(),this.groundColor=new Y(e)}function Rr(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new n(512,512),this.map=null,this.matrix=new u}function Nr(){Rr.call(this,new zt(50,1,.5,500))}function Ir(t,e,r,n,i,o){Pr.call(this,t,e),this.type="SpotLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==o?o:1,this.shadow=new Nr}function Or(t,e,r,n){Pr.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==n?n:1,this.shadow=new Rr(new zt(90,1,.5,500))}function Dr(){Rr.call(this,new Ft(-5,5,5,-5,.5,500))}function zr(t,e){Pr.call(this,t,e),this.type="DirectionalLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,this.shadow=new Dr}function Fr(t,e){Pr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function kr(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function Ur(t,e,r,n){kr.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Br(t,e,r,n){kr.call(this,t,e,r,n)}function Vr(t,e,r,n){kr.call(this,t,e,r,n)}function jr(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=$p.convertArray(e,this.TimeBufferType),this.values=$p.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function Gr(t,e,r,n){jr.call(this,t,e,r,n)}function Wr(t,e,r,n){kr.call(this,t,e,r,n)}function Hr(t,e,r,n){jr.call(this,t,e,r,n)}function Xr(t,e,r,n){jr.call(this,t,e,r,n)}function Yr(t,e,r,n){jr.call(this,t,e,r,n)}function qr(t,e,r){jr.call(this,t,e,r)}function $r(t,e,r,n){jr.call(this,t,e,r,n)}function Zr(t,e,r,n){jr.apply(this,arguments)}function Kr(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=Tp.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Qr(t){this.manager=void 0!==t?t:qp,this.textures={}}function Jr(t){this.manager=void 0!==t?t:qp}function tn(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function en(t){"boolean"==typeof t&&(t=void 0),this.manager=void 0!==t?t:qp,this.withCredentials=!1}function rn(t){this.manager=void 0!==t?t:qp,this.texturePath=""}function nn(t,e,r,n,i){var o=.5*(n-e),a=.5*(i-r),s=t*t;return(2*r-2*n+o+a)*(t*s)+(-3*r+3*n-2*o-a)*s+o*t+r}function on(t,e){var r=1-t;return r*r*e}function an(t,e){return 2*(1-t)*t*e}function sn(t,e){return t*t*e}function cn(t,e,r,n){return on(t,e)+an(t,r)+sn(t,n)}function ln(t,e){var r=1-t;return r*r*r*e}function un(t,e){var r=1-t;return 3*r*r*t*e}function hn(t,e){return 3*(1-t)*t*t*e}function pn(t,e){return t*t*t*e}function fn(t,e,r,n,i){return ln(t,e)+un(t,r)+hn(t,n)+pn(t,i)}function dn(){}function mn(t,e){this.v1=t,this.v2=e}function gn(){this.curves=[],this.autoClose=!1}function vn(t,e,r,n,i,o,a,s){this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function yn(t){this.points=void 0===t?[]:t}function _n(t,e,r,n){this.v0=t,this.v1=e,this.v2=r,this.v3=n}function xn(t,e,r){this.v0=t,this.v1=e,this.v2=r}function bn(t){gn.call(this),this.currentPoint=new n,t&&this.fromPoints(t)}function wn(){bn.apply(this,arguments),this.holes=[]}function Sn(){this.subPaths=[],this.currentPath=null}function Mn(t){this.data=t}function An(t){this.manager=void 0!==t?t:qp}function En(t){this.manager=void 0!==t?t:qp}function Cn(t,e,r,n){Pr.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==n?n:10}function Tn(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Pn(t,e,r){ut.call(this),this.type="CubeCamera";var n=new zt(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new l(1,0,0)),this.add(n);var i=new zt(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new l(-1,0,0)),this.add(i);var o=new zt(90,1,t,e);o.up.set(0,0,1),o.lookAt(new l(0,1,0)),this.add(o);var a=new zt(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new l(0,-1,0)),this.add(a);var c=new zt(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new l(0,0,1)),this.add(c);var u=new zt(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new l(0,0,-1)),this.add(u);var h={format:Qh,magFilter:zh,minFilter:zh};this.renderTarget=new s(r,r,h),this.updateCubeMap=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,s=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,n,r),r.activeCubeFace=1,t.render(e,i,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,c,r),r.texture.generateMipmaps=s,r.activeCubeFace=5,t.render(e,u,r),t.setRenderTarget(null)}}function Ln(){ut.call(this),this.type="AudioListener",this.context=Jp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Rn(t){ut.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Nn(t){Rn.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function In(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function On(t,e,r){this.binding=t,this.valueSize=r;var n,i=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":i=Array,n=this._select;break;default:n=this._lerp}this.buffer=new i(4*r),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function Dn(t,e,r){this.path=e,this.parsedPath=r||Dn.parseTrackName(e),this.node=Dn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function zn(t){this.uuid=Tp.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var r=0,n=arguments.length;r!==n;++r)e[arguments[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function Fn(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var n=e.tracks,i=n.length,o=new Array(i),a={endingStart:mp,endingEnd:mp},s=0;s!==i;++s){var c=n[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=dp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function kn(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Un(t){"string"==typeof t&&(t=arguments[1]),this.value=t}function Bn(){Pt.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Vn(t,e,r,n){this.uuid=Tp.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function jn(t,e){this.uuid=Tp.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Gn(t,e,r){jn.call(this,t,e),this.meshPerAttribute=r||1}function Wn(t,e,r){mt.call(this,t,e),this.meshPerAttribute=r||1}function Hn(t,e,r,n){this.ray=new st(t,e),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return this.Points}}})}function Xn(t,e){return t.distance-e.distance}function Yn(t,e,r,n){if(!1!==t.visible&&(t.raycast(e,r),!0===n))for(var i=t.children,o=0,a=i.length;o0&&(i=Object.create(i))}return i}function Pi(t){var e=!1;this.enable=function(t){e=t};for(var r=0,n=Object.keys(t),i=0,o=n.length;i=3&&"base64"===e[r-2]?new Blob([Ni(e[r-1])]):null}function Di(t,e,r){var n=document.createElement(t);return n.id=e,n.style.cssText=r,n}function zi(){this.domElement=Di("div","stats","padding:8px"),this._text=Di("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=vf(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}function Fi(){Si.call(this),this._cancellationRequested=!1}function ki(){this.old=null,this.now={},this._changed={},this.reset()}function Ui(t){return!(!t||"0"===t||wu.isString(t)&&"false"===t.toLowerCase())}function Bi(t){return gf.encodeQueryComponent(t,Nf)}function Vi(t){return gf.encodeQueryComponent(t,If)}function ji(t){var e=t.reps;if(!e){var r=_f.now.presets,n=t.preset||_f.now.preset;(e=r[n])||(ff.warn('Unknown preset "'+n+'"'),e=r[n=Object.keys(r)[0]]),t.preset=n,t.reps=gf.deriveDeep(e,!0)}}function Gi(t,e,r){ji(t);var n=t.reps[Af];n.hasOwnProperty(e)&&++Af>=t.reps.length&&(t.reps[Af]=gf.deriveDeep(n,!0)),void 0!==r&&(t.reps[Af][e]=r)}function Wi(t,e,r){void 0===t._objects&&(t._objects=[]);var n={type:r[0],params:e};void 0!==r[1]&&(n.opts=r[1]),t._objects[t._objects.length]=n}function Hi(t,e){var r=t.indexOf(",");return r>=0?(e.push(t.substr(r+1).split(",")),t.substr(0,r)):t}function Xi(t,e,r){if(t){var n=t.indexOf(Tf),i=Hi(t.substr(0,n>=0?n:void 0),r);if(n>=0){var o=t.substr(n+1).split(Lf);if(t=i,e){var a=e[t],s=gf.deriveDeep(a,!0);o.forEach(function(e){var r=e.split(Pf,2),n=decodeURIComponent(r[0]),i=decodeURIComponent(r[1]),o=Ef[xf(wu.get(a,n))];o?wu.set(s,n,o(i)):ff.warn('Unknown argument "'+n+'" for option "'+t+'"')}),Object.keys(s).length>0&&(t=[t,s])}}else t=i}return t}function Yi(t){Af=0;for(var e={},r=0,n=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Tf+qi(t.opts)),e}}function Ki(t){var e=[],r=0;return gf.forInRecursive(t,function(t,n){e[r++]=n+"="+gf.enquoteString(t)}),e.join(" ")}function Qi(t){return wu.isArray(t)?t[0]+(t.length<2?"":" "+Ki(t[1])):t}function Ji(t){if(t&&t.type){var e=t.type;return wu.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(gf.enquoteString).join(" ")),t.opts&&(e+=" "+Ki(t.opts)),e}}function to(t,e){function r(t,e){null!==e&&void 0!==e&&(n[i++]=t+e)}var n=[],i=0;return wu.isEmpty(t)?null:(r("",e),r("s=",gf.enquoteString(t.selector)),r("m=",Qi(t.mode)),r("c=",Qi(t.colorer)),r("mt=",Qi(t.material)),n.join(" "))}function eo(t,e){this._node=e||null,this._name=t||null,null===this._node&&null===this._name&&(this._name="Unknown")}function ro(t,e,r,n,i,o,a){this.number=t,this.name=e,this.fullName=r,this.weight=n,this.radius=i,this.radiusBonding=o,this.hydrogenValency=a}function no(t,e,r,n,i,o,a,s,c,l,u){this._index=-1,this._residue=t,this._name=e instanceof eo?e:new eo(e),this.element=r,this._position=n,this._role=i,this._mask=1,this._index=-1,this._het=o,this._serial=a,this._location=(s||" ").charCodeAt(0),this._occupancy=c||1,this._temperature=l,this._charge=u,this._hydrogenCount=-1,this._radicalCount=0,this._valence=-1,this._bonds=[],this.flags=0,"H"===r.name?this.flags|=no.Flags.HYDROGEN:"C"===r.name&&(this.flags|=no.Flags.CARBON)}function io(t){return t<2?1:t}function oo(t){return t._position}function ao(t,e,r,n,i){if(this._left=t,this._right=e,this._fixed=i,this._index=-1,t>e)throw new Error("In a bond atom indices must be in increasing order");this._order=r,this._type=n}function so(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function co(t,e){for(var r=0,n=e.length;r0)return t;var i=e*r,o=Np[i];if(void 0===o&&(o=new Float32Array(i),Np[i]=o),0!==e){n.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=r,t[a].toArray(o,s)}return o}function d(t,e){var r=Ip[e];void 0===r&&(r=new Int32Array(e),Ip[e]=r);for(var n=0;n!==e;++n)r[n]=t.allocTextureUnit();return r}function m(t,e){t.uniform1f(this.addr,e)}function g(t,e){t.uniform1i(this.addr,e)}function v(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function y(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 x(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function b(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function w(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function S(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function M(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTexture2D(e||Lp,n)}function A(t,e,r){var n=r.allocTextureUnit();t.uniform1i(this.addr,n),r.setTextureCube(e||Rp,n)}function E(t,e){t.uniform2iv(this.addr,e)}function C(t,e){t.uniform3iv(this.addr,e)}function T(t,e){t.uniform4iv(this.addr,e)}function P(t){switch(t){case 5126:return m;case 35664:return v;case 35665:return y;case 35666:return x;case 35674:return b;case 35675:return w;case 35676:return S;case 35678:return M;case 35680:return A;case 5124:case 35670:return g;case 35667:case 35671:return E;case 35668:case 35672:return C;case 35669:case 35673:return T}}function L(t,e){t.uniform1fv(this.addr,e)}function R(t,e){t.uniform1iv(this.addr,e)}function N(t,e){t.uniform2fv(this.addr,f(e,this.size,2))}function I(t,e){t.uniform3fv(this.addr,f(e,this.size,3))}function O(t,e){t.uniform4fv(this.addr,f(e,this.size,4))}function D(t,e){t.uniformMatrix2fv(this.addr,!1,f(e,this.size,4))}function z(t,e){t.uniformMatrix3fv(this.addr,!1,f(e,this.size,9))}function k(t,e){t.uniformMatrix4fv(this.addr,!1,f(e,this.size,16))}function F(t,e,r){var n=e.length,i=d(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTexture2D(e[o]||Lp,i[o])}function U(t,e,r){var n=e.length,i=d(r,n);t.uniform1iv(this.addr,i);for(var o=0;o!==n;++o)r.setTextureCube(e[o]||Rp,i[o])}function B(t){switch(t){case 5126:return L;case 35664:return N;case 35665:return I;case 35666:return O;case 35674:return D;case 35675:return z;case 35676:return k;case 35678:return F;case 35680:return U;case 5124:case 35670:return R;case 35667:case 35671:return E;case 35668:case 35672:return C;case 35669:case 35673:return T}}function V(t,e,r){this.id=t,this.addr=r,this.setValue=P(e.type)}function j(t,e,r){this.id=t,this.addr=r,this.size=e.size,this.setValue=B(e.type)}function G(t){this.id=t,p.call(this)}function W(t,e){t.seq.push(e),t.map[e.id]=e}function H(t,e,r){var n=t.name,i=n.length;for(Op.lastIndex=0;;){var o=Op.exec(n),a=Op.lastIndex,s=o[1],c="]"===o[2],l=o[3];if(c&&(s|=0),void 0===l||"["===l&&a+2===i){W(r,void 0===l?new V(s,t,e):new j(s,t,e));break}var u=r.map[s];void 0===u&&W(r,u=new G(s)),r=u}}function X(t,e,r){p.call(this),this.renderer=r;for(var n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i.001&&R.scale>.001&&(S.x=R.x,S.y=R.y,S.z=R.z,b=R.size*R.scale/g.w,w.x=b*y,w.y=b,d.uniform3f(h.screenPosition,S.x,S.y,S.z),d.uniform2f(h.scale,w.x,w.y),d.uniform1f(h.rotation,R.rotation),d.uniform1f(h.opacity,R.opacity),d.uniform3f(h.color,R.color.r,R.color.g,R.color.b),m.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),t.setTexture2D(R.texture,1),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0))}}}m.enable(d.CULL_FACE),m.enable(d.DEPTH_TEST),m.setDepthWrite(!0),t.resetGLState()}}}function K(t,e){function r(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),e=new Uint16Array([0,1,2,0,2,3]);a=d.createBuffer(),s=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,a),d.bufferData(d.ARRAY_BUFFER,t,d.STATIC_DRAW),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.bufferData(d.ELEMENT_ARRAY_BUFFER,e,d.STATIC_DRAW),u=n(),h={position:d.getAttribLocation(u,"position"),uv:d.getAttribLocation(u,"uv")},p={uvOffset:d.getUniformLocation(u,"uvOffset"),uvScale:d.getUniformLocation(u,"uvScale"),rotation:d.getUniformLocation(u,"rotation"),scale:d.getUniformLocation(u,"scale"),color:d.getUniformLocation(u,"color"),map:d.getUniformLocation(u,"map"),opacity:d.getUniformLocation(u,"opacity"),modelViewMatrix:d.getUniformLocation(u,"modelViewMatrix"),projectionMatrix:d.getUniformLocation(u,"projectionMatrix"),fogType:d.getUniformLocation(u,"fogType"),fogDensity:d.getUniformLocation(u,"fogDensity"),fogNear:d.getUniformLocation(u,"fogNear"),fogFar:d.getUniformLocation(u,"fogFar"),fogColor:d.getUniformLocation(u,"fogColor"),alphaTest:d.getUniformLocation(u,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var o=r.getContext("2d");o.fillStyle="white",o.fillRect(0,0,8,8),(f=new i(r)).needsUpdate=!0}function n(){var e=d.createProgram(),r=d.createShader(d.VERTEX_SHADER),n=d.createShader(d.FRAGMENT_SHADER);return d.shaderSource(r,["precision "+t.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),d.shaderSource(n,["precision "+t.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),d.compileShader(r),d.compileShader(n),d.attachShader(e,r),d.attachShader(e,n),d.linkProgram(e),e}function o(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var a,s,u,h,p,f,d=t.context,m=t.state,g=new l,v=new c,y=new l;this.render=function(n,i){if(0!==e.length){void 0===u&&r(),d.useProgram(u),m.initAttributes(),m.enableAttribute(h.position),m.enableAttribute(h.uv),m.disableUnusedAttributes(),m.disable(d.CULL_FACE),m.enable(d.BLEND),d.bindBuffer(d.ARRAY_BUFFER,a),d.vertexAttribPointer(h.position,2,d.FLOAT,!1,16,0),d.vertexAttribPointer(h.uv,2,d.FLOAT,!1,16,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.uniformMatrix4fv(p.projectionMatrix,!1,i.projectionMatrix.elements),m.activeTexture(d.TEXTURE0),d.uniform1i(p.map,0);var c=0,l=0,_=n.fog;_?(d.uniform3f(p.fogColor,_.color.r,_.color.g,_.color.b),_.isFog?(d.uniform1f(p.fogNear,_.near),d.uniform1f(p.fogFar,_.far),d.uniform1i(p.fogType,1),c=1,l=1):_.isFogExp2&&(d.uniform1f(p.fogDensity,_.density),d.uniform1i(p.fogType,2),c=2,l=2)):(d.uniform1i(p.fogType,0),c=0,l=0);for(var x=0,b=e.length;x0:o&&o.isGeometry&&(l=o.morphTargets&&o.morphTargets.length>0));var u=e.isSkinnedMesh&&r.skinning,h=0;l&&(h|=b),u&&(h|=w),a=s[h]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var p=a.uuid,f=r.uuid,d=E[p];void 0===d&&(d={},E[p]=d);var m=d[f];void 0===m&&(m=a.clone(),d[f]=m),a=m}a.visible=r.visible,a.wireframe=r.wireframe;var g=r.side;return F.renderSingleSided&&g==Iu&&(g=Ru),F.renderReverseSided&&(g===Ru?g=Nu:g===Nu&&(g=Ru)),a.side=g,a.clipShadows=r.clipShadows,a.clippingPlanes=r.clippingPlanes,a.wireframeLinewidth=r.wireframeLinewidth,a.linewidth=r.linewidth,n&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(i),a}function c(t,e,r){if(!1!==t.visible){0!=(t.layers.mask&e.layers.mask)&&(t.isMesh||t.isLine||t.isPoints)&&(!t.castShadow||!1!==t.frustumCulled&&!0!==f.intersectsObject(t)||!0===t.material.visible&&(t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),x.push(t)));for(var n=t.children,i=0,o=n.length;ir&&(r=t[e]);return r}function Ct(){return jp++}function Tt(){Object.defineProperty(this,"id",{value:Ct()}),this.uuid=Tp.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Pt(){Object.defineProperty(this,"id",{value:Ct()}),this.uuid=Tp.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Lt(t,e){ut.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Pt,this.material=void 0!==e?e:new dt({color:16777215*Math.random()}),this.drawMode=gp,this.updateMorphTargets()}function Rt(t,e,r,n,i,o){Tt.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:n,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Nt(t,e,r,n,i,o)),this.mergeVertices()}function Nt(t,e,r,n,i,o){function a(t,e,r,n,i,o,a,m,g,v,y){var _,x,b=o/g,w=a/v,S=o/2,M=a/2,A=m/2,E=g+1,C=v+1,T=0,P=0,L=new l;for(x=0;x0?1:-1,h.push(L.x,L.y,L.z),p.push(_/g),p.push(1-x/v),T+=1}}for(x=0;x/g;return t.replace(e,function(t,e){var r=zp[e];if(void 0===r)throw new Error("Can not resolve #include <"+e+">");return Kt(r)})}function Qt(t){var e=/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return t.replace(e,function(t,e,r,n){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,g=Xt(o,n,t.extensions),v=Yt(a),y=i.createProgram();r.isRawShaderMaterial?(f=[v,"\n"].filter($t).join("\n"),d=[g,v,"\n"].filter($t).join("\n")):(f=["precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.__webglShader.name,v,n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",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 "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter($t).join("\n"),d=[g,"precision "+n.precision+" float;","precision "+n.precision+" int;","#define SHADER_NAME "+r.__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 "+h:"",n.envMap?"#define "+p:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.vertexColors?"#define USE_COLOR":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+n.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(n.numClippingPlanes-n.numClipIntersection),n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",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!==yh?"#define TONE_MAPPING":"",n.toneMapping!==yh?zp.tonemapping_pars_fragment:"",n.toneMapping!==yh?Ht("toneMapping",n.toneMapping):"",n.outputEncoding||n.mapEncoding||n.envMapEncoding||n.emissiveMapEncoding?zp.encodings_pars_fragment:"",n.mapEncoding?Gt("mapTexelToLinear",n.mapEncoding):"",n.envMapEncoding?Gt("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMapEncoding?Gt("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.outputEncoding?Wt("linearToOutputTexel",n.outputEncoding):"",n.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter($t).join("\n")),s=Zt(s=Kt(s,n),n),c=Zt(c=Kt(c,n),n),r.isShaderMaterial||(s=Qt(s),c=Qt(c));var _=f+s,x=d+c,b=Vt(i,i.VERTEX_SHADER,_),w=Vt(i,i.FRAGMENT_SHADER,x);i.attachShader(y,b),i.attachShader(y,w),void 0!==r.index0AttributeName?i.bindAttribLocation(y,0,r.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);var S=i.getProgramInfoLog(y),M=i.getShaderInfoLog(b),A=i.getShaderInfoLog(w),E=!0,C=!0;!1===i.getProgramParameter(y,i.LINK_STATUS)?E=!1:""!==S||""!==M&&""!==A||(C=!1),C&&(this.diagnostics={runnable:E,material:r,programLog:S,vertexShader:{log:M,prefix:f},fragmentShader:{log:A,prefix:d}}),i.deleteShader(b),i.deleteShader(w);var T;this.getUniforms=function(){return void 0===T&&(T=new X(i,y,t)),T};var P;return this.getAttributes=function(){return void 0===P&&(P=qt(i,y)),P},this.destroy=function(){i.deleteProgram(y),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return this.getUniforms()}},attributes:{get:function(){return this.getAttributes()}}}),this.id=Gp++,this.code=e,this.usedTimes=1,this.program=y,this.vertexShader=b,this.fragmentShader=w,this}function te(t,e){function r(t){if(e.floatVertexTextures&&t&&t.skeleton&&t.skeleton.useVertexTexture)return 1024;var r=e.maxVertexUniforms,n=Math.floor((r-20)/4);return void 0!==t&&t&&t.isSkinnedMesh&&(n=Math.min(t.skeleton.bones.length,n),t.skeleton.bones.length),n}function n(t,e){var r;return t?t.isTexture?r=t.encoding:t.isWebGLRenderTarget&&(r=t.texture.encoding):r=_p,r===_p&&e&&(r=bp),r}var i=[],o={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},a=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking"];this.getParameters=function(i,a,s,c,l,u){var h=o[i.type],p=r(u),f=t.getPrecision();null!==i.precision&&(f=e.getMaxPrecision(i.precision),i.precision);var d=t.getCurrentRenderTarget();return{shaderID:h,precision:f,supportsVertexTextures:e.vertexTextures,outputEncoding:n(d?d.texture:null,t.gammaOutput),map:!!i.map,mapEncoding:n(i.map,t.gammaInput),envMap:!!i.envMap,envMapMode:i.envMap&&i.envMap.mapping,envMapEncoding:n(i.envMap,t.gammaInput),envMapCubeUV:!!i.envMap&&(i.envMap.mapping===Th||i.envMap.mapping===Ph),lightMap:!!i.lightMap,aoMap:!!i.aoMap,emissiveMap:!!i.emissiveMap,emissiveMapEncoding:n(i.emissiveMap,t.gammaInput),bumpMap:!!i.bumpMap,normalMap:!!i.normalMap,displacementMap:!!i.displacementMap,roughnessMap:!!i.roughnessMap,metalnessMap:!!i.metalnessMap,specularMap:!!i.specularMap,alphaMap:!!i.alphaMap,gradientMap:!!i.gradientMap,combine:i.combine,vertexColors:i.vertexColors,fog:!!s,useFog:i.fog,fogExp:s&&s.isFogExp2,flatShading:i.shading===Ou,sizeAttenuation:i.sizeAttenuation,logarithmicDepthBuffer:e.logarithmicDepthBuffer,skinning:i.skinning,maxBones:p,useVertexTexture:e.floatVertexTextures&&u&&u.skeleton&&u.skeleton.useVertexTexture,morphTargets:i.morphTargets,morphNormals:i.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:c,numClipIntersection:l,shadowMapEnabled:t.shadowMap.enabled&&u.receiveShadow&&a.shadows.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===Iu,flipSided:i.side===Nu,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(t,e){var r=[];if(e.shaderID?r.push(e.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(var i=0;i65535?wt:xt)(o,1);return n(d,t.ELEMENT_ARRAY_BUFFER),i.wireframe=d,d},update:function(e){var r=a.get(e);e.geometry.isGeometry&&r.updateFromObject(e);var i=r.index,o=r.attributes;null!==i&&n(i,t.ELEMENT_ARRAY_BUFFER);for(var s in o)n(o[s],t.ARRAY_BUFFER);var c=r.morphAttributes;for(var s in c)for(var l=c[s],u=0,h=l.length;ue||t.height>e){var r=e/Math.max(t.width,t.height),n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.width=Math.floor(t.width*r),n.height=Math.floor(t.height*r),n.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,n.width,n.height),n}return t}function c(t){return Tp.isPowerOfTwo(t.width)&&Tp.isPowerOfTwo(t.height)}function l(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Tp.nearestPowerOfTwo(t.width),e.height=Tp.nearestPowerOfTwo(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),e}return t}function u(t){return t.wrapS!==Rh||t.wrapT!==Rh||t.minFilter!==Ih&&t.minFilter!==zh}function h(e){return e===Ih||e===Oh||e===Dh?t.NEAREST:t.LINEAR}function p(t){var e=t.target;e.removeEventListener("dispose",p),d(e),S.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),m(e),S.textures--}function d(e){var r=n.get(e);if(e.image&&r.__image__webglTextureCube)t.deleteTexture(r.__image__webglTextureCube);else{if(void 0===r.__webglInit)return;t.deleteTexture(r.__webglTexture)}n.delete(e)}function m(e){var r=n.get(e),i=n.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(r.__webglFramebuffer[o]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[o]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);n.delete(e.texture),n.delete(e)}}function g(e,i){var o=n.get(e);if(e.version>0&&o.__version!==e.version){var a=e.image;if(void 0===a);else if(!1!==a.complete)return void y(o,e,i)}r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_2D,o.__webglTexture)}function v(r,a,s){var c;if(s?(t.texParameteri(r,t.TEXTURE_WRAP_S,o(a.wrapS)),t.texParameteri(r,t.TEXTURE_WRAP_T,o(a.wrapT)),t.texParameteri(r,t.TEXTURE_MAG_FILTER,o(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,o(a.minFilter))):(t.texParameteri(r,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(r,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS!==Rh||a.wrapT,t.texParameteri(r,t.TEXTURE_MAG_FILTER,h(a.magFilter)),t.texParameteri(r,t.TEXTURE_MIN_FILTER,h(a.minFilter)),a.minFilter!==Ih&&a.minFilter),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===Hh&&null===e.get("OES_texture_float_linear"))return;if(a.type===Xh&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function y(e,n,a){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",p),e.__webglTexture=t.createTexture(),S.textures++),r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,n.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,n.unpackAlignment);var h=s(n.image,i.maxTextureSize);u(n)&&!1===c(h)&&(h=l(h));var f=c(h),d=o(n.format),m=o(n.type);v(t.TEXTURE_2D,n,f);var g,y=n.mipmaps;if(n.isDepthTexture){var _=t.DEPTH_COMPONENT;if(n.type===Hh){if(!M)throw new Error("Float Depth Texture only supported in WebGL2.0");_=t.DEPTH_COMPONENT32F}else M&&(_=t.DEPTH_COMPONENT16);n.format===np&&_===t.DEPTH_COMPONENT&&n.type!==jh&&n.type!==Wh&&(n.type=jh,m=o(n.type)),n.format===ip&&(_=t.DEPTH_STENCIL,n.type!==Zh&&(n.type=Zh,m=o(n.type))),r.texImage2D(t.TEXTURE_2D,0,_,h.width,h.height,0,d,m,null)}else if(n.isDataTexture)if(y.length>0&&f){for(var x=0,b=y.length;x-1&&r.compressedTexImage2D(t.TEXTURE_2D,x,d,g.width,g.height,0,g.data):r.texImage2D(t.TEXTURE_2D,x,d,g.width,g.height,0,d,m,g.data);else if(y.length>0&&f){for(var x=0,b=y.length;x0&&l.__version!==e.version){l.__image__webglTextureCube||(e.addEventListener("dispose",p),l.__image__webglTextureCube=t.createTexture(),S.textures++),r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var u=e&&e.isCompressedTexture,h=e.image[0]&&e.image[0].isDataTexture,f=[],d=0;d<6;d++)f[d]=u||h?h?e.image[d].image:e.image[d]:s(e.image[d],i.maxCubemapSize);var m=c(f[0]),g=o(e.format),y=o(e.type);for(v(t.TEXTURE_CUBE_MAP,e,m),d=0;d<6;d++)if(u)for(var _,x=f[d].mipmaps,b=0,w=x.length;b-1&&r.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,b,g,_.width,_.height,0,_.data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,b,g,_.width,_.height,0,g,y,_.data);else h?r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,g,f[d].width,f[d].height,0,g,y,f[d].data):r.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,g,g,y,f[d]);e.generateMipmaps&&m&&t.generateMipmap(t.TEXTURE_CUBE_MAP),l.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(t.TEXTURE0+a),r.bindTexture(t.TEXTURE_CUBE_MAP,l.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){r.activeTexture(t.TEXTURE0+i),r.bindTexture(t.TEXTURE_CUBE_MAP,n.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=n.get(e),o=n.get(e.texture);e.addEventListener("dispose",f),o.__webglTexture=t.createTexture(),S.textures++;var a=!0===e.isWebGLRenderTargetCube,s=c(e);if(a)for(i.__webglFramebuffer=[],l=0;l<6;l++)i.__webglFramebuffer[l]=t.createFramebuffer();else i.__webglFramebuffer=t.createFramebuffer();if(a){r.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),v(t.TEXTURE_CUBE_MAP,e.texture,s);for(var l=0;l<6;l++)_(i.__webglFramebuffer[l],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+l);e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_CUBE_MAP),r.bindTexture(t.TEXTURE_CUBE_MAP,null)}else r.bindTexture(t.TEXTURE_2D,o.__webglTexture),v(t.TEXTURE_2D,e.texture,s),_(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_2D),r.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&w(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(i.generateMipmaps&&c(e)&&i.minFilter!==Ih&&i.minFilter!==zh){var o=e&&e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=n.get(i).__webglTexture;r.bindTexture(o,a),t.generateMipmap(o),r.bindTexture(o,null)}}}function ie(){var t={};return{get:function(e){var r=e.uuid,n=t[r];return void 0===n&&(n={},t[r]=n),n},delete:function(e){delete t[e.uuid]},clear:function(){t={}}}}function oe(t,e,r){function n(e,r,n){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a=1,F=null,U={},B=new o,V=new o,j={};return j[t.TEXTURE_2D]=n(t.TEXTURE_2D,t.TEXTURE_2D,1),j[t.TEXTURE_CUBE_MAP]=n(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:p,depth:f,stencil:d},init:function(){p.setClear(0,0,0,1),f.setClear(1),d.setClear(0),i(t.DEPTH_TEST),c(uh),l(!1),u(Eu),i(t.CULL_FACE),i(t.BLEND),s(Bu)},initAttributes:function(){for(var t=0,e=g.length;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var i,o=void 0!==r.precision?r.precision:"highp",a=n(o);a!==o&&(o=a);var s=!0===r.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),f=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),d=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=l>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var r=e.get("EXT_texture_filter_anisotropic");return i=null!==r?t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:h,maxAttributes:p,maxVertexUniforms:f,maxVaryings:d,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}function se(t){var e={};return{get:function(r){if(void 0!==e[r])return e[r];var n;switch(r){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":n=t.getExtension("WEBGL_compressed_texture_etc1");break;default:n=t.getExtension(r)}return e[r]=n,n}}}function ce(){function t(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var o=null!==t?t.length:0,a=null;if(0!==o){if(a=l.value,!0!==i||null===a){var u=n+4*o,h=e.matrixWorldInverse;c.getNormalMatrix(h),(null===a||a.length=0){var u=o[c];if(void 0!==u){var h=u.normalized,p=u.itemSize,f=ue.getAttributeProperties(u),d=f.__webglBuffer,m=f.type,g=f.bytesPerElement;if(u.isInterleavedBufferAttribute){var v=u.data,y=v.stride,_=u.offset;v&&v.isInstancedInterleavedBuffer?(Jt.enableAttributeAndDivisor(l,v.meshPerAttribute,i),void 0===r.maxInstancedCount&&(r.maxInstancedCount=v.meshPerAttribute*v.count)):Jt.enableAttribute(l),$t.bindBuffer($t.ARRAY_BUFFER,d),$t.vertexAttribPointer(l,p,m,h,y*g,(n*y+_)*g)}else u.isInstancedBufferAttribute?(Jt.enableAttributeAndDivisor(l,u.meshPerAttribute,i),void 0===r.maxInstancedCount&&(r.maxInstancedCount=u.meshPerAttribute*u.count)):Jt.enableAttribute(l),$t.bindBuffer($t.ARRAY_BUFFER,d),$t.vertexAttribPointer(l,p,m,h,0,n*p*g)}else if(void 0!==s){var x=s[c];if(void 0!==x)switch(x.length){case 2:$t.vertexAttrib2fv(l,x);break;case 3:$t.vertexAttrib3fv(l,x);break;case 4:$t.vertexAttrib4fv(l,x);break;default:$t.vertexAttrib1fv(l,x)}}}}Jt.disableUnusedAttributes()}}function p(t,e){return Math.abs(e[0])-Math.abs(t[0])}function f(t,e){return t.object.renderOrder!==e.object.renderOrder?t.object.renderOrder-e.object.renderOrder:t.material.program&&e.material.program&&t.material.program!==e.material.program?t.material.program.id-e.material.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function d(t,e){return t.object.renderOrder!==e.object.renderOrder?t.object.renderOrder-e.object.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function m(t,e,r,n,i){var o,a;r.transparent?(o=et,a=++nt):(o=Q,a=++tt);var s=o[a];void 0!==s?(s.id=t.id,s.object=t,s.geometry=e,s.material=r,s.z=Wt.z,s.group=i):(s={id:t.id,object:t,geometry:e,material:r,z:Wt.z,group:i},o.push(s))}function g(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),jt.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),y(jt)}function v(t){return jt.center.set(0,0,0),jt.radius=.7071067811865476,jt.applyMatrix4(t.matrixWorld),y(jt)}function y(t){if(!Rt.intersectsSphere(t))return!1;var e=It.numPlanes;if(0===e)return!0;var r=lt.clippingPlanes,n=t.center,i=-t.radius,o=0;do{if(r[o].distanceToPoint(n)=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var p=0;p=0&&t.numSupportedMorphNormals++}var f=n.__webglShader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=It.numPlanes,n.numIntersection=It.numIntersection,f.clippingPlanes=It.uniform),n.fog=e,n.lightsHash=Yt.hash,t.lights&&(f.ambientLightColor.value=Yt.ambient,f.directionalLights.value=Yt.directional,f.spotLights.value=Yt.spot,f.rectAreaLights.value=Yt.rectArea,f.pointLights.value=Yt.point,f.hemisphereLights.value=Yt.hemi,f.directionalShadowMap.value=Yt.directionalShadowMap,f.directionalShadowMatrix.value=Yt.directionalShadowMatrix,f.spotShadowMap.value=Yt.spotShadowMap,f.spotShadowMatrix.value=Yt.spotShadowMatrix,f.pointShadowMap.value=Yt.pointShadowMap,f.pointShadowMatrix.value=Yt.pointShadowMatrix);var d=n.program.getUniforms(),m=X.seqWithValue(d.seq,f);n.uniformsList=m}function w(t){t.side===Iu?Jt.disable($t.CULL_FACE):Jt.enable($t.CULL_FACE),Jt.setFlipSided(t.side===Nu),!0===t.transparent?Jt.setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha):Jt.setBlending(Uu),Jt.setDepthFunc(t.depthFunc),Jt.setDepthTest(t.depthTest),Jt.setDepthWrite(t.depthWrite),Jt.setColorWrite(t.colorWrite),Jt.setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)}function S(t,e,r,n){xt=0;var i=ee.get(r);if(Dt&&(Vt||t!==gt)){var o=t===gt&&r.id===ft;It.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,o)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsHash!==Yt.hash?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===It.numPlanes&&i.numIntersection===It.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(b(r,e,n),r.needsUpdate=!1);var a=!1,s=!1,c=!1,l=i.program,u=l.getUniforms(),h=i.__webglShader.uniforms;if(l.id!==ut&&($t.useProgram(l.program),ut=l.id,a=!0,s=!0,c=!0),r.id!==ft&&(ft=r.id,s=!0),a||t!==gt){if(u.set($t,t,"projectionMatrix"),Qt.logarithmicDepthBuffer&&u.setValue($t,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),t!==gt&&(gt=t,s=!0,c=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var p=u.map.cameraPosition;void 0!==p&&p.setValue($t,Wt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&u.setValue($t,"viewMatrix",t.matrixWorldInverse),u.set($t,lt,"toneMappingExposure"),u.set($t,lt,"toneMappingWhitePoint")}if(r.skinning){u.setOptional($t,n,"bindMatrix"),u.setOptional($t,n,"bindMatrixInverse");var f=n.skeleton;f&&(Qt.floatVertexTextures&&f.useVertexTexture?(u.set($t,f,"boneTexture"),u.set($t,f,"boneTextureWidth"),u.set($t,f,"boneTextureHeight")):u.setOptional($t,f,"boneMatrices"))}return(s||r.forceUniformsUpdate)&&(r.lights&&D(h,c),e&&r.fog&&T(h,e),(r.isMeshBasicMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshNormalMaterial||r.isMeshDepthMaterial)&&M(h,r),r.isLineBasicMaterial?A(h,r):r.isLineDashedMaterial?(A(h,r),E(h,r)):r.isPointsMaterial?C(h,r):r.isMeshLambertMaterial?P(h,r):r.isMeshToonMaterial?R(h,r):r.isMeshPhongMaterial?L(h,r):r.isMeshPhysicalMaterial?I(h,r):r.isMeshStandardMaterial?N(h,r):r.isMeshDepthMaterial?r.displacementMap&&(h.displacementMap.value=r.displacementMap,h.displacementScale.value=r.displacementScale,h.displacementBias.value=r.displacementBias):r.isMeshNormalMaterial&&O(h,r),void 0!==h.ltcMat&&(h.ltcMat.value=THREE.UniformsLib.LTC_MAT_TEXTURE),void 0!==h.ltcMag&&(h.ltcMag.value=THREE.UniformsLib.LTC_MAG_TEXTURE),X.upload($t,i.uniformsList,h,lt)),u.set($t,n,"modelViewMatrix"),u.set($t,n,"normalMatrix"),u.setValue($t,"modelMatrix",n.matrixWorld),l}function M(t,e){t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var r;if(e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r){r.isWebGLRenderTarget&&(r=r.texture);var n=r.offset,i=r.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}function A(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function E(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function C(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*At,t.scale.value=.5*Mt,t.map.value=e.map,null!==e.map){var r=e.map.offset,n=e.map.repeat;t.offsetRepeat.value.set(r.x,r.y,n.x,n.y)}}function T(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function P(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function L(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function R(t,e){L(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function N(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function I(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,N(t,e)}function O(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function D(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}function z(t){for(var e=0,r=0,n=t.length;r8&&(f.length=8);for(var g=n.morphAttributes,d=0,m=f.length;d0&&M.renderInstances(n,L,N):M.render(L,N)}},this.render=function(t,e,r,n){if(void 0===e||!0===e.isCamera){mt="",ft=-1,gt=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld),Gt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),Rt.setFromMatrix(Gt),$.length=0,tt=-1,nt=-1,st.length=0,ct.length=0,Vt=this.localClippingEnabled,Dt=It.init(this.clippingPlanes,Vt,e),_(t,e),Q.length=tt+1,et.length=nt+1,!0===lt.sortObjects&&(Q.sort(f),et.sort(d)),Dt&&It.beginShadows(),z($),_e.render(t,e),k($,e),Dt&&It.endShadows(),qt.calls=0,qt.vertices=0,qt.faces=0,qt.points=0,void 0===r&&(r=null),this.setRenderTarget(r);var i=t.background;if(null===i?Jt.buffers.color.setClear(bt.r,bt.g,bt.b,wt,H):i&&i.isColor&&(Jt.buffers.color.setClear(i.r,i.g,i.b,1,H),n=!0),(this.autoClear||n)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),i&&i.isCubeTexture?(void 0===me&&(me=new zt,ge=new Lt(new Nt(5,5,5),new J({uniforms:Up.cube.uniforms,vertexShader:Up.cube.vertexShader,fragmentShader:Up.cube.fragmentShader,side:Nu,depthTest:!1,depthWrite:!1,fog:!1}))),me.projectionMatrix.copy(e.projectionMatrix),me.matrixWorld.extractRotation(e.matrixWorld),me.matrixWorldInverse.getInverse(me.matrixWorld),ge.material.uniforms.tCube.value=i,ge.modelViewMatrix.multiplyMatrices(me.matrixWorldInverse,ge.matrixWorld),ue.update(ge),lt.renderBufferDirect(me,null,ge.geometry,ge.material,ge,null)):i&&i.isTexture&&(void 0===fe&&(fe=new kt(-1,1,1,-1,0,1),de=new Lt(new Ot(2,2),new dt({depthTest:!1,depthWrite:!1,fog:!1}))),de.material.map=i,ue.update(de),lt.renderBufferDirect(fe,null,de.geometry,de.material,de,null)),t.overrideMaterial){var o=t.overrideMaterial;x(Q,t,e,o),x(et,t,e,o)}else Jt.setBlending(Uu),x(Q,t,e),x(et,t,e);xe.render(t,e),be.render(t,e,_t),r&&le.updateRenderTargetMipmap(r),Jt.setDepthTest(!0),Jt.setDepthWrite(!0),Jt.setColorWrite(!0)}},this.setFaceCulling=function(t,e){Jt.setCullFace(t),Jt.setFlipSided(e===Tu)},this.allocTextureUnit=function(){var t=xt;return Qt.maxTextures,xt+=1,t},this.setTexture2D=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTarget&&(t||(t=!0),e=e.texture),le.setTexture2D(e,r)}}(),this.setTexture=function(){var t=!1;return function(e,r){t||(t=!0),le.setTexture2D(e,r)}}(),this.setTextureCube=function(){var t=!1;return function(e,r){e&&e.isWebGLRenderTargetCube&&(t||(t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?le.setTextureCube(e,r):le.setTextureCubeDynamic(e,r)}}(),this.getCurrentRenderTarget=function(){return ht},this.setRenderTarget=function(t){ht=t,t&&void 0===ee.get(t).__webglFramebuffer&&le.setupRenderTarget(t);var e,r=t&&t.isWebGLRenderTargetCube;if(t){var n=ee.get(t);e=r?n.__webglFramebuffer[t.activeCubeFace]:n.__webglFramebuffer,vt.copy(t.scissor),yt=t.scissorTest,_t.copy(t.viewport)}else e=null,vt.copy(Et).multiplyScalar(At),yt=Ct,_t.copy(Tt).multiplyScalar(At);if(pt!==e&&($t.bindFramebuffer($t.FRAMEBUFFER,e),pt=e),Jt.scissor(vt),Jt.setScissorTest(yt),Jt.viewport(_t),r){var i=ee.get(t.texture);$t.framebufferTexture2D($t.FRAMEBUFFER,$t.COLOR_ATTACHMENT0,$t.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,i.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,r,n,i,o){if(!1!==(t&&t.isWebGLRenderTarget)){var a=ee.get(t).__webglFramebuffer;if(a){var s=!1;a!==pt&&($t.bindFramebuffer($t.FRAMEBUFFER,a),s=!0);try{var c=t.texture,l=c.format,u=c.type;if(l!==Jh&&F(l)!==$t.getParameter($t.IMPLEMENTATION_COLOR_READ_FORMAT))return;if(!(u===Uh||F(u)===$t.getParameter($t.IMPLEMENTATION_COLOR_READ_TYPE)||u===Hh&&(Kt.get("OES_texture_float")||Kt.get("WEBGL_color_buffer_float"))||u===Xh&&Kt.get("EXT_color_buffer_half_float")))return;$t.checkFramebufferStatus($t.FRAMEBUFFER)===$t.FRAMEBUFFER_COMPLETE&&e>=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&$t.readPixels(e,r,n,i,F(l),F(u),o)}finally{s&&$t.bindFramebuffer($t.FRAMEBUFFER,pt)}}}}}function ue(t,e){this.name="",this.color=new Y(t),this.density=void 0!==e?e:25e-5}function he(t,e,r){this.name="",this.color=new Y(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function pe(){ut.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function fe(t,e,r,n,i){ut.call(this),this.lensFlares=[],this.positionScreen=new l,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,r,n,i)}function de(t){Q.call(this),this.type="SpriteMaterial",this.color=new Y(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function me(t){ut.call(this),this.type="Sprite",this.material=void 0!==t?t:new de}function ge(){ut.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ve(t,e,r){if(this.useVertexTexture=void 0===r||r,this.identityMatrix=new u,t=t||[],this.bones=t.slice(0),this.useVertexTexture){var n=Math.sqrt(4*this.bones.length);n=Tp.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 q(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,Jh,Hh)}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 i=0,o=this.bones.length;i=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0)}i.call(this,t,e,r,n,o,a,s,c,l),this.generateMipmaps=!1;var h=this;u()}function Ce(t,e,r,n,o,a,s,c,l,u,h,p){i.call(this,null,a,s,c,l,u,n,o,h,p),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Te(t,e,r,n,o,a,s,c,l){i.call(this,t,e,r,n,o,a,s,c,l),this.needsUpdate=!0}function Pe(t,e,r,n,o,a,s,c,l,u){if((u=void 0!==u?u:np)!==np&&u!==ip)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&u===np&&(r=jh),void 0===r&&u===ip&&(r=Zh),i.call(this,null,n,o,a,s,c,u,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:Ih,this.minFilter=void 0!==c?c:Ih,this.flipY=!1,this.generateMipmaps=!1}function Le(t){function e(t,e){return t-e}Pt.call(this),this.type="WireframeGeometry";var r,n,i,o,a,s,c,u,h=[],p=[0,0],f={},d=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(r=0,i=m.length;r.9&&o<.1&&(e<.2&&(m[t+0]+=1),r<.2&&(m[t+2]+=1),n<.2&&(m[t+4]+=1))}}function s(t){d.push(t.x,t.y,t.z)}function c(e,r){var n=3*e;r.x=t[n+0],r.y=t[n+1],r.z=t[n+2]}function u(){for(var t=new l,e=new l,r=new l,i=new l,o=new n,a=new n,s=new n,c=0,u=0;c0)&&m.push(w,S,A),(c!==r-1||u0&&u(!0),e>0&&u(!1)),this.setIndex(p),this.addAttribute("position",new St(f,3)),this.addAttribute("normal",new St(d,3)),this.addAttribute("uv",new St(m,2))}function cr(t,e,r,n,i,o,a){ar.call(this,0,t,e,r,n,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function lr(t,e,r,n,i,o,a){sr.call(this,0,t,e,r,n,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:o,thetaLength:a}}function ur(t,e,r,n){Tt.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new hr(t,e,r,n))}function hr(t,e,r,i){Pt.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var o,a,s=[],c=[],u=[],h=[],p=new l,f=new n;for(c.push(0,0,0),u.push(0,0,1),h.push(.5,.5),a=0,o=3;a<=e;a++,o+=3){var d=r+a/e*i;p.x=t*Math.cos(d),p.y=t*Math.sin(d),c.push(p.x,p.y,p.z),u.push(0,0,1),f.x=(c[o]/t+1)/2,f.y=(c[o+1]/t+1)/2,h.push(f.x,f.y)}for(o=1;o<=e;o++)s.push(o,o+1,0);this.setIndex(s),this.addAttribute("position",new St(c,3)),this.addAttribute("normal",new St(u,3)),this.addAttribute("uv",new St(h,2))}function pr(){J.call(this,{uniforms:Dp.merge([Fp.lights,{opacity:{value:1}}]),vertexShader:zp.shadow_vert,fragmentShader:zp.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}}})}function fr(t){J.call(this,t),this.type="RawShaderMaterial"}function dr(t){this.uuid=Tp.generateUUID(),this.type="MultiMaterial",this.materials=Array.isArray(t)?t:[],this.visible=!0}function mr(t){Q.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Y(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function gr(t){mr.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function vr(t){Q.call(this),this.type="MeshPhongMaterial",this.color=new Y(16777215),this.specular=new Y(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=mh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function yr(t){vr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function _r(t){Q.call(this,t),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function xr(t){Q.call(this),this.type="MeshLambertMaterial",this.color=new Y(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Y(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=mh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function br(t){Q.call(this),this.type="LineDashedMaterial",this.color=new Y(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(t)}function wr(t,e,r){var n=this,i=!1,o=0,a=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){a++,!1===i&&void 0!==n.onStart&&n.onStart(t,o,a),i=!0},this.itemEnd=function(t){o++,void 0!==n.onProgress&&n.onProgress(t,o,a),o===a&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)}}function Sr(t){this.manager=void 0!==t?t:qp}function Mr(t){this.manager=void 0!==t?t:qp,this._parser=null}function Ar(t){this.manager=void 0!==t?t:qp,this._parser=null}function Er(t){this.manager=void 0!==t?t:qp}function Cr(t){this.manager=void 0!==t?t:qp}function Tr(t){this.manager=void 0!==t?t:qp}function Pr(t,e){ut.call(this),this.type="Light",this.color=new Y(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Lr(t,e,r){Pr.call(this,t,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ut.DefaultUp),this.updateMatrix(),this.groundColor=new Y(e)}function Rr(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new n(512,512),this.map=null,this.matrix=new u}function Nr(){Rr.call(this,new zt(50,1,.5,500))}function Ir(t,e,r,n,i,o){Pr.call(this,t,e),this.type="SpotLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==o?o:1,this.shadow=new Nr}function Or(t,e,r,n){Pr.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==n?n:1,this.shadow=new Rr(new zt(90,1,.5,500))}function Dr(){Rr.call(this,new kt(-5,5,5,-5,.5,500))}function zr(t,e){Pr.call(this,t,e),this.type="DirectionalLight",this.position.copy(ut.DefaultUp),this.updateMatrix(),this.target=new ut,this.shadow=new Dr}function kr(t,e){Pr.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Fr(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function Ur(t,e,r,n){Fr.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Br(t,e,r,n){Fr.call(this,t,e,r,n)}function Vr(t,e,r,n){Fr.call(this,t,e,r,n)}function jr(t,e,r,n){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=$p.convertArray(e,this.TimeBufferType),this.values=$p.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation),this.validate(),this.optimize()}function Gr(t,e,r,n){jr.call(this,t,e,r,n)}function Wr(t,e,r,n){Fr.call(this,t,e,r,n)}function Hr(t,e,r,n){jr.call(this,t,e,r,n)}function Xr(t,e,r,n){jr.call(this,t,e,r,n)}function Yr(t,e,r,n){jr.call(this,t,e,r,n)}function qr(t,e,r){jr.call(this,t,e,r)}function $r(t,e,r,n){jr.call(this,t,e,r,n)}function Zr(t,e,r,n){jr.apply(this,arguments)}function Kr(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=Tp.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Qr(t){this.manager=void 0!==t?t:qp,this.textures={}}function Jr(t){this.manager=void 0!==t?t:qp}function tn(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function en(t){"boolean"==typeof t&&(t=void 0),this.manager=void 0!==t?t:qp,this.withCredentials=!1}function rn(t){this.manager=void 0!==t?t:qp,this.texturePath=""}function nn(t,e,r,n,i){var o=.5*(n-e),a=.5*(i-r),s=t*t;return(2*r-2*n+o+a)*(t*s)+(-3*r+3*n-2*o-a)*s+o*t+r}function on(t,e){var r=1-t;return r*r*e}function an(t,e){return 2*(1-t)*t*e}function sn(t,e){return t*t*e}function cn(t,e,r,n){return on(t,e)+an(t,r)+sn(t,n)}function ln(t,e){var r=1-t;return r*r*r*e}function un(t,e){var r=1-t;return 3*r*r*t*e}function hn(t,e){return 3*(1-t)*t*t*e}function pn(t,e){return t*t*t*e}function fn(t,e,r,n,i){return ln(t,e)+un(t,r)+hn(t,n)+pn(t,i)}function dn(){}function mn(t,e){this.v1=t,this.v2=e}function gn(){this.curves=[],this.autoClose=!1}function vn(t,e,r,n,i,o,a,s){this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=n,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function yn(t){this.points=void 0===t?[]:t}function _n(t,e,r,n){this.v0=t,this.v1=e,this.v2=r,this.v3=n}function xn(t,e,r){this.v0=t,this.v1=e,this.v2=r}function bn(t){gn.call(this),this.currentPoint=new n,t&&this.fromPoints(t)}function wn(){bn.apply(this,arguments),this.holes=[]}function Sn(){this.subPaths=[],this.currentPath=null}function Mn(t){this.data=t}function An(t){this.manager=void 0!==t?t:qp}function En(t){this.manager=void 0!==t?t:qp}function Cn(t,e,r,n){Pr.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==r?r:10,this.height=void 0!==n?n:10}function Tn(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Pn(t,e,r){ut.call(this),this.type="CubeCamera";var n=new zt(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new l(1,0,0)),this.add(n);var i=new zt(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new l(-1,0,0)),this.add(i);var o=new zt(90,1,t,e);o.up.set(0,0,1),o.lookAt(new l(0,1,0)),this.add(o);var a=new zt(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new l(0,-1,0)),this.add(a);var c=new zt(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new l(0,0,1)),this.add(c);var u=new zt(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new l(0,0,-1)),this.add(u);var h={format:Qh,magFilter:zh,minFilter:zh};this.renderTarget=new s(r,r,h),this.updateCubeMap=function(t,e){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,s=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,n,r),r.activeCubeFace=1,t.render(e,i,r),r.activeCubeFace=2,t.render(e,o,r),r.activeCubeFace=3,t.render(e,a,r),r.activeCubeFace=4,t.render(e,c,r),r.texture.generateMipmaps=s,r.activeCubeFace=5,t.render(e,u,r),t.setRenderTarget(null)}}function Ln(){ut.call(this),this.type="AudioListener",this.context=Jp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Rn(t){ut.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Nn(t){Rn.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function In(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function On(t,e,r){this.binding=t,this.valueSize=r;var n,i=Float64Array;switch(e){case"quaternion":n=this._slerp;break;case"string":case"bool":i=Array,n=this._select;break;default:n=this._lerp}this.buffer=new i(4*r),this._mixBufferRegion=n,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function Dn(t,e,r){this.path=e,this.parsedPath=r||Dn.parseTrackName(e),this.node=Dn.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function zn(t){this.uuid=Tp.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var r=0,n=arguments.length;r!==n;++r)e[arguments[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function kn(t,e,r){this._mixer=t,this._clip=e,this._localRoot=r||null;for(var n=e.tracks,i=n.length,o=new Array(i),a={endingStart:mp,endingEnd:mp},s=0;s!==i;++s){var c=n[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=dp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Fn(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Un(t){"string"==typeof t&&(t=arguments[1]),this.value=t}function Bn(){Pt.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Vn(t,e,r,n){this.uuid=Tp.generateUUID(),this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function jn(t,e){this.uuid=Tp.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Gn(t,e,r){jn.call(this,t,e),this.meshPerAttribute=r||1}function Wn(t,e,r){mt.call(this,t,e),this.meshPerAttribute=r||1}function Hn(t,e,r,n){this.ray=new st(t,e),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return this.Points}}})}function Xn(t,e){return t.distance-e.distance}function Yn(t,e,r,n){if(!1!==t.visible&&(t.raycast(e,r),!0===n))for(var i=t.children,o=0,a=i.length;o0&&(i=Object.create(i))}return i}function Pi(t){var e=!1;this.enable=function(t){e=t};for(var r=0,n=Object.keys(t),i=0,o=n.length;i=3&&"base64"===e[r-2]?new Blob([Ni(e[r-1])]):null}function Di(t,e,r){var n=document.createElement(t);return n.id=e,n.style.cssText=r,n}function zi(){this.domElement=Di("div","stats","padding:8px"),this._text=Di("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=vf(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}function ki(){Si.call(this),this._cancellationRequested=!1}function Fi(){this.old=null,this.now={},this._changed={},this.reset()}function Ui(t){return!(!t||"0"===t||wu.isString(t)&&"false"===t.toLowerCase())}function Bi(t){return gf.encodeQueryComponent(t,Nf)}function Vi(t){return gf.encodeQueryComponent(t,If)}function ji(t){var e=t.reps;if(!e){var r=_f.now.presets,n=t.preset||_f.now.preset;(e=r[n])||(ff.warn('Unknown preset "'+n+'"'),e=r[n=Object.keys(r)[0]]),t.preset=n,t.reps=gf.deriveDeep(e,!0)}}function Gi(t,e,r){ji(t);var n=t.reps[Af];n.hasOwnProperty(e)&&++Af>=t.reps.length&&(t.reps[Af]=gf.deriveDeep(n,!0)),void 0!==r&&(t.reps[Af][e]=r)}function Wi(t,e,r){void 0===t._objects&&(t._objects=[]);var n={type:r[0],params:e};void 0!==r[1]&&(n.opts=r[1]),t._objects[t._objects.length]=n}function Hi(t,e){var r=t.indexOf(",");return r>=0?(e.push(t.substr(r+1).split(",")),t.substr(0,r)):t}function Xi(t,e,r){if(t){var n=t.indexOf(Tf),i=Hi(t.substr(0,n>=0?n:void 0),r);if(n>=0){var o=t.substr(n+1).split(Lf);if(t=i,e){var a=e[t],s=gf.deriveDeep(a,!0);o.forEach(function(e){var r=e.split(Pf,2),n=decodeURIComponent(r[0]),i=decodeURIComponent(r[1]),o=Ef[xf(wu.get(a,n))];o?wu.set(s,n,o(i)):ff.warn('Unknown argument "'+n+'" for option "'+t+'"')}),Object.keys(s).length>0&&(t=[t,s])}}else t=i}return t}function Yi(t){Af=0;for(var e={},r=0,n=t.length;r0&&(e+=","+t.params.join(",")),t.opts&&(e+=Tf+qi(t.opts)),e}}function Ki(t){var e=[],r=0;return gf.forInRecursive(t,function(t,n){e[r++]=n+"="+gf.enquoteString(t)}),e.join(" ")}function Qi(t){return wu.isArray(t)?t[0]+(t.length<2?"":" "+Ki(t[1])):t}function Ji(t){if(t&&t.type){var e=t.type;return wu.isArray(t.params)&&t.params.length>0&&(e+=" "+t.params.map(gf.enquoteString).join(" ")),t.opts&&(e+=" "+Ki(t.opts)),e}}function to(t,e){function r(t,e){null!==e&&void 0!==e&&(n[i++]=t+e)}var n=[],i=0;return wu.isEmpty(t)?null:(r("",e),r("s=",gf.enquoteString(t.selector)),r("m=",Qi(t.mode)),r("c=",Qi(t.colorer)),r("mt=",Qi(t.material)),n.join(" "))}function eo(t,e){this._node=e||null,this._name=t||null,null===this._node&&null===this._name&&(this._name="Unknown")}function ro(t,e,r,n,i,o,a){this.number=t,this.name=e,this.fullName=r,this.weight=n,this.radius=i,this.radiusBonding=o,this.hydrogenValency=a}function no(t,e,r,n,i,o,a,s,c,l,u){this._index=-1,this._residue=t,this._name=e instanceof eo?e:new eo(e),this.element=r,this._position=n,this._role=i,this._mask=1,this._index=-1,this._het=o,this._serial=a,this._location=(s||" ").charCodeAt(0),this._occupancy=c||1,this._temperature=l,this._charge=u,this._hydrogenCount=-1,this._radicalCount=0,this._valence=-1,this._bonds=[],this.flags=0,"H"===r.name?this.flags|=no.Flags.HYDROGEN:"C"===r.name&&(this.flags|=no.Flags.CARBON)}function io(t){return t<2?1:t}function oo(t){return t._position}function ao(t,e,r,n,i){if(this._left=t,this._right=e,this._fixed=i,this._index=-1,t>e)throw new Error("In a bond atom indices must be in increasing order");this._order=r,this._type=n}function so(t,e,r){this._name=t,this._fullName=e,this.letterCode=r,this.flags=0}function co(t,e){for(var r=0,n=e.length;r=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function vo(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return t=go(Ao(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function yo(t){var e=_o(t),r="/"===qf(t,-1);return(t=go(Ao(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function _o(t){return"/"===t.charAt(0)}function xo(){return yo(Ao(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function bo(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=vo(t).substr(1),e=vo(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;sr?r:t}function zo(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function Fo(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function ko(t){this._complex=t,this._maxRad=1.8;var e=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=e.min.clone(),this._vBoxMax=e.max.clone(),this._pairCollection=null}function Uo(t){for(var e=ao.BondType.UNKNOWN,r=t._residues,n=0,i=r.length;n3}function qo(t){return!0}function $o(t){this._complex=t;for(var e=new Array(t._bonds.length),r=new Array(t._bonds.length),n=0,i=e.length;n>1;t;)e<<=1,t>>=1;return e}function Jo(t,e,r,n){var i,o=r-t.z,a=n-t.z,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.z&&n>=t.z?e:Math.max(s,c),[l,i]}function ta(t,e,r,n){var i,o=r-t.y,a=n-t.y,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.y&&n>=t.y?e:Math.max(s,c),[l,i]}function ea(t,e){var r;this._box=t.clone(),this._count=t.size().divide(e).floor(),this._last=this._count.clone().subScalar(1),this._cellSize=t.size().divide(this._count);var n=this._count.x*this._count.y*this._count.z;for(this._voxels=gf.allocateTyped(Int32Array,n),r=0;r0,c=!1===o&&e>0,u=(i+1)*n+s*(n+1)+c*(n+1),h=(2*i+s+c)*n,p=r/2,f=new mt(gf.allocateTyped(Float32Array,3*u),3),d=new mt(gf.allocateTyped(Float32Array,3*u),3),m=new xt(gf.allocateTyped(Uint16Array,h*Fd),1),g=new mt(gf.allocateTyped(Float32Array,2*u),2),v=0,y=0,_=-(e-t)/r,x=0;x<=i;x++){if(x!==i)for(var b=0;bE&&(E=P)}this.neighbourListLength=27*E+1,this.withinRadii=function(e,r,n,s,h){var p=0,f=i(e,c),v=i(r,l),_=i(n,u),x=Math.max(0,f-1),A=Math.max(0,v-1),E=Math.max(0,_-1),C=Math.min(d-1,f+1),T=Math.min(m-1,v+1),P=Math.min(g-1,_+1);for(o=x;o<=C;++o){var L=o*y;for(b=A;b<=T;++b)for(var R=b*g,N=E;N<=P;++N)for(var I=w[a=L+R+N],O=I+S[a],D=I;Dx&&(x=e),_[t]=e*e}s(),c(),u(),W=-1}function o(t,e,r){for(var n=gf.allocateTyped(t,e),i=0;i=0;){if(o!==n&&o!==i&&p(o,t,e,r))return W=o,o;o=O[++a]}return W=-1,-1}function p(t,e,r,n){var i=z*t,o=_[t],a=F[i]-e,s=F[i+1]-r,c=F[i+2]-n;return a*a+s*s+c*cH[Z]&&(H[Z]=J,X[Z]=U[t]),A[Z]<0&&(A[Z]=-A[Z]);var et=Math.sqrt(Q),rt=o/et,nt=K*rt,it=G*rt,ot=N*rt;if(nt+=r,it+=n,ot+=i,-1===h(nt,it,ot,t,-1)){var at=o-et;at=0;)t0&&f0){r=1/r;var n=3*t;E[n]*=r,E[n+1]*=r,E[n+2]*=r}}}function y(){i(),f(),d(),v()}var _,x,b,w,S,M,A,E,C,T,P,L,R,N,I,O,D,z=4,F=t.posRad,k=t.colors,U=t.atoms,B=F.length/z,V=e.bbox,j=V.minPosRad,G=V.maxPosRad,W=-1,H=null,X=null,Y=null,q=new l(0,0,0),$=new l(0,0,0),Z=new l(0,0,0);this.build=function(){y(),this.volTexMap=E,this.weightsMap=H,this.atomMap=X,this.volMap=A}}function $a(t,e){Ha.call(this,t,e)}function Za(t,e){this.coord=new l,this.coord.copy(t),this.radius=e,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null}function Ka(t,e,r,n,i){this._numAtoms=t,this._atoms=e,this._vBoxMin=new l,this._vBoxMax=new l,this._vBoxMin.copy(r),this._vBoxMax.copy(n),this._probeRadius=i,this._atomsList=null,this._voxelList=null}function Qa(t,e,r,n,i,o,a){this.complex=t,this.atoms=r,this.pdbAtoms=e,this.numVoxels=o,this.colorMode=a,this.vBoxMin=new l,this.vBoxMax=new l,this.vBoxMin.copy(n),this.vBoxMax.copy(i),this.voxelsRefs=null,this.voxels=null}function Ja(t,e,r){this._maxNumVertices=t,this._maxNumTriangles=e,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,r&&(this._colors=new Array(t)),this._indices=new Array(3*e),this._numVertices=0,this._numTriangles=0;var n;for(n=0;n0?n:[new u];for(var o=this._createMeshes(t),a=0,s=o.length;as&&t[e-1]._isValid?e-1:e}function o(e){return e0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:l,chunks:p,parent:r},n,i,u,o,s);g._component=h,c.add(g)})}function Ks(t,e,r){var n=document.createElement("div");if(n.className="label label-sgroup",n.style.color=e,"string"==typeof r){var i=document.createElement("span");i.style.fontSize="150%";var o=document.createElement("span"),a=document.createTextNode(r);o.appendChild(a),i.appendChild(o),n.appendChild(i)}else n.appendChild(r);var s=new na(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var c=s.getElement();return c.style.visibility="visible",c.style.textAlign="center",c.style.verticalAlign="middle",s}function Qs(t,e,r,n,i,o,a,s){var c=this;ia.call(c);for(var u=new ia,h=0;h>16&255)+r*(e>>16&255)<<16|n*(t>>8&255)+r*(e>>8&255)<<8|n*(255&t)+r*(255&e)}function bc(t,e){this.name=t||"Custom",this.id=e||"CP"}function wc(t){if(this.constructor===wc)throw new Error("Can not instantiate abstract class!");this.opts=wu.merge(gf.deriveDeep(_f.now.colorers[this.id],!0),t),this.palette=Vm.any}function Sc(t){wc.call(this,t)}function Mc(t){wc.call(this,t)}function Ac(t){wc.call(this,t)}function Ec(t){wc.call(this,t)}function Cc(t){wc.call(this,t)}function Tc(t){wc.call(this,t)}function Pc(t){wc.call(this,t);var e=pd.parse(this.opts.subset);this._subsetCached=e.error?pd.none():e.selector}function Lc(t){wc.call(this,t)}function Rc(t){wc.call(this,t)}function Nc(t){wc.call(this,t)}function Ic(t){wc.call(this,t)}function Oc(t){wc.call(this,t)}function Dc(t){return new Y(t,t,t)}function zc(t,e,r,n){this.index=t,this.mode=e,this.colorer=r,this.selector=n,this.selectorString="",this.count=0,this.material=new oa,this.material.setValues({clipPlane:_f.now.draft.clipPlane}),this.materialPreset=$m.any,this.needsRebuild=!0,this.visible=!0,this.setMode(e)}function Fc(t,e,r){var n=t.children;if(n)for(var i=0,o=n.length;i0&&(e.data=window.atob(t.substring(r+1)),e.fileType=t.substring(0,r).toLowerCase())}Yc.call(this,t,e)}function Kc(t,e){this._data=t,this._options=e}function Qc(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}function Jc(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}function tl(t){var e=4===t.trim().length;return t.slice(0,e?1:2).trim()}function el(t,e){Kc.call(this,t,e),this._complex=null,this._chain=null,this._residue=null,this._sheet=null,this._serialAtomMap=null,this._modelId=1,this._compaundFound=!1,this._biomoleculeFound=!1,this._allowedChainsIDs=null,this._lastMolId=-1,this._remarks={},this._remark=null,this._molecules=[],this._molecule=null,this._compndCurrToken="",e.fileType="pdb"}function rl(t,e){Kc.call(this,t,e),this._complex=null,e.fileType="mol"}function nl(t,e){Kc.call(this,t,e),this._complex=null,this._sheet=null,this._residue=null,this._serialAtomMap=null,this._modelId=1,this._lastMolId=-1,this._readOnlyOneMolecule=!1,e.fileType="cml"}function il(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=$g?t-Zg:t}function Sl(t,e,r){this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=r,"function"==typeof e?(this._framesRequestLength=1,this._downloadDataFn=e):this.parseBinaryData(e,!0),this.reset(),this.setFrame(0)}function Ml(t,e){if(this.constructor===Ml)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=wu.merge(gf.deriveDeep(_f.now.objects[this.type],!0),e),this.needsRebuild=!1}function Al(t,e){if(Ml.call(this,t,e),t.length<2)throw new Error("Wrong number of argumets on line object creation!");this._id1=t[0],this._id2=t[1]}function El(t){var e=Dp.clone(ev);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Cl(t){return new J({uniforms:El(t),vertexShader:Jg,fragmentShader:tv,transparent:!0,depthTest:!1,depthWrite:!1})}function Tl(t){var e=Dp.clone(nv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Pl(t){return new J({uniforms:Tl(t),vertexShader:Jg,fragmentShader:rv,transparent:!0,depthTest:!1,depthWrite:!1})}function Ll(t,e){var r=Dp.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}function Rl(t){var e=Dp.clone(hv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Nl(t){return new J({uniforms:Rl(t),vertexShader:Jg,fragmentShader:uv,transparent:!1,depthTest:!1,depthWrite:!1})}function Il(){this.position=new l(0,0,0),this.scale=1,this.orientation=new c(0,0,0,1)}function Ol(){}function Dl(t){var e;switch(t.code){case FileError.QUOTA_EXCEEDED_ERR:e="QUOTA_EXCEEDED_ERR";break;case FileError.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case FileError.SECURITY_ERR:e="SECURITY_ERR";break;case FileError.INVALID_MODIFICATION_ERR:e="INVALID_MODIFICATION_ERR";break;case FileError.INVALID_STATE_ERR:e="INVALID_STATE_ERR";break;default:e="Unknown Error"}throw new Error(e)}function zl(t,e,r,n,i){gv.root.getFile(t,{create:!n},function(t){t.createWriter(function(t){var o=new Blob([e],{type:r?"octet/stream":"text/plain"});n?(t.onwriteend=function(){i()},t.seek(t.length),t.write(o)):(t.onwriteend=function(){0===t.length&&e.length>0?t.write(o):i()},t.truncate(0))},Dl)},Dl)}function Fl(){}function kl(t){for(var e=[],r=0,n=t.length;r=0&&(t=t.substr(0,e)),t}function tu(t){if("string"==typeof t)if(t.match(/^[0-9A-Z]{4}$/i))t=t.toUpperCase();else if(t.match(/^data\/[0-9A-Z]{4}\.pdb$/i))t=t.substr(5,4).toUpperCase();else{var e=document.createElement("a");e.href=t,t=e.href}return t}function eu(t){var e=!1;return t.forEachComponent(function(t){t.forEachResidue(function(t){t._isValid&&(e=!0)})}),e}function ru(t,e,r){r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function nu(t){Si.call(this),this._opts=wu.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.body,this._containerRoot=this._container,this._running=!1,this._halting=!1,this._building=!1,this._needRender=!0,this._hotKeysEnabled=!0,this.settings=_f;var e=ff;e.console=!1,e.level="info",this.logger=e,this._cookies=new Kl(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loader=null,this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._fileSource=null,this._fileSourceAnim=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;nu.registeredPlugins.forEach(function(t){t.call(r)})}function iu(t,e,r,n){return new Promise(function(i,o){if(e=e||{},t instanceof File&&t.name.match(/.man$/i)&&(e.binary=!0,e.animation=!0),t instanceof File&&(t.name.match(/.mmtf$/i)||t.name.match(/.ccp4$/i))?e.binary=!0:wu.isString(t)&&t.match(/.mmtf$/i)&&(e.binary=!0),!e.mdFile&&!e.fileType&&"string"==typeof t){var a=t.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/);if(a){var s=a[2].trim(),c=a[1];switch(c){case"pubchem":case"pubchem+json":c="pubchem+json",t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+encodeURIComponent(s)+"/JSON?record_type=3d",e.sourceType="url",e.fileName=s+".json";break;default:if(s.match(/^\w{4}$/i))switch(c=c||"pdb"){case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s,e.sourceType="url";break;case"cif":case"pdb":t="http://files.rcsb.org/view/"+s+"."+c,e.sourceType="url"}else c=void 0}c&&(e.fileType=c)}}"mmtf"===e.fileType&&(e.binary=!0);var l=Yg.loaders.create(n,t,e),u=wu.get(e,"preset.expression");if(!wu.isUndefined(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit","draft.waterBondingHack"],p=0,f=h.length;p=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function vo(){for(var t="",e=!1,r=arguments.length-1;r>=-1&&!e;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(t=n+"/"+t,e="/"===n.charAt(0))}return t=go(Ao(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function yo(t){var e=_o(t),r="/"===qf(t,-1);return(t=go(Ao(t.split("/"),function(t){return!!t}),!e).join("/"))||e||(t="."),t&&r&&(t+="/"),(e?"/":"")+t}function _o(t){return"/"===t.charAt(0)}function xo(){return yo(Ao(Array.prototype.slice.call(arguments,0),function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function bo(t,e){function r(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=vo(t).substr(1),e=vo(e).substr(1);for(var n=r(t.split("/")),i=r(e.split("/")),o=Math.min(n.length,i.length),a=o,s=0;sr?r:t}function zo(t){return!t.isHet()||t._bonds&&0===t._bonds.length}function ko(t){return"HOH"!==t._residue._type._name&&!t.isHet()}function Fo(t){this._complex=t,this._maxRad=1.8;var e=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=e.min.clone(),this._vBoxMax=e.max.clone(),this._pairCollection=null}function Uo(t){for(var e=ao.BondType.UNKNOWN,r=t._residues,n=0,i=r.length;n3}function qo(t){return!0}function $o(t){this._complex=t;for(var e=new Array(t._bonds.length),r=new Array(t._bonds.length),n=0,i=e.length;n>1;t;)e<<=1,t>>=1;return e}function Jo(t,e,r,n){var i,o=r-t.z,a=n-t.z,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.z&&n>=t.z?e:Math.max(s,c),[l,i]}function ta(t,e,r,n){var i,o=r-t.y,a=n-t.y,s=Math.sqrt(Math.max(e*e-o*o,0)),c=Math.sqrt(Math.max(e*e-a*a,0)),l=Math.min(s,c);return i=r<=t.y&&n>=t.y?e:Math.max(s,c),[l,i]}function ea(t,e){var r;this._box=t.clone(),this._count=t.size().divide(e).floor(),this._last=this._count.clone().subScalar(1),this._cellSize=t.size().divide(this._count);var n=this._count.x*this._count.y*this._count.z;for(this._voxels=gf.allocateTyped(Int32Array,n),r=0;r0,c=!1===o&&e>0,u=(i+1)*n+s*(n+1)+c*(n+1),h=(2*i+s+c)*n,p=r/2,f=new mt(gf.allocateTyped(Float32Array,3*u),3),d=new mt(gf.allocateTyped(Float32Array,3*u),3),m=new xt(gf.allocateTyped(Uint16Array,h*Fd),1),g=new mt(gf.allocateTyped(Float32Array,2*u),2),v=0,y=0,_=-(e-t)/r,x=0;x<=i;x++){if(x!==i)for(var b=0;bE&&(E=P)}this.neighbourListLength=27*E+1,this.withinRadii=function(e,r,n,s,h){var p=0,f=i(e,c),v=i(r,l),_=i(n,u),x=Math.max(0,f-1),A=Math.max(0,v-1),E=Math.max(0,_-1),C=Math.min(d-1,f+1),T=Math.min(m-1,v+1),P=Math.min(g-1,_+1);for(o=x;o<=C;++o){var L=o*y;for(b=A;b<=T;++b)for(var R=b*g,N=E;N<=P;++N)for(var I=w[a=L+R+N],O=I+S[a],D=I;Dx&&(x=e),_[t]=e*e}s(),c(),u(),W=-1}function o(t,e,r){for(var n=gf.allocateTyped(t,e),i=0;i=0;){if(o!==n&&o!==i&&p(o,t,e,r))return W=o,o;o=O[++a]}return W=-1,-1}function p(t,e,r,n){var i=z*t,o=_[t],a=k[i]-e,s=k[i+1]-r,c=k[i+2]-n;return a*a+s*s+c*cH[Z]&&(H[Z]=J,X[Z]=U[t]),A[Z]<0&&(A[Z]=-A[Z]);var et=Math.sqrt(Q),rt=o/et,nt=K*rt,it=G*rt,ot=N*rt;if(nt+=r,it+=n,ot+=i,-1===h(nt,it,ot,t,-1)){var at=o-et;at=0;)t0&&f0){r=1/r;var n=3*t;E[n]*=r,E[n+1]*=r,E[n+2]*=r}}}function y(){i(),f(),d(),v()}var _,x,b,w,S,M,A,E,C,T,P,L,R,N,I,O,D,z=4,k=t.posRad,F=t.colors,U=t.atoms,B=k.length/z,V=e.bbox,j=V.minPosRad,G=V.maxPosRad,W=-1,H=null,X=null,Y=null,q=new l(0,0,0),$=new l(0,0,0),Z=new l(0,0,0);this.build=function(){y(),this.volTexMap=E,this.weightsMap=H,this.atomMap=X,this.volMap=A}}function $a(t,e){Ha.call(this,t,e)}function Za(t,e){this.coord=new l,this.coord.copy(t),this.radius=e,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null}function Ka(t,e,r,n,i){this._numAtoms=t,this._atoms=e,this._vBoxMin=new l,this._vBoxMax=new l,this._vBoxMin.copy(r),this._vBoxMax.copy(n),this._probeRadius=i,this._atomsList=null,this._voxelList=null}function Qa(t,e,r,n,i,o,a){this.complex=t,this.atoms=r,this.pdbAtoms=e,this.numVoxels=o,this.colorMode=a,this.vBoxMin=new l,this.vBoxMax=new l,this.vBoxMin.copy(n),this.vBoxMax.copy(i),this.voxelsRefs=null,this.voxels=null}function Ja(t,e,r){this._maxNumVertices=t,this._maxNumTriangles=e,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,r&&(this._colors=new Array(t)),this._indices=new Array(3*e),this._numVertices=0,this._numTriangles=0;var n;for(n=0;n0?n:[new u];for(var o=this._createMeshes(t),a=0,s=o.length;as&&t[e-1]._isValid?e-1:e}function o(e){return e0&&(d[m++]=t)});var g=new t(e,{cycles:d,atoms:l,chunks:p,parent:r},n,i,u,o,s);g._component=h,c.add(g)})}function Ks(t,e,r){var n=document.createElement("div");if(n.className="label label-sgroup",n.style.color=e,"string"==typeof r){var i=document.createElement("span");i.style.fontSize="150%";var o=document.createElement("span"),a=document.createTextNode(r);o.appendChild(a),i.appendChild(o),n.appendChild(i)}else n.appendChild(r);var s=new na(n);s.position.copy(t),s.userData={translation:"translate(-50%, -50%)",color:e};var c=s.getElement();return c.style.visibility="visible",c.style.textAlign="center",c.style.verticalAlign="middle",s}function Qs(t,e,r,n,i,o,a,s){var c=this;ia.call(c);for(var u=new ia,h=0;h>16&255)+r*(e>>16&255)<<16|n*(t>>8&255)+r*(e>>8&255)<<8|n*(255&t)+r*(255&e)}function bc(t,e){this.name=t||"Custom",this.id=e||"CP"}function wc(t){if(this.constructor===wc)throw new Error("Can not instantiate abstract class!");this.opts=wu.merge(gf.deriveDeep(_f.now.colorers[this.id],!0),t),this.palette=jm.any}function Sc(t){wc.call(this,t)}function Mc(t){wc.call(this,t)}function Ac(t){wc.call(this,t)}function Ec(t){wc.call(this,t)}function Cc(t){wc.call(this,t)}function Tc(t){wc.call(this,t)}function Pc(t){wc.call(this,t);var e=pd.parse(this.opts.subset);this._subsetCached=e.error?pd.none():e.selector}function Lc(t){wc.call(this,t)}function Rc(t){wc.call(this,t)}function Nc(t){wc.call(this,t)}function Ic(t){wc.call(this,t)}function Oc(t){wc.call(this,t)}function Dc(t){return new Y(t,t,t)}function zc(t,e,r,n){this.index=t,this.mode=e,this.colorer=r,this.selector=n,this.selectorString="",this.count=0,this.material=new oa,this.material.setValues({clipPlane:_f.now.draft.clipPlane}),this.materialPreset=Zm.any,this.needsRebuild=!0,this.visible=!0,this.setMode(e)}function kc(t,e,r){var n=t.children;if(n)for(var i=0,o=n.length;i0&&(e.data=window.atob(t.substring(r+1)),e.fileType=t.substring(0,r).toLowerCase())}Yc.call(this,t,e)}function Kc(t,e){this._data=t,this._options=e}function Qc(){this.matrices=[],this._matrix=null,this._matrixIndex=-1}function Jc(t){this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}function tl(t){var e=4===t.trim().length;return t.slice(0,e?1:2).trim()}function el(t,e){Kc.call(this,t,e),this._complex=null,this._chain=null,this._residue=null,this._sheet=null,this._serialAtomMap=null,this._modelId=1,this._compaundFound=!1,this._biomoleculeFound=!1,this._allowedChainsIDs=null,this._lastMolId=-1,this._remarks={},this._remark=null,this._molecules=[],this._molecule=null,this._compndCurrToken="",e.fileType="pdb"}function rl(t,e){Kc.call(this,t,e),this._complex=null,e.fileType="mol"}function nl(t,e){Kc.call(this,t,e),this._complex=null,this._sheet=null,this._residue=null,this._serialAtomMap=null,this._modelId=1,this._lastMolId=-1,this._readOnlyOneMolecule=!1,e.fileType="cml"}function il(t){this._original=Array.from(t),this._original.sort(),this._sum=0;for(var e=0;e=Zg?t-Kg:t}function Sl(t,e,r){this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=r,"function"==typeof e?(this._framesRequestLength=1,this._downloadDataFn=e):this.parseBinaryData(e,!0),this.reset(),this.setFrame(0)}function Ml(t,e){if(this.constructor===Ml)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=wu.merge(gf.deriveDeep(_f.now.objects[this.type],!0),e),this.needsRebuild=!1}function Al(t,e){if(Ml.call(this,t,e),t.length<2)throw new Error("Wrong number of argumets on line object creation!");this._id1=t[0],this._id2=t[1]}function El(t){var e=Dp.clone(rv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Cl(t){return new J({uniforms:El(t),vertexShader:tv,fragmentShader:ev,transparent:!0,depthTest:!1,depthWrite:!1})}function Tl(t){var e=Dp.clone(iv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Pl(t){return new J({uniforms:Tl(t),vertexShader:tv,fragmentShader:nv,transparent:!0,depthTest:!1,depthWrite:!1})}function Ll(t,e){var r=Dp.clone(e);for(var n in t)r.hasOwnProperty(n)&&(r[n].value=t[n]);return r}function Rl(t){var e=Dp.clone(pv);for(var r in t)e.hasOwnProperty(r)&&(e[r].value=t[r]);return e}function Nl(t){return new J({uniforms:Rl(t),vertexShader:tv,fragmentShader:hv,transparent:!1,depthTest:!1,depthWrite:!1})}function Il(){this.position=new l(0,0,0),this.scale=1,this.orientation=new c(0,0,0,1)}function Ol(){}function Dl(t){var e;switch(t.code){case FileError.QUOTA_EXCEEDED_ERR:e="QUOTA_EXCEEDED_ERR";break;case FileError.NOT_FOUND_ERR:e="NOT_FOUND_ERR";break;case FileError.SECURITY_ERR:e="SECURITY_ERR";break;case FileError.INVALID_MODIFICATION_ERR:e="INVALID_MODIFICATION_ERR";break;case FileError.INVALID_STATE_ERR:e="INVALID_STATE_ERR";break;default:e="Unknown Error"}throw new Error(e)}function zl(t,e,r,n,i){vv.root.getFile(t,{create:!n},function(t){t.createWriter(function(t){var o=new Blob([e],{type:r?"octet/stream":"text/plain"});n?(t.onwriteend=function(){i()},t.seek(t.length),t.write(o)):(t.onwriteend=function(){0===t.length&&e.length>0?t.write(o):i()},t.truncate(0))},Dl)},Dl)}function kl(){}function Fl(t){for(var e=[],r=0,n=t.length;r=0&&(t=t.substr(0,e)),t}function tu(t){if("string"==typeof t)if(t.match(/^[0-9A-Z]{4}$/i))t=t.toUpperCase();else if(t.match(/^data\/[0-9A-Z]{4}\.pdb$/i))t=t.substr(5,4).toUpperCase();else{var e=document.createElement("a");e.href=t,t=e.href}return t}function eu(t){var e=!1;return t.forEachComponent(function(t){t.forEachResidue(function(t){t._isValid&&(e=!0)})}),e}function ru(t,e,r){r?t.debug(e+"... "+Math.floor(100*r)+"%"):t.debug(e+"...")}function nu(t){Si.call(this),this._opts=wu.merge({settingsCookie:"settings",cookiePath:"/"},t),this._gfx=null,this._container=t&&t.container||document.body,this._containerRoot=this._container,this._running=!1,this._halting=!1,this._building=!1,this._needRender=!0,this._hotKeysEnabled=!0,this.settings=_f;var e=ff;e.console=!1,e.level="info",this.logger=e,this._cookies=new Kl(this),this._loadSettings(),t&&t.settings&&this.settings.override(t.settings),this._spinner=null,this._loader=null,this._animInterval=null,this._visuals={},this._curVisualName=null,this._objects=[],this._sourceWindow=null,this._fileSource=null,this._fileSourceAnim=null,this.reset(),this._repr&&e.debug("Selected "+this._repr.mode.name+" mode with "+this._repr.colorer.name+" colorer.");var r=this;nu.registeredPlugins.forEach(function(t){t.call(r)})}function iu(t,e,r,n){return new Promise(function(i,o){if(e=e||{},t instanceof File&&t.name.match(/.man$/i)&&(e.binary=!0,e.animation=!0),t instanceof File&&(t.name.match(/.mmtf$/i)||t.name.match(/.ccp4$/i))?e.binary=!0:wu.isString(t)&&t.match(/.mmtf$/i)&&(e.binary=!0),!e.mdFile&&!e.fileType&&"string"==typeof t){var a=t.match(/^(?:\s*([+\w]+)\s*:)?\s*(.*)$/);if(a){var s=a[2].trim(),c=a[1];switch(c){case"pubchem":case"pubchem+json":c="pubchem+json",t="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/"+encodeURIComponent(s)+"/JSON?record_type=3d",e.sourceType="url",e.fileName=s+".json";break;default:if(s.match(/^\w{4}$/i))switch(c=c||"pdb"){case"mmtf":t="http://mmtf.rcsb.org/v1.0/full/"+s,e.sourceType="url";break;case"cif":case"pdb":t="http://files.rcsb.org/view/"+s+"."+c,e.sourceType="url"}else c=void 0}c&&(e.fileType=c)}}"mmtf"===e.fileType&&(e.binary=!0);var l=qg.loaders.create(n,t,e),u=wu.get(e,"preset.expression");if(!wu.isUndefined(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit","draft.waterBondingHack"],p=0,f=h.length;p * Copyright JS Foundation and other contributors @@ -11,7 +11,7 @@ function go(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice( * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -(function(){function r(t,e){return t.set(e[0],e[1]),t}function n(t,e){return t.add(e),t}function i(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function o(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function h(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function z(t,e){for(var r=t.length;r--&&b(e,t[r],0)>-1;);return r}function F(t,e){for(var r=t.length,n=0;r--;)t[r]===e&&++n;return n}function k(t){return"\\"+Sr[t]}function U(t,e){return null==t?et:t[e]}function B(t){return dr.test(t)}function V(t){return mr.test(t)}function j(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}function G(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function W(t,e){return function(r){return t(e(r))}}function H(t,e){for(var r=-1,n=t.length,i=0,o=[];++r>>1,zt=[["ary",xt],["bind",ft],["bindKey",dt],["curry",gt],["curryRight",vt],["flip",wt],["partial",yt],["partialRight",_t],["rearg",bt]],Ft="[object Arguments]",kt="[object Array]",Ut="[object AsyncFunction]",Bt="[object Boolean]",Vt="[object Date]",jt="[object DOMException]",Gt="[object Error]",Wt="[object Function]",Ht="[object GeneratorFunction]",Xt="[object Map]",Yt="[object Number]",qt="[object Null]",$t="[object Object]",Zt="[object Proxy]",Kt="[object RegExp]",Qt="[object Set]",Jt="[object String]",te="[object Symbol]",ee="[object Undefined]",re="[object WeakMap]",ne="[object WeakSet]",ie="[object ArrayBuffer]",oe="[object DataView]",ae="[object Float32Array]",se="[object Float64Array]",ce="[object Int8Array]",le="[object Int16Array]",ue="[object Int32Array]",he="[object Uint8Array]",pe="[object Uint8ClampedArray]",fe="[object Uint16Array]",de="[object Uint32Array]",me=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,ve=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ye=/&(?:amp|lt|gt|quot|#39);/g,_e=/[&<>"']/g,xe=RegExp(ye.source),be=RegExp(_e.source),we=/<%-([\s\S]+?)%>/g,Se=/<%([\s\S]+?)%>/g,Me=/<%=([\s\S]+?)%>/g,Ae=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ee=/^\w*$/,Ce=/^\./,Te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pe=/[\\^$.*+?()[\]{}|]/g,Le=RegExp(Pe.source),Re=/^\s+|\s+$/g,Ne=/^\s+/,Ie=/\s+$/,Oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,De=/\{\n\/\* \[wrapped with (.+)\] \*/,ze=/,? & /,Fe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ke=/\\(\\)?/g,Ue=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Be=/\w*$/,Ve=/^[-+]0x[0-9a-f]+$/i,je=/^0b[01]+$/i,Ge=/^\[object .+?Constructor\]$/,We=/^0o[0-7]+$/i,He=/^(?:0|[1-9]\d*)$/,Xe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ye=/($^)/,qe=/['\n\r\u2028\u2029\\]/g,$e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ze="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ke="["+Ze+"]",Qe="["+$e+"]",Je="[a-z\\xdf-\\xf6\\xf8-\\xff]",tr="[^\\ud800-\\udfff"+Ze+"\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",er="\\ud83c[\\udffb-\\udfff]",rr="(?:\\ud83c[\\udde6-\\uddff]){2}",nr="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="[A-Z\\xc0-\\xd6\\xd8-\\xde]",or="(?:"+Je+"|"+tr+")",ar="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",sr="[\\ufe0e\\ufe0f]?"+ar+("(?:\\u200d(?:"+["[^\\ud800-\\udfff]",rr,nr].join("|")+")[\\ufe0e\\ufe0f]?"+ar+")*"),cr="(?:"+["[\\u2700-\\u27bf]",rr,nr].join("|")+")"+sr,lr="(?:"+["[^\\ud800-\\udfff]"+Qe+"?",Qe,rr,nr,"[\\ud800-\\udfff]"].join("|")+")",ur=RegExp("['’]","g"),hr=RegExp(Qe,"g"),pr=RegExp(er+"(?="+er+")|"+lr+sr,"g"),fr=RegExp([ir+"?"+Je+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Ke,ir,"$"].join("|")+")","(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Ke,ir+or,"$"].join("|")+")",ir+"?"+or+"+(?:['’](?:d|ll|m|re|s|t|ve))?",ir+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)","\\d+",cr].join("|"),"g"),dr=RegExp("[\\u200d\\ud800-\\udfff"+$e+"\\ufe0e\\ufe0f]"),mr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,gr=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],vr=-1,yr={};yr[ae]=yr[se]=yr[ce]=yr[le]=yr[ue]=yr[he]=yr[pe]=yr[fe]=yr[de]=!0,yr[Ft]=yr[kt]=yr[ie]=yr[Bt]=yr[oe]=yr[Vt]=yr[Gt]=yr[Wt]=yr[Xt]=yr[Yt]=yr[$t]=yr[Kt]=yr[Qt]=yr[Jt]=yr[re]=!1;var _r={};_r[Ft]=_r[kt]=_r[ie]=_r[oe]=_r[Bt]=_r[Vt]=_r[ae]=_r[se]=_r[ce]=_r[le]=_r[ue]=_r[Xt]=_r[Yt]=_r[$t]=_r[Kt]=_r[Qt]=_r[Jt]=_r[te]=_r[he]=_r[pe]=_r[fe]=_r[de]=!0,_r[Gt]=_r[Wt]=_r[re]=!1;var xr={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},br={"&":"&","<":"<",">":">",'"':""","'":"'"},wr={"&":"&","<":"<",">":">",""":'"',"'":"'"},Sr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mr=parseFloat,Ar=parseInt,Er="object"==typeof bu&&bu&&bu.Object===Object&&bu,Cr="object"==typeof self&&self&&self.Object===Object&&self,Tr=Er||Cr||Function("return this")(),Pr=e&&!e.nodeType&&e,Lr=Pr&&!0&&t&&!t.nodeType&&t,Rr=Lr&&Lr.exports===Pr,Nr=Rr&&Er.process,Ir=function(){try{return Nr&&Nr.binding&&Nr.binding("util")}catch(t){}}(),Or=Ir&&Ir.isArrayBuffer,Dr=Ir&&Ir.isDate,zr=Ir&&Ir.isMap,Fr=Ir&&Ir.isRegExp,kr=Ir&&Ir.isSet,Ur=Ir&&Ir.isTypedArray,Br=A("length"),Vr=E(xr),jr=E(br),Gr=E(wr),Wr=function t(e){function v(t){if(ea(t)&&!Wc(t)&&!(t instanceof Q)){if(t instanceof q)return t;if(Wa.call(t,"__wrapped__"))return Ao(t)}return new q(t)}function E(){}function q(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=et}function Q(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}function J(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function fr(t,e,r,n,i,o){var s,c=e&ct,l=e<,u=e&ut;if(r&&(s=i?r(t,n,i,o):r(t)),s!==et)return s;if(!ta(t))return t;var h=Wc(t);if(h){if(s=Qi(t),!c)return ai(t,s)}else{var p=tc(t),f=p==Wt||p==Ht;if(Xc(t))return qn(t,c);if(p==$t||p==Ft||f&&!i){if(s=l||f?{}:Ji(t),!c)return l?li(t,sr(s,t)):ci(t,ar(s,t))}else{if(!_r[p])return i?t:{};s=to(t,p,fr,c)}}o||(o=new Ke);var d=o.get(t);if(d)return d;o.set(t,s);var m=u?l?Vi:Bi:l?ga:ma,g=h?et:m(t);return a(g||t,function(n,i){g&&(n=t[i=n]),nr(s,i,fr(n,e,r,i,t,o))}),s}function dr(t){var e=ma(t);return function(r){return mr(r,t,e)}}function mr(t,e,r){var n=r.length;if(null==t)return!n;for(t=Da(t);n--;){var i=r[n],o=e[i],a=t[i];if(a===et&&!(i in t)||!o(a))return!1}return!0}function xr(t,e,r){if("function"!=typeof t)throw new ka(it);return nc(function(){t.apply(et,r)},e)}function br(t,e,r,n){var i=-1,o=u,a=!0,s=t.length,c=[],l=e.length;if(!s)return c;r&&(e=p(e,N(r))),n?(o=h,a=!1):e.length>=rt&&(o=O,a=!1,e=new Ze(e));t:for(;++ii?0:i+r),(n=n===et||n>i?i:ca(n))<0&&(n+=i),n=r>n?0:la(n);r0&&r(s)?e>1?Pr(s,e-1,r,n,i):f(i,s):n||(i[i.length]=s)}return i}function Lr(t,e){return t&&Ws(t,e,ma)}function Nr(t,e){return t&&Hs(t,e,ma)}function Ir(t,e){return l(e,function(e){return Ko(t[e])})}function Br(t,e){for(var r=0,n=(e=Xn(e,t)).length;null!=t&&re}function qr(t,e){return null!=t&&Wa.call(t,e)}function $r(t,e){return null!=t&&e in Da(t)}function Zr(t,e,r){return t>=xs(e,r)&&t<_s(e,r)}function Kr(t,e,r){for(var n=r?h:u,i=t[0].length,o=t.length,a=o,s=La(o),c=1/0,l=[];a--;){var f=t[a];a&&e&&(f=p(f,N(e))),c=xs(f.length,c),s[a]=!r&&(e||i>=120&&f.length>=120)?new Ze(a&&f):et}f=t[0];var d=-1,m=s[0];t:for(;++d-1;)s!==t&&is.call(s,c,1),is.call(t,c,1);return t}function bn(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;no(i)?is.call(t,i,1):kn(t,i)}}return t}function wn(t,e){return t+fs(Ss()*(e-t+1))}function Sn(t,e,r,n){for(var i=-1,o=_s(ps((e-t)/(r||1)),0),a=La(o);o--;)a[n?o:++i]=t,t+=r;return a}function Mn(t,e){var r="";if(!t||e<1||e>Lt)return r;do{e%2&&(r+=t),(e=fs(e/2))&&(t+=t)}while(e);return r}function An(t,e){return ic(go(t,e,Sa),t+"")}function En(t){return Je(ya(t))}function Cn(t,e){var r=ya(t);return bo(r,pr(e,0,r.length))}function Tn(t,e,r,n){if(!ta(t))return t;for(var i=-1,o=(e=Xn(e,t)).length,a=o-1,s=t;null!=s&&++ii?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=La(i);++n>>1,a=t[o];null!==a&&!oa(a)&&(r?a<=e:a=rt){var l=e?null:Zs(t);if(l)return X(l);a=!1,i=O,c=new Ze}else c=e?[]:s;t:for(;++n=n?t:Ln(t,e,r)}function qn(t,e){if(e)return t.slice();var r=t.length,n=ts?ts(r):new t.constructor(r);return t.copy(n),n}function $n(t){var e=new t.constructor(t.byteLength);return new Ja(e).set(new Ja(t)),e}function Zn(t,e){var r=e?$n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function Kn(t,e,n){return d(e?n(G(t),ct):G(t),r,new t.constructor)}function Qn(t){var e=new t.constructor(t.source,Be.exec(t));return e.lastIndex=t.lastIndex,e}function Jn(t,e,r){return d(e?r(X(t),ct):X(t),n,new t.constructor)}function ti(t){return Us?Da(Us.call(t)):{}}function ei(t,e){var r=e?$n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function ri(t,e){if(t!==e){var r=t!==et,n=null===t,i=t===t,o=oa(t),a=e!==et,s=null===e,c=e===e,l=oa(e);if(!s&&!l&&!o&&t>e||o&&a&&c&&!s&&!l||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!l&&t=s?c:c*("desc"==r[n]?-1:1)}return t.index-e.index}function ii(t,e,r,n){for(var i=-1,o=t.length,a=r.length,s=-1,c=e.length,l=_s(o-a,0),u=La(c+l),h=!n;++s1?r[i-1]:et,a=i>2?r[2]:et;for(o=t.length>3&&"function"==typeof o?(i--,o):et,a&&io(r[0],r[1],a)&&(o=i<3?et:o,i=1),e=Da(e);++n-1?i[o?e[a]:a]:et}}function xi(t){return Ui(function(e){var r=e.length,n=r,i=q.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new ka(it);if(i&&!a&&"wrapper"==ji(o))var a=new q([],!0)}for(n=a?n:r;++n1&&y.reverse(),h&&cs))return!1;var l=o.get(t);if(l&&o.get(e))return l==e;var u=-1,h=!0,p=r&pt?new Ze:et;for(o.set(t,e),o.set(e,t);++u1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Oe,"{\n/* [wrapped with "+e+"] */\n")}function ro(t){return Wc(t)||Gc(t)||!!(os&&t&&t[os])}function no(t,e){return!!(e=null==e?Lt:e)&&("number"==typeof t||He.test(t))&&t>-1&&t%1==0&&t0){if(++e>=At)return arguments[0]}else e=0;return t.apply(et,arguments)}}function bo(t,e){var r=-1,n=t.length,i=n-1;for(e=e===et?n:e;++r0&&(r=e.apply(this,arguments)),t<=1&&(e=et),r}}function jo(t,e,r){var n=Ni(t,gt,et,et,et,et,et,e=r?et:e);return n.placeholder=jo.placeholder,n}function Go(t,e,r){var n=Ni(t,vt,et,et,et,et,et,e=r?et:e);return n.placeholder=Go.placeholder,n}function Wo(t,e,r){function n(e){var r=u,n=h;return u=h=et,g=e,f=t.apply(n,r)}function i(t){return g=t,d=nc(s,e),v?n(t):f}function o(t){var r=t-g,n=e-(t-m);return y?xs(n,p-r):n}function a(t){var r=t-m,n=t-g;return m===et||r>=e||r<0||y&&n>=p}function s(){var t=Nc();if(a(t))return c(t);d=nc(s,o(t))}function c(t){return d=et,_&&u?n(t):(u=h=et,f)}function l(){var t=Nc(),r=a(t);if(u=arguments,h=this,m=t,r){if(d===et)return i(m);if(y)return d=nc(s,e),n(m)}return d===et&&(d=nc(s,e)),f}var u,h,p,f,d,m,g=0,v=!1,y=!1,_=!0;if("function"!=typeof t)throw new ka(it);return e=ua(e)||0,ta(r)&&(v=!!r.leading,p=(y="maxWait"in r)?_s(ua(r.maxWait)||0,e):p,_="trailing"in r?!!r.trailing:_),l.cancel=function(){d!==et&&$s(d),g=0,u=m=h=d=et},l.flush=function(){return d===et?f:c(Nc())},l}function Ho(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ka(it);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Ho.Cache||$e),r}function Xo(t){if("function"!=typeof t)throw new ka(it);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Yo(t,e){return t===e||t!==t&&e!==e}function qo(t){return null!=t&&Jo(t.length)&&!Ko(t)}function $o(t){return ea(t)&&qo(t)}function Zo(t){if(!ea(t))return!1;var e=Xr(t);return e==Gt||e==jt||"string"==typeof t.message&&"string"==typeof t.name&&!na(t)}function Ko(t){if(!ta(t))return!1;var e=Xr(t);return e==Wt||e==Ht||e==Ut||e==Zt}function Qo(t){return"number"==typeof t&&t==ca(t)}function Jo(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Lt}function ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ea(t){return null!=t&&"object"==typeof t}function ra(t){return"number"==typeof t||ea(t)&&Xr(t)==Yt}function na(t){if(!ea(t)||Xr(t)!=$t)return!1;var e=es(t);if(null===e)return!0;var r=Wa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ga.call(r)==qa}function ia(t){return"string"==typeof t||!Wc(t)&&ea(t)&&Xr(t)==Jt}function oa(t){return"symbol"==typeof t||ea(t)&&Xr(t)==te}function aa(t){if(!t)return[];if(qo(t))return ia(t)?K(t):ai(t);if(as&&t[as])return j(t[as]());var e=tc(t);return(e==Xt?G:e==Qt?X:ya)(t)}function sa(t){return t?(t=ua(t))===Pt||t===-Pt?(t<0?-1:1)*Rt:t===t?t:0:0===t?t:0}function ca(t){var e=sa(t),r=e%1;return e===e?r?e-r:e:0}function la(t){return t?pr(ca(t),0,It):0}function ua(t){if("number"==typeof t)return t;if(oa(t))return Nt;if(ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Re,"");var r=je.test(t);return r||We.test(t)?Ar(t.slice(2),r?2:8):Ve.test(t)?Nt:+t}function ha(t){return si(t,ga(t))}function pa(t){return null==t?"":zn(t)}function fa(t,e,r){var n=null==t?et:Br(t,e);return n===et?r:n}function da(t,e){return null!=t&&Ki(t,e,$r)}function ma(t){return qo(t)?Qe(t):sn(t)}function ga(t){return qo(t)?Qe(t,!0):cn(t)}function va(t,e){if(null==t)return{};var r=p(Vi(t),function(t){return[t]});return e=Wi(e),yn(t,r,function(t,r){return e(t,r[0])})}function ya(t){return null==t?[]:I(t,ma(t))}function _a(t){return Sl(pa(t).toLowerCase())}function xa(t){return(t=pa(t))&&t.replace(Xe,Vr).replace(hr,"")}function ba(t,e,r){return t=pa(t),(e=r?et:e)===et?V(t)?tt(t):y(t):t.match(e)||[]}function wa(t){return function(){return t}}function Sa(t){return t}function Ma(t){return an("function"==typeof t?t:fr(t,ct))}function Aa(t,e,r){var n=ma(e),i=Ir(e,n);null!=r||ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Ir(e,ma(e)));var o=!(ta(r)&&"chain"in r&&!r.chain),s=Ko(t);return a(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=ai(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,f([this.value()],arguments))})}),t}function Ea(){}function Ca(t){return oo(t)?A(wo(t)):_n(t)}function Ta(){return[]}function Pa(){return!1}var La=(e=null==e?Tr:Wr.defaults(Tr.Object(),e,Wr.pick(Tr,gr))).Array,Ra=e.Date,Na=e.Error,Ia=e.Function,Oa=e.Math,Da=e.Object,za=e.RegExp,Fa=e.String,ka=e.TypeError,Ua=La.prototype,Ba=Ia.prototype,Va=Da.prototype,ja=e["__core-js_shared__"],Ga=Ba.toString,Wa=Va.hasOwnProperty,Ha=0,Xa=function(){var t=/[^.]+$/.exec(ja&&ja.keys&&ja.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ya=Va.toString,qa=Ga.call(Da),$a=Tr._,Za=za("^"+Ga.call(Wa).replace(Pe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ka=Rr?e.Buffer:et,Qa=e.Symbol,Ja=e.Uint8Array,ts=Ka?Ka.allocUnsafe:et,es=W(Da.getPrototypeOf,Da),rs=Da.create,ns=Va.propertyIsEnumerable,is=Ua.splice,os=Qa?Qa.isConcatSpreadable:et,as=Qa?Qa.iterator:et,ss=Qa?Qa.toStringTag:et,cs=function(){try{var t=Yi(Da,"defineProperty");return t({},"",{}),t}catch(t){}}(),ls=e.clearTimeout!==Tr.clearTimeout&&e.clearTimeout,us=Ra&&Ra.now!==Tr.Date.now&&Ra.now,hs=e.setTimeout!==Tr.setTimeout&&e.setTimeout,ps=Oa.ceil,fs=Oa.floor,ds=Da.getOwnPropertySymbols,ms=Ka?Ka.isBuffer:et,gs=e.isFinite,vs=Ua.join,ys=W(Da.keys,Da),_s=Oa.max,xs=Oa.min,bs=Ra.now,ws=e.parseInt,Ss=Oa.random,Ms=Ua.reverse,As=Yi(e,"DataView"),Es=Yi(e,"Map"),Cs=Yi(e,"Promise"),Ts=Yi(e,"Set"),Ps=Yi(e,"WeakMap"),Ls=Yi(Da,"create"),Rs=Ps&&new Ps,Ns={},Is=So(As),Os=So(Es),Ds=So(Cs),zs=So(Ts),Fs=So(Ps),ks=Qa?Qa.prototype:et,Us=ks?ks.valueOf:et,Bs=ks?ks.toString:et,Vs=function(){function t(){}return function(e){if(!ta(e))return{};if(rs)return rs(e);t.prototype=e;var r=new t;return t.prototype=et,r}}();v.templateSettings={escape:we,evaluate:Se,interpolate:Me,variable:"",imports:{_:v}},v.prototype=E.prototype,v.prototype.constructor=v,q.prototype=Vs(E.prototype),q.prototype.constructor=q,Q.prototype=Vs(E.prototype),Q.prototype.constructor=Q,J.prototype.clear=function(){this.__data__=Ls?Ls(null):{},this.size=0},J.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},J.prototype.get=function(t){var e=this.__data__;if(Ls){var r=e[t];return r===ot?et:r}return Wa.call(e,t)?e[t]:et},J.prototype.has=function(t){var e=this.__data__;return Ls?e[t]!==et:Wa.call(e,t)},J.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ls&&e===et?ot:e,this},Fe.prototype.clear=function(){this.__data__=[],this.size=0},Fe.prototype.delete=function(t){var e=this.__data__,r=ir(e,t);return!(r<0||(r==e.length-1?e.pop():is.call(e,r,1),--this.size,0))},Fe.prototype.get=function(t){var e=this.__data__,r=ir(e,t);return r<0?et:e[r][1]},Fe.prototype.has=function(t){return ir(this.__data__,t)>-1},Fe.prototype.set=function(t,e){var r=this.__data__,n=ir(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},$e.prototype.clear=function(){this.size=0,this.__data__={hash:new J,map:new(Es||Fe),string:new J}},$e.prototype.delete=function(t){var e=Hi(this,t).delete(t);return this.size-=e?1:0,e},$e.prototype.get=function(t){return Hi(this,t).get(t)},$e.prototype.has=function(t){return Hi(this,t).has(t)},$e.prototype.set=function(t,e){var r=Hi(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Ze.prototype.add=Ze.prototype.push=function(t){return this.__data__.set(t,ot),this},Ze.prototype.has=function(t){return this.__data__.has(t)},Ke.prototype.clear=function(){this.__data__=new Fe,this.size=0},Ke.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ke.prototype.get=function(t){return this.__data__.get(t)},Ke.prototype.has=function(t){return this.__data__.has(t)},Ke.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Fe){var n=r.__data__;if(!Es||n.length1?t[e-1]:et;return r="function"==typeof r?(t.pop(),r):et,Oo(t,r)}),Sc=Ui(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return lr(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Q&&no(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:zo,args:[i],thisArg:et}),new q(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(et),t})):this.thru(i)}),Mc=ui(function(t,e,r){Wa.call(t,r)?++t[r]:cr(t,r,1)}),Ac=_i(Eo),Ec=_i(Co),Cc=ui(function(t,e,r){Wa.call(t,r)?t[r].push(e):cr(t,r,[e])}),Tc=An(function(t,e,r){var n=-1,o="function"==typeof e,a=qo(t)?La(t.length):[];return js(t,function(t){a[++n]=o?i(e,t,r):Jr(t,e,r)}),a}),Pc=ui(function(t,e,r){cr(t,r,e)}),Lc=ui(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),Rc=An(function(t,e){if(null==t)return[];var r=e.length;return r>1&&io(t,e[0],e[1])?e=[]:r>2&&io(e[0],e[1],e[2])&&(e=[e[0]]),gn(t,Pr(e,1),[])}),Nc=us||function(){return Tr.Date.now()},Ic=An(function(t,e,r){var n=ft;if(r.length){var i=H(r,Gi(Ic));n|=yt}return Ni(t,n,e,r,i)}),Oc=An(function(t,e,r){var n=ft|dt;if(r.length){var i=H(r,Gi(Oc));n|=yt}return Ni(e,n,t,r,i)}),Dc=An(function(t,e){return xr(t,1,e)}),zc=An(function(t,e,r){return xr(t,ua(e)||0,r)});Ho.Cache=$e;var Fc=qs(function(t,e){var r=(e=1==e.length&&Wc(e[0])?p(e[0],N(Wi())):p(Pr(e,1),N(Wi()))).length;return An(function(n){for(var o=-1,a=xs(n.length,r);++o=e}),Gc=tn(function(){return arguments}())?tn:function(t){return ea(t)&&Wa.call(t,"callee")&&!ns.call(t,"callee")},Wc=La.isArray,Hc=Or?N(Or):function(t){return ea(t)&&Xr(t)==ie},Xc=ms||Pa,Yc=Dr?N(Dr):function(t){return ea(t)&&Xr(t)==Vt},qc=zr?N(zr):function(t){return ea(t)&&tc(t)==Xt},$c=Fr?N(Fr):function(t){return ea(t)&&Xr(t)==Kt},Zc=kr?N(kr):function(t){return ea(t)&&tc(t)==Qt},Kc=Ur?N(Ur):function(t){return ea(t)&&Jo(t.length)&&!!yr[Xr(t)]},Qc=Ti(ln),Jc=Ti(function(t,e){return t<=e}),tl=hi(function(t,e){if(lo(e)||qo(e))si(e,ma(e),t);else for(var r in e)Wa.call(e,r)&&nr(t,r,e[r])}),el=hi(function(t,e){si(e,ga(e),t)}),rl=hi(function(t,e,r,n){si(e,ga(e),t,n)}),nl=hi(function(t,e,r,n){si(e,ma(e),t,n)}),il=Ui(lr),ol=An(function(t){return t.push(et,Ii),i(rl,et,t)}),al=An(function(t){return t.push(et,Oi),i(hl,et,t)}),sl=wi(function(t,e,r){t[e]=r},wa(Sa)),cl=wi(function(t,e,r){Wa.call(t,e)?t[e].push(r):t[e]=[r]},Wi),ll=An(Jr),ul=hi(function(t,e,r){fn(t,e,r)}),hl=hi(function(t,e,r,n){fn(t,e,r,n)}),pl=Ui(function(t,e){var r={};if(null==t)return r;var n=!1;e=p(e,function(e){return e=Xn(e,t),n||(n=e.length>1),e}),si(t,Vi(t),r),n&&(r=fr(r,ct|lt|ut,Di));for(var i=e.length;i--;)kn(r,e[i]);return r}),fl=Ui(function(t,e){return null==t?{}:vn(t,e)}),dl=Ri(ma),ml=Ri(ga),gl=gi(function(t,e,r){return e=e.toLowerCase(),t+(r?_a(e):e)}),vl=gi(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),yl=gi(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),_l=mi("toLowerCase"),xl=gi(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),bl=gi(function(t,e,r){return t+(r?" ":"")+Sl(e)}),wl=gi(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Sl=mi("toUpperCase"),Ml=An(function(t,e){try{return i(t,et,e)}catch(t){return Zo(t)?t:new Na(t)}}),Al=Ui(function(t,e){return a(e,function(e){e=wo(e),cr(t,e,Ic(t[e],t))}),t}),El=xi(),Cl=xi(!0),Tl=An(function(t,e){return function(r){return Jr(r,t,e)}}),Pl=An(function(t,e){return function(r){return Jr(t,r,e)}}),Ll=Mi(p),Rl=Mi(c),Nl=Mi(g),Il=Ci(),Ol=Ci(!0),Dl=Si(function(t,e){return t+e},0),zl=Li("ceil"),Fl=Si(function(t,e){return t/e},1),kl=Li("floor"),Ul=Si(function(t,e){return t*e},1),Bl=Li("round"),Vl=Si(function(t,e){return t-e},0);return v.after=function(t,e){if("function"!=typeof e)throw new ka(it);return t=ca(t),function(){if(--t<1)return e.apply(this,arguments)}},v.ary=Bo,v.assign=tl,v.assignIn=el,v.assignInWith=rl,v.assignWith=nl,v.at=il,v.before=Vo,v.bind=Ic,v.bindAll=Al,v.bindKey=Oc,v.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Wc(t)?t:[t]},v.chain=Do,v.chunk=function(t,e,r){e=(r?io(t,e,r):e===et)?1:_s(ca(e),0);var n=null==t?0:t.length;if(!n||e<1)return[];for(var i=0,o=0,a=La(ps(n/e));i>>0)?(t=pa(t))&&("string"==typeof e||null!=e&&!$c(e))&&!(e=zn(e))&&B(t)?Yn(K(t),0,r):t.split(e,r):[]},v.spread=function(t,e){if("function"!=typeof t)throw new ka(it);return e=null==e?0:_s(ca(e),0),An(function(r){var n=r[e],o=Yn(r,0,e);return n&&f(o,n),i(t,this,o)})},v.tail=function(t){var e=null==t?0:t.length;return e?Ln(t,1,e):[]},v.take=function(t,e,r){return t&&t.length?(e=r||e===et?1:ca(e),Ln(t,0,e<0?0:e)):[]},v.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?(e=r||e===et?1:ca(e),e=n-e,Ln(t,e<0?0:e,n)):[]},v.takeRightWhile=function(t,e){return t&&t.length?Bn(t,Wi(e,3),!1,!0):[]},v.takeWhile=function(t,e){return t&&t.length?Bn(t,Wi(e,3)):[]},v.tap=function(t,e){return e(t),t},v.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ka(it);return ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Wo(t,e,{leading:n,maxWait:e,trailing:i})},v.thru=zo,v.toArray=aa,v.toPairs=dl,v.toPairsIn=ml,v.toPath=function(t){return Wc(t)?p(t,wo):oa(t)?[t]:ai(oc(pa(t)))},v.toPlainObject=ha,v.transform=function(t,e,r){var n=Wc(t),i=n||Xc(t)||Kc(t);if(e=Wi(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:ta(t)&&Ko(o)?Vs(es(t)):{}}return(i?a:Lr)(t,function(t,n,i){return e(r,t,n,i)}),r},v.unary=function(t){return Bo(t,1)},v.union=dc,v.unionBy=mc,v.unionWith=gc,v.uniq=function(t){return t&&t.length?Fn(t):[]},v.uniqBy=function(t,e){return t&&t.length?Fn(t,Wi(e,2)):[]},v.uniqWith=function(t,e){return e="function"==typeof e?e:et,t&&t.length?Fn(t,et,e):[]},v.unset=function(t,e){return null==t||kn(t,e)},v.unzip=Io,v.unzipWith=Oo,v.update=function(t,e,r){return null==t?t:Un(t,e,Hn(r))},v.updateWith=function(t,e,r,n){return n="function"==typeof n?n:et,null==t?t:Un(t,e,Hn(r),n)},v.values=ya,v.valuesIn=function(t){return null==t?[]:I(t,ga(t))},v.without=vc,v.words=ba,v.wrap=function(t,e){return kc(Hn(e),t)},v.xor=yc,v.xorBy=_c,v.xorWith=xc,v.zip=bc,v.zipObject=function(t,e){return Gn(t||[],e||[],nr)},v.zipObjectDeep=function(t,e){return Gn(t||[],e||[],Tn)},v.zipWith=wc,v.entries=dl,v.entriesIn=ml,v.extend=el,v.extendWith=rl,Aa(v,v),v.add=Dl,v.attempt=Ml,v.camelCase=gl,v.capitalize=_a,v.ceil=zl,v.clamp=function(t,e,r){return r===et&&(r=e,e=et),r!==et&&(r=(r=ua(r))===r?r:0),e!==et&&(e=(e=ua(e))===e?e:0),pr(ua(t),e,r)},v.clone=function(t){return fr(t,ut)},v.cloneDeep=function(t){return fr(t,ct|ut)},v.cloneDeepWith=function(t,e){return e="function"==typeof e?e:et,fr(t,ct|ut,e)},v.cloneWith=function(t,e){return e="function"==typeof e?e:et,fr(t,ut,e)},v.conformsTo=function(t,e){return null==e||mr(t,e,ma(e))},v.deburr=xa,v.defaultTo=function(t,e){return null==t||t!==t?e:t},v.divide=Fl,v.endsWith=function(t,e,r){t=pa(t),e=zn(e);var n=t.length,i=r=r===et?n:pr(ca(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},v.eq=Yo,v.escape=function(t){return(t=pa(t))&&be.test(t)?t.replace(_e,jr):t},v.escapeRegExp=function(t){return(t=pa(t))&&Le.test(t)?t.replace(Pe,"\\$&"):t},v.every=function(t,e,r){var n=Wc(t)?c:wr;return r&&io(t,e,r)&&(e=et),n(t,Wi(e,3))},v.find=Ac,v.findIndex=Eo,v.findKey=function(t,e){return _(t,Wi(e,3),Lr)},v.findLast=Ec,v.findLastIndex=Co,v.findLastKey=function(t,e){return _(t,Wi(e,3),Nr)},v.floor=kl,v.forEach=Fo,v.forEachRight=ko,v.forIn=function(t,e){return null==t?t:Ws(t,Wi(e,3),ga)},v.forInRight=function(t,e){return null==t?t:Hs(t,Wi(e,3),ga)},v.forOwn=function(t,e){return t&&Lr(t,Wi(e,3))},v.forOwnRight=function(t,e){return t&&Nr(t,Wi(e,3))},v.get=fa,v.gt=Vc,v.gte=jc,v.has=function(t,e){return null!=t&&Ki(t,e,qr)},v.hasIn=da,v.head=Po,v.identity=Sa,v.includes=function(t,e,r,n){t=qo(t)?t:ya(t),r=r&&!n?ca(r):0;var i=t.length;return r<0&&(r=_s(i+r,0)),ia(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&b(t,e,r)>-1},v.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:ca(r);return i<0&&(i=_s(n+i,0)),b(t,e,i)},v.inRange=function(t,e,r){return e=sa(e),r===et?(r=e,e=0):r=sa(r),t=ua(t),Zr(t,e,r)},v.invoke=ll,v.isArguments=Gc,v.isArray=Wc,v.isArrayBuffer=Hc,v.isArrayLike=qo,v.isArrayLikeObject=$o,v.isBoolean=function(t){return!0===t||!1===t||ea(t)&&Xr(t)==Bt},v.isBuffer=Xc,v.isDate=Yc,v.isElement=function(t){return ea(t)&&1===t.nodeType&&!na(t)},v.isEmpty=function(t){if(null==t)return!0;if(qo(t)&&(Wc(t)||"string"==typeof t||"function"==typeof t.splice||Xc(t)||Kc(t)||Gc(t)))return!t.length;var e=tc(t);if(e==Xt||e==Qt)return!t.size;if(lo(t))return!sn(t).length;for(var r in t)if(Wa.call(t,r))return!1;return!0},v.isEqual=function(t,e){return en(t,e)},v.isEqualWith=function(t,e,r){var n=(r="function"==typeof r?r:et)?r(t,e):et;return n===et?en(t,e,et,r):!!n},v.isError=Zo,v.isFinite=function(t){return"number"==typeof t&&gs(t)},v.isFunction=Ko,v.isInteger=Qo,v.isLength=Jo,v.isMap=qc,v.isMatch=function(t,e){return t===e||nn(t,e,Xi(e))},v.isMatchWith=function(t,e,r){return r="function"==typeof r?r:et,nn(t,e,Xi(e),r)},v.isNaN=function(t){return ra(t)&&t!=+t},v.isNative=function(t){if(ec(t))throw new Na(nt);return on(t)},v.isNil=function(t){return null==t},v.isNull=function(t){return null===t},v.isNumber=ra,v.isObject=ta,v.isObjectLike=ea,v.isPlainObject=na,v.isRegExp=$c,v.isSafeInteger=function(t){return Qo(t)&&t>=-Lt&&t<=Lt},v.isSet=Zc,v.isString=ia,v.isSymbol=oa,v.isTypedArray=Kc,v.isUndefined=function(t){return t===et},v.isWeakMap=function(t){return ea(t)&&tc(t)==re},v.isWeakSet=function(t){return ea(t)&&Xr(t)==ne},v.join=function(t,e){return null==t?"":vs.call(t,e)},v.kebabCase=vl,v.last=Lo,v.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==et&&(i=(i=ca(r))<0?_s(n+i,0):xs(i,n-1)),e===e?$(t,e,i):x(t,S,i,!0)},v.lowerCase=yl,v.lowerFirst=_l,v.lt=Qc,v.lte=Jc,v.max=function(t){return t&&t.length?Sr(t,Sa,Yr):et},v.maxBy=function(t,e){return t&&t.length?Sr(t,Wi(e,2),Yr):et},v.mean=function(t){return M(t,Sa)},v.meanBy=function(t,e){return M(t,Wi(e,2))},v.min=function(t){return t&&t.length?Sr(t,Sa,ln):et},v.minBy=function(t,e){return t&&t.length?Sr(t,Wi(e,2),ln):et},v.stubArray=Ta,v.stubFalse=Pa,v.stubObject=function(){return{}},v.stubString=function(){return""},v.stubTrue=function(){return!0},v.multiply=Ul,v.nth=function(t,e){return t&&t.length?mn(t,ca(e)):et},v.noConflict=function(){return Tr._===this&&(Tr._=$a),this},v.noop=Ea,v.now=Nc,v.pad=function(t,e,r){t=pa(t);var n=(e=ca(e))?Z(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Ai(fs(i),r)+t+Ai(ps(i),r)},v.padEnd=function(t,e,r){t=pa(t);var n=(e=ca(e))?Z(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Ss();return xs(t+i*(e-t+Mr("1e-"+((i+"").length-1))),e)}return wn(t,e)},v.reduce=function(t,e,r){var n=Wc(t)?d:C,i=arguments.length<3;return n(t,Wi(e,4),r,i,js)},v.reduceRight=function(t,e,r){var n=Wc(t)?m:C,i=arguments.length<3;return n(t,Wi(e,4),r,i,Gs)},v.repeat=function(t,e,r){return e=(r?io(t,e,r):e===et)?1:ca(e),Mn(pa(t),e)},v.replace=function(){var t=arguments,e=pa(t[0]);return t.length<3?e:e.replace(t[1],t[2])},v.result=function(t,e,r){var n=-1,i=(e=Xn(e,t)).length;for(i||(i=1,t=et);++nLt)return[];var r=It,n=xs(t,It);e=Wi(e),t-=It;for(var i=L(n,e);++r=o)return t;var s=r-Z(n);if(s<1)return n;var c=a?Yn(a,0,s).join(""):t.slice(0,s);if(i===et)return c+n;if(a&&(s+=c.length-s),$c(i)){if(t.slice(s).search(i)){var l,u=c;for(i.global||(i=za(i.source,pa(Be.exec(i))+"g")),i.lastIndex=0;l=i.exec(u);)var h=l.index;c=c.slice(0,h===et?s:h)}}else if(t.indexOf(zn(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},v.unescape=function(t){return(t=pa(t))&&xe.test(t)?t.replace(ye,Gr):t},v.uniqueId=function(t){var e=++Ha;return pa(t)+e},v.upperCase=wl,v.upperFirst=Sl,v.each=Fo,v.eachRight=ko,v.first=Po,Aa(v,function(){var t={};return Lr(v,function(e,r){Wa.call(v.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),v.VERSION="4.17.4",a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){v[t].placeholder=v}),a(["drop","take"],function(t,e){Q.prototype[t]=function(r){r=r===et?1:_s(ca(r),0);var n=this.__filtered__&&!e?new Q(this):this.clone();return n.__filtered__?n.__takeCount__=xs(r,n.__takeCount__):n.__views__.push({size:xs(r,It),type:t+(n.__dir__<0?"Right":"")}),n},Q.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==Ct||3==r;Q.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Wi(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),a(["head","last"],function(t,e){var r="take"+(e?"Right":"");Q.prototype[t]=function(){return this[r](1).value()[0]}}),a(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");Q.prototype[t]=function(){return this.__filtered__?new Q(this):this[r](1)}}),Q.prototype.compact=function(){return this.filter(Sa)},Q.prototype.find=function(t){return this.filter(t).head()},Q.prototype.findLast=function(t){return this.reverse().find(t)},Q.prototype.invokeMap=An(function(t,e){return"function"==typeof t?new Q(this):this.map(function(r){return Jr(r,t,e)})}),Q.prototype.reject=function(t){return this.filter(Xo(Wi(t)))},Q.prototype.slice=function(t,e){t=ca(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Q(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==et&&(r=(e=ca(e))<0?r.dropRight(-e):r.take(e-t)),r)},Q.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Q.prototype.toArray=function(){return this.take(It)},Lr(Q.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=v[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(v.prototype[e]=function(){var e=this.__wrapped__,a=n?[1]:arguments,s=e instanceof Q,c=a[0],l=s||Wc(e),u=function(t){var e=i.apply(v,f([t],a));return n&&h?e[0]:e};l&&r&&"function"==typeof c&&1!=c.length&&(s=l=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,m=s&&!p;if(!o&&l){e=m?e:new Q(this);var g=t.apply(e,a);return g.__actions__.push({func:zo,args:[u],thisArg:et}),new q(g,h)}return d&&m?t.apply(this,a):(g=this.thru(u),d?n?g.value()[0]:g.value():g)})}),a(["pop","push","shift","sort","splice","unshift"],function(t){var e=Ua[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);v.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Wc(i)?i:[],t)}return this[r](function(r){return e.apply(Wc(r)?r:[],t)})}}),Lr(Q.prototype,function(t,e){var r=v[e];if(r){var n=r.name+"";(Ns[n]||(Ns[n]=[])).push({name:e,func:r})}}),Ns[bi(et,dt).name]=[{name:"wrapper",func:et}],Q.prototype.clone=function(){var t=new Q(this.__wrapped__);return t.__actions__=ai(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=ai(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=ai(this.__views__),t},Q.prototype.reverse=function(){if(this.__filtered__){var t=new Q(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Q.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Wc(t),n=e<0,i=r?t.length:0,o=$i(0,i,this.__views__),a=o.start,s=o.end,c=s-a,l=n?s:a-1,u=this.__iteratees__,h=u.length,p=0,f=xs(c,this.__takeCount__);if(!r||!n&&i==c&&f==c)return Vn(t,this.__actions__);var d=[];t:for(;c--&&p=this.__values__.length;return{done:t,value:t?et:this.__values__[this.__index__++]}},v.prototype.plant=function(t){for(var e,r=this;r instanceof E;){var n=Ao(r);n.__index__=0,n.__values__=et,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},v.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Q){var e=t;return this.__actions__.length&&(e=new Q(this)),(e=e.reverse()).__actions__.push({func:zo,args:[No],thisArg:et}),new q(e,this.__chain__)}return this.thru(No)},v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=function(){return Vn(this.__wrapped__,this.__actions__)},v.prototype.first=v.prototype.head,as&&(v.prototype[as]=function(){return this}),v}();"function"==typeof et&&"object"==typeof et.amd&&et.amd?Tr._=Wr:Lr?((Lr.exports=Wr)._=Wr,Pr._=Wr):Tr._=Wr}).call(bu)});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]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>=4,r[i]=e[19===i?3&t|8:t]);return r.join("")}}(),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*Tp.DEG2RAD},radToDeg:function(t){return t*Tp.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}};n.prototype={constructor:n,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)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return 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(r,i){return void 0===t&&(t=new n,e=new n),t.set(r,r),e.set(i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.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,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}};var Pp=0;i.DEFAULT_IMAGE=void 0,i.DEFAULT_MAPPING=300,i.prototype={constructor:i,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 r=this.image;void 0===r.uuid&&(r.uuid=Tp.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.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")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case Lh:t.x=t.x-Math.floor(t.x);break;case Rh:t.x=t.x<0?0:1;break;case Nh: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 Lh:t.y=t.y-Math.floor(t.y);break;case Rh:t.y=t.y<0?0:1;break;case Nh: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(i.prototype,r.prototype),o.prototype={constructor:o,isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,o=t.elements,a=o[0],s=o[4],c=o[8],l=o[1],u=o[5],h=o[9],p=o[2],f=o[6],d=o[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+p)<.1&&Math.abs(h+f)<.1&&Math.abs(a+u+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(u+1)/2,v=(d+1)/2,y=(s+l)/4,_=(c+p)/4,x=(h+f)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(n=y/(r=Math.sqrt(m)),i=_/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(r=y/(n=Math.sqrt(g)),i=x/n):v<.01?(r=.707106781,n=.707106781,i=0):(r=_/(i=Math.sqrt(v)),n=x/i),this.set(r,n,i,e),this}var b=Math.sqrt((f-h)*(f-h)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(f-h)/b,this.y=(c-p)/b,this.z=(l-s)/b,this.w=Math.acos((a+u+d-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new o,e=new o),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},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.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}},a.prototype={constructor:a,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(a.prototype,r.prototype),s.prototype=Object.create(a.prototype),s.prototype.constructor=s,s.prototype.isWebGLRenderTargetCube=!0,c.prototype={constructor:c,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get w(){return this._w},set w(t){this._w=t,this.onChangeCallback()},set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!1===(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=Math.cos(t._x/2),n=Math.cos(t._y/2),i=Math.cos(t._z/2),o=Math.sin(t._x/2),a=Math.sin(t._y/2),s=Math.sin(t._z/2),c=t.order;return"XYZ"===c?(this._x=o*n*i+r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i-o*a*s):"YXZ"===c?(this._x=o*n*i+r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i+o*a*s):"ZXY"===c?(this._x=o*n*i-r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i-o*a*s):"ZYX"===c?(this._x=o*n*i-r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i+o*a*s):"YZX"===c?(this._x=o*n*i+r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i-o*a*s):"XZY"===c&&(this._x=o*n*i-r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i+o*a*s),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],c=r[9],l=r[2],u=r[6],h=r[10],p=n+s+h;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(u-c)*e,this._y=(o-l)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+l)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+l)/e,this._y=(c+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e;return function(r,n){return void 0===t&&(t=new l),(e=r.dot(n)+1)<1e-6?(e=0,Math.abs(r.x)>Math.abs(r.z)?t.set(-r.y,r.x,0):t.set(0,-r.z,r.y)):t.crossVectors(r,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 r=t._x,n=t._y,i=t._z,o=t._w,a=e._x,s=e._y,c=e._z,l=e._w;return this._x=r*l+o*a+n*c-i*s,this._y=n*l+o*s+i*a-r*c,this._z=i*l+o*c+r*s-n*a,this._w=o*l-r*a-n*s-i*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var c=Math.atan2(s,a),l=Math.sin((1-e)*c)/s,u=Math.sin(e*c)/s;return this._w=o*l+this._w*u,this._x=r*l+this._x*u,this._y=n*l+this._y*u,this._z=i*l+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(c,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,o,a){var s=r[n+0],c=r[n+1],l=r[n+2],u=r[n+3],h=i[o+0],p=i[o+1],f=i[o+2],d=i[o+3];if(u!==d||s!==h||c!==p||l!==f){var m=1-a,g=s*h+c*p+l*f+u*d,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var _=Math.sqrt(y),x=Math.atan2(_,g*v);m=Math.sin(m*x)/_,a=Math.sin(a*x)/_}var b=a*v;if(s=s*m+h*b,c=c*m+p*b,l=l*m+f*b,u=u*m+d*b,m===1-a){var w=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=w,c*=w,l*=w,u*=w}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),l.prototype={constructor:l,isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return 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 c),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t;return function(e,r){return void 0===t&&(t=new c),this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;this.x=i[0]*e+i[4]*r+i[8]*n+i[12],this.y=i[1]*e+i[5]*r+i[9]*n+i[13],this.z=i[2]*e+i[6]*r+i[10]*n+i[14];var o=i[3]*e+i[7]*r+i[11]*n+i[15];return this.divideScalar(o)},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*n-a*r,l=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=c*s+h*-i+l*-a-u*-o,this.y=l*s+h*-o+u*-i-c*-a,this.z=u*s+h*-a+c*-o-l*-i,this},project:function(){var t;return function(e){return void 0===t&&(t=new u),t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t;return function(e){return void 0===t&&(t=new u),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new l,e=new l),t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},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,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t;return function(e){return void 0===t&&(t=new l),t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t;return function(e){return void 0===t&&(t=new l),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(Tp.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){if("number"==typeof t){var r=t;t=e,e=r}return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}},u.prototype={constructor:u,isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,c,l,u,h,p,f,d,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new u).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t;return function(e){void 0===t&&(t=new l);var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),c=Math.sin(n),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=p+f*c,e[5]=h-d*c,e[9]=-a*s,e[2]=d-h*c,e[6]=f+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=f*c-p,e[8]=h*c+d,e[1]=s*u,e[5]=d*c+h,e[9]=p*c-f,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-c*l,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=_*u+w,e[5]=o*l,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*l,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t.x,n=t.y,i=t.z,o=t.w,a=r+r,s=n+n,c=i+i,l=r*a,u=r*s,h=r*c,p=n*s,f=n*c,d=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(l+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(l+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t,e,r;return function(n,i,o){void 0===t&&(t=new l,e=new l,r=new l);var a=this.elements;return r.subVectors(n,i).normalize(),0===r.lengthSq()&&(r.z=1),t.crossVectors(o,r).normalize(),0===t.lengthSq()&&(r.z+=1e-4,t.crossVectors(o,r).normalize()),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],l=r[1],u=r[5],h=r[9],p=r[13],f=r[2],d=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],z=n[15];return i[0]=o*b+a*A+s*P+c*I,i[4]=o*w+a*E+s*L+c*O,i[8]=o*S+a*C+s*R+c*D,i[12]=o*M+a*T+s*N+c*z,i[1]=l*b+u*A+h*P+p*I,i[5]=l*w+u*E+h*L+p*O,i[9]=l*S+u*C+h*R+p*D,i[13]=l*M+u*T+h*N+p*z,i[2]=f*b+d*A+m*P+g*I,i[6]=f*w+d*E+m*L+g*O,i[10]=f*S+d*C+m*R+g*D,i[14]=f*M+d*T+m*N+g*z,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*z,this},multiplyToArray:function(t,e,r){var n=this.elements;return this.multiplyMatrices(t,e),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=n[3],r[4]=n[4],r[5]=n[5],r[6]=n[6],r[7]=n[7],r[8]=n[8],r[9]=n[9],r[10]=n[10],r[11]=n[11],r[12]=n[12],r[13]=n[13],r[14]=n[14],r[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},applyToBufferAttribute:function(){var t;return function(e){void 0===t&&(t=new l);for(var r=0,n=e.count;r 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}\nvec2 ltcTextureCoords( const in GeometricContext geometry, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;\n\tconst float LUT_BIAS = 0.5/LUT_SIZE;\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nvoid clipQuadToHorizon( inout vec3 L[5], out int n ) {\n\tint config = 0;\n\tif ( L[0].z > 0.0 ) config += 1;\n\tif ( L[1].z > 0.0 ) config += 2;\n\tif ( L[2].z > 0.0 ) config += 4;\n\tif ( L[3].z > 0.0 ) config += 8;\n\tn = 0;\n\tif ( config == 0 ) {\n\t} else if ( config == 1 ) {\n\t\tn = 3;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 2 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 3 ) {\n\t\tn = 4;\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t\tL[3] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 4 ) {\n\t\tn = 3;\n\t\tL[0] = -L[3].z * L[2] + L[2].z * L[3];\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t} else if ( config == 5 ) {\n\t\tn = 0;\n\t} else if ( config == 6 ) {\n\t\tn = 4;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 7 ) {\n\t\tn = 5;\n\t\tL[4] = -L[3].z * L[0] + L[0].z * L[3];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 8 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[1] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = L[3];\n\t} else if ( config == 9 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[2].z * L[3] + L[3].z * L[2];\n\t} else if ( config == 10 ) {\n\t\tn = 0;\n\t} else if ( config == 11 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 12 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t} else if ( config == 13 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = L[2];\n\t\tL[2] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t} else if ( config == 14 ) {\n\t\tn = 5;\n\t\tL[4] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t} else if ( config == 15 ) {\n\t\tn = 4;\n\t}\n\tif ( n == 3 )\n\t\tL[3] = L[0];\n\tif ( n == 4 )\n\t\tL[4] = L[0];\n}\nfloat integrateLtcBrdfOverRectEdge( vec3 v1, vec3 v2 ) {\n\tfloat cosTheta = dot( v1, v2 );\n\tfloat theta = acos( cosTheta );\n\tfloat res = cross( v1, v2 ).z * ( ( theta > 0.001 ) ? theta / sin( theta ) : 1.0 );\n\treturn res;\n}\nvoid initRectPoints( const in vec3 pos, const in vec3 halfWidth, const in vec3 halfHeight, out vec3 rectPoints[4] ) {\n\trectPoints[0] = pos - halfWidth - halfHeight;\n\trectPoints[1] = pos + halfWidth - halfHeight;\n\trectPoints[2] = pos + halfWidth + halfHeight;\n\trectPoints[3] = pos - halfWidth + halfHeight;\n}\nvec3 integrateLtcBrdfOverRect( const in GeometricContext geometry, const in mat3 brdfMat, const in vec3 rectPoints[4] ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot( V, N ));\n\tT2 = - cross( N, T1 );\n\tmat3 brdfWrtSurface = brdfMat * transpose( mat3( T1, T2, N ) );\n\tvec3 clippedRect[5];\n\tclippedRect[0] = brdfWrtSurface * ( rectPoints[0] - P );\n\tclippedRect[1] = brdfWrtSurface * ( rectPoints[1] - P );\n\tclippedRect[2] = brdfWrtSurface * ( rectPoints[2] - P );\n\tclippedRect[3] = brdfWrtSurface * ( rectPoints[3] - P );\n\tint n;\n\tclipQuadToHorizon(clippedRect, n);\n\tif ( n == 0 )\n\t\treturn vec3( 0, 0, 0 );\n\tclippedRect[0] = normalize( clippedRect[0] );\n\tclippedRect[1] = normalize( clippedRect[1] );\n\tclippedRect[2] = normalize( clippedRect[2] );\n\tclippedRect[3] = normalize( clippedRect[3] );\n\tclippedRect[4] = normalize( clippedRect[4] );\n\tfloat sum = 0.0;\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[0], clippedRect[1] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[1], clippedRect[2] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[2], clippedRect[3] );\n\tif (n >= 4)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[3], clippedRect[4] );\n\tif (n == 5)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[4], clippedRect[0] );\n\tsum = max( 0.0, sum );\n\tvec3 Lo_i = vec3( sum, sum, sum );\n\treturn Lo_i;\n}\nvec3 Rect_Area_Light_Specular_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight,\n\t\tconst in float roughness,\n\t\tconst in sampler2D ltcMat, const in sampler2D ltcMag ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tvec2 uv = ltcTextureCoords( geometry, roughness );\n\tvec4 brdfLtcApproxParams, t;\n\tbrdfLtcApproxParams = texture2D( ltcMat, uv );\n\tt = texture2D( ltcMat, uv );\n\tfloat brdfLtcScalar = texture2D( ltcMag, uv ).a;\n\tmat3 brdfLtcApproxMat = mat3(\n\t\tvec3( 1, 0, t.y ),\n\t\tvec3( 0, t.z, 0 ),\n\t\tvec3( t.w, 0, t.x )\n\t);\n\tvec3 specularReflectance = integrateLtcBrdfOverRect( geometry, brdfLtcApproxMat, rectPoints );\n\tspecularReflectance *= brdfLtcScalar;\n\treturn specularReflectance;\n}\nvec3 Rect_Area_Light_Diffuse_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tmat3 diffuseBrdfMat = mat3(1);\n\tvec3 diffuseReflectance = integrateLtcBrdfOverRect( geometry, diffuseBrdfMat, rectPoints );\n\treturn diffuseReflectance;\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 < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"#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\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = 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 envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n\t}\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff;\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.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\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#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\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\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 \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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 \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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 \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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 \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform 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"};Y.prototype={constructor:Y,isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=Tp.euclideanModulo(e,1),r=Tp.clamp(r,0,1),n=Tp.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=(u=r[1]).length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(t&&t.length>0){var u=Fp[t];void 0!==u&&this.setHex(u)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),c=Math.min(i,o,a),l=(c+s)/2;if(c===s)e=0,r=0;else{var u=s-c;switch(r=l<=.5?u/(s+c):u/(2-s-c),s){case i:e=(o-a)/u+(othis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new n).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new n).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new n;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};var Bp=0;Q.prototype={constructor:Q,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(t){!0===t&&this.update(),this._needsUpdate=t},setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r){var n=this[e];void 0!==n&&(n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]="overdraw"===e?Number(r):r)}}},toJSON:function(t){function e(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var n={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Bu&&(n.blending=this.blending),this.shading!==Du&&(n.shading=this.shading),this.side!==Ru&&(n.side=this.side),this.vertexColors!==zu&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),n.skinning=this.skinning,n.morphTargets=this.morphTargets,r){var i=e(t.textures),o=e(t.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.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,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(Q.prototype,r.prototype),J.prototype=Object.create(Q.prototype),J.prototype.constructor=J,J.prototype.isShaderMaterial=!0,J.prototype.copy=function(t){return Q.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Dp.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},J.prototype.toJSON=function(t){var e=Q.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},tt.prototype=Object.create(Q.prototype),tt.prototype.constructor=tt,tt.prototype.isMeshDepthMaterial=!0,tt.prototype.copy=function(t){return Q.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},et.prototype={constructor:et,isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;si&&(i=l),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;si&&(i=l),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new l).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t;return function(e){return void 0===t&&(t=new l),this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new l).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new l;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new l;return function(e){var r=e||new rt;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new l,new l,new l,new l,new l,new l,new l,new l];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},rt.prototype={constructor:rt,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t;return function(e,r){void 0===t&&(t=new et);var n=this.center;void 0!==r?n.copy(r):t.setFromPoints(e).getCenter(n);for(var i=0,o=0,a=e.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new et;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}},nt.prototype={constructor:nt,isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,c){var l=this.elements;return l[0]=t,l[1]=n,l[2]=a,l[3]=e,l[4]=i,l[5]=s,l[6]=r,l[7]=o,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=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},applyToBufferAttribute:function(){var t;return function(e){void 0===t&&(t=new l);for(var r=0,n=e.count;r1))return n.copy(i).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return n.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new l).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new l,e=new nt;return function(r,n){var i=this.coplanarPoint(t).applyMatrix4(r),o=n||e.getNormalMatrix(r),a=this.normal.applyMatrix3(o).normalize();return this.constant=-i.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}},ot.prototype={constructor:ot,set:function(t,e,r,n,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],c=r[5],l=r[6],u=r[7],h=r[8],p=r[9],f=r[10],d=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-n,u-s,d-h,y-m).normalize(),e[1].setComponents(a+n,u+s,d+h,y+m).normalize(),e[2].setComponents(a+i,u+c,d+p,y+g).normalize(),e[3].setComponents(a-i,u-c,d-p,y-g).normalize(),e[4].setComponents(a-o,u-l,d-f,y-v).normalize(),e[5].setComponents(a+o,u+l,d+f,y+v).normalize(),this},intersectsObject:function(){var t=new rt;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new rt;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++)if(e[i].distanceToPoint(r)0?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}},st.prototype={constructor:st,set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new l).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new l;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var r=e||new l;r.subVectors(t,this.origin);var n=r.dot(this.direction);return n<0?r.copy(this.origin):r.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new l;return function(e){var r=t.subVectors(e,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(r).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new l,e=new l,r=new l;return function(n,i,o,a){t.copy(n).add(i).multiplyScalar(.5),e.copy(i).sub(n).normalize(),r.copy(this.origin).sub(t);var s,c,l,u,h=.5*n.distanceTo(i),p=-this.direction.dot(e),f=r.dot(this.direction),d=-r.dot(e),m=r.lengthSq(),g=Math.abs(1-p*p);if(g>0)if(s=p*d-f,c=p*f-d,u=h*g,s>=0)if(c>=-u)if(c<=u){var v=1/g;l=(s*=v)*(s+p*(c*=v)+2*f)+c*(p*s+c+2*d)+m}else c=h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c=-h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c<=-u?l=-(s=Math.max(0,-(-p*h+f)))*s+(c=s>0?-h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m:c<=u?(s=0,l=(c=Math.min(Math.max(-h,-d),h))*(c+2*d)+m):l=-(s=Math.max(0,-(p*h+f)))*s+(c=s>0?h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m;else c=p>0?-h:h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),l}}(),intersectSphere:function(){var t=new l;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,c=n+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(r=(t.min.x-h.x)*c,n=(t.max.x-h.x)*c):(r=(t.max.x-h.x)*c,n=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,o=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,o=(t.min.y-h.y)*l),r>o||i>n?null:((i>r||r!==r)&&(r=i),(o=0?(a=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),r>s||a>n?null:((a>r||r!==r)&&(r=a),(s=0?r:n,e)))},intersectsBox:function(){var t=new l;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new l,e=new l,r=new l,n=new l;return function(i,o,a,s,c){e.subVectors(o,i),r.subVectors(a,i),n.crossVectors(e,r);var l,u=this.direction.dot(n);if(u>0){if(s)return null;l=1}else{if(!(u<0))return null;l=-1,u=-u}t.subVectors(this.origin,i);var h=l*this.direction.dot(r.crossVectors(t,r));if(h<0)return null;var p=l*this.direction.dot(e.cross(t));if(p<0)return null;if(h+p>u)return null;var f=-l*t.dot(n);return f<0?null:this.at(f/u,c)}}(),applyMatrix4:function(t){return this.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)}},ct.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ct.DefaultOrder="XYZ",ct.prototype={constructor:ct,isEuler:!0,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get order(){return this._order},set order(t){this._order=t,this.onChangeCallback()},set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=Tp.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],c=i[1],l=i[5],u=i[9],h=i[2],p=i[6],f=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,l))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===e&&(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,l),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t;return function(e,r,n){return void 0===t&&(t=new u),t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new c;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new l(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},lt.prototype={constructor:lt,set:function(t){this.mask=1<1){for(var e=0;e1)for(var e=0;e0){i.children=[];for(var o=0;o0&&(n.geometries=a),s.length>0&&(n.materials=s),c.length>0&&(n.textures=c),l.length>0&&(n.images=l)}return n.object=i,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.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;r0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),pt.barycoordFromPoint=function(){var t=new l,e=new l,r=new l;return function(n,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),r.subVectors(n,i);var c=t.dot(t),u=t.dot(e),h=t.dot(r),p=e.dot(e),f=e.dot(r),d=c*p-u*u,m=s||new l;if(0===d)return m.set(-2,-1,-1);var g=1/d,v=(p*h-u*f)*g,y=(c*f-u*h)*g;return m.set(1-v-y,y,v)}}(),pt.containsPoint=function(){var t=new l;return function(e,r,n,i){var o=pt.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),pt.prototype={constructor:pt,set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new l,e=new l;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new l).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return pt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new it).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return pt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return pt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t,e,r,n;return function(i,o){void 0===t&&(t=new it,e=[new ht,new ht,new ht],r=new l,n=new l);var a=o||new l,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0,s=o[1]&&o[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(v=0;v0){u=[];for(v=0;v0)for(m=0;m0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rt),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(!1!==(t&&t.isGeometry)){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,l=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new nt).getNormalMatrix(e));for(var f=0,d=a.length;f=0;r--){var d=p[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a0,x=v.vertexNormals.length>0,b=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,S=0;if(S=t(S,0,0),S=t(S,1,!0),S=t(S,2,!1),S=t(S,3,y),S=t(S,4,_),S=t(S,5,x),S=t(S,6,b),S=t(S,7,w),u.push(S),u.push(v.a,v.b,v.c),u.push(v.materialIndex),y){var M=this.faceVertexUvs[0][c];u.push(n(M[0]),n(M[1]),n(M[2]))}if(_&&u.push(e(v.normal)),x){var A=v.vertexNormals;u.push(e(A[0]),e(A[1]),e(A[2]))}if(b&&u.push(r(v.color)),w){var E=v.vertexColors;u.push(r(E[0]),r(E[1]),r(E[2]))}}return i.data={},i.data.vertices=s,i.data.normals=h,f.length>0&&(i.data.colors=f),m.length>0&&(i.data.uvs=[m]),i.data.faces=u,i},clone:function(){return(new Tt).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e65535?wt:xt)(t,1):this.index=t},addAttribute:function(t,e){if(!1!==(e&&e.isBufferAttribute)||!1!==(e&&e.isInterleavedBufferAttribute)){if("index"!==t)return this.attributes[t]=e,this;this.setIndex(e)}else this.addAttribute(t,new mt(arguments[1],arguments[2]))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;return void 0!==r&&((new nt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t;return function(e){return void 0===t&&(t=new u),t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t;return function(e){return void 0===t&&(t=new u),t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t;return function(e){return void 0===t&&(t=new u),t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t;return function(e,r,n){return void 0===t&&(t=new u),t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t;return function(e,r,n){return void 0===t&&(t=new u),t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t;return function(e){void 0===t&&(t=new ut),t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new St(3*e.vertices.length,3),n=new St(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new St(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var n;return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new At).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new mt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new mt(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new mt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new mt(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new mt(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Et(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new mt(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var c=[],l=t.morphTargets[s],u=0,h=l.length;u0){var d=new St(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new St(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:function(){var t=new et,e=new l;return function(){null===this.boundingSphere&&(this.boundingSphere=new rt);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(n);for(var i=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Pt).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(r=0,n=l.length;r0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,r=t.length;ee.far?null:{distance:c,point:x.clone(),object:t}}function r(r,n,i,o,a,l,u,p){s.fromBufferAttribute(o,l),c.fromBufferAttribute(o,u),h.fromBufferAttribute(o,p);var f=e(r,n,i,s,c,h,_);return f&&(a&&(m.fromBufferAttribute(a,l),g.fromBufferAttribute(a,u),v.fromBufferAttribute(a,p),f.uv=t(_,s,c,h,m,g,v)),f.face=new ft(l,u,p,pt.normal(s,c,h)),f.faceIndex=l),f}var i=new u,o=new st,a=new rt,s=new l,c=new l,h=new l,p=new l,f=new l,d=new l,m=new n,g=new n,v=new n,y=new l,_=new l,x=new l;return function(n,l){var u=this.geometry,y=this.material,x=this.matrixWorld;if(void 0!==y&&(null===u.boundingSphere&&u.computeBoundingSphere(),a.copy(u.boundingSphere),a.applyMatrix4(x),!1!==n.ray.intersectsSphere(a)&&(i.getInverse(x),o.copy(n.ray).applyMatrix4(i),null===u.boundingBox||!1!==o.intersectsBox(u.boundingBox)))){var b;if(u.isBufferGeometry){var w,S,M,A,E,C=u.index,T=u.attributes.position,P=u.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=k);for(var U=0,B=F.length;Uthis.scale.x*this.scale.y/4||r.push({distance:Math.sqrt(n),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),ge.prototype=Object.assign(Object.create(ut.prototype),{constructor:ge,copy:function(t){ut.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa||(f.applyMatrix4(this.matrixWorld),(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else for(var y=0,_=g.length/3-1;y<_;y+=d)u.fromArray(g,3*y),h.fromArray(g,3*y+3),(M=e.distanceSqToSegment(u,h,f,p))>a||(f.applyMatrix4(this.matrixWorld),(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else if(s.isGeometry)for(var w=s.vertices,S=w.length,y=0;ya)){f.applyMatrix4(this.matrixWorld);var A=n.ray.origin.distanceTo(f);An.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),we.prototype=Object.assign(Object.create(be.prototype),{constructor:we,isLineSegments:!0}),Se.prototype=Object.create(Q.prototype),Se.prototype.constructor=Se,Se.prototype.isPointsMaterial=!0,Se.prototype.copy=function(t){return Q.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Me.prototype=Object.assign(Object.create(ut.prototype),{constructor:Me,isPoints:!0,raycast:function(){var t=new u,e=new st,r=new rt;return function(n,i){function o(t,r){var o=e.distanceSqToPoint(t);if(on.far)return;i.push({distance:l,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=n.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),!1!==n.ray.intersectsSphere(r)){t.getInverse(c),e.copy(n.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),p=h*h,f=new l;if(s.isBufferGeometry){var d=s.index,m=s.attributes.position.array;if(null!==d)for(var g=d.array,v=0,y=g.length;v=-Number.EPSILON&&T>=-Number.EPSILON&&C>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],c=[],l=[];if(Wp.area(e)>0)for(o=0;o2;){if(h--<=0)return r?l:s;if(i=o,u<=i&&(i=0),o=i+1,u<=o&&(o=0),a=o+1,u<=a&&(a=0),t(e,i,o,a,u,c)){var p,f,d,m,g;for(p=c[i],f=c[o],d=c[a],s.push([e[p],e[f],e[d]]),l.push([c[i],c[o],c[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var d;if(p>0){if(f<0||f>p)return[];if((d=l*u-c*h)<0||d>p)return[]}else{if(f>0||f0||dA?[]:x===A?o?[]:[y]:b<=A?[y,_]:[y,S]}function o(t,e,r,n){var i=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,c=n.x-t.x,l=n.y-t.y,u=i*s-o*a,h=i*l-o*c;if(Math.abs(u)>Number.EPSILON){var p=c*s-l*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,c,l,u,h,p={},f=t.concat(),d=0,m=e.length;d0&&!(--b<0);)for(a=x;an&&(a=0);var s=o(m[t],m[i],m[a],r[e]);if(!s)return!1;var c=r.length-1,l=e-1;l<0&&(l=c);var u=e+1;return u>c&&(u=0),!!(s=o(r[e],r[l],r[u],m[t]))}(a,w)&&!function(t,e){var r,n;for(r=0;r0)return!0;return!1}(s,c)&&!function(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}(s,c)){n=w,g.splice(y,1),h=m.slice(0,a+1),p=m.slice(a),f=r.slice(n),d=r.slice(0,n+1),m=h.concat(f).concat(d).concat(p),x=a;break}if(n>=0)break;v[u]=!0}if(n>=0)break}return m}(t,e),v=Wp.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var f=Math.sqrt(h),d=Math.sqrt(l*l+u*u),m=e.x-c/f,g=e.y+s/f,v=((r.x-u/d-m)*u-(r.y+l/d-g)*l)/(s*u-c*l),y=(i=m+s*v-t.x)*i+(o=g+c*v-t.y)*o;if(y<=2)return new n(i,o);a=Math.sqrt(y/2)}else{var _=!1;s>Number.EPSILON?l>Number.EPSILON&&(_=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(_=!0):Math.sign(c)===Math.sign(u)&&(_=!0),_?(i=-c,o=s,a=Math.sqrt(h)):(i=s,o=c,a=Math.sqrt(h/2))}return new n(i/a,o/a)}function o(t,e){var r,n;for(H=t.length;--H>=0;){r=H,(n=H-1)<0&&(n=t.length-1);var i=0,o=b+2*y;for(i=0;i=0;z--){for(k=z/y,U=g*Math.cos(k*Math.PI/2),F=v*Math.sin(k*Math.PI/2),H=0,X=D.length;H0||0===t.search(/^data\:image\/jpeg/);o.format=n?Qh:Jh,o.image=r,o.needsUpdate=!0,void 0!==e&&e(o)},r,n),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Pr.prototype=Object.assign(Object.create(ut.prototype),{constructor:Pr,isLight:!0,copy:function(t){return ut.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=ut.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Lr.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Lr,isHemisphereLight:!0,copy:function(t){return Pr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Rr.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}}),Nr.prototype=Object.assign(Object.create(Rr.prototype),{constructor:Nr,isSpotLightShadow:!0,update:function(t){var e=2*Tp.RAD2DEG*t.angle,r=this.mapSize.width/this.mapSize.height,n=t.distance||500,i=this.camera;e===i.fov&&r===i.aspect&&n===i.far||(i.fov=e,i.aspect=r,i.far=n,i.updateProjectionMatrix())}}),Ir.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Ir,isSpotLight:!0,copy:function(t){return Pr.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}}),Or.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Or,isPointLight:!0,copy:function(t){return Pr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Dr.prototype=Object.assign(Object.create(Rr.prototype),{constructor:Dr}),zr.prototype=Object.assign(Object.create(Pr.prototype),{constructor:zr,isDirectionalLight:!0,copy:function(t){return Pr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Fr.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Fr,isAmbientLight:!0});var $p={arraySlice:function(t,e,r){return $p.isTypedArray(t)?new t.constructor(t.subarray(e,r)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,c=0;c!==e;++c)i[a++]=t[s+c];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};kr.prototype={constructor:kr,evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var a=e[1];t=i)break e}o=r,r=0}}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=$p.arraySlice(r,i,o),this.values=$p.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(t=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){t=!1;break}if(null!==o&&o>s){t=!1;break}o=s}if(void 0!==n&&$p.isTypedArray(n))for(var a=0,c=n.length;a!==c;++a){var l=n[a];if(isNaN(l)){t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(var d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=$p.arraySlice(t,0,i),this.values=$p.arraySlice(e,0,i*r)),this}},Gr.prototype=Object.assign(Object.create(Zp),{constructor:Gr,ValueTypeName:"vector"}),Wr.prototype=Object.assign(Object.create(kr.prototype),{constructor:Wr,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=(r-e)/(n-e),u=s+a;s!==u;s+=4)c.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Hr.prototype=Object.assign(Object.create(Zp),{constructor:Hr,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new Wr(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Xr.prototype=Object.assign(Object.create(Zp),{constructor:Xr,ValueTypeName:"number"}),Yr.prototype=Object.assign(Object.create(Zp),{constructor:Yr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),qr.prototype=Object.assign(Object.create(Zp),{constructor:qr,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),$r.prototype=Object.assign(Object.create(Zp),{constructor:$r,ValueTypeName:"color"}),Zr.prototype=Zp,Zp.constructor=Zr,Object.assign(Zr,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Zr._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];$p.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:$p.convertArray(t.times,Array),values:$p.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 Xr;case"vector":case"vector2":case"vector3":case"vector4":return Gr;case"color":return $r;case"quaternion":return Hr;case"bool":case"boolean":return qr;case"string":return Yr}throw new Error("Unsupported typeName: "+t)}}),Kr.prototype={constructor:Kr,resetDuration:function(){for(var t=0,e=0,r=this.tracks.length;e!==r;++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 l=n[h=c[1]];l||(n[h]=l=[]),l.push(s)}}var u=[];for(var h in n)u.push(Kr.CreateFromMorphTargetSequence(h,n[h],e,r));return u},parseAnimation:function(t,e){if(!t)return null;for(var r=function(t,e,r,n,i){if(0!==r.length){var o=[],a=[];$p.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[n+1]:0,c=e>2?t.skinWeights[n+2]:0,l=e>3?t.skinWeights[n+3]:0;r.skinWeights.push(new o(a,s,c,l))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,p=e>2?t.skinIndices[n+2]:0,f=e>3?t.skinIndices[n+3]:0;r.skinIndices.push(new o(u,h,p,f))}r.bones=t.bones,r.bones&&r.bones.length>0&&(r.skinWeights.length!==r.skinIndices.length||(r.skinIndices.length,r.vertices.length))}(),function(e){if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0)for(var h=r.faces,p=t.morphColors[0].colors,n=0,i=h.length;n0&&(r.animations=e)}(),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:r};var a=tn.prototype.initMaterials(t.materials,e,this.crossOrigin);return{geometry:r,materials:a}}}),Object.assign(rn.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new Sr(i.manager).load(t,function(t){var r=null;try{r=JSON.parse(t)}catch(t){return void(void 0!==n&&n(t))}var o=r.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()&&i.parse(r,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new en,n=new Jr,i=0,o=t.length;i0){var i=new Er(new wr(e));i.setCrossOrigin(this.crossOrigin);for(var o=0,a=t.length;o0?new _e(s,c):new Lt(s,c);break;case"LOD":a=new ge;break;case"Line":a=new be(i(e.geometry),o(e.material),e.mode);break;case"LineSegments":a=new we(i(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new Me(i(e.geometry),o(e.material));break;case"Sprite":a=new me(o(e.material));break;case"Group":a=new Ae;break;case"SkinnedMesh":default:a=new ut}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var l in e.children)a.add(this.parseObject(e.children[l],r,n));if("LOD"===e.type)for(var u=e.levels,h=0;h0)){c=i;break}c=i-1}if(i=c,n[i]===r)return u=i/(o-1);var l=n[i],u=(i+(r-l)/(n[i+1]-l))/(o-1);return u},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new l,a=[],s=[],c=[],h=new l,p=new u;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new l,c[0]=new l;var f=Number.MAX_VALUE,d=Math.abs(a[0].x),m=Math.abs(a[0].y),g=Math.abs(a[0].z);for(d<=f&&(f=d,o.set(1,0,0)),m<=f&&(f=m,o.set(0,1,0)),g<=f&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),c[r]=c[r-1].clone(),h.crossVectors(a[r-1],a[r]),h.length()>Number.EPSILON&&(h.normalize(),i=Math.acos(Tp.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(p.makeRotationAxis(h,i))),c[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(Tp.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(h.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(p.makeRotationAxis(a[r],i*r)),c[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:c}}},(mn.prototype=Object.create(dn.prototype)).constructor=mn,mn.prototype.isLineCurve=!0,mn.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},mn.prototype.getPointAt=function(t){return this.getPoint(t)},mn.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},gn.prototype=Object.assign(Object.create(dn.prototype),{constructor:gn,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 mn(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n=e){var i=r[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Tt,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:i+1],l=e[i>e.length-3?e.length-1:i+2];return new n(nn(o,a.x,s.x,c.x,l.x),nn(o,a.y,s.y,c.y,l.y))},(_n.prototype=Object.create(dn.prototype)).constructor=_n,_n.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,o=this.v3;return new n(fn(t,e.x,r.x,i.x,o.x),fn(t,e.y,r.y,i.y,o.y))},(xn.prototype=Object.create(dn.prototype)).constructor=xn,xn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new n(cn(t,e.x,r.x,i.x),cn(t,e.y,r.y,i.y))};var Kp=Object.assign(Object.create(gn.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);this.currentPoint.copy(u)}});bn.prototype=Kp,Kp.constructor=bn,wn.prototype=Object.assign(Object.create(Kp),{constructor:wn,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;r1){for(var v=!1,y=[],_=0,x=p.length;_Number.EPSILON){if(l<0&&(a=e[o],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=l*(t.x-a.x)-c*(t.y-a.y);if(0===u)return!0;if(u<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n})(S.p,p[A].p)&&(_!==A&&y.push({froms:_,tos:A,hole:w}),M?(M=!1,h[A].push(S)):v=!0);M&&h[_].push(S)}y.length>0&&(v||(f=h))}for(var E,m=0,C=p.length;m0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n,i){c.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}},Dn.prototype={constructor:Dn,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,r=e.objectName,n=e.propertyName,i=e.propertyIndex;if(t||(t=Dn.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(r){var o=e.objectIndex;switch(r){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(l=0;l=r){var h=r++,p=e[h];n[p.uuid]=u,e[u]=p,n[l]=h,e[h]=c;for(var f=0,d=o;f!==d;++f){var m=i[f],g=m[h],v=m[u];m[u]=g,m[h]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,c=arguments.length;s!==c;++s){var l=arguments[s].uuid,u=i[l];if(void 0!==u)if(delete i[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(a),l[u].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;null!==r&&(e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:mp:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:mp:2402)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=r,this}},kn.prototype={constructor:kn,clipAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?Kr.findByName(r,t):t,o=null!==i?i.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===i&&(i=s._clip)}if(null===i)return null;var l=new Fn(this,i,e);return this._bindAction(l,s),this._addInactiveAction(l,o,n),l},existingAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?Kr.findByName(r,t):t,o=i?i.uuid:t,a=this._actionsByClip[o];return void 0!==a?a.actionByRoot[n]||null:null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,r=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(i=0;i!==e;++i)t[i].reset();for(var i=0;i!==n;++i)r[i].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,r=this._nActiveActions,n=this.time+=t,i=Math.sign(t),o=this._accuIndex^=1,a=0;a!==r;++a){var s=e[a];s.enabled&&s._update(n,t,i,o)}for(var c=this._bindings,l=this._nActiveBindings,a=0;a!==l;++a)c[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,r=t.uuid,n=this._actionsByClip,i=n[r];if(void 0!==i){for(var o=i.knownActions,a=0,s=o.length;a!==s;++a){var c=o[a];this._deactivateAction(c);var l=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,e[l]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[r]}},uncacheRoot:function(t){var e=t.uuid,r=this._actionsByClip;for(var n in r){var i=r[n].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}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 r=this.existingAction(t,e);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}},Object.assign(kn.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,o=t._propertyBindings,a=t._interpolants,s=r.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=n[u],p=h.name,f=l[p];if(void 0!==f)o[u]=f;else{if(void 0!==(f=o[u])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,p));continue}var d=e&&e._propertyBindings[u].binding.parsedPath;++(f=new On(Dn.create(r,p,d),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(f,s,p),o[u]=f}a[u].resultBuffer=f.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e1&&(n[c=s[1]]||(n[c]={start:1/0,end:-1/0}),o<(l=n[c]).start&&(l.start=o),o>l.end&&(l.end=o),e||(e=c))}for(var c in n){var l=n[c];this.createAnimation(c,l.start,l.end,t)}this.firstAnimation=e},Kn.prototype.setAnimationDirectionForward=function(t){var e=this.animationsMap[t];e&&(e.direction=1,e.directionBackwards=!1)},Kn.prototype.setAnimationDirectionBackward=function(t){var e=this.animationsMap[t];e&&(e.direction=-1,e.directionBackwards=!0)},Kn.prototype.setAnimationFPS=function(t,e){var r=this.animationsMap[t];r&&(r.fps=e,r.duration=(r.end-r.start)/r.fps)},Kn.prototype.setAnimationDuration=function(t,e){var r=this.animationsMap[t];r&&(r.duration=e,r.fps=(r.end-r.start)/r.duration)},Kn.prototype.setAnimationWeight=function(t,e){var r=this.animationsMap[t];r&&(r.weight=e)},Kn.prototype.setAnimationTime=function(t,e){var r=this.animationsMap[t];r&&(r.time=e)},Kn.prototype.getAnimationTime=function(t){var e=0,r=this.animationsMap[t];return r&&(e=r.time),e},Kn.prototype.getAnimationDuration=function(t){var e=-1,r=this.animationsMap[t];return r&&(e=r.duration),e},Kn.prototype.playAnimation=function(t){var e=this.animationsMap[t];e&&(e.time=0,e.active=!0)},Kn.prototype.stopAnimation=function(t){var e=this.animationsMap[t];e&&(e.active=!1)},Kn.prototype.update=function(t){for(var e=0,r=this.animationsList.length;en.duration||n.time<0)&&(n.direction*=-1,n.time>n.duration&&(n.time=n.duration,n.directionBackwards=!0),n.time<0&&(n.time=0,n.directionBackwards=!1)):(n.time=n.time%n.duration,n.time<0&&(n.time+=n.duration));var o=n.start+Tp.clamp(Math.floor(n.time/i),0,n.length-1),a=n.weight;o!==n.currentFrame&&(this.morphTargetInfluences[n.lastFrame]=0,this.morphTargetInfluences[n.currentFrame]=1*a,this.morphTargetInfluences[o]=0,n.lastFrame=n.currentFrame,n.currentFrame=o);var s=n.time%i/i;n.directionBackwards&&(s=1-s),n.currentFrame!==n.lastFrame?(this.morphTargetInfluences[n.currentFrame]=s*a,this.morphTargetInfluences[n.lastFrame]=(1-s)*a):this.morphTargetInfluences[n.currentFrame]=a}}},(Qn.prototype=Object.create(ut.prototype)).constructor=Qn,Qn.prototype.isImmediateRenderObject=!0,(Jn.prototype=Object.create(we.prototype)).constructor=Jn,Jn.prototype.update=function(){var t=new l,e=new l,r=new nt;return function(){var n=["a","b","c"];this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,l=0,u=0,h=c.length;u.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),hi.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},hi.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},pi.prototype=Object.create(we.prototype),pi.prototype.constructor=pi;var rf=new l,nf=new fi,of=new fi,af=new fi;di.prototype=Object.create(dn.prototype),di.prototype.constructor=di,di.prototype.getPoint=function(t){var e=this.points,r=e.length,n=(r-(this.closed?0:1))*t,i=Math.floor(n),o=n-i;this.closed?i+=i>0?0:(Math.floor(Math.abs(i)/e.length)+1)*e.length:0===o&&i===r-1&&(i=r-2,o=1);var a,s,c,u;if(this.closed||i>0?a=e[(i-1)%r]:(rf.subVectors(e[0],e[1]).add(e[0]),a=rf),s=e[i%r],c=e[(i+1)%r],this.closed||i+2-1}function h(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function z(t,e){for(var r=t.length;r--&&b(e,t[r],0)>-1;);return r}function k(t,e){for(var r=t.length,n=0;r--;)t[r]===e&&++n;return n}function F(t){return"\\"+Sr[t]}function U(t,e){return null==t?et:t[e]}function B(t){return dr.test(t)}function V(t){return mr.test(t)}function j(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}function G(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function W(t,e){return function(r){return t(e(r))}}function H(t,e){for(var r=-1,n=t.length,i=0,o=[];++r>>1,zt=[["ary",xt],["bind",ft],["bindKey",dt],["curry",gt],["curryRight",vt],["flip",wt],["partial",yt],["partialRight",_t],["rearg",bt]],kt="[object Arguments]",Ft="[object Array]",Ut="[object AsyncFunction]",Bt="[object Boolean]",Vt="[object Date]",jt="[object DOMException]",Gt="[object Error]",Wt="[object Function]",Ht="[object GeneratorFunction]",Xt="[object Map]",Yt="[object Number]",qt="[object Null]",$t="[object Object]",Zt="[object Proxy]",Kt="[object RegExp]",Qt="[object Set]",Jt="[object String]",te="[object Symbol]",ee="[object Undefined]",re="[object WeakMap]",ne="[object WeakSet]",ie="[object ArrayBuffer]",oe="[object DataView]",ae="[object Float32Array]",se="[object Float64Array]",ce="[object Int8Array]",le="[object Int16Array]",ue="[object Int32Array]",he="[object Uint8Array]",pe="[object Uint8ClampedArray]",fe="[object Uint16Array]",de="[object Uint32Array]",me=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,ve=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ye=/&(?:amp|lt|gt|quot|#39);/g,_e=/[&<>"']/g,xe=RegExp(ye.source),be=RegExp(_e.source),we=/<%-([\s\S]+?)%>/g,Se=/<%([\s\S]+?)%>/g,Me=/<%=([\s\S]+?)%>/g,Ae=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ee=/^\w*$/,Ce=/^\./,Te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pe=/[\\^$.*+?()[\]{}|]/g,Le=RegExp(Pe.source),Re=/^\s+|\s+$/g,Ne=/^\s+/,Ie=/\s+$/,Oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,De=/\{\n\/\* \[wrapped with (.+)\] \*/,ze=/,? & /,ke=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Fe=/\\(\\)?/g,Ue=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Be=/\w*$/,Ve=/^[-+]0x[0-9a-f]+$/i,je=/^0b[01]+$/i,Ge=/^\[object .+?Constructor\]$/,We=/^0o[0-7]+$/i,He=/^(?:0|[1-9]\d*)$/,Xe=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ye=/($^)/,qe=/['\n\r\u2028\u2029\\]/g,$e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ze="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ke="["+Ze+"]",Qe="["+$e+"]",Je="[a-z\\xdf-\\xf6\\xf8-\\xff]",tr="[^\\ud800-\\udfff"+Ze+"\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",er="\\ud83c[\\udffb-\\udfff]",rr="(?:\\ud83c[\\udde6-\\uddff]){2}",nr="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="[A-Z\\xc0-\\xd6\\xd8-\\xde]",or="(?:"+Je+"|"+tr+")",ar="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",sr="[\\ufe0e\\ufe0f]?"+ar+("(?:\\u200d(?:"+["[^\\ud800-\\udfff]",rr,nr].join("|")+")[\\ufe0e\\ufe0f]?"+ar+")*"),cr="(?:"+["[\\u2700-\\u27bf]",rr,nr].join("|")+")"+sr,lr="(?:"+["[^\\ud800-\\udfff]"+Qe+"?",Qe,rr,nr,"[\\ud800-\\udfff]"].join("|")+")",ur=RegExp("['’]","g"),hr=RegExp(Qe,"g"),pr=RegExp(er+"(?="+er+")|"+lr+sr,"g"),fr=RegExp([ir+"?"+Je+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Ke,ir,"$"].join("|")+")","(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Ke,ir+or,"$"].join("|")+")",ir+"?"+or+"+(?:['’](?:d|ll|m|re|s|t|ve))?",ir+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)","\\d+",cr].join("|"),"g"),dr=RegExp("[\\u200d\\ud800-\\udfff"+$e+"\\ufe0e\\ufe0f]"),mr=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,gr=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],vr=-1,yr={};yr[ae]=yr[se]=yr[ce]=yr[le]=yr[ue]=yr[he]=yr[pe]=yr[fe]=yr[de]=!0,yr[kt]=yr[Ft]=yr[ie]=yr[Bt]=yr[oe]=yr[Vt]=yr[Gt]=yr[Wt]=yr[Xt]=yr[Yt]=yr[$t]=yr[Kt]=yr[Qt]=yr[Jt]=yr[re]=!1;var _r={};_r[kt]=_r[Ft]=_r[ie]=_r[oe]=_r[Bt]=_r[Vt]=_r[ae]=_r[se]=_r[ce]=_r[le]=_r[ue]=_r[Xt]=_r[Yt]=_r[$t]=_r[Kt]=_r[Qt]=_r[Jt]=_r[te]=_r[he]=_r[pe]=_r[fe]=_r[de]=!0,_r[Gt]=_r[Wt]=_r[re]=!1;var xr={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},br={"&":"&","<":"<",">":">",'"':""","'":"'"},wr={"&":"&","<":"<",">":">",""":'"',"'":"'"},Sr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mr=parseFloat,Ar=parseInt,Er="object"==typeof bu&&bu&&bu.Object===Object&&bu,Cr="object"==typeof self&&self&&self.Object===Object&&self,Tr=Er||Cr||Function("return this")(),Pr=e&&!e.nodeType&&e,Lr=Pr&&!0&&t&&!t.nodeType&&t,Rr=Lr&&Lr.exports===Pr,Nr=Rr&&Er.process,Ir=function(){try{return Nr&&Nr.binding&&Nr.binding("util")}catch(t){}}(),Or=Ir&&Ir.isArrayBuffer,Dr=Ir&&Ir.isDate,zr=Ir&&Ir.isMap,kr=Ir&&Ir.isRegExp,Fr=Ir&&Ir.isSet,Ur=Ir&&Ir.isTypedArray,Br=A("length"),Vr=E(xr),jr=E(br),Gr=E(wr),Wr=function t(e){function v(t){if(ea(t)&&!Wc(t)&&!(t instanceof Q)){if(t instanceof q)return t;if(Wa.call(t,"__wrapped__"))return Ao(t)}return new q(t)}function E(){}function q(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=et}function Q(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=It,this.__views__=[]}function J(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function fr(t,e,r,n,i,o){var s,c=e&ct,l=e<,u=e&ut;if(r&&(s=i?r(t,n,i,o):r(t)),s!==et)return s;if(!ta(t))return t;var h=Wc(t);if(h){if(s=Qi(t),!c)return ai(t,s)}else{var p=tc(t),f=p==Wt||p==Ht;if(Xc(t))return qn(t,c);if(p==$t||p==kt||f&&!i){if(s=l||f?{}:Ji(t),!c)return l?li(t,sr(s,t)):ci(t,ar(s,t))}else{if(!_r[p])return i?t:{};s=to(t,p,fr,c)}}o||(o=new Ke);var d=o.get(t);if(d)return d;o.set(t,s);var m=u?l?Vi:Bi:l?ga:ma,g=h?et:m(t);return a(g||t,function(n,i){g&&(n=t[i=n]),nr(s,i,fr(n,e,r,i,t,o))}),s}function dr(t){var e=ma(t);return function(r){return mr(r,t,e)}}function mr(t,e,r){var n=r.length;if(null==t)return!n;for(t=Da(t);n--;){var i=r[n],o=e[i],a=t[i];if(a===et&&!(i in t)||!o(a))return!1}return!0}function xr(t,e,r){if("function"!=typeof t)throw new Fa(it);return nc(function(){t.apply(et,r)},e)}function br(t,e,r,n){var i=-1,o=u,a=!0,s=t.length,c=[],l=e.length;if(!s)return c;r&&(e=p(e,N(r))),n?(o=h,a=!1):e.length>=rt&&(o=O,a=!1,e=new Ze(e));t:for(;++ii?0:i+r),(n=n===et||n>i?i:ca(n))<0&&(n+=i),n=r>n?0:la(n);r0&&r(s)?e>1?Pr(s,e-1,r,n,i):f(i,s):n||(i[i.length]=s)}return i}function Lr(t,e){return t&&Ws(t,e,ma)}function Nr(t,e){return t&&Hs(t,e,ma)}function Ir(t,e){return l(e,function(e){return Ko(t[e])})}function Br(t,e){for(var r=0,n=(e=Xn(e,t)).length;null!=t&&re}function qr(t,e){return null!=t&&Wa.call(t,e)}function $r(t,e){return null!=t&&e in Da(t)}function Zr(t,e,r){return t>=xs(e,r)&&t<_s(e,r)}function Kr(t,e,r){for(var n=r?h:u,i=t[0].length,o=t.length,a=o,s=La(o),c=1/0,l=[];a--;){var f=t[a];a&&e&&(f=p(f,N(e))),c=xs(f.length,c),s[a]=!r&&(e||i>=120&&f.length>=120)?new Ze(a&&f):et}f=t[0];var d=-1,m=s[0];t:for(;++d-1;)s!==t&&is.call(s,c,1),is.call(t,c,1);return t}function bn(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;no(i)?is.call(t,i,1):Fn(t,i)}}return t}function wn(t,e){return t+fs(Ss()*(e-t+1))}function Sn(t,e,r,n){for(var i=-1,o=_s(ps((e-t)/(r||1)),0),a=La(o);o--;)a[n?o:++i]=t,t+=r;return a}function Mn(t,e){var r="";if(!t||e<1||e>Lt)return r;do{e%2&&(r+=t),(e=fs(e/2))&&(t+=t)}while(e);return r}function An(t,e){return ic(go(t,e,Sa),t+"")}function En(t){return Je(ya(t))}function Cn(t,e){var r=ya(t);return bo(r,pr(e,0,r.length))}function Tn(t,e,r,n){if(!ta(t))return t;for(var i=-1,o=(e=Xn(e,t)).length,a=o-1,s=t;null!=s&&++ii?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=La(i);++n>>1,a=t[o];null!==a&&!oa(a)&&(r?a<=e:a=rt){var l=e?null:Zs(t);if(l)return X(l);a=!1,i=O,c=new Ze}else c=e?[]:s;t:for(;++n=n?t:Ln(t,e,r)}function qn(t,e){if(e)return t.slice();var r=t.length,n=ts?ts(r):new t.constructor(r);return t.copy(n),n}function $n(t){var e=new t.constructor(t.byteLength);return new Ja(e).set(new Ja(t)),e}function Zn(t,e){var r=e?$n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function Kn(t,e,n){return d(e?n(G(t),ct):G(t),r,new t.constructor)}function Qn(t){var e=new t.constructor(t.source,Be.exec(t));return e.lastIndex=t.lastIndex,e}function Jn(t,e,r){return d(e?r(X(t),ct):X(t),n,new t.constructor)}function ti(t){return Us?Da(Us.call(t)):{}}function ei(t,e){var r=e?$n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function ri(t,e){if(t!==e){var r=t!==et,n=null===t,i=t===t,o=oa(t),a=e!==et,s=null===e,c=e===e,l=oa(e);if(!s&&!l&&!o&&t>e||o&&a&&c&&!s&&!l||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!l&&t=s?c:c*("desc"==r[n]?-1:1)}return t.index-e.index}function ii(t,e,r,n){for(var i=-1,o=t.length,a=r.length,s=-1,c=e.length,l=_s(o-a,0),u=La(c+l),h=!n;++s1?r[i-1]:et,a=i>2?r[2]:et;for(o=t.length>3&&"function"==typeof o?(i--,o):et,a&&io(r[0],r[1],a)&&(o=i<3?et:o,i=1),e=Da(e);++n-1?i[o?e[a]:a]:et}}function xi(t){return Ui(function(e){var r=e.length,n=r,i=q.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new Fa(it);if(i&&!a&&"wrapper"==ji(o))var a=new q([],!0)}for(n=a?n:r;++n1&&y.reverse(),h&&cs))return!1;var l=o.get(t);if(l&&o.get(e))return l==e;var u=-1,h=!0,p=r&pt?new Ze:et;for(o.set(t,e),o.set(e,t);++u1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Oe,"{\n/* [wrapped with "+e+"] */\n")}function ro(t){return Wc(t)||Gc(t)||!!(os&&t&&t[os])}function no(t,e){return!!(e=null==e?Lt:e)&&("number"==typeof t||He.test(t))&&t>-1&&t%1==0&&t0){if(++e>=At)return arguments[0]}else e=0;return t.apply(et,arguments)}}function bo(t,e){var r=-1,n=t.length,i=n-1;for(e=e===et?n:e;++r0&&(r=e.apply(this,arguments)),t<=1&&(e=et),r}}function jo(t,e,r){var n=Ni(t,gt,et,et,et,et,et,e=r?et:e);return n.placeholder=jo.placeholder,n}function Go(t,e,r){var n=Ni(t,vt,et,et,et,et,et,e=r?et:e);return n.placeholder=Go.placeholder,n}function Wo(t,e,r){function n(e){var r=u,n=h;return u=h=et,g=e,f=t.apply(n,r)}function i(t){return g=t,d=nc(s,e),v?n(t):f}function o(t){var r=t-g,n=e-(t-m);return y?xs(n,p-r):n}function a(t){var r=t-m,n=t-g;return m===et||r>=e||r<0||y&&n>=p}function s(){var t=Nc();if(a(t))return c(t);d=nc(s,o(t))}function c(t){return d=et,_&&u?n(t):(u=h=et,f)}function l(){var t=Nc(),r=a(t);if(u=arguments,h=this,m=t,r){if(d===et)return i(m);if(y)return d=nc(s,e),n(m)}return d===et&&(d=nc(s,e)),f}var u,h,p,f,d,m,g=0,v=!1,y=!1,_=!0;if("function"!=typeof t)throw new Fa(it);return e=ua(e)||0,ta(r)&&(v=!!r.leading,p=(y="maxWait"in r)?_s(ua(r.maxWait)||0,e):p,_="trailing"in r?!!r.trailing:_),l.cancel=function(){d!==et&&$s(d),g=0,u=m=h=d=et},l.flush=function(){return d===et?f:c(Nc())},l}function Ho(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Fa(it);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a)||o,a};return r.cache=new(Ho.Cache||$e),r}function Xo(t){if("function"!=typeof t)throw new Fa(it);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Yo(t,e){return t===e||t!==t&&e!==e}function qo(t){return null!=t&&Jo(t.length)&&!Ko(t)}function $o(t){return ea(t)&&qo(t)}function Zo(t){if(!ea(t))return!1;var e=Xr(t);return e==Gt||e==jt||"string"==typeof t.message&&"string"==typeof t.name&&!na(t)}function Ko(t){if(!ta(t))return!1;var e=Xr(t);return e==Wt||e==Ht||e==Ut||e==Zt}function Qo(t){return"number"==typeof t&&t==ca(t)}function Jo(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Lt}function ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ea(t){return null!=t&&"object"==typeof t}function ra(t){return"number"==typeof t||ea(t)&&Xr(t)==Yt}function na(t){if(!ea(t)||Xr(t)!=$t)return!1;var e=es(t);if(null===e)return!0;var r=Wa.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Ga.call(r)==qa}function ia(t){return"string"==typeof t||!Wc(t)&&ea(t)&&Xr(t)==Jt}function oa(t){return"symbol"==typeof t||ea(t)&&Xr(t)==te}function aa(t){if(!t)return[];if(qo(t))return ia(t)?K(t):ai(t);if(as&&t[as])return j(t[as]());var e=tc(t);return(e==Xt?G:e==Qt?X:ya)(t)}function sa(t){return t?(t=ua(t))===Pt||t===-Pt?(t<0?-1:1)*Rt:t===t?t:0:0===t?t:0}function ca(t){var e=sa(t),r=e%1;return e===e?r?e-r:e:0}function la(t){return t?pr(ca(t),0,It):0}function ua(t){if("number"==typeof t)return t;if(oa(t))return Nt;if(ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Re,"");var r=je.test(t);return r||We.test(t)?Ar(t.slice(2),r?2:8):Ve.test(t)?Nt:+t}function ha(t){return si(t,ga(t))}function pa(t){return null==t?"":zn(t)}function fa(t,e,r){var n=null==t?et:Br(t,e);return n===et?r:n}function da(t,e){return null!=t&&Ki(t,e,$r)}function ma(t){return qo(t)?Qe(t):sn(t)}function ga(t){return qo(t)?Qe(t,!0):cn(t)}function va(t,e){if(null==t)return{};var r=p(Vi(t),function(t){return[t]});return e=Wi(e),yn(t,r,function(t,r){return e(t,r[0])})}function ya(t){return null==t?[]:I(t,ma(t))}function _a(t){return Sl(pa(t).toLowerCase())}function xa(t){return(t=pa(t))&&t.replace(Xe,Vr).replace(hr,"")}function ba(t,e,r){return t=pa(t),(e=r?et:e)===et?V(t)?tt(t):y(t):t.match(e)||[]}function wa(t){return function(){return t}}function Sa(t){return t}function Ma(t){return an("function"==typeof t?t:fr(t,ct))}function Aa(t,e,r){var n=ma(e),i=Ir(e,n);null!=r||ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Ir(e,ma(e)));var o=!(ta(r)&&"chain"in r&&!r.chain),s=Ko(t);return a(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=ai(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,f([this.value()],arguments))})}),t}function Ea(){}function Ca(t){return oo(t)?A(wo(t)):_n(t)}function Ta(){return[]}function Pa(){return!1}var La=(e=null==e?Tr:Wr.defaults(Tr.Object(),e,Wr.pick(Tr,gr))).Array,Ra=e.Date,Na=e.Error,Ia=e.Function,Oa=e.Math,Da=e.Object,za=e.RegExp,ka=e.String,Fa=e.TypeError,Ua=La.prototype,Ba=Ia.prototype,Va=Da.prototype,ja=e["__core-js_shared__"],Ga=Ba.toString,Wa=Va.hasOwnProperty,Ha=0,Xa=function(){var t=/[^.]+$/.exec(ja&&ja.keys&&ja.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ya=Va.toString,qa=Ga.call(Da),$a=Tr._,Za=za("^"+Ga.call(Wa).replace(Pe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ka=Rr?e.Buffer:et,Qa=e.Symbol,Ja=e.Uint8Array,ts=Ka?Ka.allocUnsafe:et,es=W(Da.getPrototypeOf,Da),rs=Da.create,ns=Va.propertyIsEnumerable,is=Ua.splice,os=Qa?Qa.isConcatSpreadable:et,as=Qa?Qa.iterator:et,ss=Qa?Qa.toStringTag:et,cs=function(){try{var t=Yi(Da,"defineProperty");return t({},"",{}),t}catch(t){}}(),ls=e.clearTimeout!==Tr.clearTimeout&&e.clearTimeout,us=Ra&&Ra.now!==Tr.Date.now&&Ra.now,hs=e.setTimeout!==Tr.setTimeout&&e.setTimeout,ps=Oa.ceil,fs=Oa.floor,ds=Da.getOwnPropertySymbols,ms=Ka?Ka.isBuffer:et,gs=e.isFinite,vs=Ua.join,ys=W(Da.keys,Da),_s=Oa.max,xs=Oa.min,bs=Ra.now,ws=e.parseInt,Ss=Oa.random,Ms=Ua.reverse,As=Yi(e,"DataView"),Es=Yi(e,"Map"),Cs=Yi(e,"Promise"),Ts=Yi(e,"Set"),Ps=Yi(e,"WeakMap"),Ls=Yi(Da,"create"),Rs=Ps&&new Ps,Ns={},Is=So(As),Os=So(Es),Ds=So(Cs),zs=So(Ts),ks=So(Ps),Fs=Qa?Qa.prototype:et,Us=Fs?Fs.valueOf:et,Bs=Fs?Fs.toString:et,Vs=function(){function t(){}return function(e){if(!ta(e))return{};if(rs)return rs(e);t.prototype=e;var r=new t;return t.prototype=et,r}}();v.templateSettings={escape:we,evaluate:Se,interpolate:Me,variable:"",imports:{_:v}},v.prototype=E.prototype,v.prototype.constructor=v,q.prototype=Vs(E.prototype),q.prototype.constructor=q,Q.prototype=Vs(E.prototype),Q.prototype.constructor=Q,J.prototype.clear=function(){this.__data__=Ls?Ls(null):{},this.size=0},J.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},J.prototype.get=function(t){var e=this.__data__;if(Ls){var r=e[t];return r===ot?et:r}return Wa.call(e,t)?e[t]:et},J.prototype.has=function(t){var e=this.__data__;return Ls?e[t]!==et:Wa.call(e,t)},J.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ls&&e===et?ot:e,this},ke.prototype.clear=function(){this.__data__=[],this.size=0},ke.prototype.delete=function(t){var e=this.__data__,r=ir(e,t);return!(r<0||(r==e.length-1?e.pop():is.call(e,r,1),--this.size,0))},ke.prototype.get=function(t){var e=this.__data__,r=ir(e,t);return r<0?et:e[r][1]},ke.prototype.has=function(t){return ir(this.__data__,t)>-1},ke.prototype.set=function(t,e){var r=this.__data__,n=ir(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},$e.prototype.clear=function(){this.size=0,this.__data__={hash:new J,map:new(Es||ke),string:new J}},$e.prototype.delete=function(t){var e=Hi(this,t).delete(t);return this.size-=e?1:0,e},$e.prototype.get=function(t){return Hi(this,t).get(t)},$e.prototype.has=function(t){return Hi(this,t).has(t)},$e.prototype.set=function(t,e){var r=Hi(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Ze.prototype.add=Ze.prototype.push=function(t){return this.__data__.set(t,ot),this},Ze.prototype.has=function(t){return this.__data__.has(t)},Ke.prototype.clear=function(){this.__data__=new ke,this.size=0},Ke.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Ke.prototype.get=function(t){return this.__data__.get(t)},Ke.prototype.has=function(t){return this.__data__.has(t)},Ke.prototype.set=function(t,e){var r=this.__data__;if(r instanceof ke){var n=r.__data__;if(!Es||n.length1?t[e-1]:et;return r="function"==typeof r?(t.pop(),r):et,Oo(t,r)}),Sc=Ui(function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return lr(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Q&&no(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:zo,args:[i],thisArg:et}),new q(n,this.__chain__).thru(function(t){return e&&!t.length&&t.push(et),t})):this.thru(i)}),Mc=ui(function(t,e,r){Wa.call(t,r)?++t[r]:cr(t,r,1)}),Ac=_i(Eo),Ec=_i(Co),Cc=ui(function(t,e,r){Wa.call(t,r)?t[r].push(e):cr(t,r,[e])}),Tc=An(function(t,e,r){var n=-1,o="function"==typeof e,a=qo(t)?La(t.length):[];return js(t,function(t){a[++n]=o?i(e,t,r):Jr(t,e,r)}),a}),Pc=ui(function(t,e,r){cr(t,r,e)}),Lc=ui(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]}),Rc=An(function(t,e){if(null==t)return[];var r=e.length;return r>1&&io(t,e[0],e[1])?e=[]:r>2&&io(e[0],e[1],e[2])&&(e=[e[0]]),gn(t,Pr(e,1),[])}),Nc=us||function(){return Tr.Date.now()},Ic=An(function(t,e,r){var n=ft;if(r.length){var i=H(r,Gi(Ic));n|=yt}return Ni(t,n,e,r,i)}),Oc=An(function(t,e,r){var n=ft|dt;if(r.length){var i=H(r,Gi(Oc));n|=yt}return Ni(e,n,t,r,i)}),Dc=An(function(t,e){return xr(t,1,e)}),zc=An(function(t,e,r){return xr(t,ua(e)||0,r)});Ho.Cache=$e;var kc=qs(function(t,e){var r=(e=1==e.length&&Wc(e[0])?p(e[0],N(Wi())):p(Pr(e,1),N(Wi()))).length;return An(function(n){for(var o=-1,a=xs(n.length,r);++o=e}),Gc=tn(function(){return arguments}())?tn:function(t){return ea(t)&&Wa.call(t,"callee")&&!ns.call(t,"callee")},Wc=La.isArray,Hc=Or?N(Or):function(t){return ea(t)&&Xr(t)==ie},Xc=ms||Pa,Yc=Dr?N(Dr):function(t){return ea(t)&&Xr(t)==Vt},qc=zr?N(zr):function(t){return ea(t)&&tc(t)==Xt},$c=kr?N(kr):function(t){return ea(t)&&Xr(t)==Kt},Zc=Fr?N(Fr):function(t){return ea(t)&&tc(t)==Qt},Kc=Ur?N(Ur):function(t){return ea(t)&&Jo(t.length)&&!!yr[Xr(t)]},Qc=Ti(ln),Jc=Ti(function(t,e){return t<=e}),tl=hi(function(t,e){if(lo(e)||qo(e))si(e,ma(e),t);else for(var r in e)Wa.call(e,r)&&nr(t,r,e[r])}),el=hi(function(t,e){si(e,ga(e),t)}),rl=hi(function(t,e,r,n){si(e,ga(e),t,n)}),nl=hi(function(t,e,r,n){si(e,ma(e),t,n)}),il=Ui(lr),ol=An(function(t){return t.push(et,Ii),i(rl,et,t)}),al=An(function(t){return t.push(et,Oi),i(hl,et,t)}),sl=wi(function(t,e,r){t[e]=r},wa(Sa)),cl=wi(function(t,e,r){Wa.call(t,e)?t[e].push(r):t[e]=[r]},Wi),ll=An(Jr),ul=hi(function(t,e,r){fn(t,e,r)}),hl=hi(function(t,e,r,n){fn(t,e,r,n)}),pl=Ui(function(t,e){var r={};if(null==t)return r;var n=!1;e=p(e,function(e){return e=Xn(e,t),n||(n=e.length>1),e}),si(t,Vi(t),r),n&&(r=fr(r,ct|lt|ut,Di));for(var i=e.length;i--;)Fn(r,e[i]);return r}),fl=Ui(function(t,e){return null==t?{}:vn(t,e)}),dl=Ri(ma),ml=Ri(ga),gl=gi(function(t,e,r){return e=e.toLowerCase(),t+(r?_a(e):e)}),vl=gi(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),yl=gi(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),_l=mi("toLowerCase"),xl=gi(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}),bl=gi(function(t,e,r){return t+(r?" ":"")+Sl(e)}),wl=gi(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),Sl=mi("toUpperCase"),Ml=An(function(t,e){try{return i(t,et,e)}catch(t){return Zo(t)?t:new Na(t)}}),Al=Ui(function(t,e){return a(e,function(e){e=wo(e),cr(t,e,Ic(t[e],t))}),t}),El=xi(),Cl=xi(!0),Tl=An(function(t,e){return function(r){return Jr(r,t,e)}}),Pl=An(function(t,e){return function(r){return Jr(t,r,e)}}),Ll=Mi(p),Rl=Mi(c),Nl=Mi(g),Il=Ci(),Ol=Ci(!0),Dl=Si(function(t,e){return t+e},0),zl=Li("ceil"),kl=Si(function(t,e){return t/e},1),Fl=Li("floor"),Ul=Si(function(t,e){return t*e},1),Bl=Li("round"),Vl=Si(function(t,e){return t-e},0);return v.after=function(t,e){if("function"!=typeof e)throw new Fa(it);return t=ca(t),function(){if(--t<1)return e.apply(this,arguments)}},v.ary=Bo,v.assign=tl,v.assignIn=el,v.assignInWith=rl,v.assignWith=nl,v.at=il,v.before=Vo,v.bind=Ic,v.bindAll=Al,v.bindKey=Oc,v.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Wc(t)?t:[t]},v.chain=Do,v.chunk=function(t,e,r){e=(r?io(t,e,r):e===et)?1:_s(ca(e),0);var n=null==t?0:t.length;if(!n||e<1)return[];for(var i=0,o=0,a=La(ps(n/e));i>>0)?(t=pa(t))&&("string"==typeof e||null!=e&&!$c(e))&&!(e=zn(e))&&B(t)?Yn(K(t),0,r):t.split(e,r):[]},v.spread=function(t,e){if("function"!=typeof t)throw new Fa(it);return e=null==e?0:_s(ca(e),0),An(function(r){var n=r[e],o=Yn(r,0,e);return n&&f(o,n),i(t,this,o)})},v.tail=function(t){var e=null==t?0:t.length;return e?Ln(t,1,e):[]},v.take=function(t,e,r){return t&&t.length?(e=r||e===et?1:ca(e),Ln(t,0,e<0?0:e)):[]},v.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?(e=r||e===et?1:ca(e),e=n-e,Ln(t,e<0?0:e,n)):[]},v.takeRightWhile=function(t,e){return t&&t.length?Bn(t,Wi(e,3),!1,!0):[]},v.takeWhile=function(t,e){return t&&t.length?Bn(t,Wi(e,3)):[]},v.tap=function(t,e){return e(t),t},v.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new Fa(it);return ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Wo(t,e,{leading:n,maxWait:e,trailing:i})},v.thru=zo,v.toArray=aa,v.toPairs=dl,v.toPairsIn=ml,v.toPath=function(t){return Wc(t)?p(t,wo):oa(t)?[t]:ai(oc(pa(t)))},v.toPlainObject=ha,v.transform=function(t,e,r){var n=Wc(t),i=n||Xc(t)||Kc(t);if(e=Wi(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:ta(t)&&Ko(o)?Vs(es(t)):{}}return(i?a:Lr)(t,function(t,n,i){return e(r,t,n,i)}),r},v.unary=function(t){return Bo(t,1)},v.union=dc,v.unionBy=mc,v.unionWith=gc,v.uniq=function(t){return t&&t.length?kn(t):[]},v.uniqBy=function(t,e){return t&&t.length?kn(t,Wi(e,2)):[]},v.uniqWith=function(t,e){return e="function"==typeof e?e:et,t&&t.length?kn(t,et,e):[]},v.unset=function(t,e){return null==t||Fn(t,e)},v.unzip=Io,v.unzipWith=Oo,v.update=function(t,e,r){return null==t?t:Un(t,e,Hn(r))},v.updateWith=function(t,e,r,n){return n="function"==typeof n?n:et,null==t?t:Un(t,e,Hn(r),n)},v.values=ya,v.valuesIn=function(t){return null==t?[]:I(t,ga(t))},v.without=vc,v.words=ba,v.wrap=function(t,e){return Fc(Hn(e),t)},v.xor=yc,v.xorBy=_c,v.xorWith=xc,v.zip=bc,v.zipObject=function(t,e){return Gn(t||[],e||[],nr)},v.zipObjectDeep=function(t,e){return Gn(t||[],e||[],Tn)},v.zipWith=wc,v.entries=dl,v.entriesIn=ml,v.extend=el,v.extendWith=rl,Aa(v,v),v.add=Dl,v.attempt=Ml,v.camelCase=gl,v.capitalize=_a,v.ceil=zl,v.clamp=function(t,e,r){return r===et&&(r=e,e=et),r!==et&&(r=(r=ua(r))===r?r:0),e!==et&&(e=(e=ua(e))===e?e:0),pr(ua(t),e,r)},v.clone=function(t){return fr(t,ut)},v.cloneDeep=function(t){return fr(t,ct|ut)},v.cloneDeepWith=function(t,e){return e="function"==typeof e?e:et,fr(t,ct|ut,e)},v.cloneWith=function(t,e){return e="function"==typeof e?e:et,fr(t,ut,e)},v.conformsTo=function(t,e){return null==e||mr(t,e,ma(e))},v.deburr=xa,v.defaultTo=function(t,e){return null==t||t!==t?e:t},v.divide=kl,v.endsWith=function(t,e,r){t=pa(t),e=zn(e);var n=t.length,i=r=r===et?n:pr(ca(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},v.eq=Yo,v.escape=function(t){return(t=pa(t))&&be.test(t)?t.replace(_e,jr):t},v.escapeRegExp=function(t){return(t=pa(t))&&Le.test(t)?t.replace(Pe,"\\$&"):t},v.every=function(t,e,r){var n=Wc(t)?c:wr;return r&&io(t,e,r)&&(e=et),n(t,Wi(e,3))},v.find=Ac,v.findIndex=Eo,v.findKey=function(t,e){return _(t,Wi(e,3),Lr)},v.findLast=Ec,v.findLastIndex=Co,v.findLastKey=function(t,e){return _(t,Wi(e,3),Nr)},v.floor=Fl,v.forEach=ko,v.forEachRight=Fo,v.forIn=function(t,e){return null==t?t:Ws(t,Wi(e,3),ga)},v.forInRight=function(t,e){return null==t?t:Hs(t,Wi(e,3),ga)},v.forOwn=function(t,e){return t&&Lr(t,Wi(e,3))},v.forOwnRight=function(t,e){return t&&Nr(t,Wi(e,3))},v.get=fa,v.gt=Vc,v.gte=jc,v.has=function(t,e){return null!=t&&Ki(t,e,qr)},v.hasIn=da,v.head=Po,v.identity=Sa,v.includes=function(t,e,r,n){t=qo(t)?t:ya(t),r=r&&!n?ca(r):0;var i=t.length;return r<0&&(r=_s(i+r,0)),ia(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&b(t,e,r)>-1},v.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:ca(r);return i<0&&(i=_s(n+i,0)),b(t,e,i)},v.inRange=function(t,e,r){return e=sa(e),r===et?(r=e,e=0):r=sa(r),t=ua(t),Zr(t,e,r)},v.invoke=ll,v.isArguments=Gc,v.isArray=Wc,v.isArrayBuffer=Hc,v.isArrayLike=qo,v.isArrayLikeObject=$o,v.isBoolean=function(t){return!0===t||!1===t||ea(t)&&Xr(t)==Bt},v.isBuffer=Xc,v.isDate=Yc,v.isElement=function(t){return ea(t)&&1===t.nodeType&&!na(t)},v.isEmpty=function(t){if(null==t)return!0;if(qo(t)&&(Wc(t)||"string"==typeof t||"function"==typeof t.splice||Xc(t)||Kc(t)||Gc(t)))return!t.length;var e=tc(t);if(e==Xt||e==Qt)return!t.size;if(lo(t))return!sn(t).length;for(var r in t)if(Wa.call(t,r))return!1;return!0},v.isEqual=function(t,e){return en(t,e)},v.isEqualWith=function(t,e,r){var n=(r="function"==typeof r?r:et)?r(t,e):et;return n===et?en(t,e,et,r):!!n},v.isError=Zo,v.isFinite=function(t){return"number"==typeof t&&gs(t)},v.isFunction=Ko,v.isInteger=Qo,v.isLength=Jo,v.isMap=qc,v.isMatch=function(t,e){return t===e||nn(t,e,Xi(e))},v.isMatchWith=function(t,e,r){return r="function"==typeof r?r:et,nn(t,e,Xi(e),r)},v.isNaN=function(t){return ra(t)&&t!=+t},v.isNative=function(t){if(ec(t))throw new Na(nt);return on(t)},v.isNil=function(t){return null==t},v.isNull=function(t){return null===t},v.isNumber=ra,v.isObject=ta,v.isObjectLike=ea,v.isPlainObject=na,v.isRegExp=$c,v.isSafeInteger=function(t){return Qo(t)&&t>=-Lt&&t<=Lt},v.isSet=Zc,v.isString=ia,v.isSymbol=oa,v.isTypedArray=Kc,v.isUndefined=function(t){return t===et},v.isWeakMap=function(t){return ea(t)&&tc(t)==re},v.isWeakSet=function(t){return ea(t)&&Xr(t)==ne},v.join=function(t,e){return null==t?"":vs.call(t,e)},v.kebabCase=vl,v.last=Lo,v.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==et&&(i=(i=ca(r))<0?_s(n+i,0):xs(i,n-1)),e===e?$(t,e,i):x(t,S,i,!0)},v.lowerCase=yl,v.lowerFirst=_l,v.lt=Qc,v.lte=Jc,v.max=function(t){return t&&t.length?Sr(t,Sa,Yr):et},v.maxBy=function(t,e){return t&&t.length?Sr(t,Wi(e,2),Yr):et},v.mean=function(t){return M(t,Sa)},v.meanBy=function(t,e){return M(t,Wi(e,2))},v.min=function(t){return t&&t.length?Sr(t,Sa,ln):et},v.minBy=function(t,e){return t&&t.length?Sr(t,Wi(e,2),ln):et},v.stubArray=Ta,v.stubFalse=Pa,v.stubObject=function(){return{}},v.stubString=function(){return""},v.stubTrue=function(){return!0},v.multiply=Ul,v.nth=function(t,e){return t&&t.length?mn(t,ca(e)):et},v.noConflict=function(){return Tr._===this&&(Tr._=$a),this},v.noop=Ea,v.now=Nc,v.pad=function(t,e,r){t=pa(t);var n=(e=ca(e))?Z(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Ai(fs(i),r)+t+Ai(ps(i),r)},v.padEnd=function(t,e,r){t=pa(t);var n=(e=ca(e))?Z(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Ss();return xs(t+i*(e-t+Mr("1e-"+((i+"").length-1))),e)}return wn(t,e)},v.reduce=function(t,e,r){var n=Wc(t)?d:C,i=arguments.length<3;return n(t,Wi(e,4),r,i,js)},v.reduceRight=function(t,e,r){var n=Wc(t)?m:C,i=arguments.length<3;return n(t,Wi(e,4),r,i,Gs)},v.repeat=function(t,e,r){return e=(r?io(t,e,r):e===et)?1:ca(e),Mn(pa(t),e)},v.replace=function(){var t=arguments,e=pa(t[0]);return t.length<3?e:e.replace(t[1],t[2])},v.result=function(t,e,r){var n=-1,i=(e=Xn(e,t)).length;for(i||(i=1,t=et);++nLt)return[];var r=It,n=xs(t,It);e=Wi(e),t-=It;for(var i=L(n,e);++r=o)return t;var s=r-Z(n);if(s<1)return n;var c=a?Yn(a,0,s).join(""):t.slice(0,s);if(i===et)return c+n;if(a&&(s+=c.length-s),$c(i)){if(t.slice(s).search(i)){var l,u=c;for(i.global||(i=za(i.source,pa(Be.exec(i))+"g")),i.lastIndex=0;l=i.exec(u);)var h=l.index;c=c.slice(0,h===et?s:h)}}else if(t.indexOf(zn(i),s)!=s){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},v.unescape=function(t){return(t=pa(t))&&xe.test(t)?t.replace(ye,Gr):t},v.uniqueId=function(t){var e=++Ha;return pa(t)+e},v.upperCase=wl,v.upperFirst=Sl,v.each=ko,v.eachRight=Fo,v.first=Po,Aa(v,function(){var t={};return Lr(v,function(e,r){Wa.call(v.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),v.VERSION="4.17.4",a(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){v[t].placeholder=v}),a(["drop","take"],function(t,e){Q.prototype[t]=function(r){r=r===et?1:_s(ca(r),0);var n=this.__filtered__&&!e?new Q(this):this.clone();return n.__filtered__?n.__takeCount__=xs(r,n.__takeCount__):n.__views__.push({size:xs(r,It),type:t+(n.__dir__<0?"Right":"")}),n},Q.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),a(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==Ct||3==r;Q.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Wi(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),a(["head","last"],function(t,e){var r="take"+(e?"Right":"");Q.prototype[t]=function(){return this[r](1).value()[0]}}),a(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");Q.prototype[t]=function(){return this.__filtered__?new Q(this):this[r](1)}}),Q.prototype.compact=function(){return this.filter(Sa)},Q.prototype.find=function(t){return this.filter(t).head()},Q.prototype.findLast=function(t){return this.reverse().find(t)},Q.prototype.invokeMap=An(function(t,e){return"function"==typeof t?new Q(this):this.map(function(r){return Jr(r,t,e)})}),Q.prototype.reject=function(t){return this.filter(Xo(Wi(t)))},Q.prototype.slice=function(t,e){t=ca(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Q(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==et&&(r=(e=ca(e))<0?r.dropRight(-e):r.take(e-t)),r)},Q.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Q.prototype.toArray=function(){return this.take(It)},Lr(Q.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=v[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);i&&(v.prototype[e]=function(){var e=this.__wrapped__,a=n?[1]:arguments,s=e instanceof Q,c=a[0],l=s||Wc(e),u=function(t){var e=i.apply(v,f([t],a));return n&&h?e[0]:e};l&&r&&"function"==typeof c&&1!=c.length&&(s=l=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,m=s&&!p;if(!o&&l){e=m?e:new Q(this);var g=t.apply(e,a);return g.__actions__.push({func:zo,args:[u],thisArg:et}),new q(g,h)}return d&&m?t.apply(this,a):(g=this.thru(u),d?n?g.value()[0]:g.value():g)})}),a(["pop","push","shift","sort","splice","unshift"],function(t){var e=Ua[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);v.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Wc(i)?i:[],t)}return this[r](function(r){return e.apply(Wc(r)?r:[],t)})}}),Lr(Q.prototype,function(t,e){var r=v[e];if(r){var n=r.name+"";(Ns[n]||(Ns[n]=[])).push({name:e,func:r})}}),Ns[bi(et,dt).name]=[{name:"wrapper",func:et}],Q.prototype.clone=function(){var t=new Q(this.__wrapped__);return t.__actions__=ai(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=ai(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=ai(this.__views__),t},Q.prototype.reverse=function(){if(this.__filtered__){var t=new Q(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Q.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Wc(t),n=e<0,i=r?t.length:0,o=$i(0,i,this.__views__),a=o.start,s=o.end,c=s-a,l=n?s:a-1,u=this.__iteratees__,h=u.length,p=0,f=xs(c,this.__takeCount__);if(!r||!n&&i==c&&f==c)return Vn(t,this.__actions__);var d=[];t:for(;c--&&p=this.__values__.length;return{done:t,value:t?et:this.__values__[this.__index__++]}},v.prototype.plant=function(t){for(var e,r=this;r instanceof E;){var n=Ao(r);n.__index__=0,n.__values__=et,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},v.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Q){var e=t;return this.__actions__.length&&(e=new Q(this)),(e=e.reverse()).__actions__.push({func:zo,args:[No],thisArg:et}),new q(e,this.__chain__)}return this.thru(No)},v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=function(){return Vn(this.__wrapped__,this.__actions__)},v.prototype.first=v.prototype.head,as&&(v.prototype[as]=function(){return this}),v}();"function"==typeof et&&"object"==typeof et.amd&&et.amd?Tr._=Wr:Lr?((Lr.exports=Wr)._=Wr,Pr._=Wr):Tr._=Wr}).call(bu)});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]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>=4,r[i]=e[19===i?3&t|8:t]);return r.join("")}}(),clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*Tp.DEG2RAD},radToDeg:function(t){return t*Tp.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}};n.prototype={constructor:n,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)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return 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(r,i){return void 0===t&&(t=new n,e=new n),t.set(r,r),e.set(i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.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,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*r-o*n+t.x,this.y=i*n+o*r+t.y,this}};var Pp=0;i.DEFAULT_IMAGE=void 0,i.DEFAULT_MAPPING=300,i.prototype={constructor:i,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 r=this.image;void 0===r.uuid&&(r.uuid=Tp.generateUUID()),void 0===t.images[r.uuid]&&(t.images[r.uuid]={uuid:r.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")}(r)}),e.image=r.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300===this.mapping){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case Lh:t.x=t.x-Math.floor(t.x);break;case Rh:t.x=t.x<0?0:1;break;case Nh: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 Lh:t.y=t.y-Math.floor(t.y);break;case Rh:t.y=t.y<0?0:1;break;case Nh: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(i.prototype,r.prototype),o.prototype={constructor:o,isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*n+o[12]*i,this.y=o[1]*e+o[5]*r+o[9]*n+o[13]*i,this.z=o[2]*e+o[6]*r+o[10]*n+o[14]*i,this.w=o[3]*e+o[7]*r+o[11]*n+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,o=t.elements,a=o[0],s=o[4],c=o[8],l=o[1],u=o[5],h=o[9],p=o[2],f=o[6],d=o[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+p)<.1&&Math.abs(h+f)<.1&&Math.abs(a+u+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(u+1)/2,v=(d+1)/2,y=(s+l)/4,_=(c+p)/4,x=(h+f)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(n=y/(r=Math.sqrt(m)),i=_/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(r=y/(n=Math.sqrt(g)),i=x/n):v<.01?(r=.707106781,n=.707106781,i=0):(r=_/(i=Math.sqrt(v)),n=x/i),this.set(r,n,i,e),this}var b=Math.sqrt((f-h)*(f-h)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(f-h)/b,this.y=(c-p)/b,this.z=(l-s)/b,this.w=Math.acos((a+u+d-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new o,e=new o),t.set(r,r,r,r),e.set(n,n,n,n),this.clamp(t,e)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},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.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}},a.prototype={constructor:a,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(a.prototype,r.prototype),s.prototype=Object.create(a.prototype),s.prototype.constructor=s,s.prototype.isWebGLRenderTargetCube=!0,c.prototype={constructor:c,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get w(){return this._w},set w(t){this._w=t,this.onChangeCallback()},set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!1===(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=Math.cos(t._x/2),n=Math.cos(t._y/2),i=Math.cos(t._z/2),o=Math.sin(t._x/2),a=Math.sin(t._y/2),s=Math.sin(t._z/2),c=t.order;return"XYZ"===c?(this._x=o*n*i+r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i-o*a*s):"YXZ"===c?(this._x=o*n*i+r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i+o*a*s):"ZXY"===c?(this._x=o*n*i-r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i-o*a*s):"ZYX"===c?(this._x=o*n*i-r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i+o*a*s):"YZX"===c?(this._x=o*n*i+r*a*s,this._y=r*a*i+o*n*s,this._z=r*n*s-o*a*i,this._w=r*n*i-o*a*s):"XZY"===c&&(this._x=o*n*i-r*a*s,this._y=r*a*i-o*n*s,this._z=r*n*s+o*a*i,this._w=r*n*i+o*a*s),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],o=r[8],a=r[1],s=r[5],c=r[9],l=r[2],u=r[6],h=r[10],p=n+s+h;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(u-c)*e,this._y=(o-l)*e,this._z=(a-i)*e):n>s&&n>h?(e=2*Math.sqrt(1+n-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+l)/e):s>h?(e=2*Math.sqrt(1+s-n-h),this._w=(o-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-n-s),this._w=(a-i)/e,this._x=(o+l)/e,this._y=(c+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e;return function(r,n){return void 0===t&&(t=new l),(e=r.dot(n)+1)<1e-6?(e=0,Math.abs(r.x)>Math.abs(r.z)?t.set(-r.y,r.x,0):t.set(0,-r.z,r.y)):t.crossVectors(r,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 r=t._x,n=t._y,i=t._z,o=t._w,a=e._x,s=e._y,c=e._z,l=e._w;return this._x=r*l+o*a+n*c-i*s,this._y=n*l+o*s+i*a-r*c,this._z=i*l+o*c+r*s-n*a,this._w=o*l-r*a-n*s-i*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,o=this._w,a=o*t._w+r*t._x+n*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var c=Math.atan2(s,a),l=Math.sin((1-e)*c)/s,u=Math.sin(e*c)/s;return this._w=o*l+this._w*u,this._x=r*l+this._x*u,this._y=n*l+this._y*u,this._z=i*l+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(c,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,o,a){var s=r[n+0],c=r[n+1],l=r[n+2],u=r[n+3],h=i[o+0],p=i[o+1],f=i[o+2],d=i[o+3];if(u!==d||s!==h||c!==p||l!==f){var m=1-a,g=s*h+c*p+l*f+u*d,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var _=Math.sqrt(y),x=Math.atan2(_,g*v);m=Math.sin(m*x)/_,a=Math.sin(a*x)/_}var b=a*v;if(s=s*m+h*b,c=c*m+p*b,l=l*m+f*b,u=u*m+d*b,m===1-a){var w=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=w,c*=w,l*=w,u*=w}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),l.prototype={constructor:l,isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?this.multiplyVectors(t,e):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return 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 c),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t;return function(e,r){return void 0===t&&(t=new c),this.applyQuaternion(t.setFromAxisAngle(e,r))}}(),applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;this.x=i[0]*e+i[4]*r+i[8]*n+i[12],this.y=i[1]*e+i[5]*r+i[9]*n+i[13],this.z=i[2]*e+i[6]*r+i[10]*n+i[14];var o=i[3]*e+i[7]*r+i[11]*n+i[15];return this.divideScalar(o)},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*n-a*r,l=s*r+a*e-i*n,u=s*n+i*r-o*e,h=-i*e-o*r-a*n;return this.x=c*s+h*-i+l*-a-u*-o,this.y=l*s+h*-o+u*-i-c*-a,this.z=u*s+h*-a+c*-o-l*-i,this},project:function(){var t;return function(e){return void 0===t&&(t=new u),t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t;return function(e){return void 0===t&&(t=new u),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(r,n){return void 0===t&&(t=new l,e=new l),t.set(r,r,r),e.set(n,n,n),this.clamp(t,e)}}(),clampLength:function(t,e){var r=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},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,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){if(void 0!==e)return this.crossVectors(t,e);var r=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-r*t.z,this.z=r*t.y-n*t.x,this},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*o-r*s,this.z=r*a-n*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t;return function(e){return void 0===t&&(t=new l),t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t;return function(e){return void 0===t&&(t=new l),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(Tp.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){if("number"==typeof t){var r=t;t=e,e=r}return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}},u.prototype={constructor:u,isMatrix4:!0,set:function(t,e,r,n,i,o,a,s,c,l,u,h,p,f,d,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=r,g[12]=n,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=h,g[3]=p,g[7]=f,g[11]=d,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new u).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(){var t;return function(e){void 0===t&&(t=new l);var r=this.elements,n=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*o,r[5]=n[5]*o,r[6]=n[6]*o,r[8]=n[8]*a,r[9]=n[9]*a,r[10]=n[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler;var e=this.elements,r=t.x,n=t.y,i=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(n),c=Math.sin(n),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=p+f*c,e[5]=h-d*c,e[9]=-a*s,e[2]=d-h*c,e[6]=f+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){var m=s*l,g=s*u,v=c*l,y=c*u;e[0]=m-y*a,e[4]=-o*u,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){var h=o*l,p=o*u,f=a*l,d=a*u;e[0]=s*l,e[4]=f*c-p,e[8]=h*c+d,e[1]=s*u,e[5]=d*c+h,e[9]=p*c-f,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=w-_*u,e[8]=b*u+x,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-c*l,e[6]=x*u+b,e[10]=_-w*u}else if("XZY"===t.order){var _=o*s,x=o*c,b=a*s,w=a*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=_*u+w,e[5]=o*l,e[9]=x*u-b,e[2]=b*u-x,e[6]=a*l,e[10]=w*u+_}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,r=t.x,n=t.y,i=t.z,o=t.w,a=r+r,s=n+n,c=i+i,l=r*a,u=r*s,h=r*c,p=n*s,f=n*c,d=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(p+d),e[4]=u-v,e[8]=h+g,e[1]=u+v,e[5]=1-(l+d),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(l+p),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t,e,r;return function(n,i,o){void 0===t&&(t=new l,e=new l,r=new l);var a=this.elements;return r.subVectors(n,i).normalize(),0===r.lengthSq()&&(r.z=1),t.crossVectors(o,r).normalize(),0===t.lengthSq()&&(r.z+=1e-4,t.crossVectors(o,r).normalize()),e.crossVectors(r,t),a[0]=t.x,a[4]=e.x,a[8]=r.x,a[1]=t.y,a[5]=e.y,a[9]=r.y,a[2]=t.z,a[6]=e.z,a[10]=r.z,this}}(),multiply:function(t,e){return void 0!==e?this.multiplyMatrices(t,e):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,o=r[0],a=r[4],s=r[8],c=r[12],l=r[1],u=r[5],h=r[9],p=r[13],f=r[2],d=r[6],m=r[10],g=r[14],v=r[3],y=r[7],_=r[11],x=r[15],b=n[0],w=n[4],S=n[8],M=n[12],A=n[1],E=n[5],C=n[9],T=n[13],P=n[2],L=n[6],R=n[10],N=n[14],I=n[3],O=n[7],D=n[11],z=n[15];return i[0]=o*b+a*A+s*P+c*I,i[4]=o*w+a*E+s*L+c*O,i[8]=o*S+a*C+s*R+c*D,i[12]=o*M+a*T+s*N+c*z,i[1]=l*b+u*A+h*P+p*I,i[5]=l*w+u*E+h*L+p*O,i[9]=l*S+u*C+h*R+p*D,i[13]=l*M+u*T+h*N+p*z,i[2]=f*b+d*A+m*P+g*I,i[6]=f*w+d*E+m*L+g*O,i[10]=f*S+d*C+m*R+g*D,i[14]=f*M+d*T+m*N+g*z,i[3]=v*b+y*A+_*P+x*I,i[7]=v*w+y*E+_*L+x*O,i[11]=v*S+y*C+_*R+x*D,i[15]=v*M+y*T+_*N+x*z,this},multiplyToArray:function(t,e,r){var n=this.elements;return this.multiplyMatrices(t,e),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=n[3],r[4]=n[4],r[5]=n[5],r[6]=n[6],r[7]=n[7],r[8]=n[8],r[9]=n[9],r[10]=n[10],r[11]=n[11],r[12]=n[12],r[13]=n[13],r[14]=n[14],r[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},applyToBufferAttribute:function(){var t;return function(e){void 0===t&&(t=new l);for(var r=0,n=e.count;r 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}\nvec2 ltcTextureCoords( const in GeometricContext geometry, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;\n\tconst float LUT_BIAS = 0.5/LUT_SIZE;\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nvoid clipQuadToHorizon( inout vec3 L[5], out int n ) {\n\tint config = 0;\n\tif ( L[0].z > 0.0 ) config += 1;\n\tif ( L[1].z > 0.0 ) config += 2;\n\tif ( L[2].z > 0.0 ) config += 4;\n\tif ( L[3].z > 0.0 ) config += 8;\n\tn = 0;\n\tif ( config == 0 ) {\n\t} else if ( config == 1 ) {\n\t\tn = 3;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 2 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 3 ) {\n\t\tn = 4;\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t\tL[3] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 4 ) {\n\t\tn = 3;\n\t\tL[0] = -L[3].z * L[2] + L[2].z * L[3];\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t} else if ( config == 5 ) {\n\t\tn = 0;\n\t} else if ( config == 6 ) {\n\t\tn = 4;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 7 ) {\n\t\tn = 5;\n\t\tL[4] = -L[3].z * L[0] + L[0].z * L[3];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 8 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[1] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = L[3];\n\t} else if ( config == 9 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[2].z * L[3] + L[3].z * L[2];\n\t} else if ( config == 10 ) {\n\t\tn = 0;\n\t} else if ( config == 11 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 12 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t} else if ( config == 13 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = L[2];\n\t\tL[2] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t} else if ( config == 14 ) {\n\t\tn = 5;\n\t\tL[4] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t} else if ( config == 15 ) {\n\t\tn = 4;\n\t}\n\tif ( n == 3 )\n\t\tL[3] = L[0];\n\tif ( n == 4 )\n\t\tL[4] = L[0];\n}\nfloat integrateLtcBrdfOverRectEdge( vec3 v1, vec3 v2 ) {\n\tfloat cosTheta = dot( v1, v2 );\n\tfloat theta = acos( cosTheta );\n\tfloat res = cross( v1, v2 ).z * ( ( theta > 0.001 ) ? theta / sin( theta ) : 1.0 );\n\treturn res;\n}\nvoid initRectPoints( const in vec3 pos, const in vec3 halfWidth, const in vec3 halfHeight, out vec3 rectPoints[4] ) {\n\trectPoints[0] = pos - halfWidth - halfHeight;\n\trectPoints[1] = pos + halfWidth - halfHeight;\n\trectPoints[2] = pos + halfWidth + halfHeight;\n\trectPoints[3] = pos - halfWidth + halfHeight;\n}\nvec3 integrateLtcBrdfOverRect( const in GeometricContext geometry, const in mat3 brdfMat, const in vec3 rectPoints[4] ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot( V, N ));\n\tT2 = - cross( N, T1 );\n\tmat3 brdfWrtSurface = brdfMat * transpose( mat3( T1, T2, N ) );\n\tvec3 clippedRect[5];\n\tclippedRect[0] = brdfWrtSurface * ( rectPoints[0] - P );\n\tclippedRect[1] = brdfWrtSurface * ( rectPoints[1] - P );\n\tclippedRect[2] = brdfWrtSurface * ( rectPoints[2] - P );\n\tclippedRect[3] = brdfWrtSurface * ( rectPoints[3] - P );\n\tint n;\n\tclipQuadToHorizon(clippedRect, n);\n\tif ( n == 0 )\n\t\treturn vec3( 0, 0, 0 );\n\tclippedRect[0] = normalize( clippedRect[0] );\n\tclippedRect[1] = normalize( clippedRect[1] );\n\tclippedRect[2] = normalize( clippedRect[2] );\n\tclippedRect[3] = normalize( clippedRect[3] );\n\tclippedRect[4] = normalize( clippedRect[4] );\n\tfloat sum = 0.0;\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[0], clippedRect[1] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[1], clippedRect[2] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[2], clippedRect[3] );\n\tif (n >= 4)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[3], clippedRect[4] );\n\tif (n == 5)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[4], clippedRect[0] );\n\tsum = max( 0.0, sum );\n\tvec3 Lo_i = vec3( sum, sum, sum );\n\treturn Lo_i;\n}\nvec3 Rect_Area_Light_Specular_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight,\n\t\tconst in float roughness,\n\t\tconst in sampler2D ltcMat, const in sampler2D ltcMag ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tvec2 uv = ltcTextureCoords( geometry, roughness );\n\tvec4 brdfLtcApproxParams, t;\n\tbrdfLtcApproxParams = texture2D( ltcMat, uv );\n\tt = texture2D( ltcMat, uv );\n\tfloat brdfLtcScalar = texture2D( ltcMag, uv ).a;\n\tmat3 brdfLtcApproxMat = mat3(\n\t\tvec3( 1, 0, t.y ),\n\t\tvec3( 0, t.z, 0 ),\n\t\tvec3( t.w, 0, t.x )\n\t);\n\tvec3 specularReflectance = integrateLtcBrdfOverRect( geometry, brdfLtcApproxMat, rectPoints );\n\tspecularReflectance *= brdfLtcScalar;\n\treturn specularReflectance;\n}\nvec3 Rect_Area_Light_Diffuse_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tmat3 diffuseBrdfMat = mat3(1);\n\tvec3 diffuseReflectance = integrateLtcBrdfOverRect( geometry, diffuseBrdfMat, rectPoints );\n\treturn diffuseReflectance;\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 < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"#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\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = 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 envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n\t}\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff;\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.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\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#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\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\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 \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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 \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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 \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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 \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform 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"};Y.prototype={constructor:Y,isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(){function t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}return function(e,r,n){if(e=Tp.euclideanModulo(e,1),r=Tp.clamp(r,0,1),n=Tp.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,o=2*n-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(t){void 0!==t&&parseFloat(t)}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],o=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(a,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=(u=r[1]).length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(t&&t.length>0){var u=kp[t];void 0!==u&&this.setHex(u)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,n=t||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),c=Math.min(i,o,a),l=(c+s)/2;if(c===s)e=0,r=0;else{var u=s-c;switch(r=l<=.5?u/(s+c):u/(2-s-c),s){case i:e=(o-a)/u+(othis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new n).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new n).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new n;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};var Bp=0;Q.prototype={constructor:Q,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(t){!0===t&&this.update(),this._needsUpdate=t},setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r){var n=this[e];void 0!==n&&(n&&n.isColor?n.set(r):n&&n.isVector3&&r&&r.isVector3?n.copy(r):this[e]="overdraw"===e?Number(r):r)}}},toJSON:function(t){function e(t){var e=[];for(var r in t){var n=t[r];delete n.metadata,e.push(n)}return e}var r=void 0===t;r&&(t={textures:{},images:{}});var n={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Bu&&(n.blending=this.blending),this.shading!==Du&&(n.shading=this.shading),this.side!==Ru&&(n.side=this.side),this.vertexColors!==zu&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),n.skinning=this.skinning,n.morphTargets=this.morphTargets,r){var i=e(t.textures),o=e(t.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.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,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(Q.prototype,r.prototype),J.prototype=Object.create(Q.prototype),J.prototype.constructor=J,J.prototype.isShaderMaterial=!0,J.prototype.copy=function(t){return Q.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Dp.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},J.prototype.toJSON=function(t){var e=Q.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},tt.prototype=Object.create(Q.prototype),tt.prototype.constructor=tt,tt.prototype.isMeshDepthMaterial=!0,tt.prototype.copy=function(t){return Q.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},et.prototype={constructor:et,isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;si&&(i=l),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;si&&(i=l),u>o&&(o=u),h>a&&(a=h)}return this.min.set(e,r,n),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new l).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t;return function(e){return void 0===t&&(t=new l),this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=t.constant&&r>=t.constant},clampPoint:function(t,e){return(e||new l).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new l;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new l;return function(e){var r=e||new rt;return this.getCenter(r.center),r.radius=.5*this.getSize(t).length(),r}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new l,new l,new l,new l,new l,new l,new l,new l];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},rt.prototype={constructor:rt,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t;return function(e,r){void 0===t&&(t=new et);var n=this.center;void 0!==r?n.copy(r):t.setFromPoints(e).getCenter(n);for(var i=0,o=0,a=e.length;othis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){var e=t||new et;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}},nt.prototype={constructor:nt,isMatrix3:!0,set:function(t,e,r,n,i,o,a,s,c){var l=this.elements;return l[0]=t,l[1]=n,l[2]=a,l[3]=e,l[4]=i,l[5]=s,l[6]=r,l[7]=o,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=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},applyToBufferAttribute:function(){var t;return function(e){void 0===t&&(t=new l);for(var r=0,n=e.count;r1))return n.copy(i).multiplyScalar(a).add(e.start)}else if(0===this.distanceToPoint(e.start))return n.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new l).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new l,e=new nt;return function(r,n){var i=this.coplanarPoint(t).applyMatrix4(r),o=n||e.getNormalMatrix(r),a=this.normal.applyMatrix3(o).normalize();return this.constant=-i.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}},ot.prototype={constructor:ot,set:function(t,e,r,n,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(n),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],c=r[5],l=r[6],u=r[7],h=r[8],p=r[9],f=r[10],d=r[11],m=r[12],g=r[13],v=r[14],y=r[15];return e[0].setComponents(a-n,u-s,d-h,y-m).normalize(),e[1].setComponents(a+n,u+s,d+h,y+m).normalize(),e[2].setComponents(a+i,u+c,d+p,y+g).normalize(),e[3].setComponents(a-i,u-c,d-p,y-g).normalize(),e[4].setComponents(a-o,u-l,d-f,y-v).normalize(),e[5].setComponents(a+o,u+l,d+f,y+v).normalize(),this},intersectsObject:function(){var t=new rt;return function(e){var r=e.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),t.copy(r.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new rt;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++)if(e[i].distanceToPoint(r)0?r.min.x:r.max.x,e.x=o.normal.x>0?r.max.x:r.min.x,t.y=o.normal.y>0?r.min.y:r.max.y,e.y=o.normal.y>0?r.max.y:r.min.y,t.z=o.normal.z>0?r.min.z:r.max.z,e.z=o.normal.z>0?r.max.z:r.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}},st.prototype={constructor:st,set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new l).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new l;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var r=e||new l;r.subVectors(t,this.origin);var n=r.dot(this.direction);return n<0?r.copy(this.origin):r.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new l;return function(e){var r=t.subVectors(e,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(r).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new l,e=new l,r=new l;return function(n,i,o,a){t.copy(n).add(i).multiplyScalar(.5),e.copy(i).sub(n).normalize(),r.copy(this.origin).sub(t);var s,c,l,u,h=.5*n.distanceTo(i),p=-this.direction.dot(e),f=r.dot(this.direction),d=-r.dot(e),m=r.lengthSq(),g=Math.abs(1-p*p);if(g>0)if(s=p*d-f,c=p*f-d,u=h*g,s>=0)if(c>=-u)if(c<=u){var v=1/g;l=(s*=v)*(s+p*(c*=v)+2*f)+c*(p*s+c+2*d)+m}else c=h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c=-h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;else c<=-u?l=-(s=Math.max(0,-(-p*h+f)))*s+(c=s>0?-h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m:c<=u?(s=0,l=(c=Math.min(Math.max(-h,-d),h))*(c+2*d)+m):l=-(s=Math.max(0,-(p*h+f)))*s+(c=s>0?h:Math.min(Math.max(-h,-d),h))*(c+2*d)+m;else c=p>0?-h:h,l=-(s=Math.max(0,-(p*c+f)))*s+c*(c+2*d)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),l}}(),intersectSphere:function(){var t=new l;return function(e,r){t.subVectors(e.center,this.origin);var n=t.dot(this.direction),i=t.dot(t)-n*n,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=n-a,c=n+a;return s<0&&c<0?null:s<0?this.at(c,r):this.at(s,r)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,o,a,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(r=(t.min.x-h.x)*c,n=(t.max.x-h.x)*c):(r=(t.max.x-h.x)*c,n=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,o=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,o=(t.min.y-h.y)*l),r>o||i>n?null:((i>r||r!==r)&&(r=i),(o=0?(a=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(a=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),r>s||a>n?null:((a>r||r!==r)&&(r=a),(s=0?r:n,e)))},intersectsBox:function(){var t=new l;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new l,e=new l,r=new l,n=new l;return function(i,o,a,s,c){e.subVectors(o,i),r.subVectors(a,i),n.crossVectors(e,r);var l,u=this.direction.dot(n);if(u>0){if(s)return null;l=1}else{if(!(u<0))return null;l=-1,u=-u}t.subVectors(this.origin,i);var h=l*this.direction.dot(r.crossVectors(t,r));if(h<0)return null;var p=l*this.direction.dot(e.cross(t));if(p<0)return null;if(h+p>u)return null;var f=-l*t.dot(n);return f<0?null:this.at(f/u,c)}}(),applyMatrix4:function(t){return this.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)}},ct.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ct.DefaultOrder="XYZ",ct.prototype={constructor:ct,isEuler:!0,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get order(){return this._order},set order(t){this._order=t,this.onChangeCallback()},set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,r){var n=Tp.clamp,i=t.elements,o=i[0],a=i[4],s=i[8],c=i[1],l=i[5],u=i[9],h=i[2],p=i[6],f=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===e?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,l))):"YZX"===e?(this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,o)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===e&&(this._z=Math.asin(-n(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,l),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-u,f),this._y=0)),this._order=e,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var t;return function(e,r,n){return void 0===t&&(t=new u),t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,r,n)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new c;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new l(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},lt.prototype={constructor:lt,set:function(t){this.mask=1<1){for(var e=0;e1)for(var e=0;e0){i.children=[];for(var o=0;o0&&(n.geometries=a),s.length>0&&(n.materials=s),c.length>0&&(n.textures=c),l.length>0&&(n.images=l)}return n.object=i,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.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;r0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),pt.barycoordFromPoint=function(){var t=new l,e=new l,r=new l;return function(n,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),r.subVectors(n,i);var c=t.dot(t),u=t.dot(e),h=t.dot(r),p=e.dot(e),f=e.dot(r),d=c*p-u*u,m=s||new l;if(0===d)return m.set(-2,-1,-1);var g=1/d,v=(p*h-u*f)*g,y=(c*f-u*h)*g;return m.set(1-v-y,y,v)}}(),pt.containsPoint=function(){var t=new l;return function(e,r,n,i){var o=pt.barycoordFromPoint(e,r,n,i,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),pt.prototype={constructor:pt,set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new l,e=new l;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new l).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return pt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new it).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return pt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return pt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t,e,r,n;return function(i,o){void 0===t&&(t=new it,e=[new ht,new ht,new ht],r=new l,n=new l);var a=o||new l,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,r),!0===this.containsPoint(r))a.copy(r);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var c=0;c0,s=o[1]&&o[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(v=0;v0){u=[];for(v=0;v0)for(m=0;m0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,i;for(r=0,n=this.faces.length;r0&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new rt),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(!1!==(t&&t.isGeometry)){var n,i=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,l=this.faceVertexUvs[0],u=t.faceVertexUvs[0],h=this.colors,p=t.colors;void 0===r&&(r=0),void 0!==e&&(n=(new nt).getNormalMatrix(e));for(var f=0,d=a.length;f=0;r--){var d=p[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a0,x=v.vertexNormals.length>0,b=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,S=0;if(S=t(S,0,0),S=t(S,1,!0),S=t(S,2,!1),S=t(S,3,y),S=t(S,4,_),S=t(S,5,x),S=t(S,6,b),S=t(S,7,w),u.push(S),u.push(v.a,v.b,v.c),u.push(v.materialIndex),y){var M=this.faceVertexUvs[0][c];u.push(n(M[0]),n(M[1]),n(M[2]))}if(_&&u.push(e(v.normal)),x){var A=v.vertexNormals;u.push(e(A[0]),e(A[1]),e(A[2]))}if(b&&u.push(r(v.color)),w){var E=v.vertexColors;u.push(r(E[0]),r(E[1]),r(E[2]))}}return i.data={},i.data.vertices=s,i.data.normals=h,f.length>0&&(i.data.colors=f),m.length>0&&(i.data.uvs=[m]),i.data.faces=u,i},clone:function(){return(new Tt).copy(this)},copy:function(t){var e,r,n,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,r=s.length;e65535?wt:xt)(t,1):this.index=t},addAttribute:function(t,e){if(!1!==(e&&e.isBufferAttribute)||!1!==(e&&e.isInterleavedBufferAttribute)){if("index"!==t)return this.attributes[t]=e,this;this.setIndex(e)}else this.addAttribute(t,new mt(arguments[1],arguments[2]))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;return void 0!==r&&((new nt).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t;return function(e){return void 0===t&&(t=new u),t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t;return function(e){return void 0===t&&(t=new u),t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t;return function(e){return void 0===t&&(t=new u),t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t;return function(e,r,n){return void 0===t&&(t=new u),t.makeTranslation(e,r,n),this.applyMatrix(t),this}}(),scale:function(){var t;return function(e,r,n){return void 0===t&&(t=new u),t.makeScale(e,r,n),this.applyMatrix(t),this}}(),lookAt:function(){var t;return function(e){void 0===t&&(t=new ut),t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new St(3*e.vertices.length,3),n=new St(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new St(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var r=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(r=void 0,e.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(e);r.verticesNeedUpdate=e.verticesNeedUpdate,r.normalsNeedUpdate=e.normalsNeedUpdate,r.colorsNeedUpdate=e.colorsNeedUpdate,r.uvsNeedUpdate=e.uvsNeedUpdate,r.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=r}var n;return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new At).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new mt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new mt(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new mt(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new mt(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new mt(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Et(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new mt(a,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var s in t.morphTargets){for(var c=[],l=t.morphTargets[s],u=0,h=l.length;u0){var d=new St(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new St(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z)},computeBoundingSphere:function(){var t=new et,e=new l;return function(){null===this.boundingSphere&&(this.boundingSphere=new rt);var r=this.attributes.position;if(r){var n=this.boundingSphere.center;t.setFromBufferAttribute(r),t.getCenter(n);for(var i=0,o=0,a=r.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Pt).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(r=0,n=l.length;r0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,r=t.length;ee.far?null:{distance:c,point:x.clone(),object:t}}function r(r,n,i,o,a,l,u,p){s.fromBufferAttribute(o,l),c.fromBufferAttribute(o,u),h.fromBufferAttribute(o,p);var f=e(r,n,i,s,c,h,_);return f&&(a&&(m.fromBufferAttribute(a,l),g.fromBufferAttribute(a,u),v.fromBufferAttribute(a,p),f.uv=t(_,s,c,h,m,g,v)),f.face=new ft(l,u,p,pt.normal(s,c,h)),f.faceIndex=l),f}var i=new u,o=new st,a=new rt,s=new l,c=new l,h=new l,p=new l,f=new l,d=new l,m=new n,g=new n,v=new n,y=new l,_=new l,x=new l;return function(n,l){var u=this.geometry,y=this.material,x=this.matrixWorld;if(void 0!==y&&(null===u.boundingSphere&&u.computeBoundingSphere(),a.copy(u.boundingSphere),a.applyMatrix4(x),!1!==n.ray.intersectsSphere(a)&&(i.getInverse(x),o.copy(n.ray).applyMatrix4(i),null===u.boundingBox||!1!==o.intersectsBox(u.boundingBox)))){var b;if(u.isBufferGeometry){var w,S,M,A,E,C=u.index,T=u.attributes.position,P=u.attributes.uv;if(null!==C)for(A=0,E=C.count;A0&&(I=F);for(var U=0,B=k.length;Uthis.scale.x*this.scale.y/4||r.push({distance:Math.sqrt(n),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),ge.prototype=Object.assign(Object.create(ut.prototype),{constructor:ge,copy:function(t){ut.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){t.setFromMatrixPosition(r.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);n[0].object.visible=!0;for(var o=1,a=n.length;o=n[o].distance;o++)n[o-1].object.visible=!1,n[o].object.visible=!0;for(;oa||(f.applyMatrix4(this.matrixWorld),(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else for(var y=0,_=g.length/3-1;y<_;y+=d)u.fromArray(g,3*y),h.fromArray(g,3*y+3),(M=e.distanceSqToSegment(u,h,f,p))>a||(f.applyMatrix4(this.matrixWorld),(A=n.ray.origin.distanceTo(f))n.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this}))}else if(s.isGeometry)for(var w=s.vertices,S=w.length,y=0;ya)){f.applyMatrix4(this.matrixWorld);var A=n.ray.origin.distanceTo(f);An.far||i.push({distance:A,point:p.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),we.prototype=Object.assign(Object.create(be.prototype),{constructor:we,isLineSegments:!0}),Se.prototype=Object.create(Q.prototype),Se.prototype.constructor=Se,Se.prototype.isPointsMaterial=!0,Se.prototype.copy=function(t){return Q.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Me.prototype=Object.assign(Object.create(ut.prototype),{constructor:Me,isPoints:!0,raycast:function(){var t=new u,e=new st,r=new rt;return function(n,i){function o(t,r){var o=e.distanceSqToPoint(t);if(on.far)return;i.push({distance:l,distanceToRay:Math.sqrt(o),point:s.clone(),index:r,face:null,object:a})}}var a=this,s=this.geometry,c=this.matrixWorld,u=n.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(c),!1!==n.ray.intersectsSphere(r)){t.getInverse(c),e.copy(n.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),p=h*h,f=new l;if(s.isBufferGeometry){var d=s.index,m=s.attributes.position.array;if(null!==d)for(var g=d.array,v=0,y=g.length;v=-Number.EPSILON&&T>=-Number.EPSILON&&C>=-Number.EPSILON))return!1;return!0}return function(e,r){var n=e.length;if(n<3)return null;var i,o,a,s=[],c=[],l=[];if(Wp.area(e)>0)for(o=0;o2;){if(h--<=0)return r?l:s;if(i=o,u<=i&&(i=0),o=i+1,u<=o&&(o=0),a=o+1,u<=a&&(a=0),t(e,i,o,a,u,c)){var p,f,d,m,g;for(p=c[i],f=c[o],d=c[a],s.push([e[p],e[f],e[d]]),l.push([c[i],c[o],c[a]]),m=o,g=o+1;g2&&t[e-1].equals(t[0])&&t.pop()}function n(t,e,r){return t.x!==e.x?t.xNumber.EPSILON){var d;if(p>0){if(f<0||f>p)return[];if((d=l*u-c*h)<0||d>p)return[]}else{if(f>0||f0||dA?[]:x===A?o?[]:[y]:b<=A?[y,_]:[y,S]}function o(t,e,r,n){var i=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,c=n.x-t.x,l=n.y-t.y,u=i*s-o*a,h=i*l-o*c;if(Math.abs(u)>Number.EPSILON){var p=c*s-l*a;return u>0?h>=0&&p>=0:h>=0||p>=0}return h>0}r(t),e.forEach(r);for(var a,s,c,l,u,h,p={},f=t.concat(),d=0,m=e.length;d0&&!(--b<0);)for(a=x;an&&(a=0);var s=o(m[t],m[i],m[a],r[e]);if(!s)return!1;var c=r.length-1,l=e-1;l<0&&(l=c);var u=e+1;return u>c&&(u=0),!!(s=o(r[e],r[l],r[u],m[t]))}(a,w)&&!function(t,e){var r,n;for(r=0;r0)return!0;return!1}(s,c)&&!function(t,r){var n,o,a,s;for(n=0;n0)return!0;return!1}(s,c)){n=w,g.splice(y,1),h=m.slice(0,a+1),p=m.slice(a),f=r.slice(n),d=r.slice(0,n+1),m=h.concat(f).concat(d).concat(p),x=a;break}if(n>=0)break;v[u]=!0}if(n>=0)break}return m}(t,e),v=Wp.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var f=Math.sqrt(h),d=Math.sqrt(l*l+u*u),m=e.x-c/f,g=e.y+s/f,v=((r.x-u/d-m)*u-(r.y+l/d-g)*l)/(s*u-c*l),y=(i=m+s*v-t.x)*i+(o=g+c*v-t.y)*o;if(y<=2)return new n(i,o);a=Math.sqrt(y/2)}else{var _=!1;s>Number.EPSILON?l>Number.EPSILON&&(_=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(_=!0):Math.sign(c)===Math.sign(u)&&(_=!0),_?(i=-c,o=s,a=Math.sqrt(h)):(i=s,o=c,a=Math.sqrt(h/2))}return new n(i/a,o/a)}function o(t,e){var r,n;for(H=t.length;--H>=0;){r=H,(n=H-1)<0&&(n=t.length-1);var i=0,o=b+2*y;for(i=0;i=0;z--){for(F=z/y,U=g*Math.cos(F*Math.PI/2),k=v*Math.sin(F*Math.PI/2),H=0,X=D.length;H0||0===t.search(/^data\:image\/jpeg/);o.format=n?Qh:Jh,o.image=r,o.needsUpdate=!0,void 0!==e&&e(o)},r,n),o},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Pr.prototype=Object.assign(Object.create(ut.prototype),{constructor:Pr,isLight:!0,copy:function(t){return ut.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=ut.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Lr.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Lr,isHemisphereLight:!0,copy:function(t){return Pr.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Rr.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}}),Nr.prototype=Object.assign(Object.create(Rr.prototype),{constructor:Nr,isSpotLightShadow:!0,update:function(t){var e=2*Tp.RAD2DEG*t.angle,r=this.mapSize.width/this.mapSize.height,n=t.distance||500,i=this.camera;e===i.fov&&r===i.aspect&&n===i.far||(i.fov=e,i.aspect=r,i.far=n,i.updateProjectionMatrix())}}),Ir.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Ir,isSpotLight:!0,copy:function(t){return Pr.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}}),Or.prototype=Object.assign(Object.create(Pr.prototype),{constructor:Or,isPointLight:!0,copy:function(t){return Pr.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Dr.prototype=Object.assign(Object.create(Rr.prototype),{constructor:Dr}),zr.prototype=Object.assign(Object.create(Pr.prototype),{constructor:zr,isDirectionalLight:!0,copy:function(t){return Pr.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),kr.prototype=Object.assign(Object.create(Pr.prototype),{constructor:kr,isAmbientLight:!0});var $p={arraySlice:function(t,e,r){return $p.isTypedArray(t)?new t.constructor(t.subarray(e,r)):t.slice(e,r)},convertArray:function(t,e,r){return!t||!r&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,r=new Array(e),n=0;n!==e;++n)r[n]=n;return r.sort(function(e,r){return t[e]-t[r]}),r},sortedArray:function(t,e,r){for(var n=t.length,i=new t.constructor(n),o=0,a=0;a!==n;++o)for(var s=r[o]*e,c=0;c!==e;++c)i[a++]=t[s+c];return i},flattenJSON:function(t,e,r,n){for(var i=1,o=t[0];void 0!==o&&void 0===o[n];)o=t[i++];if(void 0!==o){var a=o[n];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[n])&&(e.push(o.time),r.push.apply(r,a)),o=t[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[n])&&(e.push(o.time),a.toArray(r,r.length)),o=t[i++]}while(void 0!==o);else do{void 0!==(a=o[n])&&(e.push(o.time),r.push(a)),o=t[i++]}while(void 0!==o)}}};Fr.prototype={constructor:Fr,evaluate:function(t){var e=this.parameterPositions,r=this._cachedIndex,n=e[r],i=e[r-1];t:{e:{var o;r:{n:if(!(t=i)break t;var a=e[1];t=i)break e}o=r,r=0}}for(;r>>1;te;)--o;if(++o,0!==i||o!==n){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=$p.arraySlice(r,i,o),this.values=$p.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(t=!1);for(var o=null,a=0;a!==i;a++){var s=r[a];if("number"==typeof s&&isNaN(s)){t=!1;break}if(null!==o&&o>s){t=!1;break}o=s}if(void 0!==n&&$p.isTypedArray(n))for(var a=0,c=n.length;a!==c;++a){var l=n[a];if(isNaN(l)){t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(var d=o*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[d+p];++i}return i!==t.length&&(this.times=$p.arraySlice(t,0,i),this.values=$p.arraySlice(e,0,i*r)),this}},Gr.prototype=Object.assign(Object.create(Zp),{constructor:Gr,ValueTypeName:"vector"}),Wr.prototype=Object.assign(Object.create(Fr.prototype),{constructor:Wr,interpolate_:function(t,e,r,n){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,l=(r-e)/(n-e),u=s+a;s!==u;s+=4)c.slerpFlat(i,0,o,s-a,o,s,l);return i}}),Hr.prototype=Object.assign(Object.create(Zp),{constructor:Hr,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new Wr(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Xr.prototype=Object.assign(Object.create(Zp),{constructor:Xr,ValueTypeName:"number"}),Yr.prototype=Object.assign(Object.create(Zp),{constructor:Yr,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),qr.prototype=Object.assign(Object.create(Zp),{constructor:qr,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),$r.prototype=Object.assign(Object.create(Zp),{constructor:$r,ValueTypeName:"color"}),Zr.prototype=Zp,Zp.constructor=Zr,Object.assign(Zr,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Zr._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var r=[],n=[];$p.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,r=t.constructor;if(void 0!==r.toJSON)e=r.toJSON(t);else{e={name:t.name,times:$p.convertArray(t.times,Array),values:$p.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 Xr;case"vector":case"vector2":case"vector3":case"vector4":return Gr;case"color":return $r;case"quaternion":return Hr;case"bool":case"boolean":return qr;case"string":return Yr}throw new Error("Unsupported typeName: "+t)}}),Kr.prototype={constructor:Kr,resetDuration:function(){for(var t=0,e=0,r=this.tracks.length;e!==r;++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 l=n[h=c[1]];l||(n[h]=l=[]),l.push(s)}}var u=[];for(var h in n)u.push(Kr.CreateFromMorphTargetSequence(h,n[h],e,r));return u},parseAnimation:function(t,e){if(!t)return null;for(var r=function(t,e,r,n,i){if(0!==r.length){var o=[],a=[];$p.flattenJSON(r,o,a,n),0!==o.length&&i.push(new t(e,o,a))}},n=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[n+1]:0,c=e>2?t.skinWeights[n+2]:0,l=e>3?t.skinWeights[n+3]:0;r.skinWeights.push(new o(a,s,c,l))}if(t.skinIndices)for(var n=0,i=t.skinIndices.length;n1?t.skinIndices[n+1]:0,p=e>2?t.skinIndices[n+2]:0,f=e>3?t.skinIndices[n+3]:0;r.skinIndices.push(new o(u,h,p,f))}r.bones=t.bones,r.bones&&r.bones.length>0&&(r.skinWeights.length!==r.skinIndices.length||(r.skinIndices.length,r.vertices.length))}(),function(e){if(void 0!==t.morphTargets)for(var n=0,i=t.morphTargets.length;n0)for(var h=r.faces,p=t.morphColors[0].colors,n=0,i=h.length;n0&&(r.animations=e)}(),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:r};var a=tn.prototype.initMaterials(t.materials,e,this.crossOrigin);return{geometry:r,materials:a}}}),Object.assign(rn.prototype,{load:function(t,e,r,n){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new Sr(i.manager).load(t,function(t){var r=null;try{r=JSON.parse(t)}catch(t){return void(void 0!==n&&n(t))}var o=r.metadata;void 0!==o&&void 0!==o.type&&"geometry"!==o.type.toLowerCase()&&i.parse(r,e)},r,n)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var r=this.parseGeometries(t.geometries),n=this.parseImages(t.images,function(){void 0!==e&&e(a)}),i=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,i),a=this.parseObject(t.object,r,o);return t.animations&&(a.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(a),a},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new en,n=new Jr,i=0,o=t.length;i0){var i=new Er(new wr(e));i.setCrossOrigin(this.crossOrigin);for(var o=0,a=t.length;o0?new _e(s,c):new Lt(s,c);break;case"LOD":a=new ge;break;case"Line":a=new be(i(e.geometry),o(e.material),e.mode);break;case"LineSegments":a=new we(i(e.geometry),o(e.material));break;case"PointCloud":case"Points":a=new Me(i(e.geometry),o(e.material));break;case"Sprite":a=new me(o(e.material));break;case"Group":a=new Ae;break;case"SkinnedMesh":default:a=new ut}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.children)for(var l in e.children)a.add(this.parseObject(e.children[l],r,n));if("LOD"===e.type)for(var u=e.levels,h=0;h0)){c=i;break}c=i-1}if(i=c,n[i]===r)return u=i/(o-1);var l=n[i],u=(i+(r-l)/(n[i+1]-l))/(o-1);return u},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,i,o=new l,a=[],s=[],c=[],h=new l,p=new u;for(r=0;r<=t;r++)n=r/t,a[r]=this.getTangentAt(n),a[r].normalize();s[0]=new l,c[0]=new l;var f=Number.MAX_VALUE,d=Math.abs(a[0].x),m=Math.abs(a[0].y),g=Math.abs(a[0].z);for(d<=f&&(f=d,o.set(1,0,0)),m<=f&&(f=m,o.set(0,1,0)),g<=f&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),r=1;r<=t;r++)s[r]=s[r-1].clone(),c[r]=c[r-1].clone(),h.crossVectors(a[r-1],a[r]),h.length()>Number.EPSILON&&(h.normalize(),i=Math.acos(Tp.clamp(a[r-1].dot(a[r]),-1,1)),s[r].applyMatrix4(p.makeRotationAxis(h,i))),c[r].crossVectors(a[r],s[r]);if(!0===e)for(i=Math.acos(Tp.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(h.crossVectors(s[0],s[t]))>0&&(i=-i),r=1;r<=t;r++)s[r].applyMatrix4(p.makeRotationAxis(a[r],i*r)),c[r].crossVectors(a[r],s[r]);return{tangents:a,normals:s,binormals:c}}},(mn.prototype=Object.create(dn.prototype)).constructor=mn,mn.prototype.isLineCurve=!0,mn.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},mn.prototype.getPointAt=function(t){return this.getPoint(t)},mn.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},gn.prototype=Object.assign(Object.create(dn.prototype),{constructor:gn,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 mn(e,t))},getPoint:function(t){for(var e=t*this.getLength(),r=this.getCurveLengths(),n=0;n=e){var i=r[n]-e,o=this.curves[n],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Tt,r=0,n=t.length;re;)r-=e;re.length-2?e.length-1:i+1],l=e[i>e.length-3?e.length-1:i+2];return new n(nn(o,a.x,s.x,c.x,l.x),nn(o,a.y,s.y,c.y,l.y))},(_n.prototype=Object.create(dn.prototype)).constructor=_n,_n.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2,o=this.v3;return new n(fn(t,e.x,r.x,i.x,o.x),fn(t,e.y,r.y,i.y,o.y))},(xn.prototype=Object.create(dn.prototype)).constructor=xn,xn.prototype.getPoint=function(t){var e=this.v0,r=this.v1,i=this.v2;return new n(cn(t,e.x,r.x,i.x),cn(t,e.y,r.y,i.y))};var Kp=Object.assign(Object.create(gn.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);this.currentPoint.copy(u)}});bn.prototype=Kp,Kp.constructor=bn,wn.prototype=Object.assign(Object.create(Kp),{constructor:wn,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;r1){for(var v=!1,y=[],_=0,x=p.length;_Number.EPSILON){if(l<0&&(a=e[o],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var u=l*(t.x-a.x)-c*(t.y-a.y);if(0===u)return!0;if(u<0)continue;n=!n}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return n})(S.p,p[A].p)&&(_!==A&&y.push({froms:_,tos:A,hole:w}),M?(M=!1,h[A].push(S)):v=!0);M&&h[_].push(S)}y.length>0&&(v||(f=h))}for(var E,m=0,C=p.length;m0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[r+o]},_slerp:function(t,e,r,n,i){c.slerpFlat(t,e,t,e,t,r,n)},_lerp:function(t,e,r,n,i){for(var o=1-n,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[r+a]*n}}},Dn.prototype={constructor:Dn,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,r=e.objectName,n=e.propertyName,i=e.propertyIndex;if(t||(t=Dn.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(r){var o=e.objectIndex;switch(r){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(l=0;l=r){var h=r++,p=e[h];n[p.uuid]=u,e[u]=p,n[l]=h,e[h]=c;for(var f=0,d=o;f!==d;++f){var m=i[f],g=m[h],v=m[u];m[u]=g,m[h]=v}}}this.nCachedObjects_=r},uncache:function(t){for(var e=this._objects,r=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,c=arguments.length;s!==c;++s){var l=arguments[s].uuid,u=i[l];if(void 0!==u)if(delete i[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(a),l[u].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;null!==r&&(e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var r=this._clip.duration,n=this.loop,i=this._loopCount;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=2202===n;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=r||e<0){var a=Math.floor(e/r);e-=r*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,r-e}return this.time=e,e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:mp:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:mp:2402)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=r,this}},Fn.prototype={constructor:Fn,clipAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?Kr.findByName(r,t):t,o=null!==i?i.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===i&&(i=s._clip)}if(null===i)return null;var l=new kn(this,i,e);return this._bindAction(l,s),this._addInactiveAction(l,o,n),l},existingAction:function(t,e){var r=e||this._root,n=r.uuid,i="string"==typeof t?Kr.findByName(r,t):t,o=i?i.uuid:t,a=this._actionsByClip[o];return void 0!==a?a.actionByRoot[n]||null:null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,r=this._bindings,n=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(i=0;i!==e;++i)t[i].reset();for(var i=0;i!==n;++i)r[i].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,r=this._nActiveActions,n=this.time+=t,i=Math.sign(t),o=this._accuIndex^=1,a=0;a!==r;++a){var s=e[a];s.enabled&&s._update(n,t,i,o)}for(var c=this._bindings,l=this._nActiveBindings,a=0;a!==l;++a)c[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,r=t.uuid,n=this._actionsByClip,i=n[r];if(void 0!==i){for(var o=i.knownActions,a=0,s=o.length;a!==s;++a){var c=o[a];this._deactivateAction(c);var l=c._cacheIndex,u=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,u._cacheIndex=l,e[l]=u,e.pop(),this._removeInactiveBindingsForAction(c)}delete n[r]}},uncacheRoot:function(t){var e=t.uuid,r=this._actionsByClip;for(var n in r){var i=r[n].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}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 r=this.existingAction(t,e);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}},Object.assign(Fn.prototype,{_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,o=t._propertyBindings,a=t._interpolants,s=r.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=n[u],p=h.name,f=l[p];if(void 0!==f)o[u]=f;else{if(void 0!==(f=o[u])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,p));continue}var d=e&&e._propertyBindings[u].binding.parsedPath;++(f=new On(Dn.create(r,p,d),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(f,s,p),o[u]=f}a[u].resultBuffer=f.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e1&&(n[c=s[1]]||(n[c]={start:1/0,end:-1/0}),o<(l=n[c]).start&&(l.start=o),o>l.end&&(l.end=o),e||(e=c))}for(var c in n){var l=n[c];this.createAnimation(c,l.start,l.end,t)}this.firstAnimation=e},Kn.prototype.setAnimationDirectionForward=function(t){var e=this.animationsMap[t];e&&(e.direction=1,e.directionBackwards=!1)},Kn.prototype.setAnimationDirectionBackward=function(t){var e=this.animationsMap[t];e&&(e.direction=-1,e.directionBackwards=!0)},Kn.prototype.setAnimationFPS=function(t,e){var r=this.animationsMap[t];r&&(r.fps=e,r.duration=(r.end-r.start)/r.fps)},Kn.prototype.setAnimationDuration=function(t,e){var r=this.animationsMap[t];r&&(r.duration=e,r.fps=(r.end-r.start)/r.duration)},Kn.prototype.setAnimationWeight=function(t,e){var r=this.animationsMap[t];r&&(r.weight=e)},Kn.prototype.setAnimationTime=function(t,e){var r=this.animationsMap[t];r&&(r.time=e)},Kn.prototype.getAnimationTime=function(t){var e=0,r=this.animationsMap[t];return r&&(e=r.time),e},Kn.prototype.getAnimationDuration=function(t){var e=-1,r=this.animationsMap[t];return r&&(e=r.duration),e},Kn.prototype.playAnimation=function(t){var e=this.animationsMap[t];e&&(e.time=0,e.active=!0)},Kn.prototype.stopAnimation=function(t){var e=this.animationsMap[t];e&&(e.active=!1)},Kn.prototype.update=function(t){for(var e=0,r=this.animationsList.length;en.duration||n.time<0)&&(n.direction*=-1,n.time>n.duration&&(n.time=n.duration,n.directionBackwards=!0),n.time<0&&(n.time=0,n.directionBackwards=!1)):(n.time=n.time%n.duration,n.time<0&&(n.time+=n.duration));var o=n.start+Tp.clamp(Math.floor(n.time/i),0,n.length-1),a=n.weight;o!==n.currentFrame&&(this.morphTargetInfluences[n.lastFrame]=0,this.morphTargetInfluences[n.currentFrame]=1*a,this.morphTargetInfluences[o]=0,n.lastFrame=n.currentFrame,n.currentFrame=o);var s=n.time%i/i;n.directionBackwards&&(s=1-s),n.currentFrame!==n.lastFrame?(this.morphTargetInfluences[n.currentFrame]=s*a,this.morphTargetInfluences[n.lastFrame]=(1-s)*a):this.morphTargetInfluences[n.currentFrame]=a}}},(Qn.prototype=Object.create(ut.prototype)).constructor=Qn,Qn.prototype.isImmediateRenderObject=!0,(Jn.prototype=Object.create(we.prototype)).constructor=Jn,Jn.prototype.update=function(){var t=new l,e=new l,r=new nt;return function(){var n=["a","b","c"];this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,l=0,u=0,h=c.length;u.99999?this.quaternion.set(0,0,0,1):r.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(r.z,0,-r.x).normalize(),t=Math.acos(r.y),this.quaternion.setFromAxisAngle(e,t))}}(),hi.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},hi.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},pi.prototype=Object.create(we.prototype),pi.prototype.constructor=pi;var rf=new l,nf=new fi,of=new fi,af=new fi;di.prototype=Object.create(dn.prototype),di.prototype.constructor=di,di.prototype.getPoint=function(t){var e=this.points,r=e.length,n=(r-(this.closed?0:1))*t,i=Math.floor(n),o=n-i;this.closed?i+=i>0?0:(Math.floor(Math.abs(i)/e.length)+1)*e.length:0===o&&i===r-1&&(i=r-2,o=1);var a,s,c,u;if(this.closed||i>0?a=e[(i-1)%r]:(rf.subVectors(e[0],e[1]).add(e[0]),a=rf),s=e[i%r],c=e[(i+1)%r],this.closed||i+2=0;n--){var i=t[n];"."===i?t.splice( var target = document.getElementById('foo') var spinner = new Spinner(opts).spin(target) */ -!function(e,r){t.exports?t.exports=r():e.Spinner=r()}(bu,function(){function t(t,e){var r,n=document.createElement(t||"div");for(r in e)n[r]=e[r];return n}function e(t){for(var e=1,r=arguments.length;e>1)+"px"})}for(var l,u=0,h=(o.lines-1)*(1-o.direction)/2;u',r)}l.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(t,n){function o(){return i(r("group",{coordsize:u+" "+u,coordorigin:-l+" "+-l}),{width:u,height:u})}function s(t,s,c){e(p,e(i(o(),{rotation:360/n.lines*t+"deg",left:~~s}),e(i(r("roundrect",{arcsize:n.corners}),{width:l,height:n.scale*n.width,left:n.scale*n.radius,top:-n.scale*n.width>>1,filter:c}),r("fill",{color:a(n.color,t),opacity:n.opacity}),r("stroke",{opacity:0}))))}var c,l=n.scale*(n.length+n.width),u=2*n.scale*l,h=-(n.width+n.length)*n.scale*2+"px",p=i(o(),{position:"absolute",top:h,left:h});if(n.shadow)for(c=1;c<=n.lines;c++)s(c,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(c=1;c<=n.lines;c++)s(c);return e(t,p)},s.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n0)return"!"+r.join()}return""},objectsDiff:Ii,forInRecursive:function(t,e){function r(t,n){wu.forIn(t,function(t,i){var o=n+(n.length>0?".":"");t instanceof Object?r(t,o+i):void 0!==t&&e(t,o+i)})}r(t,"")},enquoteString:function(t){return wu.isString(t)?'"'+t.replace(/"/g,'\\"')+'"':t},shotOpen:function(t){"undefined"!=typeof window&&window.open().document.write('')},shotDownload:function(t,e){if(t&&"data:"===t.substr(0,5))if(e||(e=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(Oi(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Oi(t)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(t,e,r,n){for(var i=0,o=r.length;ithis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=t),t},update:function(){this._startTime=this.end()},show:function(t){void 0===t&&(t=!0),this.domElement.style.display=t?"block":"none"}},gf.deriveClass(Fi,Si),Fi.prototype.cancel=function(){this._cancellationRequested=!0,this.dispatchEvent("cancel")},Fi.prototype.isCancellationRequested=function(){return this._cancellationRequested},Fi.prototype.notify=function(t){this.dispatchEvent({type:"notification",slaveEvent:t})};var yf={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:2,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},labels:"no",antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},theme:"dark",themes:{dark:2105376,light:13421772},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5,waterBondingHack:!1},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,ao:!1,autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};ki.prototype={constructor:ki,defaults:yf,set:function(t,e){wu.set(this.now,t,e),this._changed[t]=!0},get:function(t,e){return wu.get(this.now,t,e)},reset:function(){this.now=wu.cloneDeep(yf),this.old=null,this._changed={}},checkpoint:function(){this.old=wu.cloneDeep(this.now),this._changed={}},undo:function(){this.now=wu.cloneDeep(this.old),this._changed={}},changed:function(){if(!this.old)return[];var t=this.old,e=this.now;return wu.filter(Object.keys(this._changed),function(r){return wu.get(t,r)!==wu.get(e,r)})},override:function(t){wu.merge(this.now,t)},applyDiffs:function(t){if(t.hasOwnProperty("VERSION")&&0!==t.VERSION)throw new Error("Settings version does not match!");this.reset(),wu.merge(this.now,t)},getDiffs:function(t){var e=gf.objectsDiff(this.now,yf);return t&&(e.VERSION=0),e},setPluginOpts:function(t,e){yf.plugins[t]=wu.cloneDeep(e),this.now.plugins[t]=wu.cloneDeep(e)}};var _f=new ki,xf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bf=(function(){function t(t){this.value=t}function e(e){function r(i,o){try{var a=e[i](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){r("next",t)},function(t){r("throw",t)}):n(a.done?"return":"normal",a.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}(i=i.next)?r(i.key,i.arg):o=null}var i,o;this._invoke=function(t,e){return new Promise(function(n,a){var s={key:t,arg:e,resolve:n,reject:a,next:null};o?o=o.next=s:(i=o=s,r(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),wf=function(){function t(t,e){for(var r=0;r0?gf.deriveDeep(e.reps[Af-1],!0):gf.deriveDeep(_f.defaults.presets.default[0],!0))},s:"select",select:function(t,e){Gi(e,"selector",t)},m:"mode",mode:function(t,e){Gi(e,"mode",Xi(t,_f.defaults.modes))},c:"color",color:function(t,e){Gi(e,"colorer",Xi(t,_f.defaults.colorers))},mt:"material",material:function(t,e){Gi(e,"material",Xi(t,_f.defaults.materials))},dup:function(t,e){ji(e);var r=e.reps,n=r[Af];++Af>=r.length&&(r[Af]=gf.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"},Df={fromURL:function(t){return Yi(gf.getUrlParameters(t))},fromAttr:function(t){return Yi(gf.getUrlParameters("?"+(t||"")))},adapters:Ef,toURL:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=Bi(t)+Cf+Bi(e))}var r=[],n=0;e("l",t.load),e("u",t.unit),e("p",t.preset),function(t){if(t)for(var r=0,n=t.length;r0&&(i+="?"+r.join("&")),i},toScript:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=t+" "+e)}var r=[],n=0;return e("set","autobuild false"),e("load",t.load),e("unit",t.unit),e("preset",t.preset),function(t){if(t)for(var r=0,n=t.length;r0?t.getString():this.element.name.trim()},no.prototype.forEachBond=function(t){for(var e=this._bonds,r=0,n=e.length;r=0)return this._hydrogenCount;var t=this.element,e=t.hydrogenValency;if(1===e.length&&0===e[0])return 0;switch(t.number){case 1:return this.getHydrogenCountHydrogen();case 3:case 11:case 19:case 37:case 55:case 87:case 4:case 12:case 20:case 38:case 56:case 88:case 13:case 31:case 49:case 41:case 82:case 83:return this.getHydrogenCountMetal();case 6:case 14:case 32:case 51:return this.getHydrogenCountGroup14();case 50:return this.getHydrogenCountTin();case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 53:case 85:return this.getHydrogenCountNonMetal();case 5:return this.getHydrogenCountBoron();default:return 0}},no.prototype.getAtomBondsCount=function(){for(var t=this.getBonds(),e=0,r=0;r=t){r=e[n];break}return r},no.prototype.getCharge=function(){return this._charge},no.prototype.getLocation=function(){return this._location},no.prototype.getFullName=function(){var t="";return null!==this._residue&&(null!==this._residue._chain&&(t+=this._residue._chain.getName()+"."),t+=this._residue._sequence+"."),t+=this._name.getString()};var zf={UNKNOWN:0,COVALENT:1,AROMATIC:2};ao.BondType=zf,ao.prototype.BondType=zf,ao.prototype.getLeft=function(){return this._left},ao.prototype.getRight=function(){return this._right},ao.prototype.getOrder=function(){return this._order},ao.prototype.calcLength=function(){return this._left._position.distanceTo(this._right._position)},ao.prototype._forEachNeighbour=function(t,e){for(var r=t._bonds,n=0,i=r.length;n0?++o:++a}function i(t){"C"===t.element.name&&n(t)}for(var o=0,a=0,s=t.clone(),c=[[this.forEachLevelOne,i],[this.forEachLevelOne,n],[this.forEachLevelTwo,i],[this.forEachLevelTwo,n]],l=0;lo)return e.multiplyScalar(-1);if(ar._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,c=0,l=s.length;ca&&u!==n&&(o=u,a=u._bonds.length)}var h=t(i),p=t(n).clone().sub(h),f=t(o).clone().sub(h);return f.crossVectors(p,f),f.lengthSq()<1e-4&&f.set(0,1,0),p.normalize(),f.normalize(),p.crossVectors(f,p),p.lengthSq()<1e-4&&p.set(0,1,0),p.normalize(),this._fixDir(h,p,t)},so.prototype.getName=function(){return this._name},so.StandardTypes={ALA:new so("ALA","Alanine","A"),ARG:new so("ARG","Arginine","R"),ASN:new so("ASN","Asparagine","N"),ASP:new so("ASP","Aspartic Acid","D"),CYS:new so("CYS","Cysteine","C"),GLN:new so("GLN","Glutamine","Q"),GLU:new so("GLU","Glutamic Acid","E"),GLY:new so("GLY","Glycine","G"),HIS:new so("HIS","Histidine","H"),ILE:new so("ILE","Isoleucine","I"),LEU:new so("LEU","Leucine","L"),LYS:new so("LYS","Lysine","K"),MET:new so("MET","Methionine","M"),PHE:new so("PHE","Phenylalanine","F"),PRO:new so("PRO","Proline","P"),PYL:new so("PYL","Pyrrolysine","O"),SEC:new so("SEC","Selenocysteine","U"),SER:new so("SER","Serine","S"),THR:new so("THR","Threonine","T"),TRP:new so("TRP","Tryptophan","W"),TYR:new so("TYR","Tyrosine","Y"),VAL:new so("VAL","Valine","V"),A:new so("A","Adenine","A"),C:new so("C","Cytosine","C"),G:new so("G","Guanine","G"),I:new so("I","Inosine","I"),T:new so("T","Thymine","T"),U:new so("U","Uracil","U"),DA:new so("DA","Adenine","A"),DC:new so("DC","Cytosine","C"),DG:new so("DG","Guanine","G"),DI:new so("DI","Inosine","I"),DT:new so("DT","Thymine","T"),DU:new so("DU","Uracil","U"),"+A":new so("+A","Adenine","A"),"+C":new so("+C","Cytosine","C"),"+G":new so("+G","Guanine","G"),"+I":new so("+I","Inosine","I"),"+T":new so("+T","Thymine","T"),"+U":new so("+U","Uracil","U"),WAT:new so("WAT","Water",""),H2O:new so("H2O","Water",""),HOH:new so("HOH","Water",""),UNK:new so("UNK","Unknown",""),UNL:new so("UNL","Unknown Ligand","")},so.Flags={PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536};var Ff=so.Flags;co(Ff.WATER,["WAT","H2O","HOH"]),co(Ff.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),co(Ff.BASIC,["ARG","HIS","LYS"]),co(Ff.ACIDIC,["ASP","GLU"]),co(Ff.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),co(Ff.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),co(Ff.AROMATIC,["PHE","TRP","TYR"]),co(Ff.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),co(Ff.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),co(Ff.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),co(Ff.DNA,["DA","DG","DI","DC","DT","DU"]),co(Ff.RNA,["A","G","I","C","T","U"]),function(t,e){for(var r=Object.keys(e),n=0,i=r.length;nMath.PI/2&&o.negate(),o},lo.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new l(a.x,a.y,a.z);if(0==(this._type.flags&so.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var c=e._controlPoint;n._midPoint=c.clone().lerp(s,.5),n._wingVector=this.calcWing(c,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},lo.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},lo.prototype.isConnected=function(t){if(this._chain!==t._chain)return!1;if(this===t)return!0;var e=!1;return this.forEachAtom(function(r){for(var n=r._bonds,i=0,o=n.length;i1){var a=t[1]._wingVector;t[0]._wingVector=new l(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new l(1,0,0))},uo.prototype.updateToFrame=function(t){for(var e=this._residues,r=null,n=null,i=t._residues,o=e.length,a=0;a1?i[e[1]._index]._wingVector:new l(1,0,0)},uo.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new lo(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(so.Flags.NUCLEIC|so.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},uo.prototype.getResidueCount=function(){return this._residues.length},uo.prototype.forEachResidue=function(t){for(var e=this._residues,r=0,n=e.length;r1?i=n>1?this._repeat.toString()+"("+i+")":this._repeat.toString()+i:n>1&&(i="("+i+")"),o>1&&(i+="^"+o.toString()+"+"),1===o&&(i+="^+"),o<-1&&(i+="^"+Math.abs(o).toString()+"-"),-1===o&&(i+="^-")):this._repeat>1&&(i=this._repeat.toString()+i),i};var Gf={},Wf=Object.freeze({default:Gf}),Hf=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Xf=function(t){return Hf.exec(t).slice(1)},Yf={extname:Mo,basename:So,dirname:wo,sep:"/",delimiter:":",relative:bo,join:xo,isAbsolute:_o,normalize:yo,resolve:vo},qf="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)},$f=Object.freeze({resolve:vo,normalize:yo,isAbsolute:_o,join:xo,relative:bo,sep:"/",delimiter:":",dirname:wo,basename:So,extname:Mo,default:Yf}),Zf=Wf&&Gf||Wf,Kf=$f&&Yf||$f,Qf=e(function(e,r){var n=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,4],n=[1,5],i=[1,6],o=[1,7],a=[1,8],s=[1,9],c=[1,11],l=[1,12],u=[5,7,8,11],h=[1,17],p=[1,22],f=[1,20],d=[1,21],m=[5,7,8,11,19],g={trace:function(){},yy:{},symbols_:{error:2,Program:3,Expression:4,EOF:5,Selector:6,OR:7,AND:8,NOT:9,"(":10,")":11,SELECTOR:12,NAMED_SELECTOR:13,SELECTOR_RANGED:14,RangeList:15,SELECTOR_NAMED:16,NameList:17,Range:18,",":19,NUMBER:20,":":21,Name:22,IDENTIFIER:23,STRING:24,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"OR",8:"AND",9:"NOT",10:"(",11:")",12:"SELECTOR",13:"NAMED_SELECTOR",14:"SELECTOR_RANGED",16:"SELECTOR_NAMED",19:",",20:"NUMBER",21:":",23:"IDENTIFIER",24:"STRING"},productions_:[0,[3,2],[4,1],[4,3],[4,3],[4,2],[4,3],[6,1],[6,1],[6,2],[6,2],[15,1],[15,3],[18,1],[18,3],[17,1],[17,3],[22,1],[22,1],[22,1]],performAction:function(t,e,r,n,i,o,a){var s=o.length-1;switch(i){case 1:return o[s-1];case 3:this.$=n.keyword("or")(o[s-2],o[s]);break;case 4:this.$=n.keyword("and")(o[s-2],o[s]);break;case 5:this.$=n.keyword("not")(o[s]);break;case 6:this.$=o[s-1];break;case 7:this.$=n.keyword(o[s])();break;case 8:this.$=n.GetSelector(o[s].toLowerCase().slice(1,o[s].length));break;case 9:case 10:this.$=n.keyword(o[s-1])(o[s]);break;case 11:this.$=new n.RangeList(o[s]);break;case 12:case 16:this.$=o[s-2].append(o[s]);break;case 13:this.$=new n.Range(Number(o[s]));break;case 14:this.$=new n.Range(Number(o[s-2]),Number(o[s]));break;case 15:this.$=new n.ValueList(o[s])}},table:[{3:1,4:2,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{1:[3]},{5:[1,10],7:c,8:l},e(u,[2,2]),{4:13,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:14,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,7]),e(u,[2,8]),{15:15,18:16,20:h},{17:18,20:p,22:19,23:f,24:d},{1:[2,1]},{4:23,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:24,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,5]),{7:c,8:l,11:[1,25]},e(u,[2,9],{19:[1,26]}),e(m,[2,11]),e(m,[2,13],{21:[1,27]}),e(u,[2,10],{19:[1,28]}),e(m,[2,15]),e(m,[2,17]),e(m,[2,18]),e(m,[2,19]),e([5,7,11],[2,3],{8:l}),e(u,[2,4]),e(u,[2,6]),{18:29,20:h},{20:[1,30]},{20:p,22:31,23:f,24:d},e(m,[2,12]),e(m,[2,14]),e(m,[2,16])],defaultActions:{10:[2,1]},parseError:function(t,e){if(!e.recoverable){var r=function(t,e){this.message=t,this.hash=e};throw r.prototype=Error,new r(t,e)}this.trace(t)},parse:function(t){var e=this,r=[0],n=[],i=[null],o=[],a=this.table,s="",c=0,l=0,u=1,h=o.slice.call(arguments,1),p=Object.create(this.lexer),f={yy:{}};for(var d in this.yy)Object.prototype.hasOwnProperty.call(this.yy,d)&&(f.yy[d]=this.yy[d]);p.setInput(t,f.yy),f.yy.lexer=p,f.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;o.push(m);var g=p.options&&p.options.ranges;"function"==typeof f.yy.parseError?this.parseError=f.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var v,y,_,x,b,w,S,M,A,E={};;){if(_=r[r.length-1],this.defaultActions[_]?x=this.defaultActions[_]:(null!==v&&void 0!==v||(v=function(){var t;return"number"!=typeof(t=n.pop()||p.lex()||u)&&(t instanceof Array&&(t=(n=t).pop()),t=e.symbols_[t]||t),t}()),x=a[_]&&a[_][v]),void 0===x||!x.length||!x[0]){var C="";A=[];for(w in a[_])this.terminals_[w]&&w>2&&A.push("'"+this.terminals_[w]+"'");C=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(c+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(C,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],E.$=i[i.length-S],E._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(E._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(E,[s,l,c,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(E.$),o.push(E._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},v={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return e.yytext=e.yytext.substr(1,e.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return g.lexer=v,t.prototype=g,g.Parser=t,new t}();void 0!==t&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=Zf.readFileSync(Kf.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}).parser,Jf={},td=function(){function t(e,r){bf(this,t),this.min=e,this.max=void 0===r?e:r}return wf(t,[{key:"includes",value:function(t){return this.min<=t&&t<=this.max}},{key:"toString",value:function(){var t=this.min,e=this.max;return t===e?String(t):[t,e].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),t}(),ed=function(){function t(e){if(bf(this,t),e instanceof this.constructor)return e;e instanceof Array?this._values=e.slice(0):this._values=e?[e]:[]}return wf(t,[{key:"append",value:function(t){var e=this._values;return e[e.length]=t,this}},{key:"remove",value:function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var t=this._values,e=[],r=0,n=t.length;rthis.priority?"("+this.rhs+")":this.rhs;return this.keyword+" "+t}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),e}();ud.prototype.priority=1;var hd=function(t){function e(t,r){bf(this,e);var n=Mf(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||ld,n.rhs=r||ld,n}return Sf(e,od),wf(e,[{key:"toString",value:function(){var t=this.lhs.priority&&this.lhs.priority>this.priority?"("+this.lhs+")":this.lhs,e=this.rhs.priority&&this.rhs.priority>this.priority?"("+this.rhs+")":this.rhs;return t+" "+this.keyword+" "+e}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),e}();hd.prototype.priority=1e3,To("Not",1,function(t){function e(){return bf(this,e),Mf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sf(e,ud),wf(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),To("And",2,function(t){function e(){return bf(this,e),Mf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sf(e,hd),wf(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),To("Or",3,function(t){function e(){return bf(this,e),Mf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sf(e,hd),wf(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var pd=Object.create(Jf);pd.Selector=od,pd.RangeListSelector=sd,pd.ValueListSelector=cd,pd.Range=td,pd.RangeList=rd,pd.ValueList=id,pd.PrefixOperator=ud,pd.InfixOperator=hd,pd.Context=Object.create({}),pd.GetSelector=function(t){if(!pd.Context.hasOwnProperty(t))throw{message:"selector "+t+" is not registered"};return pd.Context[t]||ld},pd.ClearContext=function(){Object.keys(pd.Context).forEach(function(t){delete pd.Context[t]})},pd.keyword=function(t){return Jf[t.toLowerCase()]||Jf.none},pd.parse=function(t){var e={};try{e.selector=Qf.parse(t)}catch(t){e.selector=ld,e.error=t.message}return e},Qf.yy=pd,Qf.yy.parseError=Qf.parseError,Po.prototype.constructor=Po,Po.prototype.computeBoundaries=function(){var t,e=this._complex._atoms,r=e.length,n=this._selector,i=this._boundaries.boundingBox;if(i.makeEmpty(),1===r){i.expandByPoint(e[0]._position);var o=i.getCenter(),a=2*e[0].element.radius;i.setFromCenterAndSize(o,new l(a,a,a))}else for(t=0;t0?this._selector=pd.keyword("Chain")(this.chains):this._selector=pd.keyword("None")()},Ro.prototype.id="__",No.prototype.getResidues=function(){return this._complex._residues},No.prototype.getResidueCount=function(){return this._residueCount},No.prototype.forEachResidue=function(t){for(var e=this._complex._residues,r=this._residueIndices,n=0,i=r.length;ne?t:e,i=r+(n<<14),o=(r+89237*n&dd-1)*fd,a=0;a=fd)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");o=this.numPairs*md,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};ko.prototype._addExistingPairs=function(){for(var t=this._complex.getAtoms(),e=t.length,r=0,n=this._pairCollection;r=a))for(var b=-1;b<=1;++b){var w=v+b;if(!(w<0||w>=o))for(var S=-1;S<=1;++S){var M=g+S;if(!(M<0||M>=i))for(var A=t[x*c+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},ko.prototype._addPairs=function(){for(var t=this._complex._atoms,e=0,r=0;e125e3);this.xB=t,this.yB=e,this.zB=r,this.invPairDist=i;for(var f=[],d=0;d.1)&&t.dot(e)>=0}}();Wo.prototype.update=function(){for(var t=this.atoms,e=new l,r=t.length,n=0;ni[c]?++c:++s}return!1},$o.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Vo(t,e),a=e._position.clone().sub(o._position),s=this._currStart,c=this,l=this._bondMarks,u=this._checkBond;l[t._index]=!0,u=void 0===u?Ho:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!l[o._index]&&!c._haveSameCycle(i,t,o)){var h=Vo(o,e),p=h._position.clone().sub(e._position),f=h===s?-2:1-jo(a,p),d=p.cross(a);if(_d(d,r)){for(var m=0;ms?1:0},Zo.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},Zo.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},Zo.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=ro.ByName.H.name,c=0;r.forEach(function(t){var e=t.getHydrogenCount();n=t.element,i[n.name]?i[n.name]+=1:i[n.name]=1,e>0&&(i[s]?i[s]+=e:i[s]=e),c+=t.getCharge()});var l=Object.keys(i);return i.C?l.sort(this._atomNameCompareCWithH.bind(this)):l.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),l.forEach(function(t){var e=t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase();i[t]>1?o+=e+i[t].toString():o+=e}),null===e?(0!==c&&(l.length>1&&(o="("+o+")"),c>1&&(o+="^{"+c.toString()+"+}"),1===c&&(o+="^+"),c<-1&&(o+="^{"+Math.abs(c).toString()+"-}"),-1===c&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(l.length,c),o},Zo.prototype._buildPartFormula=function(t){return t.owner instanceof Zo||t.owner instanceof No?this._buildFormulaSimple(t,null):t.owner instanceof mo?t.owner.buildChemicalFormula(this,t):""},Zo.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},Zo.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[a]?r[a]+=n:r[a]=n)}});var n=Object.keys(r);return n.sort(o._atomNameCompareCWithoutH.bind(o)),{seq:n,data:r}}for(var i,o=this,a=ro.ByName.H.name,s=[r,!1],c=0;cro.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{";return""},Zo.prototype.buildChemicalFormula=function(){var t=[],e=null,r=null,n={},i=null,o=this,a=this._checkFormulaBuildable();if(""!==a)return a;this.forEachAtom(function(t){n[t.getSerial()]&&ff.warn("Broken complex. Formula can be invalid..."),n[t.getSerial()]={atom:t,taken:null}}),this.forEachSGroup(function(o){0===o._charge&&1===o._repeat||(r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)}),e.atoms.length>0&&t.push(e),e=null)}),this.forEachComponent(function(o){r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o.forEachResidue(function(t){t._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)})}),e.atoms.length>0&&t.push(e),e=null}),Object.keys(n).forEach(function(t){null===t.taken&&(null===e&&(e={owner:o,atoms:[],repeatCount:1}),e.atoms.push(t.atom),t.taken=o)}),null!==e&&e.atoms.length>0&&t.push(e),t.sort(function(t,e){return o._partCompareFunc(t,e)});for(var s=t.length-1,c=t.length-2;s>=0&&c>=0;){var l=t[s],u=t[c];l.owner instanceof Zo||l.owner instanceof No?u.owner instanceof Zo||u.owner instanceof No?(0===this._partCompareFuncInt(u,l,!1)&&(u.repeatCount+=l.repeatCount,t.splice(s,1)),c--,s--):c--:--s===c&&c--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},Zo.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},Zo.prototype.splitUnifiedSerial=function(t){var e=Math.floor(t/16777216),r=t-16777216*e,n=Math.floor(r/65536);return{chain:e,serial:r-65536*n,iCode:n}},Zo.prototype._fillCmpEdit=function(){function t(){var t=new No(e);return t._index=r.length,r[t._index]=t,t}var e=this,r=this._components;this.forEachChain(function(e){var r=e._residues,n=r.length;if(!(n<1))for(var i=t(),o=r[0]._index,a=0;a=0&&t=0;e--){var i=n[e];null===i._left||null===i._right?n.splice(e,1):(i._left._bonds.push(i),i._right._bonds.push(i))}var o=this._residues;for(e=0,r=o.length;e1?t.x/(this._dimX-1):0,e.y=this._dimY>1?t.y/(this._dimY-1):0,e.z=this._dimZ>1?t.z/(this._dimZ-1):0,e},Ko.prototype.computeGradient=function(){function t(t,e,r){return Math.min(r,Math.max(e,t))}function e(t,e,r){return c[r*o*a+e*o+t]}if(1!==this._dimVec)return null;for(var r=new Ko(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),n=this.getCellSize(),i=new l(-.5/n.x,-.5/n.y,-.5/n.z),o=this._dimX,a=this._dimY,s=this._dimZ,c=this._data,u=0;u=0;r=this._atoms[r+1])e(this._atoms[r])},ea.prototype._forEachVoxelWithinRadius=function(t,e,r){var i,o,a,s,c,l,u,h,p=new n,f=new n,d=new n;d.set(t.z-e,t.z+e),d.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=d.x;m<=d.y;++m){c=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],h=t.z-e<=c[0]&&c[1]<=t.z+e,i=Jo(t,e,c[0],c[1]),f.set(t.y-i[1],t.y+i[1]),f.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var g=f.x;g<=f.y;++g){s=[this._box.min.y+g*this._cellSize.y,this._box.min.y+(g+1)*this._cellSize.y],u=t.y-i[0]<=s[0]&&s[1]<=t.y+i[0],o=ta(t,i[1],s[0],s[1]),p.set(t.x-o[1],t.x+o[1]),p.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var v=p.x;v<=p.y;++v)a=[this._box.min.x+v*this._cellSize.x,this._box.min.x+(v+1)*this._cellSize.x],l=t.x-o[0]<=a[0]&&a[1]<=t.x+o[0],r(v+this._count.x*(g+this._count.y*m),l&&u&&h)}}},ea.prototype.forEachAtomWithinRadius=function(t,e,r){var n=this,i=e*e;n._forEachVoxelWithinRadius(t,e,function(e,o){o?n._forEachAtomInVoxel(e,r):n._forEachAtomInVoxel(e,function(e){t.distanceToSquared(e._position)=0;s=a[s+1])if(t._position.distanceToSquared(a[s]._position)=1?this.fov=t:this.fov=Tp.radToDeg(2*Math.atan(Math.tan(.5*Tp.degToRad(t))/this.aspect))},zt.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*Tp.degToRad(e))},mt.prototype.copyAtList=function(t,e){for(var r=this.itemSize,n=0,i=e.length;n1e-5;)e=n,n=t/((i=1+r*n)*i);return 1/i}(a*a+s*s);i.setXY(o,c*a,c*s)}return n},RCGroup:ia,fillArray:function(t,e,r,n){r=void 0!==r?r:0,n=void 0!==n?n:t.length;for(var i=r;i65535,s=i*e,c=this._index=gf.allocateTyped(a?Uint32Array:Uint16Array,s);this._positions=gf.allocateTyped(Float32Array,3*o),this._normals=gf.allocateTyped(Float32Array,3*o),this._colors=gf.allocateTyped(Float32Array,3*o);var l=this._alpha=gf.allocateTyped(Float32Array,o);wu.fill(l,1);for(var u=0;u65535;this._index=gf.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=gf.allocateTyped(Float32Array,4*e),this._colors=gf.allocateTyped(Float32Array,3*e),this._directions=gf.allocateTyped(Float32Array,3*e);var n=this._alpha=gf.allocateTyped(Float32Array,e);wu.fill(n,1);for(var i=this._index,o=0,a=0,s=0;s117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=gf.allocateTyped(Float32Array,32*e),this.hasIntersection=gf.allocateTyped(Int32Array,e),this.bitsInside=gf.allocateTyped(Int32Array,e),0},Ba.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},Ba.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var am=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0];ja.prototype.constructor=ja,Ga.prototype.constructor=Ga,Wa.prototype.constructor=Wa,Wa.prototype._prepareAxesAndDirs=function(){var t=this._volumetricData.getCellSize(),e=this._xAxis,r=this._yAxis,n=this._zAxis,i=this._xDir,o=this._yDir,a=this._zDir;e.set(t.x,0,0),r.set(0,t.y,0),n.set(0,0,t.z),i.set(1,0,0),o.set(0,1,0),a.set(0,0,1);var s=new l;return s.crossVectors(i,o),s.dot(a)<0&&(i.negate(),o.negate(),a.negate()),!(i.x<0||i.y<0||i.z<0||o.x<0||o.y<0||o.z<0||a.x<0||a.y<0||a.z<0)&&!(0!==e.y||0!==e.z||0!==r.x||0!==r.z||0!==n.x||0!==n.y)},Wa.prototype._vertexInterp=function(t,e,r,n,i,o){var a=e.p[r],s=e.p[n],c=e.g[r],l=e.g[n],u=e.val[r],h=t-u,p=e.val[n]-u,f=0;Math.abs(p)>0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(c,l,f)},Wa.prototype._polygonize=function(){for(var t=Ba.prototype.striIndicesMarchCube,e=[0,1,2,3,4,5,6,7,0,1,2,3],r=[1,2,3,0,5,6,7,4,4,5,6,7],n=new Array(12),i=new Array(12),o=0;o<12;++o)n[o]=new l,i[o]=new l;return function(a,s,c){var l=a.cubeIndex;for(o=0;o<12;++o)am[l]&1<s?s:l+e,h=-1,p=l;pV&&(j=G,V=C[G]);if(j<0||!n.includesAtom(E[j])){P[a]=-1;continue}}P[a]=L++;var W=D=0&&nt>=0&&it>=0&&(this._indices[3*et]=rt,this._indices[3*et+1]=nt,this._indices[3*et+2]=it,++et)}this._position=new Float32Array(this._position.buffer.slice(0,3*L*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*L*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*L*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*et*4))}},Wa.prototype.toMesh=function(){var t=new Pt;return t.setIndex(new mt(this._indices,1)),t.addAttribute("position",new mt(this._position,3)),t.addAttribute("normal",new mt(this._normals,3)),t.addAttribute("color",new mt(this._colors,3)),t.computeBoundingSphere(),t},Ha.prototype=Object.create(Ua.prototype),Ha.prototype.constructor=Ha,Ha.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new l(1,0,0),this.yAxis=new l(0,1,0),this.zAxis=new l(0,0,1),this.origin=new l(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},Ha.prototype._findMinMax=function(t){for(var e=t.length/4,r=[t[0],t[1],t[2],t[3]],n=[t[0],t[1],t[2],t[3]],i=1;i4&&(e.gridSpacing*=i[3]);var a=e.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var c=0;c<3;++c)i[c]-=a,o[c]+=a;for(c=0;c<3;++c)r[c]=Math.ceil((o[c]-i[c])/e.gridSpacing);return this.xAxis.x=(r[0]-1)*e.gridSpacing,this.yAxis.y=(r[1]-1)*e.gridSpacing,this.zAxis.z=(r[2]-1)*e.gridSpacing,this.origin.x=i[0],this.origin.y=i[1],this.origin.z=i[2],{bbox:n,dim:r}},Ha.prototype._makeSurface=function(t,e){var r=new Wa;r.compute(t.volMap,this.origin,e.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0&&(r.setColorVolTex(t.volTexMap,t.atomMap,t.atomWeightMap,this._visibilitySelector),this.setIndex(new mt(r._indices,1)),this.addAttribute("position",new mt(r._position,3)),this.addAttribute("normal",new mt(r._normals,3)),this.addAttribute("color",new mt(r._colors,3)))},Ha.prototype._calcSurface=function(t){var e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==e.posRad.length){var r=this._findNumVoxels(e.posRad,t),n=new et(this.origin,new l(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var sm=xd.Volume;(Xa.prototype=Object.create(Ha.prototype)).constructor=Xa,Xa.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new sm(Float32Array,this.numVoxels,e),volTexMap:new sm(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new sm(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},Xa.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,c=this.numVoxels,l=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=c[0]-1,m=c[1]-1,g=c[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,U),W=y.getDirectIdx(N,V,U),H=N*h-a[A],X=N;X<=I;++X,H+=h,G+=x,W+=w){var Y=-(H*H+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var $=3*M;b[W]+=q*s[$],b[W+1]+=q*s[$+1],b[W+2]+=q*s[$+2]}}}},Xa.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;ol?e:l,u+=e;var h=Math.floor(s/l);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=l;var p=h,f=h*h,d=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),g=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),v=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),y=0,_=m*h,x=g*h,b=v*h;for(c=0;c=0?C:0,T=T>=0?T:0,P=P>=0?P:0,L=L=0;s=this._atomsList[2*s+1])e(a[this._atomsList[2*s]])},Ka.prototype.getClosestAtom=function(t){var e=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(t,function(n){var i=t.distanceToSquared(n.coord);im)){var v=t.radius+i._probeRadius;(p=n-v*v)<0&&(p=-p),f=Math.exp(g*p),l+=e*f,u+=r*f,h+=d*f,o++}}),n=l*l+u*u+h*h,o>0&&(p=1/Math.sqrt(n),l*=p,u*=p,h*=p),r[v].x=l,r[v].y=u,r[v].z=h;return 0},Ka.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,c=0,l=0,u=n,h=u*u,p=[],f=[],d=0,m=0;mh)){var m=t.radius+i._probeRadius;(c=u-m*m)<0&&(c=-c),l=1/(.8+c),p.push([t.colorX,t.colorY,t.colorZ]),f.push(l),d+=l}});for(var g=0;g=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var z=new Y(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var F=this.complex.monomerTypeArray[h].color;c=F.r,l=F.g,u=F.b}1!==this.colorMode&&0!==this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),z.set(E,C,T),s[x]=new Za(z,L),s[x].colorX=c,s[x].colorY=l,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Ja.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var lm=xd.Element;(ts.prototype=Object.create(Ua.prototype)).constructor=ts,ts.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},ts.prototype._fromGeo=function(t){var e=null,r=gf.allocateTyped(Float32Array,3*t._numVertices),n=gf.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=gf.allocateTyped(Float32Array,3*t._numVertices));var i,o=gf.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?c:i,s.x-cr.x&&(r.x=s.x+c),s.y+c>r.y&&(r.y=s.y+c),s.z+c>r.z&&(r.z=s.z+c)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},ts.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),c=r*s,l=n*s,u=i*s;a.x=t.x*(1-c)+e.x*c,a.y=t.y*(1-l)+e.y*l,a.z=t.z*(1-u)+e.z*u},ts.prototype.buildEdgePoint=function(t,e,r,n,i,o){if(r[t]^r[e]){var a=(0-n.pointsValuesLinear[i+24+t])/(n.pointsValuesLinear[i+24+e]-n.pointsValuesLinear[i+24+t]),s=n.pointsValuesLinear[i+3*t+0],c=n.pointsValuesLinear[i+3*t+1],l=n.pointsValuesLinear[i+3*t+2],u=n.pointsValuesLinear[i+3*e+0],h=n.pointsValuesLinear[i+3*e+1],p=n.pointsValuesLinear[i+3*e+2];o.x=s*(1-a)+u*a,o.y=c*(1-a)+h*a,o.z=l*(1-a)+p*a}},ts.prototype.isTriangleVisible=function(t,e,r){var n=this.voxelWorld.getClosestAtom(t),i=this.voxelWorld.getClosestAtom(e),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&(this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom))},ts.prototype.addTriangle=function(t,e,r){if(this.visibilitySelector&&!this.isTriangleVisible(t,e,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,t),o=this.addVertexToGeo(n,e),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0},ts.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,c=t-1,u=t,h=t*t,p=new Array(12);for(a=0;a<12;a++)p[a]=new l;var f=[];for(a=0;a<8;a++)f[a]=1;for(var d=new l,m=0,g=0,v=0;ve.length/2||2*Object.keys(lm.ByName).length!==e.length)throw new Error("atomT.length should be equal Element.ByName.length * 2");return e[2*t-1]},ts.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,c=new l,u=new l,h=0;h=0;r=this.hashEntries[2*r+1]){var u=this.hashEntries[2*r+0];if(i.copy(t._vertices[u]),i.x-=e.x,i.y-=e.y,i.z-=e.z,i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return u}if(t._numVertices>=this.maxNumVertices)return-1;var h=t._numVertices;if(t._vertices[h].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var p=this.hashLines[c+1];this.hashLines[c+1]=r,this.hashEntries[2*r+0]=h,this.hashEntries[2*r+1]=p,this.hashLines[c+0]++}return t._numVertices++,h},ts.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){for(var a,s,c,l=t*t,u=(t-1)/(n.x-r.x),h=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),f=2*e*(2*e),d=1/(t-1),m=0;m=0?y:0,_=_>=0?_:0,x=x>=0?x:0,b=b<=t-1?b:t-1,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1;for(var M=_;M<=w;M++)for(var A=M*l,E=x;E<=S;E++)for(var C=E*t,T=y;T<=b;T++){a=A+C+T;var P=T*d,L=r.x*(1-P)+n.x*P;P=M*d;var R=r.y*(1-P)+n.y*P;P=E*d;var N=r.z*(1-P)+n.z*P,I=L-g.x,O=R-g.y,D=N-g.z,z=I*I+O*O+D*D;z0?(o[a]<0&&(o[a]=c),c>o[a]&&(o[a]=c)):c>o[a]&&(o[a]=c))}}return 0},ts.prototype._innerBuild=function(){var t,e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=e.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.clusterizationType=this._opts.clusterizationType,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var r=new Array(this.atoms.length);this.convertToAtomsColored(e,r);var n=this.vBoxMin=new l,i=this.vBoxMax=new l;this.getBoundingBox(r,n,i);var o=this.marCubeResoultion=4*this.meshResolution,a=o,s=a*a*a,c=gf.allocateTyped(Float32Array,s),u=this.meshResolution,h=4,p=this.atoms.length;p>=100&&(h=Math.floor(Math.pow(2*p,1/3))),u>h&&(u=h);var f=this.probeRadius*this.atomRadiusScale,d=null,m=null;this.clusterizationType>0?(d=new Qa(this.complex,this.atoms,r,n,i,u,this.colorMode),m=1===this.clusterizationType?d.buildKMeans():d.buildSimple(),n.x-=3.5,n.y-=3.5,n.z-=3.5,i.x+=3.5,i.y+=3.5,i.z+=3.5,this.calculateGridCorners(c,a,n,i,m,f)):this.calculateGridCorners(c,a,n,i,r,f);var g=o-1,v=new Ba;if((t=v.create(g))<0)return t;var y=new l;y.x=(i.x-n.x)/g,y.y=(i.y-n.y)/g,y.z=(i.z-n.z)/g;var _=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2);if(this.geoOut=new Ja(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;var w=f;if(this.excludeProbe&&(w=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Ka(m.length,m,n,i,w):this.voxelWorld=new Ka(r.length,r,n,i,w),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,c,y,v),this.excludeProbe){if(this.modifyExcludedFromGeo(a,f,n,i,this.geoOut,c),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,_=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2),this.geoOut=new Ja(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;t=this.buildGeoFromCorners(a,n,i,c,y,v)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var S=6.5;this.excludeProbe&&(S-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,S)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==d&&d.destroy(),v.destroy(),t},(rs.prototype=Object.create(Si.prototype)).constructor=rs,rs.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||es(r,"label label-"+i);o.worldPos.copy(e),o.style.textAlign=n.horizontalAlign,o.style.verticalAlign=n.verticalAlign,this.items[t]=o},rs.prototype.setColor=function(t,e,r){this.items[t].opts={color:e,background:r}},rs.prototype.startUpdate=function(){return!0},rs.prototype.finishUpdate=function(){this.needsUpdate=!0,this.dispatchEvent({type:"update"})},rs.prototype.finalize=function(){this.finishUpdate()},rs.prototype.raycast=function(){},rs.prototype.setOpacity=function(){},rs.prototype.getSubset=function(){return[]};var um={InstancedSpheresGeometry:ga,SimpleSpheresGeometry:_a,Simple2CCylindersGeometry:xa,Instanced2CCylinderGeometry:Ca,ExtrudedObjectsGeometry:Pa,ChunkedLinesGeometry:za,TwoColorLinesGeometry:Fa,CrossGeometry:ka,QuickSurfGeometry:Xa,ContactSurfaceGeometry:$a,SSIsosurfaceGeometry:ts,LabelsGeometry:rs},hm=function(t){function e(){t.apply(this,arguments),this.onBeforeRender=e.prototype.onBeforeRender}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.onBeforeRender=function(t,e,r,n,i,o){this._onBeforeRender(t,e,r,n,i,o),this._update()},e.prototype._onBeforeRender=function(){},e.prototype._update=function(){var t=this.material;t&&t instanceof oa&&t.updateUniforms()},e},pm=hm(Lt);(ns.prototype=Object.create(pm.prototype)).constructor=ns,ns.prototype._onBeforeRender=function(){var t=this.material;t&&t.uniforms.invModelViewMatrix&&t.uniforms.invModelViewMatrix.value.getInverse(this.modelViewMatrix)};var fm=hm(Lt);(is.prototype=Object.create(fm.prototype)).constructor=is,is.prototype._onBeforeRender=function(t,e,r){var n=this.geometry,i=this.material;if(n.zClip&&i.uberOptions){var o=(new u).multiplyMatrices(this.matrixWorld,r.matrixWorldInverse),a=(new l).setFromMatrixColumn(o,0).length(),s=(new l).copy(n.boundingSphere.center);this.localToWorld(s),i.uberOptions.zClipValue=r.position.z-s.z-a*(.5*n.boundingSphere.radius)}},(os.prototype=Object.create(Ae.prototype)).constructor=os,os.prototype.init=function(){for(var t=this.children,e=t.length-1;e>=0;--e)this.remove(t[e]);var r=this.geometry.items,n=this.geometry.userData,i=r.length;for(e=0;e>16&255,r=t>>8&255,n=255&t;return.2126*e+.7152*r+.0722*n>127?(e=3*e/10,r=3*r/10,n=3*n/10):(e=255-3*(255-e)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),e<<16|r<<8|n},inverse:function(t){return 255-(t>>16&255)<<16|255-(t>>8&255)<<8|255-(255&t)}},vm={serial:function(t){return t.getSerial()},name:function(t){return t.getVisualName()},elem:function(t){return t.element.name},residue:function(t){return t._residue.getType().getName()},sequence:function(t){return t._residue.getSequence()},chain:function(t){return t._residue.getChain().getName()},hetatm:function(t){return t.isHet()},water:function(t){return"HOH"===t._residue.getType().getName()||"WAT"===t._residue.getType().getName()}},ym=function(t,e){return e.replace(/\{\{(\s*\w+\s*)\}\}/g,function(e){var r=e.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),vm.hasOwnProperty(r)?vm[r](t):"null"})};(ws.prototype=Object.create(gs.prototype)).constructor=ws,ws.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},ws.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;a>1)+"px"})}for(var l,u=0,h=(o.lines-1)*(1-o.direction)/2;u',r)}l.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(t,n){function o(){return i(r("group",{coordsize:u+" "+u,coordorigin:-l+" "+-l}),{width:u,height:u})}function s(t,s,c){e(p,e(i(o(),{rotation:360/n.lines*t+"deg",left:~~s}),e(i(r("roundrect",{arcsize:n.corners}),{width:l,height:n.scale*n.width,left:n.scale*n.radius,top:-n.scale*n.width>>1,filter:c}),r("fill",{color:a(n.color,t),opacity:n.opacity}),r("stroke",{opacity:0}))))}var c,l=n.scale*(n.length+n.width),u=2*n.scale*l,h=-(n.width+n.length)*n.scale*2+"px",p=i(o(),{position:"absolute",top:h,left:h});if(n.shadow)for(c=1;c<=n.lines;c++)s(c,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(c=1;c<=n.lines;c++)s(c);return e(t,p)},s.prototype.opacity=function(t,e,r,n){var i=t.firstChild;n=n.shadow&&n.lines||0,i&&e+n0)return"!"+r.join()}return""},objectsDiff:Ii,forInRecursive:function(t,e){function r(t,n){wu.forIn(t,function(t,i){var o=n+(n.length>0?".":"");t instanceof Object?r(t,o+i):void 0!==t&&e(t,o+i)})}r(t,"")},enquoteString:function(t){return wu.isString(t)?'"'+t.replace(/"/g,'\\"')+'"':t},shotOpen:function(t){"undefined"!=typeof window&&window.open().document.write('')},shotDownload:function(t,e){if(t&&"data:"===t.substr(0,5))if(e||(e=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(Oi(t),e);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=e,r.innerHTML="download",r.href=window.URL.createObjectURL(Oi(t)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(t,e,r,n){for(var i=0,o=r.length;ithis._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=t),t},update:function(){this._startTime=this.end()},show:function(t){void 0===t&&(t=!0),this.domElement.style.display=t?"block":"none"}},gf.deriveClass(ki,Si),ki.prototype.cancel=function(){this._cancellationRequested=!0,this.dispatchEvent("cancel")},ki.prototype.isCancellationRequested=function(){return this._cancellationRequested},ki.prototype.notify=function(t){this.dispatchEvent({type:"notification",slaveEvent:t})};var yf={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:2,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:5,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},labels:"no",antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},theme:"dark",themes:{dark:2105376,light:13421772},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5,waterBondingHack:!1},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,ao:!1,autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};Fi.prototype={constructor:Fi,defaults:yf,set:function(t,e){wu.set(this.now,t,e),this._changed[t]=!0},get:function(t,e){return wu.get(this.now,t,e)},reset:function(){this.now=wu.cloneDeep(yf),this.old=null,this._changed={}},checkpoint:function(){this.old=wu.cloneDeep(this.now),this._changed={}},undo:function(){this.now=wu.cloneDeep(this.old),this._changed={}},changed:function(){if(!this.old)return[];var t=this.old,e=this.now;return wu.filter(Object.keys(this._changed),function(r){return wu.get(t,r)!==wu.get(e,r)})},override:function(t){wu.merge(this.now,t)},applyDiffs:function(t){if(t.hasOwnProperty("VERSION")&&0!==t.VERSION)throw new Error("Settings version does not match!");this.reset(),wu.merge(this.now,t)},getDiffs:function(t){var e=gf.objectsDiff(this.now,yf);return t&&(e.VERSION=0),e},setPluginOpts:function(t,e){yf.plugins[t]=wu.cloneDeep(e),this.now.plugins[t]=wu.cloneDeep(e)}};var _f=new Fi,xf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bf=(function(){function t(t){this.value=t}function e(e){function r(i,o){try{var a=e[i](o),s=a.value;s instanceof t?Promise.resolve(s.value).then(function(t){r("next",t)},function(t){r("throw",t)}):n(a.done?"return":"normal",a.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}(i=i.next)?r(i.key,i.arg):o=null}var i,o;this._invoke=function(t,e){return new Promise(function(n,a){var s={key:t,arg:e,resolve:n,reject:a,next:null};o?o=o.next=s:(i=o=s,r(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),wf=function(){function t(t,e){for(var r=0;r0?gf.deriveDeep(e.reps[Af-1],!0):gf.deriveDeep(_f.defaults.presets.default[0],!0))},s:"select",select:function(t,e){Gi(e,"selector",t)},m:"mode",mode:function(t,e){Gi(e,"mode",Xi(t,_f.defaults.modes))},c:"color",color:function(t,e){Gi(e,"colorer",Xi(t,_f.defaults.colorers))},mt:"material",material:function(t,e){Gi(e,"material",Xi(t,_f.defaults.materials))},dup:function(t,e){ji(e);var r=e.reps,n=r[Af];++Af>=r.length&&(r[Af]=gf.deriveDeep(n,!0))},ar:"autoResolution",background:"theme"},Df={fromURL:function(t){return Yi(gf.getUrlParameters(t))},fromAttr:function(t){return Yi(gf.getUrlParameters("?"+(t||"")))},adapters:Ef,toURL:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=Bi(t)+Cf+Bi(e))}var r=[],n=0;e("l",t.load),e("u",t.unit),e("p",t.preset),function(t){if(t)for(var r=0,n=t.length;r0&&(i+="?"+r.join("&")),i},toScript:function(t){function e(t,e){null!==e&&void 0!==e&&(r[n++]=t+" "+e)}var r=[],n=0;return e("set","autobuild false"),e("load",t.load),e("unit",t.unit),e("preset",t.preset),function(t){if(t)for(var r=0,n=t.length;r0?t.getString():this.element.name.trim()},no.prototype.forEachBond=function(t){for(var e=this._bonds,r=0,n=e.length;r=0)return this._hydrogenCount;var t=this.element,e=t.hydrogenValency;if(1===e.length&&0===e[0])return 0;switch(t.number){case 1:return this.getHydrogenCountHydrogen();case 3:case 11:case 19:case 37:case 55:case 87:case 4:case 12:case 20:case 38:case 56:case 88:case 13:case 31:case 49:case 41:case 82:case 83:return this.getHydrogenCountMetal();case 6:case 14:case 32:case 51:return this.getHydrogenCountGroup14();case 50:return this.getHydrogenCountTin();case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 53:case 85:return this.getHydrogenCountNonMetal();case 5:return this.getHydrogenCountBoron();default:return 0}},no.prototype.getAtomBondsCount=function(){for(var t=this.getBonds(),e=0,r=0;r=t){r=e[n];break}return r},no.prototype.getCharge=function(){return this._charge},no.prototype.getLocation=function(){return this._location},no.prototype.getFullName=function(){var t="";return null!==this._residue&&(null!==this._residue._chain&&(t+=this._residue._chain.getName()+"."),t+=this._residue._sequence+"."),t+=this._name.getString()};var zf={UNKNOWN:0,COVALENT:1,AROMATIC:2};ao.BondType=zf,ao.prototype.BondType=zf,ao.prototype.getLeft=function(){return this._left},ao.prototype.getRight=function(){return this._right},ao.prototype.getOrder=function(){return this._order},ao.prototype.calcLength=function(){return this._left._position.distanceTo(this._right._position)},ao.prototype._forEachNeighbour=function(t,e){for(var r=t._bonds,n=0,i=r.length;n0?++o:++a}function i(t){"C"===t.element.name&&n(t)}for(var o=0,a=0,s=t.clone(),c=[[this.forEachLevelOne,i],[this.forEachLevelOne,n],[this.forEachLevelTwo,i],[this.forEachLevelTwo,n]],l=0;lo)return e.multiplyScalar(-1);if(ar._bonds.length&&(n=r,i=e);for(var o=n,a=0,s=i._bonds,c=0,l=s.length;ca&&u!==n&&(o=u,a=u._bonds.length)}var h=t(i),p=t(n).clone().sub(h),f=t(o).clone().sub(h);return f.crossVectors(p,f),f.lengthSq()<1e-4&&f.set(0,1,0),p.normalize(),f.normalize(),p.crossVectors(f,p),p.lengthSq()<1e-4&&p.set(0,1,0),p.normalize(),this._fixDir(h,p,t)},so.prototype.getName=function(){return this._name},so.StandardTypes={ALA:new so("ALA","Alanine","A"),ARG:new so("ARG","Arginine","R"),ASN:new so("ASN","Asparagine","N"),ASP:new so("ASP","Aspartic Acid","D"),CYS:new so("CYS","Cysteine","C"),GLN:new so("GLN","Glutamine","Q"),GLU:new so("GLU","Glutamic Acid","E"),GLY:new so("GLY","Glycine","G"),HIS:new so("HIS","Histidine","H"),ILE:new so("ILE","Isoleucine","I"),LEU:new so("LEU","Leucine","L"),LYS:new so("LYS","Lysine","K"),MET:new so("MET","Methionine","M"),PHE:new so("PHE","Phenylalanine","F"),PRO:new so("PRO","Proline","P"),PYL:new so("PYL","Pyrrolysine","O"),SEC:new so("SEC","Selenocysteine","U"),SER:new so("SER","Serine","S"),THR:new so("THR","Threonine","T"),TRP:new so("TRP","Tryptophan","W"),TYR:new so("TYR","Tyrosine","Y"),VAL:new so("VAL","Valine","V"),A:new so("A","Adenine","A"),C:new so("C","Cytosine","C"),G:new so("G","Guanine","G"),I:new so("I","Inosine","I"),T:new so("T","Thymine","T"),U:new so("U","Uracil","U"),DA:new so("DA","Adenine","A"),DC:new so("DC","Cytosine","C"),DG:new so("DG","Guanine","G"),DI:new so("DI","Inosine","I"),DT:new so("DT","Thymine","T"),DU:new so("DU","Uracil","U"),"+A":new so("+A","Adenine","A"),"+C":new so("+C","Cytosine","C"),"+G":new so("+G","Guanine","G"),"+I":new so("+I","Inosine","I"),"+T":new so("+T","Thymine","T"),"+U":new so("+U","Uracil","U"),WAT:new so("WAT","Water",""),H2O:new so("H2O","Water",""),HOH:new so("HOH","Water",""),UNK:new so("UNK","Unknown",""),UNL:new so("UNL","Unknown Ligand","")},so.Flags={PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536};var kf=so.Flags;co(kf.WATER,["WAT","H2O","HOH"]),co(kf.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),co(kf.BASIC,["ARG","HIS","LYS"]),co(kf.ACIDIC,["ASP","GLU"]),co(kf.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),co(kf.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),co(kf.AROMATIC,["PHE","TRP","TYR"]),co(kf.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),co(kf.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),co(kf.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),co(kf.DNA,["DA","DG","DI","DC","DT","DU"]),co(kf.RNA,["A","G","I","C","T","U"]),function(t,e){for(var r=Object.keys(e),n=0,i=r.length;nMath.PI/2&&o.negate(),o},lo.prototype._innerFinalize=function(t,e,r,n,i){var o=null===e,a=i(this._leadAtom),s=new l(a.x,a.y,a.z);if(0==(this._type.flags&so.Flags.NUCLEIC)){if(o)n._midPoint=i(this._firstAtom).clone();else{var c=e._controlPoint;n._midPoint=c.clone().lerp(s,.5),n._wingVector=this.calcWing(c,s,i(t._wingAtom),e._wingVector)}n._controlPoint=s}else this._detectLeadWing(n,r,i)},lo.prototype._finalize2=function(t,e){this._innerFinalize(t,t,e,this,function(t){return t._position})},lo.prototype.isConnected=function(t){if(this._chain!==t._chain)return!1;if(this===t)return!0;var e=!1;return this.forEachAtom(function(r){for(var n=r._bonds,i=0,o=n.length;i1){var a=t[1]._wingVector;t[0]._wingVector=new l(a.x,a.y,a.z)}else t.length>0&&(t[0]._wingVector=new l(1,0,0))},uo.prototype.updateToFrame=function(t){for(var e=this._residues,r=null,n=null,i=t._residues,o=e.length,a=0;a1?i[e[1]._index]._wingVector:new l(1,0,0)},uo.prototype.addResidue=function(t,e,r){var n=this._complex.getResidueType(t);null===n&&(n=this._complex.addResidueType(t));var i=new lo(this,n,e,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(so.Flags.NUCLEIC|so.Flags.PROTEIN)&&(this.maxSequencee&&(this.minSequence=e)),i},uo.prototype.getResidueCount=function(){return this._residues.length},uo.prototype.forEachResidue=function(t){for(var e=this._residues,r=0,n=e.length;r1?i=n>1?this._repeat.toString()+"("+i+")":this._repeat.toString()+i:n>1&&(i="("+i+")"),o>1&&(i+="^"+o.toString()+"+"),1===o&&(i+="^+"),o<-1&&(i+="^"+Math.abs(o).toString()+"-"),-1===o&&(i+="^-")):this._repeat>1&&(i=this._repeat.toString()+i),i};var Gf={},Wf=Object.freeze({default:Gf}),Hf=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Xf=function(t){return Hf.exec(t).slice(1)},Yf={extname:Mo,basename:So,dirname:wo,sep:"/",delimiter:":",relative:bo,join:xo,isAbsolute:_o,normalize:yo,resolve:vo},qf="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)},$f=Object.freeze({resolve:vo,normalize:yo,isAbsolute:_o,join:xo,relative:bo,sep:"/",delimiter:":",dirname:wo,basename:So,extname:Mo,default:Yf}),Zf=Wf&&Gf||Wf,Kf=$f&&Yf||$f,Qf=e(function(e,r){var n=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,4],n=[1,5],i=[1,6],o=[1,7],a=[1,8],s=[1,9],c=[1,11],l=[1,12],u=[5,7,8,11],h=[1,17],p=[1,22],f=[1,20],d=[1,21],m=[5,7,8,11,19],g={trace:function(){},yy:{},symbols_:{error:2,Program:3,Expression:4,EOF:5,Selector:6,OR:7,AND:8,NOT:9,"(":10,")":11,SELECTOR:12,NAMED_SELECTOR:13,SELECTOR_RANGED:14,RangeList:15,SELECTOR_NAMED:16,NameList:17,Range:18,",":19,NUMBER:20,":":21,Name:22,IDENTIFIER:23,STRING:24,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"OR",8:"AND",9:"NOT",10:"(",11:")",12:"SELECTOR",13:"NAMED_SELECTOR",14:"SELECTOR_RANGED",16:"SELECTOR_NAMED",19:",",20:"NUMBER",21:":",23:"IDENTIFIER",24:"STRING"},productions_:[0,[3,2],[4,1],[4,3],[4,3],[4,2],[4,3],[6,1],[6,1],[6,2],[6,2],[15,1],[15,3],[18,1],[18,3],[17,1],[17,3],[22,1],[22,1],[22,1]],performAction:function(t,e,r,n,i,o,a){var s=o.length-1;switch(i){case 1:return o[s-1];case 3:this.$=n.keyword("or")(o[s-2],o[s]);break;case 4:this.$=n.keyword("and")(o[s-2],o[s]);break;case 5:this.$=n.keyword("not")(o[s]);break;case 6:this.$=o[s-1];break;case 7:this.$=n.keyword(o[s])();break;case 8:this.$=n.GetSelector(o[s].toLowerCase().slice(1,o[s].length));break;case 9:case 10:this.$=n.keyword(o[s-1])(o[s]);break;case 11:this.$=new n.RangeList(o[s]);break;case 12:case 16:this.$=o[s-2].append(o[s]);break;case 13:this.$=new n.Range(Number(o[s]));break;case 14:this.$=new n.Range(Number(o[s-2]),Number(o[s]));break;case 15:this.$=new n.ValueList(o[s])}},table:[{3:1,4:2,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{1:[3]},{5:[1,10],7:c,8:l},e(u,[2,2]),{4:13,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:14,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,7]),e(u,[2,8]),{15:15,18:16,20:h},{17:18,20:p,22:19,23:f,24:d},{1:[2,1]},{4:23,6:3,9:r,10:n,12:i,13:o,14:a,16:s},{4:24,6:3,9:r,10:n,12:i,13:o,14:a,16:s},e(u,[2,5]),{7:c,8:l,11:[1,25]},e(u,[2,9],{19:[1,26]}),e(m,[2,11]),e(m,[2,13],{21:[1,27]}),e(u,[2,10],{19:[1,28]}),e(m,[2,15]),e(m,[2,17]),e(m,[2,18]),e(m,[2,19]),e([5,7,11],[2,3],{8:l}),e(u,[2,4]),e(u,[2,6]),{18:29,20:h},{20:[1,30]},{20:p,22:31,23:f,24:d},e(m,[2,12]),e(m,[2,14]),e(m,[2,16])],defaultActions:{10:[2,1]},parseError:function(t,e){if(!e.recoverable){var r=function(t,e){this.message=t,this.hash=e};throw r.prototype=Error,new r(t,e)}this.trace(t)},parse:function(t){var e=this,r=[0],n=[],i=[null],o=[],a=this.table,s="",c=0,l=0,u=1,h=o.slice.call(arguments,1),p=Object.create(this.lexer),f={yy:{}};for(var d in this.yy)Object.prototype.hasOwnProperty.call(this.yy,d)&&(f.yy[d]=this.yy[d]);p.setInput(t,f.yy),f.yy.lexer=p,f.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var m=p.yylloc;o.push(m);var g=p.options&&p.options.ranges;"function"==typeof f.yy.parseError?this.parseError=f.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var v,y,_,x,b,w,S,M,A,E={};;){if(_=r[r.length-1],this.defaultActions[_]?x=this.defaultActions[_]:(null!==v&&void 0!==v||(v=function(){var t;return"number"!=typeof(t=n.pop()||p.lex()||u)&&(t instanceof Array&&(t=(n=t).pop()),t=e.symbols_[t]||t),t}()),x=a[_]&&a[_][v]),void 0===x||!x.length||!x[0]){var C="";A=[];for(w in a[_])this.terminals_[w]&&w>2&&A.push("'"+this.terminals_[w]+"'");C=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(c+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(C,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],E.$=i[i.length-S],E._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(E._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(E,[s,l,c,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(E.$),o.push(E._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},v={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return e.yytext=e.yytext.substr(1,e.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return g.lexer=v,t.prototype=g,g.Parser=t,new t}();void 0!==t&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=Zf.readFileSync(Kf.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}).parser,Jf={},td=function(){function t(e,r){bf(this,t),this.min=e,this.max=void 0===r?e:r}return wf(t,[{key:"includes",value:function(t){return this.min<=t&&t<=this.max}},{key:"toString",value:function(){var t=this.min,e=this.max;return t===e?String(t):[t,e].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),t}(),ed=function(){function t(e){if(bf(this,t),e instanceof this.constructor)return e;e instanceof Array?this._values=e.slice(0):this._values=e?[e]:[]}return wf(t,[{key:"append",value:function(t){var e=this._values;return e[e.length]=t,this}},{key:"remove",value:function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var t=this._values,e=[],r=0,n=t.length;rthis.priority?"("+this.rhs+")":this.rhs;return this.keyword+" "+t}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),e}();ud.prototype.priority=1;var hd=function(t){function e(t,r){bf(this,e);var n=Mf(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.lhs=t||ld,n.rhs=r||ld,n}return Sf(e,od),wf(e,[{key:"toString",value:function(){var t=this.lhs.priority&&this.lhs.priority>this.priority?"("+this.lhs+")":this.lhs,e=this.rhs.priority&&this.rhs.priority>this.priority?"("+this.rhs+")":this.rhs;return t+" "+this.keyword+" "+e}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),e}();hd.prototype.priority=1e3,To("Not",1,function(t){function e(){return bf(this,e),Mf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sf(e,ud),wf(e,[{key:"includesAtom",value:function(t){return!this.rhs.includesAtom(t)}}]),e}()),To("And",2,function(t){function e(){return bf(this,e),Mf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sf(e,hd),wf(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)&&this.rhs.includesAtom(t)}}]),e}()),To("Or",3,function(t){function e(){return bf(this,e),Mf(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return Sf(e,hd),wf(e,[{key:"includesAtom",value:function(t){return this.lhs.includesAtom(t)||this.rhs.includesAtom(t)}}]),e}());var pd=Object.create(Jf);pd.Selector=od,pd.RangeListSelector=sd,pd.ValueListSelector=cd,pd.Range=td,pd.RangeList=rd,pd.ValueList=id,pd.PrefixOperator=ud,pd.InfixOperator=hd,pd.Context=Object.create({}),pd.GetSelector=function(t){if(!pd.Context.hasOwnProperty(t))throw{message:"selector "+t+" is not registered"};return pd.Context[t]||ld},pd.ClearContext=function(){Object.keys(pd.Context).forEach(function(t){delete pd.Context[t]})},pd.keyword=function(t){return Jf[t.toLowerCase()]||Jf.none},pd.parse=function(t){var e={};try{e.selector=Qf.parse(t)}catch(t){e.selector=ld,e.error=t.message}return e},Qf.yy=pd,Qf.yy.parseError=Qf.parseError,Po.prototype.constructor=Po,Po.prototype.computeBoundaries=function(){var t,e=this._complex._atoms,r=e.length,n=this._selector,i=this._boundaries.boundingBox;if(i.makeEmpty(),1===r){i.expandByPoint(e[0]._position);var o=i.getCenter(),a=2*e[0].element.radius;i.setFromCenterAndSize(o,new l(a,a,a))}else for(t=0;t0?this._selector=pd.keyword("Chain")(this.chains):this._selector=pd.keyword("None")()},Ro.prototype.id="__",No.prototype.getResidues=function(){return this._complex._residues},No.prototype.getResidueCount=function(){return this._residueCount},No.prototype.forEachResidue=function(t){for(var e=this._complex._residues,r=this._residueIndices,n=0,i=r.length;ne?t:e,i=r+(n<<14),o=(r+89237*n&dd-1)*fd,a=0;a=fd)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+a]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");o=this.numPairs*md,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++};Fo.prototype._addExistingPairs=function(){for(var t=this._complex.getAtoms(),e=t.length,r=0,n=this._pairCollection;r=a))for(var b=-1;b<=1;++b){var w=v+b;if(!(w<0||w>=o))for(var S=-1;S<=1;++S){var M=g+S;if(!(M<0||M>=i))for(var A=t[x*c+w*i+M],E=0;EN*N||L<.001||this._pairCollection.addPair(u,C)}}}}}}}}},Fo.prototype._addPairs=function(){for(var t=this._complex._atoms,e=0,r=0;e125e3);this.xB=t,this.yB=e,this.zB=r,this.invPairDist=i;for(var f=[],d=0;d.1)&&t.dot(e)>=0}}();Wo.prototype.update=function(){for(var t=this.atoms,e=new l,r=t.length,n=0;ni[c]?++c:++s}return!1},$o.prototype._tryBond=function(t,e,r){var n=[],i=this._bondsData,o=Vo(t,e),a=e._position.clone().sub(o._position),s=this._currStart,c=this,l=this._bondMarks,u=this._checkBond;l[t._index]=!0,u=void 0===u?Ho:u,e.forEachBond(function(o){if(u(o)&&o!==t&&!l[o._index]&&!c._haveSameCycle(i,t,o)){var h=Vo(o,e),p=h._position.clone().sub(e._position),f=h===s?-2:1-jo(a,p),d=p.cross(a);if(_d(d,r)){for(var m=0;ms?1:0},Zo.prototype._atomNameCompareCWithH=function(t,e){return this._atomNameCompare(t,e,2)},Zo.prototype._atomNameCompareCWithoutH=function(t,e){return this._atomNameCompare(t,e,254)},Zo.prototype._buildFormulaSimple=function(t,e){var r=t.atoms,n=null,i={},o="",a=this,s=ro.ByName.H.name,c=0;r.forEach(function(t){var e=t.getHydrogenCount();n=t.element,i[n.name]?i[n.name]+=1:i[n.name]=1,e>0&&(i[s]?i[s]+=e:i[s]=e),c+=t.getCharge()});var l=Object.keys(i);return i.C?l.sort(this._atomNameCompareCWithH.bind(this)):l.sort(function(t,e){return a._atomNameCompare(t,e,"H".charCodeAt(0))}),l.forEach(function(t){var e=t.substr(0,1).toUpperCase()+t.substr(1).toLowerCase();i[t]>1?o+=e+i[t].toString():o+=e}),null===e?(0!==c&&(l.length>1&&(o="("+o+")"),c>1&&(o+="^{"+c.toString()+"+}"),1===c&&(o+="^+"),c<-1&&(o+="^{"+Math.abs(c).toString()+"-}"),-1===c&&(o+="^-")),t.repeatCount>1&&(o=t.repeatCount.toString(10)+o)):e(l.length,c),o},Zo.prototype._buildPartFormula=function(t){return t.owner instanceof Zo||t.owner instanceof No?this._buildFormulaSimple(t,null):t.owner instanceof mo?t.owner.buildChemicalFormula(this,t):""},Zo.prototype._partCompareFunc=function(t,e){return this._partCompareFuncInt(t,e,!0)},Zo.prototype._getCumulativeCharge=function(t){for(var e=t.length,r=0,n=0;n0&&(r[a]?r[a]+=n:r[a]=n)}});var n=Object.keys(r);return n.sort(o._atomNameCompareCWithoutH.bind(o)),{seq:n,data:r}}for(var i,o=this,a=ro.ByName.H.name,s=[r,!1],c=0;cro.ByName.MT.number)return"}\\text{Could not create chemical formula for this structure.}{";return""},Zo.prototype.buildChemicalFormula=function(){var t=[],e=null,r=null,n={},i=null,o=this,a=this._checkFormulaBuildable();if(""!==a)return a;this.forEachAtom(function(t){n[t.getSerial()]&&ff.warn("Broken complex. Formula can be invalid..."),n[t.getSerial()]={atom:t,taken:null}}),this.forEachSGroup(function(o){0===o._charge&&1===o._repeat||(r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)}),e.atoms.length>0&&t.push(e),e=null)}),this.forEachComponent(function(o){r=(e={owner:o,atoms:[],repeatCount:1}).atoms,o.forEachResidue(function(t){t._atoms.forEach(function(t){null===(i=n[t.getSerial()]).taken&&(r.push(t),i.taken=o)})}),e.atoms.length>0&&t.push(e),e=null}),Object.keys(n).forEach(function(t){null===t.taken&&(null===e&&(e={owner:o,atoms:[],repeatCount:1}),e.atoms.push(t.atom),t.taken=o)}),null!==e&&e.atoms.length>0&&t.push(e),t.sort(function(t,e){return o._partCompareFunc(t,e)});for(var s=t.length-1,c=t.length-2;s>=0&&c>=0;){var l=t[s],u=t[c];l.owner instanceof Zo||l.owner instanceof No?u.owner instanceof Zo||u.owner instanceof No?(0===this._partCompareFuncInt(u,l,!1)&&(u.repeatCount+=l.repeatCount,t.splice(s,1)),c--,s--):c--:--s===c&&c--}return t.forEach(function(t){var e=o._buildPartFormula(t);e.length>0&&(a.length>0&&(a+="*"),a+=e)}),a},Zo.prototype.getUnifiedSerial=function(t,e,r){return e+65536*r+16777216*t},Zo.prototype.splitUnifiedSerial=function(t){var e=Math.floor(t/16777216),r=t-16777216*e,n=Math.floor(r/65536);return{chain:e,serial:r-65536*n,iCode:n}},Zo.prototype._fillCmpEdit=function(){function t(){var t=new No(e);return t._index=r.length,r[t._index]=t,t}var e=this,r=this._components;this.forEachChain(function(e){var r=e._residues,n=r.length;if(!(n<1))for(var i=t(),o=r[0]._index,a=0;a=0&&t=0;e--){var i=n[e];null===i._left||null===i._right?n.splice(e,1):(i._left._bonds.push(i),i._right._bonds.push(i))}var o=this._residues;for(e=0,r=o.length;e1?t.x/(this._dimX-1):0,e.y=this._dimY>1?t.y/(this._dimY-1):0,e.z=this._dimZ>1?t.z/(this._dimZ-1):0,e},Ko.prototype.computeGradient=function(){function t(t,e,r){return Math.min(r,Math.max(e,t))}function e(t,e,r){return c[r*o*a+e*o+t]}if(1!==this._dimVec)return null;for(var r=new Ko(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),n=this.getCellSize(),i=new l(-.5/n.x,-.5/n.y,-.5/n.z),o=this._dimX,a=this._dimY,s=this._dimZ,c=this._data,u=0;u=0;r=this._atoms[r+1])e(this._atoms[r])},ea.prototype._forEachVoxelWithinRadius=function(t,e,r){var i,o,a,s,c,l,u,h,p=new n,f=new n,d=new n;d.set(t.z-e,t.z+e),d.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=d.x;m<=d.y;++m){c=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],h=t.z-e<=c[0]&&c[1]<=t.z+e,i=Jo(t,e,c[0],c[1]),f.set(t.y-i[1],t.y+i[1]),f.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var g=f.x;g<=f.y;++g){s=[this._box.min.y+g*this._cellSize.y,this._box.min.y+(g+1)*this._cellSize.y],u=t.y-i[0]<=s[0]&&s[1]<=t.y+i[0],o=ta(t,i[1],s[0],s[1]),p.set(t.x-o[1],t.x+o[1]),p.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var v=p.x;v<=p.y;++v)a=[this._box.min.x+v*this._cellSize.x,this._box.min.x+(v+1)*this._cellSize.x],l=t.x-o[0]<=a[0]&&a[1]<=t.x+o[0],r(v+this._count.x*(g+this._count.y*m),l&&u&&h)}}},ea.prototype.forEachAtomWithinRadius=function(t,e,r){var n=this,i=e*e;n._forEachVoxelWithinRadius(t,e,function(e,o){o?n._forEachAtomInVoxel(e,r):n._forEachAtomInVoxel(e,function(e){t.distanceToSquared(e._position)=0;s=a[s+1])if(t._position.distanceToSquared(a[s]._position)=1?this.fov=t:this.fov=Tp.radToDeg(2*Math.atan(Math.tan(.5*Tp.degToRad(t))/this.aspect))},zt.prototype.setDistanceToFit=function(t,e){this.position.z=t/Math.sin(.5*Tp.degToRad(e))},mt.prototype.copyAtList=function(t,e){for(var r=this.itemSize,n=0,i=e.length;n1e-5;)e=n,n=t/((i=1+r*n)*i);return 1/i}(a*a+s*s);i.setXY(o,c*a,c*s)}return n},RCGroup:ia,fillArray:function(t,e,r,n){r=void 0!==r?r:0,n=void 0!==n?n:t.length;for(var i=r;i65535,s=i*e,c=this._index=gf.allocateTyped(a?Uint32Array:Uint16Array,s);this._positions=gf.allocateTyped(Float32Array,3*o),this._normals=gf.allocateTyped(Float32Array,3*o),this._colors=gf.allocateTyped(Float32Array,3*o);var l=this._alpha=gf.allocateTyped(Float32Array,o);wu.fill(l,1);for(var u=0;u65535;this._index=gf.allocateTyped(r?Uint32Array:Uint16Array,6*t),this._positions=gf.allocateTyped(Float32Array,4*e),this._colors=gf.allocateTyped(Float32Array,3*e),this._directions=gf.allocateTyped(Float32Array,3*e);var n=this._alpha=gf.allocateTyped(Float32Array,e);wu.fill(n,1);for(var i=this._index,o=0,a=0,s=0;s117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=gf.allocateTyped(Float32Array,32*e),this.hasIntersection=gf.allocateTyped(Int32Array,e),this.bitsInside=gf.allocateTyped(Int32Array,e),0},Ba.prototype.destroy=function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null},Ba.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var sm=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0];ja.prototype.constructor=ja,Ga.prototype.constructor=Ga,Wa.prototype.constructor=Wa,Wa.prototype._prepareAxesAndDirs=function(){var t=this._volumetricData.getCellSize(),e=this._xAxis,r=this._yAxis,n=this._zAxis,i=this._xDir,o=this._yDir,a=this._zDir;e.set(t.x,0,0),r.set(0,t.y,0),n.set(0,0,t.z),i.set(1,0,0),o.set(0,1,0),a.set(0,0,1);var s=new l;return s.crossVectors(i,o),s.dot(a)<0&&(i.negate(),o.negate(),a.negate()),!(i.x<0||i.y<0||i.z<0||o.x<0||o.y<0||o.z<0||a.x<0||a.y<0||a.z<0)&&!(0!==e.y||0!==e.z||0!==r.x||0!==r.z||0!==n.x||0!==n.y)},Wa.prototype._vertexInterp=function(t,e,r,n,i,o){var a=e.p[r],s=e.p[n],c=e.g[r],l=e.g[n],u=e.val[r],h=t-u,p=e.val[n]-u,f=0;Math.abs(p)>0&&(f=h/p),f=f>1?1:f,i.lerpVectors(a,s,f),o.lerpVectors(c,l,f)},Wa.prototype._polygonize=function(){for(var t=Ba.prototype.striIndicesMarchCube,e=[0,1,2,3,4,5,6,7,0,1,2,3],r=[1,2,3,0,5,6,7,4,4,5,6,7],n=new Array(12),i=new Array(12),o=0;o<12;++o)n[o]=new l,i[o]=new l;return function(a,s,c){var l=a.cubeIndex;for(o=0;o<12;++o)sm[l]&1<s?s:l+e,h=-1,p=l;pV&&(j=G,V=C[G]);if(j<0||!n.includesAtom(E[j])){P[a]=-1;continue}}P[a]=L++;var W=D=0&&nt>=0&&it>=0&&(this._indices[3*et]=rt,this._indices[3*et+1]=nt,this._indices[3*et+2]=it,++et)}this._position=new Float32Array(this._position.buffer.slice(0,3*L*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*L*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*L*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*et*4))}},Wa.prototype.toMesh=function(){var t=new Pt;return t.setIndex(new mt(this._indices,1)),t.addAttribute("position",new mt(this._position,3)),t.addAttribute("normal",new mt(this._normals,3)),t.addAttribute("color",new mt(this._colors,3)),t.computeBoundingSphere(),t},Ha.prototype=Object.create(Ua.prototype),Ha.prototype.constructor=Ha,Ha.prototype._build=function(){var t=this._opts;this.numVoxels=[128,128,128],this.xAxis=new l(1,0,0),this.yAxis=new l(0,1,0),this.zAxis=new l(0,0,1),this.origin=new l(0,0,0),this._visibilitySelector=t.visibilitySelector,this._calcSurface(t)},Ha.prototype._findMinMax=function(t){for(var e=t.length/4,r=[t[0],t[1],t[2],t[3]],n=[t[0],t[1],t[2],t[3]],i=1;i4&&(e.gridSpacing*=i[3]);var a=e.radScale*o[3]*1.7,s=a;s=.65*Math.sqrt(4/3*Math.PI*s*s*s),a=Math.max(a,s);for(var c=0;c<3;++c)i[c]-=a,o[c]+=a;for(c=0;c<3;++c)r[c]=Math.ceil((o[c]-i[c])/e.gridSpacing);return this.xAxis.x=(r[0]-1)*e.gridSpacing,this.yAxis.y=(r[1]-1)*e.gridSpacing,this.zAxis.z=(r[2]-1)*e.gridSpacing,this.origin.x=i[0],this.origin.y=i[1],this.origin.z=i[2],{bbox:n,dim:r}},Ha.prototype._makeSurface=function(t,e){var r=new Wa;r.compute(t.volMap,this.origin,e.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0&&(r.setColorVolTex(t.volTexMap,t.atomMap,t.atomWeightMap,this._visibilitySelector),this.setIndex(new mt(r._indices,1)),this.addAttribute("position",new mt(r._position,3)),this.addAttribute("normal",new mt(r._normals,3)),this.addAttribute("color",new mt(r._colors,3)))},Ha.prototype._calcSurface=function(t){var e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==e.posRad.length){var r=this._findNumVoxels(e.posRad,t),n=new et(this.origin,new l(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),i=this._computeSurface(e,n,r,t);this._makeSurface(i,t)}};var cm=xd.Volume;(Xa.prototype=Object.create(Ha.prototype)).constructor=Xa,Xa.prototype._computeSurface=function(t,e,r,n){this._shiftByOrigin(t.posRad);var i={volMap:new cm(Float32Array,this.numVoxels,e),volTexMap:new cm(Float32Array,this.numVoxels,e,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new cm(Float32Array,this.numVoxels,e)),this.gaussdensity(i,t,null,n),i},Xa.prototype.gaussdensity=function(t,e,r,n){var i,o=e.posRad.length/4,a=e.posRad,s=e.colors,c=this.numVoxels,l=n.radScale,u=n.gaussLim,h=n.gridSpacing,p=1/n.isoValue,f=1/h,d=c[0]-1,m=c[1]-1,g=c[2]-1,v=t.volMap,y=t.volTexMap,_=v.getData(),x=v.getStrideX(),b=y.getData(),w=y.getStrideX();null!=this._visibilitySelector&&(i=t.atomWeightMap.getData());for(var S=t.atomMap,M=0;M=L))for(var G=v.getDirectIdx(N,V,U),W=y.getDirectIdx(N,V,U),H=N*h-a[A],X=N;X<=I;++X,H+=h,G+=x,W+=w){var Y=-(H*H+j)*T,q=Math.exp(Y)*C;null!=this._visibilitySelector&&q>i[G]&&(i[G]=q,S[G]=e.atoms[M]),_[G]+=q,q*=p;var $=3*M;b[W]+=q*s[$],b[W+1]+=q*s[$+1],b[W+2]+=q*s[$+2]}}}},Xa.prototype._shiftByOrigin=function(t){for(var e=this.origin.x,r=this.origin.y,n=this.origin.z,i=t.length/4,o=0;ol?e:l,u+=e;var h=Math.floor(s/l);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=l;var p=h,f=h*h,d=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),g=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),v=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),y=0,_=m*h,x=g*h,b=v*h;for(c=0;c=0?C:0,T=T>=0?T:0,P=P>=0?P:0,L=L=0;s=this._atomsList[2*s+1])e(a[this._atomsList[2*s]])},Ka.prototype.getClosestAtom=function(t){var e=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(t,function(n){var i=t.distanceToSquared(n.coord);im)){var v=t.radius+i._probeRadius;(p=n-v*v)<0&&(p=-p),f=Math.exp(g*p),l+=e*f,u+=r*f,h+=d*f,o++}}),n=l*l+u*u+h*h,o>0&&(p=1/Math.sqrt(n),l*=p,u*=p,h*=p),r[v].x=l,r[v].y=u,r[v].z=h;return 0},Ka.prototype.buildColors=function(t,e,r,n){for(var i=this,o=0,a=0,s=0,c=0,l=0,u=n,h=u*u,p=[],f=[],d=0,m=0;mh)){var m=t.radius+i._probeRadius;(c=u-m*m)<0&&(c=-c),l=1/(.8+c),p.push([t.colorX,t.colorY,t.colorZ]),f.push(l),d+=l}});for(var g=0;g=0&&!(this.voxelsRefs[2*o+1]<0);)o=this.voxelsRefs[2*o+1];this.voxelsRefs[2*o+1]=r}}for(var x=0,b=0;b=0;)E+=(a=this.atoms[o]).coord.x,C+=a.coord.y,T+=a.coord.z,P++,o=this.voxelsRefs[2*o+1];for(E*=1/P,C*=1/P,T*=1/P,r=0;r<8;r++)p[r]=0;var L=0;for(o=this.voxels[i];o>=0;){var R=(a=this.atoms[o]).coord.x-E,N=a.coord.y-C,I=a.coord.z-T,O=Math.sqrt(R*R+N*N+I*I)+a.radius;O>L&&(L=O),h=e.getIndex(t,this.atoms[o]),p[h&=7]++,o=this.voxelsRefs[2*o+1]}var D=0;for(r=1;r<8;r++)p[r]>p[D]&&(D=r);var z=new Y(e.getAtomColor(t,this.atoms[D]));if(0===this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),1===this.colorMode){var k=this.complex.monomerTypeArray[h].color;c=k.r,l=k.g,u=k.b}1!==this.colorMode&&0!==this.colorMode&&(c=this.atomColors[D].x,l=this.atomColors[D].y,u=this.atomColors[D].z),z.set(E,C,T),s[x]=new Za(z,L),s[x].colorX=c,s[x].colorY=l,s[x].colorZ=u,x++}return this.voxelsRefs=null,this.voxels=null,s},Ja.prototype.destroy=function(){this._vertices=null,this._normals=null,this._indices=null};var um=xd.Element;(ts.prototype=Object.create(Ua.prototype)).constructor=ts,ts.prototype._build=function(){this._innerBuild();var t=this.getGeo();this.destroy(),this._fromGeo(t)},ts.prototype._fromGeo=function(t){var e=null,r=gf.allocateTyped(Float32Array,3*t._numVertices),n=gf.allocateTyped(Float32Array,3*t._numVertices);null!==t._colors&&(e=gf.allocateTyped(Float32Array,3*t._numVertices));var i,o=gf.allocateTyped(Uint32Array,3*t._numTriangles),a=0;for(i=0;ii?c:i,s.x-cr.x&&(r.x=s.x+c),s.y+c>r.y&&(r.y=s.y+c),s.z+c>r.z&&(r.z=s.z+c)}e.x-=i,e.y-=i,e.z-=i,r.x+=i,r.y+=i,r.z+=i},ts.prototype.getCornerCoord=function(t,e,r,n,i,o,a){var s=1/(o-1),c=r*s,l=n*s,u=i*s;a.x=t.x*(1-c)+e.x*c,a.y=t.y*(1-l)+e.y*l,a.z=t.z*(1-u)+e.z*u},ts.prototype.buildEdgePoint=function(t,e,r,n,i,o){if(r[t]^r[e]){var a=(0-n.pointsValuesLinear[i+24+t])/(n.pointsValuesLinear[i+24+e]-n.pointsValuesLinear[i+24+t]),s=n.pointsValuesLinear[i+3*t+0],c=n.pointsValuesLinear[i+3*t+1],l=n.pointsValuesLinear[i+3*t+2],u=n.pointsValuesLinear[i+3*e+0],h=n.pointsValuesLinear[i+3*e+1],p=n.pointsValuesLinear[i+3*e+2];o.x=s*(1-a)+u*a,o.y=c*(1-a)+h*a,o.z=l*(1-a)+p*a}},ts.prototype.isTriangleVisible=function(t,e,r){var n=this.voxelWorld.getClosestAtom(t),i=this.voxelWorld.getClosestAtom(e),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&(this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom))},ts.prototype.addTriangle=function(t,e,r){if(this.visibilitySelector&&!this.isTriangleVisible(t,e,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,t),o=this.addVertexToGeo(n,e),a=this.addVertexToGeo(n,r);if((i|o|a)<0)return!1;var s=3*n._numTriangles;return n._indices[s+0]=i,n._indices[s+1]=o,n._indices[s+2]=a,n._numTriangles++,!0},ts.prototype.buildGeoFromCorners=function(t,e,r,n,i,o){var a,s,c=t-1,u=t,h=t*t,p=new Array(12);for(a=0;a<12;a++)p[a]=new l;var f=[];for(a=0;a<8;a++)f[a]=1;for(var d=new l,m=0,g=0,v=0;ve.length/2||2*Object.keys(um.ByName).length!==e.length)throw new Error("atomT.length should be equal Element.ByName.length * 2");return e[2*t-1]},ts.prototype.calculateGridCorners=function(t,e,r,n,i,o){for(var a=e*e,s=a*e,c=new l,u=new l,h=0;h=0;r=this.hashEntries[2*r+1]){var u=this.hashEntries[2*r+0];if(i.copy(t._vertices[u]),i.x-=e.x,i.y-=e.y,i.z-=e.z,i.x*i.x+i.y*i.y+i.z*i.z<1e-6)return u}if(t._numVertices>=this.maxNumVertices)return-1;var h=t._numVertices;if(t._vertices[h].copy(e),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var p=this.hashLines[c+1];this.hashLines[c+1]=r,this.hashEntries[2*r+0]=h,this.hashEntries[2*r+1]=p,this.hashLines[c+0]++}return t._numVertices++,h},ts.prototype.modifyExcludedFromGeo=function(t,e,r,n,i,o){for(var a,s,c,l=t*t,u=(t-1)/(n.x-r.x),h=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),f=2*e*(2*e),d=1/(t-1),m=0;m=0?y:0,_=_>=0?_:0,x=x>=0?x:0,b=b<=t-1?b:t-1,w=w<=t-1?w:t-1,S=S<=t-1?S:t-1;for(var M=_;M<=w;M++)for(var A=M*l,E=x;E<=S;E++)for(var C=E*t,T=y;T<=b;T++){a=A+C+T;var P=T*d,L=r.x*(1-P)+n.x*P;P=M*d;var R=r.y*(1-P)+n.y*P;P=E*d;var N=r.z*(1-P)+n.z*P,I=L-g.x,O=R-g.y,D=N-g.z,z=I*I+O*O+D*D;z0?(o[a]<0&&(o[a]=c),c>o[a]&&(o[a]=c)):c>o[a]&&(o[a]=c))}}return 0},ts.prototype._innerBuild=function(){var t,e={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=e.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.clusterizationType=this._opts.clusterizationType,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var r=new Array(this.atoms.length);this.convertToAtomsColored(e,r);var n=this.vBoxMin=new l,i=this.vBoxMax=new l;this.getBoundingBox(r,n,i);var o=this.marCubeResoultion=4*this.meshResolution,a=o,s=a*a*a,c=gf.allocateTyped(Float32Array,s),u=this.meshResolution,h=4,p=this.atoms.length;p>=100&&(h=Math.floor(Math.pow(2*p,1/3))),u>h&&(u=h);var f=this.probeRadius*this.atomRadiusScale,d=null,m=null;this.clusterizationType>0?(d=new Qa(this.complex,this.atoms,r,n,i,u,this.colorMode),m=1===this.clusterizationType?d.buildKMeans():d.buildSimple(),n.x-=3.5,n.y-=3.5,n.z-=3.5,i.x+=3.5,i.y+=3.5,i.z+=3.5,this.calculateGridCorners(c,a,n,i,m,f)):this.calculateGridCorners(c,a,n,i,r,f);var g=o-1,v=new Ba;if((t=v.create(g))<0)return t;var y=new l;y.x=(i.x-n.x)/g,y.y=(i.y-n.y)/g,y.z=(i.z-n.z)/g;var _=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2);if(this.geoOut=new Ja(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;var w=f;if(this.excludeProbe&&(w=.01),this.voxelWorld=null,this.clusterizationType>0?this.voxelWorld=new Ka(m.length,m,n,i,w):this.voxelWorld=new Ka(r.length,r,n,i,w),this.voxelWorld.createVoxels(),t=this.buildGeoFromCorners(o,n,i,c,y,v),this.excludeProbe){if(this.modifyExcludedFromGeo(a,f,n,i,this.geoOut,c),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,_=this.getNumIntersectedCells(a,g,c,v),x=Math.floor(1.2*_),b=Math.floor(1.2*_*2),this.geoOut=new Ja(x,b,this.useVertexColors),(t=this.createVertexHash(x,b))<0)return t;t=this.buildGeoFromCorners(a,n,i,c,y,v)}if(null!==this.voxelWorld){this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var S=6.5;this.excludeProbe&&(S-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,S)}return this.voxelWorld.destroyVoxels(),this.voxelWorld=null,null!==d&&d.destroy(),v.destroy(),t},(rs.prototype=Object.create(Si.prototype)).constructor=rs,rs.prototype.setItem=function(t,e,r){var n=this._opts,i=n.labels,o=this.items[t]||es(r,"label label-"+i);o.worldPos.copy(e),o.style.textAlign=n.horizontalAlign,o.style.verticalAlign=n.verticalAlign,this.items[t]=o},rs.prototype.setColor=function(t,e,r){this.items[t].opts={color:e,background:r}},rs.prototype.startUpdate=function(){return!0},rs.prototype.finishUpdate=function(){this.needsUpdate=!0,this.dispatchEvent({type:"update"})},rs.prototype.finalize=function(){this.finishUpdate()},rs.prototype.raycast=function(){},rs.prototype.setOpacity=function(){},rs.prototype.getSubset=function(){return[]};var hm={InstancedSpheresGeometry:ga,SimpleSpheresGeometry:_a,Simple2CCylindersGeometry:xa,Instanced2CCylinderGeometry:Ca,ExtrudedObjectsGeometry:Pa,ChunkedLinesGeometry:za,TwoColorLinesGeometry:ka,CrossGeometry:Fa,QuickSurfGeometry:Xa,ContactSurfaceGeometry:$a,SSIsosurfaceGeometry:ts,LabelsGeometry:rs},pm=function(t){function e(){t.apply(this,arguments),this.onBeforeRender=e.prototype.onBeforeRender}return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.prototype.onBeforeRender=function(t,e,r,n,i,o){this._onBeforeRender(t,e,r,n,i,o),this._update()},e.prototype._onBeforeRender=function(){},e.prototype._update=function(){var t=this.material;t&&t instanceof oa&&t.updateUniforms()},e},fm=pm(Lt);(ns.prototype=Object.create(fm.prototype)).constructor=ns,ns.prototype._onBeforeRender=function(){var t=this.material;t&&t.uniforms.invModelViewMatrix&&t.uniforms.invModelViewMatrix.value.getInverse(this.modelViewMatrix)};var dm=pm(Lt);(is.prototype=Object.create(dm.prototype)).constructor=is,is.prototype._onBeforeRender=function(t,e,r){var n=this.geometry,i=this.material;if(n.zClip&&i.uberOptions){var o=(new u).multiplyMatrices(this.matrixWorld,r.matrixWorldInverse),a=(new l).setFromMatrixColumn(o,0).length(),s=(new l).copy(n.boundingSphere.center);this.localToWorld(s),i.uberOptions.zClipValue=r.position.z-s.z-a*(.5*n.boundingSphere.radius)}},(os.prototype=Object.create(Ae.prototype)).constructor=os,os.prototype.init=function(){for(var t=this.children,e=t.length-1;e>=0;--e)this.remove(t[e]);var r=this.geometry.items,n=this.geometry.userData,i=r.length;for(e=0;e>16&255,r=t>>8&255,n=255&t;return.2126*e+.7152*r+.0722*n>127?(e=3*e/10,r=3*r/10,n=3*n/10):(e=255-3*(255-e)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),e<<16|r<<8|n},inverse:function(t){return 255-(t>>16&255)<<16|255-(t>>8&255)<<8|255-(255&t)}},ym={serial:function(t){return t.getSerial()},name:function(t){return t.getVisualName()},elem:function(t){return t.element.name},residue:function(t){return t._residue.getType().getName()},sequence:function(t){return t._residue.getSequence()},chain:function(t){return t._residue.getChain().getName()},hetatm:function(t){return t.isHet()},water:function(t){return"HOH"===t._residue.getType().getName()||"WAT"===t._residue.getType().getName()}},_m=function(t,e){return e.replace(/\{\{(\s*\w+\s*)\}\}/g,function(e){var r=e.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),ym.hasOwnProperty(r)?ym[r](t):"null"})};(ws.prototype=Object.create(gs.prototype)).constructor=ws,ws.prototype._makeGeoArgs=function(t,e,r,n){var i=e.getLabelOpts();return[t.chunks.length,i]},ws.prototype._build=function(){for(var t=this._mode.getLabelOpts(),e=this._selection.chunks,r=this._selection.atoms,n=this._selection.parent,i=this._colorer,o=this._geo,a=0,s=e.length;ae-1&&(t=r-t),t},t=function(){function t(t,e){if(this.array=t.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[e.clip]))throw"Invalid clip: "+e.clip}return t.prototype.getClippedInput=function(t){return 0<=t&&t=o;i<=o?r++:r--)n+=this.kernel(t-r)*this.getClippedInput(r);return n},r}(),f=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?l++:l--)r.push(new h(f(t,l),e));return r}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;r1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),o.setColor(p++,i.getAtomColor(v,r),i.getAtomColor(y,r))}}o.finalize(),this._chunksIdc=f},Gs.prototype.updateToFrame=function(t){for(var e=this._selection.chunks,r=this._selection.bonds,n=this._mode,i=this._colorer,o=this._geo,a=n.drawMultiorderBonds(),s=n.showAromaticLoops(),c=new l,u=new l,h=new l,p=0,f=t.needsColorUpdate(i),d=0,m=e.length;d1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),f&&o.setColor(p,t.getAtomColor(i,v),t.getAtomColor(i,y)),p++}}o.finalize()};var wm={AtomsSphereGroup:vs,AtomsSurfaceGroup:ys,AtomsSASSESGroup_stub:_s,AtomsTextGroup:ws,AromaticTorusGroup:Es,AromaticLinesGroup:Cs,NucleicCylindersGroup:Ls,NucleicSpheresGroup:Rs,ResiduesSubseqGroup:ks,ResiduesTraceGroup:Us,BondsCylinderGroup:js,BondsLinesGroup:Gs};Ws.prototype=Object.create(ia.prototype),Ws.prototype.constructor=Ws,Ws.prototype._checkAtom=function(t,e){return t._mask&e},Ws.prototype.getSubset=function(t,e){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&s.add(p)}return s},rc.prototype=Object.create(ec.prototype),rc.prototype.constructor=rc,rc.prototype.update=function(){var t=this._staticGroups;"no"===this.settings.now.labels?this.depGroups=this.depGroups.slice(0,t):(this.depGroups[t]="TextLabelsGeo",this.depGroups[t+1]="SGroupsLabels")},rc.prototype.buildGeometry=function(t,e,r,n){return this.update(),ec.prototype.buildGeometry.call(this,t,e,r,n)},gf.deriveClass(ic,rc,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),ic.prototype.drawMultiorderBonds=function(){return this.opts.multibond},ic.prototype.calcAtomRadius=function(){return this.opts.atom},ic.prototype.getAromaticOffset=function(){return this.opts.offsarom},ic.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},ic.prototype.showAromaticLoops=function(){return this.opts.showarom},ic.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gf.deriveClass(oc,rc,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),oc.prototype.calcAtomRadius=function(t){return this.opts.bond},oc.prototype.calcStickRadius=function(){return this.opts.bond},oc.prototype.calcSpaceFraction=function(){return this.opts.space},oc.prototype.getAromRadius=function(){return this.opts.aromrad},oc.prototype.showAromaticLoops=function(){return this.opts.showarom},oc.prototype.drawMultiorderBonds=function(){return this.opts.multibond},oc.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gf.deriveClass(ac,rc,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),ac.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},ac.prototype.calcStickRadius=function(){return this.opts.bond},ac.prototype.getAromRadius=function(){return this.opts.aromrad},ac.prototype.showAromaticLoops=function(){return this.opts.showarom},ac.prototype.calcSpaceFraction=function(){return this.opts.space},ac.prototype.drawMultiorderBonds=function(){return this.opts.multibond},ac.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gf.deriveClass(sc,ec,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),sc.prototype.calcAtomRadius=function(t){return t.element.radius},gf.deriveClass(cc,ec,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),cc.prototype.calcStickRadius=function(){return this.opts.radius},gf.deriveClass(lc,ec,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),lc.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},lc.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},lc.prototype.getTension=function(){return this.opts.tension},lc.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius;return this.TUBE_RADIUS=new n(o,o),ec.prototype.buildGeometry.call(this,t,e,r,i)},gf.deriveClass(uc,ec,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),uc.prototype.getResidueStartRadius=function(t){var e=t.getSecondary();if(!e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?r.start:r.center:this.TUBE_RADIUS},uc.prototype.getResidueEndRadius=function(t){var e=t.getSecondary();if(null===e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?this.ARROW_END:r.center:this.TUBE_RADIUS},uc.prototype.getResidueRadius=function(t,e){var r=this.getResidueStartRadius(t);if(0===e)return r;var n=this.getResidueEndRadius(t);return 2===e?n:r.clone().lerp(n,e/2)},uc.prototype.calcStickRadius=function(t){return this.opts.radius},uc.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},uc.prototype.getTension=function(){return this.opts.tension},uc.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius,a=this.opts.depth;this.TUBE_RADIUS=new n(o,o),this.ARROW_END=new n(a,o);var s={},c=this.opts.ss;for(var l in c)s[l]={center:new n(a,c[l].width),start:new n(a,c[l].arrow)};return this.secCache=s,ec.prototype.buildGeometry.call(this,t,e,r,i)};var Mm=xd.selectors;gf.deriveClass(pc,ec,{isSurface:!0,surfaceNames:[]}),pc.prototype.calcAtomRadius=function(t){return t.element.radius},pc.prototype.getVisibilitySelector=function(){var t=null;if(""!==this.opts.subset){var e=Mm.parse(this.opts.subset);e.error||(t=e.selector)}return t},gf.deriveClass(fc,pc,{id:"QS",name:"Quick Surface",shortName:"Quick Surf",surfaceNames:["QuickSurfGeo"]}),fc.prototype.getSurfaceOpts=function(){return{useBeads:!1,isoValue:this.opts.isoValue,gaussLim:this.opts.gaussLim[this.settings.now.resolution],radScale:this.opts.scale,gridSpacing:this.opts.gridSpacing[this.settings.now.resolution],zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},gf.deriveClass(dc,pc,{id:"SU",name:"Surface",shortName:"Surface",surfaceNames:["SASSESSurfaceGeo"]}),dc.prototype._radScale=1,dc.prototype._isVertexNormalsRendered=!1,dc.prototype._isSurfaceTransparent=!1,dc.prototype._clusterViaKMeans=0,dc.prototype._excludeProbe=!1,dc.prototype.calcAtomRadius=function(t){return t.element.radius},dc.prototype.getSurfaceOpts=function(){return{gridSpacing:this.opts.polyComplexity[this.settings.now.resolution],radScale:this._radScale,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector(),probeRadius:this.opts.probeRadius,excludeProbe:this._excludeProbe,clusterizationType:this._clusterViaKMeans}},gf.deriveClass(mc,dc,{id:"SA",name:"Solvent Accessible Surface",shortName:"SAS"}),gf.deriveClass(gc,dc,{id:"SE",name:"Solvent Excluded Surface",shortName:"SES"}),gf.deriveClass(vc,pc,{id:"CS",name:"Contact Surface",shortName:"Contact Surf",isSurface:!0,surfaceNames:["ContactSurfaceGeo"]}),vc.prototype.getSurfaceOpts=function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},gf.deriveClass(yc,ec,{id:"TX",name:"Text mode",shortName:"Text",depGroups:["TextLabelsGeo"]}),yc.prototype.getTemplateOptions=function(){return this.opts.template},yc.prototype.getLabelOpts=function(){return _.merge(this.opts,{labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0})};var Am=[],Em={};!function(t){for(var e=0,r=t.length;e=256?e-256:e))%this.chainColors.length,this.chainColors[e]},getSecondaryColor:function(t,e){var r=this.secondaryColors[t];return r instanceof Object&&(r=r[e]),void 0===r?this.defaultSecondaryColor:r},getSequentialColor:function(t){var e=this.colors,r=e.length;return t<0?e[t%r+r]:e[t%r]},getGradientColor:function(t,e){var r=this.gradients[e];if(r){var n=r.length,i=t*(n-1),o=Math.floor(i),a=_c(o+1,0,n-1);return o=_c(o,0,n-1),xc(r[o],r[a],i-o)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}}).namedColorsArray,Pm=bc.prototype.namedColors,Lm=0,Rm=Tm.length;Lm=0?this.opts.carbon:this.palette.getElementColor(r)},Sc.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},gf.deriveClass(Mc,wc,{id:"RT",name:"Residue Type",shortName:"Residue"}),Mc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Mc.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},gf.deriveClass(Ac,wc,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Ac.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ac.prototype.getResidueColor=function(t,e){var r=t._chain,n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},gf.deriveClass(Ec,wc,{id:"CH",name:"Chain",shortName:"Chain"}),Ec.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ec.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},gf.deriveClass(Cc,wc,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),Cc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Cc.prototype.getResidueColor=function(t,e){if(t._type.flags&so.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&so.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},gf.deriveClass(Tc,wc,{id:"UN",name:"Uniform",shortName:"Uniform"}),Tc.prototype.getAtomColor=function(t,e){return this.opts.color},Tc.prototype.getResidueColor=function(t,e){return this.opts.color},gf.deriveClass(Pc,wc,{id:"CO",name:"Conditional",shortName:"Conditional"}),Pc.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},Pc.prototype.getResidueColor=function(t,e){for(var r=this._subsetCached,n=!0,i=t._atoms,o=0,a=i.length;o0){var i=(n-r.min)/(r.max-r.min);return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},gf.deriveClass(Nc,wc,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),Nc.prototype.getAtomColor=function(t,e){var r=this.opts;if(t._occupancy&&r){var n=1-t._occupancy;return this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultElementColor},Nc.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._occupancy&&t._role===xd.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},gf.deriveClass(Ic,wc,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),Ic.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ic.prototype.getResidueColor=function(t,e){var r=this.palette.defaultResidueColor;if(t._type.hydrophobicity){r=this.palette.getGradientColor((t._type.hydrophobicity- -4.5)/9,this.opts.gradient)}return r},gf.deriveClass(Oc,wc,{id:"MO",name:"Molecule",shortName:"Molecule"}),Oc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Oc.prototype.getResidueColor=function(t,e){var r=t._molecule,n=e.getMoleculeCount();return n>1?this.palette.getGradientColor((r._index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)};var jm=[],Gm={};!function(t){for(var e=0,r=t.length;e0){(e=new Ae).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return ff.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<0?this._reprList[0]:null,this._selectionBit=t.length,this._reprUsedBits|=1<=0&&tthis._reprList.length)return ff.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,ff.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],n={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var i=!1;if(e.selector){var o=Km.parse(e.selector).selector,a=String(o);n.selector!==a&&(r.selectorString=n.selector=a,r.selector=o,r.markAtoms(this._complex),i=!0,ff.debug("rep["+t+"].selector changed to"+a))}if(e.mode){var s=e.mode;wu.isEqual(n.mode,s)||(n.mode=s,r.setMode(Cm.create(e.mode)),i=!0,ff.debug("rep["+t+"].mode changed to "+s),!r.mode.isSurface||"ultra"!==_f.now.resolution&&"high"!==_f.now.resolution||(ff.report('Surface resolution was changed to "medium" to avoid hang-ups.'),_f.now.resolution="medium"))}if(e.colorer){var c=e.colorer;wu.isEqual(n.colorer,c)||(n.colorer=c,r.colorer=Wm.create(e.colorer),i=!0,ff.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var l=e.material;wu.isEqual(n.material,l)||(n.material=l,r.setMaterialPreset($m.get(e.material)),i=!0,ff.debug("rep["+t+"].material changed to"+l))}i&&(r.needsRebuild=!0)}return n},Vc.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},Vc.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<32;++e,t>>=1)if(0==(1&t))return e;return-1},Vc.prototype.repAdd=function(t){if(this._reprList.length>=this.getMaxRepresentationCount())return-1;var e=this._getFreeReprIdx();if(e<0)return-1;var r=this.buildSelectorFromMask(1<=e||e<=1)){var r=this._reprList[t];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length||this._reprList[t].show(!e)},Vc.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=Km.chain(r),o=o?Km.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=Km.and(Km.chain(s),Km.residx(n(e[s]))),o=o?Km.or(o,a):a);t.length>0&&(a=Km.serial(n(t)),o=o?Km.or(o,a):a),o||(o=Km.none())}return o},Vc.prototype.buildSelectorFromMask=function(t){var e=this._complex,r=[],n={},i=[];return e.forEachChain(function(e){e._mask&t&&r.push(e._name)}),e.forEachResidue(function(e){if(e._mask&t&&!(e._chain._mask&t)){var r=e._chain._name;r in n?n[r].push(e._index):n[r]=[e._index]}}),e.forEachAtom(function(e){e._mask&t&&!(e._residue._mask&t)&&i.push(e._serial)}),this._buildSelectorFromSortedLists(i,n,r)},Vc.prototype.getSelectedComponent=function(){var t=1<=0):n<8+d.indices.length&&(this.cullFlag[n]=!0);var v=this.geometry.getAttribute("position"),y=0;for(n=0;n=3&&(h+=3*(r.indices.length-2));var p=0,f=new Uint16Array(h);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),c>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)}requestAnimationFrame(s)})},Xc.prototype.mean=function(){return this._prof?this._prof.rawMean():0},Xc.prototype.min=function(){return this._prof?this._prof.min():0},Yc.prototype.abort=function(){this._agent.abort()},ha(Yc.prototype),Yc.addCommonHandlers=function(t,e){e.error&&(t.addEventListener("error",function(){e.error("OnError() event fired while loading")}),t.addEventListener("abort",function(){e.error("OnAbort() event fired while loading")})),e.progress&&t.addEventListener("progress",function(t){t.lengthComputable?e.progress(t.loaded/t.total):e.progress()})},(qc.prototype=Object.create(Yc.prototype)).constructor=qc,qc.prototype.load=function(t){var e=new FileReader;this._agent=e,t.ready&&e.addEventListener("load",function(e){t.ready(e.target.result)}),Yc.addCommonHandlers(e,t),this._binary?e.readAsArrayBuffer(this._source):e.readAsText(this._source)},qc.canLoad=function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)},($c.prototype=Object.create(Yc.prototype)).constructor=$c,$c.prototype.load=function(t){var e=this._source,r=new XMLHttpRequest;this._agent=r,t.ready&&r.addEventListener("load",function(){200===r.status?t.ready(r.response):t.error&&t.error("HTTP "+r.status+" while fetching "+e)}),Yc.addCommonHandlers(r,t),r.open("GET",e),this._binary?r.responseType="arraybuffer":r.responseType="text",r.send()},$c.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)},(Zc.prototype=Object.create(Yc.prototype)).constructor=Zc,Zc.prototype.load=function(t){t.progress&&t.progress(0),this._options.data&&null!==this._options.data&&""!==this._options.data||t.error&&t.error("No data found!"),t.progress&&t.progress(.5),this._options.dataType&&null!==this._options.dataType&&""!==this._options.dataType||t.error&&t.error("No dataType found!"),t.progress&&t.progress(1),t.ready&&t.ready(this._options.data)},Zc.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(3===t.indexOf(":",0)||"message"===r)};var eg=[];!function(t){for(var e=0,r=t.length;e0&&e.addChain(h)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new ng(this._complex),this.assemblies.push(e))};var ig="\n".length,og=function(){function t(e){bf(this,t),this._data=e,this._start=0,this._next=-ig,this._end=e.length,this.next()}return wf(t,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(t){return(t=this._start+t-1)=this._end}},{key:"next",value:function(){var t=this._next+ig;this._start=t0?e:this._end}}]),t}(),ag=xd.Complex,sg=xd.Element,cg=xd.Helix,lg=xd.Sheet,ug=xd.Strand,hg=xd.Bond,pg=xd.Molecule;(el.prototype=Object.create(Kc.prototype)).constructor=el,el.canParse=function(t,e){return!!t&&("string"==typeof t&&(Kc.checkDataTypeOptions(e,"pdb")||Kc.checkDataTypeOptions(e,"pdb",".ent")))},el.prototype._finalize=function(){this._fixBondsArray(),this._fixChains();var t=this._remarks[290];this._complex.symmetry=wu.isUndefined(t)?[]:t.matrices;var e=this._remarks[350];this._complex.structures=this._complex.structures.concat(wu.isUndefined(e)?[]:e.assemblies),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})},el.prototype._finalizeMolecules=function(){var t,e={},r=this._complex._chains;for(t=0;te&&a.addBond(e,r,0,hg.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,hg.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,hg.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,hg.BondType.UNKNOWN,!0)},el.prototype._parseCOMPND=function(t){var e=t.readString(11,80),r=e.indexOf(":");if(this._compndCurrToken=r>0?e.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(e.substring(r+1,e.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=e.substring(r+1,e.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=e.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}};var fg={290:Qc,350:Jc};el.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(wu.isUndefined(r)){var n=fg[e];wu.isFunction(n)&&(this._remarks[e]=r=new n(this._complex))}wu.isUndefined(r)||r.parse(t)},el.prototype._parseHELIX=function(t){var e=[20,22,32,34];this._parseSTRUCTURE(t,e,function(t){this._complex.addHelix(t)}.bind(this))},el.prototype._parseSHEET=function(t){var e=[22,23,33,34];this._parseSTRUCTURE(t,e,function(t){this._complex.addSheet(t)}.bind(this))},el.prototype._parseSTRUCTURE=function(t,e,r){var n=t.readInt(8,10),i=t.readString(12,14).trim(),o=t.readString(41,70).trim(),a=t.readInt(72,76),s=t.readInt(39,40),c=t.readInt(15,16),l=t.readInt(42,45),u=t.readInt(57,60),h=t.readString(e[0],e[2]+1).charCodeAt(0),p=t.readString(e[2],e[2]+1).charCodeAt(0),f=t.readInt(e[1],e[1]+3),d=t.readString(e[1]+4,e[1]+4),m=0;d.length>0&&(m=d.charCodeAt(0));var g=t.readInt(e[3],e[3]+3),v=0;(d=t.readString(e[3]+4,e[3]+4)).length>0&&(v=d.charCodeAt(0));var y,_=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=y=new lg(i,c),r(y)):y=_;var x=new ug(y,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,l,u);y.addStrand(x)}else r(y=new cg(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,o,a))},el.prototype._parseHEADER=function(t){var e=this._complex.metadata;e.classification=t.readString(11,50).trim(),e.date=t.readString(51,59).trim();var r=t.readString(63,66).trim();e.id=r,r&&(this._complex.name=r)},el.prototype._parseTITLE=function(t){var e=this._complex.metadata;e.title=e.title||[];var r=t.readInt(9,10)||1;e.title[r-1]=t.readString(11,80).trim()};var dg={HEADER:el.prototype._parseHEADER,"TITLE ":el.prototype._parseTITLE,"ATOM ":el.prototype._parseATOM,HETATM:el.prototype._parseATOM,ENDMDL:el.prototype._parseENDMDL,CONECT:el.prototype._parseCONECT,COMPND:el.prototype._parseCOMPND,REMARK:el.prototype._parseREMARK,"HELIX ":el.prototype._parseHELIX,"SHEET ":el.prototype._parseSHEET,"ATOM 1":el.prototype._parseATOM,"ATOM 2":el.prototype._parseATOM,"ATOM 3":el.prototype._parseATOM,"ATOM 4":el.prototype._parseATOM,"ATOM 5":el.prototype._parseATOM,"ATOM 6":el.prototype._parseATOM,"ATOM 7":el.prototype._parseATOM,"ATOM 8":el.prototype._parseATOM,"ATOM 9":el.prototype._parseATOM};el.prototype._parse=function(t){for(var e=new og(this._data),r=this._complex=new ag;!e.end();){var n=e.readString(1,6),i=dg[n];wu.isFunction(i)&&i.call(this,e),e.next()}this.hasOwnProperty("_abort")?t.error(new Error("Aborted")):(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0!==r.getAtomCount()?this.hasOwnProperty("_abort")?t.error(new Error("Aborted")):t.ready(r):t.error(new Error("Loaded file does not contain valid atoms.
Loading as empty...")))};var mg=xd.Complex;(rl.prototype=Object.create(Kc.prototype)).constructor=rl,rl.prototype.parse=function(t){var e=this._complex=new mg;this._complex=null,t.ready(e)},rl.canParse=function(t,e){return!!t&&("string"==typeof t&&Kc.checkDataTypeOptions(e,"mol"))};var gg=xd.Complex,vg=xd.Element,yg=xd.AtomName,_g=xd.SGroup,xg=xd.Bond,bg={A:0,S:1,D:2,T:3};(nl.prototype=Object.create(Kc.prototype)).constructor=nl,nl.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\1)c[a].order=h;else{var p=bg[u];void 0!==p&&(c[a].order=p,"A"===u&&(c[a].type=xg.BondType.AROMATIC))}}for(s=e.length,a=0;a1&&s.splice(1,s.length-1),s.forEach(function(t){var r=e(t);r.atoms.length>0&&a.push(r)}),a},nl.prototype._packLabel=function(t,e){return(e<<16)+t},nl.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},nl.prototype._breadWidthSearch=function(t,e){var r,n=new Array(t.length);for(r=0;r0;){o++;var s=-1;for(r=0;r0;){var c=i.shift();if(c)for(var l=0;l=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},nl.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n Loading as empty..."));else if(this.hasOwnProperty("_abort"))t.error(new Error("Aborted"));else{if(e.length>1){var i=new gg;i.joinComplexes(e),i.originalCML=e[0].originalCML,t.ready(i)}1===e.length&&t.ready(e[0]),0===e.length&&t.ready(new gg)}};var wg=e(function(t,e){!function(t,r){r(e)}(0,function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t,i,o){var a=typeof t;if("string"===a){if(32>(s=r(t)))return i.setUint8(o,160|s),e(i,o+1,t),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,t),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,t),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,t),5+s}if(t instanceof Uint8Array){var s=t.byteLength,c=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),c.set(t,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),c.set(t,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),c.set(t,o+5),5+s}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return i.setUint8(o,203),i.setFloat64(o+1,t),9;if(t>=0){if(128>t)return i.setUint8(o,t),1;if(256>t)return i.setUint8(o,204),i.setUint8(o+1,t),2;if(65536>t)return i.setUint8(o,205),i.setUint16(o+1,t),3;if(4294967296>t)return i.setUint8(o,206),i.setUint32(o+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return i.setInt8(o,t),1;if(t>=-128)return i.setUint8(o,208),i.setInt8(o+1,t),2;if(t>=-32768)return i.setUint8(o,209),i.setInt16(o+1,t),3;if(t>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,t?195:194),1;if("object"===a){var l=0,u=Array.isArray(t);if(u)s=t.length;else{var h=Object.keys(t);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),l=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),l=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),l=5),u)for(p=0;s>p;p++)l+=n(t[p],i,o+l);else for(var p=0;s>p;p++){var f=h[p];l+=n(f,i,o+l),l+=n(t[f],i,o+l)}return l}throw new Error("Unknown type "+a)}function i(t){var e=typeof t;if("string"===e){if(32>(n=r(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var n,o=0;if(Array.isArray(t)){n=t.length;for(s=0;n>s;s++)o+=i(t[s])}else{var a=Object.keys(t);n=a.length;for(var s=0;n>s;s++){var c=a[s];o+=i(c)+i(t[c])}}if(16>n)return 1+o;if(65536>n)return 3+o;if(4294967296>n)return 5+o;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+e)}function o(t){var e=new ArrayBuffer(i(t));return n(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function s(t){return a(DataView,t)}function c(t){return a(Uint8Array,t)}function l(t){return a(Int8Array,t)}function u(t){return a(Int32Array,t,4)}function h(t){return a(Float32Array,t,4)}function p(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)e[n]=t[i]<<8^t[i+1]<<0;return e}function f(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=s(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return c(e)}function d(t,e){var r=t.length/4;e||(e=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)e[n]=t[i]<<24^t[i+1]<<16^t[i+2]<<8^t[i+3]<<0;return e}function m(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=s(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return c(e)}function g(t,e){var r=t.length;e||(e=new Float32Array(r/4));for(var n=s(e),i=s(t),o=0,a=0,c=r/4;c>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return e}function v(t,e,r){var n=t.length,i=1/e;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=t[o]*i;return r}function y(t,e,r){var n=t.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(t[i]*e);return r}function _(t,e){var r,n;if(!e){var i=0;for(r=0,n=t.length;n>r;r+=2)i+=t[r+1];e=new t.constructor(i)}var o=0;for(r=0,n=t.length;n>r;r+=2)for(var a=t[r],s=t[r+1],c=0;s>c;++c)e[o]=a,++o;return e}function x(t){if(0===t.length)return new Int32Array;var e,r,n=2;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]?(i[o]=t[e-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=t[t.length-1],i[o+1]=a,i}function b(t,e){var r=t.length;e||(e=new t.constructor(r)),r&&(e[0]=t[0]);for(var n=1;r>n;++n)e[n]=t[n]+e[n-1];return e}function w(t,e){var r=t.length;e||(e=new t.constructor(r)),e[0]=t[0];for(var n=1;r>n;++n)e[n]=t[n]-t[n-1];return e}function S(t,e){var r,n,i=t instanceof Int8Array?127:32767,o=-i-1,a=t.length;if(!e){var s=0;for(r=0;a>r;++r)t[r]o&&++s;e=new Int32Array(s)}for(r=0,n=0;a>r;){for(var c=0;t[r]===i||t[r]===o;)c+=t[r],++r;c+=t[r],++r,e[n]=c,++n}return e}function M(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r)0===(l=t[r])?++a:a+=l===n||l===i?2:l>0?Math.ceil(l/n):Math.ceil(l/i);var s=e?new Int8Array(a):new Int16Array(a),c=0;for(r=0;o>r;++r){var l=t[r];if(l>=0)for(;l>=n;)s[c]=n,++c,l-=n;else for(;i>=l;)s[c]=i,++c,l-=i;s[c]=l,++c}return s}function A(t,e){return b(_(t),e)}function E(t){return x(w(t))}function C(t,e,r){return v(_(t,u(r)),e,r)}function T(t,e){return x(y(t,e))}function P(t,e,r){return v(b(t,u(r)),e,r)}function L(t,e,r){return w(y(t,e),r)}function R(t,e,r){return v(S(t,u(r)),e,r)}function N(t,e,r){var n=S(t,u(r));return P(n,e,h(n))}function I(t,e,r){return M(L(t,e),r)}function O(t){var e=s(t),r=e.getInt32(0),n=e.getInt32(4),i=t.subarray(8,12);return[r,t=t.subarray(12),n,i]}function D(t,e,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,t),a.setInt32(4,e),r&&o.set(r,8),o.set(n,12),o}function z(t){return D(2,t.length,void 0,c(t))}function F(t){return D(4,t.length,void 0,m(t))}function k(t,e){return D(5,t.length/e,m([e]),c(t))}function U(t){return D(6,t.length,void 0,m(x(t)))}function B(t){return D(8,t.length,void 0,m(E(t)))}function V(t,e){return D(9,t.length,m([e]),m(T(t,e)))}function j(t,e){return D(10,t.length,m([e]),f(I(t,e)))}function G(t){var e={};return Z.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=F(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=z(t.bondOrderList)),e.xCoordList=j(t.xCoordList,1e3),e.yCoordList=j(t.yCoordList,1e3),e.zCoordList=j(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=j(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=B(t.atomIdList)),t.altLocList&&(e.altLocList=U(t.altLocList)),t.occupancyList&&(e.occupancyList=V(t.occupancyList,100)),e.groupIdList=B(t.groupIdList),e.groupTypeList=F(t.groupTypeList),t.secStructList&&(e.secStructList=z(t.secStructList,1)),t.insCodeList&&(e.insCodeList=U(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=B(t.sequenceIndexList)),e.chainIdList=k(t.chainIdList,4),t.chainNameList&&(e.chainNameList=k(t.chainNameList,4)),e}function W(t){function e(t){for(var e={},r=0;t>r;r++)e[o()]=o();return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;var n=65535;if(e>n){for(var i=[],o=0;or;r++)e[r]=o();return e}function o(){var o,c,l=t[a];if(0==(128&l))return a++,l;if(128==(240&l))return c=15&l,a++,e(c);if(144==(240&l))return c=15&l,a++,i(c);if(160==(224&l))return c=31&l,a++,n(c);if(224==(224&l))return o=s.getInt8(a),a++,o;switch(l){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,r(c);case 197:return c=s.getUint16(a+1),a+=3,r(c);case 198:return c=s.getUint32(a+1),a+=5,r(c);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return c=s.getUint8(a+1),a+=2,n(c);case 218:return c=s.getUint16(a+1),a+=3,n(c);case 219:return c=s.getUint32(a+1),a+=5,n(c);case 220:return c=s.getUint16(a+1),a+=3,i(c);case 221:return c=s.getUint32(a+1),a+=5,i(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+l.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function H(t,e,r,n){switch(t){case 1:return g(e);case 2:return l(e);case 3:return p(e);case 4:return d(e);case 5:return c(e);case 6:return _(d(e),new Uint8Array(r));case 7:return _(d(e));case 8:return A(d(e));case 9:return C(d(e),d(n)[0]);case 10:return N(p(e),d(n)[0]);case 11:return v(p(e),d(n)[0]);case 12:return R(p(e),d(n)[0]);case 13:return R(l(e),d(n)[0]);case 14:return S(p(e));case 15:return S(l(e))}}function X(t,e){var r=(e=e||{}).ignoreFields,n={};return Q.forEach(function(e){var i=!!r&&-1!==r.indexOf(e),o=t[e];i||void 0===o||(o instanceof Uint8Array?n[e]=H.apply(null,O(o)):n[e]=o)}),n}function Y(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function q(t,e){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r;return r=t instanceof Uint8Array?W(t):t,X(r,e)}function $(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=q(i.response);r(t)}catch(t){n(t)}},!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",e+t.toUpperCase()),i.send()}var Z=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],K=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],Q=Z.concat(K),J="//mmtf.rcsb.org/v1.0/",tt=J+"full/",et=J+"reduced/";t.encode=function(t){return o(G(t))},t.decode=q,t.traverse=function(t,e,r){var n,i,o,a,s,c,l=(r=r||{}).firstModelOnly,u=e.onModel,h=e.onChain,p=e.onGroup,f=e.onAtom,d=e.onBond,m=0,g=0,v=0,y=0,_=0,x=-1,b=t.chainNameList,w=t.secStructList,S=t.insCodeList,M=t.sequenceIndexList,A=t.atomIdList,E=t.bFactorList,C=t.altLocList,T=t.occupancyList,P=t.bondAtomList,L=t.bondOrderList;for(n=0,i=t.chainsPerModel.length;i>n&&!(l&&m>0);++n){var R=t.chainsPerModel[m];for(u&&u({chainCount:R,modelIndex:m}),o=0;R>o;++o){var N=t.groupsPerChain[g];if(h){var I=Y(t.chainIdList.subarray(4*g,4*g+4)),O=null;b&&(O=Y(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var D=t.groupList[t.groupTypeList[v]],z=D.atomNameList.length;if(p){var F=null;w&&(F=w[v]);var k=null;t.insCodeList&&(k=String.fromCharCode(S[v]));var U=null;M&&(U=M[v]),p({atomCount:z,groupIndex:v,chainIndex:g,modelIndex:m,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:D.groupName,singleLetterCode:D.singleLetterCode,chemCompType:D.chemCompType,secStruct:F,insCode:k,sequenceIndex:U})}for(s=0;z>s;++s){if(f){var B=null;A&&(B=A[y]);var V=null;E&&(V=E[y]);var j=null;C&&(j=String.fromCharCode(C[y]));var G=null;T&&(G=T[y]),f({atomIndex:y,groupIndex:v,chainIndex:g,modelIndex:m,atomId:B,element:D.elementList[s],atomName:D.atomNameList[s],formalCharge:D.formalChargeList[s],xCoord:t.xCoordList[y],yCoord:t.yCoordList[y],zCoord:t.zCoordList[y],bFactor:V,altLoc:j,occupancy:G})}y+=1}if(d){var W=D.bondAtomList;for(s=0,c=D.bondOrderList.length;c>s;++s)d({atomIndex1:y-z+W[2*s],atomIndex2:y-z+W[2*s+1],bondOrder:D.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,d&&P)for(s=0,c=P.length;c>s;s+=2){var H=P[s],X=P[s+1];(H>=_&&x>=H||X>=_&&x>=X)&&d({atomIndex1:H,atomIndex2:X,bondOrder:L?L[s/2]:null})}m+=1}},t.fetch=function(t,e,r){$(t,tt,e,r)},t.fetchReduced=function(t,e,r){$(t,et,e,r)},t.version="v1.1.0dev",t.fetchUrl=tt,t.fetchReducedUrl=et,t.encodeMsgpack=o,t.encodeMmtf=G,t.decodeMsgpack=W,t.decodeMmtf=X})}),Sg=xd.Complex,Mg=xd.Chain,Ag=xd.Atom,Eg=xd.AtomName,Cg=xd.Element,Tg=xd.Helix,Pg=xd.Sheet,Lg=xd.Strand,Rg=xd.Bond,Ng=xd.Assembly,Ig=xd.Molecule;il.prototype.constructor=il,il.prototype.compare=function(t){var e=t.length;if(e!==this._original.length)return!1;var r,n=0;for(r=0;r=this._complex._atoms.length)){var r=Math.min(t.atomIndex1,t.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[e],t.bondOrder,Rg.BondType.UNKNOWN,!0)}},ol.prototype._updateSecStructure=function(t,e,r){var n=[3,-1,1,-1,5];if(!wu.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof Tg||this._ssStruct instanceof Lg)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof Tg||this._ssStruct instanceof Lg)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!wu.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var i=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:i=new Tg(0,"",e,null,n[this._ssType],"",0),t._helices.push(i);break;case 3:var o=new Pg("",0);t._sheets.push(o),i=new Lg(o,e,null,0);break;default:i={type:"mmtf"+this._ssType}}this._ssStruct=i,e._secondary=i}},ol.prototype._updateMolecules=function(t){if(t)for(var e=0;e=e))for(var a=this._complex._chains[o],s=0;s0&&u.addChain(r[m])}u.matrices=h,t.structures.push(u)}}}},ll._parseToObject=function(t){function e(t){return 32===t||10===t||13===t||9===t}function r(t,e,r){for(var n=e.length,i=-1;r=c||e(t.charCodeAt(a+1)))){if(u&&59===l){s=a;var i=0;do{if(-1===(s=r(10,t,s+1)))return d="unterminated text block found",null;++i}while(s+1=c);return n=t.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=i,p=1,u=!1,n}if(39===l||34===l){s=a;do{if(-1===(s=r(l,t,s+1)))return d="unterminated quoted string found",null}while(s+10){for(var w=0;w0&&(this._altObj.setObjects(s.objects),this._altObj.pivot=s.pivot,"axis"in s?this._altObj.axis=s.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new n(a*i,a*o)),this.dispatchEvent({type:"change",action:"translate"}))}else a*=10*(_f.now.inversePanning?-1:1),this.camera.translateX(a*i),this.camera.translateY(a*o),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},yl.prototype.reset=function(){this._state=qg.NONE,this.object.quaternion.copy(new c(0,0,0,1))},yl.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===qg.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===qg.NONE)if(0===t.button){this._affectedObj.stop();var e=!1;if(t.altKey){var r=this.getAltObj();(e=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=e?this._altObj:this._mainObj,this._state=e&&t.ctrlKey&&this._isTranslationAllowed?qg.TRANSLATE:qg.ROTATE}else 2===t.button&&(this._state=qg.TRANSLATE_PIVOT);this._state===qg.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==qg.TRANSLATE&&this._state!==qg.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},yl.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==qg.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case qg.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this.rotateByMouse(t.altKey&&!this._isAltObjFreeRotationAllowed||t.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case qg.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case qg.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},yl.prototype.mousewheel=function(t){if(!1!==this.enabled&&_f.now.zooming&&this._state===qg.NONE&&!t.shiftKey){t.preventDefault();var e=0;t.wheelDelta?e=t.wheelDelta/40:t.detail&&(e=-t.detail/3);var r=1+.05*e;this.scale(r),this.dispatchEvent({type:"change",action:"zoom",factor:r})}},yl.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==qg.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=qg.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},yl.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=qg.ROTATE,this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=qg.SCALE_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(e*e+r*r),this._scaleStart=this.object.scale.x,this._originalPinchCenter=new n(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY)),this._originalCameraPos.copy(this.camera.position);break;default:this._state=qg.NONE}},yl.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==qg.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case qg.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case qg.SCALE_PAN:if(_f.now.zooming){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=Math.sqrt(e*e+r*r);var i=this.object.scale.x,o=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(o),this.dispatchEvent({type:"change",action:"zoom",factor:0===i?1:o/i})}if(_f.now.panning){var a=new n(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));a.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*a.x,this.camera.position.y=this._originalCameraPos.y+.1*a.y,this.dispatchEvent({type:"change",action:"pan"})}}},yl.prototype.keydownup=function(t){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(t.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[t.keyCode]="keydown"===t.type,t.preventDefault(),t.stopPropagation()}},yl.prototype.getKeyBindObject=function(){return window.top},yl.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new l;if(_f.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=this._framesCount&&(t=0),this._buffer={state:"none"},this._prepareBuffer(t,t+this._framesRequestLength),null!==this._frameRequest){var e=this._frameRequest;this._frameRequest=null,this.setFrame(e)}}},Sl.prototype.parseBinaryData=function(t){var e=new DataView(t),r=0,n=e.getUint32(r,!0);r+=4;var i=e.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n;this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||t.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=e.getUint32(r,!0),c=0;s>1e3&&c>>28,y=wl((268435200&g)>>>8>>0),_=wl(((255&g)<<12|(4293918720&m)>>>20)>>0),x=wl((1048575&m)>>0);p[d]=0,v>0&&v<4?p[d]=1:4===v&&(p[d]=2),u[h++]=y/100,u[h++]=_/100,u[h++]=x/100}l.push(bl(p,a))}this._secondaryData=l,this._data=u},Sl.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},Sl.prototype.needsColorUpdate=function(t){return t instanceof Cc},Sl.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},Sl.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},Sl.prototype._updateSecondary=function(){var t,e=this._residues,r=e.length;for(t=0;t=this._framesRange.start&&t<=this._framesRange.end)this._currFrame=t,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=t,this._buffer){var e=this;switch(this._buffer.state){case"none":this._prepareBuffer(t);break;case"ready":e._parseBuffer()}}else this._prepareBuffer(t)},Sl.prototype.disableEvents=function(){this._callbacks=null},Sl.prototype.getAtomPos=function(){var t=new l;return function(e){var r=this,n=r._data,i=3*(r._atomsCount*(r._currFrame-r._framesRange.start)+e);return t.set(n[i],n[i+1],n[i+2]),t}}(),Sl.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},Ml.prototype.type="__",Ml.prototype.identify=function(){var t={type:this.type,params:this.params},e=gf.objectsDiff(this.opts,_f.now.modes[this.id]);return wu.isEmpty(e)||(t.opts=e),t},Ml.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+gf.compareOptionsWithDefaults(this.opts,_f.defaults.objects[this.type])},Ml.prototype.getGeometry=function(){return this._mesh},Ml.prototype.destroy=function(){this._mesh&&Ed.destroyObject(this._mesh)},gf.deriveClass(Al,Ml,{type:"line"}),Al.prototype.constructor=Al,Al.prototype._getAtomFromName=function(t,e){var r=t.getAtomByFullname(e);if(!r)throw new Error(e+" - Wrong atom format it must be '#CHAIN_NAME.#NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r},Al.prototype.build=function(t){var e=new Tt;this._atom1=this._getAtomFromName(t,this._id1),this._atom2=this._getAtomFromName(t,this._id2),e.vertices[0]=this._atom1._position.clone(),e.vertices[1]=this._atom2._position.clone(),e.dynamic=!0,e.computeLineDistances(),e.computeBoundingBox(),this._line=new mm.Line(e,new oa({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new Y(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(t,e){},this._mesh=this._line;var r=t.getTransforms();r.length>0&&(this._mesh=new Ae,this._mesh.add(this._line),Ed.applyTransformsToMeshes(this._mesh,r))},Al.prototype.updateToFrame=function(t){if(this._atom1&&this._atom2&&this._line){var e=this._line.geometry;e.vertices[0].copy(t.getAtomPos(this._atom1._index)),e.vertices[1].copy(t.getAtomPos(this._atom2._index)),e.computeLineDistances(),e.computeBoundingSphere(),e.verticesNeedUpdate=!0}};var Jg="varying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n",tv="uniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = vec2(1, 1) / srcTexSize;\r\n\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = grad;\r\n}\r\n",ev=Dp.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new n(512,512)},opacity:{type:"f",value:1}}]),rv="// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\nvec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {return texture2D( tex, pos + off * res ).xyz;}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {return texture2D( tex, pos).xyz;}\r\n//=====================================================================//\r\nvoid main() {\r\n// renaming\r\n vec2 posM = vUv;\r\n// get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n// find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n// calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n// exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n// calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0/spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\r\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n}\r\n",nv=Dp.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)}}]),iv="#define MAX_SAMPLES_COUNT 32\r\n\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nuniform vec2 fogNearFar;\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (- projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n vec2 viewRay = vec2(projPos.x * aspectRatio * tanHalfFOV, projPos.y * tanHalfFOV); // TODO mode to vs\r\n // reconstruct viewposition in right-handed sc with z from viewer\r\n viewPos.xy = vec2(viewRay.x * viewPos.z, viewRay.y * viewPos.z);\r\n return viewPos;\r\n}\r\n\r\nvec3 GetDerivative( vec3 p0, vec3 p1, vec3 p2 )\r\n{\r\n vec3 v1 = p1 - p0;\r\n vec3 v2 = p0 - p2;\r\n return ( dot( v1, v1 ) < dot( v2, v2 ) ) ? v1 : v2;\r\n}\r\n\r\nvec3 RestoreNormalFromDepth(vec2 texcoords, vec3 p) {\r\n\r\n vec2 offset1 = vec2(srcTexelSize.x, 0.0);\r\n vec2 offset2 = vec2(0.0, srcTexelSize.y);\r\n\r\n vec3 p1 = ViewPosFromDepth(texcoords + offset1);\r\n vec3 p2 = ViewPosFromDepth(texcoords + offset2);\r\n vec3 p3 = ViewPosFromDepth(texcoords - offset1);\r\n vec3 p4 = ViewPosFromDepth(texcoords - offset2);\r\n\r\n vec3 dx = GetDerivative(p, p3, p1);\r\n vec3 dy = GetDerivative(p, p4, p2);\r\n vec3 normal = cross(dx, dy);\r\n return normalize(normal);\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n // restore normal from depth buffer\r\n vec3 normal = RestoreNormalFromDepth(vUv, viewPos); \r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n // project sample to screen to get sample's screen pos\r\n vec4 offset = vec4(samplePos, 1.0);\r\n offset = projMatrix * offset;\r\n offset.xy /= offset.w;\r\n offset.xy = (-offset.xy + vec2(1.0)) * 0.5;\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(offset.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // add fog to the AO value\r\n AO *= 1.0 - smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z);\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / 32.0 * factor); // TODO use MAX_SAMPLES_COUNT\r\n vec3 color = texture2D(diffuseTexture, vUv).rgb;\r\n // check if the fragment doesn't belong to background\r\n if (abs(- viewPos.z - camNearFar.y) < 0.1) { // FIXME remove temporal fix for background darkening\r\n gl_FragColor = vec4(1.0);\r\n return;\r\n }\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}",ov="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )) * weight;\r\n weightSum += weight;\r\n }\r\n gl_FragColor = res / weightSum;\r\n}\r\n",av="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)) * weight;\r\n weightSum += weight;\r\n }\r\n res /= weightSum;\r\n vec3 color = texture2D(diffuseTexture, vec2(x, y)).rgb;\r\n gl_FragColor = vec4(color * res.rgb, 1.0);\r\n}",sv=Dp.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new n(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:null},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1},fogNearFar:{type:"v2",value:new n(100,100)}}]),cv=Dp.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]),lv={AOMaterial:function(t){return new J({uniforms:Ll(t,sv),vertexShader:Jg,fragmentShader:iv,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new J({uniforms:Ll(t,cv),vertexShader:Jg,fragmentShader:ov,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new J({uniforms:Ll(t,cv),vertexShader:Jg,fragmentShader:av,transparent:!1,depthTest:!1,depthWrite:!1})}},uv="uniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",hv=Dp.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);Il.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};Ol.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},Ol.prototype.isMoving=function(){return this._isMoving},Ol.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},Ol.prototype.start=function(){this._startTime=Date.now();var t=_f.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},Ol.prototype.getCurrentView=function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var t=this.createView(),e=Date.now();if(e>this._endTime)return t=this._dstView,this._reset(),{success:!0,view:t};var r=(e-this._startTime)/(this._endTime-this._startTime);return t.position.copy(this._srcView.position),t.position.lerp(this._dstView.position,r),t.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,t.orientation.copy(this._srcView.orientation),t.orientation.slerp(this._dstView.orientation,r),{success:!0,view:t}},Ol.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},Ol.prototype.createView=function(){return new Il};var pv=new Ol,fv=_f.now.fbxprec,dv='; FBX 6.1.0 project file\n; Copyright (C) 1997-2007 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n FBXHeaderExtension: {\n FBXHeaderVersion: 1003\n FBXVersion: 6100\n CreationTimeStamp: {\n Version: 1000\n Year: 2015\n Month: 12\n Day: 7\n Hour: 17\n Minute: 34\n Second: 53\n Millisecond: 369\n }\n Creator: "FBX SDK/FBX Plugins build 20080212"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nreationTime: "2015-12-07 17:34:53:369"\nreator: "FBX SDK/FBX Plugins build 20080212"\n\n; Document Description\n;------------------------------------------------------------------\n\n Document: {\n Name: ""\n}\n\n; Document References\n;------------------------------------------------------------------\n\n References: {\n}\n\n; Object definitions\n;------------------------------------------------------------------\n\n Definitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "SceneInfo" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n}\n\n; Object properties\n;------------------------------------------------------------------\n\n Objects: {\n Model: "Model::Sphere01", "Mesh" {\n Version: 232\n Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "InheritType", "enum", "",1\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Lcl Translation", "Lcl Translation", "A+",-0.169204741716385,-0.507614195346832,0\n Property: "Lcl Rotation", "Lcl Rotation", "A+",0,0,0\n Property: "Lcl Scaling", "Lcl Scaling", "A+",1,1,1\n Property: "Visibility", "Visibility", "A+",1\n Property: "BBoxMin", "Vector3D", "N",0,0,0\n Property: "BBoxMax", "Vector3D", "N",0,0,0\n }\n MultiLayer: 0\n MultiTake: 1\n Shading: T\n Culling: "CullingOff"\n',mv='NodeAttributeName: "Geometry::Sphere01"\n}\nceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n Type: "UserData"\n Version: 100\n MetaData: {\n Version: 100\n Title: ""\n Subject: ""\n Author: ""\n Keywords: ""\n Revision: ""\n Comment: ""\n }\n Properties60: {\n Property: "DocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "SrcDocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "Original", "Compound", ""\n Property: "Original|ApplicationVendor", "KString", "", "Autodesk"\n Property: "Original|ApplicationName", "KString", "", "3ds Max"\n Property: "Original|ApplicationVersion", "KString", "", "2009.0"\n Property: "Original|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n Property: "Original|FileName", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "LastSaved", "Compound", ""\n Property: "LastSaved|ApplicationVendor", "KString", "", "Autodesk"\n Property: "LastSaved|ApplicationName", "KString", "", "3ds Max"\n Property: "LastSaved|ApplicationVersion", "KString", "", "2009.0"\n Property: "LastSaved|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n }\n}\nlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",2\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",1\n Property: "FrontAxisSign", "int", "",-1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",2.54\n }\n}\n}\n\n; Object relations\n;------------------------------------------------------------------\n\n Relations: {\n Model: "Model::Sphere01", "Mesh" {\n }\n SceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n }\n}\n\n; Object connections\n;------------------------------------------------------------------\n\n Connections: {\n Connect: "OO", "Model::Sphere01", "Model::Scene"\n}\n\n;Object data\n;------------------------------------------------------------------\n\n ObjectData: {\n}\n;Takes and animation section\n;----------------------------------------------------\n\n Takes: {\n Current: "Take 001"\n}\n;Version 5 settings\n;------------------------------------------------------------------\n\n Version5: {\n AmbientRenderSettings: {\n Version: 101\n AmbientLightColor: 0.533333003520966,0.533333003520966,0.533333003520966,1\n }\n FogOptions: {\n FlogEnable: 0\n FogMode: 0\n FogDensity: 0.002\n FogStart: 0.3\n FogEnd: 1000\n FogColor: 1,1,1,1\n }\n Settings: {\n FrameRate: "30"\n TimeFormat: 1\n SnapOnFrames: 0\n ReferenceTimeIndex: -1\n TimeLineStartTime: 0\n TimeLineStopTime: 153953860000\n }\n RendererSetting: {\n DefaultCamera: ""\n DefaultViewingMode: 0\n }\n}\n\n',gv=null;Fl.prototype.queue=[],Fl.prototype.busy=!1,Fl.prototype.add=function(t,e,r,n){this.queue.push([t,e,r,n]),this.busy||this.next()},Fl.prototype.next=function(){var t=this.queue.shift(),e=this;t&&!e.busy&&(this.busy=!0,zl(t[0],t[1],t[2],t[3],function(){e.busy=!1,e.next()}))};ha(Kl.prototype),Kl.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e,r)):i.renderer.renderDummyQuad(r),i.renderer.renderScreenQuadFromTex(r.texture,.6,n),t.uniforms.srcTex.value=r.texture,t.uniforms.srcTexSize.value.set(r.width,r.height),i.renderer.renderScreenQuad(t,n)}}(),nu.prototype.renderVolume=function(){var t=new tg.BackFacePosMaterial,e=new tg.FrontFacePosMaterial,r=(new u).makeTranslation(.5,.5,.5),n=new u;return function(i,o,a,s,c,l){var u=this._gfx,h=i.getMesh();h.rebuild(o),u.renderer.setClearColor("black",0),u.renderer.clearTarget(s),u.renderer.clearTarget(c),u.renderer.clearTarget(l),o.layers.set(Ed.LAYERS.VOLUME_BFPLANE),u.renderer.render(u.scene,o,s),o.layers.set(Ed.LAYERS.VOLUME),u.scene.overrideMaterial=t,u.renderer.render(u.scene,o,s),o.layers.set(Ed.LAYERS.VOLUME),u.scene.overrideMaterial=e,u.renderer.render(u.scene,o,c),u.scene.overrideMaterial=null,o.layers.set(Ed.LAYERS.DEFAULT),n.getInverse(h.matrixWorld),oa.prototype.uberOptions.world2colorMatrix.multiplyMatrices(r,n),this.setUberMaterialValues({colorFromPos:!0}),u.renderer.render(u.scene,o,l),this.setUberMaterialValues({colorFromPos:!1});var p=h.material;p.uniforms._BFRight.value=s.texture,p.uniforms._FFRight.value=c.texture,p.uniforms._WFFRight.value=l.texture,o.layers.set(Ed.LAYERS.VOLUME),u.renderer.render(u.scene,o,a),o.layers.set(Ed.LAYERS.DEFAULT)}}(),nu.prototype.renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(Ed.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(Ed.LAYERS.PREPASS_TRANSPARENT),r.renderer.context.colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,t,e),r.renderer.context.colorMask(!0,!0,!0,!0),t.layers.set(Ed.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(Ed.LAYERS.DEFAULT)},nu.prototype.performFXAA=function(){var t=new Pl;return function(e,r){if(void 0!==e&&void 0!==r){var n=this._gfx;n.renderer.setClearColor(_f.now.themes[_f.now.theme],1),n.renderer.clearTarget(r),t.uniforms.srcTex.value=e.texture,t.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),t.transparent=!0,n.renderer.renderScreenQuad(t,r)}}}(),nu.prototype.performAO=function(){var t=new lv.AOMaterial,e=new lv.HorBilateralBlurMaterial,r=new lv.VertBilateralBlurMaterial,n=new q(new Uint8Array([0,0,0,66,0,0,77,0,0,155,62,0,0,247,0,33,0,0,0,0,0,235,0,0,0,0,0,176,44,0,232,46,0,0,29,0,0,0,0,78,197,0,93,0,0,0,0,0]),4,4,Qh,Uh,300,Lh,Lh,Ih,Ih,1);n.needsUpdate=!0;var i=[new l(.295184,.077723,.068429),new l(-.271976,-.365221,.838363),new l(.547713,.467576,.488515),new l(.662808,-.031733,.584758),new l(-.025717,.218955,.657094),new l(-.310153,-.365223,.370701),new l(-.101407,-.006313,.747665),new l(-.769138,.360399,.086847),new l(-.271988,-.27514,.905353),new l(.09674,-.566901,.700151),new l(.562872,-.735136,.094647),new l(.379877,.359278,.190061),new l(.519064,-.023055,.405068),new l(-.301036,.114696,.088885),new l(-.282922,.598305,.487214),new l(-.181859,.25167,.679702),new l(-.191463,-.635818,.512919),new l(-.293655,.427423,.078921),new l(-.267983,.680534,.13288),new l(.139611,.319637,.477439),new l(-.352086,.31104,.653913),new l(.321032,.805279,.487345),new l(.073516,.820734,.414183),new l(-.155324,.589983,.41146),new l(.335976,.170782,.527627),new l(.46346,-.355658,.167689),new l(.222654,.59655,.769406),new l(.922138,-.04207,.147555),new l(-.72705,-.329192,.369826),new l(-.090731,.53382,.463767),new l(-.323457,-.876559,.238524),new l(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,u,h,p){if(void 0!==a&&void 0!==s&&void 0!==u&&void 0!==h&&void 0!==p){var f=this._gfx;t.uniforms.diffuseTexture.value=a.texture,t.uniforms.depthTexture.value=s,t.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),t.uniforms.camNearFar.value.set(f.camera.near,f.camera.far),t.uniforms.projMatrix.value=f.camera.projectionMatrix,t.uniforms.aspectRatio.value=f.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*Tp.DEG2RAD*f.camera.fov),t.uniforms.samplesKernel.value=i;var d=new l,m=new c,g=new l;f.root.matrix.decompose(d,m,g),t.uniforms.kernelRadius.value=_f.now.debug.ssaoKernelRadius*g.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=_f.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var v=f.scene.fog;v&&t.uniforms.fogNearFar.value.set(v.near,v.far),t.transparent=!1,f.renderer.renderScreenQuad(t,p),e.uniforms.aoMap.value=p.texture,e.uniforms.srcTexelSize.value.set(1/p.width,1/p.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(e,h),r.uniforms.aoMap.value=h.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/h.width,1/h.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(r,u)}}}(),nu.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(xv.COMPLEX),this.resetObjects(),this._gfx&&(Ed.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},nu.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},nu.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(xv.COMPLEX),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},nu.prototype.load=function(t,e){var r=this;return r._loader&&r._loader.cancel(),r.dispatchEvent({type:"load",options:e}),t instanceof File&&t.name.match(/.man$/i)?this._fileSourceAnim=tu(t):this._fileSource=tu(t),e&&e.mdFile&&(this._fileSourceAnim=e.mdFile),this.settings.now.use.multiFile||e&&e.animation||this.reset(!0),r._loader=new Fi,r._loader.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),r._spinner.spin(this._container),su(t,e,r._loader,r).then(function(t){return r._loader=null,r._spinner.stop(),new Promise(function(n){t.opts.animation?(r.refreshTitle(),r._startAnimation(t.data),n(null)):(r._stopAnimation(),e&&e.keepRepsInfo||(r._opts.reps=null,r._opts._objects=null),n(r._onLoad(t.data,t.opts)))})},function(){r._loader=null,r._spinner.stop(),r.refreshTitle()})},nu.prototype.unload=function(t){this._removeVisual(t||this.getCurrentVisual())},nu.prototype._startAnimation=function(t){this._stopAnimation();var e=this,r=this._getComplexVisual();if(null!==r){try{this._frameInfo=new Sl(r.getComplex(),t,{onLoadStatusChanged:function(){e.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:e._isAnimating,isLoading:!e._frameInfo||e._frameInfo.isLoading}})},onError:function(t){e._stopAnimation(),e.logger.error(t)}})}catch(t){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")},nu.prototype._startMdAnimation=function(t,e){this._stopAnimation();var r=this,n=this._getComplexVisual();if(null!==n){try{this._frameInfo=new Sl(n.getComplex(),this.srvStreamMdFn(t,e),{onLoadStatusChanged:function(){r.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:r._isAnimating,isLoading:!r._frameInfo||r._frameInfo.isLoading}})},onError:function(t){r._stopAnimation(),r.logger.error(t)}})}catch(t){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")},nu.prototype._pauseAnimation=function(){null!==this._animInterval&&(this._isAnimating=!1,clearInterval(this._animInterval),this._animInterval=null,this._frameInfo&&this.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:this._isAnimating,isLoading:this._frameInfo.isLoading}}))},nu.prototype._continueAnimation=function(){this._isAnimating=!0;var t=1e3/_f.now.maxfps;t=Number.isNaN(t)?0:t;var e=this,r=e._gfx.pivot,n=this._getComplexVisual();n&&(n.resetSelectionMask(),n.rebuildSelectionGeometry(),this._msgAtomInfo.style.opacity=0),this._animInterval=setInterval(function(){if(e.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:e._isAnimating,isLoading:e._frameInfo.isLoading}}),e._frameInfo.frameIsReady){r.updateToFrame(e._frameInfo),e.updateObjsToFrame(e._frameInfo),e.refreshTitle(" Frame "+e._frameInfo._currFrame+" of "+e._frameInfo._framesCount+" time interval - "+e._frameInfo._timeStep);try{e._frameInfo.nextFrame()}catch(t){return e.logger.error("Error during animation"),void e._stopAnimation()}e._needRender=!0}},t)},nu.prototype._stopAnimation=function(){null!==this._animInterval&&(clearInterval(this._animInterval),this._frameInfo.disableEvents(),this._frameInfo=null,this._animInterval=null,this._fileSourceAnim=null,this.dispatchEvent({type:"mdPlayerStateChanged",state:null}))},nu.prototype._onLoad=function(t,e){var r=this._gfx,n=null;if("Complex"===t.id){var i=t;e.fileName?i.name=i.name||Jl(e.fileName).toUpperCase():e.amberFileName?i.name=i.name||Jl(e.amberFileName).toUpperCase():i.name="Dynamic "+e.fileType+" molecule",n=this._addVisual(new Vc(i.name,i)),this._curVisualName=n;var o=this.info();if(this.logger.info("Parsed "+e.fileName+" ("+o.atoms+" atoms, "+o.bonds+" bonds, "+o.residues+" residues, "+o.chains+" chains)."),wu.isNumber(this._opts.unit)&&i.setCurrentStructure(this._opts.unit),e.preset)this.srvPresetApply(e.preset);else if(_f.now.autoPreset)switch(e.fileType){case"cml":this.resetReps("small");break;case"pdb":case"mmtf":case"cif":eu(i)?this.resetReps("macro"):this.resetReps("small");break;default:this.resetReps("default")}}else"Volume"===t.id&&(this.resetEd(),n=this._onLoadEd(t));return r.camera.updateProjectionMatrix(),this._updateFog(),r.root.resetTransform(),this.resetPivot(),this.resetPan(),this._objectControls.setScale(_f.now.radiusToFit/this._getBSphereRadius()),this.resetObjects(),_f.now.autoResolution&&this._tweakResolution(),this._opts.view&&(this.view(this._opts.view),delete this._opts.view),e.error?this.dispatchEvent({type:"onParseError",error:e.error}):this.dispatchEvent({type:"onParseDone"}),this.refreshTitle(),e.convertedFile&&e.mdFile&&this._startMdAnimation(e.mdFile,e.convertedFile),n},nu.prototype.resetEd=function(){this._edLoader&&(this._edLoader.abort(),this._edLoader=null),this._removeVisual(this._getVolumeVisual()),this._needRender=!0},nu.prototype.loadEd=function(t){var e=this;this.resetEd(),(this._edLoader=Yg.loaders.create(e,t,{binary:!0})).load({ready:function(t){Yg.parsers.create(e,t,{fileType:"ccp4"}).parse({ready:function(t){e._onLoadEd(t)},progress:function(t){ru(e.logger,"Parsing ED",t)}})},progress:function(t){ru(e.logger,"Loading ED",t)}})},nu.prototype._onLoadEd=function(t){t.normalize();var e=new Wc("volume",t);e.getMesh().layers.set(Ed.LAYERS.VOLUME);var r=this._addVisual(e);return this._needRender=!0,r},nu.prototype._needRebuild=function(){var t=!1;return this._forEachComplexVisual(function(e){t=t||e.needsRebuild()}),t},nu.prototype.rebuildObjects=function(){var t,e,r=this,n=this._gfx,i=[];for(t=0;t0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},nu.prototype.rebuild=function(){if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuild"}),this.rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual(function(e){e.needsRebuild()&&t.push(e.rebuild().then(function(){return new Promise(function(t){e.rebuildSelectionGeometry(),t()})}))});var e=this;this._spinner.spin(this._container),Promise.all(t).then(function(){e._spinner.stop(),e._needRender=!0,e.refreshTitle(),e._building=!1})}},nu.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},nu.prototype.refreshTitle=function(t){var e;t=void 0===t?"":t;var r=this._getComplexVisual();if(r){e=r.getComplex().name;var n=r.repGet(r.repCurrent());e+=n?" – "+n.mode.name+" Mode":""}else e=Object.keys(this._visuals).length>0?"Unknown":"No Data";e+=t,this.dispatchEvent({type:"titleChanged",data:e})},nu.prototype.setNeedRender=function(){this._needRender=!0},nu.prototype._extractRepresentation=function(){var t=this,e=[];this._forEachComplexVisual(function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<0&&(this.logger.report("New representation from selection for complexes: "+e.join(", ")),this.dispatchEvent({type:"repAdd"}))},nu.prototype.setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},nu.prototype.applyPreset=function(t){for(var e=_f.now.presets,r=[t||_f.defaults.preset,_f.defaults.preset,Object.keys(e)[0]],n=null,i=0;!n&&i0&&t.push(e)}),1===t.length){var e=t[0].beginFragmentEdit();e&&(this._editors=[e],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(xv.FRAGMENT),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},nu.prototype._applyFragmentEdit=function(){if(this._editMode===xv.FRAGMENT){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new l(0,0,0)}},nu.prototype.resetPivot=function(){var t=new et;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},nu.prototype.setPivotResidue=function(t){var e=this._getVisualForComplex(t.getChain().getComplex());if(e){var r=this._gfx.pivot.position;if(t._controlPoint)r.copy(t._controlPoint);else{for(var n=0,i=0,o=0,a=t._atoms.length,s=0;s=5&&(e._gfxScore=1e3/r.mean()),t>0&&(e._gfxScore=.5*t),e._spinner.stop(),n()})):n()})},nu.prototype.screenshot=function(t,e){var r=this._gfx;e=e||t||r.height;var n;if((t=t||r.width)===r.width&&e===r.height)n=r.renderer.domElement.toDataURL("image/png");else{var i=r.width/r.height,o=r.camera.fov,a=o*Math.min(r.width,r.height)/r.height,s=t/e;r.camera.aspect=s,r.camera.fov=a/Math.min(s,1),r.camera.updateProjectionMatrix(),r.renderer.setSize(t,e),this._renderFrame("NONE"),n=r.renderer.domElement.toDataURL("image/png"),r.camera.aspect=i,r.camera.fov=o,r.camera.updateProjectionMatrix(),r.renderer.setSize(r.width,r.height),this._needRender=!0}return n},nu.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);gf.shotDownload(n,t)},nu.profile=function(t,e,r){function n(t){var e=t.length-Math.round(.1*t.length);t.sort();for(var r=0,n=0;n0)for(var r=1e6*this._gfxScore/e,n=0;nn?(o=!1,r.preset="empty"):_f.now.preset!==_f.defaults.preset&&(r.preset=_f.now.preset);for(var a=[],s=!0,c=0,l=n;c0&&(e._objects=a),t.view&&(e.view=this.view()),t.settings){var l=this.settings.getDiffs(!1);wu.isEmpty(l)||(e.settings=l)}return e},nu.prototype.get=function(t,e){return _f.get(t,e)},nu.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*_f.now.draft.clipPlaneFactor,_f.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&A.push("'"+this.terminals_[w]+"'");C=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(c+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(C,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],E.$=i[i.length-S],E._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(E._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(E,[s,l,c,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(E.$),o.push(E._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},St={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 41;case 4:return 34;case 5:return 96;case 6:case 7:return 97;case 8:return 8;case 9:return 6;case 10:return 100;case 11:return 7;case 12:return 9;case 13:return 79;case 14:return 81;case 15:return 12;case 16:return 14;case 17:return 16;case 18:return 17;case 19:return 18;case 20:return 19;case 21:return 82;case 22:return 84;case 23:return 22;case 24:return 24;case 25:return 25;case 26:return 26;case 27:return 29;case 28:return 33;case 29:return 32;case 30:return 85;case 31:return 86;case 32:return 36;case 33:return 40;case 34:return 42;case 35:return 51;case 36:return 53;case 37:return 54;case 38:return 44;case 39:return 46;case 40:return 43;case 41:return 55;case 42:return 57;case 43:return 58;case 44:return 61;case 45:return 62;case 46:return 63;case 47:return 65;case 48:return 66;case 49:return 67;case 50:return 68;case 51:return 69;case 52:return 70;case 53:return 71;case 54:return 73;case 55:return 72;case 56:case 57:return 90;case 58:case 59:return 91;case 60:case 61:case 62:return 93;case 63:return 30;case 64:return 35;case 65:return 77;case 66:return 74;case 67:return 78;case 68:return 76;case 69:return e.yytext=e.yytext.substr(1,e.yyleng-2),13;case 70:return 37;case 71:return 5;case 72:return 102;case 73:return 103;case 74:return"\\";case 75:return 27;case 76:return 59;case 77:return 28;case 78:return 56;case 79:return 75}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],inclusive:!0}}};return wt.lexer=St,t.prototype=wt,wt.Parser=t,new t}();void 0!==t&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=Zf.readFileSync(Kf.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}).parser,Mv={$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = #aromatic radius"," atom = #atom radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},CA:{$help:[" Cartoon"," arrow = #arrow size"," depth = #depth of surface"," heightSegmentsRatio = "," radius = #tube radius"," tension = #"," width = #secondary width\n"]},LN:{$help:[" Lines"," atom = #atom radius"," chunkarom = "," multibond = #use multibond"," showarom = #show aromatic"," offsarom = \n"]},LC:{$help:[" Licorice"," aromrad = #aromatic radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = "," radius = #tube radius"," tension = \n"]},SA:{$help:[" Surface"," zClip = #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = "," scale = "," wireframe = "," zClip = #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = #clip z plane\n"]},TX:{$help:[" Text mode",' template = string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = {"left", "right", "center"}',' verticalAlign = {"top", "bottom", "middle"}'," dx = #offset along x"," dy = #offset along y"," dz = #offset along z"," fg = #text color modificator"," could be keyword, named color or hex"," fg = #back color modificator"," could be keyword, named color or hex"," showBg = #if set show background"," plate under text"]}},Av={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = #RGB->HEX->dec\n"],color:{$help:Object.keys(Vm.get(_f.now.palette).namedColors).sort().join("\n")}}},Ev={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Cv={$help:["Short (packed) representation description as a set of variables"," s="," selector property"," m=[!:[,...]]"," render mode property"," c=[!:[,...]]"," color mode property"," mt="," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Mv,c:Av,mt:Ev},Tv={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Mv,colorers:Av},Pv={$help:["help (| )","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (||-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [] []"," Add new item to representation set with"," default or params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Cv},rep:{$help:["rep [|] []"," set current representation by name or index"," edit current representation by "],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Cv},remove:{$help:["remove (|)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector "," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode [=...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Mv},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Av},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Ev},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:Tv},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:Tv},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset []","Reset current representation or set preset to "],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit []","Change current biological structure view. Zero value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view []","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [] [(x|y|z) []]...","Rotate scene"]},scale:{$help:["scale ","Scale scene"]},select:{$help:["select [as ]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within of as ","Build within named selector"," DISTANCE "," SELECTOR_STRING "," SELECTOR_NAME "]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [ []]","Make a screenshot of the scene"," WIDTH in pixels"," HEIGHT in pixels, equal to WIDTH by default"]},line:{$help:["line [=]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj ","Remove scene object by its index. Indices could be obtained by command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]},file_list:{$help:["file_list [(|FILE_NAME)] [-f=]","Report registered files on server or presets in file if defined FILE_ID or FILE_NAME"," also you can use -f flag for fast search"," entity by starting part of name"]},file_register:{$help:["file_register ","Try register current opened file to server"]},file_delete:{$help:["file_delete (|FILE_NAME) [-f]","Delete file from server"," if -f not set then file will be deleted"," only when it has not got any presets in it"," if -f set then file will be deleted anyway"]},preset_add:{$help:["preset_add ","Create new preset from current viewer state"," to current opened file on server"]},preset_delete:{$help:["preset_delete (|)","Delete preset from server"]},preset_update:{$help:["preset_update <(|)","Update due the current viewer state"]},preset_rename:{$help:["preset_rename (|) ","Rename preset"]},preset_open:{$help:["preset_open (|)","Load preset"]},create_scenario:{$help:["create_scenario "," Creates scenario context for future work with them"]},reset_scenario:{$help:["reset_scenario"," Clear current scenario context"]},add_scenario_item:{$help:["add_scenario_item"," pdb=( | )"," prst=(|)"," delay="," desc=\n"," Add item to context and update scenario on server"," Pay attention that order of arguments is important"]},delete_scenario:{$help:["delete_scenario (|)"," Deletes scenario from server"]},list_scenario:{$help:["list_scenario [-e [|]]"," Report scenario list, when -e is set reports expanded"," If set -e then reports only requested scenario"]}},Lv=function(){function t(){bf(this,t)}return wf(t,[{key:"createSelectorFromNode",value:function(t){return hu(t)}}]),t}(),Rv=nu.chem.selectors,Nv=nu.modes,Iv=nu.colorers,Ov=nu.materials,Dv=nu.palettes,zv=nu.options,Fv=nu.settings,kv=function(){var t=new pu;return function(){return t}}();fu.prototype.get=function(t){return this.representationMap[t]||this.representationID[t]||""},fu.prototype.add=function(t,e){if(void 0!==e){if(this.representationMap.hasOwnProperty(t))return"This name has already existed, registered without name";this.representationMap[t.toString()]=e,this.representationID[e]=t.toString()}return"Representation "+t+" successfully added"},fu.prototype.remove=function(t){t&&this.representationID.hasOwnProperty(t)&&(delete this.representationMap[this.representationID[t]],delete this.representationID[t]);var e=Object.keys(this.representationID).sort();for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];n>t&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}},fu.prototype.clear=function(){this.representationMap={},this.representationID={}};var Uv=new fu;du.prototype.list=function(t,e,r){var n="";if(t&&void 0!==e&&(void 0===r||"-e"===r))for(var i=t.repCount(),o=0;o"===s?"":s)+"\n",void 0!==n){var l=o.selector;l instanceof Array&&(l=(new Lv).createSelectorFromNode(l));var u=o.colorer instanceof Array?o.colorer[0]:o.colorer,h=o.material;i+=' selection : "'+l+'"\n',i+=" mode : ("+c+"), "+Nv.get(c).name+"\n",i+=" colorer : ("+u+"), "+Iv.get(u).name+"\n",i+=" material : ("+h+"), "+Ov.get(h).name+"\n"}return i},du.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},du.prototype.listObjs=function(t){var e=t._objects;if(!e||!Array.isArray(e)||0===e.length)return"There are no objects on the scene";for(var r=[],n=0,i=e.length;n0)throw{message:t+' must be a "'+xf(wu.get(Fv.defaults,t))+'"'}}return e};var Bv=new du;gu.prototype.addItem=function(t,e){this.scenarioId=t,this.data.push(e)},yu.prototype.requestScenarioID=function(t,e,r,n){var i=this;t.awaitWhileCMDisInProcess(),void 0!==e&&t.srvScenarioList(function(o){if(o instanceof Array){var a=wu.filter(o,function(t){return void 0!==t.name&&t.name.toLowerCase()===e.toLowerCase()||t.id===Number(e)});a.length<1?(void 0!==n&&n("File not found"),i.finish(t)):a.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(a[0].id):i.finish(t)}else i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)})},yu.prototype.requestPdbID=function(t,e,r,n){var i=this,o=e.split("/");if(t.awaitWhileCMDisInProcess(),1!==o.length)void 0!==n&&n("Path can contain only file name or id"),i.finish(t);else{var a=Number(o[0]);Number.isNaN(a)?t.srvTopologyFind(o[0],function(e){e instanceof Array?e.length<1?(void 0!==n&&n("File not found"),i.finish(t)):e.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(e[0].id):i.finish(t):i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)}):r(a)}},yu.prototype.requestPresetId=function(t,e,r,n){function i(e){void 0!==e&&void 0!==n&&n(e),a.finish(t)}function o(e){if(e instanceof Array){var i=wu.filter(e,function(t){return t.name.toLowerCase()===s[1].toLowerCase()||t.id===Number(s[1])});i.length<1?(void 0!==n&&n("Preset not found"),a.finish(t)):i.length>1?(void 0!==n&&n("There are two or more presets, please specify one by preset_id"),a.finish(t)):void 0!==r?r(i[0].id):a.finish(t)}else a.finish(t)}var a=this,s=e.split("/");t.awaitWhileCMDisInProcess(),2!==s.length?(void 0!==n&&n("Path can has 2 levels only (pdb/preset)"),a.finish(t)):this.requestPdbID(t,s[0],function(e){t.srvPresetList(e,o,i)},i)},yu.prototype.createScenario=function(t){this.scenarioContext=new vu(t)},yu.prototype.resetScenario=function(){this.scenarioContext=new vu},yu.prototype.deleteScenario=function(t,e,r,n){function i(r){void 0!==r&&e(r),s.finish(t)}function o(e){void 0!==e&&r(e),s.finish(t)}function a(e){t.srvScenarioDelete(e,i,o),s.finish(t)}var s=this;this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?a(n):this.requestScenarioID(t,n,a,o)},yu.prototype.listScenario=function(t,e,r,n){var i=this;this.init(t,e),t.awaitWhileCMDisInProcess(),t.srvScenarioList(function(r){if(r instanceof Array){for(var o="",a=0,s=r.length;a"),void o.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void o.finish(t)):(r("internal interpreter error"),void o.finish(t));var s=arguments[3],c=arguments[4],l=arguments[5],u=arguments[6];if(wu.isString(s))this.requestPdbID(t,s,function(t){t>=0&&(a[3]=t,o.addScenarioItem.apply(o,a))},i);else if(wu.isString(c))this.requestPresetId(t,s+"/"+c,function(t){t>=0&&(a[4]=t,o.addScenarioItem.apply(o,a))},i);else{if("number"!=typeof s||"number"!=typeof c)return i("Internal error"),void o.finish(t);!function(e,r,a,s){o.scenarioContext.script.addItem(o.scenarioContext.id,new mu(e,r,a,s)),t.srvScenarioAdd(o.scenarioContext.id,o.scenarioContext.name,JSON.stringify(o.scenarioContext.script),n,i)}(s,c,l,u)}},yu.prototype.init=function(t,e){var r=this;this.isOnApllyPresetEventInitialized||(t.addEventListener("presetApplyFinished",function(){r.finish(t),void 0!==e&&e("Preset applied")}),this.isOnApllyPresetEventInitialized=!0)},yu.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},yu.prototype.fileList=function(t,e,r,n,i){function o(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),l.finish(t)):void 0===o?i.call(t,n[0].id,a,c):i.call(t,n[0].id,o,a,c)}else l.finish(t)}function c(e){void 0!==e&&r(e),l.finish(t)}var l=this;this.init(t,e),t.awaitWhileCMDisInProcess();var u=n.split("/");2!==u.length?(r("Path can has 2 levels only (pdb/preset)"),l.finish(t)):t.srvTopologyFind(u[0],function(e){e instanceof Array?e.length<1?(r("File not found"),l.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),l.finish(t)):t.srvPresetList(e[0].id,s,c):l.finish(t)},c)},yu.prototype.coroutineWithFileName=function(t,e,r,n,i){function o(r){void 0!==r&&e(r),s.finish(t)}function a(e){void 0!==e&&r(e),s.finish(t)}var s=this,c=arguments;this.init(t),t.awaitWhileCMDisInProcess();var l=n.split("/");1!==l.length?(r("Path can contain only file name or id"),s.finish(t)):t.srvTopologyFind(l[0],function(e){if(e instanceof Array)if(e.length<1)r("File not found");else if(e.length>1)r("There are two or more files, please specify one by file_id");else switch(c.length){case 5:i.call(t,e[0].id,o,a);break;case 6:i.call(t,e[0].id,c[5],o,a);break;case 9:i.call(c[5],c[6],c[7],c[8],e[0].id);break;case 10:i.call(c[5],c[6],c[7],c[8],e[0].id,c[9]);break;default:s.finish(t)}s.finish(t)},a)};var Vv=new yu;xu.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},xu.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},xu.prototype.toJSO=function(t,e,r){for(var n={},i=this._values,o=0,a=i.length;o0},nu.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={};e.success=!1;try{Sv.parse(t),e.success=!0}catch(t){e.error=t.message,Sv.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},nu.JSONConverter=Lv,Sv.yy=jv,Sv.yy.parseError=Sv.parseError,nu}); +(function(){var t,r,n,i,o,a,s,c,l,u,h,p,f,d,m,g,v,y,_,x,b,w,S,M,A,E,C=Object.prototype.hasOwnProperty,T=function(t,e){function r(){this.constructor=t}for(var n in e)C.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};p={method:(n={METHOD_NEAREST:"nearest",METHOD_LINEAR:"linear",METHOD_CUBIC:"cubic",METHOD_LANCZOS:"lanczos",METHOD_SINC:"sinc",CLIP_CLAMP:"clamp",CLIP_ZERO:"zero",CLIP_PERIODIC:"periodic",CLIP_MIRROR:"mirror",CUBIC_TENSION_DEFAULT:0,CUBIC_TENSION_CATMULL_ROM:0}).METHOD_CUBIC,cubicTension:n.CUBIC_TENSION_DEFAULT,clip:n.CLIP_CLAMP,scaleTo:0,sincFilterSize:2,sincWindow:void 0},l=function(t,e){return Math.max(0,Math.min(t,e-1))},h=function(t,e){return(t%=e)<0&&(t+=e),t},u=function(t,e){var r;return r=2*(e-1),(t=h(t,r))>e-1&&(t=r-t),t},t=function(){function t(t,e){if(this.array=t.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[e.clip]))throw"Invalid clip: "+e.clip}return t.prototype.getClippedInput=function(t){return 0<=t&&t=o;i<=o?r++:r--)n+=this.kernel(t-r)*this.getClippedInput(r);return n},r}(),f=function(t,e){var r,n,i,o;for(o=[],n=0,i=t.length;na;0<=a?l++:l--)r.push(new h(f(t,l),e));return r}(),function(t){var e,r,n,i;for(i=[],r=0,n=m.length;r1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),o.setColor(p++,i.getAtomColor(v,r),i.getAtomColor(y,r))}}o.finalize(),this._chunksIdc=f},Gs.prototype.updateToFrame=function(t){for(var e=this._selection.chunks,r=this._selection.bonds,n=this._mode,i=this._colorer,o=this._geo,a=n.drawMultiorderBonds(),s=n.showAromaticLoops(),c=new l,u=new l,h=new l,p=0,f=t.needsColorUpdate(i),d=0,m=e.length;d1&&0!==C&&(u.lerpVectors(_,x,.15/S),h.lerpVectors(_,x,1-.15/S)),C*=.15,u.addScaledVector(M,C),h.addScaledVector(M,C),o.setItem(p,u,h),f&&o.setColor(p,t.getAtomColor(i,v),t.getAtomColor(i,y)),p++}}o.finalize()};var Sm={AtomsSphereGroup:vs,AtomsSurfaceGroup:ys,AtomsSASSESGroup_stub:_s,AtomsTextGroup:ws,AromaticTorusGroup:Es,AromaticLinesGroup:Cs,NucleicCylindersGroup:Ls,NucleicSpheresGroup:Rs,ResiduesSubseqGroup:Fs,ResiduesTraceGroup:Us,BondsCylinderGroup:js,BondsLinesGroup:Gs};Ws.prototype=Object.create(ia.prototype),Ws.prototype.constructor=Ws,Ws.prototype._checkAtom=function(t,e){return t._mask&e},Ws.prototype.getSubset=function(t,e){for(var r=[],n=this.children,i=0,o=0,a=n.length;o0&&s.add(p)}return s},rc.prototype=Object.create(ec.prototype),rc.prototype.constructor=rc,rc.prototype.update=function(){var t=this._staticGroups;"no"===this.settings.now.labels?this.depGroups=this.depGroups.slice(0,t):(this.depGroups[t]="TextLabelsGeo",this.depGroups[t+1]="SGroupsLabels")},rc.prototype.buildGeometry=function(t,e,r,n){return this.update(),ec.prototype.buildGeometry.call(this,t,e,r,n)},gf.deriveClass(ic,rc,{id:"LN",name:"Lines",shortName:"Lines",depGroups:["ALoopsLines","BondsLines","OrphanedAtomsCrosses"]}),ic.prototype.drawMultiorderBonds=function(){return this.opts.multibond},ic.prototype.calcAtomRadius=function(){return this.opts.atom},ic.prototype.getAromaticOffset=function(){return this.opts.offsarom},ic.prototype.getAromaticArcChunks=function(){return this.opts.chunkarom},ic.prototype.showAromaticLoops=function(){return this.opts.showarom},ic.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!0,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gf.deriveClass(oc,rc,{id:"LC",name:"Licorice",shortName:"Licorice",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),oc.prototype.calcAtomRadius=function(t){return this.opts.bond},oc.prototype.calcStickRadius=function(){return this.opts.bond},oc.prototype.calcSpaceFraction=function(){return this.opts.space},oc.prototype.getAromRadius=function(){return this.opts.aromrad},oc.prototype.showAromaticLoops=function(){return this.opts.showarom},oc.prototype.drawMultiorderBonds=function(){return this.opts.multibond},oc.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gf.deriveClass(ac,rc,{id:"BS",name:"Balls and Sticks",shortName:"Balls",depGroups:["AtomsSpheres","BondsCylinders","ALoopsTorus"]}),ac.prototype.calcAtomRadius=function(t){return t.element.radius*this.opts.atom},ac.prototype.calcStickRadius=function(){return this.opts.bond},ac.prototype.getAromRadius=function(){return this.opts.aromrad},ac.prototype.showAromaticLoops=function(){return this.opts.showarom},ac.prototype.calcSpaceFraction=function(){return this.opts.space},ac.prototype.drawMultiorderBonds=function(){return this.opts.multibond},ac.prototype.getLabelOpts=function(){return{fg:"none",bg:"0x202020",showBg:!1,labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0}},gf.deriveClass(sc,ec,{id:"VW",name:"Van der Waals",shortName:"VDW",depGroups:["AtomsSpheres"]}),sc.prototype.calcAtomRadius=function(t){return t.element.radius},gf.deriveClass(cc,ec,{id:"TR",name:"Trace",shortName:"Trace",depGroups:["TraceChains"]}),cc.prototype.calcStickRadius=function(){return this.opts.radius},gf.deriveClass(lc,ec,{id:"TU",name:"Tube",shortName:"Tube",depGroups:["CartoonChains"]}),lc.prototype.getResidueRadius=function(t){return this.TUBE_RADIUS},lc.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},lc.prototype.getTension=function(){return this.opts.tension},lc.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius;return this.TUBE_RADIUS=new n(o,o),ec.prototype.buildGeometry.call(this,t,e,r,i)},gf.deriveClass(uc,ec,{id:"CA",name:"Cartoon",shortName:"Cartoon",depGroups:["CartoonChains","NucleicSpheres","NucleicCylinders"]}),uc.prototype.getResidueStartRadius=function(t){var e=t.getSecondary();if(!e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?r.start:r.center:this.TUBE_RADIUS},uc.prototype.getResidueEndRadius=function(t){var e=t.getSecondary();if(null===e||!e.type)return this.TUBE_RADIUS;var r=this.secCache[e.type];return r?e._end===t?this.ARROW_END:r.center:this.TUBE_RADIUS},uc.prototype.getResidueRadius=function(t,e){var r=this.getResidueStartRadius(t);if(0===e)return r;var n=this.getResidueEndRadius(t);return 2===e?n:r.clone().lerp(n,e/2)},uc.prototype.calcStickRadius=function(t){return this.opts.radius},uc.prototype.getHeightSegmentsRatio=function(){return this.opts.heightSegmentsRatio},uc.prototype.getTension=function(){return this.opts.tension},uc.prototype.buildGeometry=function(t,e,r,i){var o=this.opts.radius,a=this.opts.depth;this.TUBE_RADIUS=new n(o,o),this.ARROW_END=new n(a,o);var s={},c=this.opts.ss;for(var l in c)s[l]={center:new n(a,c[l].width),start:new n(a,c[l].arrow)};return this.secCache=s,ec.prototype.buildGeometry.call(this,t,e,r,i)};var Am=xd.selectors;gf.deriveClass(pc,ec,{isSurface:!0,surfaceNames:[]}),pc.prototype.calcAtomRadius=function(t){return t.element.radius},pc.prototype.getVisibilitySelector=function(){var t=null;if(""!==this.opts.subset){var e=Am.parse(this.opts.subset);e.error||(t=e.selector)}return t},gf.deriveClass(fc,pc,{id:"QS",name:"Quick Surface",shortName:"Quick Surf",surfaceNames:["QuickSurfGeo"]}),fc.prototype.getSurfaceOpts=function(){return{useBeads:!1,isoValue:this.opts.isoValue,gaussLim:this.opts.gaussLim[this.settings.now.resolution],radScale:this.opts.scale,gridSpacing:this.opts.gridSpacing[this.settings.now.resolution],zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},gf.deriveClass(dc,pc,{id:"SU",name:"Surface",shortName:"Surface",surfaceNames:["SASSESSurfaceGeo"]}),dc.prototype._radScale=1,dc.prototype._isVertexNormalsRendered=!1,dc.prototype._isSurfaceTransparent=!1,dc.prototype._clusterViaKMeans=0,dc.prototype._excludeProbe=!1,dc.prototype.calcAtomRadius=function(t){return t.element.radius},dc.prototype.getSurfaceOpts=function(){return{gridSpacing:this.opts.polyComplexity[this.settings.now.resolution],radScale:this._radScale,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector(),probeRadius:this.opts.probeRadius,excludeProbe:this._excludeProbe,clusterizationType:this._clusterViaKMeans}},gf.deriveClass(mc,dc,{id:"SA",name:"Solvent Accessible Surface",shortName:"SAS"}),gf.deriveClass(gc,dc,{id:"SE",name:"Solvent Excluded Surface",shortName:"SES"}),gf.deriveClass(vc,pc,{id:"CS",name:"Contact Surface",shortName:"Contact Surf",isSurface:!0,surfaceNames:["ContactSurfaceGeo"]}),vc.prototype.getSurfaceOpts=function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}},gf.deriveClass(yc,ec,{id:"TX",name:"Text mode",shortName:"Text",depGroups:["TextLabelsGeo"]}),yc.prototype.getTemplateOptions=function(){return this.opts.template},yc.prototype.getLabelOpts=function(){return _.merge(this.opts,{labels:this.settings.now.labels,colors:!0,adjustColor:!0,transparent:!0})};var Em=[],Cm={};!function(t){for(var e=0,r=t.length;e=256?e-256:e))%this.chainColors.length,this.chainColors[e]},getSecondaryColor:function(t,e){var r=this.secondaryColors[t];return r instanceof Object&&(r=r[e]),void 0===r?this.defaultSecondaryColor:r},getSequentialColor:function(t){var e=this.colors,r=e.length;return t<0?e[t%r+r]:e[t%r]},getGradientColor:function(t,e){var r=this.gradients[e];if(r){var n=r.length,i=t*(n-1),o=Math.floor(i),a=_c(o+1,0,n-1);return o=_c(o,0,n-1),xc(r[o],r[a],i-o)}return this.defaultNamedColor},getNamedColor:function(t,e){var r=this.namedColors[t];return void 0!==r||e?r:this.defaultNamedColor}}).namedColorsArray,Lm=bc.prototype.namedColors,Rm=0,Nm=Pm.length;Rm=0?this.opts.carbon:this.palette.getElementColor(r)},Sc.prototype.getResidueColor=function(t,e){return this.palette.defaultResidueColor},gf.deriveClass(Mc,wc,{id:"RT",name:"Residue Type",shortName:"Residue"}),Mc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Mc.prototype.getResidueColor=function(t,e){return this.palette.getResidueColor(t._type._name)},gf.deriveClass(Ac,wc,{id:"SQ",aliases:["RI"],name:"Sequence",shortName:"Sequence"}),Ac.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ac.prototype.getResidueColor=function(t,e){var r=t._chain,n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((t._sequence-n)/(i-n),this.opts.gradient)},gf.deriveClass(Ec,wc,{id:"CH",name:"Chain",shortName:"Chain"}),Ec.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ec.prototype.getResidueColor=function(t,e){return this.palette.getChainColor(t.getChain()._name)},gf.deriveClass(Cc,wc,{id:"SS",name:"Secondary Structure",shortName:"Structure"}),Cc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Cc.prototype.getResidueColor=function(t,e){if(t._type.flags&so.Flags.DNA)return this.palette.getSecondaryColor("dna");if(t._type.flags&so.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=t.getSecondary();return r?this.palette.getSecondaryColor(r.type,r._type):this.palette.getSecondaryColor("")},gf.deriveClass(Tc,wc,{id:"UN",name:"Uniform",shortName:"Uniform"}),Tc.prototype.getAtomColor=function(t,e){return this.opts.color},Tc.prototype.getResidueColor=function(t,e){return this.opts.color},gf.deriveClass(Pc,wc,{id:"CO",name:"Conditional",shortName:"Conditional"}),Pc.prototype.getAtomColor=function(t,e){return this._subsetCached.includesAtom(t)?this.opts.color:this.opts.baseColor},Pc.prototype.getResidueColor=function(t,e){for(var r=this._subsetCached,n=!0,i=t._atoms,o=0,a=i.length;o0){var i=(n-r.min)/(r.max-r.min);return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},gf.deriveClass(Nc,wc,{id:"OC",name:"Occupancy",shortName:"Occupancy"}),Nc.prototype.getAtomColor=function(t,e){var r=this.opts;if(t._occupancy&&r){var n=1-t._occupancy;return this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultElementColor},Nc.prototype.getResidueColor=function(t,e){var r=this.opts;if(!r)return this.palette.defaultResidueColor;var n=-1;if(t.forEachAtom(function(t){t._occupancy&&t._role===xd.Element.Constants.Lead&&(n=t._occupancy)}),n>0){var i=1-n;return this.palette.getGradientColor(i,r.gradient)}return this.palette.defaultResidueColor},gf.deriveClass(Ic,wc,{id:"HY",name:"Hydrophobicity",shortName:"Hydrophobicity"}),Ic.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Ic.prototype.getResidueColor=function(t,e){var r=this.palette.defaultResidueColor;if(t._type.hydrophobicity){r=this.palette.getGradientColor((t._type.hydrophobicity- -4.5)/9,this.opts.gradient)}return r},gf.deriveClass(Oc,wc,{id:"MO",name:"Molecule",shortName:"Molecule"}),Oc.prototype.getAtomColor=function(t,e){return this.getResidueColor(t._residue,e)},Oc.prototype.getResidueColor=function(t,e){var r=t._molecule,n=e.getMoleculeCount();return n>1?this.palette.getGradientColor((r._index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)};var Gm=[],Wm={};!function(t){for(var e=0,r=t.length;e0){(e=new Ae).matrixAutoUpdate=!1,e.matrix=this.geo.matrix;for(var n=0;n2)return ff.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<0?this._reprList[0]:null,this._selectionBit=t.length,this._reprUsedBits|=1<=0&&tthis._reprList.length)return ff.error("Rep "+t+" does not exist!"),null;t===this._reprList.length&&(this.repAdd(e),e=void 0,ff.warn("Rep "+t+" does not exist! New representation was created."));var r=this._reprList[t],n={selector:r.selectorString,mode:r.mode.identify(),colorer:r.colorer.identify(),material:r.materialPreset.id};if(e){var i=!1;if(e.selector){var o=Qm.parse(e.selector).selector,a=String(o);n.selector!==a&&(r.selectorString=n.selector=a,r.selector=o,r.markAtoms(this._complex),i=!0,ff.debug("rep["+t+"].selector changed to"+a))}if(e.mode){var s=e.mode;wu.isEqual(n.mode,s)||(n.mode=s,r.setMode(Tm.create(e.mode)),i=!0,ff.debug("rep["+t+"].mode changed to "+s),!r.mode.isSurface||"ultra"!==_f.now.resolution&&"high"!==_f.now.resolution||(ff.report('Surface resolution was changed to "medium" to avoid hang-ups.'),_f.now.resolution="medium"))}if(e.colorer){var c=e.colorer;wu.isEqual(n.colorer,c)||(n.colorer=c,r.colorer=Hm.create(e.colorer),i=!0,ff.debug("rep["+t+"].colorer changed to "+c))}if(e.material){var l=e.material;wu.isEqual(n.material,l)||(n.material=l,r.setMaterialPreset(Zm.get(e.material)),i=!0,ff.debug("rep["+t+"].material changed to"+l))}i&&(r.needsRebuild=!0)}return n},Vc.prototype.repGet=function(t){return(void 0===t||t instanceof Object)&&(t=this.repCurrent()),t<0||t>=this._reprList.length?null:this._reprList[t]},Vc.prototype._getFreeReprIdx=function(){for(var t=this._reprUsedBits,e=0;e<32;++e,t>>=1)if(0==(1&t))return e;return-1},Vc.prototype.repAdd=function(t){if(this._reprList.length>=this.getMaxRepresentationCount())return-1;var e=this._getFreeReprIdx();if(e<0)return-1;var r=this.buildSelectorFromMask(1<=e||e<=1)){var r=this._reprList[t];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<=this._reprList.length||this._reprList[t].show(!e)},Vc.prototype.select=function(t,e){e?this._selectionCount+=this._complex.markAtomsAdditionally(t,1<0&&(a=Qm.chain(r),o=o?Qm.or(o,a):a),Object.keys(e).length>0)for(var s in e)e.hasOwnProperty(s)&&(a=Qm.and(Qm.chain(s),Qm.residx(n(e[s]))),o=o?Qm.or(o,a):a);t.length>0&&(a=Qm.serial(n(t)),o=o?Qm.or(o,a):a),o||(o=Qm.none())}return o},Vc.prototype.buildSelectorFromMask=function(t){var e=this._complex,r=[],n={},i=[];return e.forEachChain(function(e){e._mask&t&&r.push(e._name)}),e.forEachResidue(function(e){if(e._mask&t&&!(e._chain._mask&t)){var r=e._chain._name;r in n?n[r].push(e._index):n[r]=[e._index]}}),e.forEachAtom(function(e){e._mask&t&&!(e._residue._mask&t)&&i.push(e._serial)}),this._buildSelectorFromSortedLists(i,n,r)},Vc.prototype.getSelectedComponent=function(){var t=1<=0):n<8+d.indices.length&&(this.cullFlag[n]=!0);var y=this.geometry.getAttribute("position"),_=0;for(n=0;n=3&&(h+=3*(r.indices.length-2));var p=0,f=new Uint16Array(h);for(e=0;ee&&(n._prof.end(),n._prof.start(),++i),c>r||i===t?a(Math.max(i,0)):requestAnimationFrame(s)}requestAnimationFrame(s)})},Xc.prototype.mean=function(){return this._prof?this._prof.rawMean():0},Xc.prototype.min=function(){return this._prof?this._prof.min():0},Yc.prototype.abort=function(){this._agent.abort()},ha(Yc.prototype),Yc.addCommonHandlers=function(t,e){e.error&&(t.addEventListener("error",function(){e.error("OnError() event fired while loading")}),t.addEventListener("abort",function(){e.error("OnAbort() event fired while loading")})),e.progress&&t.addEventListener("progress",function(t){t.lengthComputable?e.progress(t.loaded/t.total):e.progress()})},(qc.prototype=Object.create(Yc.prototype)).constructor=qc,qc.prototype.load=function(t){var e=new FileReader;this._agent=e,t.ready&&e.addEventListener("load",function(e){t.ready(e.target.result)}),Yc.addCommonHandlers(e,t),this._binary?e.readAsArrayBuffer(this._source):e.readAsText(this._source)},qc.canLoad=function(t,e){var r=e.sourceType;return t instanceof File&&(!r||"file"===r)},($c.prototype=Object.create(Yc.prototype)).constructor=$c,$c.prototype.load=function(t){var e=this._source,r=new XMLHttpRequest;this._agent=r,t.ready&&r.addEventListener("load",function(){200===r.status?t.ready(r.response):t.error&&t.error("HTTP "+r.status+" while fetching "+e)}),Yc.addCommonHandlers(r,t),r.open("GET",e),this._binary?r.responseType="arraybuffer":r.responseType="text",r.send()},$c.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(!r||"url"===r)},(Zc.prototype=Object.create(Yc.prototype)).constructor=Zc,Zc.prototype.load=function(t){t.progress&&t.progress(0),this._options.data&&null!==this._options.data&&""!==this._options.data||t.error&&t.error("No data found!"),t.progress&&t.progress(.5),this._options.dataType&&null!==this._options.dataType&&""!==this._options.dataType||t.error&&t.error("No dataType found!"),t.progress&&t.progress(1),t.ready&&t.ready(this._options.data)},Zc.canLoad=function(t,e){var r=e.sourceType;return"string"==typeof t&&(3===t.indexOf(":",0)||"message"===r)};var rg=[];!function(t){for(var e=0,r=t.length;e0&&e.addChain(h)}else"BIOMOLECULE:"===t.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=e=new ig(this._complex),this.assemblies.push(e))};var og="\n".length,ag=function(){function t(e){bf(this,t),this._data=e,this._start=0,this._next=-og,this._end=e.length,this.next()}return wf(t,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(t){return(t=this._start+t-1)=this._end}},{key:"next",value:function(){var t=this._next+og;this._start=t0?e:this._end}}]),t}(),sg=xd.Complex,cg=xd.Element,lg=xd.Helix,ug=xd.Sheet,hg=xd.Strand,pg=xd.Bond,fg=xd.Molecule;(el.prototype=Object.create(Kc.prototype)).constructor=el,el.canParse=function(t,e){return!!t&&("string"==typeof t&&(Kc.checkDataTypeOptions(e,"pdb")||Kc.checkDataTypeOptions(e,"pdb",".ent")))},el.prototype._finalize=function(){this._fixBondsArray(),this._fixChains();var t=this._remarks[290];this._complex.symmetry=wu.isUndefined(t)?[]:t.matrices;var e=this._remarks[350];this._complex.structures=this._complex.structures.concat(wu.isUndefined(e)?[]:e.assemblies),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})},el.prototype._finalizeMolecules=function(){var t,e={},r=this._complex._chains;for(t=0;te&&a.addBond(e,r,0,pg.BondType.UNKNOWN,!0),n&&n>e&&a.addBond(e,n,0,pg.BondType.UNKNOWN,!0),i&&i>e&&a.addBond(e,i,0,pg.BondType.UNKNOWN,!0),o&&o>e&&a.addBond(e,o,0,pg.BondType.UNKNOWN,!0)},el.prototype._parseCOMPND=function(t){var e=t.readString(11,80),r=e.indexOf(":");if(this._compndCurrToken=r>0?e.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(e.substring(r+1,e.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=e.substring(r+1,e.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=e.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}};var dg={290:Qc,350:Jc};el.prototype._parseREMARK=function(t){var e=t.readInt(8,10),r=this._remarks[e];if(wu.isUndefined(r)){var n=dg[e];wu.isFunction(n)&&(this._remarks[e]=r=new n(this._complex))}wu.isUndefined(r)||r.parse(t)},el.prototype._parseHELIX=function(t){var e=[20,22,32,34];this._parseSTRUCTURE(t,e,function(t){this._complex.addHelix(t)}.bind(this))},el.prototype._parseSHEET=function(t){var e=[22,23,33,34];this._parseSTRUCTURE(t,e,function(t){this._complex.addSheet(t)}.bind(this))},el.prototype._parseSTRUCTURE=function(t,e,r){var n=t.readInt(8,10),i=t.readString(12,14).trim(),o=t.readString(41,70).trim(),a=t.readInt(72,76),s=t.readInt(39,40),c=t.readInt(15,16),l=t.readInt(42,45),u=t.readInt(57,60),h=t.readString(e[0],e[2]+1).charCodeAt(0),p=t.readString(e[2],e[2]+1).charCodeAt(0),f=t.readInt(e[1],e[1]+3),d=t.readString(e[1]+4,e[1]+4),m=0;d.length>0&&(m=d.charCodeAt(0));var g=t.readInt(e[3],e[3]+3),v=0;(d=t.readString(e[3]+4,e[3]+4)).length>0&&(v=d.charCodeAt(0));var y,_=this._sheet;if(83===t.readCharCode(1)){null!==_&&_.getName()!==i&&(_=null,this._sheet=null),null===_?(this._sheet=y=new ug(i,c),r(y)):y=_;var x=new hg(y,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,l,u);y.addStrand(x)}else r(y=new lg(n,i,this._complex.getUnifiedSerial(h,f,m),this._complex.getUnifiedSerial(p,g,v),s,o,a))},el.prototype._parseHEADER=function(t){var e=this._complex.metadata;e.classification=t.readString(11,50).trim(),e.date=t.readString(51,59).trim();var r=t.readString(63,66).trim();e.id=r,r&&(this._complex.name=r)},el.prototype._parseTITLE=function(t){var e=this._complex.metadata;e.title=e.title||[];var r=t.readInt(9,10)||1;e.title[r-1]=t.readString(11,80).trim()};var mg={HEADER:el.prototype._parseHEADER,"TITLE ":el.prototype._parseTITLE,"ATOM ":el.prototype._parseATOM,HETATM:el.prototype._parseATOM,ENDMDL:el.prototype._parseENDMDL,CONECT:el.prototype._parseCONECT,COMPND:el.prototype._parseCOMPND,REMARK:el.prototype._parseREMARK,"HELIX ":el.prototype._parseHELIX,"SHEET ":el.prototype._parseSHEET,"ATOM 1":el.prototype._parseATOM,"ATOM 2":el.prototype._parseATOM,"ATOM 3":el.prototype._parseATOM,"ATOM 4":el.prototype._parseATOM,"ATOM 5":el.prototype._parseATOM,"ATOM 6":el.prototype._parseATOM,"ATOM 7":el.prototype._parseATOM,"ATOM 8":el.prototype._parseATOM,"ATOM 9":el.prototype._parseATOM};el.prototype._parse=function(t){for(var e=new ag(this._data),r=this._complex=new sg;!e.end();){var n=e.readString(1,6),i=mg[n];wu.isFunction(i)&&i.call(this,e),e.next()}this.hasOwnProperty("_abort")?t.error(new Error("Aborted")):(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0!==r.getAtomCount()?this.hasOwnProperty("_abort")?t.error(new Error("Aborted")):t.ready(r):t.error(new Error("Loaded file does not contain valid atoms.
Loading as empty...")))};var gg=xd.Complex;(rl.prototype=Object.create(Kc.prototype)).constructor=rl,rl.prototype.parse=function(t){var e=this._complex=new gg;this._complex=null,t.ready(e)},rl.canParse=function(t,e){return!!t&&("string"==typeof t&&Kc.checkDataTypeOptions(e,"mol"))};var vg=xd.Complex,yg=xd.Element,_g=xd.AtomName,xg=xd.SGroup,bg=xd.Bond,wg={A:0,S:1,D:2,T:3};(nl.prototype=Object.create(Kc.prototype)).constructor=nl,nl.canParse=function(t,e){if(!t)return!1;var r=new RegExp("^\\s*?\\<\\?xml"),n=new RegExp("^\\s*?\\1)c[a].order=h;else{var p=wg[u];void 0!==p&&(c[a].order=p,"A"===u&&(c[a].type=bg.BondType.AROMATIC))}}for(s=e.length,a=0;a1&&s.splice(1,s.length-1),s.forEach(function(t){var r=e(t);r.atoms.length>0&&a.push(r)}),a},nl.prototype._packLabel=function(t,e){return(e<<16)+t},nl.prototype._unpackLabel=function(t){return{molId:t>>>16,compId:65535&t}},nl.prototype._breadWidthSearch=function(t,e){var r,n=new Array(t.length);for(r=0;r0;){o++;var s=-1;for(r=0;r0;){var c=i.shift();if(c)for(var l=0;l=0){var i=[Math.min(t,e),Math.max(t,e)];this._complex.addBond(i[0],i[1],r,n,!0)}},nl.prototype._fixBondsArray=function(){for(var t=this._serialAtomMap={},e=this._complex,r=e._atoms,n=0,i=r.length;n Loading as empty..."));else if(this.hasOwnProperty("_abort"))t.error(new Error("Aborted"));else{if(e.length>1){var i=new vg;i.joinComplexes(e),i.originalCML=e[0].originalCML,t.ready(i)}1===e.length&&t.ready(e[0]),0===e.length&&t.ready(new vg)}};var Sg=e(function(t,e){!function(t,r){r(e)}(0,function(t){function e(t,e,r){for(var n=(t.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)t.setUint8(e++,o>>>0&127|0);else if(2048>o)t.setUint8(e++,o>>>6&31|192),t.setUint8(e++,o>>>0&63|128);else if(65536>o)t.setUint8(e++,o>>>12&15|224),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);t.setUint8(e++,o>>>18&7|240),t.setUint8(e++,o>>>12&63|128),t.setUint8(e++,o>>>6&63|128),t.setUint8(e++,o>>>0&63|128)}}}function r(t){for(var e=0,r=0,n=t.length;n>r;r++){var i=t.charCodeAt(r);if(128>i)e+=1;else if(2048>i)e+=2;else if(65536>i)e+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);e+=4}}return e}function n(t,i,o){var a=typeof t;if("string"===a){if(32>(s=r(t)))return i.setUint8(o,160|s),e(i,o+1,t),1+s;if(256>s)return i.setUint8(o,217),i.setUint8(o+1,s),e(i,o+2,t),2+s;if(65536>s)return i.setUint8(o,218),i.setUint16(o+1,s),e(i,o+3,t),3+s;if(4294967296>s)return i.setUint8(o,219),i.setUint32(o+1,s),e(i,o+5,t),5+s}if(t instanceof Uint8Array){var s=t.byteLength,c=new Uint8Array(i.buffer);if(256>s)return i.setUint8(o,196),i.setUint8(o+1,s),c.set(t,o+2),2+s;if(65536>s)return i.setUint8(o,197),i.setUint16(o+1,s),c.set(t,o+3),3+s;if(4294967296>s)return i.setUint8(o,198),i.setUint32(o+1,s),c.set(t,o+5),5+s}if("number"===a){if(!isFinite(t))throw new Error("Number not finite: "+t);if(Math.floor(t)!==t)return i.setUint8(o,203),i.setFloat64(o+1,t),9;if(t>=0){if(128>t)return i.setUint8(o,t),1;if(256>t)return i.setUint8(o,204),i.setUint8(o+1,t),2;if(65536>t)return i.setUint8(o,205),i.setUint16(o+1,t),3;if(4294967296>t)return i.setUint8(o,206),i.setUint32(o+1,t),5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return i.setInt8(o,t),1;if(t>=-128)return i.setUint8(o,208),i.setInt8(o+1,t),2;if(t>=-32768)return i.setUint8(o,209),i.setInt16(o+1,t),3;if(t>=-2147483648)return i.setUint8(o,210),i.setInt32(o+1,t),5;throw new Error("Number too small -0x"+(-t).toString(16).substr(1))}if(null===t)return i.setUint8(o,192),1;if("boolean"===a)return i.setUint8(o,t?195:194),1;if("object"===a){var l=0,u=Array.isArray(t);if(u)s=t.length;else{var h=Object.keys(t);s=h.length}if(16>s?(i.setUint8(o,s|(u?144:128)),l=1):65536>s?(i.setUint8(o,u?220:222),i.setUint16(o+1,s),l=3):4294967296>s&&(i.setUint8(o,u?221:223),i.setUint32(o+1,s),l=5),u)for(p=0;s>p;p++)l+=n(t[p],i,o+l);else for(var p=0;s>p;p++){var f=h[p];l+=n(f,i,o+l),l+=n(t[f],i,o+l)}return l}throw new Error("Unknown type "+a)}function i(t){var e=typeof t;if("string"===e){if(32>(n=r(t)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(t instanceof Uint8Array){if(256>(n=t.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===e){if(Math.floor(t)!==t)return 9;if(t>=0){if(128>t)return 1;if(256>t)return 2;if(65536>t)return 3;if(4294967296>t)return 5;throw new Error("Number too big 0x"+t.toString(16))}if(t>=-32)return 1;if(t>=-128)return 2;if(t>=-32768)return 3;if(t>=-2147483648)return 5;throw new Error("Number too small -0x"+t.toString(16).substr(1))}if("boolean"===e||null===t)return 1;if("object"===e){var n,o=0;if(Array.isArray(t)){n=t.length;for(s=0;n>s;s++)o+=i(t[s])}else{var a=Object.keys(t);n=a.length;for(var s=0;n>s;s++){var c=a[s];o+=i(c)+i(t[c])}}if(16>n)return 1+o;if(65536>n)return 3+o;if(4294967296>n)return 5+o;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+e)}function o(t){var e=new ArrayBuffer(i(t));return n(t,new DataView(e),0),new Uint8Array(e)}function a(t,e,r){return e?new t(e.buffer,e.byteOffset,e.byteLength/(r||1)):void 0}function s(t){return a(DataView,t)}function c(t){return a(Uint8Array,t)}function l(t){return a(Int8Array,t)}function u(t){return a(Int32Array,t,4)}function h(t){return a(Float32Array,t,4)}function p(t,e){var r=t.length/2;e||(e=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)e[n]=t[i]<<8^t[i+1]<<0;return e}function f(t,e){var r=t.length;e||(e=new Uint8Array(2*r));for(var n=s(e),i=0;r>i;++i)n.setInt16(2*i,t[i]);return c(e)}function d(t,e){var r=t.length/4;e||(e=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)e[n]=t[i]<<24^t[i+1]<<16^t[i+2]<<8^t[i+3]<<0;return e}function m(t,e){var r=t.length;e||(e=new Uint8Array(4*r));for(var n=s(e),i=0;r>i;++i)n.setInt32(4*i,t[i]);return c(e)}function g(t,e){var r=t.length;e||(e=new Float32Array(r/4));for(var n=s(e),i=s(t),o=0,a=0,c=r/4;c>o;++o,a+=4)n.setFloat32(a,i.getFloat32(a),!0);return e}function v(t,e,r){var n=t.length,i=1/e;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=t[o]*i;return r}function y(t,e,r){var n=t.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(t[i]*e);return r}function _(t,e){var r,n;if(!e){var i=0;for(r=0,n=t.length;n>r;r+=2)i+=t[r+1];e=new t.constructor(i)}var o=0;for(r=0,n=t.length;n>r;r+=2)for(var a=t[r],s=t[r+1],c=0;s>c;++c)e[o]=a,++o;return e}function x(t){if(0===t.length)return new Int32Array;var e,r,n=2;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]&&(n+=2);var i=new Int32Array(n),o=0,a=1;for(e=1,r=t.length;r>e;++e)t[e-1]!==t[e]?(i[o]=t[e-1],i[o+1]=a,a=1,o+=2):++a;return i[o]=t[t.length-1],i[o+1]=a,i}function b(t,e){var r=t.length;e||(e=new t.constructor(r)),r&&(e[0]=t[0]);for(var n=1;r>n;++n)e[n]=t[n]+e[n-1];return e}function w(t,e){var r=t.length;e||(e=new t.constructor(r)),e[0]=t[0];for(var n=1;r>n;++n)e[n]=t[n]-t[n-1];return e}function S(t,e){var r,n,i=t instanceof Int8Array?127:32767,o=-i-1,a=t.length;if(!e){var s=0;for(r=0;a>r;++r)t[r]o&&++s;e=new Int32Array(s)}for(r=0,n=0;a>r;){for(var c=0;t[r]===i||t[r]===o;)c+=t[r],++r;c+=t[r],++r,e[n]=c,++n}return e}function M(t,e){var r,n=e?127:32767,i=-n-1,o=t.length,a=0;for(r=0;o>r;++r)0===(l=t[r])?++a:a+=l===n||l===i?2:l>0?Math.ceil(l/n):Math.ceil(l/i);var s=e?new Int8Array(a):new Int16Array(a),c=0;for(r=0;o>r;++r){var l=t[r];if(l>=0)for(;l>=n;)s[c]=n,++c,l-=n;else for(;i>=l;)s[c]=i,++c,l-=i;s[c]=l,++c}return s}function A(t,e){return b(_(t),e)}function E(t){return x(w(t))}function C(t,e,r){return v(_(t,u(r)),e,r)}function T(t,e){return x(y(t,e))}function P(t,e,r){return v(b(t,u(r)),e,r)}function L(t,e,r){return w(y(t,e),r)}function R(t,e,r){return v(S(t,u(r)),e,r)}function N(t,e,r){var n=S(t,u(r));return P(n,e,h(n))}function I(t,e,r){return M(L(t,e),r)}function O(t){var e=s(t),r=e.getInt32(0),n=e.getInt32(4),i=t.subarray(8,12);return[r,t=t.subarray(12),n,i]}function D(t,e,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),a=new DataView(i);return a.setInt32(0,t),a.setInt32(4,e),r&&o.set(r,8),o.set(n,12),o}function z(t){return D(2,t.length,void 0,c(t))}function k(t){return D(4,t.length,void 0,m(t))}function F(t,e){return D(5,t.length/e,m([e]),c(t))}function U(t){return D(6,t.length,void 0,m(x(t)))}function B(t){return D(8,t.length,void 0,m(E(t)))}function V(t,e){return D(9,t.length,m([e]),m(T(t,e)))}function j(t,e){return D(10,t.length,m([e]),f(I(t,e)))}function G(t){var e={};return Z.forEach(function(r){void 0!==t[r]&&(e[r]=t[r])}),t.bondAtomList&&(e.bondAtomList=k(t.bondAtomList)),t.bondOrderList&&(e.bondOrderList=z(t.bondOrderList)),e.xCoordList=j(t.xCoordList,1e3),e.yCoordList=j(t.yCoordList,1e3),e.zCoordList=j(t.zCoordList,1e3),t.bFactorList&&(e.bFactorList=j(t.bFactorList,100)),t.atomIdList&&(e.atomIdList=B(t.atomIdList)),t.altLocList&&(e.altLocList=U(t.altLocList)),t.occupancyList&&(e.occupancyList=V(t.occupancyList,100)),e.groupIdList=B(t.groupIdList),e.groupTypeList=k(t.groupTypeList),t.secStructList&&(e.secStructList=z(t.secStructList,1)),t.insCodeList&&(e.insCodeList=U(t.insCodeList)),t.sequenceIndexList&&(e.sequenceIndexList=B(t.sequenceIndexList)),e.chainIdList=F(t.chainIdList,4),t.chainNameList&&(e.chainNameList=F(t.chainNameList,4)),e}function W(t){function e(t){for(var e={},r=0;t>r;r++)e[o()]=o();return e}function r(e){var r=t.subarray(a,a+e);return a+=e,r}function n(e){var r=t.subarray(a,a+e);a+=e;var n=65535;if(e>n){for(var i=[],o=0;or;r++)e[r]=o();return e}function o(){var o,c,l=t[a];if(0==(128&l))return a++,l;if(128==(240&l))return c=15&l,a++,e(c);if(144==(240&l))return c=15&l,a++,i(c);if(160==(224&l))return c=31&l,a++,n(c);if(224==(224&l))return o=s.getInt8(a),a++,o;switch(l){case 192:return a++,null;case 194:return a++,!1;case 195:return a++,!0;case 196:return c=s.getUint8(a+1),a+=2,r(c);case 197:return c=s.getUint16(a+1),a+=3,r(c);case 198:return c=s.getUint32(a+1),a+=5,r(c);case 202:return o=s.getFloat32(a+1),a+=5,o;case 203:return o=s.getFloat64(a+1),a+=9,o;case 204:return o=t[a+1],a+=2,o;case 205:return o=s.getUint16(a+1),a+=3,o;case 206:return o=s.getUint32(a+1),a+=5,o;case 208:return o=s.getInt8(a+1),a+=2,o;case 209:return o=s.getInt16(a+1),a+=3,o;case 210:return o=s.getInt32(a+1),a+=5,o;case 217:return c=s.getUint8(a+1),a+=2,n(c);case 218:return c=s.getUint16(a+1),a+=3,n(c);case 219:return c=s.getUint32(a+1),a+=5,n(c);case 220:return c=s.getUint16(a+1),a+=3,i(c);case 221:return c=s.getUint32(a+1),a+=5,i(c);case 222:return c=s.getUint16(a+1),a+=3,e(c);case 223:return c=s.getUint32(a+1),a+=5,e(c)}throw new Error("Unknown type 0x"+l.toString(16))}var a=0,s=new DataView(t.buffer);return o()}function H(t,e,r,n){switch(t){case 1:return g(e);case 2:return l(e);case 3:return p(e);case 4:return d(e);case 5:return c(e);case 6:return _(d(e),new Uint8Array(r));case 7:return _(d(e));case 8:return A(d(e));case 9:return C(d(e),d(n)[0]);case 10:return N(p(e),d(n)[0]);case 11:return v(p(e),d(n)[0]);case 12:return R(p(e),d(n)[0]);case 13:return R(l(e),d(n)[0]);case 14:return S(p(e));case 15:return S(l(e))}}function X(t,e){var r=(e=e||{}).ignoreFields,n={};return Q.forEach(function(e){var i=!!r&&-1!==r.indexOf(e),o=t[e];i||void 0===o||(o instanceof Uint8Array?n[e]=H.apply(null,O(o)):n[e]=o)}),n}function Y(t){return String.fromCharCode.apply(null,t).replace(/\0/g,"")}function q(t,e){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r;return r=t instanceof Uint8Array?W(t):t,X(r,e)}function $(t,e,r,n){var i=new XMLHttpRequest;i.addEventListener("load",function(){try{var t=q(i.response);r(t)}catch(t){n(t)}},!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",e+t.toUpperCase()),i.send()}var Z=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],K=["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"],Q=Z.concat(K),J="//mmtf.rcsb.org/v1.0/",tt=J+"full/",et=J+"reduced/";t.encode=function(t){return o(G(t))},t.decode=q,t.traverse=function(t,e,r){var n,i,o,a,s,c,l=(r=r||{}).firstModelOnly,u=e.onModel,h=e.onChain,p=e.onGroup,f=e.onAtom,d=e.onBond,m=0,g=0,v=0,y=0,_=0,x=-1,b=t.chainNameList,w=t.secStructList,S=t.insCodeList,M=t.sequenceIndexList,A=t.atomIdList,E=t.bFactorList,C=t.altLocList,T=t.occupancyList,P=t.bondAtomList,L=t.bondOrderList;for(n=0,i=t.chainsPerModel.length;i>n&&!(l&&m>0);++n){var R=t.chainsPerModel[m];for(u&&u({chainCount:R,modelIndex:m}),o=0;R>o;++o){var N=t.groupsPerChain[g];if(h){var I=Y(t.chainIdList.subarray(4*g,4*g+4)),O=null;b&&(O=Y(b.subarray(4*g,4*g+4))),h({groupCount:N,chainIndex:g,modelIndex:m,chainId:I,chainName:O})}for(a=0;N>a;++a){var D=t.groupList[t.groupTypeList[v]],z=D.atomNameList.length;if(p){var k=null;w&&(k=w[v]);var F=null;t.insCodeList&&(F=String.fromCharCode(S[v]));var U=null;M&&(U=M[v]),p({atomCount:z,groupIndex:v,chainIndex:g,modelIndex:m,groupId:t.groupIdList[v],groupType:t.groupTypeList[v],groupName:D.groupName,singleLetterCode:D.singleLetterCode,chemCompType:D.chemCompType,secStruct:k,insCode:F,sequenceIndex:U})}for(s=0;z>s;++s){if(f){var B=null;A&&(B=A[y]);var V=null;E&&(V=E[y]);var j=null;C&&(j=String.fromCharCode(C[y]));var G=null;T&&(G=T[y]),f({atomIndex:y,groupIndex:v,chainIndex:g,modelIndex:m,atomId:B,element:D.elementList[s],atomName:D.atomNameList[s],formalCharge:D.formalChargeList[s],xCoord:t.xCoordList[y],yCoord:t.yCoordList[y],zCoord:t.zCoordList[y],bFactor:V,altLoc:j,occupancy:G})}y+=1}if(d){var W=D.bondAtomList;for(s=0,c=D.bondOrderList.length;c>s;++s)d({atomIndex1:y-z+W[2*s],atomIndex2:y-z+W[2*s+1],bondOrder:D.bondOrderList[s]})}v+=1}g+=1}if(_=x+1,x=y-1,d&&P)for(s=0,c=P.length;c>s;s+=2){var H=P[s],X=P[s+1];(H>=_&&x>=H||X>=_&&x>=X)&&d({atomIndex1:H,atomIndex2:X,bondOrder:L?L[s/2]:null})}m+=1}},t.fetch=function(t,e,r){$(t,tt,e,r)},t.fetchReduced=function(t,e,r){$(t,et,e,r)},t.version="v1.1.0dev",t.fetchUrl=tt,t.fetchReducedUrl=et,t.encodeMsgpack=o,t.encodeMmtf=G,t.decodeMsgpack=W,t.decodeMmtf=X})}),Mg=xd.Complex,Ag=xd.Chain,Eg=xd.Atom,Cg=xd.AtomName,Tg=xd.Element,Pg=xd.Helix,Lg=xd.Sheet,Rg=xd.Strand,Ng=xd.Bond,Ig=xd.Assembly,Og=xd.Molecule;il.prototype.constructor=il,il.prototype.compare=function(t){var e=t.length;if(e!==this._original.length)return!1;var r,n=0;for(r=0;r=this._complex._atoms.length)){var r=Math.min(t.atomIndex1,t.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[e],t.bondOrder,Ng.BondType.UNKNOWN,!0)}},ol.prototype._updateSecStructure=function(t,e,r){var n=[3,-1,1,-1,5];if(!wu.isUndefined(r)&&r.secStruct===this._ssType)return e._secondary=this._ssStruct,void((this._ssStruct instanceof Pg||this._ssStruct instanceof Rg)&&this._ssStruct._residues.push(e));if(-1!==this._ssType&&(this._ssStruct instanceof Pg||this._ssStruct instanceof Rg)&&(this._ssStruct._end=this._ssStruct._residues[this._ssStruct._residues.length-1]),!wu.isUndefined(r)){this._ssType=r.secStruct,this._ssStart=e;var i=null;switch(this._ssType){case-1:break;case 0:case 2:case 4:i=new Pg(0,"",e,null,n[this._ssType],"",0),t._helices.push(i);break;case 3:var o=new Lg("",0);t._sheets.push(o),i=new Rg(o,e,null,0);break;default:i={type:"mmtf"+this._ssType}}this._ssStruct=i,e._secondary=i}},ol.prototype._updateMolecules=function(t){if(t)for(var e=0;e=e))for(var a=this._complex._chains[o],s=0;s0&&u.addChain(r[m])}u.matrices=h,t.structures.push(u)}}}},ll._parseToObject=function(t){function e(t){return 32===t||10===t||13===t||9===t}function r(t,e,r){for(var n=e.length,i=-1;r=c||e(t.charCodeAt(a+1)))){if(u&&59===l){s=a;var i=0;do{if(-1===(s=r(10,t,s+1)))return d="unterminated text block found",null;++i}while(s+1=c);return n=t.substring(a+1,s).replace(/\r/g,""),a=s+2,h+=i,p=1,u=!1,n}if(39===l||34===l){s=a;do{if(-1===(s=r(l,t,s+1)))return d="unterminated quoted string found",null}while(s+10){for(var w=0;w0&&(this._altObj.setObjects(s.objects),this._altObj.pivot=s.pivot,"axis"in s?this._altObj.axis=s.axis.clone():this._altObj.axis.set(0,0,1),this._altObj.translate(new n(a*i,a*o)),this.dispatchEvent({type:"change",action:"translate"}))}else a*=10*(_f.now.inversePanning?-1:1),this.camera.translateX(a*i),this.camera.translateY(a*o),this.dispatchEvent({type:"change",action:"pan"})}}this._lastUpdateTime=t},yl.prototype.reset=function(){this._state=$g.NONE,this.object.quaternion.copy(new c(0,0,0,1))},yl.prototype.mousedown=function(t){if(!1!==this.enabled&&this._state===$g.NONE){if(t.preventDefault(),t.stopPropagation(),this._state===$g.NONE)if(0===t.button){this._affectedObj.stop();var e=!1;if(t.altKey){var r=this.getAltObj();(e=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=e?this._altObj:this._mainObj,this._state=e&&t.ctrlKey&&this._isTranslationAllowed?$g.TRANSLATE:$g.ROTATE}else 2===t.button&&(this._state=$g.TRANSLATE_PIVOT);this._state===$g.ROTATE&&(this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos)),this._state!==$g.TRANSLATE&&this._state!==$g.TRANSLATE_PIVOT||(this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this._mousePrevPos.copy(this._mouseCurPos))}},yl.prototype.mousemove=function(t){if(!1!==this.enabled&&this._state!==$g.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case $g.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.pageX,t.pageY)),this.rotateByMouse(t.altKey&&!this._isAltObjFreeRotationAllowed||t.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case $g.TRANSLATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translate();break;case $g.TRANSLATE_PIVOT:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseViewport(t.pageX,t.pageY)),this.translatePivotByMouse()}},yl.prototype.mousewheel=function(t){if(!1!==this.enabled&&_f.now.zooming&&this._state===$g.NONE&&!t.shiftKey){t.preventDefault();var e=0;t.wheelDelta?e=t.wheelDelta/40:t.detail&&(e=-t.detail/3);var r=1+.05*e;this.scale(r),this.dispatchEvent({type:"change",action:"zoom",factor:r})}},yl.prototype.mouseup=function(t){!1!==this.enabled&&this._state!==$g.NONE&&(t.preventDefault(),t.stopPropagation(),this._state=$g.NONE,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},yl.prototype.touchstartend=function(t){if(!1!==this.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:this._state=$g.ROTATE,this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=$g.SCALE_PAN;var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(e*e+r*r),this._scaleStart=this.object.scale.x,this._originalPinchCenter=new n(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY)),this._originalCameraPos.copy(this.camera.position);break;default:this._state=$g.NONE}},yl.prototype.touchmove=function(t){if(!1!==this.enabled&&this._state!==$g.NONE)switch(t.preventDefault(),t.stopPropagation(),this._state){case $g.ROTATE:this._mousePrevPos.copy(this._mouseCurPos),this._mouseCurPos.copy(this.getMouseOnCircle(t.touches[0].pageX,t.touches[0].pageY)),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case $g.SCALE_PAN:if(_f.now.zooming){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY;this._touchDistanceCur=Math.sqrt(e*e+r*r);var i=this.object.scale.x,o=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart;this.setScale(o),this.dispatchEvent({type:"change",action:"zoom",factor:0===i?1:o/i})}if(_f.now.panning){var a=new n(.5*(t.touches[0].pageX+t.touches[1].pageX),.5*(t.touches[0].pageY+t.touches[1].pageY));a.sub(this._originalPinchCenter),this.camera.position.x=this._originalCameraPos.x-.1*a.x,this.camera.position.y=this._originalCameraPos.y+.1*a.y,this.dispatchEvent({type:"change",action:"pan"})}}},yl.prototype.keydownup=function(t){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(t.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[t.keyCode]="keydown"===t.type,t.preventDefault(),t.stopPropagation()}},yl.prototype.getKeyBindObject=function(){return window.top},yl.prototype.dispose=function(){for(var t=0;t0){var o=e[0],a=new l;if(_f.now.draft.clipPlane&&this.hasOwnProperty("clipPlaneValue")){var s;for(s=0;s=this._framesCount&&(t=0),this._buffer={state:"none"},this._prepareBuffer(t,t+this._framesRequestLength),null!==this._frameRequest){var e=this._frameRequest;this._frameRequest=null,this.setFrame(e)}}},Sl.prototype.parseBinaryData=function(t){var e=new DataView(t),r=0,n=e.getUint32(r,!0);r+=4;var i=e.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n;this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||t.byteLength!==12+o*n*8)throw new Error;for(var a=this._complex,s=e.getUint32(r,!0),c=0;s>1e3&&c>>28,y=wl((268435200&g)>>>8>>0),_=wl(((255&g)<<12|(4293918720&m)>>>20)>>0),x=wl((1048575&m)>>0);p[d]=0,v>0&&v<4?p[d]=1:4===v&&(p[d]=2),u[h++]=y/100,u[h++]=_/100,u[h++]=x/100}l.push(bl(p,a))}this._secondaryData=l,this._data=u},Sl.prototype.nextFrame=function(){this.setFrame((this._currFrame+1)%this._framesCount)},Sl.prototype.needsColorUpdate=function(t){return t instanceof Cc},Sl.prototype.getAtomColor=function(t,e){return t.getResidueColor(this._residues[e._residue._index],this._complex)},Sl.prototype.getResidueColor=function(t,e){return t.getResidueColor(this._residues[e._index],this._complex)},Sl.prototype._updateSecondary=function(){var t,e=this._residues,r=e.length;for(t=0;t=this._framesRange.start&&t<=this._framesRange.end)this._currFrame=t,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=t,this._buffer){var e=this;switch(this._buffer.state){case"none":this._prepareBuffer(t);break;case"ready":e._parseBuffer()}}else this._prepareBuffer(t)},Sl.prototype.disableEvents=function(){this._callbacks=null},Sl.prototype.getAtomPos=function(){var t=new l;return function(e){var r=this,n=r._data,i=3*(r._atomsCount*(r._currFrame-r._framesRange.start)+e);return t.set(n[i],n[i+1],n[i+2]),t}}(),Sl.prototype.getResidues=function(){return this._cachedResidues?this._residues:(this._complex.updateToFrame(this),this._residues)},Ml.prototype.type="__",Ml.prototype.identify=function(){var t={type:this.type,params:this.params},e=gf.objectsDiff(this.opts,_f.now.modes[this.id]);return wu.isEmpty(e)||(t.opts=e),t},Ml.prototype.toString=function(){return"o="+this.type+","+this.params.join(",")+gf.compareOptionsWithDefaults(this.opts,_f.defaults.objects[this.type])},Ml.prototype.getGeometry=function(){return this._mesh},Ml.prototype.destroy=function(){this._mesh&&Cd.destroyObject(this._mesh)},gf.deriveClass(Al,Ml,{type:"line"}),Al.prototype.constructor=Al,Al.prototype._getAtomFromName=function(t,e){var r=t.getAtomByFullname(e);if(!r)throw new Error(e+" - Wrong atom format it must be '#CHAIN_NAME.#NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r},Al.prototype.build=function(t){var e=new Tt;this._atom1=this._getAtomFromName(t,this._id1),this._atom2=this._getAtomFromName(t,this._id2),e.vertices[0]=this._atom1._position.clone(),e.vertices[1]=this._atom2._position.clone(),e.dynamic=!0,e.computeLineDistances(),e.computeBoundingBox(),this._line=new gm.Line(e,new oa({lights:!1,overrideColor:!0,dashedLine:!0})),this._line.material.setUberOptions({fixedColor:new Y(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(t,e){},this._mesh=this._line;var r=t.getTransforms();r.length>0&&(this._mesh=new Ae,this._mesh.add(this._line),Cd.applyTransformsToMeshes(this._mesh,r))},Al.prototype.updateToFrame=function(t){if(this._atom1&&this._atom2&&this._line){var e=this._line.geometry;e.vertices[0].copy(t.getAtomPos(this._atom1._index)),e.vertices[1].copy(t.getAtomPos(this._atom2._index)),e.computeLineDistances(),e.computeBoundingSphere(),e.verticesNeedUpdate=!0}};var tv="varying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n",ev="uniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = vec2(1, 1) / srcTexSize;\r\n\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = grad;\r\n}\r\n",rv=Dp.merge([{srcTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new n(512,512)},opacity:{type:"f",value:1}}]),nv="// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\nvec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {return texture2D( tex, pos + off * res ).xyz;}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {return texture2D( tex, pos).xyz;}\r\n//=====================================================================//\r\nvoid main() {\r\n// renaming\r\n vec2 posM = vUv;\r\n// get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n// find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n// calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n// exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n// calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0/spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\r\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\r\n gl_FragColor = vec4(FxaaTexTop(srcTex, posM).xyz, 1.0);\r\n return;\r\n}\r\n",iv=Dp.merge([{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)}}]),ov="#define MAX_SAMPLES_COUNT 32\r\n\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nuniform vec2 fogNearFar;\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (- projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n vec2 viewRay = vec2(projPos.x * aspectRatio * tanHalfFOV, projPos.y * tanHalfFOV); // TODO mode to vs\r\n // reconstruct viewposition in right-handed sc with z from viewer\r\n viewPos.xy = vec2(viewRay.x * viewPos.z, viewRay.y * viewPos.z);\r\n return viewPos;\r\n}\r\n\r\nvec3 GetDerivative( vec3 p0, vec3 p1, vec3 p2 )\r\n{\r\n vec3 v1 = p1 - p0;\r\n vec3 v2 = p0 - p2;\r\n return ( dot( v1, v1 ) < dot( v2, v2 ) ) ? v1 : v2;\r\n}\r\n\r\nvec3 RestoreNormalFromDepth(vec2 texcoords, vec3 p) {\r\n\r\n vec2 offset1 = vec2(srcTexelSize.x, 0.0);\r\n vec2 offset2 = vec2(0.0, srcTexelSize.y);\r\n\r\n vec3 p1 = ViewPosFromDepth(texcoords + offset1);\r\n vec3 p2 = ViewPosFromDepth(texcoords + offset2);\r\n vec3 p3 = ViewPosFromDepth(texcoords - offset1);\r\n vec3 p4 = ViewPosFromDepth(texcoords - offset2);\r\n\r\n vec3 dx = GetDerivative(p, p3, p1);\r\n vec3 dy = GetDerivative(p, p4, p2);\r\n vec3 normal = cross(dx, dy);\r\n return normalize(normal);\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n // restore normal from depth buffer\r\n vec3 normal = RestoreNormalFromDepth(vUv, viewPos); \r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n // project sample to screen to get sample's screen pos\r\n vec4 offset = vec4(samplePos, 1.0);\r\n offset = projMatrix * offset;\r\n offset.xy /= offset.w;\r\n offset.xy = (-offset.xy + vec2(1.0)) * 0.5;\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(offset.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // add fog to the AO value\r\n AO *= 1.0 - smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z);\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / 32.0 * factor); // TODO use MAX_SAMPLES_COUNT\r\n vec3 color = texture2D(diffuseTexture, vUv).rgb;\r\n // check if the fragment doesn't belong to background\r\n if (abs(- viewPos.z - camNearFar.y) < 0.1) { // FIXME remove temporal fix for background darkening\r\n gl_FragColor = vec4(1.0);\r\n return;\r\n }\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}",av="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )) * weight;\r\n weightSum += weight;\r\n }\r\n gl_FragColor = res / weightSum;\r\n}\r\n",sv="#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)) * weight;\r\n weightSum += weight;\r\n }\r\n res /= weightSum;\r\n vec3 color = texture2D(diffuseTexture, vec2(x, y)).rgb;\r\n gl_FragColor = vec4(color * res.rgb, 1.0);\r\n}",cv=Dp.merge([{noiseTexture:{type:"t",value:null},noiseTexelSize:{type:"v2",value:new n(1/512,1/512)},diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:null},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1},fogNearFar:{type:"v2",value:new n(100,100)}}]),lv=Dp.merge([{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new n(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:null},camNearFar:{type:"v2",value:new n(1,10)},projMatrix:{type:"mat4",value:new u},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0}}]),uv={AOMaterial:function(t){return new J({uniforms:Ll(t,cv),vertexShader:tv,fragmentShader:ov,transparent:!1,depthTest:!1,depthWrite:!1})},HorBilateralBlurMaterial:function(t){return new J({uniforms:Ll(t,lv),vertexShader:tv,fragmentShader:av,transparent:!1,depthTest:!1,depthWrite:!1})},VertBilateralBlurMaterial:function(t){return new J({uniforms:Ll(t,lv),vertexShader:tv,fragmentShader:sv,transparent:!1,depthTest:!1,depthWrite:!1})}},hv="uniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",pv=Dp.merge([{srcL:{type:"t",value:null},srcR:{type:"t",value:null}}]);Il.prototype.set=function(t,e,r){this.position=t,this.scale=e,this.orientation=r};Ol.prototype.setup=function(t,e){this._startTime=void 0,this._endTime=void 0,this._srcView=t,this._dstView=e,this._isMoving=!1},Ol.prototype.isMoving=function(){return this._isMoving},Ol.prototype.wasStarted=function(){return void 0!==this._startTime&&void 0!==this._endTime},Ol.prototype.start=function(){this._startTime=Date.now();var t=_f.now.interpolateViews?1500:0;this._endTime=this._startTime+t,this._isMoving=!0},Ol.prototype.getCurrentView=function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var t=this.createView(),e=Date.now();if(e>this._endTime)return t=this._dstView,this._reset(),{success:!0,view:t};var r=(e-this._startTime)/(this._endTime-this._startTime);return t.position.copy(this._srcView.position),t.position.lerp(this._dstView.position,r),t.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,t.orientation.copy(this._srcView.orientation),t.orientation.slerp(this._dstView.orientation,r),{success:!0,view:t}},Ol.prototype._reset=function(){this._startTime=this._endTime=0,this._isMoving=!1},Ol.prototype.createView=function(){return new Il};var fv=new Ol,dv=_f.now.fbxprec,mv='; FBX 6.1.0 project file\n; Copyright (C) 1997-2007 Autodesk Inc. and/or its licensors.\n; All rights reserved.\n; ----------------------------------------------------\n\n FBXHeaderExtension: {\n FBXHeaderVersion: 1003\n FBXVersion: 6100\n CreationTimeStamp: {\n Version: 1000\n Year: 2015\n Month: 12\n Day: 7\n Hour: 17\n Minute: 34\n Second: 53\n Millisecond: 369\n }\n Creator: "FBX SDK/FBX Plugins build 20080212"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nreationTime: "2015-12-07 17:34:53:369"\nreator: "FBX SDK/FBX Plugins build 20080212"\n\n; Document Description\n;------------------------------------------------------------------\n\n Document: {\n Name: ""\n}\n\n; Document References\n;------------------------------------------------------------------\n\n References: {\n}\n\n; Object definitions\n;------------------------------------------------------------------\n\n Definitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "SceneInfo" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n}\n\n; Object properties\n;------------------------------------------------------------------\n\n Objects: {\n Model: "Model::Sphere01", "Mesh" {\n Version: 232\n Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "InheritType", "enum", "",1\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Lcl Translation", "Lcl Translation", "A+",-0.169204741716385,-0.507614195346832,0\n Property: "Lcl Rotation", "Lcl Rotation", "A+",0,0,0\n Property: "Lcl Scaling", "Lcl Scaling", "A+",1,1,1\n Property: "Visibility", "Visibility", "A+",1\n Property: "BBoxMin", "Vector3D", "N",0,0,0\n Property: "BBoxMax", "Vector3D", "N",0,0,0\n }\n MultiLayer: 0\n MultiTake: 1\n Shading: T\n Culling: "CullingOff"\n',gv='NodeAttributeName: "Geometry::Sphere01"\n}\nceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n Type: "UserData"\n Version: 100\n MetaData: {\n Version: 100\n Title: ""\n Subject: ""\n Author: ""\n Keywords: ""\n Revision: ""\n Comment: ""\n }\n Properties60: {\n Property: "DocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "SrcDocumentUrl", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "Original", "Compound", ""\n Property: "Original|ApplicationVendor", "KString", "", "Autodesk"\n Property: "Original|ApplicationName", "KString", "", "3ds Max"\n Property: "Original|ApplicationVersion", "KString", "", "2009.0"\n Property: "Original|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n Property: "Original|FileName", "KString", "", "D:\\depot\\MolViewer\\Assets\\models\\test1.FBX"\n Property: "LastSaved", "Compound", ""\n Property: "LastSaved|ApplicationVendor", "KString", "", "Autodesk"\n Property: "LastSaved|ApplicationName", "KString", "", "3ds Max"\n Property: "LastSaved|ApplicationVersion", "KString", "", "2009.0"\n Property: "LastSaved|DateTime_GMT", "DateTime", "", "07/12/2015 14:34:53.369"\n }\n}\nlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",2\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",1\n Property: "FrontAxisSign", "int", "",-1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",2.54\n }\n}\n}\n\n; Object relations\n;------------------------------------------------------------------\n\n Relations: {\n Model: "Model::Sphere01", "Mesh" {\n }\n SceneInfo: "SceneInfo::GlobalInfo", "UserData" {\n }\n}\n\n; Object connections\n;------------------------------------------------------------------\n\n Connections: {\n Connect: "OO", "Model::Sphere01", "Model::Scene"\n}\n\n;Object data\n;------------------------------------------------------------------\n\n ObjectData: {\n}\n;Takes and animation section\n;----------------------------------------------------\n\n Takes: {\n Current: "Take 001"\n}\n;Version 5 settings\n;------------------------------------------------------------------\n\n Version5: {\n AmbientRenderSettings: {\n Version: 101\n AmbientLightColor: 0.533333003520966,0.533333003520966,0.533333003520966,1\n }\n FogOptions: {\n FlogEnable: 0\n FogMode: 0\n FogDensity: 0.002\n FogStart: 0.3\n FogEnd: 1000\n FogColor: 1,1,1,1\n }\n Settings: {\n FrameRate: "30"\n TimeFormat: 1\n SnapOnFrames: 0\n ReferenceTimeIndex: -1\n TimeLineStartTime: 0\n TimeLineStopTime: 153953860000\n }\n RendererSetting: {\n DefaultCamera: ""\n DefaultViewingMode: 0\n }\n}\n\n',vv=null;kl.prototype.queue=[],kl.prototype.busy=!1,kl.prototype.add=function(t,e,r,n){this.queue.push([t,e,r,n]),this.busy||this.next()},kl.prototype.next=function(){var t=this.queue.shift(),e=this;t&&!e.busy&&(this.busy=!0,zl(t[0],t[1],t[2],t[3],function(){e.busy=!1,e.next()}))};ha(Kl.prototype),Kl.prototype.removeCookie=function(t){var e=this._toCount(t),r=this._getSimpleCookie(e);if(r){this._removeSimpleCookie(e),r=parseInt(r,10);for(var n=0;n0?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e,r)):i.renderer.renderDummyQuad(r),i.renderer.renderScreenQuadFromTex(r.texture,.6,n),t.uniforms.srcTex.value=r.texture,t.uniforms.srcTexSize.value.set(r.width,r.height),i.renderer.renderScreenQuad(t,n)}}(),nu.prototype.renderVolume=function(){var t=new eg.BackFacePosMaterial,e=new eg.FrontFacePosMaterial,r=(new u).makeTranslation(.5,.5,.5),n=new u;return function(i,o,a,s,c,l){var u=this._gfx,h=i.getMesh();h.rebuild(o),u.renderer.setClearColor("black",0),u.renderer.clearTarget(s),u.renderer.clearTarget(c),u.renderer.clearTarget(l),o.layers.set(Cd.LAYERS.VOLUME_BFPLANE),u.renderer.render(u.scene,o,s),o.layers.set(Cd.LAYERS.VOLUME),u.scene.overrideMaterial=t,u.renderer.render(u.scene,o,s),o.layers.set(Cd.LAYERS.VOLUME),u.scene.overrideMaterial=e,u.renderer.render(u.scene,o,c),u.scene.overrideMaterial=null,o.layers.set(Cd.LAYERS.DEFAULT),n.getInverse(h.matrixWorld),oa.prototype.uberOptions.world2colorMatrix.multiplyMatrices(r,n),this.setUberMaterialValues({colorFromPos:!0}),u.renderer.render(u.scene,o,l),this.setUberMaterialValues({colorFromPos:!1});var p=h.material;p.uniforms._BFRight.value=s.texture,p.uniforms._FFRight.value=c.texture,p.uniforms._WFFRight.value=l.texture,o.layers.set(Cd.LAYERS.VOLUME),u.renderer.render(u.scene,o,a),o.layers.set(Cd.LAYERS.DEFAULT)}}(),nu.prototype.renderWithPrepassTransparency=function(t,e){var r=this._gfx;t.layers.set(Cd.LAYERS.DEFAULT),r.renderer.render(r.scene,t,e),t.layers.set(Cd.LAYERS.PREPASS_TRANSPARENT),r.renderer.context.colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,t,e),r.renderer.context.colorMask(!0,!0,!0,!0),t.layers.set(Cd.LAYERS.TRANSPARENT),r.renderer.render(r.scene,t,e),t.layers.set(Cd.LAYERS.DEFAULT)},nu.prototype.performFXAA=function(){var t=new Pl;return function(e,r){if(void 0!==e&&void 0!==r){var n=this._gfx;n.renderer.setClearColor(_f.now.themes[_f.now.theme],1),n.renderer.clearTarget(r),t.uniforms.srcTex.value=e.texture,t.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),t.transparent=!0,n.renderer.renderScreenQuad(t,r)}}}(),nu.prototype.performAO=function(){var t=new uv.AOMaterial,e=new uv.HorBilateralBlurMaterial,r=new uv.VertBilateralBlurMaterial,n=new q(new Uint8Array([0,0,0,66,0,0,77,0,0,155,62,0,0,247,0,33,0,0,0,0,0,235,0,0,0,0,0,176,44,0,232,46,0,0,29,0,0,0,0,78,197,0,93,0,0,0,0,0]),4,4,Qh,Uh,300,Lh,Lh,Ih,Ih,1);n.needsUpdate=!0;var i=[new l(.295184,.077723,.068429),new l(-.271976,-.365221,.838363),new l(.547713,.467576,.488515),new l(.662808,-.031733,.584758),new l(-.025717,.218955,.657094),new l(-.310153,-.365223,.370701),new l(-.101407,-.006313,.747665),new l(-.769138,.360399,.086847),new l(-.271988,-.27514,.905353),new l(.09674,-.566901,.700151),new l(.562872,-.735136,.094647),new l(.379877,.359278,.190061),new l(.519064,-.023055,.405068),new l(-.301036,.114696,.088885),new l(-.282922,.598305,.487214),new l(-.181859,.25167,.679702),new l(-.191463,-.635818,.512919),new l(-.293655,.427423,.078921),new l(-.267983,.680534,.13288),new l(.139611,.319637,.477439),new l(-.352086,.31104,.653913),new l(.321032,.805279,.487345),new l(.073516,.820734,.414183),new l(-.155324,.589983,.41146),new l(.335976,.170782,.527627),new l(.46346,-.355658,.167689),new l(.222654,.59655,.769406),new l(.922138,-.04207,.147555),new l(-.72705,-.329192,.369826),new l(-.090731,.53382,.463767),new l(-.323457,-.876559,.238524),new l(-.663277,-.372384,.342856)],o=[-2,-1,0,1,2];return function(a,s,u,h,p){if(void 0!==a&&void 0!==s&&void 0!==u&&void 0!==h&&void 0!==p){var f=this._gfx;t.uniforms.diffuseTexture.value=a.texture,t.uniforms.depthTexture.value=s,t.uniforms.srcTexelSize.value.set(1/a.width,1/a.height),t.uniforms.camNearFar.value.set(f.camera.near,f.camera.far),t.uniforms.projMatrix.value=f.camera.projectionMatrix,t.uniforms.aspectRatio.value=f.camera.aspect,t.uniforms.tanHalfFOV.value=Math.tan(.5*Tp.DEG2RAD*f.camera.fov),t.uniforms.samplesKernel.value=i;var d=new l,m=new c,g=new l;f.root.matrix.decompose(d,m,g),t.uniforms.kernelRadius.value=_f.now.debug.ssaoKernelRadius*g.x,t.uniforms.depthThreshold.value=2*this._getBSphereRadius(),t.uniforms.factor.value=_f.now.debug.ssaoFactor,t.uniforms.noiseTexture.value=n,t.uniforms.noiseTexelSize.value.set(.25,.25);var v=f.scene.fog;v&&t.uniforms.fogNearFar.value.set(v.near,v.far),t.transparent=!1,f.renderer.renderScreenQuad(t,p),e.uniforms.aoMap.value=p.texture,e.uniforms.srcTexelSize.value.set(1/p.width,1/p.height),e.uniforms.depthTexture.value=s,e.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(e,h),r.uniforms.aoMap.value=h.texture,r.uniforms.diffuseTexture.value=a.texture,r.uniforms.srcTexelSize.value.set(1/h.width,1/h.height),r.uniforms.depthTexture.value=s,r.uniforms.samplesOffsets.value=o,f.renderer.renderScreenQuad(r,u)}}}(),nu.prototype.reset=function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(bv.COMPLEX),this.resetObjects(),this._gfx&&(Cd.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()},nu.prototype._resetScene=function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()},nu.prototype.resetView=function(){this._picker&&this._picker.reset(),this._setEditMode(bv.COMPLEX),this._resetScene(),this._forEachComplexVisual(function(t){t.updateSelectionMask({}),t.rebuildSelectionGeometry()})},nu.prototype.load=function(t,e){var r=this;return r._loader&&r._loader.cancel(),r.dispatchEvent({type:"load",options:e}),t instanceof File&&t.name.match(/.man$/i)?this._fileSourceAnim=tu(t):this._fileSource=tu(t),e&&e.mdFile&&(this._fileSourceAnim=e.mdFile),this.settings.now.use.multiFile||e&&e.animation||this.reset(!0),r._loader=new ki,r._loader.addEventListener("notification",function(t){r.dispatchEvent(t.slaveEvent)}),r._spinner.spin(this._container),su(t,e,r._loader,r).then(function(t){return r._loader=null,r._spinner.stop(),new Promise(function(n){t.opts.animation?(r.refreshTitle(),r._startAnimation(t.data),n(null)):(r._stopAnimation(),e&&e.keepRepsInfo||(r._opts.reps=null,r._opts._objects=null),n(r._onLoad(t.data,t.opts)))})},function(){r._loader=null,r._spinner.stop(),r.refreshTitle()})},nu.prototype.unload=function(t){this._removeVisual(t||this.getCurrentVisual())},nu.prototype._startAnimation=function(t){this._stopAnimation();var e=this,r=this._getComplexVisual();if(null!==r){try{this._frameInfo=new Sl(r.getComplex(),t,{onLoadStatusChanged:function(){e.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:e._isAnimating,isLoading:!e._frameInfo||e._frameInfo.isLoading}})},onError:function(t){e._stopAnimation(),e.logger.error(t)}})}catch(t){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")},nu.prototype._startMdAnimation=function(t,e){this._stopAnimation();var r=this,n=this._getComplexVisual();if(null!==n){try{this._frameInfo=new Sl(n.getComplex(),this.srvStreamMdFn(t,e),{onLoadStatusChanged:function(){r.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:r._isAnimating,isLoading:!r._frameInfo||r._frameInfo.isLoading}})},onError:function(t){r._stopAnimation(),r.logger.error(t)}})}catch(t){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")},nu.prototype._pauseAnimation=function(){null!==this._animInterval&&(this._isAnimating=!1,clearInterval(this._animInterval),this._animInterval=null,this._frameInfo&&this.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:this._isAnimating,isLoading:this._frameInfo.isLoading}}))},nu.prototype._continueAnimation=function(){this._isAnimating=!0;var t=1e3/_f.now.maxfps;t=Number.isNaN(t)?0:t;var e=this,r=e._gfx.pivot,n=this._getComplexVisual();n&&(n.resetSelectionMask(),n.rebuildSelectionGeometry(),this._msgAtomInfo.style.opacity=0),this._animInterval=setInterval(function(){if(e.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:e._isAnimating,isLoading:e._frameInfo.isLoading}}),e._frameInfo.frameIsReady){r.updateToFrame(e._frameInfo),e.updateObjsToFrame(e._frameInfo),e.refreshTitle(" Frame "+e._frameInfo._currFrame+" of "+e._frameInfo._framesCount+" time interval - "+e._frameInfo._timeStep);try{e._frameInfo.nextFrame()}catch(t){return e.logger.error("Error during animation"),void e._stopAnimation()}e._needRender=!0}},t)},nu.prototype._stopAnimation=function(){null!==this._animInterval&&(clearInterval(this._animInterval),this._frameInfo.disableEvents(),this._frameInfo=null,this._animInterval=null,this._fileSourceAnim=null,this.dispatchEvent({type:"mdPlayerStateChanged",state:null}))},nu.prototype._onLoad=function(t,e){var r=this._gfx,n=null;if("Complex"===t.id){var i=t;e.fileName?i.name=i.name||Jl(e.fileName).toUpperCase():e.amberFileName?i.name=i.name||Jl(e.amberFileName).toUpperCase():i.name="Dynamic "+e.fileType+" molecule",n=this._addVisual(new Vc(i.name,i)),this._curVisualName=n;var o=this.info();if(this.logger.info("Parsed "+e.fileName+" ("+o.atoms+" atoms, "+o.bonds+" bonds, "+o.residues+" residues, "+o.chains+" chains)."),wu.isNumber(this._opts.unit)&&i.setCurrentStructure(this._opts.unit),e.preset)this.srvPresetApply(e.preset);else if(_f.now.autoPreset)switch(e.fileType){case"cml":this.resetReps("small");break;case"pdb":case"mmtf":case"cif":eu(i)?this.resetReps("macro"):this.resetReps("small");break;default:this.resetReps("default")}}else"Volume"===t.id&&(this.resetEd(),n=this._onLoadEd(t));return r.camera.updateProjectionMatrix(),this._updateFog(),r.root.resetTransform(),this.resetPivot(),this.resetPan(),this._objectControls.setScale(_f.now.radiusToFit/this._getBSphereRadius()),this.resetObjects(),_f.now.autoResolution&&this._tweakResolution(),this._opts.view&&(this.view(this._opts.view),delete this._opts.view),e.error?this.dispatchEvent({type:"onParseError",error:e.error}):this.dispatchEvent({type:"onParseDone"}),this.refreshTitle(),e.convertedFile&&e.mdFile&&this._startMdAnimation(e.mdFile,e.convertedFile),n},nu.prototype.resetEd=function(){this._edLoader&&(this._edLoader.abort(),this._edLoader=null),this._removeVisual(this._getVolumeVisual()),this._needRender=!0},nu.prototype.loadEd=function(t){var e=this;this.resetEd(),(this._edLoader=qg.loaders.create(e,t,{binary:!0})).load({ready:function(t){qg.parsers.create(e,t,{fileType:"ccp4"}).parse({ready:function(t){e._onLoadEd(t)},progress:function(t){ru(e.logger,"Parsing ED",t)}})},progress:function(t){ru(e.logger,"Loading ED",t)}})},nu.prototype._onLoadEd=function(t){t.normalize();var e=new Wc("volume",t);e.getMesh().layers.set(Cd.LAYERS.VOLUME);var r=this._addVisual(e);return this._needRender=!0,r},nu.prototype._needRebuild=function(){var t=!1;return this._forEachComplexVisual(function(e){t=t||e.needsRebuild()}),t},nu.prototype.rebuildObjects=function(){var t,e,r=this,n=this._gfx,i=[];for(t=0;t0?"Bio molecule "+n:"Asymmetric unit")+")"}if(!r)throw new Error("There is no complex to change!");return r.getComplex().setCurrentStructure(t)&&this._resetScene(),""},nu.prototype.rebuild=function(){if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuild"}),this.rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual(function(e){e.needsRebuild()&&t.push(e.rebuild().then(function(){return new Promise(function(t){e.rebuildSelectionGeometry(),t()})}))});var e=this;this._spinner.spin(this._container),Promise.all(t).then(function(){e._spinner.stop(),e._needRender=!0,e.refreshTitle(),e._building=!1})}},nu.prototype.rebuildAll=function(){this._forEachComplexVisual(function(t){t.setNeedsRebuild()})},nu.prototype.refreshTitle=function(t){var e;t=void 0===t?"":t;var r=this._getComplexVisual();if(r){e=r.getComplex().name;var n=r.repGet(r.repCurrent());e+=n?" – "+n.mode.name+" Mode":""}else e=Object.keys(this._visuals).length>0?"Unknown":"No Data";e+=t,this.dispatchEvent({type:"titleChanged",data:e})},nu.prototype.setNeedRender=function(){this._needRender=!0},nu.prototype._extractRepresentation=function(){var t=this,e=[];this._forEachComplexVisual(function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<0&&(this.logger.report("New representation from selection for complexes: "+e.join(", ")),this.dispatchEvent({type:"repAdd"}))},nu.prototype.setReps=function(t){t=t||this._opts&&this._opts.reps||[],this._forEachComplexVisual(function(e){return e.resetReps(t)})},nu.prototype.applyPreset=function(t){for(var e=_f.now.presets,r=[t||_f.defaults.preset,_f.defaults.preset,Object.keys(e)[0]],n=null,i=0;!n&&i0&&t.push(e)}),1===t.length){var e=t[0].beginFragmentEdit();e&&(this._editors=[e],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(bv.FRAGMENT),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(e.isFreeRotationAllowed()),this._needRender=!0)}}},nu.prototype._applyFragmentEdit=function(){if(this._editMode===bv.FRAGMENT){this._objectControls.stop();for(var t=0;t0){if(t){t=null;break}t=r}}if(t)return t}return{objects:[],pivot:new l(0,0,0)}},nu.prototype.resetPivot=function(){var t=new et;this._forEachVisual(function(e){t.union(e.getBoundaries().boundingBox)}),t.getCenter(this._gfx.pivot.position),this._gfx.pivot.position.negate(),this.dispatchEvent({type:"transform"})},nu.prototype.setPivotResidue=function(t){var e=this._getVisualForComplex(t.getChain().getComplex());if(e){var r=this._gfx.pivot.position;if(t._controlPoint)r.copy(t._controlPoint);else{for(var n=0,i=0,o=0,a=t._atoms.length,s=0;s=5&&(e._gfxScore=1e3/r.mean()),t>0&&(e._gfxScore=.5*t),e._spinner.stop(),n()})):n()})},nu.prototype.screenshot=function(t,e){var r=this._gfx;e=e||t||r.height;var n;if((t=t||r.width)===r.width&&e===r.height)n=r.renderer.domElement.toDataURL("image/png");else{var i=r.camera.aspect,o=r.camera.fov,a=function(t){return Math.tan(Tp.degToRad(.5*t))}(r.camera.fov)*Math.min(r.width,r.height)/r.height,s=t/e;r.camera.aspect=s,r.camera.fov=function(t){return 2*Tp.radToDeg(Math.atan(t))}(a/Math.min(s,1)),r.camera.updateProjectionMatrix(),r.renderer.setSize(t,e),this._renderFrame("NONE"),n=r.renderer.domElement.toDataURL("image/png"),r.camera.aspect=i,r.camera.fov=o,r.camera.updateProjectionMatrix(),r.renderer.setSize(r.width,r.height),this._needRender=!0}return n},nu.prototype.screenshotSave=function(t,e,r){var n=this.screenshot(e,r);gf.shotDownload(n,t)},nu.profile=function(t,e,r){function n(t){var e=t.length-Math.round(.1*t.length);t.sort();for(var r=0,n=0;n0)for(var r=1e6*this._gfxScore/e,n=0;nn?(o=!1,r.preset="empty"):_f.now.preset!==_f.defaults.preset&&(r.preset=_f.now.preset);for(var a=[],s=!0,c=0,l=n;c0&&(e._objects=a),t.view&&(e.view=this.view()),t.settings){var l=this.settings.getDiffs(!1);wu.isEmpty(l)||(e.settings=l)}return e},nu.prototype.get=function(t,e){return _f.get(t,e)},nu.prototype._clipPlaneUpdateValue=function(t){var e=Math.max(this._gfx.camera.position.z-t*_f.now.draft.clipPlaneFactor,_f.now.camNear),r={clipPlaneValue:e};this._forEachComplexVisual(function(t){t.setUberOptions(r)});for(var n=0,i=this._objects.length;n2&&A.push("'"+this.terminals_[w]+"'");C=p.showPosition?"Parse error on line "+(c+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[v]||v)+"'":"Parse error on line "+(c+1)+": Unexpected "+(v==u?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(C,{text:p.match,token:this.terminals_[v]||v,line:p.yylineno,loc:m,expected:A})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+v);switch(x[0]){case 1:r.push(v),i.push(p.yytext),o.push(p.yylloc),r.push(x[1]),v=null,y?(v=y,y=null):(l=p.yyleng,s=p.yytext,c=p.yylineno,m=p.yylloc);break;case 2:if(S=this.productions_[x[1]][1],E.$=i[i.length-S],E._$={first_line:o[o.length-(S||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(S||1)].first_column,last_column:o[o.length-1].last_column},g&&(E._$.range=[o[o.length-(S||1)].range[0],o[o.length-1].range[1]]),void 0!==(b=this.performAction.apply(E,[s,l,c,f.yy,x[1],i,o].concat(h))))return b;S&&(r=r.slice(0,-1*S*2),i=i.slice(0,-1*S),o=o.slice(0,-1*S)),r.push(this.productions_[x[1]][0]),i.push(E.$),o.push(E._$),M=a[r[r.length-2]][r[r.length-1]],r.push(M);break;case 3:return!0}}return!0}},St={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)){if(e=r,n=o,this.options.backtrack_lexer){if(!1!==(t=this.test_match(r,i[o])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(t,e,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 41;case 4:return 34;case 5:return 96;case 6:case 7:return 97;case 8:return 8;case 9:return 6;case 10:return 100;case 11:return 7;case 12:return 9;case 13:return 79;case 14:return 81;case 15:return 12;case 16:return 14;case 17:return 16;case 18:return 17;case 19:return 18;case 20:return 19;case 21:return 82;case 22:return 84;case 23:return 22;case 24:return 24;case 25:return 25;case 26:return 26;case 27:return 29;case 28:return 33;case 29:return 32;case 30:return 85;case 31:return 86;case 32:return 36;case 33:return 40;case 34:return 42;case 35:return 51;case 36:return 53;case 37:return 54;case 38:return 44;case 39:return 46;case 40:return 43;case 41:return 55;case 42:return 57;case 43:return 58;case 44:return 61;case 45:return 62;case 46:return 63;case 47:return 65;case 48:return 66;case 49:return 67;case 50:return 68;case 51:return 69;case 52:return 70;case 53:return 71;case 54:return 73;case 55:return 72;case 56:case 57:return 90;case 58:case 59:return 91;case 60:case 61:case 62:return 93;case 63:return 30;case 64:return 35;case 65:return 77;case 66:return 74;case 67:return 78;case 68:return 76;case 69:return e.yytext=e.yytext.substr(1,e.yyleng-2),13;case 70:return 37;case 71:return 5;case 72:return 102;case 73:return 103;case 74:return"\\";case 75:return 27;case 76:return 59;case 77:return 28;case 78:return 56;case 79:return 75}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:script\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"([^"]*)"|'([^']*)')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79],inclusive:!0}}};return wt.lexer=St,t.prototype=wt,wt.Parser=t,new t}();void 0!==t&&(r.parser=n,r.Parser=n.Parser,r.parse=function(){return n.parse.apply(n,arguments)},r.main=function(t){t[1]||process.exit(1);var e=Zf.readFileSync(Kf.normalize(t[1]),"utf8");return r.parser.parse(e)},t.main===e&&r.main(process.argv.slice(1)))}).parser,Av={$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = #aromatic radius"," atom = #atom radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},CA:{$help:[" Cartoon"," arrow = #arrow size"," depth = #depth of surface"," heightSegmentsRatio = "," radius = #tube radius"," tension = #"," width = #secondary width\n"]},LN:{$help:[" Lines"," atom = #atom radius"," chunkarom = "," multibond = #use multibond"," showarom = #show aromatic"," offsarom = \n"]},LC:{$help:[" Licorice"," aromrad = #aromatic radius"," bond = #bond radius"," multibond = #use multibond"," showarom = #show aromatic"," space = #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = "," radius = #tube radius"," tension = \n"]},SA:{$help:[" Surface"," zClip = #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = "," scale = "," wireframe = "," zClip = #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = #clip z plane\n"]},TX:{$help:[" Text mode",' template = string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = {"left", "right", "center"}',' verticalAlign = {"top", "bottom", "middle"}'," dx = #offset along x"," dy = #offset along y"," dz = #offset along z"," fg = #text color modificator"," could be keyword, named color or hex"," fg = #back color modificator"," could be keyword, named color or hex"," showBg = #if set show background"," plate under text"]}},Ev={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = #RGB->HEX->dec\n"],color:{$help:Object.keys(jm.get(_f.now.palette).namedColors).sort().join("\n")}}},Cv={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Tv={$help:["Short (packed) representation description as a set of variables"," s="," selector property"," m=[!:[,...]]"," render mode property"," c=[!:[,...]]"," color mode property"," mt="," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Av,c:Ev,mt:Cv},Pv={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (|)"],modes:Av,colorers:Ev},Lv={$help:["help (| )","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (||-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [] []"," Add new item to representation set with"," default or params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Tv},rep:{$help:["rep [|] []"," set current representation by name or index"," edit current representation by "],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Tv},remove:{$help:["remove (|)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector "," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode [=...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Av},color:{$help:["color [=...]"," set colorer and apply parameters to current representation"],COLORER_ID:Ev},material:{$help:["material "," set material to current representation"],MATERIAL_ID:Cv},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s||]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," | show only current representation"]},hide:{$help:["hide (|)","Hide representation referenced in args"]},show:{$help:["show (|)","Show representation referenced in args"]},get:{$help:["get ","Print value"," - path to option use get.PARAMETER to get more info"],PARAMETER:Pv},set:{$help:["set ","Set with "," - path to option use set.PARAMETER to get more info"],PARAMETER:Pv},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset []","Reset current representation or set preset to "],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit []","Change current biological structure view. Zero value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view []","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [] [(x|y|z) []]...","Rotate scene"]},scale:{$help:["scale ","Scale scene"]},select:{$help:["select [as ]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within of as ","Build within named selector"," DISTANCE "," SELECTOR_STRING "," SELECTOR_NAME "]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [ []]","Make a screenshot of the scene"," WIDTH in pixels"," HEIGHT in pixels, equal to WIDTH by default"]},line:{$help:["line [=]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj ","Remove scene object by its index. Indices could be obtained by command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]},file_list:{$help:["file_list [(|FILE_NAME)] [-f=]","Report registered files on server or presets in file if defined FILE_ID or FILE_NAME"," also you can use -f flag for fast search"," entity by starting part of name"]},file_register:{$help:["file_register ","Try register current opened file to server"]},file_delete:{$help:["file_delete (|FILE_NAME) [-f]","Delete file from server"," if -f not set then file will be deleted"," only when it has not got any presets in it"," if -f set then file will be deleted anyway"]},preset_add:{$help:["preset_add ","Create new preset from current viewer state"," to current opened file on server"]},preset_delete:{$help:["preset_delete (|)","Delete preset from server"]},preset_update:{$help:["preset_update <(|)","Update due the current viewer state"]},preset_rename:{$help:["preset_rename (|) ","Rename preset"]},preset_open:{$help:["preset_open (|)","Load preset"]},create_scenario:{$help:["create_scenario "," Creates scenario context for future work with them"]},reset_scenario:{$help:["reset_scenario"," Clear current scenario context"]},add_scenario_item:{$help:["add_scenario_item"," pdb=( | )"," prst=(|)"," delay="," desc=\n"," Add item to context and update scenario on server"," Pay attention that order of arguments is important"]},delete_scenario:{$help:["delete_scenario (|)"," Deletes scenario from server"]},list_scenario:{$help:["list_scenario [-e [|]]"," Report scenario list, when -e is set reports expanded"," If set -e then reports only requested scenario"]}},Rv=function(){function t(){bf(this,t)}return wf(t,[{key:"createSelectorFromNode",value:function(t){return hu(t)}}]),t}(),Nv=nu.chem.selectors,Iv=nu.modes,Ov=nu.colorers,Dv=nu.materials,zv=nu.palettes,kv=nu.options,Fv=nu.settings,Uv=function(){var t=new pu;return function(){return t}}();fu.prototype.get=function(t){return this.representationMap[t]||this.representationID[t]||""},fu.prototype.add=function(t,e){if(void 0!==e){if(this.representationMap.hasOwnProperty(t))return"This name has already existed, registered without name";this.representationMap[t.toString()]=e,this.representationID[e]=t.toString()}return"Representation "+t+" successfully added"},fu.prototype.remove=function(t){t&&this.representationID.hasOwnProperty(t)&&(delete this.representationMap[this.representationID[t]],delete this.representationID[t]);var e=Object.keys(this.representationID).sort();for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];n>t&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}},fu.prototype.clear=function(){this.representationMap={},this.representationID={}};var Bv=new fu;du.prototype.list=function(t,e,r){var n="";if(t&&void 0!==e&&(void 0===r||"-e"===r))for(var i=t.repCount(),o=0;o"===s?"":s)+"\n",void 0!==n&&(i+=' selection : "'+l+'"\n',i+=" mode : ("+c.id+"), "+c.name+"\n",i+=" colorer : ("+u.id+"), "+u.name+"\n",i+=" material : ("+h.id+"), "+h.name+"\n"),i},du.prototype.listSelector=function(t,e){var r="";for(var n in e)e.hasOwnProperty(n)&&(r+=n+' : "'+e[n]+'"\n');return r},du.prototype.listObjs=function(t){var e=t._objects;if(!e||!Array.isArray(e)||0===e.length)return"There are no objects on the scene";for(var r=[],n=0,i=e.length;n0)throw{message:t+' must be a "'+xf(wu.get(Fv.defaults,t))+'"'}}return e};var Vv=new du;gu.prototype.addItem=function(t,e){this.scenarioId=t,this.data.push(e)},yu.prototype.requestScenarioID=function(t,e,r,n){var i=this;t.awaitWhileCMDisInProcess(),void 0!==e&&t.srvScenarioList(function(o){if(o instanceof Array){var a=wu.filter(o,function(t){return void 0!==t.name&&t.name.toLowerCase()===e.toLowerCase()||t.id===Number(e)});a.length<1?(void 0!==n&&n("File not found"),i.finish(t)):a.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(a[0].id):i.finish(t)}else i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)})},yu.prototype.requestPdbID=function(t,e,r,n){var i=this,o=e.split("/");if(t.awaitWhileCMDisInProcess(),1!==o.length)void 0!==n&&n("Path can contain only file name or id"),i.finish(t);else{var a=Number(o[0]);Number.isNaN(a)?t.srvTopologyFind(o[0],function(e){e instanceof Array?e.length<1?(void 0!==n&&n("File not found"),i.finish(t)):e.length>1?(void 0!==n&&n("There are two or more files, please specify one by file_id"),i.finish(t)):void 0!==r?r(e[0].id):i.finish(t):i.finish(t)},function(e){void 0!==e&&void 0!==n&&n(e),i.finish(t)}):r(a)}},yu.prototype.requestPresetId=function(t,e,r,n){function i(e){void 0!==e&&void 0!==n&&n(e),a.finish(t)}function o(e){if(e instanceof Array){var i=wu.filter(e,function(t){return t.name.toLowerCase()===s[1].toLowerCase()||t.id===Number(s[1])});i.length<1?(void 0!==n&&n("Preset not found"),a.finish(t)):i.length>1?(void 0!==n&&n("There are two or more presets, please specify one by preset_id"),a.finish(t)):void 0!==r?r(i[0].id):a.finish(t)}else a.finish(t)}var a=this,s=e.split("/");t.awaitWhileCMDisInProcess(),2!==s.length?(void 0!==n&&n("Path can has 2 levels only (pdb/preset)"),a.finish(t)):this.requestPdbID(t,s[0],function(e){t.srvPresetList(e,o,i)},i)},yu.prototype.createScenario=function(t){this.scenarioContext=new vu(t)},yu.prototype.resetScenario=function(){this.scenarioContext=new vu},yu.prototype.deleteScenario=function(t,e,r,n){function i(r){void 0!==r&&e(r),s.finish(t)}function o(e){void 0!==e&&r(e),s.finish(t)}function a(e){t.srvScenarioDelete(e,i,o),s.finish(t)}var s=this;this.init(t,e),t.awaitWhileCMDisInProcess(),"number"==typeof n?a(n):this.requestScenarioID(t,n,a,o)},yu.prototype.listScenario=function(t,e,r,n){var i=this;this.init(t,e),t.awaitWhileCMDisInProcess(),t.srvScenarioList(function(r){if(r instanceof Array){for(var o="",a=0,s=r.length;a"),void o.finish(t);if(7!==arguments.length)return 5===arguments.length?(r("not supported now"),void o.finish(t)):(r("internal interpreter error"),void o.finish(t));var s=arguments[3],c=arguments[4],l=arguments[5],u=arguments[6];if(wu.isString(s))this.requestPdbID(t,s,function(t){t>=0&&(a[3]=t,o.addScenarioItem.apply(o,a))},i);else if(wu.isString(c))this.requestPresetId(t,s+"/"+c,function(t){t>=0&&(a[4]=t,o.addScenarioItem.apply(o,a))},i);else{if("number"!=typeof s||"number"!=typeof c)return i("Internal error"),void o.finish(t);!function(e,r,a,s){o.scenarioContext.script.addItem(o.scenarioContext.id,new mu(e,r,a,s)),t.srvScenarioAdd(o.scenarioContext.id,o.scenarioContext.name,JSON.stringify(o.scenarioContext.script),n,i)}(s,c,l,u)}},yu.prototype.init=function(t,e){var r=this;this.isOnApllyPresetEventInitialized||(t.addEventListener("presetApplyFinished",function(){r.finish(t),void 0!==e&&e("Preset applied")}),this.isOnApllyPresetEventInitialized=!0)},yu.prototype.finish=function(t){t.finishAwaitingCMDInProcess()},yu.prototype.fileList=function(t,e,r,n,i){function o(r){if(void 0!==r)for(var n=0;n1?(r("There are two or more presets, please specify one by preset_id"),l.finish(t)):void 0===o?i.call(t,n[0].id,a,c):i.call(t,n[0].id,o,a,c)}else l.finish(t)}function c(e){void 0!==e&&r(e),l.finish(t)}var l=this;this.init(t,e),t.awaitWhileCMDisInProcess();var u=n.split("/");2!==u.length?(r("Path can has 2 levels only (pdb/preset)"),l.finish(t)):t.srvTopologyFind(u[0],function(e){e instanceof Array?e.length<1?(r("File not found"),l.finish(t)):e.length>1?(r("There are two or more files, please specify one by file_id"),l.finish(t)):t.srvPresetList(e[0].id,s,c):l.finish(t)},c)},yu.prototype.coroutineWithFileName=function(t,e,r,n,i){function o(r){void 0!==r&&e(r),s.finish(t)}function a(e){void 0!==e&&r(e),s.finish(t)}var s=this,c=arguments;this.init(t),t.awaitWhileCMDisInProcess();var l=n.split("/");1!==l.length?(r("Path can contain only file name or id"),s.finish(t)):t.srvTopologyFind(l[0],function(e){if(e instanceof Array)if(e.length<1)r("File not found");else if(e.length>1)r("There are two or more files, please specify one by file_id");else switch(c.length){case 5:i.call(t,e[0].id,o,a);break;case 6:i.call(t,e[0].id,c[5],o,a);break;case 9:i.call(c[5],c[6],c[7],c[8],e[0].id);break;case 10:i.call(c[5],c[6],c[7],c[8],e[0].id,c[9]);break;default:s.finish(t)}s.finish(t)},a)};var jv=new yu;xu.prototype.append=function(t){var e=this._values;return e[e.length]=t,this},xu.prototype.remove=function(t){var e=this._values,r=e.indexOf(t);return r>=0&&e.splice(r,1),this},xu.prototype.toJSO=function(t,e,r){for(var n={},i=this._values,o=0,a=i.length;o0},nu.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var t=this.cmdQueue.shift(),e={};e.success=!1;try{Mv.parse(t),e.success=!0}catch(t){e.error=t.message,Mv.yy.error(e.error),this.finishAwaitingCMDInProcess()}return e}return""},nu.JSONConverter=Rv,Mv.yy=Gv,Mv.yy.parseError=Mv.parseError,nu}); //# sourceMappingURL=Miew.min.js.map diff --git a/dist/Miew.module.js b/dist/Miew.module.js index bf3a8540..77934926 100644 --- a/dist/Miew.module.js +++ b/dist/Miew.module.js @@ -1,4 +1,4 @@ -/** Miew - 3D Molecular Viewer v0.7.3 Copyright (c) 2015-2017 EPAM Systems, Inc. */ +/** Miew - 3D Molecular Viewer v0.7.4 Copyright (c) 2015-2017 EPAM Systems, Inc. */ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -69114,9 +69114,22 @@ RCGroup.prototype.getSubset = function (mask, innerOnly) { return totalSubset; }; -var vertexShader = "precision mediump float;\r\nprecision mediump int;\r\n\r\nfloat INSTANCED_SPRITE_OVERSCALE = 1.3;\r\n\r\nattribute vec3 normal;\r\nvarying vec3 vNormal;\r\n#ifdef THICK_LINE\r\n attribute vec4 position; // W contains vert pos or neg offset\r\n#else\r\n attribute vec3 position;\r\n#endif\r\nvarying vec3 vPosition;\r\n\r\nvarying vec3 vWorldPosition;\r\nvarying vec3 vViewPosition;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n attribute float alphaColor;\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n varying vec2 vUv;\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n varying vec4 instOffset;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\nuniform mat4 projMatrixInv; // TODO move to thick line\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n vec3 objectNormal = vec3( normal );\r\n#ifdef INSTANCED_MATRIX\r\n vec3 transformedNormal = vec3(\r\n dot(objectNormal, matVector1.xyz),\r\n dot(objectNormal, matVector2.xyz),\r\n dot(objectNormal, matVector3.xyz));\r\n transformedNormal = normalMatrix * transformedNormal;\r\n#else\r\n vec3 transformedNormal = normalMatrix * objectNormal;\r\n#endif\r\n vNormal = normalize(transformedNormal);\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n instOffset = offset;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n spritePosEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = spritePosEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n spritePosEye.w = offset.w * scale;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n spritePosEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n spritePosEye.w = 1.0;\r\n\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n vec2 spriteSize = INSTANCED_SPRITE_OVERSCALE * abs(spritePosEye.z) *\r\n (spriteSizeScreen + 2.0 * rad / minZ);\r\n\r\n mvPosition = spritePosEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n vUv = uv;\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n"; +var vertexShader = "float INSTANCED_SPRITE_OVERSCALE = 1.3;\r\n\r\nattribute vec3 normal;\r\nvarying vec3 vNormal;\r\n#ifdef THICK_LINE\r\n attribute vec4 position; // W contains vert pos or neg offset\r\n#else\r\n attribute vec3 position;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition;\r\nvarying vec3 vViewPosition;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n attribute float alphaColor;\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n varying vec2 vUv;\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n varying vec4 instOffset;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\nuniform mat4 projMatrixInv; // TODO move to thick line\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n vec3 objectNormal = vec3( normal );\r\n#ifdef INSTANCED_MATRIX\r\n vec3 transformedNormal = vec3(\r\n dot(objectNormal, matVector1.xyz),\r\n dot(objectNormal, matVector2.xyz),\r\n dot(objectNormal, matVector3.xyz));\r\n transformedNormal = normalMatrix * transformedNormal;\r\n#else\r\n vec3 transformedNormal = normalMatrix * objectNormal;\r\n#endif\r\n vNormal = normalize(transformedNormal);\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n instOffset = offset;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n spritePosEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = spritePosEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n spritePosEye.w = offset.w * scale;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n spritePosEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n spritePosEye.w = 1.0;\r\n\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n vec2 spriteSize = INSTANCED_SPRITE_OVERSCALE * abs(spritePosEye.z) *\r\n (spriteSizeScreen + 2.0 * rad / minZ);\r\n\r\n mvPosition = spritePosEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n vUv = uv;\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n"; -var fragmentShader = "precision mediump float;\r\nprecision mediump int;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n varying vec2 vUv;\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\nvarying vec3 vNormal;\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n uniform mat4 projectionMatrix;\r\n varying vec4 spritePosEye;\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 instOffset;\r\n\r\n float intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_sphere_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into sphere local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = normalize(v.xyz);\r\n\r\n return intersect_ray_sphere(origin, ray, point);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n float intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n float halfHeight = 0.5;\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_cylinder_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into cylinder local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Lighting ////////////////////////////////////////////////\r\n\r\n#if NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n uniform vec3 ambientLightColor;\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n // use loop for number\r\n #if NUM_DIR_LIGHTS > 1\r\n for (int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n RE_Direct_BlinnPhong(directionalLights[i], geometry, material, reflectedLight);\r\n #else\r\n RE_Direct_BlinnPhong(directionalLights[0], geometry, material, reflectedLight);\r\n #endif\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n #if NUM_DIR_LIGHTS > 1\r\n }\r\n #endif\r\n\r\n return reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (get_sphere_point(-vViewPosition, p) < 0.0) discard;\r\n pixelPosWorld = modelMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n // pixelPosEye = modelViewMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += instOffset.w *\r\n (modelViewMatrix[0][2] * p.x +\r\n modelViewMatrix[1][2] * p.y +\r\n modelViewMatrix[2][2] * p.z);\r\n normal = normalize(normalMatrix * p);\r\n }\r\n\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (get_cylinder_point(-vViewPosition, p) < 0.0) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n#else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n#endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n#ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n#endif\r\n\r\n// transparency prepass writes only z, so we don't need to calc the color\r\n#ifdef PREPASS_TRANSP\r\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n#endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n#endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n#ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n#else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n#endif\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n #ifdef DOUBLE_SIDED\r\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #else\r\n float flipNormal = 1.0;\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n#endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n GeometricContext geometry = GeometricContext(normal, normalize( vViewPosition ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material);\r\n#else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n gl_FragColor = world2colorMatrix * pixelPosWorld;\r\n#else\r\n #ifdef OVERRIDE_COLOR\r\n gl_FragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float fogFactor = smoothstep( fogNear, fogFar, vViewPosition.z );\r\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n#endif\r\n}\r\n"; +var fragmentShader = "#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n varying vec2 vUv;\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\nvarying vec3 vNormal;\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n uniform mat4 projectionMatrix;\r\n varying vec4 spritePosEye;\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 instOffset;\r\n\r\n float intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_sphere_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into sphere local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = normalize(v.xyz);\r\n\r\n return intersect_ray_sphere(origin, ray, point);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n float intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return -1.0;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point\r\n float halfHeight = 0.5;\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n return t1;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n return t2;\r\n }\r\n\r\n return -1.0;\r\n }\r\n\r\n float get_cylinder_point(in vec3 pixelPosEye, out vec3 point) {\r\n // transform camera pos into cylinder local coords\r\n vec4 v = invModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\r\n vec3 origin = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n\r\n // transform (camera -> pixel) ray into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n vec3 ray = vec3(\r\n dot(v, invmatVec1),\r\n dot(v, invmatVec2),\r\n dot(v, invmatVec3));\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Lighting ////////////////////////////////////////////////\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n uniform vec3 ambientLightColor;\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n // use loop for number\r\n #if NUM_DIR_LIGHTS > 1\r\n for (int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n RE_Direct_BlinnPhong(directionalLights[i], geometry, material, reflectedLight);\r\n #else\r\n RE_Direct_BlinnPhong(directionalLights[0], geometry, material, reflectedLight);\r\n #endif\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n #if NUM_DIR_LIGHTS > 1\r\n }\r\n #endif\r\n\r\n return reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (get_sphere_point(-vViewPosition, p) < 0.0) discard;\r\n pixelPosWorld = modelMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n // pixelPosEye = modelViewMatrix * vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += instOffset.w *\r\n (modelViewMatrix[0][2] * p.x +\r\n modelViewMatrix[1][2] * p.y +\r\n modelViewMatrix[2][2] * p.z);\r\n normal = normalize(normalMatrix * p);\r\n }\r\n\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (get_cylinder_point(-vViewPosition, p) < 0.0) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n#else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n#endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n#ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n#endif\r\n\r\n// transparency prepass writes only z, so we don't need to calc the color\r\n#ifdef PREPASS_TRANSP\r\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n#endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n#endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n#ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n#else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n#endif\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n #ifdef DOUBLE_SIDED\r\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\r\n #else\r\n float flipNormal = 1.0;\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n#endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n GeometricContext geometry = GeometricContext(normal, normalize( vViewPosition ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material);\r\n#else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n gl_FragColor = world2colorMatrix * pixelPosWorld;\r\n#else\r\n #ifdef OVERRIDE_COLOR\r\n gl_FragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n gl_FragColor = vec4(outgoingLight, diffuseColor.a);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float fogFactor = smoothstep( fogNear, fogFar, vViewPosition.z );\r\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n#endif\r\n}\r\n"; + +var capabilities = { + + precision: 'mediump', + + /** + * + * @param {THREE.WebGLRenderer} renderer + */ + init: function init(renderer) { + this.precision = renderer.capabilities.getMaxPrecision('highp'); + } +}; /* eslint-disable no-magic-numbers */ /* eslint-disable guard-for-in */ @@ -69185,8 +69198,8 @@ function UberMaterial(params) { // set default values RawShaderMaterial.prototype.setValues.call(this, { uniforms: UniformsUtils.clone(defaultUniforms), - vertexShader: vertexShader, - fragmentShader: fragmentShader, + vertexShader: this.precisionString() + vertexShader, + fragmentShader: this.precisionString() + fragmentShader, lights: true, fog: true, side: DoubleSide @@ -69198,6 +69211,12 @@ function UberMaterial(params) { UberMaterial.prototype = Object.create(RawShaderMaterial.prototype); UberMaterial.prototype.constructor = UberMaterial; +UberMaterial.prototype.precisionString = function () { + var precision = capabilities.precision; + var str = 'precision ' + precision + ' float;\n' + 'precision ' + precision + ' int;\n\n'; + return str; +}; + // properties that convert to uniforms UberMaterial.prototype.uberOptions = { diffuse: new Color(0xffffff), // used in phong lighting @@ -77574,6 +77593,14 @@ var exports$1 = /** @alias module:gfx/modes */{ */ list: modeList, + /** + * The list of mode descriptions. + * @type {Array<{id:string, name:string}>} + */ + descriptions: lodash.map(modeList, function (m) { + return lodash.pick(m.prototype, ['id', 'name']); + }), + /** * The mode constructor one can use if he doesn't care (the default one). * @type {function(new:Mode)} @@ -77969,8 +77996,13 @@ palette$1.chainColors = [ 0xFFB22222]; palette$1.secondaryColors = { - 'helix': { 1: 0xFF0080, 5: 0xA00080 }, + 'helix': { + 1: 0xFF0080, // RH alpha + 3: 0x600080, // RH pi + 5: 0xA00080 // RH 3-10 + }, 'strand': 0xFFC800, + 'turn': 0x6080FF, 'dna': 0xAE00FE, 'rna': 0xFD0162 }; @@ -78519,6 +78551,14 @@ var exports$2 = /** @alias module:gfx/colorers */{ */ list: colorerList, + /** + * The list of colorer descriptions. + * @type {Array<{id:string, name:string}>} + */ + descriptions: lodash.map(colorerList, function (m) { + return lodash.pick(m.prototype, ['id', 'name']); + }), + /** * The colorer constructor one can use if he doesn't care (the default one). * @type {Function} @@ -78638,6 +78678,10 @@ for (var i$2 = 0, n$1 = materialList.length; i$2 < n$1; ++i$2) { var materials = { list: materialList, + descriptions: lodash.map(materialList, function (m) { + return lodash.pick(m, ['id', 'name']); + }), + any: materialDict[settings.now.presets.default.material] || materialList[0], get: function get(id) { @@ -80181,7 +80225,7 @@ VolumeMesh.prototype._updateVertices = function () { var i; var norm = this.clipPlane.normal; - var D = -norm.dot(this.clipPlane.constant); + var D = this.clipPlane.constant; var vert = this.vertices; var size = this.size; @@ -80282,11 +80326,13 @@ VolumeMesh.prototype._updateVertices = function () { this.faces[6] = face; var diff = new Vector3(); + var coplanarPoint = new Vector3(); + this.clipPlane.coplanarPoint(coplanarPoint); for (i = 0; i < vert.length; ++i) { this.cullFlag[i] = false; if (i < 8) { // corners should be culled by clipping plane - diff.subVectors(vert[i], this.clipPlane.constant); + diff.subVectors(vert[i], coplanarPoint); this.cullFlag[i] = norm.dot(diff) >= 0.0; } else if (i < 8 + face.indices.length) { // cross section vertices don't get culled @@ -80454,26 +80500,41 @@ VolumeMesh.prototype.setDataSource = function (dataSource) { bbox.getCenter(this.position); }; -VolumeMesh.prototype.rebuild = function (camera) { +VolumeMesh.prototype.rebuild = function () { + var nearClipPlaneOffset = 0.2; + var pos = new Vector3(); + var norm = new Vector3(); + var norm4D = new Vector4(); + var matrixWorldToLocal = new Matrix4(); + var clipPlane = new Plane(); - // get clip plane in local space - var norm = camera.getWorldDirection(); - var pos = camera.getWorldPosition(); - pos.addScaledVector(norm, camera.near + nearClipPlaneOffset); - this.worldToLocal(pos); - this.worldToLocal(norm); - norm.normalize(); + return function (camera) { - var clipPlane = new Plane(norm, pos); + // get clip plane in local space + camera.getWorldDirection(norm); + camera.getWorldPosition(pos); + pos.addScaledVector(norm, camera.near + nearClipPlaneOffset); - if (!this.clipPlane.equals(clipPlane)) { - this.clipPlane = clipPlane; + // transform pos to local CS + matrixWorldToLocal.getInverse(this.matrixWorld); + pos.applyMatrix4(matrixWorldToLocal); - this._updateVertices(); - this._updateIndices(); - } -}; + // transform norm to local CS + norm4D.set(norm.x, norm.y, norm.z, 0.0); // NOTE: use homogeneous norm for proper transformation + norm4D.applyMatrix4(matrixWorldToLocal); + norm.copy(norm4D); + norm.normalize(); + + clipPlane.setFromNormalAndCoplanarPoint(norm, pos); + + if (!this.clipPlane.equals(clipPlane)) { + this.clipPlane = clipPlane.clone(); + this._updateVertices(); + this._updateIndices(); + } + }; +}(); function VolumeVisual(name, dataSource) { Visual.call(this, name, dataSource); @@ -86204,7 +86265,7 @@ Cookies.prototype._exists = function (key) { return document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)')); }; -/* global "0.7.3":false */ +/* global "0.7.4":false */ ////////////////////////////////////////////////////////////////////////////// @@ -86531,6 +86592,7 @@ Miew$1.prototype._initGfx = function () { gfx.renderer2d = new CSS2DRenderer(); gfx.renderer = new WebGLRenderer(webGLOptions); + capabilities.init(gfx.renderer); // z-sprites and ambient occlusion possibility if (!gfx.renderer.getContext().getExtension('EXT_frag_depth')) { @@ -88451,6 +88513,8 @@ Miew$1.prototype._onKeyDown = function (event) { } break; case 'S'.charCodeAt(0): + event.preventDefault(); + event.stopPropagation(); settings.now.ao = !settings.now.ao; this._needRender = true; break; @@ -88690,6 +88754,14 @@ Miew$1.prototype.benchmarkGfx = function (force) { Miew$1.prototype.screenshot = function (width, height) { var gfx = this._gfx; + function Fov2Tan(fov) { + return Math.tan(_Math.degToRad(0.5 * fov)); + } + + function Tan2Fov(tan) { + return _Math.radToDeg(Math.atan(tan)) * 2.0; + } + height = height || width || gfx.height; width = width || gfx.width; @@ -88700,17 +88772,19 @@ Miew$1.prototype.screenshot = function (width, height) { screenshotURI = gfx.renderer.domElement.toDataURL('image/png'); } else { - var originalAspect = gfx.width / gfx.height; + var originalAspect = gfx.camera.aspect; var originalFov = gfx.camera.fov; + var originalTanFov2 = Fov2Tan(gfx.camera.fov); // screenshot should contain the principal area of interest (a centered square touching screen sides) var areaOfInterestSize = Math.min(gfx.width, gfx.height); - var areaOfInterestFov = originalFov * areaOfInterestSize / gfx.height; + //var areaOfInterestFov = originalFov * areaOfInterestSize / gfx.height; + var areaOfInterestTanFov2 = originalTanFov2 * areaOfInterestSize / gfx.height; // set appropriate camera aspect & FOV var shotAspect = width / height; gfx.camera.aspect = shotAspect; - gfx.camera.fov = areaOfInterestFov / Math.min(shotAspect, 1.0); + gfx.camera.fov = Tan2Fov(areaOfInterestTanFov2 / Math.min(shotAspect, 1.0)); gfx.camera.updateProjectionMatrix(); // resize canvas to the required size of screenshot @@ -89740,7 +89814,7 @@ function load(file, loadOptions, master, context) { //////////////////////////////////////////////////////////////////////////// // Additional exports -Miew$1.prototype.VERSION = typeof "0.7.3" !== 'undefined' && "0.7.3" || '0.0.0-dev'; +Miew$1.prototype.VERSION = typeof "0.7.4" !== 'undefined' && "0.7.4" || '0.0.0-dev'; // Miew.prototype.debugTracer = new utils.DebugTracer(Miew.prototype); lodash.assign(Miew$1, /** @lends Miew */{ @@ -89878,7 +89952,7 @@ case 4: this.$ = yy.miew.rebuild(); break; case 5: -this.$ = yy.miew.rebuildAll(); +this.$ = yy.miew.rebuildAll(); yy.miew.rebuild(); break; case 6: this.$ = yy.echo(yy.utils.help().toString()); @@ -91250,28 +91324,26 @@ CLIUtils.prototype.list = function (miew, repMap, key) { CLIUtils.prototype.listRep = function (miew, repMap, repIndex, key) { var ret = ''; - var opts = miew.rep(repIndex); + var rep = miew.repGet(repIndex); + if (!rep) { + logger.warn('Rep ' + repIndex + ' does not exist!'); + return ret; + } var index = repIndex; var repName = repMap.get(index); - var modeId = opts.mode instanceof Array ? opts.mode[0] : opts.mode; + var mode = rep.mode; + var selectionStr = rep.selectorString; + var colorer = rep.colorer; + var material = rep.materialPreset; - ret += '#' + index + ' : ' + modes$1.get(modeId).name + (repName === '' ? '' : repName) + '\n'; + ret += '#' + index + ' : ' + mode.name + (repName === '' ? '' : repName) + '\n'; if (key !== undefined) { - var selectionStr = opts.selector; - if (selectionStr instanceof Array) { - var converter = new JSONtoSelectorConverter(); - selectionStr = converter.createSelectorFromNode(selectionStr); - } - - var colorerId = opts.colorer instanceof Array ? opts.colorer[0] : opts.colorer; - var materialId = opts.material; - ret += ' selection : "' + selectionStr + '"\n'; - ret += ' mode : (' + modeId + '), ' + modes$1.get(modeId).name + '\n'; - ret += ' colorer : (' + colorerId + '), ' + colorers$1.get(colorerId).name + '\n'; - ret += ' material : (' + materialId + '), ' + materials$1.get(materialId).name + '\n'; + ret += ' mode : (' + mode.id + '), ' + mode.name + '\n'; + ret += ' colorer : (' + colorer.id + '), ' + colorer.name + '\n'; + ret += ' material : (' + material.id + '), ' + material.name + '\n'; } return ret; diff --git a/package.json b/package.json index de2fdf4b..b9124ccf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miew", - "version": "0.7.3", + "version": "0.7.4", "description": "Miew - 3D Molecular Viewer", "author": "EPAM Systems, Inc.", "main": "dist/Miew.js", diff --git a/sonar-project.properties b/sonar-project.properties index 2a03aa5e..137058e1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=epam:miew sonar.projectName=Miew - 3D Molecular Viewer -sonar.projectVersion=0.7.3 +sonar.projectVersion=0.7.4 sonar.links.homepage=https://github.com/epam/miew sonar.links.ci=https://travis-ci.org/epam/miew